Ping Survey
Aus Weis nix
Ping Survey
The following Unix shell script can be used to measure network latencies over a 24h period:
#!/bin/bash # # Ping Survey - script to collect ping times # # Configure below, then run in the background. # Total runtime will be ITERATION*INTERVAL # Results will be stored in LOG # # Specify the logfile LOG="/tmp/ping-survey.log" # Specify the target TARGET_IP="11.22.33.44" # Configure probing PINGS="10" ITERATIONS="96" INTERVAL="15m" # --------------------------------------------------------- # Start log echo "====== Ping Survey to $TARGET_IP==========" >"$LOG" hostname >>"$LOG" hostname -i >>"$LOG" echo "">>"$LOG" # Survey loop for i in `seq 1 $ITERATIONS`; do echo "====== Test $i ==========" >>"$LOG" date >>"$LOG" ping -nq -c "$PINGS" "$TARGET_IP" >>"$LOG" echo "========================">>"$LOG" echo "">>"$LOG" sleep "$INTERVAL" done
The following perl script can be used to extract the data series from the log:
#!/usr/bin/perl
use Date::Manip;
while (<>) {
$line = $_;
$date = ParseDate($line);
if ($date) {
$lastdate = $date;
}
if ($line =~ /round-trip/) {
@numbers = split(/\//,$line);
$count=0;
print &UnixDate($lastdate,"%T");
print " ";
$numbers[3] =~ s/stddev =//;
print $numbers[3];
print " ";
print $numbers[4];
print " ";
print $numbers[5];
print "\n";
}
}
The following gnuplot script can be used to create a plot from the data series:
set terminal postscript set output "ping-survey.ps" set xdata time set title "Ping Survey" set xlabel "Time (CET) 1-Jan-2009" set ylabel "Latency (ms)" set timefmt "%H:%M:%S" set yrange [50:250] set format x "%H:%M" plot "ping-survey.txt" using 1:3:2:4 title "Measurement" with yerrorbars, 9400*1000*1.4*2/299792458*1000 title "Speed of Light" with lines
A PDF can be created with the sequence of commands:
perl ping-survey.pl <ping-survey.log >ping-survey.txt gnuplot ping-survey.plt ps2pdf ping-survey.ps >ping-survey.pdf
The speed of light latency in this example is estimated based on the great-circle distance between California and Europe (approx 9400km), a wire factor of 140%, and doubling of the distance for a round trip.
