There's more than one way to do things PerlMonks

### Re^4: Net::Ping output

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

in reply to Re^3: Net::Ping output

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!!!

Comment on Re^4: Net::Ping output
Re^5: Net::Ping output
by Anonymous Monk on Aug 20, 2013 at 11:27 UTC
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();

for (1..4) {  # 4 is the amount of packets transmitted
my (\$ret, \$duration, \$ip) = \$p->ping(\$host, 5.5);

printf "Your RTT is %.2f ms\n", \$duration * 1000;
}
Throw in a sleep 1; there somewhere if you want.

Ok , then how it will tell that its minimum or maximum RTT

The same way you would do it in real life: Compare it to a previously stored minimum and maximum.
Are you aware that you are using a programming language and can make the computer do things?

That is by far the most sarcastic sentence I've read in ages! roflmfao!

(apologies to gaurav)

Create A New User
Node Status?
node history
Node Type: note [id://1050167]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (19)
As of 2013-12-19 15:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?