• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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# teach it about processor affinity and the TCP_MSS test
14# rick jones 2007-11-08
15#
16
17if [ $# -gt 2 ]; then
18  echo "try again, correctly -> packet_byte_script hostname [CPU]"
19  exit 1
20fi
21
22if [ $# -eq 0 ]; then
23  echo "try again, correctly -> packet_byte_script hostname [CPU]"
24  exit 1
25fi
26
27# where is netperf
28NETPERF_DIR=${NETPERF_DIR:=/opt/netperf2/bin}
29
30
31# at what port will netserver be waiting? If you decide to run
32# netserver at a differnet port than the default of 12865, then set
33# the value of NETPERF_PORT apropriately
34# NETPERF_PORT="-p some_other_portnum"
35NETPERF_PORT=${NETPERF_PORT:=""}
36
37
38# The test length in seconds
39NETPERF_TIME=${NETPERF_TIME:=30}
40
41# How accurate we want the estimate of performance:
42#      maximum and minimum test iterations (-i)
43#      confidence level (99 or 95) and interval (percent)
44NETPERF_STATS=${NETPERF_STATS:="-i 30,3 -I 99,5"}
45
46# The socket sizes that we will be testing - using -1 will let it
47# be the system default.
48NETPERF_SKTS=${NETPERF_SKTS:="-1"}
49
50# The CPU affinity to be applied
51NETPERF_AFFINITY=${NETPERF_AFFINITY:=""}
52
53# NETPERF_CMD is an amalgam of previous variables
54NETPERF_CMD="${NETPERF_DIR}/netperf ${NETPERF_AFFINITY}"
55
56# if there are two parms, parm one it the hostname and parm two will
57# be a CPU indicator. actually, anything as a second parm will cause
58# the CPU to be measured, but we will "advertise" it should be "CPU"
59
60if [ $# -eq 2 ]; then
61  REM_HOST=$1
62  LOC_CPU="-c"
63  REM_CPU="-C"
64fi
65
66if [ $# -eq 1 ]; then
67  REM_HOST=$1
68fi
69
70MSS=`$NETPERF_CMD -H $REM_HOST -t TCP_MSS -P 0 -v 0`
71
72# The request,response sizes that we will be using. The netperf
73# command parser will treat "1" the same as "1,1" - I use 1,1 to
74# remember that it is "request,response"
75
76# start at one and multiply by two on our way to the MSS
77bar=1
78while [ $bar -lt $MSS ]
79do
80 NETPERF_REQS="${NETPERF_REQS} $bar"
81 bar=`expr $bar \* 2`
82done
83
84# and now multiples of the mss and that plus one
85for i in 1 2 3
86do
87 bar=`expr $MSS \* $i`
88 NETPERF_REQS="${NETPERF_REQS} $bar"
89 NETPERF_REQS="${NETPERF_REQS} `expr $bar + 1`"
90done
91
92bar=1
93while [ $bar -lt $MSS ]
94do
95  NETPERF_RESP="${NETPERF_RESP} $bar"
96  bar=`expr $bar \* 2`
97done
98
99for i in 1 2 3
100do
101 bar=`expr $MSS \* $i`
102 NETPERF_RESP="${NETPERF_RESP} $bar"
103 NETPERF_RESP="${NETPERF_RESP} `expr $bar + 1`"
104done
105
106
107
108# If we are measuring CPU utilization, then we can save beaucoup
109# time by saving the results of the CPU calibration and passing
110# them in during the real tests. So, we execute the new CPU "tests"
111# of netperf and put the values into shell vars.
112case $LOC_CPU in
113\-c) LOC_RATE=`$NETPERF_CMD $PORT -t LOC_CPU`;;
114*) LOC_RATE=""
115esac
116
117case $REM_CPU in
118\-C) REM_RATE=`$NETPERF_CMD $PORT -t REM_CPU -H $REM_HOST`;;
119*) REM_RATE=""
120esac
121
122# This disables header display
123NO_HDR="-P 0"
124NO_HDR=""
125
126for SOCKET_SIZE in $NETPERF_SKTS
127 do
128  echo
129  echo ------------------------------------------------------
130  echo Testing with the following command line:
131  # we echo the command line for cut and paste to th database
132  echo $NETPERF_CMD $NETPERF_PORT -l $NETPERF_TIME -H $REM_HOST -t TCP_RR \
133       $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE $NETPERF_STATS --\
134       -s $SOCKET_SIZE -S $SOCKET_SIZE
135  echo
136  echo and these settings for send sizes $NETPERF_REQS
137  echo
138
139  for REQ in $NETPERF_REQS
140  do
141   # since we have the confidence interval stuff, we do not
142   # need to repeat a test multiple times from the shell
143   $NETPERF_CMD $NETPERF_PORT -l $NETPERF_TIME -H $REM_HOST $NO_HDR \
144   -t TCP_RR $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE $NETPERF_STATS --\
145   -r ${REQ},1 -s $SOCKET_SIZE -S $SOCKET_SIZE
146   NO_HDR="-P 0"
147  done
148  echo
149  echo ------------------------------------------------------
150  NO_HDR=""
151  echo Testing with the following command line:
152  # we echo the command line for cut and paste to th database
153  echo $NETPERF_CMD $NETPERF_PORT -l $NETPERF_TIME -H $REM_HOST -t TCP_RR \
154       $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE $NETPERF_STATS --\
155       -s $SOCKET_SIZE -S $SOCKET_SIZE
156  echo and these settings for response sizes $NETPERF_RESP
157  echo
158  for RESP in $NETPERF_RESP
159   do
160   # since we have the confidence interval stuff, we do not
161   # need to repeat a test multiple times from the shell
162   $NETPERF_CMD $PORT -l $NETPERF_TIME -H $REM_HOST $NO_HDR \
163   -t TCP_RR $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE $NETPERF_STATS --\
164   -r 1,${RESP} -s $SOCKET_SIZE -S $SOCKET_SIZE
165   NO_HDR="-P 0"
166 done
167  echo
168  echo ------------------------------------------------------
169  NO_HDR=""
170  echo Testing with the following command line:
171  # we echo the command line for cut and paste to th database
172  echo $NETPERF_CMD $NETPERF_PORT -l $NETPERF_TIME -H $REM_HOST -t TCP_STREAM\
173       $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE $NETPERF_STATS --\
174       -s $SOCKET_SIZE -S $SOCKET_SIZE
175  echo and these settings for response sizes $NETPERF_RESP
176  echo
177  for REQ in $NETPERF_REQS
178   do
179   # since we have the confidence interval stuff, we do not
180   # need to repeat a test multiple times from the shell
181   $NETPERF_CMD $PORT -l $NETPERF_TIME -H $REM_HOST $NO_HDR \
182   -t TCP_STREAM $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE $NETPERF_STATS --\
183   -m ${REQ} -s $SOCKET_SIZE -S $SOCKET_SIZE -D
184   NO_HDR="-P 0"
185 done
186done
187
188# The test length in seconds for the CRR test, which needs to be
189#    longer for a connect/request/response test
190
191NETPERF_CRR_TIME=${NETPERF_CRR_TIME:=120}
192
193# now we do the TCP_CRR test
194echo
195echo ------------------------------------------------------
196echo $NETPERF_CMD $NETPERF_PORT -l $NETPERF_CRR_TIME -H $REM_HOST -t TCP_CRR\
197       $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE $NETPERF_STATS --\
198       -s $SOCKET_SIZE -S $SOCKET_SIZE
199echo
200$NETPERF_CMD $NETPERF_PORT -l $NETPERF_CRR_TIME -H $REM_HOST -t TCP_CRR\
201       $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE $NETPERF_STATS --\
202       -s $SOCKET_SIZE -S $SOCKET_SIZE
203