1753917 Members
8013 Online
108810 Solutions
New Discussion юеВ

Re: ping timeout value.

 
SOLVED
Go to solution
Padma Asrani
Honored Contributor

ping timeout value.

Hi

I would like to understand -W option on Fedora Linux. What is the default value of -W. I was going through the man page.

-W timeout
Time to wait for a response, in seconds. The option affects only timeout in absense of any responses,
otherwise ping waits for two RTTs.

What is the values of two RTTS? If I ues -W 1000 would it mean it will wait for 1000 seconds for the response packet before declaring timeout.

Regards
Padma
6 REPLIES 6
Ivan Ferreira
Honored Contributor
Solution

Re: ping timeout value.

>>> What is the values of two RTTS?

According to ping source code:

if (nreceived) {
/* approx. 2*tmax, in seconds (2 RTT) */
expire = tmax / (512*1024);
if (expire == 0)
expire = 1;
}

2 RTTs would be 2*tmax, being tmax the maximum RTT obtained from a ping sequence. You can see it at the end of a ping as:

rtt min/avg/max/mdev = 0.040/0.042/0.044/0.002 ms, pipe 2

That would mean that the -W allows you to
specify how much time you will wait for a
response, in case that you have, for example,
missing packets.
After some echo reply, you will have your RTTs calculated,
if a response is not received, and you don't
specify -W, it will wait 2*tmax, otherwise,
will wait -W seconds.

Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Padma Asrani
Honored Contributor

Re: ping timeout value.

Hi

Thanks for the response. What is the value of tmax
In my case it is returning

rtt min/avg/max/mdev = 0.398/0.656/0.915/0.259 ms

How do i interpret this. I wanted to call ping from a c program and with -W. what would be reasonable default value in case user doesn't specify it.

Thanks
Padma
Ivan Ferreira
Honored Contributor

Re: ping timeout value.

>>> What is the value of tmax
>>> In my case it is returning

>>> rtt min/avg/max/mdev = 0.398/0.656/0.915/0.259 ms

As you can see above, the max would be the third value, first is min, then average, then max.

>>> I wanted to call ping from a c program and with -W. what would be reasonable default value in case user doesn't specify it.

This depends of what you are trying to do, probably, you don't even need to specify a timeout value, but a count. Or probably, would be better if you use -w (lower).
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Padma Asrani
Honored Contributor

Re: ping timeout value.

Hi

Ok I got you, so if min is 0.398 mili seconds then I believe we use -W so -W 398

right?

Padma
Ivan Ferreira
Honored Contributor

Re: ping timeout value.

>>> Ok I got you, so if min is 0.398 mili seconds then I believe we use -W so -W 398

That would be correct, but remember that -W use max, not min. But, why do you want to specify this value?
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Padma Asrani
Honored Contributor

Re: ping timeout value.

Hi

Thanks for your response. We have a enterprise specific MIB file which I can do ping through snmp, now a user can specify this value, if this value is not specified then I have to start with some default value.

Regards
Padma