How to Make Sense of Linux Ping Stats
Linux & macOS Terminal
Summary
- The mean ping time reveals the typical round-trip duration.
- Standard deviation indicates how much ping times vary from the mean.
- More pings may mean more accurate results, but the distribution of ping times might be skewed. Wired networks may have lower ping times.
If you run the ping command on Linux, you might notice some statistics when it finishes. What do they mean and how can they help you figure out your network issues?
Average Ping Times, Explained
The Linux ping command reports the mean round trip time in milliseconds or the average. This is the sum of all the ping times divided by the number of pings. Statisticians call this the “arithmetic mean.”
The mean is a measure of central tendency. By pinging a remote address several times and taking the mean of the return trip times, we can get an idea of how long the return times would typically take. We would have an “average” ping time.
Let’s use Google as an example and ping the site four times:
ping -c 4 google.com
At the bottom, you’ll see the stats for the round-trip times on the line “rtt.” The mean is the second value separated by the “/” (slash) character. In this case, it’s 26.819 milliseconds.
Ping Standard Deviation
Another stat that ping reports is the standard deviation, listed under “mdev.”
The standard deviation is the square root of the variance, or the sum of the mean subtracted from each data point, divided by the number of data points.
There’s a difference between a sample standard deviation and a population standard deviation, where the number of data points minus 1 is used in the former. The Linux ping command, according to the manual page, reports the population standard deviation.
So what does the standard deviation mean? The standard deviation is a measure of dispersion. It tells you how spread out the values are around the mean. A lower value means that the ping times bunch up around the mean, while a higher value indicates that the data points are more spread out from the mean. If you look at the ping times, you’ll often see a few outliers with longer return trip times, which increases the standard deviation.
If you notice performance problems with a connection, try running a ping on a remote server. If you see a high standard deviation, it means either you or the remote server’s administrator has a mystery to solve. It could be a problem with the remote server, or it could be with your connection. I find that the standard deviation is higher on wireless connections than on wired. This might be due to things like interference with the Wi-Fi signal. If network performance matters, here’s why basic statistics prove that you should use a wired connection, such as playing online games.
More Pings = More Accurate Results?
The difficulty of gauging your actual ping times might be that samples of pings tend to be small. An ideal sample size would be greater than 30, but it’s typical to ping machines for much less than that.
The main reason for this is that excessive pings can be interpreted as an attempt to break into a remote machine. So when administrators need to ping a machine, they’ll usually use a low count.
Following the central limit theorem, the sample mean will approach a normal distribution mean as the number of data points increases. My experimentation would question whether the ping times would be normally distributed, with a bell-shaped curve.
Below is a plot of a histogram of the ping times I made of some ping times over my Wi-Fi network to Google using a larger sample in Python and Seaborn. You can see that the peak is on the left while the tail is on the right.
With a normal distribution, you’d expect to see the famous bell-shaped curve that’s symmetrical around the middle. Given how skewed the distribution of ping times is, the median might be a better measure of the central tendency than the mean. The median is the middle value of a sorted set of numbers and is easy to calculate in a spreadsheet such as Excel or LibreOffice and in certain Python libraries like NumPy. The median might be a better estimate of the average because it’s less sensitive to outliers than the mean.
Ping Times Aren’t Everything
Ping times seem to vary quite a bit on wireless connections, but is that a problem? It may be for things like streaming and online gaming, but these are specialized uses. Most ordinary people might not notice this problem, except for some intermittent hiccups. I use Wi-Fi over wired most times because it’s a lot more convenient than plugging in an Ethernet cable into my laptop.
Lots of people are happily swiping on their phones out in the real world. The lesson may be that ping times are important but are only a smaller part of the bigger picture.