2 # SPDX-License-Identifier: GPL-2.0
4 . "$(dirname "${0}")/mptcp_lib.sh"
8 optstring="S:R:d:e:l:r:h4cm:f:tC"
18 timeout_test=$((timeout_poll * 2 + 1))
20 ethtool_random_on=true
21 tc_delay="$((RANDOM%50))"
22 tc_loss=$((RANDOM%101))
30 connect_per_transfer=1
32 if [ $tc_loss -eq 100 ];then
34 elif [ $tc_loss -ge 10 ]; then
36 elif [ $tc_loss -ge 1 ]; then
43 echo "Usage: $0 [ -a ]"
44 echo -e "\t-d: tc/netem delay in milliseconds, e.g. \"-d 10\" (default random)"
45 echo -e "\t-l: tc/netem loss percentage, e.g. \"-l 0.02\" (default random)"
46 echo -e "\t-r: tc/netem reorder mode, e.g. \"-r 25% 50% gap 5\", use "-r 0" to disable reordering (default random)"
47 echo -e "\t-e: ethtool features to disable, e.g.: \"-e tso -e gso\" (default: randomly disable any of tso/gso/gro)"
48 echo -e "\t-4: IPv4 only: disable IPv6 tests (default: test both IPv4 and IPv6)"
49 echo -e "\t-c: capture packets for each test using tcpdump (default: no capture)"
50 echo -e "\t-f: size of file to transfer in bytes (default random)"
51 echo -e "\t-S: set sndbuf value (default: use kernel default)"
52 echo -e "\t-R: set rcvbuf value (default: use kernel default)"
53 echo -e "\t-m: test mode (poll, sendfile; default: poll)"
54 echo -e "\t-t: also run tests with TCP (use twice to non-fallback tcp)"
55 echo -e "\t-C: enable the MPTCP data checksum"
58 while getopts "$optstring" option;do
65 if [ $OPTARG -ge 0 ];then
68 echo "-d requires numeric argument, got \"$OPTARG\"" 1>&2
73 ethtool_args="$ethtool_args $OPTARG off"
74 ethtool_random_on=false
89 if [ $OPTARG -ge 0 ];then
92 echo "-S requires numeric argument, got \"$OPTARG\"" 1>&2
97 if [ $OPTARG -ge 0 ];then
100 echo "-R requires numeric argument, got \"$OPTARG\"" 1>&2
124 rndh=$(printf %x $sec)-$(mktemp -u XXXXXX)
134 rm -f "$cin_disconnect" "$cout_disconnect"
140 for netns in "$ns1" "$ns2" "$ns3" "$ns4";do
142 rm -f /tmp/$netns.{nstat,out}
146 mptcp_lib_check_mptcp
147 mptcp_lib_check_kallsyms
149 ip -Version > /dev/null 2>&1
151 echo "SKIP: Could not run test without ip tool"
160 cin_disconnect="$cin".disconnect
161 cout_disconnect="$cout".disconnect
164 for i in "$ns1" "$ns2" "$ns3" "$ns4";do
165 ip netns add $i || exit $ksft_skip
166 ip -net $i link set lo up
170 # ns1eth2 ns2eth1 ns2eth3 ns3eth2 ns3eth4 ns4eth3
171 # - drop 1% -> reorder 25%
174 ip link add ns1eth2 netns "$ns1" type veth peer name ns2eth1 netns "$ns2"
175 ip link add ns2eth3 netns "$ns2" type veth peer name ns3eth2 netns "$ns3"
176 ip link add ns3eth4 netns "$ns3" type veth peer name ns4eth3 netns "$ns4"
178 ip -net "$ns1" addr add 10.0.1.1/24 dev ns1eth2
179 ip -net "$ns1" addr add dead:beef:1::1/64 dev ns1eth2 nodad
181 ip -net "$ns1" link set ns1eth2 up
182 ip -net "$ns1" route add default via 10.0.1.2
183 ip -net "$ns1" route add default via dead:beef:1::2
185 ip -net "$ns2" addr add 10.0.1.2/24 dev ns2eth1
186 ip -net "$ns2" addr add dead:beef:1::2/64 dev ns2eth1 nodad
187 ip -net "$ns2" link set ns2eth1 up
189 ip -net "$ns2" addr add 10.0.2.1/24 dev ns2eth3
190 ip -net "$ns2" addr add dead:beef:2::1/64 dev ns2eth3 nodad
191 ip -net "$ns2" link set ns2eth3 up
192 ip -net "$ns2" route add default via 10.0.2.2
193 ip -net "$ns2" route add default via dead:beef:2::2
194 ip netns exec "$ns2" sysctl -q net.ipv4.ip_forward=1
195 ip netns exec "$ns2" sysctl -q net.ipv6.conf.all.forwarding=1
197 ip -net "$ns3" addr add 10.0.2.2/24 dev ns3eth2
198 ip -net "$ns3" addr add dead:beef:2::2/64 dev ns3eth2 nodad
199 ip -net "$ns3" link set ns3eth2 up
201 ip -net "$ns3" addr add 10.0.3.2/24 dev ns3eth4
202 ip -net "$ns3" addr add dead:beef:3::2/64 dev ns3eth4 nodad
203 ip -net "$ns3" link set ns3eth4 up
204 ip -net "$ns3" route add default via 10.0.2.1
205 ip -net "$ns3" route add default via dead:beef:2::1
206 ip netns exec "$ns3" sysctl -q net.ipv4.ip_forward=1
207 ip netns exec "$ns3" sysctl -q net.ipv6.conf.all.forwarding=1
209 ip -net "$ns4" addr add 10.0.3.1/24 dev ns4eth3
210 ip -net "$ns4" addr add dead:beef:3::1/64 dev ns4eth3 nodad
211 ip -net "$ns4" link set ns4eth3 up
212 ip -net "$ns4" route add default via 10.0.3.2
213 ip -net "$ns4" route add default via dead:beef:3::2
216 for i in "$ns1" "$ns2" "$ns3" "$ns4";do
217 ip netns exec $i sysctl -q net.mptcp.checksum_enabled=1
221 set_ethtool_flags() {
226 ip netns exec $ns ethtool -K $dev $flags 2>/dev/null
227 [ $? -eq 0 ] && echo "INFO: set $ns dev $dev: ethtool -K $flags"
230 set_random_ethtool_flags() {
234 local pick1=$((r & 1))
235 local pick2=$((r & 2))
236 local pick3=$((r & 4))
238 [ $pick1 -ne 0 ] && flags="tso off"
239 [ $pick2 -ne 0 ] && flags="$flags gso off"
240 [ $pick3 -ne 0 ] && flags="$flags gro off"
242 [ -z "$flags" ] && return
244 set_ethtool_flags "$1" "$2" "$flags"
247 if $ethtool_random_on;then
248 set_random_ethtool_flags "$ns3" ns3eth2
249 set_random_ethtool_flags "$ns4" ns4eth3
251 set_ethtool_flags "$ns3" ns3eth2 "$ethtool_args"
252 set_ethtool_flags "$ns4" ns4eth3 "$ethtool_args"
258 echo "Trailing bytes are: "
268 cmp "$in" "$out" > /dev/null 2>&1
269 if [ $? -ne 0 ] ;then
270 echo "[ FAIL ] $what does not match (in, out):"
272 print_file_err "$out"
280 check_mptcp_disabled()
282 local disabled_ns="ns_disabled-$rndh"
283 ip netns add ${disabled_ns} || exit $ksft_skip
285 # net.mptcp.enabled should be enabled by default
286 if [ "$(ip netns exec ${disabled_ns} sysctl net.mptcp.enabled | awk '{ print $3 }')" -ne 1 ]; then
287 echo -e "net.mptcp.enabled sysctl is not 1 by default\t\t[ FAIL ]"
291 ip netns exec ${disabled_ns} sysctl -q net.mptcp.enabled=0
294 LC_ALL=C ip netns exec ${disabled_ns} ./mptcp_connect -p 10000 -s MPTCP 127.0.0.1 < "$cin" 2>&1 | \
295 grep -q "^socket: Protocol not available$" && err=1
296 ip netns delete ${disabled_ns}
298 if [ ${err} -eq 0 ]; then
299 echo -e "New MPTCP socket cannot be blocked via sysctl\t\t[ FAIL ]"
304 echo -e "New MPTCP socket can be blocked via sysctl\t\t[ OK ]"
316 local listener_ns="$1"
317 local connector_ns="$2"
318 local connect_addr="$3"
319 local ping_args="-q -c 1"
321 if is_v6 "${connect_addr}"; then
323 ping_args="${ping_args} -6"
326 ip netns exec ${connector_ns} ping ${ping_args} $connect_addr >/dev/null
327 if [ $? -ne 0 ] ; then
328 echo "$listener_ns -> $connect_addr connectivity [ FAIL ]" 1>&2
337 # $1: ns, $2: MIB counter
340 local listener_ns="${1}"
344 ip netns exec "${listener_ns}" \
345 nstat -z -a "${mib}" | \
347 while read a count c rest; do
353 wait_local_port_listen()
355 local listener_ns="${1}"
360 port_hex="$(printf "%04X" "${port}")"
361 for i in $(seq 10); do
362 ip netns exec "${listener_ns}" cat /proc/net/tcp* | \
363 awk "BEGIN {rc=1} {if (\$2 ~ /:${port_hex}\$/ && \$4 ~ /0A/) {rc=0; exit}} END {exit rc}" &&
371 local listener_ns="$1"
372 local connector_ns="$2"
375 local connect_addr="$5"
376 local local_addr="$6"
377 local extra_args="$7"
380 port=$((10000+$TEST_COUNT))
381 TEST_COUNT=$((TEST_COUNT+1))
383 if [ "$rcvbuf" -gt 0 ]; then
384 extra_args="$extra_args -R $rcvbuf"
387 if [ "$sndbuf" -gt 0 ]; then
388 extra_args="$extra_args -S $sndbuf"
391 if [ -n "$testmode" ]; then
392 extra_args="$extra_args -m $testmode"
395 if [ -n "$extra_args" ] && $options_log; then
396 echo "INFO: extra options: $extra_args"
405 addr_port=$(printf "%s:%d" ${connect_addr} ${port})
406 printf "%.3s %-5s -> %.3s (%-20s) %-5s\t" ${connector_ns} ${cl_proto} ${listener_ns} ${addr_port} ${srv_proto}
410 if [ -z $SUDO_USER ] ; then
413 capuser="-Z $SUDO_USER"
416 local capfile="${rndh}-${connector_ns:0:3}-${listener_ns:0:3}-${cl_proto}-${srv_proto}-${connect_addr}-${port}"
417 local capopt="-i any -s 65535 -B 32768 ${capuser}"
419 ip netns exec ${listener_ns} tcpdump ${capopt} -w "${capfile}-listener.pcap" >> "${capout}" 2>&1 &
420 local cappid_listener=$!
422 ip netns exec ${connector_ns} tcpdump ${capopt} -w "${capfile}-connector.pcap" >> "${capout}" 2>&1 &
423 local cappid_connector=$!
428 NSTAT_HISTORY=/tmp/${listener_ns}.nstat ip netns exec ${listener_ns} \
430 if [ ${listener_ns} != ${connector_ns} ]; then
431 NSTAT_HISTORY=/tmp/${connector_ns}.nstat ip netns exec ${connector_ns} \
435 local stat_synrx_last_l=$(get_mib_counter "${listener_ns}" "MPTcpExtMPCapableSYNRX")
436 local stat_ackrx_last_l=$(get_mib_counter "${listener_ns}" "MPTcpExtMPCapableACKRX")
437 local stat_cookietx_last=$(get_mib_counter "${listener_ns}" "TcpExtSyncookiesSent")
438 local stat_cookierx_last=$(get_mib_counter "${listener_ns}" "TcpExtSyncookiesRecv")
439 local stat_csum_err_s=$(get_mib_counter "${listener_ns}" "MPTcpExtDataCsumErr")
440 local stat_csum_err_c=$(get_mib_counter "${connector_ns}" "MPTcpExtDataCsumErr")
442 timeout ${timeout_test} \
443 ip netns exec ${listener_ns} \
444 ./mptcp_connect -t ${timeout_poll} -l -p $port -s ${srv_proto} \
445 $extra_args $local_addr < "$sin" > "$sout" &
448 wait_local_port_listen "${listener_ns}" "${port}"
452 timeout ${timeout_test} \
453 ip netns exec ${connector_ns} \
454 ./mptcp_connect -t ${timeout_poll} -p $port -s ${cl_proto} \
455 $extra_args $connect_addr < "$cin" > "$cout" &
468 kill ${cappid_listener}
469 kill ${cappid_connector}
472 NSTAT_HISTORY=/tmp/${listener_ns}.nstat ip netns exec ${listener_ns} \
473 nstat | grep Tcp > /tmp/${listener_ns}.out
474 if [ ${listener_ns} != ${connector_ns} ]; then
475 NSTAT_HISTORY=/tmp/${connector_ns}.nstat ip netns exec ${connector_ns} \
476 nstat | grep Tcp > /tmp/${connector_ns}.out
480 duration=$((stop-start))
481 printf "(duration %05sms) " "${duration}"
482 if [ ${rets} -ne 0 ] || [ ${retc} -ne 0 ]; then
483 echo "[ FAIL ] client exit code $retc, server $rets" 1>&2
484 echo -e "\nnetns ${listener_ns} socket stat for ${port}:" 1>&2
485 ip netns exec ${listener_ns} ss -Menita 1>&2 -o "sport = :$port"
486 cat /tmp/${listener_ns}.out
487 echo -e "\nnetns ${connector_ns} socket stat for ${port}:" 1>&2
488 ip netns exec ${connector_ns} ss -Menita 1>&2 -o "dport = :$port"
489 [ ${listener_ns} != ${connector_ns} ] && cat /tmp/${connector_ns}.out
496 check_transfer $sin $cout "file received by client"
498 check_transfer $cin $sout "file received by server"
501 local stat_synrx_now_l=$(get_mib_counter "${listener_ns}" "MPTcpExtMPCapableSYNRX")
502 local stat_ackrx_now_l=$(get_mib_counter "${listener_ns}" "MPTcpExtMPCapableACKRX")
503 local stat_cookietx_now=$(get_mib_counter "${listener_ns}" "TcpExtSyncookiesSent")
504 local stat_cookierx_now=$(get_mib_counter "${listener_ns}" "TcpExtSyncookiesRecv")
505 local stat_ooo_now=$(get_mib_counter "${listener_ns}" "TcpExtTCPOFOQueue")
507 expect_synrx=$((stat_synrx_last_l))
508 expect_ackrx=$((stat_ackrx_last_l))
510 cookies=$(ip netns exec ${listener_ns} sysctl net.ipv4.tcp_syncookies)
511 cookies=${cookies##*=}
513 if [ ${cl_proto} = "MPTCP" ] && [ ${srv_proto} = "MPTCP" ]; then
514 expect_synrx=$((stat_synrx_last_l+$connect_per_transfer))
515 expect_ackrx=$((stat_ackrx_last_l+$connect_per_transfer))
518 if [ ${stat_synrx_now_l} -lt ${expect_synrx} ]; then
519 printf "[ FAIL ] lower MPC SYN rx (%d) than expected (%d)\n" \
520 "${stat_synrx_now_l}" "${expect_synrx}" 1>&2
523 if [ ${stat_ackrx_now_l} -lt ${expect_ackrx} -a ${stat_ooo_now} -eq 0 ]; then
524 if [ ${stat_ooo_now} -eq 0 ]; then
525 printf "[ FAIL ] lower MPC ACK rx (%d) than expected (%d)\n" \
526 "${stat_ackrx_now_l}" "${expect_ackrx}" 1>&2
529 printf "[ Note ] fallback due to TCP OoO"
534 local csum_err_s=$(get_mib_counter "${listener_ns}" "MPTcpExtDataCsumErr")
535 local csum_err_c=$(get_mib_counter "${connector_ns}" "MPTcpExtDataCsumErr")
537 local csum_err_s_nr=$((csum_err_s - stat_csum_err_s))
538 if [ $csum_err_s_nr -gt 0 ]; then
539 printf "[ FAIL ]\nserver got $csum_err_s_nr data checksum error[s]"
543 local csum_err_c_nr=$((csum_err_c - stat_csum_err_c))
544 if [ $csum_err_c_nr -gt 0 ]; then
545 printf "[ FAIL ]\nclient got $csum_err_c_nr data checksum error[s]"
550 if [ $retc -eq 0 ] && [ $rets -eq 0 ]; then
554 if [ $cookies -eq 2 ];then
555 if [ $stat_cookietx_last -ge $stat_cookietx_now ] ;then
556 printf " WARN: CookieSent: did not advance"
558 if [ $stat_cookierx_last -ge $stat_cookierx_now ] ;then
559 printf " WARN: CookieRecv: did not advance"
562 if [ $stat_cookietx_last -ne $stat_cookietx_now ] ;then
563 printf " WARN: CookieSent: changed"
565 if [ $stat_cookierx_last -ne $stat_cookierx_now ] ;then
566 printf " WARN: CookieRecv: changed"
570 if [ ${stat_synrx_now_l} -gt ${expect_synrx} ]; then
571 printf " WARN: SYNRX: expect %d, got %d (probably retransmissions)" \
572 "${expect_synrx}" "${stat_synrx_now_l}"
574 if [ ${stat_ackrx_now_l} -gt ${expect_ackrx} ]; then
575 printf " WARN: ACKRX: expect %d, got %d (probably retransmissions)" \
576 "${expect_ackrx}" "${stat_ackrx_now_l}"
581 [ $retc -eq 0 ] && [ $rets -eq 0 ]
592 if [ $SIZE -eq 0 ]; then
593 local MAXSIZE=$((1024 * 1024 * 8))
594 local MINSIZE=$((1024 * 256))
596 SIZE=$(((RANDOM * RANDOM + MINSIZE) % MAXSIZE))
599 ksize=$((SIZE / 1024))
600 rem=$((SIZE - (ksize * 1024)))
602 dd if=/dev/urandom of="$name" bs=1024 count=$ksize 2> /dev/null
603 dd if=/dev/urandom conv=notrunc of="$name" bs=1 count=$rem 2> /dev/null
604 echo -e "\nMPTCP_TEST_FILE_END_MARKER" >> "$name"
606 echo "Created $name (size $(du -b "$name")) containing data sent by $who"
611 local listener_ns="$1"
612 local connector_ns="$2"
613 local connect_addr="$3"
615 local extra_args="$5"
618 # skip if test programs are running inside same netns for subsequent runs.
619 if [ $loopback -eq 0 ] && [ ${listener_ns} = ${connector_ns} ]; then
623 # skip if we don't want v6
624 if ! $ipv6 && is_v6 "${connect_addr}"; then
629 if is_v6 "${connect_addr}"; then
635 do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP \
636 ${connect_addr} ${local_addr} "${extra_args}"
638 if [ $lret -ne 0 ]; then
643 if [ $do_tcp -eq 0 ]; then
644 # don't bother testing fallback tcp except for loopback case.
645 if [ ${listener_ns} != ${connector_ns} ]; then
650 do_transfer ${listener_ns} ${connector_ns} MPTCP TCP \
651 ${connect_addr} ${local_addr} "${extra_args}"
653 if [ $lret -ne 0 ]; then
658 do_transfer ${listener_ns} ${connector_ns} TCP MPTCP \
659 ${connect_addr} ${local_addr} "${extra_args}"
661 if [ $lret -ne 0 ]; then
666 if [ $do_tcp -gt 1 ] ;then
667 do_transfer ${listener_ns} ${connector_ns} TCP TCP \
668 ${connect_addr} ${local_addr} "${extra_args}"
670 if [ $lret -ne 0 ]; then
681 run_tests_lo $1 $2 $3 0
684 run_test_transparent()
686 local connect_addr="$1"
689 local connector_ns="$ns1"
690 local listener_ns="$ns2"
694 # skip if we don't want v6
695 if ! $ipv6 && is_v6 "${connect_addr}"; then
699 # IP(V6)_TRANSPARENT has been added after TOS support which came with
700 # the required infrastructure in MPTCP sockopt code. To support TOS, the
701 # following function has been exported (T). Not great but better than
702 # checking for a specific kernel version.
703 if ! mptcp_lib_kallsyms_has "T __ip_sock_set_tos$"; then
704 echo "INFO: ${msg} not supported by the kernel: SKIP"
708 ip netns exec "$listener_ns" nft -f /dev/stdin <<"EOF"
712 type filter hook prerouting priority -150;
714 meta l4proto tcp socket transparent 1 meta mark set 1 accept
715 tcp dport 20000 tproxy to :20000 meta mark set 1 accept
719 if [ $? -ne 0 ]; then
720 echo "SKIP: $msg, could not load nft ruleset"
725 if is_v6 "${connect_addr}"; then
732 ip -net "$listener_ns" $r6flag rule add fwmark 1 lookup 100
733 if [ $? -ne 0 ]; then
734 ip netns exec "$listener_ns" nft flush ruleset
735 echo "SKIP: $msg, ip $r6flag rule failed"
739 ip -net "$listener_ns" route add local $local_addr/0 dev lo table 100
740 if [ $? -ne 0 ]; then
741 ip netns exec "$listener_ns" nft flush ruleset
742 ip -net "$listener_ns" $r6flag rule del fwmark 1 lookup 100
743 echo "SKIP: $msg, ip route add local $local_addr failed"
747 echo "INFO: test $msg"
750 local extra_args="-o TRANSPARENT"
751 do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP \
752 ${connect_addr} ${local_addr} "${extra_args}"
755 ip netns exec "$listener_ns" nft flush ruleset
756 ip -net "$listener_ns" $r6flag rule del fwmark 1 lookup 100
757 ip -net "$listener_ns" route del local $local_addr/0 dev lo table 100
759 if [ $lret -ne 0 ]; then
760 echo "FAIL: $msg, mptcp connection error" 1>&2
773 echo "INFO: with peek mode: ${peekmode}"
774 run_tests_lo "$ns1" "$ns1" 10.0.1.1 1 "-P ${peekmode}"
775 run_tests_lo "$ns1" "$ns1" dead:beef:1::1 1 "-P ${peekmode}"
780 if ! mptcp_lib_kallsyms_has "mptcp_fastopen_"; then
781 echo "INFO: TFO not supported by the kernel: SKIP"
785 echo "INFO: with MPTFO start"
786 ip netns exec "$ns1" sysctl -q net.ipv4.tcp_fastopen=2
787 ip netns exec "$ns2" sysctl -q net.ipv4.tcp_fastopen=1
789 run_tests_lo "$ns1" "$ns2" 10.0.1.1 0 "-o MPTFO"
790 run_tests_lo "$ns1" "$ns2" 10.0.1.1 0 "-o MPTFO"
792 run_tests_lo "$ns1" "$ns2" dead:beef:1::1 0 "-o MPTFO"
793 run_tests_lo "$ns1" "$ns2" dead:beef:1::1 0 "-o MPTFO"
795 ip netns exec "$ns1" sysctl -q net.ipv4.tcp_fastopen=0
796 ip netns exec "$ns2" sysctl -q net.ipv4.tcp_fastopen=0
797 echo "INFO: with MPTFO end"
800 run_tests_disconnect()
805 if ! mptcp_lib_kallsyms_has "mptcp_pm_data_reset$"; then
806 echo "INFO: Full disconnect not supported: SKIP"
810 cat $cin $cin $cin > "$cin".disconnect
812 # force do_transfer to cope with the multiple transmissions
813 sin="$cin.disconnect"
814 cin="$cin.disconnect"
815 cin_disconnect="$old_cin"
816 connect_per_transfer=3
818 echo "INFO: disconnect"
819 run_tests_lo "$ns1" "$ns1" 10.0.1.1 1 "-I 3 -i $old_cin"
820 run_tests_lo "$ns1" "$ns1" dead:beef:1::1 1 "-I 3 -i $old_cin"
822 # restore previous status
825 cin_disconnect="$cin".disconnect
826 connect_per_transfer=1
832 time_run=$((time_end-time_start))
834 echo "Time: ${time_run} seconds"
841 if [ ${ret} -ne 0 ]; then
842 echo "FAIL: ${msg}" 1>&2
848 make_file "$cin" "client"
849 make_file "$sin" "server"
853 stop_if_error "The kernel configuration is not valid for MPTCP"
855 echo "INFO: validating network environment with pings"
856 for sender in "$ns1" "$ns2" "$ns3" "$ns4";do
857 do_ping "$ns1" $sender 10.0.1.1
858 do_ping "$ns1" $sender dead:beef:1::1
860 do_ping "$ns2" $sender 10.0.1.2
861 do_ping "$ns2" $sender dead:beef:1::2
862 do_ping "$ns2" $sender 10.0.2.1
863 do_ping "$ns2" $sender dead:beef:2::1
865 do_ping "$ns3" $sender 10.0.2.2
866 do_ping "$ns3" $sender dead:beef:2::2
867 do_ping "$ns3" $sender 10.0.3.2
868 do_ping "$ns3" $sender dead:beef:3::2
870 do_ping "$ns4" $sender 10.0.3.1
871 do_ping "$ns4" $sender dead:beef:3::1
874 stop_if_error "Could not even run ping tests"
876 [ -n "$tc_loss" ] && tc -net "$ns2" qdisc add dev ns2eth3 root netem loss random $tc_loss delay ${tc_delay}ms
877 echo -n "INFO: Using loss of $tc_loss "
878 test "$tc_delay" -gt 0 && echo -n "delay $tc_delay ms "
880 reorder_delay=$(($tc_delay / 4))
882 if [ -z "${tc_reorder}" ]; then
883 reorder1=$((RANDOM%10))
884 reorder1=$((100 - reorder1))
885 reorder2=$((RANDOM%100))
887 if [ $reorder_delay -gt 0 ] && [ $reorder1 -lt 100 ] && [ $reorder2 -gt 0 ]; then
888 tc_reorder="reorder ${reorder1}% ${reorder2}%"
889 echo -n "$tc_reorder with delay ${reorder_delay}ms "
891 elif [ "$tc_reorder" = "0" ];then
893 elif [ "$reorder_delay" -gt 0 ];then
894 # reordering requires some delay
895 tc_reorder="reorder $tc_reorder"
896 echo -n "$tc_reorder with delay ${reorder_delay}ms "
901 tc -net "$ns3" qdisc add dev ns3eth4 root netem delay ${reorder_delay}ms $tc_reorder
903 run_tests_lo "$ns1" "$ns1" 10.0.1.1 1
904 stop_if_error "Could not even run loopback test"
906 run_tests_lo "$ns1" "$ns1" dead:beef:1::1 1
907 stop_if_error "Could not even run loopback v6 test"
909 for sender in $ns1 $ns2 $ns3 $ns4;do
910 # ns1<->ns2 is not subject to reordering/tc delays. Use it to test
911 # mptcp syncookie support.
912 if [ $sender = $ns1 ]; then
913 ip netns exec "$ns2" sysctl -q net.ipv4.tcp_syncookies=2
915 ip netns exec "$ns2" sysctl -q net.ipv4.tcp_syncookies=1
918 run_tests "$ns1" $sender 10.0.1.1
919 run_tests "$ns1" $sender dead:beef:1::1
921 run_tests "$ns2" $sender 10.0.1.2
922 run_tests "$ns2" $sender dead:beef:1::2
923 run_tests "$ns2" $sender 10.0.2.1
924 run_tests "$ns2" $sender dead:beef:2::1
926 run_tests "$ns3" $sender 10.0.2.2
927 run_tests "$ns3" $sender dead:beef:2::2
928 run_tests "$ns3" $sender 10.0.3.2
929 run_tests "$ns3" $sender dead:beef:3::2
931 run_tests "$ns4" $sender 10.0.3.1
932 run_tests "$ns4" $sender dead:beef:3::1
934 stop_if_error "Tests with $sender as a sender have failed"
937 run_tests_peekmode "saveWithPeek"
938 run_tests_peekmode "saveAfterPeek"
939 stop_if_error "Tests with peek mode have failed"
941 # MPTFO (MultiPath TCP Fatopen tests)
943 stop_if_error "Tests with MPTFO have failed"
945 # connect to ns4 ip address, ns2 should intercept/proxy
946 run_test_transparent 10.0.3.1 "tproxy ipv4"
947 run_test_transparent dead:beef:3::1 "tproxy ipv6"
948 stop_if_error "Tests with tproxy have failed"