T
Ted Byers
Here is a little script assembled fromt he documentation for
Net:ing.
use Net:ing;
$p = Net:ing->new();
$p->hires();
#$host = '192.168.2.1';
$host = 'www.google.ca';
print '$host: ',$host,"\n\n";
($ret, $duration, $ip) = $p->ping($host,50);
print $ret,"\n";
print $duration,"\n";
print $ip,"\n\n";
printf("$host [ip: $ip] is alive (packet return time: %.2f ms)\n",
1000 * $duration)
if $ret;
$p->close();
And here is the output from three runs of a program using Net:ing:
C:/Perl/bin\perl.exe -w k:/Work/test.network.pl
$host: 192.168.2.1
1
0.96875
192.168.2.1
192.168.2.1 [ip: 192.168.2.1] is alive (packet return time: 968.75 ms)
Compilation finished at Mon Dec 08 16:26:54
C:/Perl/bin\perl.exe -w k:/Work/test.network.pl
$host: www.google.ca
0
5
72.14.205.99
Compilation finished at Mon Dec 08 16:27:56
C:/Perl/bin\perl.exe -w k:/Work/test.network.pl
$host: www.google.ca
0
21.046875
72.14.205.99
Compilation finished at Mon Dec 08 16:29:48
The first is within my homeoffice LAN, 192.168.2.1 being the router.
The first two sets of output are without specifying a timeout (i.e.
using ($ret, $duration, $ip) = $p->ping($host)).
And now here is what I get using ping manually:
C:\>ping www.google.ca
Pinging www.l.google.com [72.14.205.103] with 32 bytes of data:
Reply from 72.14.205.103: bytes=32 time=17ms TTL=246
Reply from 72.14.205.103: bytes=32 time=14ms TTL=246
Reply from 72.14.205.103: bytes=32 time=14ms TTL=246
Reply from 72.14.205.103: bytes=32 time=16ms TTL=246
Ping statistics for 72.14.205.103:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 14ms, Maximum = 17ms, Average = 15ms
C:\>ping www.google.ca
Pinging www.l.google.com [72.14.205.99] with 32 bytes of data:
Reply from 72.14.205.99: bytes=32 time=17ms TTL=246
Reply from 72.14.205.99: bytes=32 time=17ms TTL=246
Reply from 72.14.205.99: bytes=32 time=17ms TTL=246
Reply from 72.14.205.99: bytes=32 time=17ms TTL=246
Ping statistics for 72.14.205.99:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 17ms, Maximum = 17ms, Average = 17ms
C:\>
The manual execution of ping happened just before and just after my
test scriptlet was executed.
So, then, why would my router invariably be seen by Net:ing as
accessable while google would not be, even though google clearly IS
accessable. Again, I tried other sites, such as Microsoft, and while
they are clearly accessable when manually invoking ping, the script
using Net:ing can not see them even though they get the correct IP
address for them (as can be determined by comparison with the manual
Ping command output at the time the script is executed.
Is there something in configuring Net:ing that can make it useful
for automating checking connectivity (in the context of handling
situations where, say, and LWP agent fails to retieve data as expected
- did we get no data because there was no data or because the
connection was lost or some other reason)?
Thanks
Ted
Net:ing.
use Net:ing;
$p = Net:ing->new();
$p->hires();
#$host = '192.168.2.1';
$host = 'www.google.ca';
print '$host: ',$host,"\n\n";
($ret, $duration, $ip) = $p->ping($host,50);
print $ret,"\n";
print $duration,"\n";
print $ip,"\n\n";
printf("$host [ip: $ip] is alive (packet return time: %.2f ms)\n",
1000 * $duration)
if $ret;
$p->close();
And here is the output from three runs of a program using Net:ing:
C:/Perl/bin\perl.exe -w k:/Work/test.network.pl
$host: 192.168.2.1
1
0.96875
192.168.2.1
192.168.2.1 [ip: 192.168.2.1] is alive (packet return time: 968.75 ms)
Compilation finished at Mon Dec 08 16:26:54
C:/Perl/bin\perl.exe -w k:/Work/test.network.pl
$host: www.google.ca
0
5
72.14.205.99
Compilation finished at Mon Dec 08 16:27:56
C:/Perl/bin\perl.exe -w k:/Work/test.network.pl
$host: www.google.ca
0
21.046875
72.14.205.99
Compilation finished at Mon Dec 08 16:29:48
The first is within my homeoffice LAN, 192.168.2.1 being the router.
The first two sets of output are without specifying a timeout (i.e.
using ($ret, $duration, $ip) = $p->ping($host)).
And now here is what I get using ping manually:
C:\>ping www.google.ca
Pinging www.l.google.com [72.14.205.103] with 32 bytes of data:
Reply from 72.14.205.103: bytes=32 time=17ms TTL=246
Reply from 72.14.205.103: bytes=32 time=14ms TTL=246
Reply from 72.14.205.103: bytes=32 time=14ms TTL=246
Reply from 72.14.205.103: bytes=32 time=16ms TTL=246
Ping statistics for 72.14.205.103:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 14ms, Maximum = 17ms, Average = 15ms
C:\>ping www.google.ca
Pinging www.l.google.com [72.14.205.99] with 32 bytes of data:
Reply from 72.14.205.99: bytes=32 time=17ms TTL=246
Reply from 72.14.205.99: bytes=32 time=17ms TTL=246
Reply from 72.14.205.99: bytes=32 time=17ms TTL=246
Reply from 72.14.205.99: bytes=32 time=17ms TTL=246
Ping statistics for 72.14.205.99:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 17ms, Maximum = 17ms, Average = 17ms
C:\>
The manual execution of ping happened just before and just after my
test scriptlet was executed.
So, then, why would my router invariably be seen by Net:ing as
accessable while google would not be, even though google clearly IS
accessable. Again, I tried other sites, such as Microsoft, and while
they are clearly accessable when manually invoking ping, the script
using Net:ing can not see them even though they get the correct IP
address for them (as can be determined by comparison with the manual
Ping command output at the time the script is executed.
Is there something in configuring Net:ing that can make it useful
for automating checking connectivity (in the context of handling
situations where, say, and LWP agent fails to retieve data as expected
- did we get no data because there was no data or because the
connection was lost or some other reason)?
Thanks
Ted