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 # uncomment the next line if you think the script is broken
      8 #set -x
      9 
     10 
     11 if [ $# -gt 2 ]; then
     12   echo "try again, correctly -> udp_rr_script hostname [CPU]"
     13   exit 1
     14 fi
     15 
     16 if [ $# -eq 0 ]; then
     17   echo "try again, correctly -> udp_rr_script hostname [CPU]"
     18   exit 1
     19 fi
     20 
     21 # where the programs are
     22 
     23 #NETHOME=/usr/local/netperf
     24 #NETHOME="/opt/netperf"
     25 NETHOME="."
     26 
     27 # at what port will netserver be waiting? If you decide to run
     28 # netserver at a differnet port than the default of 12865, then set
     29 # the value of PORT apropriately
     30 #PORT="-p some_other_portnum"
     31 PORT=""
     32 
     33 
     34 # The test length in seconds
     35 
     36 TEST_TIME=60
     37 
     38 # How accurate we want the estimate of performance: 
     39 #      maximum and minimum test iterations (-i)
     40 #      confidence level (99 or 95) and interval (percent)
     41 
     42 STATS_STUFF="-i 10,2 -I 99,10"
     43 
     44 # The socket sizes that we will be testing - -1 means use default
     45 # not much point in changing the socket buffer for a UDP request/
     46 # response test - unless you want to have requests/responses which 
     47 # are larger than the default
     48 
     49 SOCKET_SIZES="-1"
     50 
     51 # The send sizes that we will be using
     52 
     53 RR_SIZES="1,1 64,64 100,200 1024,1024"
     54 
     55 # if there are two parms, parm one it the hostname and parm two will
     56 # be a CPU indicator. actually, anything as a second parm will cause
     57 # the CPU to be measured, but we will "advertise" it should be "CPU"
     58 
     59 if [ $# -eq 2 ]; then
     60   REM_HOST=$1
     61   LOC_CPU="-c"
     62   REM_CPU="-C"
     63 fi
     64 
     65 if [ $# -eq 1 ]; then
     66   LOC_CPU=""
     67   REM_CPU=""
     68   REM_HOST=$1
     69 fi
     70 
     71 # If we are measuring CPU utilization, then we can save beaucoup
     72 # time by saving the results of the CPU calibration and passing
     73 # them in during the real tests. So, we execute the new CPU "tests"
     74 # of netperf and put the values into shell vars.
     75 case $LOC_CPU in
     76 \-c) LOC_RATE=`$NETHOME/netperf $PORT -t LOC_CPU`;;
     77 *) LOC_RATE=""
     78 esac
     79 
     80 case $REM_CPU in
     81 \-C) REM_RATE=`$NETHOME/netperf $PORT -t REM_CPU -H $REM_HOST`;;
     82 *) REM_RATE=""
     83 esac
     84 
     85 # This turns-off the display headers
     86 NO_HDR="-P 0"
     87 
     88 for SOCKET_SIZE in $SOCKET_SIZES
     89 do
     90   for RR_SIZE in $RR_SIZES
     91   do
     92   echo
     93   echo ------------------------------------------------------
     94   echo Testing with the following command line:
     95   echo $NETHOME/netperf $PORT -l $TEST_TIME -H $REM_HOST $STATS_STUFF \
     96                   $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE -t UDP_RR --\
     97                   -r $RR_SIZE -s $SOCKET_SIZE -S $SOCKET_SIZE
     98   $NETHOME/netperf $PORT -l $TEST_TIME -H $REM_HOST $STATS_STUFF \
     99     $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE -t UDP_RR $NO_HDR --\
    100                   -r $RR_SIZE -s $SOCKET_SIZE -S $SOCKET_SIZE
    101   done
    102 done
    103 echo
    104