http://www.perlmonks.org?node_id=1072660


in reply to Issues with network connectivity and Net::Ping

Could you please try with different protocol instead of 'tcp'. like try with 'icmp' or 'udp' and check.


All is well
  • Comment on Re: Issues with network connectivity and Net::Ping

Replies are listed 'Best First'.
Re^2: Issues with network connectivity and Net::Ping
by FloydATC (Deacon) on Jan 30, 2014 at 12:21 UTC

    If I recall correctly, the ICMP protocol requires root access, this could be the reason he's trying to use TCP.

    I ended up using "/bin/ping" for my own network monitoring script and I believe this was one of the reasons. I also recall having problems with Net::Ping not timing out properly in some situations which can be a real problem when you have more than a handful of hosts to check.

    -- FloydATC

    Time flies when you don't know what you're doing

Re^2: Issues with network connectivity and Net::Ping
by Steve_BZ (Chaplain) on Jan 30, 2014 at 12:50 UTC

    Hi vinoth.ree,

    I tried with udp and I still get a timeout.

    FloydATC is correct in supposing that I didn't use ICMP to avoid the need to be root.

    I'm thinking of going down the direct call route. What do you think?

    Like this

    my $p = `ping -c 1 www.google.com | grep -i "bytes.*ms"`
    And then I either get:
    64 bytes from lhr14s21-in-f16.1e100.net (173.194.34.144): icmp_seq=1 t +tl=55 time=549 ms

    or ..

    ping: unknown host www.google.com

    There is a slight delay. But it seems reliable. Any views?

    Regards

    Steve

      Potentially, Net::Ping::External, together with the 'external' protocol should accomplish the same.

        So Net::Ping ::External it is. At least it doesn't rub the delay in your face.

        500 ms is indeed a long time and I'd be delighted to try faster methods of testing connectivity to the Internet. It doesn't need to be a specific server, I just used Google, because it's mostly available when you want it and even if you don't.

        Thanks

        Steve

      IMHO 549ms isn't slight.

      Regards, Karl

      «The Crux of the Biscuit is the Apostrophe»

        That depends on the carrier, doesn't it?

        -- FloydATC

        Time flies when you don't know what you're doing