1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
Loading...

Update in: 15 December 2020


:

#!/usr/bin/perl -w

# calculate the variance over the latency of 5 consecutive measurements to a host, aka jitter 
# Cor van Wandelen 10-12-2020

use strict;
use warnings;

if (($#ARGV + 1) != 1) {
    print "Usage: jitter.pl host or ip address";
    exit;
}

my @rt = (0,0,0,0,0);
my $mean = 0.0;
my $var = 0.0;

for (my $n = 0; $n < 5; $n++) {
    $rt[$n] = `ping -nc 1 $ARGV[0] | sed -n 2p | cut -d ' ' -f 7 | cut -d '=' -f 2`;
    $mean += $rt[$n];
}
$mean /= 5;

for (my $n = 0; $n < 5; $n++) {
    $var += ($rt[$n] - $mean) ** 2;
}

$var /= 5;

$var = sprintf "%.3f",$var;
print "$var";


(Visited 49 times, 1 visits today)