The TCP and UDP pings require the echo service to be running. Most security concious folk will have this disabled by default (or probably blocked at a firewall) as it serves no real useful purpose (other than for people using Net::Ping :).

To answer the questions, in the first case the TCP connection probably hit a real machine with no TCP echo service running (which promptly returned something telling your TCP stack that a connection couldn't be made). Then it hit an address that was either firewalled or not there, so it didn't hang in as much as it was waiting for the connection to be established (most implementations will wait about 2 minutes before returning an error in this case).

In the second case, there probably was nothing running a UDP echo service so you saw no replies (or a firewall was dropping all UDP traffic).

As for the final case, the error message sums it up: you were trying to do something that requires root privledges on most real OSen. Sending ICMP traffic requires access to a raw network socket, which means you can pretty much send whatever packets you'd like (meaning you could inject spoofed traffic onto the network). J Random User isn't allowed to do this (which is a good thing). You'd need to run the program as root (or have it setuid to root; in which case you'd need to be aware of the security implications that brings :) in order for it to work. If you look at your system's ping utility you'll see that it's setuid to root.


In reply to Re: Why does Net::Ping behave this way? by Fletch
in thread Why does Net::Ping behave this way? by rbc

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.