Skip to content

Commit 767659f

Browse files
Florian Westphaldavem330
authored andcommitted
selftests: mptcp: add option to specify size of file to transfer
The script generates two random files that are then sent via tcp and mptcp connections. In order to compare throughput over consecutive runs add an option to provide the file size on the command line: "-f 128000". Also add an option, -t, to enable tcp tests. This is useful to compare throughput of mptcp connections and tcp connections. Example: run tests with a 4mb file size, 300ms delay 0.01% loss, default gso/tso/gro settings and with large write/blocking io: mptcp_connect.sh -t -f $((4 * 1024 * 1024)) -d 300 -l 0.01% -r 0 -e "" -m mmap Signed-off-by: Florian Westphal <[email protected]> Reviewed-by: Matthieu Baerts <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b97e9d9 commit 767659f

File tree

1 file changed

+39
-13
lines changed

1 file changed

+39
-13
lines changed

tools/testing/selftests/net/mptcp/mptcp_connect.sh

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
time_start=$(date +%s)
55

6-
optstring="S:R:d:e:l:r:h4cm:"
6+
optstring="S:R:d:e:l:r:h4cm:f:t"
77
ret=0
88
sin=""
99
sout=""
@@ -21,6 +21,8 @@ testmode=""
2121
sndbuf=0
2222
rcvbuf=0
2323
options_log=true
24+
do_tcp=0
25+
filesize=0
2426

2527
if [ $tc_loss -eq 100 ];then
2628
tc_loss=1%
@@ -40,9 +42,11 @@ usage() {
4042
echo -e "\t-e: ethtool features to disable, e.g.: \"-e tso -e gso\" (default: randomly disable any of tso/gso/gro)"
4143
echo -e "\t-4: IPv4 only: disable IPv6 tests (default: test both IPv4 and IPv6)"
4244
echo -e "\t-c: capture packets for each test using tcpdump (default: no capture)"
45+
echo -e "\t-f: size of file to transfer in bytes (default random)"
4346
echo -e "\t-S: set sndbuf value (default: use kernel default)"
4447
echo -e "\t-R: set rcvbuf value (default: use kernel default)"
4548
echo -e "\t-m: test mode (poll, sendfile; default: poll)"
49+
echo -e "\t-t: also run tests with TCP (use twice to non-fallback tcp)"
4650
}
4751

4852
while getopts "$optstring" option;do
@@ -94,6 +98,12 @@ while getopts "$optstring" option;do
9498
"m")
9599
testmode="$OPTARG"
96100
;;
101+
"f")
102+
filesize="$OPTARG"
103+
;;
104+
"t")
105+
do_tcp=$((do_tcp+1))
106+
;;
97107
"?")
98108
usage $0
99109
exit 1
@@ -449,20 +459,25 @@ make_file()
449459
{
450460
local name=$1
451461
local who=$2
462+
local SIZE=$filesize
463+
local ksize
464+
local rem
452465

453-
local SIZE TSIZE
454-
SIZE=$((RANDOM % (1024 * 8)))
455-
TSIZE=$((SIZE * 1024))
466+
if [ $SIZE -eq 0 ]; then
467+
local MAXSIZE=$((1024 * 1024 * 8))
468+
local MINSIZE=$((1024 * 256))
456469

457-
dd if=/dev/urandom of="$name" bs=1024 count=$SIZE 2> /dev/null
470+
SIZE=$(((RANDOM * RANDOM + MINSIZE) % MAXSIZE))
471+
fi
458472

459-
SIZE=$((RANDOM % 1024))
460-
SIZE=$((SIZE + 128))
461-
TSIZE=$((TSIZE + SIZE))
462-
dd if=/dev/urandom conv=notrunc of="$name" bs=1 count=$SIZE 2> /dev/null
473+
ksize=$((SIZE / 1024))
474+
rem=$((SIZE - (ksize * 1024)))
475+
476+
dd if=/dev/urandom of="$name" bs=1024 count=$ksize 2> /dev/null
477+
dd if=/dev/urandom conv=notrunc of="$name" bs=1 count=$rem 2> /dev/null
463478
echo -e "\nMPTCP_TEST_FILE_END_MARKER" >> "$name"
464479

465-
echo "Created $name (size $TSIZE) containing data sent by $who"
480+
echo "Created $name (size $(du -b "$name")) containing data sent by $who"
466481
}
467482

468483
run_tests_lo()
@@ -497,9 +512,11 @@ run_tests_lo()
497512
return 1
498513
fi
499514

500-
# don't bother testing fallback tcp except for loopback case.
501-
if [ ${listener_ns} != ${connector_ns} ]; then
502-
return 0
515+
if [ $do_tcp -eq 0 ]; then
516+
# don't bother testing fallback tcp except for loopback case.
517+
if [ ${listener_ns} != ${connector_ns} ]; then
518+
return 0
519+
fi
503520
fi
504521

505522
do_transfer ${listener_ns} ${connector_ns} MPTCP TCP ${connect_addr} ${local_addr}
@@ -516,6 +533,15 @@ run_tests_lo()
516533
return 1
517534
fi
518535

536+
if [ $do_tcp -gt 1 ] ;then
537+
do_transfer ${listener_ns} ${connector_ns} TCP TCP ${connect_addr} ${local_addr}
538+
lret=$?
539+
if [ $lret -ne 0 ]; then
540+
ret=$lret
541+
return 1
542+
fi
543+
fi
544+
519545
return 0
520546
}
521547

0 commit comments

Comments
 (0)