Created
April 18, 2010 18:53
-
-
Save fukusaka/370467 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
HOST=ref1 | |
TARGET=target | |
TARGET_IF=eth0 | |
#TARGET=target2 | |
#TARGET_IF=eth1 | |
MODS="via_velocity velocityget" | |
MOD=via_velocity | |
#MOD=velocityget | |
#METHOD=netperf | |
METHOD=nuttcp | |
#use_ifstat=yes | |
PNAME=DMA_length | |
VALS="6" | |
#VALS="0 1 2 3 4 5 6 7" | |
#PNAME=int_works | |
#VALS="20 32 64 96 128 256" | |
#PNAME=rx_thresh | |
#VALS="0 1 2" | |
#PNAME=TxDescriptors | |
#VALS="16 32 64 128 256" | |
#PNAME=RxDescriptors | |
#VALS="64 128 252" | |
#PNAME=tx_intsup | |
#VALS="1 8 12 16 24 32 48 63" | |
#PNAME=txque_timer | |
#VALS="0 32 64 96 128 255" | |
#VALS="0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16" | |
#VALS="0 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90" | |
#PNAME=rx_intsup | |
#VALS="1 8 12 16 24 32 48 63" | |
#PNAME=rxque_timer | |
#VALS="0 32 64 96 128 255" | |
OPTIONS="" | |
#OPTIONS="$OPTIONS int_works=64" | |
#OPTIONS="$OPTIONS DMA_length=6" | |
#OPTIONS="$OPTIONS tx_intsup=63" | |
#OPTIONS="$OPTIONS txque_timer=0" | |
#OPTIONS="$OPTIONS rx_intsup=63" | |
#OPTIONS="$OPTIONS rxque_timer=0" | |
#OPTIONS="$OPTIONS RxDescriptors=252" | |
#OPTIONS="$OPTIONS TxDescriptors=256" | |
main() { | |
header $METHOD | |
echo "outbound ($TARGET -> $HOST)" ; measure_all $METHOD out | |
echo "inbound ($TARGET <- $HOST)" ; measure_all $METHOD in | |
} | |
mod_reload() { | |
CMD="/etc/init.d/networking stop" | |
CMD="$CMD; for mod in $MODS; do lsmod | grep -q ^\$mod && rmmod \$mod; done" | |
CMD="$CMD; modprobe $MOD $OPTIONS $PNAME=$1" | |
CMD="$CMD; /etc/init.d/networking start" | |
#CMD="$CMD; /sbin/ifconfig $TARGET_IF txqueuelen 2000" | |
ssh $TARGET -- "$CMD" | |
} | |
header() { | |
method=$1; shift; | |
case $method in | |
netperf) | |
cat <<EOF | |
module: $MOD | |
options:$OPTIONS | |
$PNAME = $VALS | |
Recv Send Send Utilization Service Demand | |
Socket Socket Message Elapsed Send Recv Send Recv | |
Size Size Size Time Throughput local remote local remote | |
bytes bytes bytes secs. 10^6bits/s % S % S us/KB us/KB | |
EOF | |
;; | |
nuttcp) | |
cat <<EOF | |
module: $MOD | |
options:$OPTIONS | |
$PNAME = $VALS | |
Total Size / Elapsed = Throughput CPU Usage | |
EOF | |
;; | |
esac | |
} | |
measure_net() { | |
method=$1; direct=$2; mark="$3"; | |
#ITCPOPTS="-s 16K -S 48K -m 16K" | |
#OTCPOPTS="-s 8K -S 42K -m 16K" | |
case $method-$direct in | |
netperf-out) | |
netperf -t TCP_MAERTS -H $TARGET -c -C -P 0 -B "$mark" -- $OTCPOPTS | |
;; | |
netperf-in) | |
netperf -t TCP_STREAM -H $TARGET -c -C -P 0 -B "$mark" -- $ITCPOPTS | |
;; | |
nuttcp-out) | |
ssh -f $TARGET -- "nuttcp -S -1" | |
nuttcp -r -I "$mark" $TARGET | |
;; | |
nuttcp-in) | |
ssh -f $TARGET -- "nuttcp -S -1" | |
nuttcp -t -I "$mark" $TARGET | |
;; | |
esac | |
} | |
ifstat() { | |
read VAR < <( ssh $TARGET -- cat /proc/net/dev | grep $TARGET_IF ) | |
#echo $VAR | |
rx_errs=`echo $VAR | awk '{print $3,"errs",$4,"drop",$5,"fifo",$6,"frame";}'` | |
tx_errs=`echo $VAR | awk '{print $11,"errs",$12,"drop",$13,"fifo",$15,"carrier",$14,"colls";}'` | |
echo "rx $rx_errs / tx $tx_errs" | |
} | |
measure_all() { | |
method=$1; direct=$2; | |
for val in $VALS; do | |
mark=`printf "% 8d" $val` | |
mod_reload $val > /dev/null 2>&1 | |
sleep 3 | |
measure_net $method $direct "$mark" | |
test "x$use_ifstat" == "xyes" && ifstat | |
done | |
} | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment