10.2.ping command

  • You can use it to check IP connectivity between two network devices.

  • Multiple platforms (for example, routers, switches, and hosts) support the ping command.

  • The ping command uses Internet Control Message Protocol (ICMP), which is a Layer 4 protocol.

  • The syntax of the ping command:

ping [ -t ] [-n count ] [ -l size ] [ -f ] [ -i TTL ] [ -S srcaddr ] target_name

Parameters for the Windows ping Command

Parameter

Purpose

-t

This option repeatedly sends pings (ICMP echo messages) until you stop it by pressing Ctrl+C.

-n count

This option specifies the number of pings to send.

-f

This option sets the don’t fragment bit in a packet’s header. 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 TTL

This option sets the TTL value in a packet’s header. The TTL is decremented for each router hop. A packet is discarded when its TTL value reaches 0.

-S srcaddr

If the PC from which you are issuing the ping command has more than one IP address, this option allows you to specify the source IP address from which the ICMP echo messages should be sent.

target_name

This option specifies the name or the IP address of the device to which you are sending ICMP echo messages.

Sample Output from the Windows ping Command

Example 1:

If you issue a ping command from your PC, your PC sends an ICMP echo message to the specified destination host. Assuming the destination host is reachable, the host responds with an ICMP echo reply message.

C:\> ping 192.168.1.2
Pinging 192.168.1.2 with 32 bytes of data:
Reply from 192.168.1.2: bytes=32 time=2ms TTL=64
Reply from 192.168.1.2: bytes=32 time=1ms TTL=64
Reply from 192.168.1.2: bytes=32 time=1ms TTL=64
Reply from 192.168.1.2: bytes=32 time=1ms TTL=64
Ping statistics for 192.168.1.2:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss) ,
Approximate round trip times in milli-seconds:
Minimum = 1ms, Maximum = 2ms, Average = 1ms

Example 2:

Other ICMP messages can be returned to your PC, from your PC’s default gateway, to indicate that a destination host is unreachable, that an ICMP echo timed out, or that a Time To Live (TTL) value (which is decremented by 1 at each router hop) has expired (decremented to a value of 0).

C:\> ping 192.168.1.200
Pinging 192.168.1.200 with 32 bytes of data:
Reply from 192.168.1.50: Destination host unreachable .
Reply from 192.168.1.50: Destination host unreachable.
Reply from 192.168.1.50: Destination host unreachable.
Reply from 192.168.1.50: Destination host unreachable.
Ping statistics for 192.168.1.200:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),

Last updated

Was this helpful?