Home | History | Annotate | Download | only in tcp_fastopen
      1 #!/bin/sh
      2 # Copyright (c) 2014-2016 Oracle and/or its affiliates. All Rights Reserved.
      3 #
      4 # This program is free software; you can redistribute it and/or
      5 # modify it under the terms of the GNU General Public License as
      6 # published by the Free Software Foundation; either version 2 of
      7 # the License, or (at your option) any later version.
      8 #
      9 # This program is distributed in the hope that it would be useful,
     10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
     11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     12 # GNU General Public License for more details.
     13 #
     14 # You should have received a copy of the GNU General Public License
     15 # along with this program; if not, write the Free Software Foundation,
     16 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
     17 #
     18 # Author: Alexey Kodanev <alexey.kodanev (at] oracle.com>
     19 #
     20 
     21 # default command-line options
     22 user_name="root"
     23 use_ssh=0
     24 clients_num=2
     25 client_requests=2000000
     26 max_requests=3
     27 
     28 TST_TOTAL=1
     29 TCID="tcp_fastopen"
     30 
     31 . test_net.sh
     32 
     33 while getopts :hu:sr:p:n:R:6 opt; do
     34 	case "$opt" in
     35 	h)
     36 		echo "Usage:"
     37 		echo "h        help"
     38 		echo "u x      server user name"
     39 		echo "s        use ssh to run remote cmds"
     40 		echo "n x      num of clients running in parallel"
     41 		echo "r x      the number of client requests"
     42 		echo "R x      num of requests, after which conn. closed"
     43 		echo "6        run over IPv6"
     44 		exit 0
     45 	;;
     46 	u) user_name=$OPTARG ;;
     47 	s) export TST_USE_SSH=1 ;;
     48 	n) clients_num=$OPTARG ;;
     49 	r) client_requests=$OPTARG ;;
     50 	R) max_requests=$OPTARG ;;
     51 	6) # skip, test_net library already processed it
     52 	;;
     53 	*) tst_brkm TBROK "unknown option: $opt" ;;
     54 	esac
     55 done
     56 
     57 cleanup()
     58 {
     59 	tst_rmdir
     60 }
     61 
     62 tst_require_root
     63 
     64 if tst_kvcmp -lt "3.7"; then
     65 	tst_brkm TCONF "test must be run with kernel 3.7 or newer"
     66 fi
     67 
     68 if tst_kvcmp -lt "3.16" && [ "$TST_IPV6" ]; then
     69 	tst_brkm TCONF "test must be run with kernel 3.16 or newer"
     70 fi
     71 
     72 trap "tst_brkm TBROK 'test interrupted'" INT
     73 TST_CLEANUP="cleanup"
     74 tst_tmpdir
     75 
     76 tst_resm TINFO "using old TCP API and set tcp_fastopen to '0'"
     77 tst_netload -H $(tst_ipaddr rhost) -a $clients_num -r $client_requests \
     78 	-R $max_requests -t 0
     79 time_tfo_off=$(cat tst_netload.res)
     80 
     81 tst_resm TINFO "using new TCP API and set tcp_fastopen to '3'"
     82 tst_netload -H $(tst_ipaddr rhost)  -a $clients_num -r $client_requests \
     83 	-R $max_requests -f -t 3
     84 time_tfo_on=$(cat tst_netload.res)
     85 
     86 tfo_cmp=$(( 100 - ($time_tfo_on * 100) / $time_tfo_off ))
     87 
     88 if [ "$tfo_cmp" -lt 3 ]; then
     89 	tst_resm TFAIL "TFO performance result is '$tfo_cmp' percent"
     90 else
     91 	tst_resm TPASS "TFO performance result is '$tfo_cmp' percent"
     92 fi
     93 
     94 tst_exit
     95