Phoenix.pm: Net::Ping Object

Bill Nash billn at billn.net
Tue Feb 5 03:12:42 CST 2002


ICMP ping uses the 'echo' function. ICMP packets themselves are UDP.

>From /etc/services on a *nix box near you:
echo 7/tcp
echo 7/udp

The details are in the implementation. =)

- billn

On Tue, 5 Feb 2002, Scott Walters wrote:

>
> Take a look at the source code... by default it sends a UDP packet...
> TCP, if you contact a closed port, a packet with the reset bit is sent
> back, and your telnet client tells you "Connection refused". With UDP,
> there is no such thing. The packet is ignored. I'm wonder how the author
> of this module thinks he can use UDP as a ping? If the machine is up,
> nothing comes back. If the machine is down, well, you know. TCP would
> make more sence...
>
> On Tue, 5 Feb 2002, Frooninckx Craig - cfroon wrote:
>
> > I thought of that as well and tried it with 5, which is what the
> > documentation says is the default if you don't put anything in for timeout
> > (second argument on the new method or the ping method).
> >
> > -----Original Message-----
> > From: Bill Nash [mailto:billn at billn.net]
> > Sent: Tuesday, February 05, 2002 12:34 AM
> > To: 'phoenix-pm-list at happyfunball.pm.org'
> > Subject: Re: Phoenix.pm: Net::Ping Object
> >
> >
> >
> > If memory serves correctly (I'm a few years out from having used
> > Net::Ping), it looks like you're missing the timeout value, which, if
> > undefined, could result in the package reporting the host unreachable
> > because the response time is > 0.
> >
> > - billn
> >
> > On Tue, 5 Feb 2002, Frooninckx Craig - cfroon wrote:
> >
> > > I've written a small application that is suppose to go out and ping a
> > server
> > > to verify that the network is still active between the local server and
> > the
> > > remote server.  When I do a command line ping it works fine, however, when
> > I
> > > use the Net::Ping object, it reports that it is unable to access the
> > remote
> > > server (in the code the remote server is actually the localserver).  Can
> > > anyone see the bug??
> > >
> > > -Craig
> > >
> > >
> > > SOURCE CODE:
> > > #!/usr/bin/perl -w
> > >
> > > # Application to check the availibility of production servers every hour.
> > >
> > > use strict;
> > >
> > > use Net::Ping;
> > > use Date::Format;
> > >
> > > while () {
> > >         my $p = Net::Ping->new() or die "Can't create ping: $!\n";
> > >         my $time = time2str( "%X", time );
> > >         print "\nTime: $time\n";
> > >         my $host = "127.0.0.1";
> > >         print "Ping: ", $p->ping( $host ), "\n";
> > >         print "$host is responding!\n" if $p->ping( $host );
> > >         $p->close;
> > >         sleep 60;
> > > };
> > >
> > > __END__
> > >
> > > RESULTS:
> > > cfroon at gsgatlas: /usr/users/cfroon/Perl => ping.pl
> > >
> > > Time: 10:32:20
> > > Ping: 0
> > > cfroon at gsgatlas: /usr/users/cfroon/Perl => ping 127.0.0.1
> > > PING 127.0.0.1 (127.0.0.1): 56 data bytes
> > > 64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0 ms
> > > 64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0 ms
> > > 64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0 ms
> > >
> > >
> > > ----127.0.0.1 PING Statistics----
> > > 3 packets transmitted, 3 packets received, 0% packet loss
> > > round-trip (ms)  min/avg/max = 0/0/0 ms
> > >
> > >
> > > ********************************************************************
> > >
> > > The information contained in this communication is
> > > confidential, is intended only for the use of the recipient
> > > named above, and may be legally privileged.
> > > If the reader of this message is not the intended
> > > recipient, you are hereby notified that any dissemination,
> > > distribution, or copying of this communication is strictly
> > > prohibited.
> > > If you have received this communication in error,
> > > please re-send this communication to the sender and
> > > delete the original message or any copy of it from your
> > > computer system. Thank You.
> > >
> >
>




More information about the Phoenix-pm mailing list