Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Net::Ping Response

by set_uk (Pilgrim)
on Oct 21, 2003 at 15:18 UTC ( [id://300946]=perlquestion: print w/replies, xml ) Need Help??

set_uk has asked for the wisdom of the Perl Monks concerning the following question:

I would like to know what the meanings of the default timeout and timeout options mean in relation to Net::Ping.
This may seem like a dumb question but depending on what they are set to the response time of the ping is affected.
If set to 1 I get a reponse of .15 from the following script. If set to 5 I get a response of 4.
Shouldn't the way it work be - if we get a response then continue as soon as we get it?? I also find that this bears no relation to the ms response I get from the command line ping utility. Is this because Net::Ping is timing the perl code and perl is slower than the os binary?
sub Ping{ my ($self,$host) = @_; my $p = Net::Ping->new("external",1,80); $p->hires(); print "HOST->".$host."\n"; my ($ret, $dur, $ip) = $p->ping($host); print "RET->".$ret."\n"; print "DUR->".$dur."\n"; print "IP->".$ip."\n"; if (defined($ret)){ return $ret; } else { return undef; } }

Replies are listed 'Best First'.
Re: Net::Ping Response
by pg (Canon) on Oct 21, 2003 at 16:14 UTC
    • timeout is the amount of time you are willing to wait before the response come back.
    • duration returned from ping function call is the elapsed time (response time).

    Duration shall be less than timeout, and that's what you observed.

      How can I set it up so that it returns when we get a response back from the device. The timeout appears to be interfering with the response
Re: Net::Ping Response
by Abigail-II (Bishop) on Oct 21, 2003 at 16:35 UTC
    Is this because Net::Ping is timing the perl code and perl is slower than the os binary?
    Well, since you use 'external' as the protocol, Net::Ping *is* using your systems ping utility.

    Abigail

      Also I checked the source code for both Net::Ping and Net::Ping::External, and they seem okay to me. They didn’t use timeout value in any funny way.

      Actually on some platform, timeout value is even not used (Net::Ping::External does not pass it to the system ping facility), if that particular ping facility on that platform actually does not support timeout.

      Yes but the time value for response that was returned did not appear to represent the output that I would have gotten had I used ping from the command line.
      I gave up in the end and put something together using sudo and fping.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://300946]
Approved by HyperZonk
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-04-25 14:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found