How to Use the Ping Command in Windows to Test the Network Connectivity

The-Ping-Command-Ofbit.in

The Ping Command, is one of the most commonly used Command Line Commands by any Network Administrator to test the Network Connectivity. In this tutorial, we will learn How to use the Ping Command in Windows to Test the Network Connectivity.

The Ping Command is used to check the Network Connectivity between any two Network Nodes or Devices. Ping Command supports multiple platforms to test the network connectivity, i.e. Network Systems, Routers, Switches etc. You can use Ping Command to Ping Computers on Network, Ping Network Printers, Ping Servers, etc.

What is Ping Command


Ping, stands for Packet Internet Groper, the most used TCP/IP Troubleshooting Utility. The Ping command is used to test Layer 3 connectivity. Ping uses ICMP Echo Request Messages to initiate the test Device connectivity to another device. If the destination is active and reachable, the destination device responds with an ICMP Echo Reply Message.

Usually, the Ping command is the first step to any troubleshooting if a connectivity or service problem occurs between two Network Nodes/Devices.

ICMP – Which Layer Protocol


The Ping Command uses Internet Control Message Protocol (ICMP) at the Internet Layer of TCP/IP. Whereas in the OSI Model, the Ping command uses ICMP at Layer 3 or the Network Layer.

In short, ICMP is the Internet Layer Protocol of TCP/IP, and Layer 3 or the Network Layer of the OSI Model.

How Ping Works


Ping uses Internet Control Message Protocol to initiate the connection test to the remote devices by sending Echo Request Packets and listening for Echo Reply Packets.

The source sends an ICMP Echo Request Packet and waits for a response.

If the remote device is reachable, it replies with ICMP Echo Reply Packets.

If the remote device is not reachable, the Host device will get a reply from the default gateway. That indicates a destination device is unreachable, an ICMP Echo Request Timed Out.

Purpose of Ping Command


Ping Utility is a Command line Utility that is included with most TCP/IP stacks for most platforms. The primary reason we use the Ping command is mainly to find if the remote Host is active and reachable.

Apart from this using Ping, we can resolve IP addresses to hostnames, by increasing the Echo request packet size we can test the response time, determine if Brandwidth is present between source and destination etc.

This can be done using available options with the ping command which is explained in the upcoming section.

Ping Command Syntax


Ping Command Syntax is structured as follows:

ping [options] Target

Mainly we use the Target Device IP address or Hostname (FQDN) in the Ping Command as follows:

Ping the Hostname

ping [options]  FQDN 
i.e. ping -t ofbit.in

Ping the IP Address

ping [options] IP Address 
i.e. ping -t 9.9.9.9

To perform a Ping, follow the below steps:

The best and simple method is to run the command prompt using the RUN box.

Step 1: To open Run Box Press Windows+R.

Step 2: Type CMD and press Enter.

This will open the command prompt in User mode. You can also run command prompt as administrator.

By default, Ping will send Four Echo Request Packets. The default Ping Test and response look something like this:

Ping Ofbit.in

To view all the Options available in the Windows command-line version of Ping, use the Ping Command with /? or -? switch. This command will also display a table with all the Options available and their functions.

Ping Command In Windows-Help

Ping Options with Functions


OptionFunction
-tPing the specified host until stopped.
To see statistics and continue – type Control-Break;
To stop – type Control-C.
-aResolve addresses to hostnames.
-n countA number of echo requests to send.
-l sizeSend buffer size.
-fSet the Don’t Fragment flag in the packet’s header (IPv4-only). If the
packet tries to cross a router that attempts to fragment the packet,
the packet is dropped, and an ICMP error message is returned.
-i TTLTime To Live. This option sets the TTL value in a packet’s header. The TTL value
is decremented for each router hop. A packet is discarded when its
TTL value reaches 0.
-v TOSType Of Service (IPv4-only. This setting has been deprecated
and has no effect on the type of service field in the IP
Header).
-r countRecord route for count hops (IPv4-only).
-s countTimestamp for count hops (IPv4-only).
-j host-listLoose source route along host list (IPv4-only).
-k host-listStrict source route along host list (IPv4-only).
-w timeoutTimeout in milliseconds to wait for each reply.
-RUse 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 srcaddrSource address to use.
If the PC from which you are issuing the ping command has multiple IP addresses, this option allows you to specify the source IP address from which the ICMP echo request messages should be sent.
-c compartmentRouting compartment identifier.
-pPing a Hyper-V Network Virtualization provider address.
-4Force using IPv4.
-6Force using IPv6.

You can use multiple options with a ping command. For example, at the same time, you can use the ‘-a‘ option to resolve the IP address to hostname, along with the ‘-t‘ option for Continuous Ping.

Ping Command In Windows ping -a -t Ofbit.in

Some of the most used and useful options that are used with the Ping Command:

Continuous Ping Command


To perform a Continuous Ping to the specified remote device until stopped, use the -t option with Ping as follows:

ping -t ofbit.in

To Stop Continuous Ping press Ctrl+C from the keyboard.

Ping -t -ofbit.in

Resolve IP addresses to hostnames


While checking the connectivity over a network, you can use the -a option to resolve the IP address to the hostname.

ping -a 9.9.9.9
The Ping Command Ping-a -ofbit.in

Setting the Number of Echo requests to send


By default, 4 Echo Requests are sent. But you can specify the number of echo packets to send to the remote device. To specify the number of echo packets to send, use ‘-n count of echo requests‘.

ping -n 10 ofbit.in
Setting the Number of Echo Requests Ping-n Ofbit.in

Setting the Echo Packet Size


By default, the Echo Packets are sent in 32-byte chunks. But you can specify the packet size to test the response time. Please note, the maximum echo packet size allowed is 65,500 bytes.

To specify the packet size, use ‘-l packet size‘.

ping -l 68 google.com
Setting the Echo Packet Size Ping-l Ofbit.in

How to Use the Ping Command to Troubleshoot Network Issues


Although the primary reason to use the Ping Command by any Network Administrator in his day-to-day troubleshooting is mainly to find if the Remote Host is active and reachable. But using the options available with the Ping Command, one can perform more advanced troubleshooting. Also, Ping is used to gathering information about the network configuration. In this section, we will understand the ping result to determine the problem.

First, determine if you can ping the loopback address, i.e. ping 127.0.0.1. If fails, then something is wrong with the NIC or with the TCP/IP stack installed on the device. Check if the Network Driver is up-to-date, or reinstall the Driver. If you get the same result, the issue is with your NIC. Your need to replace the device’s NIC.

Next, try to ping a locally configured IP and default Gateway. If fails, something is wrong with the Network configuration on the device. Check and confirm if the IP Address, Default Gateway, Subnet Mask, and DNS server are configured properly.

If you are unable to ping the Hostname, but you can ping the IP Address, it is most likely because of the problem with Name Resolution.

After ping the destination host, if the first echo request times out but the rest of the echo requests are successful, the first request probably timed out due to the source and the possibly intermediate device performing ARP Lookup.

While getting a ‘reply timed out’ message, try to increase the timeout value with the ‘-w‘ option. If the replies are returning from a destination host after increasing the timeout value, a bandwidth problem might be present.

If the Ping result displays intermixed echo replies and destination unreachable messages, this might be due to either a lot of traffic between the source and destination. Or a Physical Layer problem causing sent data corruption.

I hope in this tutorial, you have learnt about the Ping Command and its uses. Apart from Ping, there are others command line utility that every Network Administrator should know. For example hostname, ipconfig, nslookup, traceroute, arp, netstat, etc.

Follow us:


If you like our articles and tutorials, you can follow us on Facebook. Also, join our Official Facebook Group for QnA sessions and Discussions with the worldwide technical community.

Related posts

Leave a Comment