1. Overview

ping is one of the most popular commands to check the reachability of a host. Besides troubleshooting connectivity problems, it also displays several statistics about round-trip times such as average and standard deviation. However, ping displays the ping statistics at the end of the pinging when we stop it.

Sometimes, we may want to get information about intermediary ping statistics without stopping pinging. In this tutorial, we’ll discuss how to get intermediary ping statistics without stopping pinging.

2. The Default Behavior

First, we’ll inspect the default behavior of ping. Let’s start by pinging the localhost:

$ ping localhost
PING localhost(localhost (::1)) 56 data bytes
64 bytes from localhost (::1): icmp_seq=1 ttl=64 time=0.112 ms
64 bytes from localhost (::1): icmp_seq=2 ttl=64 time=0.092 ms

Now, we’ll send a SIGINT signal to the process from another terminal using the kill command:

$ kill –SIGINT 2388

2388 is the PID of the already running ping process. Let’s check the output of ping:

$ ping localhost
PING localhost(localhost (::1)) 56 data bytes
64 bytes from localhost (::1): icmp_seq=1 ttl=64 time=0.112 ms
64 bytes from localhost (::1): icmp_seq=2 ttl=64 time=0.092 ms
64 bytes from localhost (::1): icmp_seq=3 ttl=64 time=0.101 ms
64 bytes from localhost (::1): icmp_seq=4 ttl=64 time=0.089 ms
64 bytes from localhost (::1): icmp_seq=5 ttl=64 time=0.090 ms
^C
--- localhost ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4118s
rtt min/avg/max/mdev = 0.089/0.096/0.112/0.015 ms

As the output of the ping localhost command shows, we were able to get the ping statistics on the last two lines. However, sending a SIGINT signal to the process also stopped pinging. We stopped pinging the localhost after the fifth ping in our example.

We could also stop pinging by pressing Ctrl+C. Its effect is the same as sending a SIGINT signal to a process.

How can we get the ping statistics without canceling pinging? We’ll discuss it in the subsequent sections.

3. Using SIGQUIT

We’ll check what happens if we send a SIGQUIT signal to a running ping process instead of sending a SIGINT signal. First, let’s start pinging again:

$ ping localhost
PING localhost(localhost (::1)) 56 data bytes
64 bytes from localhost (::1): icmp_seq=1 ttl=64 time=0.110 ms
64 bytes from localhost (::1): icmp_seq=2 ttl=64 time=0.109 ms

We’ll send a SIGQUIT signal to the running ping process from another terminal:

 $ kill –SIGQUIT 4190

4190 is the PID of the already running process. Let’s check the output of ping:

$ ping localhost
PING localhost(localhost (::1)) 56 data bytes
64 bytes from localhost (::1): icmp_seq=1 ttl=64 time=0.110 ms
64 bytes from localhost (::1): icmp_seq=2 ttl=64 time=0.109 ms
64 bytes from localhost (::1): icmp_seq=3 ttl=64 time=0.111 ms
64 bytes from localhost (::1): icmp_seq=4 ttl=64 time=0.105 ms
4/4 packets, 0% loss, min/avg/ewma/max = 0.105/0.108/0.109/0.111 ms
64 bytes from localhost (::1): icmp_seq=5 ttl=64 time=0.097 ms
64 bytes from localhost (::1): icmp_seq=6 ttl=64 time=0.107 ms

As is apparent from the output, the SIGQUIT signal doesn’t kill the pinging process. In addition to this, the statistics until that time were displayed in the row 4/4 packets, 0% loss, min/avg/ewma/max = 0.098/0.102/0.103/0.106 ms.

Now, let’s run the kill –SIGQUIT 4190 command once more, and then kill the process by pressing Ctrl+C:

$ ping localhost
PING localhost(localhost (::1)) 56 data bytes
64 bytes from localhost (::1): icmp_seq=1 ttl=64 time=0.110 ms
64 bytes from localhost (::1): icmp_seq=2 ttl=64 time=0.109 ms
64 bytes from localhost (::1): icmp_seq=3 ttl=64 time=0.111 ms
64 bytes from localhost (::1): icmp_seq=4 ttl=64 time=0.105 ms
4/4 packets, 0% loss, min/avg/ewma/max = 0.105/0.108/0.109/0.111 ms
64 bytes from localhost (::1): icmp_seq=5 ttl=64 time=0.097 ms
64 bytes from localhost (::1): icmp_seq=6 ttl=64 time=0.107 ms
64 bytes from localhost (::1): icmp_seq=7 ttl=64 time=0.111 ms
64 bytes from localhost (::1): icmp_seq=8 ttl=64 time=0.111 ms
8/8 packets, 0% loss, min/avg/ewma/max = 0.097/0.107/0.108/0.111 ms
64 bytes from localhost (::1): icmp_seq=9 ttl=64 time=0.074 ms
64 bytes from localhost (::1): icmp_seq=10 ttl=64 time=0.105 ms
64 bytes from localhost (::1): icmp_seq=11 ttl=64 time=0.100 ms
64 bytes from localhost (::1): icmp_seq=12 ttl=64 time=0.106 ms
^C
--- localhost ping statistics ---
12 packets transmitted, 12 received, 0% packet loss, time 11295s
rtt min/avg/max/mdev = 0.074/0.103/0.111/0.016 ms

As it’s apparent from the output, the second SIGQUIT also caused the intermediary ping statistics to be displayed until that time, which is 8/8 packets, 0% loss,min/avg/ewma/max = 0.097/0.107/0.108/0.111 ms.

Therefore, sending SIGQUIT to a running ping process lets us observe the intermediary results without stopping the process.

There are slight differences between the intermediary statistics and the final statistics obtained by stopping the pinging process. Intermediary ping statistics include a value named ewma. This is an abbreviation for Exponential Weighted Moving Average. The average in this case is calculated by applying weighting coefficients to the samples. The weighting coefficients for older samples decrease exponentially. Therefore, the latest samples have more effect on the average.

The final statistics, on the other hand, include a value named mdev. This is the standard deviation of the samples.

The final statistics also include total ping time, which isn’t included in the intermediary statistics.

4. Using Key Combinations

We know that we can stop pinging by pressing Ctrl+C. Are there any other key combinations that don’t stop pinging, but also give intermediary ping statistics? The answer to this question is yes.

In fact, there is more than one option – Ctrl+|. Let’s start pinging the localhost and then press Ctrl+|:

$ ping localhost
PING localhost(localhost (::1)) 56 data bytes
64 bytes from localhost (::1): icmp_seq=1 ttl=64 time=0.113 ms
64 bytes from localhost (::1): icmp_seq=2 ttl=64 time=0.103 ms
64 bytes from localhost (::1): icmp_seq=3 ttl=64 time=0.105 ms
64 bytes from localhost (::1): icmp_seq=4 ttl=64 time=0.116 ms
4/4 packets, 0% loss, min/avg/ewma/max = 0.103/0.109/0.111/0.116 ms
64 bytes from localhost (::1): icmp_seq=5 ttl=64 time=0.107 ms

When we pressed Ctrl+| after the fourth ping, we got the statistics of the packets until that time. Pinging also continues. Therefore, the behavior is the same as sending SIGQUIT to the pinging process.

The other alternative is pressing Ctrl+\. Let’s start pinging the localhost and then press Ctrl+\:

$ ping localhost
PING localhost(localhost (::1)) 56 data bytes
64 bytes from localhost (::1): icmp_seq=1 ttl=64 time=0.033 ms
64 bytes from localhost (::1): icmp_seq=2 ttl=64 time=0.025 ms
64 bytes from localhost (::1): icmp_seq=3 ttl=64 time=0.050 ms
64 bytes from localhost (::1): icmp_seq=4 ttl=64 time=0.024 ms
4/4 packets, 0% loss, min/avg/ewma/max = 0.024/0.033/0.033/0.050 ms
64 bytes from localhost (::1): icmp_seq=5 ttl=64 time=0.038 ms

The behavior is the same. The last key combination is Ctrl+4. Let’s press Ctrl+4 while pinging continues:

$ ping localhost
PING localhost(localhost (::1)) 56 data bytes
64 bytes from localhost (::1): icmp_seq=1 ttl=64 time=0.035 ms
64 bytes from localhost (::1): icmp_seq=2 ttl=64 time=0.038 ms
64 bytes from localhost (::1): icmp_seq=3 ttl=64 time=0.057 ms
64 bytes from localhost (::1): icmp_seq=4 ttl=64 time=0.043 ms
4/4 packets, 0% loss, min/avg/ewma/max = 0.035/0.043/0.038/0.057 ms
64 bytes from localhost (::1): icmp_seq=5 ttl=64 time=0.062 ms

Therefore, we were able to get intermediary ping statistics without stopping pinging using the Ctrl+|, Ctrl+\, and Ctrl+4 key combinations.

5. Conclusion

In this article, we discussed how to get intermediary ping statistics without stopping pinging.

First, we saw that when we stop pinging by either sending a SIGINT signal or pressing Ctrl+C, ping shows the ping statistics at the end.

Secondly, we learned that getting intermediary ping statistics is possible by sending a SIGQUIT signal to the running ping process. The pinging process continues running, but intermediary statistics are displayed as soon as the process receives the SIGQUIT signal.

Finally, we saw that getting intermediary ping statistics is also possible by using some key combinations. These key combinations are Ctrl+|, Ctrl+\, and Ctrl+4.

Comments are open for 30 days after publishing a post. For any issues past this date, use the Contact form on the site.