If you have ever had problems with your connection, it is likely that, you have used a network utility known as Ping, implemented by default in the vast majority of operating systems. The purpose of a ping is to determine if a destination host, identified with a particular IP, is accessible from another host.
To do this, the source host sends a 32-byte information packet to the target host through the ICMP protocol and waits for a reply to the latter, which must contain the same data. If the response arrives correctly, the ping has been successful. If, on the contrary, the ping fails, then either the request of the source host or the response of the destination host has been lost along the way. But how can we use this command from our computer? How can we use it to determine what the problem of our connection might be?
How to ping
To ping another host from a computer with a Windows operating system, it is as simple as following these steps:
- Open the command console: To do this, go to Start >> Run and type cmd. In more recent versions, simply go to Start and type it in Search programs and files. Then press enter.
- Type "ping hostname": Now we will see a window with a black background. In it we will write, for example, ping www.google.com
If everything went well, in our command window something similar to the following will appear:
What do these lines mean? As the ping confirms that it has sent four packets of 32 bytes in size to the server we have selected, in this case www.google.com, and that server corresponds to the IP 172.217.8.132. In this case the ping has been satisfactory, the four test packets have arrived correctly and have returned to our computer with an average time of 102ms.
To prevent a ping request from traveling unlimited on the Internet, a Time To Live (TTL) is established in each of them, which represents the number of hops that the host packet has given in the internet host until reaching its destination. At each hop, the TTL is decremented by one unit, and if at any point it reaches 0 then the packet is discarded and the host returns an error to the source.
Ping is a very simple command but also with several options to customize the results. For example, if you want not only 4 packets to be sent, but also sent continuously, it is as simple as adding a -t to the end of the line (ping www.google.com -t).
Diagnosing the problem
As the main purpose of a ping is to see if a particular computer or server is accessible from another, it is a very useful tool when diagnosing problems in a given network. Suppose, for example, that you cannot load any web pages. This can be due to several reasons, for example, if our local network fails, if the DNS servers we are using are dropped or if, directly, what is missing is our internet connection.
Using the ping command is easy to discard possible sources of error. First, if we see that our connection is not working properly, it is best to ping a generic server, like the one we put before as an example (ping www.google.com). If you return one of the four packages and others do not, it is probably temporary. However, if everyone gets rejected or if you do not ping directly, then there is some problem with our connection.
What we can do next is to verify that the fault is not from our local network. To do this, we ping the IP address of our router. This address is usually 192.168.0.1 or 192.168.1.1, but you can easily get it if you write ipconfig in the command console and look for the address of the gateway. If we ping the router and it is satisfactory, then our computer has access to it and it works correctly.
What other flaws can we diagnose? Well, for example, the DNS (that are responsible for translating the domains to the IPs) that we are using do not work correctly. How can we detect it? Very simple: we ping a domain, for example www.google.com, and it gives us an error. Instead, if we ping its IP address (for example, at 172.217.8.132) and it works for us correctly, then it looks like the bug may be in DNS.