From 3082ee6bf092482074b26a5bbf34b3e417930c59 Mon Sep 17 00:00:00 2001 From: Mariusz Drost Date: Fri, 31 Jan 2020 12:25:10 +0000 Subject: l4p/tcp_ofo: ofo and loss tests merge Addition of tests for packets that are out of order or lost that are executed on a single machine (with use of tap interface). Added tests are merged into existing test suite which runs on local/remote machine. Choice of mode is done with ETH_DEV variable. Signed-off-by: Mariusz Drost Change-Id: I766ebda215310342d9dc1edf71bc3667648fdeff --- examples/l4fwd/test/config.sh | 342 +++++++++++++++++++++++------------ examples/l4fwd/test/example_env_vars | 15 +- examples/l4fwd/test/nctxrx.sh | 110 ++++++----- examples/l4fwd/test/run_test.sh | 14 +- 4 files changed, 315 insertions(+), 166 deletions(-) diff --git a/examples/l4fwd/test/config.sh b/examples/l4fwd/test/config.sh index fef8fda..eeb9476 100644 --- a/examples/l4fwd/test/config.sh +++ b/examples/l4fwd/test/config.sh @@ -9,17 +9,28 @@ DPDK_PORT=0 TCP_PORT=6000 # local interface addresses to set -LOCAL_IPV4=192.168.1.60 -LOCAL_IPV6=fd12:3456:789a:0001:0000:0000:0000:0060 +L4FWD_IPV4=192.168.2.60 +L4FWD_IPV6=fd12:3456:789a:0002:0000:0000:0000:0060 # remote interface addresses to set -REMOTE_IPV4=192.168.1.64 -REMOTE_IPV6=fd12:3456:789a:0001:0000:0000:0000:0064 +LINUX_IPV4=192.168.2.64 +LINUX_IPV6=fd12:3456:789a:0002:0000:0000:0000:0064 # mask length for addresses of each IP version MASK_IPV4=24 MASK_IPV6=64 +# Interface tap/remote +IFACE="" + +# should tap mode be used (1 - use tap interface, 0 - use real NIC) +USE_TAP=0 + +# MAC address for tap interface - filled when tap is created +LINUX_MAC="00:64:74:61:70:30" +# fake MAC address to provide in neighbours +FAKE_MAC="00:64:74:61:70:33" + # name of the config files for backend and frontend of l4fwd app L4FWD_BE_CFG_FILE=$(mktemp) L4FWD_FE_CFG_FILE=$(mktemp) @@ -40,6 +51,15 @@ then exit 127 fi +# set interface based on mode used +if [[ "${ETH_DEV}" == "tap" ]] +then + IFACE=l4fwd_tap0 + USE_TAP=1 +else + IFACE=${REMOTE_IFACE} +fi + # check if L4FWD_PATH points to an executable if [[ ! -x ${L4FWD_PATH} ]] then @@ -47,23 +67,27 @@ then exit 127 fi -# check if REMOTE_HOST is reachable -ssh ${REMOTE_HOST} echo -st=$? -if [[ $st -ne 0 ]] +# neccesary check for real NIC mode +if [[ ${USE_TAP} -eq 0 ]] then - echo "host ${REMOTE_HOST} is not reachable" - exit $st -fi + # check if REMOTE_HOST is reachable + ssh ${REMOTE_HOST} echo + st=$? + if [[ $st -ne 0 ]] + then + echo "host ${REMOTE_HOST} is not reachable" + exit $st + fi -# get ethernet address of REMOTE_HOST -REMOTE_MAC=$(ssh ${REMOTE_HOST} ip addr show dev ${REMOTE_IFACE}) -st=$? -REMOTE_MAC=$(echo ${REMOTE_MAC} | sed -e 's/^.*ether //' -e 's/ brd.*$//') -if [[ $st -ne 0 || -z "${REMOTE_MAC}" ]] -then - echo "could not retrive ethernet address from ${REMOTE_IFACE}" - exit 127 + # get ethernet address of REMOTE_HOST + LINUX_MAC=$(ssh ${REMOTE_HOST} ip addr show dev ${IFACE}) + st=$? + LINUX_MAC=$(echo ${LINUX_MAC} | sed -e 's/^.*ether //' -e 's/ brd.*$//') + if [[ $st -ne 0 || -z "${LINUX_MAC}" ]] + then + echo "could not retrive ethernet address from ${IFACE}" + exit 127 + fi fi # check if FECORE is set - default 0 @@ -87,8 +111,22 @@ else L4FWD_LCORE="${L4FWD_FECORE}" fi +L4FWD_TAP="" + +# set eal parameters specific for mode used +if [[ ${USE_TAP} -eq 0 ]] +then + L4FWD_DEV="${ETH_DEV}" +else + L4FWD_DEV="--no-pci --vdev=\"net_tap0,iface=${IFACE},\ +mac=\"${LINUX_MAC}\"\"" +fi + # set EAL parameters -L4FWD_CMD_EAL_PRM="--lcores='${L4FWD_LCORE}' -n 4 ${ETH_DEV}" +L4FWD_CMD_EAL_PRM="--lcores='${L4FWD_LCORE}' -n 4 ${L4FWD_DEV}" + +# interface to wait for until it is set up properly +L4FWD_WAIT_VDEV="${IFACE}" # l4fwd parameters (listen, TCP only, enable arp, promiscuous) L4FWD_CMD_PRM="--listen --tcp --enable-arp --promisc ${L4FWD_STREAMS}" @@ -100,21 +138,31 @@ L4FWD_CONFIG="--fecfg ${L4FWD_FE_CFG_FILE} --becfg ${L4FWD_BE_CFG_FILE}" if [[ ${ipv4} -eq 1 ]] then L4FWD_PORT_PRM="port=${DPDK_PORT},lcore=${L4FWD_BECORE},rx_offload=0x0\ -,tx_offload=0x0,ipv4=${LOCAL_IPV4}" +,tx_offload=0x0,ipv4=${L4FWD_IPV4}" elif [[ ${ipv6} -eq 1 ]] then L4FWD_PORT_PRM="port=${DPDK_PORT},lcore=${L4FWD_BECORE},rx_offload=0x0\ -,tx_offload=0x0,ipv6=${LOCAL_IPV6}" +,tx_offload=0x0,ipv6=${L4FWD_IPV6}" fi # other variables-------------------------------------------------------------- +# function to run command with ssh if needed +use_ssh() +{ + if [[ ${USE_TAP} -eq 1 ]] + then + "$@" + else + ssh ${REMOTE_HOST} "$*" + fi +} + # check if directories on remote are set, if not make one -ssh ${REMOTE_HOST} mkdir -p {${REMOTE_OUTDIR},${REMOTE_RESDIR}} +use_ssh mkdir -p {${REMOTE_OUTDIR},${REMOTE_RESDIR}} # instruction to set -netem="ssh ${REMOTE_HOST} tc qdisc add dev ${REMOTE_IFACE} \ -root netem limit 100000" +netem="tc qdisc add dev ${IFACE} root netem limit 100000" # setting for scp which suppresses output of scp when not in verbose mode if [[ ${verbose} -eq 1 ]] @@ -135,12 +183,13 @@ fi # set address to use by netcat if [[ ${ipv4} -eq 1 ]] then - nc_addr=${LOCAL_IPV4} + nc_addr=${L4FWD_IPV4} elif [[ ${ipv6} -eq 1 ]] then - nc_addr=${LOCAL_IPV6} + nc_addr=${L4FWD_IPV6} fi +# calculate network address let "ipv4_elem=(${MASK_IPV4}/8)" let "ipv6_elem=(${MASK_IPV6}/16)" let "ipv4_elem_rev=4-${ipv4_elem}" @@ -151,9 +200,18 @@ while [[ ${ipv4_elem_rev} -ne 0 ]]; do let "ipv4_elem_rev=${ipv4_elem_rev}-1" done -ipv4_network=$(echo ${REMOTE_IPV4} | cut -d. -f-${ipv4_elem} | \ +ipv4_network=$(echo ${LINUX_IPV4} | cut -d. -f-${ipv4_elem} | \ sed 's#.*#&'"${ipv4_append}"'#') -ipv6_network=$(echo ${REMOTE_IPV6} | cut -d: -f-${ipv6_elem} | sed 's#.*#&::#') +ipv6_network=$(echo ${LINUX_IPV6} | cut -d: -f-${ipv6_elem} | sed 's#.*#&::#') + +# create temporary result file for tap mode, and/or set common file name +if [[ ${USE_TAP} -eq 0 ]] +then + common_result_file="${REMOTE_RESDIR}/results.out" +else + > ${local_result_file} + common_result_file=${local_result_file} +fi # helper functions------------------------------------------------------------- @@ -174,18 +232,33 @@ update_results() it=$3 # get only 'real' time in results file - $(ssh ${REMOTE_HOST} "awk '/real/{print \$2}' \ - ${REMOTE_RESDIR}/${file}.result.${it} \ - >> ${REMOTE_RESDIR}/results.out") + if [[ ${USE_TAP} -eq 0 ]] + then + $(ssh ${REMOTE_HOST} "awk '/real/{print \$2}' \ +${REMOTE_RESDIR}/${file}.result.${it} >> ${common_result_file}") + else + awk '/real/{print $2}' ${REMOTE_RESDIR}/${file}.result.${it} \ + >> ${common_result_file} + fi # add file and status of test to results if [[ ${status} -ne 0 ]] then - $(ssh ${REMOTE_HOST} "sed -i '$ s_.*_[FAIL]\t&_' \ - ${REMOTE_RESDIR}/results.out") + if [[ ${USE_TAP} -eq 0 ]] + then + $(ssh ${REMOTE_HOST} "sed -i '$ s_.*_[FAIL]\t&_' \ +${common_result_file}") + else + sed -i '$ s_.*_[FAIL]\t&_' ${common_result_file} + fi else - $(ssh ${REMOTE_HOST} "sed -i '$ s_.*_[OK]\t&_' \ - ${REMOTE_RESDIR}/results.out") + if [[ ${USE_TAP} -eq 0 ]] + then + $(ssh ${REMOTE_HOST} "sed -i '$ s_.*_[OK]\t&_' \ +${common_result_file}") + else + sed -i '$ s_.*_[OK]\t&_' ${common_result_file} + fi fi length=$(expr length "${file}") @@ -196,13 +269,21 @@ update_results() tab="\t" fi - $(ssh ${REMOTE_HOST} "sed -i '$ s_.*_${file}${tab}&_' \ - ${REMOTE_RESDIR}/results.out") + if [[ ${USE_TAP} -eq 0 ]] + then + $(ssh ${REMOTE_HOST} "sed -i '$ s_.*_${file}${tab}&_' \ +${common_result_file}") + else + sed -i "$ s_.*_${file}${tab}&_" ${common_result_file} + fi } # start l4fwd app l4fwd_start() { + # make configuration files for be/fe + configure_be_fe + # create temporary file for command running l4fwd L4FWD_EXEC_FILE=$(mktemp) @@ -229,6 +310,20 @@ EOF rm -f ${L4FWD_EXEC_FILE} exit 127 fi + + if [[ ${USE_TAP} -eq 1 ]] + then + # check if tap interface is up + i=0 + st=1 + while [[ ${i} -ne 5 && ${st} -ne 0 ]] + do + sleep 1 + ip link show dev ${L4FWD_WAIT_VDEV} > /dev/null 2>&1 + st=$? + let i++ + done + fi } # stop l4fwd app @@ -236,7 +331,7 @@ l4fwd_stop() { # kill runnning l4fwd app kill -s SIGINT ${L4FWD_PID} - + sleep 1 # remove temporary files rm -f ${L4FWD_EXEC_FILE} rm -f ${L4FWD_FE_CFG_FILE} @@ -246,13 +341,8 @@ l4fwd_stop() # helper function to set netem on remote setup_netem() { - # remove netem settings from remote interface if any - check_netem=$(ssh ${REMOTE_HOST} "tc qdisc show dev \ - ${REMOTE_IFACE} | grep netem") - if [[ -n ${check_netem} ]] - then - ssh ${REMOTE_HOST} tc qdisc del dev ${REMOTE_IFACE} root - fi + # remove netem settings from interface + use_ssh tc qdisc del dev ${IFACE} root # set default delay for reorder if [[ ${reorder} -ne 0 && ${delay} -eq 0 ]] @@ -284,35 +374,42 @@ setup_netem() netem="${netem} reorder 100% gap ${reorder}" fi - # set netem on remote - ${netem} + # set netem + use_ssh ${netem} # visual break of the output if_verbose echo -e "\nNetwork rules on remote set to:" # print current netem settings - if_verbose ssh ${REMOTE_HOST} tc qdisc show dev ${REMOTE_IFACE} + if_verbose use_ssh tc qdisc show dev ${IFACE} } -# configure IPv4 remote machine -configure_ip4_remote() +# configure IPv4 interface +configure_l4fwd_ip4() { # visual break of the output - if_verbose echo "Setting interface on remote" + if_verbose echo "Setting IPv4 interface" # set remote interface with correct IP address - ssh ${REMOTE_HOST} ip link set ${REMOTE_IFACE} down - ssh ${REMOTE_HOST} ip addr flush dev ${REMOTE_IFACE} - ssh ${REMOTE_HOST} ip addr add ${REMOTE_IPV4}/${MASK_IPV4} \ - dev ${REMOTE_IFACE} - ssh ${REMOTE_HOST} ip link set ${REMOTE_IFACE} up - if_verbose ssh ${REMOTE_HOST} ip addr show dev ${REMOTE_IFACE} - - ssh ${REMOTE_HOST} ip neigh flush dev ${REMOTE_IFACE} - ssh ${REMOTE_HOST} iptables --flush + if [[ ${USE_TAP} -eq 0 ]] + then + ssh ${REMOTE_HOST} ip link set ${IFACE} down + ssh ${REMOTE_HOST} ip addr flush dev ${IFACE} + ssh ${REMOTE_HOST} ip addr add ${LINUX_IPV4}/${MASK_IPV4} \ +dev ${IFACE} + ssh ${REMOTE_HOST} ip link set ${IFACE} up + ssh ${REMOTE_HOST} ip neigh flush dev ${IFACE} + else + ip addr add ${LINUX_IPV4}/${MASK_IPV4} dev ${IFACE} + ip link set ${IFACE} up + ip neigh flush dev ${IFACE} + ip neigh add ${L4FWD_IPV4} dev ${IFACE} lladdr ${FAKE_MAC} + fi - ssh ${REMOTE_HOST} ip route change ${ipv4_network}/${MASK_IPV4} dev \ - ${REMOTE_IFACE} rto_min 30ms + use_ssh iptables --flush + use_ssh ip route change ${ipv4_network}/${MASK_IPV4} dev ${IFACE} \ +rto_min 30ms + if_verbose use_ssh ip addr show dev ${IFACE} # construct instruction if [[ set_netem -eq 1 ]] @@ -324,32 +421,40 @@ configure_ip4_remote() sleep 1 } -# configure IPv6 remote machine -configure_ip6_remote() +# configure IPv6 interface +configure_l4fwd_ip6() { # visual break of the output - if_verbose echo "Setting interface on remote" + if_verbose echo "Setting IPv6 interface" # set remote interface with correct IP address - ssh ${REMOTE_HOST} ip link set ${REMOTE_IFACE} down - ssh ${REMOTE_HOST} sysctl -q -w \ - net.ipv6.conf.${REMOTE_IFACE}.disable_ipv6=0 - ssh ${REMOTE_HOST} ip addr flush dev ${REMOTE_IFACE} - ssh ${REMOTE_HOST} ip -6 addr add ${REMOTE_IPV6}/${MASK_IPV6} \ - dev ${REMOTE_IFACE} - ssh ${REMOTE_HOST} ip -6 link set ${REMOTE_IFACE} up - if_verbose ssh ${REMOTE_HOST} ip addr show dev ${REMOTE_IFACE} - - ssh ${REMOTE_HOST} ip neigh flush dev ${REMOTE_IFACE} - ssh ${REMOTE_HOST} ip -6 neigh add ${LOCAL_IPV6} dev ${REMOTE_IFACE} \ - lladdr ${LOCAL_MAC} - ssh ${REMOTE_HOST} iptables --flush - ssh ${REMOTE_HOST} ip6tables --flush - - ssh ${REMOTE_HOST} ip route change ${ipv6_network}/${MASK_IPV6} dev \ - ${REMOTE_IFACE} proto kernel metric 256 rto_min 30ms - - ssh ${REMOTE_HOST} ip -6 route show + if [[ ${USE_TAP} -eq 0 ]] + then + ssh ${REMOTE_HOST} ip link set ${IFACE} down + ssh ${REMOTE_HOST} sysctl -q -w \ +net.ipv6.conf.${IFACE}.disable_ipv6=0 + ssh ${REMOTE_HOST} ip addr flush dev ${IFACE} + ssh ${REMOTE_HOST} ip -6 addr add ${LINUX_IPV6}/${MASK_IPV6} \ +dev ${IFACE} + ssh ${REMOTE_HOST} ip -6 link set ${IFACE} up + ssh ${REMOTE_HOST} ip neigh flush dev ${IFACE} + ssh ${REMOTE_HOST} ip -6 neigh add ${L4FWD_IPV6} dev ${IFACE} \ +lladdr ${LOCAL_MAC} + else + sysctl -q -w net.ipv6.conf.${IFACE}.disable_ipv6=0 + ip addr flush dev ${IFACE} + ip -6 addr add ${LINUX_IPV6}/${MASK_IPV6} dev ${IFACE} + ip -6 link set ${IFACE} up + ip neigh flush dev ${IFACE} + ip -6 neigh add ${L4FWD_IPV6} dev ${IFACE} lladdr ${FAKE_MAC} + fi + + use_ssh iptables --flush + use_ssh ip6tables --flush + + use_ssh ip route change ${ipv6_network}/${MASK_IPV6} dev \ +${IFACE} proto kernel metric 256 rto_min 30ms + if_verbose use_ssh ip addr show dev ${IFACE} # construct instruction if [[ set_netem -eq 1 ]] @@ -357,36 +462,25 @@ configure_ip6_remote() setup_netem fi - # give linux 1 sec to handle all network settings - sleep 1 + # give linux 3 sec to handle all network settings + sleep 3 } -# configure remote -configure_remote() + +# configure tap interfaces +configure_interfaces() { # call proper configuration if [[ ${ipv4} -eq 1 ]] then - configure_ip4_remote - - if_verbose echo -e "\nBE configuration:" - config4_be - - if_verbose echo -e "\nFE configuration:" - config4_fe + configure_l4fwd_ip4 elif [[ ${ipv6} -eq 1 ]] then - configure_ip6_remote - - if_verbose echo -e "\nBE configuration:" - config6_be - - if_verbose echo -e "\nFE configuration:" - config6_fe + configure_l4fwd_ip6 fi # create empty results file on remote - $(ssh ${REMOTE_HOST} "> ${REMOTE_RESDIR}/results.out") + $(ssh ${REMOTE_HOST} "> ${common_result_file}") } # restore netem settings to default @@ -394,21 +488,41 @@ restore_netem() { if [[ ${set_netem} -eq 1 ]] then - ssh ${REMOTE_HOST} tc qdisc del dev ${REMOTE_IFACE} root + use_ssh tc qdisc del dev ${IFACE} root fi } # remove created directories after test is done remove_directories() { - ssh ${REMOTE_HOST} rm -fr ${REMOTE_DIR} + use_ssh rm -fr ${REMOTE_DIR} } # configuration of be/fe config------------------------------------------------ +configure_be_fe() +{ + # call proper configuration + if [[ ${ipv4} -eq 1 ]] + then + if_verbose echo -e "\nBE configuration:" + config4_be + + if_verbose echo -e "\nFE configuration:" + config4_fe + elif [[ ${ipv6} -eq 1 ]] + then + if_verbose echo -e "\nBE configuration:" + config6_be + + if_verbose echo -e "\nFE configuration:" + config6_fe + fi +} + config4_be() { - cat < ${L4FWD_BE_CFG_FILE} -port=${DPDK_PORT},masklen=${MASK_IPV4},addr=${REMOTE_IPV4},mac=${REMOTE_MAC} + cat < ${L4FWD_BE_CFG_FILE} +port=${DPDK_PORT},masklen=${MASK_IPV4},addr=${LINUX_IPV4},mac=${LINUX_MAC} EOF if_verbose cat ${L4FWD_BE_CFG_FILE} @@ -416,8 +530,8 @@ EOF config6_be() { - cat < ${L4FWD_BE_CFG_FILE} -port=${DPDK_PORT},masklen=${MASK_IPV6},addr=${REMOTE_IPV6},mac=${REMOTE_MAC} + cat < ${L4FWD_BE_CFG_FILE} +port=${DPDK_PORT},masklen=${MASK_IPV6},addr=${LINUX_IPV6},mac=${LINUX_MAC} EOF if_verbose cat ${L4FWD_BE_CFG_FILE} @@ -426,8 +540,8 @@ EOF config4_fe() { cat < ${L4FWD_FE_CFG_FILE} -lcore=${L4FWD_FECORE},belcore=${L4FWD_BECORE},op=echo,laddr=${LOCAL_IPV4}\ -,lport=${TCP_PORT},raddr=${REMOTE_IPV4},rport=0 +lcore=${L4FWD_FECORE},belcore=${L4FWD_BECORE},op=echo,laddr=${L4FWD_IPV4}\ +,lport=${TCP_PORT},raddr=${LINUX_IPV4},rport=0 EOF if_verbose cat ${L4FWD_FE_CFG_FILE} @@ -436,8 +550,8 @@ EOF config6_fe() { cat < ${L4FWD_FE_CFG_FILE} -lcore=${L4FWD_FECORE},belcore=${L4FWD_BECORE},op=echo,laddr=${LOCAL_IPV6}\ -,lport=${TCP_PORT},raddr=${REMOTE_IPV6},rport=0 +lcore=${L4FWD_FECORE},belcore=${L4FWD_BECORE},op=echo,laddr=${L4FWD_IPV6}\ +,lport=${TCP_PORT},raddr=${LINUX_IPV6},rport=0 EOF if_verbose cat ${L4FWD_FE_CFG_FILE} diff --git a/examples/l4fwd/test/example_env_vars b/examples/l4fwd/test/example_env_vars index 9877db8..82e0e85 100644 --- a/examples/l4fwd/test/example_env_vars +++ b/examples/l4fwd/test/example_env_vars @@ -2,12 +2,19 @@ # ENV VARIABLES -export REMOTE_HOST=root@10.237.214.104 -export REMOTE_IFACE=enp138s0f0 -export LOCAL_MAC="68:05:ca:04:47:02" +# configuration for tap interface +export ETH_DEV="tap" export L4FWD_PATH=/opt/home/md/Projects/tldk/BuildForTLDK/app/l4fwd export L4FWD_FECORE=5 #optional export L4FWD_BECORE=6 #optional -export ETH_DEV="-w 8a:00.0" + +# configuration for real NIC +#export ETH_DEV="-w 8a:00.0" +#export L4FWD_PATH=/opt/home/md/Projects/tldk/BuildForTLDK/app/l4fwd +#export REMOTE_HOST=root@10.237.214.104 #required for real NIC only +#export REMOTE_IFACE=enp138s0f0 #required for real NIC only +#export LOCAL_MAC="68:05:ca:04:47:02" #required for real NIC only +#export L4FWD_FECORE=5 #optional +#export L4FWD_BECORE=6 #optional # ENV VARIABLES end diff --git a/examples/l4fwd/test/nctxrx.sh b/examples/l4fwd/test/nctxrx.sh index 6a016e0..98f84c2 100644 --- a/examples/l4fwd/test/nctxrx.sh +++ b/examples/l4fwd/test/nctxrx.sh @@ -8,41 +8,54 @@ # script with -h (help) # # User needs to specify following environment variables: -# ETH_DEV - ethernet device to be used on SUT by DPDK +# L4FWD_PATH - path to l4fwd app binary +# ETH_DEV - for real NIC usage - ethernet device to be used on SUT by DPDK +# - for tap interface - tap +# +# User needs to set following enviroment variables in case of real NIC usage: # REMOTE_HOST - ip/hostname of DUT # REMOTE_IFACE - interface name for the test-port on DUT # LOCAL_MAC - MAC address used by DPDK -# L4FWD_PATH - path to l4fwd app binary +# # Optional envirenment variables: # L4FWD_FECORE - core on which l4fwd frontend should run # L4FWD_BECORE - core on which l4fwd backend should run # -# The purpose of the script is to automate validation tests for l4fwd app -# where packets are out of order/lost. It expects l4fwd application being -# run on local linux system (SUT). Script is operating on remote linux -# machine (DUT) with use of ssh. SUT and DUT are connected via NIC. On SUT -# network traffic is managed by DPDK and on DUT by linux. On DUT netcat is -# used to send test data via TCP to TLDK on SUT, which is set to echo mode +# The purpose of the script is to automate validation tests for l4fwd app where +# packets are out of order/lost. Script is operating on local linux machine only +# or on local and remote machine (depending on enviroment variables). +# +# For local machine only, l4fwd application is being run by the script, which +# sets up the tap interface. Created interface is serving a connection for l4fwd +# and netcat within the same OS. +# +# For local/remote linux machine mode, script uses real NIC specified in +# enviroment variable. Connection with remote machine is made via ssh. L4fwd app +# is being run on local machine, while interface and netcat are being set on +# remote side (operated by linux). +# +# Netcat is used to send test data via TCP to l4fwd, which is set to echo mode # (sends back the same data). Depending on test specified, TCP segments are -# artificially changed in sending buffer of DUT, so they are lost in some -# percentage or sent out of order. If specified, report is sent from DUT -# to SUT after all tests were performed. +# artificially changed inside sending buffer, so they are lost in some +# percentage or sent out of order. Report is printed after all tests were +# performed. # -# Example traffic visualisation: -# DUT --(TCP out of order)--> SUT --(TCP with correct order)--> DUT(validation) +# Example of traffic visualisation +# Netcat(TAP/NIC) --(TCP out of order)--> (TAP/NIC)L4FWD(TAP/NIC) -- +# --(TCP with correct order)--> (TAP/NIC)Netcat(validation) # options which can be changed by the user if needed--------------------------- # timeout in [s] for calling nc (in case traffic stuck) timeout=600 -# delay for netem (50 [ms] is default value when reorder option used) +# delay for netem (20 [ms] is default value when reorder option used) delay=0 # default loss of packets [%] value loss=0 -# default probability [%] of not losing burst of packets +# default probability [%] of not loosing burst of packets loss_burst=80 # variables used by script----------------------------------------------------- @@ -55,7 +68,7 @@ rmresults="" set_netem=0 # flag to check if default files should to be used (default 1) -# default files are generated with urandom (couple of sizes) +# default files are generated with urandom default_file=1 # IP protocol version @@ -160,7 +173,7 @@ done # load configuration . $(dirname $0)/config.sh -# send file with results to local machine +# send file with results to local machine when in real NIC mode send_results() { if_verbose echo -e "Sending result file to local" @@ -185,7 +198,7 @@ run_test() # -q 0 -> wait 0 seconds after EOF and quit # timeout to deal with hanging connection when sth went wrong # feed netcat with {of} file to send - # receiving end is redirected to out/...out files + # receiving end is redirected to out/...out file # 'exec' for redirecting nc err output to not mess result cmd="exec 4>&2 \$({ time timeout ${timeout} nc ${nc_ipv6} -q 0 ${nc_addr} ${TCP_PORT} \ @@ -195,13 +208,18 @@ run_test() exec 4>&-" # create temporary file for nc command to execute - xf=$(ssh ${REMOTE_HOST} mktemp -p ${REMOTE_DIR}) + xf=$(use_ssh mktemp -p ${REMOTE_DIR}) # store command from {cmd} into temporaty file - echo "${cmd}" | ssh ${REMOTE_HOST} "cat > ${xf}" + if [[ ${USE_TAP} -eq 0 ]] + then + echo "${cmd}" | ssh ${REMOTE_HOST} "cat > ${xf}" + else + echo "${cmd}" | cat > ${xf} + fi # execute nc command in the background - ssh ${REMOTE_HOST} /bin/bash ${xf} & + use_ssh /bin/bash ${xf} & pids="${pids} $!" @@ -219,7 +237,7 @@ exec 4>&-" wait ${pids} # remove temporary files - ssh ${REMOTE_HOST} rm -f ${rmxf} + use_ssh rm -f ${rmxf} # visual break if_verbose echo -e "\nNetstat:" @@ -227,13 +245,13 @@ exec 4>&-" # prints network information for given {TCP_PORT} number # -n -> show numeric addresses # -a -> show all (both listening and non-listening sockets) - if_verbose ssh ${REMOTE_HOST} netstat -na | grep ${TCP_PORT} + if_verbose use_ssh netstat -na | grep ${TCP_PORT} # visual break if_verbose echo -e "\nJobs:" # display status of jobs in the current session (this bash script) - if_verbose ssh ${REMOTE_HOST} jobs -l + if_verbose use_ssh jobs -l # visual break if_verbose echo -e "\nNetcat processes:" @@ -242,7 +260,7 @@ exec 4>&-" # -e -> show all processes # -f -> do full format listing (more info) # grep -v -> get rid of the following word match from grep output - if_verbose ssh ${REMOTE_HOST} ps -ef | grep "nc " | grep -v grep + if_verbose use_ssh ps -ef | grep "nc " | grep -v grep # visual break if_verbose echo -e "\nRunning validation" @@ -252,13 +270,12 @@ exec 4>&-" while [[ ${i} -lt ${num} ]] do # prints checksum of sent and received file - if_verbose ssh ${REMOTE_HOST} cksum ${REMOTE_DIR}/${of} \ + if_verbose use_ssh cksum ${REMOTE_DIR}/${of} \ ${REMOTE_OUTDIR}/${of}.out.${i} # compares sent and received files if they match # compare {of} and {out/of.out.i} line by line - ssh ${REMOTE_HOST} diff ${REMOTE_DIR}/${of} \ - ${REMOTE_OUTDIR}/${of}.out.${i} + use_ssh diff ${REMOTE_DIR}/${of} ${REMOTE_OUTDIR}/${of}.out.${i} # capture the result of diff command above rc=$? @@ -280,15 +297,15 @@ exec 4>&-" fi # remove received file from out/ directory - ssh ${REMOTE_HOST} rm -f ${REMOTE_OUTDIR}/${of}.out.${i} + use_ssh rm -f ${REMOTE_OUTDIR}/${of}.out.${i} i=$(expr $i + 1) done # remove temporary results - ssh ${REMOTE_HOST} rm -f ${rmresults} + use_ssh rm -f ${rmresults} - if [[ flag_error -eq 1 ]] + if [[ flag_error -ne 0 ]] then return ${flag_error} fi @@ -296,13 +313,17 @@ exec 4>&-" if_verbose echo "" echo -e "TEST SUCCESSFUL - ${of}" if_verbose echo "" + return 0 } # clean up after error or end of tests cleanup() { - send_results + if [[ ${USE_TAP} -eq 0 ]] + then + send_results + fi restore_netem l4fwd_stop remove_directories @@ -310,17 +331,20 @@ cleanup() # script start----------------------------------------------------------------- -#configure remote machine -configure_remote - # start l4fwd app l4fwd_start +#configure configure tap interfaces +configure_interfaces + # check if default files should be used if [[ ${default_file} -eq 0 ]] then if_verbose echo -e "Sending test file to remote" - scp ${scp_suppress} ${file} ${REMOTE_HOST}:${REMOTE_DIR} + if [[ ${USE_TAP} -eq 0 ]] + then + scp ${scp_suppress} ${file} ${REMOTE_HOST}:${REMOTE_DIR} + fi run_test ${file} # check test outcome @@ -330,17 +354,17 @@ then cleanup exit ${ret} fi - ssh ${REMOTE_HOST} rm -f ${REMOTE_DIR}/${file} + use_ssh rm -f ${REMOTE_DIR}/${file} else - # use default files with size 16MB - for size in 16 + # use default files with size 8MB + for size in 8 do # generate file - if_verbose echo -e "Generating ${size}MB file for test" - x=$(ssh ${REMOTE_HOST} mktemp $(basename $0).${size}MB.XXX \ + if_verbose echo -e "\nGenerating ${size}MB file for test" + x=$(use_ssh mktemp $(basename $0).${size}MB.XXX \ -p ${REMOTE_DIR}) - ssh ${REMOTE_HOST} dd if=/dev/urandom of=${x} bs=1M \ + use_ssh dd if=/dev/urandom of=${x} bs=1M \ count=${size} ${dd_suppress} # run test over generated file @@ -355,7 +379,7 @@ else fi # remove generated file only if test successful - ssh ${REMOTE_HOST} rm -f ${x} + use_ssh rm -f ${x} done fi diff --git a/examples/l4fwd/test/run_test.sh b/examples/l4fwd/test/run_test.sh index 690651a..431e973 100644 --- a/examples/l4fwd/test/run_test.sh +++ b/examples/l4fwd/test/run_test.sh @@ -2,18 +2,22 @@ # readme section--------------------------------------------------------------- -# usage: /bin/bash run_test.sh [-46lrh] +# usage: /bin/bash run_test.sh [-46alrh] # # Run all tests using nctxrx.sh. Report stored and printed # after tests were done. For details about options run # script with -h (help) # # User needs to specify following environment variables: -# ETH_DEV - ethernet device to be used on SUT by DPDK +# L4FWD_PATH - path to l4fwd app binary +# ETH_DEV - for real NIC usage - ethernet device to be used on SUT by DPDK +# - for tap interface - tap +# +# User needs to set following enviroment variables in case of real NIC usage: # REMOTE_HOST - ip/hostname of DUT # REMOTE_IFACE - interface name for the test-port on DUT # LOCAL_MAC - MAC address used by DPDK -# L4FWD_PATH - path to l4fwd app binary +# # Optional envirenment variables: # L4FWD_FECORE - core on which l4fwd frontend should run # L4FWD_BECORE - core on which l4fwd backend should run @@ -203,7 +207,7 @@ do then echo -e "\nTest for reorder: ${reorder}\t[OK]" else - echo -e "\nTest for reorder: $reorder}\t[FAIL]" + echo -e "\nTest for reorder: ${reorder}\t[FAIL]" error_count=$(expr ${error_count} + 1) fi @@ -274,5 +278,5 @@ else fi # print report after all tests were done -echo -e "Report\n" +echo -e "Report:\n" cat ${result} -- cgit 1.2.3-korg