The ping utility is a basic, yet the most widely used network command-line tool used to test network connectivity and name resolution of a remote device. The device can be another computer, network switch, or a router on your local network. Or, it can be a device on the Internet, such as a web server, web site, DNS server, or email server. Ping uses the Internet Control Message Protocol (ICMP) Echo function as described in RFC 792. A small data packet is sent through the network to the remote device. The device that sent the packet then waits and listens for a return packet. If the connections are good and the remote device is online, a good return packet will be received. If you encounter issues accessing a website, sending an email, or opening a file on your network file server, the ping tool is used to test and troubleshoot connectivity issue.
These commands shown here are tested on Windows 10 but most will work in other versions of Windows as well.
The ping command allows you to send a signal to another computer (either on your local network or a computer on the Internet) to determine if it is active or if it can be reached. This command uses Internet Control Message Protocol (ICMP) to send out an ECHO_REQUEST to the target computer and waits for an ECHO_REPLY packet.
The ping command is one of the primary network troubleshooting tools to test reachability of a remote computer (hence the term "can it be pinged?"). Written by Mike Muuss in 1983, this utility, comprise of about a thousand line of code, was reportedly named "ping" to have it sound like the ping submarine sonar makes.
How ping accomplishes this is by sending a series of small data packet to a device and waiting for a reply from the device to acknowledge (also referred to as replies) it received the data. For most Windows computer, the ping command sends a series of four (4) data packets. Most network devices are configured to automatically listen for and acknowledge receipt of each ping packet sent to them. The ping/reply process typically takes just milliseconds for each data packet. The replies, will let us know if the device is online and how long it took to receive the reply (known as latency).
The ping command reports the following information:
To use this utility, you will need to launch the Command Prompt window. The three common ways to launch the Command Prompt window are:
cmd
using the built-in Windows search tool.cmd
at the Run window that appears.ping [/t] [/a] [/n <Count>] [/l <Size>] [/f] [/I <TTL>] [/v <TOS>] [/r <Count>] [/s <Count>] [{/j <Hostlist> | /k <Hostlist>}] [/w <timeout>] [/R] [/S <Srcaddr>] [/4] [/6] <TargetName>
Parameter | Description |
---|---|
-t | Ping the specified host until interrupted. To see statistics and continue - type Control-Break. To stop - type Control-C. |
-a | Resolve addresses to hostnames. |
-n count | Set the number of echo requests to send. Default is 4. |
-l size | Set the length (in bytes) of the data field (send buffer size). The default is 32 bytes. Maximum is 65,527. |
-f | Set the Don't Fragment flag in packet (IPv4-only) in the IP header set to 1. The echo Request message cannot be fragmented by routers in the path to the destination. This parameter is useful for troubleshooting path Maximum Transmission Unit (PMTU) problems. |
-i TTL | Set the Time To Live value. The default is the default TTL value of the host. The maximum TTL is 255. |
-v TOS | Type Of Service (IPv4-only. This setting has been deprecated and has no effect on the type of service field in the IP Header). |
-r count | Record route for count hops (IPv4-only).Count must be a minimum of 1 and a maximum of 9. |
-s count | Timestamp for count hops (IPv4-only). Count must be a minimum of 1 and a maximum of 4. |
-j host-list | Loose source route along host-list (IPv4-only). With loose source routing, successive intermediate destinations can be separated by one or more routers. The maximum number of addresses of names is the host list is nine (9). The hostlist is simply a series of IP addresses in dotted decimal notation (e.g., 192.168.128.8) each separated by spaces. This parameter is only for IPv4 addresses. |
-k host-list | Strict source route along host-list (IPv4-only). With strict source routing, successive intermediate destinations must be directly reachable. The maximum number of addresses of names is the host list is nine (9). The hostlist is simply a series of IP addresses in dotted decimal notation (e.g., 192.168.128.8) each separated by spaces. This parameter is only for IPv4 addresses. |
-w timeout | Timeout in milliseconds to wait for each reply. |
-R | Use routing header to test reverse route also (IPv6-only). Per RFC 5095 the use of this routing header has been deprecated. Some systems may drop echo requests if this header is used. |
-S srcaddr | Source address to use (IPv6-only). |
-c compartment | Routing compartment identifier. |
-p | Ping a Hyper-V Network Virtualization provider address. |
-4 | Force tracert to use IPv4 for the trace. |
-6 | Force tracert to use IPv6 for the trace. |
/? | Displays help information. |
There are a variety of switches (sub commands) available with the ping utility that will configure how it behaves. The examples in this article illustrates common ways ping is used.
To test network connectivity and latency to a website, such as www.meridianoutpost.com, type the following in the command window then press Enter: ping www.meridianoutpost.com
In the example illustration shown below, the ping command sent four data packets to the web server hosting the website www.meridianoutpost.com. There were four 'pings' sent and four replies received (one for each of the four 'pings'). Additionally, the ping reports the amount of time it took to receive each of the replies (lower time is better) and other useful information. In this example, it shows the average round trip time (latency) is 66ms and the web server received and replied to all four ping packets.
Lastly, the ping also will report the IP of the website being pinged, namely 72.47.244.140. Ping will perform a DNS lookup to find the IP address of the remote device as it is required for any network communication on the Internet.
If the website you are pinging is offline, does not exist, or there is no network connectivity to it, ping will response back with time outs or other related messages in its result, as illustrated below.
To test network connectivity and latency to a specific IP address, such as 8.8.8.8 (this IP is a Google DNS server), type the following in the command window then press Enter: ping 8.8.8.8
In the example illustration shown below, the ping command sent four data packets to the server at 8.8.8.8. There were four 'pings' sent and four replies received (one for each of the four 'pings'). Additionally, the ping reports the amount of time it took to receive each of the replies (lower time is better) and other useful information. In this example, it shows the average round trip time (latency) is 10ms and the server received and replied to all four ping packets.
If the website you are pinging is offline, does not exist, or there is no network connectivity to it, ping will response back with time outs or other messages in its result, similar to the those illustrated in the ping <URL> example.
The ping utility allows to you custom how it behaves. Using the -n
and -l
switches, we can define the number of packet to send and the size of each packet, respectively. For example, to send 10 packets, each sized at 2,000 bytes to the web server hosting the website www.meridianoutpost.com, type the following in the command window then press Enter: ping -n 10 -l 2000 www.meridianoutpost.com
You can use the -a
switch to have ping report the hostname of a particular IP address. For example, the IP address 72.47.244.140 is a web server on the Internet. To find out the hostname of this server using ping command, type the following in the command window then press Enter: ping -a 72.47.244.140
In the example illustration shown below, the hostname for the web server with IP address of 72.47.244.140 is agaaacgeks.gs11.gridserver.com.
Just like ping <URL> described previously, you can look up the IP address of a website or a domain with the ping utility. For example, to find the IP address to the domain mediatemple.net, type the following in the command window then press Enter: ping mediatemple.net
As the screenshot below shows, the IP for the domain mediatemple.net is 143.204.142.118.
To continuously ping a device, use the -t
switch. This will indefinitely ping the remote device until you explicitly stop it. The most common reason for using this switch is to have a real-time visible indicator to identify was a device comes online or offline. This would typically be in scenarios where administrator are troubleshooting or configuring a system. By continously pinging the device and looking at the response, one can know when it come online or offline.
To continuously ping, as an example, the IP address of 192.168.1.1, type the following in the command window then press Enter: ping -t 192.168.1.1
You can also specify an website URL to continuously ping as well. To stop the continuous ping, press CTRL+C.
The 127.0.0.1 is a special IP address, called a loopback address. It is a virtual IP address, in that it cannot be assigned to a device. This IP address is always interrupted to be 'yourself'. Meaning, if you ping this IP from your computer, you are pinging your own computer. If you are on a file server and you ping this loopback address from that device, you are pinging that file server.
This loopback address is used to test the device TCP/IP network stack (e.g., network software/driver) of the computer. If you are experience network connectivity issue on a computer, you would first perform ping 127.0.0.1
from that computer first. If ping responses with packet lost, then your connectivity issue is likely on that computer. You will need to resolve this first before exploring other causes. If the loopback ping reports no packet lost, then your connectivity issue is not stemming from your computer and you can then explore other causes upstream.
The example usage described in the article shows only some of the functions available with ping. To get a list of the available switches, type the following in the command window then press Enter: ping /?
-i
switch and specifying a value. For example, to specify a TTL of 200 (the maximum value allows is 255) when pinging 8.8.8.8, type the following in the command window then press Enter: ping -i 200 8.8.8.8
The following is an example of a good ping result. It shows all four test packets were sent successfully to the remote host. The four response packets sent from the remote host is received successfully by the local device (as indicated by 0% loss). Additionally, the round trip time are not excessively long.
Reply from 192.168.1.1: bytes=32 time<1ms TTL=64
Reply from 192.168.1.1: bytes=32 time<1ms TTL=64
Reply from 192.168.1.1: bytes=32 time<1ms TTL=64
Reply from 192.168.1.1: bytes=32 time<1ms TTL=64
Ping statistics for 192.168.1.1:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 63ms, Maximum = 63ms, Average = 63ms
The following is an example ping result showing a that four test packets were sent to the remote device but none were responded to. This can mean one of the following likely scenarios:
Pinging 192.168.1.222 with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Ping statistics for 192.168.1.222:
Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
The following is an example ping result showing a problem reaching the remote device. Four test packets were sent and no where received back from the remote host. A ping result like this can meaning one of the following:
Pinging 192.168.1.222 with 32 bytes of data:
Destination host unreachable.
Destination host unreachable.
Destination host unreachable.
Destination host unreachable.
Ping statistics for 192.168.1.222:
Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
ping 192.168.1.1 > c:\temp\ping-results.txt
The Windows ping utility does not come with a built-in function report the date and time in its results. However, with a bit of scripting, we can display the date and time next to each ping responses. The following script was developed from referencing various posts on StackOverflow. This example pings the website www.meridianoutpost.com. To see this script in action, type the following in the command window then press Enter:
ping meridianoutpost.com | cmd /q /v /c "(pause&pause)>nul & for /l %a in () do (set /p "data=" && echo(!date! !time! !data!) & ping -n 2 meridianoutpost.com > nul"
You will need to press CTRL+C to bring back the prompt. As illustrated below, this command displays the date and time next to each ping response.
Ping accurately measures the network connection between two devices at the time the test was run. However, because network conditions change continously, you should perform a new ping test every time you are trouleshooting your network. Test results from yesterday or even the last hour may be irrelevant. Additionaly, ping result from one target server can vary greatly from the result of another. Depending on what is it you are troubleshooting, you may need to ping several remote servers to better understand the problem.
An investment in knowledge always pays the best interest.
Simply knowing a device is reachable with a ping does not necessarily mean that the device is fully operating correctly. Being able to ping a web server, for example, only mean the network subsystem is working correctly. However, it does not mean that the Internet Information Services (IIS) on a Windows web server or Apache on a Linux web server application is functioning normal to deliver web page content.
The ping utility is a useful tool for troubleshooting basic network issues. As a helpdesk technician, network administrator, or system administrator, this will undoubtedly be used in conjunction with other advanced tools to effective trouble network issues.
Back to Top