Home | History | Annotate | Download | only in examples
      1 #!/bin/sh
      2 #
      3 # This is an example script for using netperf. Feel free to modify it 
      4 # as necessary, but I would suggest that you copy this one first.
      5 #
      6 # 
      7 # This version has been modified to take advantage of the confidence
      8 # interval support in revision 2.0 of netperf. it has also been altered
      9 # to make submitting its resutls to the netperf database easier
     10 # raj 11/94
     11 #
     12 # usage: tcp_rr_script hostname [CPU]
     13 #
     14 
     15 if [ $# -gt 2 ]; then
     16   echo "try again, correctly -> tcp_rr_script hostname [CPU]"
     17   exit 1
     18 fi
     19 
     20 if [ $# -eq 0 ]; then
     21   echo "try again, correctly -> tcp_rr_script hostname [CPU]"
     22   exit 1
     23 fi
     24 
     25 # where the programs are
     26 #NETHOME=/usr/local/netperf
     27 #NETHOME="/opt/netperf"
     28 NETHOME=.
     29 
     30 # at what port will netserver be waiting? If you decide to run
     31 # netserver at a differnet port than the default of 12865, then set
     32 # the value of PORT apropriately
     33 #PORT="-p some_other_portnum"
     34 PORT=""
     35 
     36 # The test length in seconds
     37 TEST_TIME=60
     38 
     39 # How accurate we want the estimate of performance: 
     40 #      maximum and minimum test iterations (-i)
     41 #      confidence level (99 or 95) and interval (percent)
     42 STATS_STUFF="-i 10,3 -I 99,5"
     43 
     44 # The socket sizes that we will be testing - using zero will let it 
     45 # be the system default.
     46 SOCKET_SIZES="0"
     47 
     48 # The request,response sizes that we will be using. The netperf
     49 # command parser will treat "1" the same as "1,1" - I use 1,1 to
     50 # remember that it is "request,response"
     51 RR_SIZES="1,1 64,64 100,200 128,8192"
     52 
     53 # if there are two parms, parm one it the hostname and parm two will
     54 # be a CPU indicator. actually, anything as a second parm will cause
     55 # the CPU to be measured, but we will "advertise" it should be "CPU"
     56 
     57 if [ $# -eq 2 ]; then
     58   REM_HOST=$1
     59   LOC_CPU="-c"
     60   REM_CPU="-C"
     61 fi
     62 
     63 if [ $# -eq 1 ]; then
     64   REM_HOST=$1
     65 fi
     66 
     67 # If we are measuring CPU utilization, then we can save beaucoup
     68 # time by saving the results of the CPU calibration and passing
     69 # them in during the real tests. So, we execute the new CPU "tests"
     70 # of netperf and put the values into shell vars.
     71 case $LOC_CPU in
     72 \-c) LOC_RATE=`$NETHOME/netperf $PORT -t LOC_CPU`;;
     73 *) LOC_RATE=""
     74 esac
     75 
     76 case $REM_CPU in
     77 \-C) REM_RATE=`$NETHOME/netperf $PORT -t REM_CPU -H $REM_HOST`;;
     78 *) REM_RATE=""
     79 esac
     80 
     81 # This disables header display
     82 NO_HDR="-P 0"
     83 
     84 for SOCKET_SIZE in $SOCKET_SIZES
     85  do
     86   for RR_SIZE in $RR_SIZES
     87    do
     88    echo
     89    echo ------------------------------------------------------
     90    echo Testing with the following command line:
     91    # we echo the command line for cut and paste to th database
     92    echo $NETHOME/netperf $PORT -l $TEST_TIME -H $REM_HOST -t TCP_RR \
     93         $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE $STATS_STUFF --\
     94         -r $RR_SIZE -s $SOCKET_SIZE -S $SOCKET_SIZE
     95    echo
     96    # since we have the confidence interval stuff, we do not
     97    # need to repeat a test multiple times from the shell
     98    $NETHOME/netperf $PORT -l $TEST_TIME -H $REM_HOST -t TCP_RR \
     99    $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE $STATS_STUFF --\
    100    -r $RR_SIZE -s $SOCKET_SIZE -S $SOCKET_SIZE
    101  done
    102 done
    103 echo
    104