Skip to content

Instantly share code, notes, and snippets.

@paulsmith paulsmith/
Last active Aug 29, 2015

What would you like to do?
Latency and packet loss report

If you are experiencing poor or degrading home network performance, it's good to come armed with evidence when talking with your friendly neighborhood ISP.


From your cable or DSL modem, find out the gateway, aka your ISP's router between you and them. Usually you can just run netstat -rn and the entry next to destination== is the gateway. (Be sure to be plugged directly into your modem, not going through your WiFi router, or you'll just be getting the gateway of your internal private network, which will be the WiFi router itself.) Armed with that IP address, log a few hours worth of ping(8) to a file, and then run on it.

$ ping -D <gwipaddress> | tee ping.log
# wait a few hours
$ ./ ping.log
mean        95th        99th         %packetloss
121.271164  757.000000  2070.000000  8.00
set -u -e
(echo "mean 95th 99th %packetloss" | col
cat $file | awk '/icmp_seq/ {print $8}' | cut -f2 -d= | sort -n | \
awk '{s[NR-1]=$1; sum+=$1} END {printf("%f %f %f ", sum/NR, s[int(NR*0.95-0.5)], s[int(NR*0.99-0.5)])}'; \
echo "scale=2; 100*(1-`wc -l $file | cut -f1 -d' '`/`tail -1 $file | awk '{print $6}' | cut -f2 -d=`)" | bc) | \
column -t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.