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

Re^2: Net::Ping output

by gaurav (Acolyte)
on Aug 20, 2013 at 04:18 UTC ( #1050119=note: print w/ replies, xml ) Need Help??

in reply to Re: Net::Ping output
in thread Net::Ping output

Actually I want the same output as System-Ping command say, Tx packet,Rx Packets,TTL,RTT(max,min,avg),packet-loss.

Comment on Re^2: Net::Ping output
Replies are listed 'Best First'.
Re^3: Net::Ping output
by Anonymous Monk on Aug 20, 2013 at 08:44 UTC
    And you can get the same output. Ping n times, collect results in an array, calculate values, print them out (if necessary). Which part were you having trouble with?

      I am sorry ,but didn't get you .would you please elaborate more,because I have seen this code & it does not seems like to draw the required values

      $p = Net::Ping->new(); $p->hires(); ($ret, $duration, $ip) = $p->ping($host, 5.5); printf("$host [ip: $ip] is alive (packet return time: %.2f ms)\n", + 1000 * $duration) if $ret; $p->close();

      Now please tell me how can I calculate RTT,how I can get transmitted packets,recieved packets.Please!!!

        RTT is stored into $duration; if a packet was received, $ret is true. Are you aware that you are using a programming language and can make the computer do things?
        my $p = Net::Ping->new(); $p->hires(); my $received = 0; for (1..4) { # 4 is the amount of packets transmitted my ($ret, $duration, $ip) = $p->ping($host, 5.5); $received++ if $ret; printf "Your RTT is %.2f ms\n", $duration * 1000; } printf "Received %i packets\n", $received;
        Throw in a sleep 1; there somewhere if you want.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1050119]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2015-11-26 05:54 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (696 votes), past polls