What Is the Ping Command and What Is It For?

Many times users can find that we cannot access a computer on our network, a website, a resource on the network, etc. That is why a very useful tool to diagnose connection problems is the so-called ” ping “. In this article we will explain what it is for, how it can be used and what options this command has so important for networks.

What is ping and how does it work?

When we execute a PING request, it sends an ICMP Echo Request message to the destination host, and when the destination host responds to it, it does so with an ICMP Echo Reply message. Following that response, the minimum, average and maximum response time is calculated. In case of not receiving a response in a predetermined time, we will receive the message that there is no connection with the host, the network is unreachable or that the route to the host is not found.

What can it do to throw a ping?

Imagine we do not have access to a website. By pinging the web server, we can know if it is a problem that there is no connection to the server, or it is another type of problem. Another example could be that we can not print on a network printer, for this, if we perform a ping we will know if we have a network connection with the printer or not, that is, if we simply have communication with it or it is a matter of drivers or others problems. These examples apply to any network device, either local or Internet that has an IP address, either private or public IP.

How to use the ping command

To use the ping command, we must run the “command prompt” console, although this command is also on Linux and macOS operating systems. Once the console is open, we will simply have to type the ping command, followed by a space, and followed by the IP address or website we want to consult. You can see the following example:

In the photo above we can see how the ping responds to the Google.es website, and to an IP address of the local network, specifically the private IP address that our router has. In the answer we can see that it shows us the following information:

  • Bytes : It is the size of the data packet sent.
  • Time : It is the time it took to send it and receive a response from the destination host.
  • TTL : It is the time of life, in each jump that takes until arriving at the host one discovers. That is done so that the package is not running the network infinitely and can be discarded when the time comes.
  • Packages : Shows the number of packages sent, received and lost.
  • Approximate round trip time in milliseconds : It helps us to know how long it has taken on average the four ping requests you have made

What happens if we ping a website or computer that is not accessible

As you can see in the image below, it shows us in each of the four attempts a “timeout for this request” message. This means that it was unable to contact the destination host. In addition, we can also see in the information of the packages, which sent four packages, received zero packages and, therefore, there are four lost packages.

Ping command options in Windows

When we use the ping command, apart from typing in the command prompt console the ping command and the IP address or name of the server, we can write a series of options to modify or obtain extra data, for this we must enter the command «ping »A space, and followed one of the options that we indicate below. An example would be: ping -t 192.168.1.1

  • -t: This option allows us to make an unlimited number of pings to the destination host. To stop it we must press the key combination control + c.
  • -a: This option allows us to resolve addresses in host names, that is, if we enter this option followed by an IP address, it will show us the name of the destination host server.
  • -n: This option is used to specify the number of ping requests we want to make to a host. To do this, we must enter the -n option, a space, followed by the number of requests we want to make.
  • -l: This option is used to specify the buffer size of the ping request that we want to make to a host. To do this, we must enter the -l option, a space, followed by the buffer size we want.
  • -f: This option is used to set the mark of not fragmenting packages. It only works with IPv4 IP address.
  • -i: This option is used to specify the lifetime of the ping request. To do this, we must introduce the option -i, a space, followed by the life time we want.
  • -r: This option is used to record the maximum number of jumps that the ping request can make. To do this, we must enter the -r option, a space, followed by the number of jumps we want. It only works with IPv4 IP addresses.
  • -s: This option is used to record the time of each jump made by the ping request. To do this, we must introduce the -s option, a space, followed by the time we want to take between jumps. It only works with IPv4 IP addresses.
  • -j: This option is to indicate to the ping request what will be the non-strict origin of the ping request to the host. To do this, we must enter the -j option, a space, followed by the source host we want. It only works with IPv4 IP addresses.
  • -k: This option is to indicate to the ping request what will be the strict origin of the ping request to the host. To do this, we must enter the -k option, a space, followed by the source host we want. It only works with IPv4 IP addresses.
  • -w: This option is used to indicate the maximum waiting time in milliseconds in each response before giving connection failure. To do this, we must enter the -w option, a space, and the time in milliseconds we want.
  • -R: This option is used to use a routing header and test the reverse route. It only works with IPv6 IP addresses.
  • -S: This option is used to indicate to the ping command, which source address we want to use to ping. To do this, we must enter the -s option, a space, followed by the source IP address.
  • -c: This option is for routing the compartment identifier.
  • -p: This option allows us to ping a virtualized server with Hyper-V.
  • -4: This option serves to force the use of IPv4 IP addresses.
  • -6: This option helps us to force the use of IPv6 IP addresses.

As we have seen, thanks to the ping command we can know if we have a connection to a network device, website, or remote device. To do this, we only have to execute the ping command in a console, and we will obtain response time data and if we have connection to the destination host. In addition, we have available a series of options that can be very useful.