1

I used ping to do an estimate of lower bound for HTTP request times as part of a feasibility study.

In order to make the test faster I lowered the interval of the ping (to get enough pings to get a reasonable average) and noted that if the interval gets short the RTT against local host dropped. For example:

>sudo ping -i 0.01 -c500 -q localhost
PING localhost (127.0.0.1) 56(84) bytes of data.

--- localhost ping statistics ---
500 packets transmitted, 500 received, 0% packet loss, time 5986ms
rtt min/avg/max/mdev = 0.006/0.007/0.055/0.004 ms
>sudo ping -i 0.00 -c500 -q localhost
PING localhost (127.0.0.1) 56(84) bytes of data.

--- localhost ping statistics ---
500 packets transmitted, 500 received, 0% packet loss, time 8ms
rtt min/avg/max/mdev = 0.003/0.004/0.016/0.000 ms, ipg/ewma 0.018/0.004 ms

(using actual -f option yielded similar results as -i 0.00).

Why does the flood ping give 4us RTT while the non-flood gives 8us? If I skip the -q flag it gets even worse as the non-flood will get up to 34us. Why this difference for printing a line for each individual pings?

My guess is that the ICMP packets are put in a queue and there's a latency before the kernel processes the queue and if there's more ICMP packets it could be that it can process them all in the same go.

A follow up question might be if ping RTT's are relevant for local host, it might be that TCP/IP is not being used when doing a localhost HTTP request.

For the record: I'm running Linux (#1 SMP Debian 3.2.68-1+deb7u2).

1

I have no idea what kind of CPU you are using, for me -i 0.01 yields 45µs rtt, vs. 8µs with -f. This difference is (for my SandyBridge CPU) roughly consistent with the time needed for a wakeup from C6 power saving state:

http://ena-hpc.org/2014/pdf/paper_06.pdf

And yes, printing to the console can be quite expensive, depending on your terminal emulator (or ssh, etc.).

  • Perhaps printing to the console is expensive, but considering that the command lines are in quiet mode (nothing printed while pinging) I think one could rule that one out. Also I don't see why the wakeup time would be relevant - the RTT is the time between the ping is issued and the response is returned, I don't see why the CPU would enter power saving state here. – skyking May 14 '17 at 13:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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