#!/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.
# This script performs various UDP unidirectional stream tests.
#

# this will point us towards netperf
NETHOME=/usr/local/netperf

# The name of the remote machine - the default is localhost
REM_HOST="localhost"

# The test length in seconds
TEST_TIME=60

# The socket sizes that we will be testing. This should be a list of
# integers separated by spaces
SOCKET_SIZES="32768"

# The send sizes that we will be using. Using send sizes that result
# in UDP packets which are larger than link size can be a bad thing to do.
# for FDDI, you can tack-on a 4096 data point
SEND_SIZES="64 1024 1472"

# 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 will tell netperf that headers are not to be displayed
NO_HDR="-P 0"

for SOCKET_SIZE in $SOCKET_SIZES
	do
	for SEND_SIZE in $SEND_SIZES
		do
		echo
		echo
		echo Testing with $SOCKET_SIZE sockets and $SEND_SIZE sends
		echo ------------------------------------------------------
		echo
		$NETHOME/netperf -l $TEST_TIME -H $REM_HOST \
                  $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE -t UDP_STREAM -- \
                  -m $SEND_SIZE -s $SOCKET_SIZE -S $SOCKET_SIZE
		$NETHOME/netperf -l $TEST_TIME -H $REM_HOST $NO_HDR \
                  $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE -t UDP_STREAM -- \
                  -m $SEND_SIZE -s $SOCKET_SIZE -S $SOCKET_SIZE
		$NETHOME/netperf -l $TEST_TIME -H $REM_HOST $NO_HDR \
                  $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE -t UDP_STREAM -- \
                  -m $SEND_SIZE -s $SOCKET_SIZE -S $SOCKET_SIZE
		$NETHOME/netperf -l $TEST_TIME -H $REM_HOST $NO_HDR \
                  $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE -t UDP_STREAM -- \
                  -m $SEND_SIZE -s $SOCKET_SIZE -S $SOCKET_SIZE
		$NETHOME/netperf -l $TEST_TIME -H $REM_HOST $NO_HDR \
                  $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE -t UDP_STREAM -- \
                  -m $SEND_SIZE -s $SOCKET_SIZE -S $SOCKET_SIZE
		done
	done
