#!/bin/sh
#
# This is an example script for using netperf. Feel free to modify it 
# as necessary, but I would suggest that you copy this one first.
#
#
# uncomment the next line if you think the script is broken
#set -x

# This points me at the program
NETHOME=/usr/local/netperf

# The name of the remote machine
REM_HOST="localhost"

# The test length in seconds
TEST_TIME=60

# The socket sizes that we will be testing - 0 means use default
# not much point in changing the socket buffr for a UDP request/response
# test - unless you want to have requests/responses whicha re larger than
# the default
SOCKET_SIZES="0"

# The send sizes that we will be using
RR_SIZES="1,1 64,64 100,200 1024,1024"

# Do you want local cpu usage? Use the line that defines LOC_CPU as "-c"
# Otherwise, define it as ""
#LOC_CPU="-c"
LOC_CPU=""

# Do you want remote cpu usage? Use the line that defines REM_CPU as "-C"
# Otherwise, define it as ""
#REM_CPU="-C"
REM_CPU=""

# If we are measuring CPU utilization, then we can save beaucoup
# time by saving the results of the CPU calibration and passing
# them in during the real tests. So, we execute the new CPU "tests"
# of netperf and put the values into shell vars.
case $LOC_CPU in
\-c) LOC_RATE=`$NETHOME/netperf -t LOC_CPU`;;
*) LOC_RATE=""
esac

case $REM_CPU in
\-C) REM_RATE=`$NETHOME/netperf -t REM_CPU -H $REM_HOST`;;
*) REM_RATE=""
esac

# This turns-off the display headers
NO_HDR="-P 0"

for SOCKET_SIZE in $SOCKET_SIZES
	do
	for RR_SIZE in $RR_SIZES
		do
		echo
		echo
		echo Testing with $SOCKET_SIZE sockets and $RR_SIZE req/rep
		echo ------------------------------------------------------
		echo
		$NETHOME/netperf -l $TEST_TIME -H $REM_HOST \
                  $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE -t UDP_RR --\
                  -r $RR_SIZE -s $SOCKET_SIZE -S $SOCKET_SIZE
		$NETHOME/netperf -l $TEST_TIME -H $REM_HOST \
		  $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE -t UDP_RR $NO_HDR --\
                  -r $RR_SIZE -s $SOCKET_SIZE -S $SOCKET_SIZE
		$NETHOME/netperf -l $TEST_TIME -H $REM_HOST \
                  $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE -t UDP_RR $NO_HDR --\
                  -r $RR_SIZE -s $SOCKET_SIZE -S $SOCKET_SIZE
		done
	done
