-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Incorporate
-Z passphrase
option for betterspeedtest.sh and netperf…
…runner.sh
- Loading branch information
1 parent
736aab4
commit d1a5e7b
Showing
3 changed files
with
130 additions
and
33 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,8 +17,9 @@ | |
# -p | --ping: Host to ping to measure latency (default - gstatic.com) | ||
# -i | --idle: Don't send traffic, only measure idle latency | ||
# -n | --number: Number of simultaneous sessions (default - 5 sessions) | ||
# -Z Required passphrase - see http://netperf.bufferbloat.net for today's value | ||
|
||
# Copyright (c) 2014-2022 - Rich Brown [email protected] | ||
# Copyright (c) 2014-2024 - Rich Brown [email protected] | ||
# GPLv2 | ||
|
||
# Process the ping times from the passed-in file, and summarize the results | ||
|
@@ -69,7 +70,6 @@ sed 's/^.*time=\([^ ]*\) ms/\1/'| \ | |
} | ||
|
||
# Print a line of dots as a progress indicator. | ||
|
||
print_dots() { | ||
while : ; do | ||
printf "." | ||
|
@@ -78,7 +78,6 @@ print_dots() { | |
} | ||
|
||
# Stop the current print_dots() process | ||
|
||
kill_dots() { | ||
# echo "Pings: $ping_pid Dots: $dots_pid" | ||
kill -9 "$dots_pid" | ||
|
@@ -87,7 +86,6 @@ kill_dots() { | |
} | ||
|
||
# Stop the current ping process | ||
|
||
kill_pings() { | ||
# echo "Pings: $ping_pid Dots: $dots_pid" | ||
kill -9 "$ping_pid" | ||
|
@@ -102,6 +100,7 @@ clean_up() { | |
kill_dots | ||
rm "$PINGFILE" | ||
rm "$SPEEDFILE" | ||
rm "$ERRFILE" | ||
} | ||
|
||
# Stop the current pings and dots, and exit | ||
|
@@ -116,6 +115,14 @@ catch_interrupt() { | |
exit 1 | ||
} | ||
|
||
# Display "no passphrase" message and exit | ||
no_passphrase() { | ||
echo "" | ||
echo "Missing passphrase - see netperf.bufferbloat.net" | ||
echo "" | ||
exit 1 | ||
} | ||
|
||
# ------------ start_pings() ---------------- | ||
# Start printing dots, then start a ping process, saving the results to a PINGFILE | ||
|
||
|
@@ -150,6 +157,7 @@ measure_direction() { | |
|
||
# Create temp file | ||
SPEEDFILE=$(mktemp /tmp/netperfUL.XXXXXX) || exit 1 | ||
ERRFILE=$(mktemp /tmp/netperfErr.XXXXXX) || exit 1 | ||
DIRECTION=$1 | ||
|
||
# start off the ping process | ||
|
@@ -166,10 +174,10 @@ measure_direction() { | |
# netperf writes the sole output value (in Mbps) to stdout when completed | ||
for i in $( seq "$MAXSESSIONS" ) | ||
do | ||
netperf "$TESTPROTO" -H "$TESTHOST" -t "$dir" -l "$TESTDUR" -v 0 -P 0 >> "$SPEEDFILE" & | ||
netperf "$TESTPROTO" -H "$TESTHOST" -t "$dir" -l "$TESTDUR" -v 0 -P 0 $PASSPHRASEOPTION >> "$SPEEDFILE" 2>> $ERRFILE & | ||
# echo "Starting PID $! params: $TESTPROTO -H $TESTHOST -t $dir -l $TESTDUR -v 0 -P 0 >> $SPEEDFILE" | ||
done | ||
done | ||
|
||
# Wait until each of the background netperf processes completes | ||
# echo "Process is $$" | ||
# echo `pgrep -P $$ netperf ` | ||
|
@@ -180,7 +188,14 @@ measure_direction() { | |
wait "$i" | ||
done | ||
|
||
# Print TCP Download speed | ||
# Check the length of the error file. If it's > 0, then there were errors | ||
file_size=$(wc -c < "$ERRFILE") | ||
if [ $file_size -gt 0 ]; then | ||
clean_up # stop the machinery | ||
no_passphrase # print the error and exit | ||
fi | ||
|
||
# Summarize the speed records and print them | ||
echo "" | ||
awk -v dir="$1" '{s+=$1} END {printf " %s: %1.2f Mbps", dir, s}' < "$SPEEDFILE" | ||
|
||
|
@@ -193,14 +208,15 @@ measure_direction() { | |
|
||
# ------- Start of the main routine -------- | ||
|
||
# Usage: sh betterspeedtest.sh [ -4 -6 ] [ -H netperf-server ] [ -t duration ] [ -p host-to-ping ] [ -i ] [ -n simultaneous-sessions ] | ||
# Usage: sh betterspeedtest.sh -Z passphrase [ -4 -6 ] [ -H netperf-server ] [ -t duration ] [ -p host-to-ping ] [ -i ] [ -n simultaneous-sessions ] | ||
|
||
# “H” and “host” DNS or IP address of the netperf server host (default: netperf.bufferbloat.net) | ||
# “t” and “time” Time to run the test in each direction (default: 60 seconds) | ||
# “p” and “ping” Host to ping for latency measurements (default: gstatic.com) | ||
# "i" and "idle" Don't send up/down traffic - just measure idle link latency | ||
# "n" and "number" Number of simultaneous upload or download sessions (default: 5 sessions; | ||
# 5 sessions chosen empirically because total didn't increase much after that number) | ||
# "Z" Required passphrase - see netperf.bufferbloat.net | ||
|
||
# set an initial values for defaults | ||
TESTHOST="netperf.bufferbloat.net" | ||
|
@@ -244,8 +260,13 @@ do | |
esac ;; | ||
-i|--idle) | ||
IDLETEST=true ; shift 1 ;; | ||
-Z) | ||
case "$2" in | ||
"") no_passphrase ; exit 1 ;; | ||
*) PASSPHRASEOPTION="-Z $2" ; shift 2 ;; | ||
esac ;; | ||
--) shift ; break ;; | ||
*) echo "Usage: sh betterspeedtest.sh [-4 -6] [ -H netperf-server ] [ -t duration ] [ -p host-to-ping ] [ -n simultaneous-sessions ] [ --idle ]" ; exit 1 ;; | ||
*) echo "Usage: sh betterspeedtest.sh -Z passphrase [-4 -6] [ -H netperf-server ] [ -t duration ] [ -p host-to-ping ] [ -n simultaneous-sessions ] [ --idle ]" ; exit 1 ;; | ||
esac | ||
done | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
# a) total bandwidth available | ||
# b) the distribution of ping latency | ||
|
||
# Usage: sh netperfrunner.sh [ -4 -6 ] [ -H netperf-server ] [ -t duration ] [ -t host-to-ping ] [ -n simultaneous-streams ] | ||
# Usage: sh netperfrunner.sh -Z passphrase [ -4 -6 ] [ -H netperf-server ] [ -t duration ] [ -t host-to-ping ] [ -n simultaneous-streams ] | ||
|
||
# Options: If options are present: | ||
# | ||
|
@@ -23,8 +23,9 @@ | |
# -t | --time: Duration for how long each direction's test should run - (default - 60 seconds) | ||
# -p | --ping: Host to ping to measure latency (default - gstatic.com) | ||
# -n | --number: Number of simultaneous sessions (default - 5 sessions) | ||
# -Z passphrase: Passphrase required for netperf.bufferbloat.net | ||
|
||
# Copyright (c) 2014-2022 - Rich Brown [email protected] | ||
# Copyright (c) 2014-2024 - Rich Brown [email protected] | ||
# GPLv2 | ||
|
||
# Process the ping times from the passed-in file, and summarize the results | ||
|
@@ -74,6 +75,48 @@ sed 's/^.*time=\([^ ]*\) ms/\1/'| \ | |
}' | ||
} | ||
|
||
# Print a line of dots as a progress indicator. | ||
print_dots() { | ||
while : ; do | ||
printf "." | ||
sleep 1 | ||
done | ||
} | ||
|
||
# Stop the current print_dots() process | ||
kill_dots() { | ||
# echo "Pings: $ping_pid Dots: $dots_pid" | ||
kill -9 "$dots_pid" | ||
wait "$dots_pid" 2>/dev/null | ||
dots_pid=0 | ||
} | ||
|
||
# Stop the current ping process | ||
kill_pings() { | ||
# echo "Pings: $ping_pid Dots: $dots_pid" | ||
kill -9 "$ping_pid" | ||
wait "$ping_pid" 2>/dev/null | ||
ping_pid=0 | ||
} | ||
|
||
# Clean up all the debris from the testing | ||
clean_up() { | ||
kill_pings | ||
kill_dots | ||
rm "$PINGFILE" | ||
rm "$ULFILE" | ||
rm "$DLFILE" | ||
rm "$ERRFILE" | ||
} | ||
|
||
# Display "no passphrase" message and exit | ||
no_passphrase() { | ||
echo "" | ||
echo "Missing passphrase - see netperf.bufferbloat.net" | ||
echo "" | ||
exit 1 | ||
} | ||
|
||
# ------- Start of the main routine -------- | ||
|
||
# Usage: sh betterspeedtest.sh [ -H netperf-server ] [ -t duration ] [ -p host-to-ping ] | ||
|
@@ -100,6 +143,8 @@ TESTPROTO=-4 | |
ULFILE=`mktemp /tmp/netperfUL.XXXXXX` || exit 1 | ||
DLFILE=`mktemp /tmp/netperfDL.XXXXXX` || exit 1 | ||
PINGFILE=`mktemp /tmp/measurepings.XXXXXX` || exit 1 | ||
ERRFILE=$(mktemp /tmp/netperfErr.XXXXXX) || exit 1 | ||
|
||
# echo $ULFILE $DLFILE $PINGFILE | ||
|
||
# read the options | ||
|
@@ -129,8 +174,13 @@ do | |
"") echo "Missing number of simultaneous sessions" ; exit 1 ;; | ||
*) MAXSESSIONS=$2 ; shift 2 ;; | ||
esac ;; | ||
-Z) | ||
case "$2" in | ||
"") no_passphrase ; exit 1 ;; | ||
*) PASSPHRASEOPTION="-Z $2" ; shift 2 ;; | ||
esac ;; | ||
--) shift ; break ;; | ||
*) echo "Usage: sh Netperfrunner.sh [ -H netperf-server ] [ -t duration ] [ -p host-to-ping ] [ -n simultaneous-streams ]" ; exit 1 ;; | ||
*) echo "Usage: sh Netperfrunner.sh -Z passphrase [ -H netperf-server ] [ -t duration ] [ -p host-to-ping ] [ -n simultaneous-streams ]" ; exit 1 ;; | ||
esac | ||
done | ||
|
||
|
@@ -149,28 +199,45 @@ echo "$DATE Testing $TESTHOST ($PROTO) with $MAXSESSIONS streams down and up whi | |
# echo "This test is part of the CeroWrt project. To learn more, visit:" | ||
# echo " http://bufferbloat.net/projects/cerowrt/" | ||
|
||
# Start Ping | ||
if [ $TESTPROTO -eq "-4" ] | ||
then | ||
"${PING4}" $PINGHOST > $PINGFILE & | ||
else | ||
"${PING6}" $PINGHOST > $PINGFILE & | ||
fi | ||
ping_pid=$! | ||
# echo "Ping PID: $ping_pid" | ||
# ------------ start_pings() ---------------- | ||
# Start printing dots, then start a ping process, saving the results to a PINGFILE | ||
|
||
start_pings() { | ||
|
||
# Create temp file | ||
PINGFILE=$(mktemp /tmp/measurepings.XXXXXX) || exit 1 | ||
|
||
# Start dots | ||
print_dots & | ||
dots_pid=$! | ||
# echo "Dots PID: $dots_pid" | ||
|
||
# Start Ping | ||
if [ "$TESTPROTO" -eq "-4" ] | ||
then | ||
"$PING4" "$PINGHOST" > "$PINGFILE" & | ||
else | ||
"$PING6" "$PINGHOST" > "$PINGFILE" & | ||
fi | ||
ping_pid=$! | ||
# echo "Ping PID: $ping_pid" | ||
|
||
} | ||
|
||
start_pings | ||
|
||
# Start $MAXSESSIONS upload datastreams from netperf client to the netperf server | ||
# netperf writes the sole output value (in Mbps) to stdout when completed | ||
for i in $( seq $MAXSESSIONS ) | ||
do | ||
netperf $TESTPROTO -H $TESTHOST -t TCP_STREAM -l $TESTDUR -v 0 -P 0 >> $ULFILE & | ||
netperf $TESTPROTO -H $TESTHOST -t TCP_STREAM -l $TESTDUR -v 0 -P 0 $PASSPHRASEOPTION >> $ULFILE 2>> $ERRFILE& | ||
# echo "Starting upload #$i $!" | ||
done | ||
|
||
# Start $MAXSESSIONS download datastreams from netperf server to the client | ||
for i in $( seq $MAXSESSIONS ) | ||
do | ||
netperf $TESTPROTO -H $TESTHOST -t TCP_MAERTS -l $TESTDUR -v 0 -P 0 >> $DLFILE & | ||
netperf $TESTPROTO -H $TESTHOST -t TCP_MAERTS -l $TESTDUR -v 0 -P 0 $PASSPHRASEOPTION >> $DLFILE 2>> $ERRFILE& | ||
# echo "Starting download #$i $!" | ||
done | ||
|
||
|
@@ -184,17 +251,22 @@ do | |
wait $i | ||
done | ||
|
||
# Stop the pings after the netperf's are all done | ||
kill -9 $ping_pid | ||
wait $ping_pid 2>/dev/null | ||
# Check the length of the error file. If it's > 0, then there were errors | ||
file_size=$(wc -c < "$ERRFILE") | ||
if [ $file_size -gt 0 ]; then | ||
clean_up # stop the machinery | ||
no_passphrase # print the error and exit | ||
fi | ||
|
||
# # Stop the pings after the netperf's are all done | ||
# kill -9 $ping_pid | ||
# wait $ping_pid 2>/dev/null | ||
|
||
# sum up all the values (one line per netperf test) from $DLFILE and $ULFILE | ||
# then summarize the ping stat's | ||
echo "" | ||
echo " Download: " `awk '{s+=$1} END {print s}' $DLFILE` Mbps | ||
echo " Upload: " `awk '{s+=$1} END {print s}' $ULFILE` Mbps | ||
summarize_pings $PINGFILE | ||
|
||
# Clean up | ||
rm $PINGFILE | ||
rm $DLFILE | ||
rm $ULFILE | ||
clean_up |