Ping: What It Is, How It Works, and Why It's Helpful in Diagnosing Network Problems

Network problems? Use Ping, a helpful diagnostic tool.

Windows Ping Command
No comments Twitter Flipboard E-mail

If you’ve ever had problems with your Internet connection, you’ve probably used a network utility known as Ping, either on your own or at the suggestion of tech support. Most operating systems use this diagnostic tool for computer networks to determine whether a target host, identified by a given IP, is accessible from another host.

To do this, the source host sends a 32-byte packet of information to the destination host using the ICMP protocol and waits for a response from the destination host containing the same data. If the response is successful, the ping was successful. If the ping fails, either the request from the source host or the response from the destination host has been lost along the way. But how can you use this command from your computer? How can you use it to determine if there's a problem with your connection?

How to Ping

Performing a ping to another host from a computer is as simple as following these steps. Here’s how to ping on Windows 10 and 11:

  1. Open the Windows taskbar and type cmd to display the Command Prompt window. Press Enter, and you’ll now see a black box.
  2. Type ping followed by an IP address or a domain name, and press enter. For example, ping google.com.

What about macOS?

  1. Open the Finder. From the list of apps, click on Utilities.
  2. In the following list, click on Terminal.
  3. Now, in the box, type ping followed by an IP address or a domain name, and press enter. For example, ping google.com.
Ping Mac The Ping Command on MacOS.

If everything goes well, you’ll see the latency data for a list of Google’s servers.

What do these lines mean? Well, the ping confirms that, as you can see in the MacOS example above, it sent numerous 64-byte packets to the server we selected—in this case, google.com—and that the IP 142.250.201.78 corresponds to this server. In this case, the ping was successful, the test packets arrived correctly, and they returned to our computer in a matter of milliseconds.

To prevent a ping request from traveling indefinitely across the Internet, a Time To Live (TTL) is set for each ping request, representing the number of hops the packet has made from host to host before reaching its destination. At each hop, the TTL is decremented by one unit, and if at any point it reaches 0, the packet is discarded, and the host returns an error to the source.


How to Diagnose a Problem

Because the primary purpose of ping is to see if a particular computer or server is accessible from another, it’s a practical tool for diagnosing problems on a specific network. For example, let's imagine that a web page doesn’t load. This can happen for several reasons, including problems with your local network, the failure of DNS servers, or a problem with your Internet connection.

When using the ping command, it’s easy to rule out sources of error. If your connection isn't working correctly, the first thing to do is ping a generic server, such as the one we used in the example (ping google.com). If it returns some of the packets and not others, it’s probably something temporary. However, if they all come back rejected or the ping fails, your Internet connection has a problem.

The next thing you can do is verify that the problem has nothing to do with your local network. To do this, you can ping the IP address of your router. You can find it by typing ipconfig in the Windows Command Prompt. In macOS, go to Terminal and type ipconfig getifaddr en0 if you’re using a Wi-Fi connection, but if you’re using Ethernet, type ipconfig getifaddr en1. If you ping the router successfully, your computer will have access to the router and will work properly.

What other errors could you encounter? For example, your DNS—responsible for translating domains into IPs—isn’t working correctly. How can you detect this? It’s simple: If you ping a domain, for example, google.com, and you get an error message in return. On the other hand, if you ping its IP address and it works correctly, then it looks like the error might be in the DNS.

However, one thing to keep in mind when using the ping command is that not all servers accept it, and many routers cut off this type of request for security reasons. So, if you ping a server and it returns an error, it may be because the server doesn’t implement it. In these cases, the best thing to do is try the servers that you know will respond to pings.

Traceroute, Another Alternative

Ping isn't the only option available in situations like this. There's another network utility that is like ping. I'm talking about traceroute, which not only sends a packet to a destination like a ping but also shows the route it takes, including other interesting data such as the time it takes for each hop and the hosts it visits until it reaches the destination. Using this command in Windows is as simple as typing tracert and the IP address or web address for the destination, for example, tracert google.com. In MacOS, type traceroute google.com.

An advantage of tracerouting over ping is that if a communication failure occurs, you can know when it happened and on what specific host. Traceroute and ping are simple and useful commands that return valuable information that can help any user see the status of their connection and why it might fail.

This article was written by María González and originally published in Spanish.

Images | Xataka On

Related | Wi-Fi 6E: What Is It and What Are Its Advantages?

Home o Index