Skip to content

linux ping is using deadline instead of timeout for probes #100

@sa-linetco

Description

@sa-linetco

According to the ping manpage the parameter used for timeout should be -W. Currently -w is used, which sets the deadline option on linux. The deadline option overrides the packet count option (-n) (in some scenarios) which results in more ping requests than expected.

man ping
       -w deadline
              Specify  a  timeout,  in seconds, before ping exits regardless of how many packets have been sent or received. In this case ping does not stop after count packet are sent, it waits either for
              deadline expire or until count probes are answered or for some error notification from network.

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

Comparison between -w and -W (have a look at the "packets transmitted" count):

:~$ time /bin/ping -n -w 5 -c 1 172.29.14.32
PING 172.29.14.32 (172.29.14.32) 56(84) bytes of data.

--- 172.29.14.32 ping statistics ---
5 packets transmitted, 0 received, 100% packet loss, time 4098ms

real	0m5,008s
user	0m0,006s
sys	0m0,000s
:~$ time /bin/ping -n -W 5 -c 1 172.29.14.32
PING 172.29.14.32 (172.29.14.32) 56(84) bytes of data.

--- 172.29.14.32 ping statistics ---
1 packets transmitted, 0 received, 100% packet loss, time 0ms

real	0m5,006s
user	0m0,001s
sys	0m0,004s

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions