The ping command is one of the most helpful network diagnostic tools at your disposal. It’s useful for finding problems both on your local network and on the wider internet. Let’s look at what the ping command does and how to use it.
What Does It Mean to Ping Something?
To “ping” something on a network means that you send an internet packet to a destination computer or other network device, asking for a response. That device then sends a packet back to you.
When the packet comes back (if it makes it back, that is) you can learn all sorts of interesting things about the network between yourself and the destination.
Most commonly, we simply want to know how long the reply takes. So when someone mentions the “ping” of (for example) a website, it’s usually expressed in milliseconds, with a lower number being better in general.
What Is an Internet Packet?
To better understand ping, you need to know a little about the packet you’re sending to the target computer or network device as a “ping.”
Packets are the fundamental units of the modern internet. When you send someone data, like a photo, it gets broken up into tiny pieces. Each packet is marked with a source and destination address and then sent off into the internet. These packets pass through many other computers, such as web servers and internet routers. Packets keep getting passed along until they reach the target system.
What You Can Use Ping For
The ping command has two primary uses:
- To check whether your connection to a remote computer works at all.
- To check how healthy that connection is.
Even if your ping reaches its destination and you get a reply, the ping response will tell you how long a packet took to return and how many packets have been lost. You can use the ping command to diagnose if the connection is too slow or unreliable.
What sorts of things can you ping?
- In theory, you can ping anything with an IP address.
- You can ping devices on your LAN to make sure they’re connected properly.
- You can also ping websites to see if you can reach them.
How to Use Ping on Windows
Using ping is easy. You run it from the Command Prompt or PowerShell, but we’re using the Command Prompt in this example:
- Open the Start Menu, search for the Command Prompt, and select it.
- Type Ping and then enter either the IP address of the device or the URL of a site you’d like to ping.
We’ve used Google.com as an example below.
Once initiated, ping will send four packets of data.
A message for any packets that says “request timed out” implies that your computer did not receive a reply from the target. If some packets are lost, some of the routing paths between your computer and the target have an issue.
Useful Ping Command Modifiers for Windows
There are quite a few command switches you can use with the ping command. Switches are extra options to customize how the ping command functions. If you want to see a complete list of options, all you have to do is type ping /help at the Command Prompt and press Enter. You’ll see the whole list as well as the syntax and usage.
Below is a list of a few command switches that are of use to most users:
- /t: Continuously ping a target for however long you want. Press Ctrl + Break to pause the process and look at the current statistics. To quit, press Ctrl + C.
- /a: Resolve the hostname of an IP address. This is useful if you have an IP address and would like to know the web address associated with the specific server you’re pinging.
- /n X: Replace “X” with the number of pings you want to send. The default is four. But if you want to better analyze the number of lost packets, send more pings to get a more accurate idea of how many packets are getting lost on average.
- /w X: Replace “X” with the number of milliseconds you want to wait before declaring a timeout. By default, this value is 4000ms. If you think that a connection may be working but that ping isn’t waiting long enough for a reply, you can increase X to see if you’re right.
- /l X: Replace “X” with a value in bytes to increase the size of each ping. By default this value is 32, but you can increase it to 65527. This is useful to see if it’s packet sizes that are causing issues on your network. A 32-byte ping would work with the default setting, but something larger would result in lost packets.
How to Use Ping on macOS
For Mac users, you have to user Terminal. Previous versions of macOS included Network Utility, which was a graphical utility that you could use to run network commands like ping.
However, the latest versions have deprecated that utility in favor of Terminal. It’s not as intuitive to use, but it’s still fairly straight-forward. First, open Terminal by opening Spotlight (Command + Spacebar) and typing in terminal.
To start a ping, just type the command as was shown in Windows: ping followed by the IP address or URL of the website, i.e. ping www.google.com.
The main difference you’ll notice between using ping on Windows and Mac is that on macOS it just keeps going until you manually stop it. To stop pinging the device or URL, press Ctrl + C. That will bring you back to the main prompt.
To see a list of all of the parameters you can use for ping on macOS, you can type man ping and get the help pages. There are a lot of switches, so take your time playing around with the different options.
To get out of the man page, you have to simply press the q key on your keyboard. This will quit the man page and take you back to the prompt.
The ping command is very versatile and is often the fastest way to figure out where the problem is on a network. We strongly recommend that you check out The Best Windows Command Line Network Commands for essential network diagnostic commands.