Home > Enterprise >  What's the max value for Ping -W parameter?
What's the max value for Ping -W parameter?

Time:06-07

In my computer,I run the command ping 127.0.0.1 -c3 -W 5 and the result is ok.But when I run the command ping 127.0.0.1 -c3 -W 5000,the result is not ok,the result is

ping: bad linger time.

.So I wonder What's the max value for Ping -W parameter?

CodePudding user response:

In the specification of ping protocol, there is no maximum for timeout value. once I used it in code for a project .I used Int as data type for this properties, so the maximum value would be 2147483647. However, this value as milliseconds is equivalent to approx. 25 days. I don't think any one would wait for 25 days to get a ping response. Most likely other part of the network infrastructure already time out and discard the ping packets. just don't use space between w and 500 ping 127.0.0.1 -c3 -W5000

There is no limit to the legnth of timeout flag

CodePudding user response:

Regarding your posted version i simply looked up the code on github for release s20160308.

as seen in line 427

if (lingertime < 0 || lingertime > INT_MAX/1000000)

the max value in your specific case is INT_MAX/1000000. Now INT_MAX can also depending on the implementation, but keeping the defaults it should be 2147483647 which would result in the answer of ping -W maximum value of

2.147

however in newer version of ping, this value is much higher. so you might consider updating your iputils

  • Related