Internet, IT and Technology

How to continuously ping on Windows CMD or PowerShell

windows cmd ping continuously

When we need to use the ping command, it is usually to inspect the performance or stability of our network, or it could also be because we want to see the latency between our equipment and a remote server or computer. But whatever the case if we use it in Windows, with any version this command from the console, example: ping google.com, will only make 4 requests to the domain or IP address, even with PowerShell.

Run ping command continuously

If we talk about Linux when we run the ping command, it does not stop until we force it with CTRL + C, but when you need this to happen in Windows for continuous scanning, the solution is to use the command as below with the -t attribute:

ping -t google.com

In this way the requests will not stop, a continuous ping will be achieved until we force it to stop with a keyboard combination. Although it is quite simple, sometimes we forget it, but with constant use we will learn it, and we will not have problems with the command stopping fast.

powershell ping parameter t google

If instead of constantly pinging we only want it to do a certain number of times we use the -n parameter, this limits the number of packets sent. The following example limits it to 100 packages.

ping -n 100 google.com

In this case, only 100 requests will be sent to Google domain. Whatever we use, we can use either the classic Windows terminal or the more modern PowerShell terminal, since the command is the same.

powershell ping parameter n google

Stop command execution

To stop ping, use the key combination:

CTRL + C

stop ping

If we do not stop the command with the above combination, the stats will not show up, so simply closing the window is not the best idea if we need them.

How else can we use this parameter?

  • In the case of monitoring, if we run the command throughout the day, in the end we can stop it and check if there is any network problem.
  • In other cases, we can use it to see at what time or on which days there is more congestion of our Internet connection or any Network.
  • We can diagnose our local network and detect if the problem is in our local network or if it is our provider's fault in case of Internet failures.
  • It is the easiest way to know if a server is available within our local network or on the Internet.
  • We can diagnose DNS indirectly, because if the ping command to a domain does not resolve to an IP address, it could indicate DNS problems.

What do the statistics refer to when stopping execution?

Firstly, it shows us the IP address, followed by the number of UDP packets that were sent and of those few that were received. In case one is not received, it is called a lost package. In the case of a good connection, always or 99% of the time it must be zero.

Times are in milliseconds (0.001 seconds = 1 millisecond):

  • Minimum: Refers to what was the shortest response time of a package sent during the entire execution of the command.
  • Maximum: This is the maximum time that any packet took without counting lost packets during the entire execution.
  • Mean: It is the average of all times until completion of the execution, without taking into account lost packets.

Regarding the information of the packages, if 5 packages are sent, the ideal is to receive 5 packages, otherwise they count as lost packages and the latter means that we send a signal, but we do not receive a response from the server. If the percentage of lost packets is greater than 0% it could indicate connection problems on our part or on the part of the server.

Packet loss

In no scenario is it acceptable to have lost packets, not even for domestic use it is acceptable. When there are lost packets, the first symptoms will be slow page loading at startup, interrupted downloads, video loading interruptions, and this could be throughout the day or only occasionally depending on the technology used. Why do I mention technology? When copper connections are used, a fracture can create an intermittency in the service, but when we have fiber optics, a fracture renders the Internet service completely useless. The explanation for this phenomenon is that in copper the contact between the two parts of the cable can vary due to climate and terrain, while in optical fiber, since light is refracted, it is easier to be interrupted.

Why do I get error?

In some cases that we do not receive a response does not mean that we do not have a connection to the server, this could be because many servers or IP addresses have the ICMP protocol blocked. What we must do to verify is simply try another server or send the ping from another computer on a different network.

To give some examples, it is recommended to ping known public addresses, such as Cloudflare and Google DNS, below are the IPs in the mentioned order.

  • 1.1.1.1
  • 8.8.8.8

If there is no response from these servers, then there is a problem. Otherwise, if there is a response, but there are many time-out errors, we can now begin to identify network problems.

IPv4 and IPv6 protocols

If our Internet provider has IPv6 configured, Windows by default will use IPv6 to ping. In some strange cases, our network can work perfectly over IPv4 and not IPv6 and vice versa. Therefore, it is essential that when pinging a domain or host, we must specify IPv4 to force it, or leave it as is so that IPv6 is used. If we try to use IPv6 on a network that only supports IPv4, it will show an error. This is a very quick way to know if we have an IPv6 connection through our Internet provider.

To force IPv4, we use -4.

ping -4 google.com

To force IPv6, we use -6.

ping -6 google.com

Note: these options do not work if we use IP addresses directly.

Can we ping continuously as many times as we want?

However, this does not represent a security threat because the ICMP protocol used by the command is very lightweight. This does not mean that it cannot be used maliciously, for example, if a very large group of computers infected with a virus decide to ping a single server at the same time, and it does not have a firewall nor does it have updated software. , they could cause you some performance problems. It wouldn't be serious, but there is a minimal risk.

Categories

Related content