Commit 767659f6 authored by Florian Westphal's avatar Florian Westphal Committed by David S. Miller

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: default avatarFlorian Westphal <fw@strlen.de>
Reviewed-by: default avatarMatthieu Baerts <matthieu.baerts@tessares.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b97e9d9d
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
time_start=$(date +%s) time_start=$(date +%s)
optstring="S:R:d:e:l:r:h4cm:" optstring="S:R:d:e:l:r:h4cm:f:t"
ret=0 ret=0
sin="" sin=""
sout="" sout=""
...@@ -21,6 +21,8 @@ testmode="" ...@@ -21,6 +21,8 @@ testmode=""
sndbuf=0 sndbuf=0
rcvbuf=0 rcvbuf=0
options_log=true options_log=true
do_tcp=0
filesize=0
if [ $tc_loss -eq 100 ];then if [ $tc_loss -eq 100 ];then
tc_loss=1% tc_loss=1%
...@@ -40,9 +42,11 @@ usage() { ...@@ -40,9 +42,11 @@ usage() {
echo -e "\t-e: ethtool features to disable, e.g.: \"-e tso -e gso\" (default: randomly disable any of tso/gso/gro)" echo -e "\t-e: ethtool features to disable, e.g.: \"-e tso -e gso\" (default: randomly disable any of tso/gso/gro)"
echo -e "\t-4: IPv4 only: disable IPv6 tests (default: test both IPv4 and IPv6)" echo -e "\t-4: IPv4 only: disable IPv6 tests (default: test both IPv4 and IPv6)"
echo -e "\t-c: capture packets for each test using tcpdump (default: no capture)" echo -e "\t-c: capture packets for each test using tcpdump (default: no capture)"
echo -e "\t-f: size of file to transfer in bytes (default random)"
echo -e "\t-S: set sndbuf value (default: use kernel default)" echo -e "\t-S: set sndbuf value (default: use kernel default)"
echo -e "\t-R: set rcvbuf value (default: use kernel default)" echo -e "\t-R: set rcvbuf value (default: use kernel default)"
echo -e "\t-m: test mode (poll, sendfile; default: poll)" echo -e "\t-m: test mode (poll, sendfile; default: poll)"
echo -e "\t-t: also run tests with TCP (use twice to non-fallback tcp)"
} }
while getopts "$optstring" option;do while getopts "$optstring" option;do
...@@ -94,6 +98,12 @@ while getopts "$optstring" option;do ...@@ -94,6 +98,12 @@ while getopts "$optstring" option;do
"m") "m")
testmode="$OPTARG" testmode="$OPTARG"
;; ;;
"f")
filesize="$OPTARG"
;;
"t")
do_tcp=$((do_tcp+1))
;;
"?") "?")
usage $0 usage $0
exit 1 exit 1
...@@ -449,20 +459,25 @@ make_file() ...@@ -449,20 +459,25 @@ make_file()
{ {
local name=$1 local name=$1
local who=$2 local who=$2
local SIZE=$filesize
local ksize
local rem
if [ $SIZE -eq 0 ]; then
local MAXSIZE=$((1024 * 1024 * 8))
local MINSIZE=$((1024 * 256))
local SIZE TSIZE SIZE=$(((RANDOM * RANDOM + MINSIZE) % MAXSIZE))
SIZE=$((RANDOM % (1024 * 8))) fi
TSIZE=$((SIZE * 1024))
dd if=/dev/urandom of="$name" bs=1024 count=$SIZE 2> /dev/null ksize=$((SIZE / 1024))
rem=$((SIZE - (ksize * 1024)))
SIZE=$((RANDOM % 1024)) dd if=/dev/urandom of="$name" bs=1024 count=$ksize 2> /dev/null
SIZE=$((SIZE + 128)) dd if=/dev/urandom conv=notrunc of="$name" bs=1 count=$rem 2> /dev/null
TSIZE=$((TSIZE + SIZE))
dd if=/dev/urandom conv=notrunc of="$name" bs=1 count=$SIZE 2> /dev/null
echo -e "\nMPTCP_TEST_FILE_END_MARKER" >> "$name" echo -e "\nMPTCP_TEST_FILE_END_MARKER" >> "$name"
echo "Created $name (size $TSIZE) containing data sent by $who" echo "Created $name (size $(du -b "$name")) containing data sent by $who"
} }
run_tests_lo() run_tests_lo()
...@@ -497,10 +512,12 @@ run_tests_lo() ...@@ -497,10 +512,12 @@ run_tests_lo()
return 1 return 1
fi fi
if [ $do_tcp -eq 0 ]; then
# don't bother testing fallback tcp except for loopback case. # don't bother testing fallback tcp except for loopback case.
if [ ${listener_ns} != ${connector_ns} ]; then if [ ${listener_ns} != ${connector_ns} ]; then
return 0 return 0
fi fi
fi
do_transfer ${listener_ns} ${connector_ns} MPTCP TCP ${connect_addr} ${local_addr} do_transfer ${listener_ns} ${connector_ns} MPTCP TCP ${connect_addr} ${local_addr}
lret=$? lret=$?
...@@ -516,6 +533,15 @@ run_tests_lo() ...@@ -516,6 +533,15 @@ run_tests_lo()
return 1 return 1
fi fi
if [ $do_tcp -gt 1 ] ;then
do_transfer ${listener_ns} ${connector_ns} TCP TCP ${connect_addr} ${local_addr}
lret=$?
if [ $lret -ne 0 ]; then
ret=$lret
return 1
fi
fi
return 0 return 0
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment