Network latency is the time data travels from source to destination in a computer network. It is simply the delay from sending a data package until you receive the response. High latency can cause slow website loading, lag in online gaming, and performance issues in web applications for VoIP (Voice over IP) and video calls. One of the simplest ways to measure network latency is by using the ping test.
In this article, we’ll cover how the ping command works, how to check network latency, and how to interpret the results.
Table of Contents
What is Ping?
Ping is a command-line tool we use to perform a ping test. It sends ICMP (Internet Control Message Protocol) echo request packets to a target host and measures the time it takes to receive a response. This round-trip time, or RTT, is the network latency we measure. In addition to network latency, ping can detect packet loss and jitter.
How to Use Ping to Test Network Latency
For Windows Machines
Open the Command Prompt by pressing Win +R, typing end, and hitting Enter. Then you can run the following command:
ping <destination>
For Linux and MacOS machines
Open the terminal application and run the same command:
ping <destination>
For example, to do a ping test and check the latency to Google’s public DNS server, run:
ping 8.8.8.8
You can also use the domain to do a ping test and check the network latency to some websites or your application’s server.
ping google.com
ping some.service.com
Interpret the Ping Results
A typical ping test output would look something like this:
Pinging google.com [216.58.212.14] with 32 bytes of data:
Reply from 216.58.212.14: bytes=32 time=17ms TTL=118
Reply from 216.58.212.14: bytes=32 time=336ms TTL=118
Reply from 216.58.212.14: bytes=32 time=21ms TTL=118
Reply from 216.58.212.14: bytes=32 time=8ms TTL=118
Ping statistics for 216.58.212.14:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 8ms, Maximum = 336ms, Average = 95ms
- bytes=32 – The packet size sent.
- time=17ms – The latency in milliseconds.
- TTL=118 – Time to live (indicates how many hops the packet can make before being discarded).
- lost=0 – number of packets lost and loss percentage
- round trip times (rrt) – the time it took for the network request to travel to the destination and back to the sender again.
Run a Continuous Ping Test
To monitor latency over time, on Windows, you can use the command:
ping -t google.com
Or on Linux and MacOS, the command ping runs until stopped, and you can use Ctrl+C to stop the command:
ping google.com
Destination host unreachable
If the TTL is 0 before it reaches the destination, you will get “TTL exceeded” or “Destination host unreachable.”
You may receive error messages if the host machine you are trying to ping from does not have a network. If the destination you are trying to reach is offline or the ICMP is blocked by the firewall, you will also receive messages such as “Request timed out.” This means the request is timed out before it gets any response.
Use Ping with Additional Options
You can use the flags option, which you can check with man ping for more details, to set the number of packets, packet size, and timeout.
• Set the number of packets:
On Windows:
ping -n 10 google.con
On Linux/macOS
ping -c 10 google.com
• To ping only IPv4 address:
ping -4 google.com
• Set timeout:
For Windows:
ping -w 500 google.com # (500ms timeout)
On Linux/macOS
ping -W 500 google.com
Troubleshooting with Ping
Ping can also help you identify packet loss and variation in response time (jitter). If some pings time out or show high variation in latency, there could be network congestion or instability.
The ping test is used for troubleshooting, and the values for latency, packet loss, or no response indicate an issue that needs to be checked.
• If there’s high latency, check for poor internet and bandwidth limitations
• If there’s packet loss, check for network interference. You can also use traceroute to identify the path and find the issue. It may also indicate faulty cables or router issues.
• If there’s no response, the host may be down, there might be a firewall, or ICMP may be disabled.
Conclusion
Ping is a simple yet powerful tool for testing network latency. You can diagnose network issues and improve performance by running different ping tests, analyzing round-trip times, and checking for packet loss.
For more advanced network troubleshooting, you can also use tools like traceroute (Linux/macOS) or tracert (Windows) to help you identify where network latency occurs along the network path. Alternatively, if you use our Linux VPS hosting or dedicated servers, you can just ask us to do it all for you.