1#!/bin/sh
2#
3# This script runs a series of netperf tests intended to gather the 
4# raw material necessary to arrive at estimates for the cost of
5# sending and receiving a TCP segment, the cost of each additional byte
6# and the cost of each incremental segment.
7# 
8# there are a number of data points gathered by this script - it might
9# run for a considerable length of time.
10#
11# rick jones 4/99
12#
13
14if [ $# -gt 2 ]; then
15  echo "try again, correctly -> packet_byte_script hostname [CPU]"
16  exit 1
17fi
18
19if [ $# -eq 0 ]; then
20  echo "try again, correctly -> packet_byte_script hostname [CPU]"
21  exit 1
22fi
23
24# where is netperf
25NETPERF_CMD=${NETPERF_CMD:=/opt/netperf/netperf}
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 NETPERF_PORT apropriately
30# NETPERF_PORT="-p some_other_portnum"
31NETPERF_PORT=${NETPERF_PORT:=""}
32
33
34# The test length in seconds
35NETPERF_TIME=${NETPERF_TIME:=20}
36
37# How accurate we want the estimate of performance: 
38#      maximum and minimum test iterations (-i)
39#      confidence level (99 or 95) and interval (percent)
40NETPERF_STATS=${NETPERF_STATS:="-i 10,3 -I 99,5"}
41
42# The socket sizes that we will be testing - using zero will let it 
43# be the system default.
44NETPERF_SKTS=${NETPERF_SKTS:="0"}
45
46# The request,response sizes that we will be using. The netperf
47# command parser will treat "1" the same as "1,1" - I use 1,1 to
48# remember that it is "request,response"
49NETPERF_REQS=${NETPERF_REQS:="1 16 32 64 128 256 512 1024 \
50 1460 1461 2920 2921 4380 4381"}
51
52NETPERF_RESP=${NETPERF_RESP:="1 16 32 64 128 256 512 1024 \
53 1460 1461 2920 2921 4380 4381"}
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
59if [ $# -eq 2 ]; then
60  REM_HOST=$1
61  LOC_CPU="-c"
62  REM_CPU="-C"
63fi
64
65if [ $# -eq 1 ]; then
66  REM_HOST=$1
67fi
68
69# If we are measuring CPU utilization, then we can save beaucoup
70# time by saving the results of the CPU calibration and passing
71# them in during the real tests. So, we execute the new CPU "tests"
72# of netperf and put the values into shell vars.
73case $LOC_CPU in
74\-c) LOC_RATE=`$NETPERF_CMD $PORT -t LOC_CPU`;;
75*) LOC_RATE=""
76esac
77
78case $REM_CPU in
79\-C) REM_RATE=`$NETPERF_CMD $PORT -t REM_CPU -H $REM_HOST`;;
80*) REM_RATE=""
81esac
82
83# This disables header display
84NO_HDR="-P 0"
85NO_HDR=""
86
87for SOCKET_SIZE in $NETPERF_SKTS
88 do
89  echo
90  echo ------------------------------------------------------
91  echo Testing with the following command line:
92  # we echo the command line for cut and paste to th database
93  echo $NETPERF_CMD $NETPERF_PORT -l $NETPERF_TIME -H $REM_HOST -t TCP_RR \
94       $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE $NETPERF_STATS --\
95       -s $SOCKET_SIZE -S $SOCKET_SIZE
96  echo
97  echo and these settings for send sizes $NETPERF_REQS
98  echo
99
100  for REQ in $NETPERF_REQS
101  do
102   # since we have the confidence interval stuff, we do not
103   # need to repeat a test multiple times from the shell
104   $NETPERF_CMD $NETPERF_PORT -l $NETPERF_TIME -H $REM_HOST $NO_HDR \
105   -t TCP_RR $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE $NETPERF_STATS --\
106   -r ${REQ},1 -s $SOCKET_SIZE -S $SOCKET_SIZE
107   NO_HDR="-P 0"
108  done
109  echo
110  echo ------------------------------------------------------
111  NO_HDR=""
112  echo Testing with the following command line:
113  # we echo the command line for cut and paste to th database
114  echo $NETPERF_CMD $NETPERF_PORT -l $NETPERF_TIME -H $REM_HOST -t TCP_RR \
115       $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE $NETPERF_STATS --\
116       -s $SOCKET_SIZE -S $SOCKET_SIZE
117  echo and these settings for response sizes $NETPERF_RESP
118  echo
119  for RESP in $NETPERF_RESP
120   do
121   # since we have the confidence interval stuff, we do not
122   # need to repeat a test multiple times from the shell
123   $NETPERF_CMD $PORT -l $NETPERF_TIME -H $REM_HOST $NO_HDR \
124   -t TCP_RR $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE $NETPERF_STATS --\
125   -r 1,${RESP} -s $SOCKET_SIZE -S $SOCKET_SIZE
126   NO_HDR="-P 0"
127 done
128  echo
129  echo ------------------------------------------------------
130  NO_HDR=""
131  echo Testing with the following command line:
132  # we echo the command line for cut and paste to th database
133  echo $NETPERF_CMD $NETPERF_PORT -l $NETPERF_TIME -H $REM_HOST -t TCP_STREAM\
134       $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE $NETPERF_STATS --\
135       -s $SOCKET_SIZE -S $SOCKET_SIZE
136  echo and these settings for response sizes $NETPERF_RESP
137  echo
138  for REQ in $NETPERF_REQS
139   do
140   # since we have the confidence interval stuff, we do not
141   # need to repeat a test multiple times from the shell
142   $NETPERF_CMD $PORT -l $NETPERF_TIME -H $REM_HOST $NO_HDR \
143   -t TCP_STREAM $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE $NETPERF_STATS --\
144   -m ${REQ} -s $SOCKET_SIZE -S $SOCKET_SIZE -D
145   NO_HDR="-P 0"
146 done
147done
148
149# The test length in seconds for the CRR test, which needs to be
150#    longer for a connect/request/response test
151
152NETPERF_CRR_TIME=${NETPERF_CRR_TIME:=120}
153
154# now we do the TCP_CRR test
155echo
156echo ------------------------------------------------------
157echo $NETPERF_CMD $NETPERF_PORT -l $NETPERF_CRR_TIME -H $REM_HOST -t TCP_CRR\
158       $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE $NETPERF_STATS --\
159       -s $SOCKET_SIZE -S $SOCKET_SIZE
160echo
161$NETPERF_CMD $NETPERF_PORT -l $NETPERF_CRR_TIME -H $REM_HOST -t TCP_CRR\
162       $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE $NETPERF_STATS --\
163       -s $SOCKET_SIZE -S $SOCKET_SIZE
164