@@ -128,6 +128,7 @@ cleanup()
128
128
local netns
129
129
for netns in " $ns1 " " $ns2 " " $ns3 " " $ns4 " ; do
130
130
ip netns del $netns
131
+ rm -f /tmp/$netns .{nstat,out}
131
132
done
132
133
}
133
134
@@ -333,6 +334,21 @@ do_ping()
333
334
return 0
334
335
}
335
336
337
+ # $1: ns, $2: MIB counter
338
+ get_mib_counter ()
339
+ {
340
+ local listener_ns=" ${1} "
341
+ local mib=" ${2} "
342
+
343
+ # strip the header
344
+ ip netns exec " ${listener_ns} " \
345
+ nstat -z -a " ${mib} " | \
346
+ tail -n+2 | \
347
+ while read a count c rest; do
348
+ echo $count
349
+ done
350
+ }
351
+
336
352
# $1: ns, $2: port
337
353
wait_local_port_listen ()
338
354
{
@@ -409,10 +425,10 @@ do_transfer()
409
425
sleep 1
410
426
fi
411
427
412
- local stat_synrx_last_l=$( ip netns exec ${listener_ns} nstat -z -a MPTcpExtMPCapableSYNRX | while read a count c rest ; do echo $count ; done )
413
- local stat_ackrx_last_l=$( ip netns exec ${listener_ns} nstat -z -a MPTcpExtMPCapableACKRX | while read a count c rest ; do echo $count ; done )
414
- local stat_cookietx_last=$( ip netns exec ${listener_ns} nstat -z -a TcpExtSyncookiesSent | while read a count c rest ; do echo $count ; done )
415
- local stat_cookierx_last=$( ip netns exec ${listener_ns} nstat -z -a TcpExtSyncookiesRecv | while read a count c rest ; do echo $count ; done )
428
+ local stat_synrx_last_l=$( get_mib_counter " ${listener_ns} " " MPTcpExtMPCapableSYNRX" )
429
+ local stat_ackrx_last_l=$( get_mib_counter " ${listener_ns} " " MPTcpExtMPCapableACKRX" )
430
+ local stat_cookietx_last=$( get_mib_counter " ${listener_ns} " " TcpExtSyncookiesSent" )
431
+ local stat_cookierx_last=$( get_mib_counter " ${listener_ns} " " TcpExtSyncookiesRecv" )
416
432
417
433
ip netns exec ${listener_ns} ./mptcp_connect -t $timeout -l -p $port -s ${srv_proto} $extra_args $local_addr < " $sin " > " $sout " &
418
434
local spid=$!
@@ -438,16 +454,26 @@ do_transfer()
438
454
kill ${cappid_connector}
439
455
fi
440
456
457
+ NSTAT_HISTORY=/tmp/${listener_ns} .nstat ip netns exec ${listener_ns} \
458
+ nstat | grep Tcp > /tmp/${listener_ns} .out
459
+ if [ ${listener_ns} != ${connector_ns} ]; then
460
+ NSTAT_HISTORY=/tmp/${connector_ns} .nstat ip netns exec ${connector_ns} \
461
+ nstat | grep Tcp > /tmp/${connector_ns} .out
462
+ fi
463
+
441
464
local duration
442
465
duration=$(( stop- start))
443
- duration= $( printf " (duration %05sms)" $ duration)
466
+ printf " (duration %05sms) " " ${ duration} "
444
467
if [ ${rets} -ne 0 ] || [ ${retc} -ne 0 ]; then
445
- echo " $duration [ FAIL ] client exit code $retc , server $rets " 1>&2
468
+ echo " [ FAIL ] client exit code $retc , server $rets " 1>&2
446
469
echo -e " \nnetns ${listener_ns} socket stat for ${port} :" 1>&2
447
- ip netns exec ${listener_ns} ss -nita 1>&2 -o " sport = :$port "
470
+ ip netns exec ${listener_ns} ss -Menita 1>&2 -o " sport = :$port "
471
+ cat /tmp/${listener_ns} .out
448
472
echo -e " \nnetns ${connector_ns} socket stat for ${port} :" 1>&2
449
- ip netns exec ${connector_ns} ss -nita 1>&2 -o " dport = :$port "
473
+ ip netns exec ${connector_ns} ss -Menita 1>&2 -o " dport = :$port "
474
+ [ ${listener_ns} != ${connector_ns} ] && cat /tmp/${connector_ns} .out
450
475
476
+ echo
451
477
cat " $capout "
452
478
return 1
453
479
fi
@@ -457,11 +483,10 @@ do_transfer()
457
483
check_transfer $cin $sout " file received by server"
458
484
rets=$?
459
485
460
- local stat_synrx_now_l=$( ip netns exec ${listener_ns} nstat -z -a MPTcpExtMPCapableSYNRX | while read a count c rest ; do echo $count ; done)
461
- local stat_ackrx_now_l=$( ip netns exec ${listener_ns} nstat -z -a MPTcpExtMPCapableACKRX | while read a count c rest ; do echo $count ; done)
462
-
463
- local stat_cookietx_now=$( ip netns exec ${listener_ns} nstat -z -a TcpExtSyncookiesSent | while read a count c rest ; do echo $count ; done)
464
- local stat_cookierx_now=$( ip netns exec ${listener_ns} nstat -z -a TcpExtSyncookiesRecv | while read a count c rest ; do echo $count ; done)
486
+ local stat_synrx_now_l=$( get_mib_counter " ${listener_ns} " " MPTcpExtMPCapableSYNRX" )
487
+ local stat_ackrx_now_l=$( get_mib_counter " ${listener_ns} " " MPTcpExtMPCapableACKRX" )
488
+ local stat_cookietx_now=$( get_mib_counter " ${listener_ns} " " TcpExtSyncookiesSent" )
489
+ local stat_cookierx_now=$( get_mib_counter " ${listener_ns} " " TcpExtSyncookiesRecv" )
465
490
466
491
expect_synrx=$(( stat_synrx_last_l))
467
492
expect_ackrx=$(( stat_ackrx_last_l))
@@ -473,37 +498,50 @@ do_transfer()
473
498
expect_synrx=$(( stat_synrx_last_l+ 1 ))
474
499
expect_ackrx=$(( stat_ackrx_last_l+ 1 ))
475
500
fi
501
+
502
+ if [ ${stat_synrx_now_l} -lt ${expect_synrx} ]; then
503
+ printf " [ FAIL ] lower MPC SYN rx (%d) than expected (%d)\n" \
504
+ " ${stat_synrx_now_l} " " ${expect_synrx} " 1>&2
505
+ retc=1
506
+ fi
507
+ if [ ${stat_ackrx_now_l} -lt ${expect_ackrx} ]; then
508
+ printf " [ FAIL ] lower MPC ACK rx (%d) than expected (%d)\n" \
509
+ " ${stat_ackrx_now_l} " " ${expect_ackrx} " 1>&2
510
+ rets=1
511
+ fi
512
+
513
+ if [ $retc -eq 0 ] && [ $rets -eq 0 ]; then
514
+ printf " [ OK ]"
515
+ fi
516
+
476
517
if [ $cookies -eq 2 ]; then
477
518
if [ $stat_cookietx_last -ge $stat_cookietx_now ] ; then
478
- echo " ${listener_ns} CookieSent: ${cl_proto} -> ${srv_proto} : did not advance"
519
+ printf " WARN: CookieSent : did not advance"
479
520
fi
480
521
if [ $stat_cookierx_last -ge $stat_cookierx_now ] ; then
481
- echo " ${listener_ns} CookieRecv: ${cl_proto} -> ${srv_proto} : did not advance"
522
+ printf " WARN: CookieRecv : did not advance"
482
523
fi
483
524
else
484
525
if [ $stat_cookietx_last -ne $stat_cookietx_now ] ; then
485
- echo " ${listener_ns} CookieSent: ${cl_proto} -> ${srv_proto} : changed"
526
+ printf " WARN: CookieSent : changed"
486
527
fi
487
528
if [ $stat_cookierx_last -ne $stat_cookierx_now ] ; then
488
- echo " ${listener_ns} CookieRecv: ${cl_proto} -> ${srv_proto} : changed"
529
+ printf " WARN: CookieRecv : changed"
489
530
fi
490
531
fi
491
532
492
- if [ $expect_synrx -ne $stat_synrx_now_l ] ; then
493
- echo " ${listener_ns} SYNRX: ${cl_proto} -> ${srv_proto} : expect ${expect_synrx} , got ${stat_synrx_now_l} "
533
+ if [ ${stat_synrx_now_l} -gt ${expect_synrx} ]; then
534
+ printf " WARN: SYNRX: expect %d, got %d (probably retransmissions)" \
535
+ " ${expect_synrx} " " ${stat_synrx_now_l} "
494
536
fi
495
- if [ $expect_ackrx -ne $stat_ackrx_now_l ] ; then
496
- echo " ${listener_ns} ACKRX: ${cl_proto} -> ${srv_proto} : expect ${expect_synrx} , got ${stat_synrx_now_l} "
497
- fi
498
-
499
- if [ $retc -eq 0 ] && [ $rets -eq 0 ]; then
500
- echo " $duration [ OK ]"
501
- cat " $capout "
502
- return 0
537
+ if [ ${stat_ackrx_now_l} -gt ${expect_ackrx} ]; then
538
+ printf " WARN: ACKRX: expect %d, got %d (probably retransmissions)" \
539
+ " ${expect_ackrx} " " ${stat_ackrx_now_l} "
503
540
fi
504
541
542
+ echo
505
543
cat " $capout "
506
- return 1
544
+ [ $retc -eq 0 ] && [ $rets -eq 0 ]
507
545
}
508
546
509
547
make_file ()
0 commit comments