The Ping Command, one of the most used commands by SysAdmins. The Ping cmd sends small packets of data to a specified IP Address or Hostname. It measures how long it took for the response to return and how many packets are lost during the test.
The Ping Cmd is a simple command to use, in this article I will give you some tips to get more out of it.
How to use the Ping Cmd
You can use the ping command from every terminal, Windows Command Prompt, PowerShell or in the terminal on Linux or macOS. In this article, we will use the Command Prompt.
- Press Windows key + R to open the Run Window
- Type cmd
- Press enter
Or if you are using Windows 10, you can simply open the start menu and immediately type cmd. Windows will find the command prompt for you and you only have to press enter.
The ping cmd is really simple to use, just type ping followed by the IP address or hostname you want to test.
This command will send 4 packets of 32 bytes from your computer to network device with IP address 192.168.0.1 (most likely your router). During the ping you will see the results of each packet that is sent and a summary:
Pinging 192.168.0.1 with 32 bytes of data: Reply from 192.168.0.1: bytes=32 time=1ms TTL=64 Reply from 192.168.0.1: bytes=32 time=1ms TTL=64 Reply from 192.168.0.1: bytes=32 time=1ms TTL=64 Reply from 192.168.0.1: bytes=32 time=1ms TTL=64 Ping statistics for 192.168.0.1: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 1ms, Maximum = 1ms, Average = 1ms
Reading the ping results
So if we look in the result above, you see some different values, but what do they all mean? By default, ping will send 4 packets of 32 bytes to the requested Ip Address. For each packet we see the result, in this case, 192.168.0.1 has replied in 1ms.
Reply from 192.168.0.1: bytes=32 time=1ms TTL=64
- Bytes indicates the size of the packet that was sent. We can change this by using the -l switch.
- Time is how long it took for the response to come back (latency), in this case, 1ms.
- TTL is how long a packet should live (Time to Live). This is not in ms, but how many hops a network packet can take before it’s dropped. Each hop (network device) that the packet comes through lowers the TTL until it reached 0. This is to protect your network from an endless loop of network packages that couldn’t find their destination.
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
At the end of the result, we see how many packet where send in total and how many of them were lost. You want a 0% loss, of course, if you start losing package then you should narrow it down to find in which part of the network the loss occurred.
Now, this is was a simple internal network test. A response time of 1ms for in your home network is what you want. Any longer indicates that something isn’t optimal.
You can use ping to check if you can reach a host, but most of the time when you are troubleshooting a network you are more interested in the ping latency. The lower the latency the faster the connection is between you and the host. A ping time of 100ms is really high, between the 10ms and 20ms is more common.
Now the amount of latency you have depends on a lot of factors. Are you connected of WiFi or cable? What kind of internet connection do you have? Where are you located compared to the host geographically?
Their are a few general guide lines when it comes to latency:
- You latency should be steady. If you have a lot of fluctuation in the ping latency, then the network, workstation or host can’t handle the traffic (or you are on a 4G network… )
- The internal network should be at 1ms with a max of 3ms.
- A good latency to a public server is in general between the 7ms and 20ms.
C:\>ping lazyadmin.nl Pinging lazyadmin.nl [22.214.171.124] with 32 bytes of data: Reply from 126.96.36.199: bytes=32 time=10ms TTL=57 Reply from 188.8.131.52: bytes=32 time=11ms TTL=57 Reply from 184.108.40.206: bytes=32 time=11ms TTL=57 Reply from 220.127.116.11: bytes=32 time=10ms TTL=57 Ping statistics for 18.104.22.168: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 10ms, Maximum = 11ms, Average = 10ms
Take for example this site, which is hosted in the United States. If I ping it from my current location in the Netherlands, I have a ping of 10ms. This is absolutely perfect.
If you have a high or inconsistent latency you really should check this article, where I talk more about optimizing your router to get the best performance.
Ping Command Options
The basic ping command will do fine for small and simple tests, but with some option, you can make the ping cmd more useful for troubleshooting potential network problems.
The ping -t command is something I use pretty often. Let’s say you want to restart your router, now you can repeatedly press F5 to check if the router is back online. With the ping -t cmd you can let the ping run continuous, so you can see when the router is offline and when it comes back online.
C:\>ping -t 192.168.1.1 Pinging 192.168.1.1 with 32 bytes of data: Reply from 192.168.1.1: bytes=32 time=1ms TTL=64 Reply from 192.168.1.1: bytes=32 time=1ms TTL=64 Reply from 192.168.1.1: bytes=32 time=1ms TTL=64 Reply from 192.168.1.1: bytes=32 time=2ms TTL=64 Reply from 192.168.1.1: Destination host unreachable. Reply from 192.168.1.1: Destination host unreachable Reply from 192.168.1.1: bytes=32 time=1ms TTL=64 Reply from 192.168.1.1: bytes=32 time=2ms TTL=64 Reply from 192.168.1.1: bytes=32 time=1ms TTL=64 Reply from 192.168.1.1: bytes=32 time=1ms TTL=64 Reply from 192.168.1.1: bytes=32 time=1ms TTL=64 Reply from 192.168.1.1: bytes=32 time=1ms TTL=64 Ping statistics for 192.168.1.1: Packets: Sent = 12, Received = 10, Lost = 2 (16% loss), Approximate round trip times in milli-seconds: Minimum = 1ms, Maximum = 2ms, Average = 1ms
As you can see in the results above, the host (router in this case) was for a brief moment unreachable and then came back online.
If you are troubleshooting network issues it’s sometimes a good idea to increase the packet size that is sent during the ping. Some network problems only occur when more data is sent. With the ping -l (L) command you can change the size of the packets.
C:\>ping -l 1024 192.168.1.1 Pinging 192.168.1.1 with 1024 bytes of data: Reply from 192.168.1.1: bytes=1024 time=1ms TTL=64 Reply from 192.168.1.1: bytes=1024 time=1ms TTL=64 Reply from 192.168.1.1: bytes=1024 time=3ms TTL=64 Reply from 192.168.1.1: bytes=1024 time=1ms TTL=64
Here we are sending packets of 1024 bytes to the router with IP Address 192.168.1.1.
With the ping -n command you can specify the number of pings you want to run. So instead of the default 4 or the continuous with -t, you can ping a host 10 times for example. Not something I really use often, but it might come in handy if you have some performance issue that you want to check
ping -n 10 192.168.1.1
Finding network issues with the Ping Cmd
If you have network issues your first start is probably to ping the server that you can’t reach. But that isn’t really helpful, yes you probably get the result Destination host unreachable but that doesn’t tell you much. Only that you can’t reach the server in question.
You want to know where the problem is, now you can ping each hop (network device) between you and the server, but there is a easier way. With pathping you can ping each hop between you and the server, showing you exactly where the connection is lost.
Read more about pathping and how to use it in this article.
Ping Command Conclusion
Ping is a really easy to use command that is available on almost every device. Even some routers have built-in ping tools that you can use to troubleshoot your network. Keep an eye on the latency, that is one of the most important values from the ping cmd results.