I modeled this after the dslreports test somewhat. I'm sure someone else can make this puppy a beast.
#!/bin/sh
# This script is mostly intended to run while performing a throughout test
# It can also be used for other purposes to measure latency across various links :>)
# https://www.dslreports.com */ mobile app version available */
# https://www.speedtest.com */ mobile app version available */
# https://www.nperf.com */ mobile app version available */
# https://www.librespeed.org */ ??? */
# iperf */ mobile app version avalable */
# Enter your average idle ping time, whole numbers only
# Best to have NO network activity happening while looking for the average idle time
AVG_IDLE=38
# Server to send icmp echo requests to
IP=8.8.8.8
# Number of times to ping the server
# Usually most speed tests actually run for ~40 seconds
COUNT=60
MAX=$( ping -c $COUNT -q -n $IP | cut -d "/" -s -f4 | cut -d "." -f1 )
if [ "$MAX" -lt "$((AVG_IDLE + 5))" ]; then
echo "Latency = A+ $MAX ms"
elif [ "$MAX" -gt "$((AVG_IDLE + 5))" ] && [ "$MAX" -lt "$((AVG_IDLE + 30))" ]; then
echo "Latency = A $MAX ms"
elif [ "$MAX" -gt "$((AVG_IDLE + 30))" ] && [ "$MAX" -lt "$((AVG_IDLE + 60))" ]; then
echo "Latency = B $MAX ms"
elif [ "$MAX" -gt "$((AVG_IDLE + 60))" ] && [ "$MAX" -lt "$((AVG_IDLE + 200))" ]; then
echo "Latency = C $MAX ms"
elif [ "$MAX" -gt "$((AVG_IDLE + 200))" ] && [ "$MAX" -lt "$((AVG_IDLE + 400))" ]; then
echo "Latency = D $MAX ms"
else
echo "Latency = F $MAX ms"
fi
exit 0