5

What was the rationale for the design decision to make ping's default behavior to ping forever?

For example, the following basic usage will ping address 127.0.0.1 forever:

$ ping 127.0.0.1

According to Wikipedia, ping is used to:

test the reachability of a host on an Internet Protocol (IP) network and to measure the round-trip time for messages sent from the originating host to a destination computer and back.

In both of those use cases (reachability and round-trip time/latency), pinging forever is probably not the desired behavior, which is why it seems odd to me that it is the default behavior.

As a side note, it seems even more odd considering there is no provided user interface mechanism to quit, other than something like ctrl + c, which seems a little unrefined.

Of course the number of pings can optionally be limited if the count parameter (-c) is used, e.g.:

$ ping -c 3 127.0.0.1

[EDIT]:

To clarify, I'm hoping someone can provide a reference of some sort which mentions the reason the actual developer(s) decided on the default behavior, rather than opinion-based answers. Perhaps documentation or code comments exist which document this?

I see this question is currently on hold as being primarily opinion-based, so I'm trying to make it less so.

closed as primarily opinion-based by Sparhawk, Celada, slm Jan 14 '16 at 22:47

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    Perhaps a better question would be "Why does ping not run forever by default in Windows"? The answer to both is that the devs decided on this. Both options make sense. "Reachability" can be tested easily if the pings never stop, to test network drop-outs. – Sparhawk Jan 14 '16 at 21:43
4

Imagine you want to establish a route between hosts A and B.

On host A, you run ping B. Initially, it won't work.

On host B, or on some firewall, you make a change to the network configuration and the moment it is applied you see almost instantly that your change worked.

So, it's just very practical that it does that. Otherwise you would have to write while ! ping B; do :; done, which is more work.

In the end all of these types of questions generally end up with "Because of system resource limitations at the time" or "common sense". In this case it is "common sense".

1

Different implementations, different choices.

In iputils-ping (on Linux) the ping is continuous by default while on Solaris you need to use the -s option to get that behaviour. That's useful for monitoring network status continuously.

On Solaris ping's default behaviour of exiting successfully after the first returned packet makes it easier to use in scripts to test connectivity, whereas with iputils-ping you have to use ping -c1 -w15 to get (something like) the same behaviour.

Both are useful in different circumstances.

Different developers, different choices.

Not the answer you're looking for? Browse other questions tagged or ask your own question.