When I run this on an Ubuntu box:
sudo ping google.com -c 25 -l 25
I get about 1 line back every 2 seconds despite the fact that it should (if I'm reading things correctly) send out all 25 packets at the get go. Oddly enough it claims that I'm getting ping times of:
--- google.com ping statistics ---
25 packets transmitted, 24 received, 4% packet loss, time 0ms
rtt min/avg/max/mdev = 23.370/28.067/32.902/2.895 ms, pipe 24
Also, if I want to bail early, I need to punch ctrl-C once for each packet. Does anyone have any clue what could be causing this?
If you ping via IP, as opposed to hostname, you will receive the expected behavior.
I'm still investigating to get to the root of why this is the case.
UPDATE
After running ping through strace, I found that it was getting hung up on name resolution (no surprise). However, the thing that caught my eye was
avahi-daemon
. This service implements Apple's Zeroconf architecture (also known as "Rendezvous" or "Bonjour"). In other words, functionality I don't need.After stopping the avahi-daemon, ping behavior went back to normal.
Disabling it during startup can be accomplished with:
Another work around is simply using the
-n
flag with ping. The hang up is with reverse DNS lookups performed when processing the replies.If you do a tcpdump while doing your ping, you'll probably see that it's pausing on the reverse-mapping lookup... ie: when it looks up the IP-to-name DNS mapping.
I guess avahi-daemon is being queried somewhere in the chain when the packets come back in. The -l 25 only cares about the outbound packets... ping is still going to do its job and look up all the names, whether you preload or not. :)