PING www.google.com (173.194.34.146) 56(84) bytes of data.
64 bytes from lhr14s21-in-f18.1e100.net (173.194.34.146): icmp_seq=1 ttl=55 time=394 ms
64 bytes from lhr14s21-in-f18.1e100.net (173.194.34.146): icmp_seq=2 ttl=55 time=332 ms
64 bytes from lhr14s21-in-f18.1e100.net (173.194.34.146): icmp_seq=3 ttl=55 time=362 ms
64 bytes from lhr14s21-in-f18.1e100.net (173.194.34.146): icmp_seq=4 ttl=55 time=276 ms
64 bytes from lhr14s21-in-f18.1e100.net (173.194.34.146): icmp_seq=5 ttl=55 time=92.4 ms
64 bytes from lhr14s21-in-f18.1e100.net (173.194.34.146): icmp_seq=6 ttl=55 time=219 ms
64 bytes from lhr14s21-in-f18.1e100.net (173.194.34.146): icmp_seq=7 ttl=55 time=116 ms
64 bytes from lhr14s21-in-f18.1e100.net (173.194.34.146): icmp_seq=8 ttl=55 time=265 ms
64 bytes from lhr14s21-in-f18.1e100.net (173.194.34.146): icmp_seq=9 ttl=55 time=75.9 ms
^C
####
using Net::Ping (Range 500-1000 ms)
1031.06737136841 ms
729.610681533813 ms
1004.48346138 ms
775.990009307861 ms
600.036859512329 ms
589.807271957397 ms
754.30154800415 ms
605.571508407593 ms
560.036897659302 ms
782.053709030151 ms
using Net::Ping::External (Range 400-800 ms)
791.388988494873 ms
570.100784301758 ms
687.773942947388 ms
402.096509933472 ms
430.928707122803 ms
398.749589920044 ms
712.586641311646 ms
837.354421615601 ms
560.385465621948 ms
650.154113769531 ms
####
#!/usr/bin/perl -w
use strict;
use Time::HiRes qw( usleep ualarm gettimeofday tv_interval nanosleep
clock_gettime clock_getres clock_nanosleep clock
stat lstat );
use strict;
use warnings;
use Net::Ping;
print "using Net::Ping\n";
my $p = Net::Ping->new("tcp", 2);
$p->port_number(80);
my $basetime = clock_gettime();
my $realtime = clock_gettime();
my $roundtrip = ($realtime-$basetime) * 1000;
for (my $i=1; $i<=10 ; $i++){
if ($p->ping("www.google.com")) {
$realtime = clock_gettime();
$roundtrip = ($realtime-$basetime) * 1000;
print $roundtrip," ms\n";
} else {
print "Host is not reachable\n";
}
$basetime = clock_gettime();
}
use Net::Ping::External qw(ping);
print "using Net::Ping::External\n";
#my $p = Net::Ping->new("tcp", 2);
#$p->port_number(80);
$basetime = clock_gettime();
$realtime = clock_gettime();
$roundtrip = ($realtime-$basetime) * 1000;
for (my $i=1; $i<=10 ; $i++){
if (ping(host => "www.google.com")) {
$realtime = clock_gettime();
$roundtrip = ($realtime-$basetime) * 1000;
print $roundtrip," ms\n";
} else {
print "Host is not reachable\n";
}
$basetime = clock_gettime();
}