Ping Survey

Aus Weis nix
Wechseln zu: Navigation, Suche

Ping Survey

The following Unix shell script can be used to measure network latencies over a 24h period:

# 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
# Specify the target
# Configure probing
# ---------------------------------------------------------
# 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"

The following perl script can be used to extract the data series from the log:

use Date::Manip;
while (<>) {
 $line = $_;
 $date = ParseDate($line);
 if ($date) {
  $lastdate = $date;
 if ($line =~ /round-trip/) {
  @numbers = split(/\//,$line);
  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 ""
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.log >ping-survey.txt
gnuplot ping-survey.plt
ps2pdf >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.