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