ping Command


ping Command

The ping (packet internet groper) command issued from a Windows command prompt is used for diagnostic purposes to verify host-to-host connectivity.

The ping command sends an ICMP echo-request datagram. The destination receives this datagram and replies with an ICMP echo-reply packet. The following displays the syntaxes that can be used with the ping command from a Windows 2000 workstation:

 C:\>  ping  Usage: ping [-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS]             [-r count] [-s count] [[-j host-list]  [-k host-list]]             [-w timeout] destination-list Options:     -t             Ping the specified host until stopped.                    To see statistics and continue - type Control-Break;                    To stop - type Control-C.     -a             Resolve addresses to hostnames.     -n count       Number of echo requests to send.     -l size        Send buffer size.     -f             Set Don't Fragment flag in packet.     -i TTL         Time To Live.     -v TOS         Type Of Service.     -r count       Record route for count hops.     -s count       Timestamp for count hops.     -j host-list   Loose source route along host-list.     -k host-list   Strict source route along host-list.     -w timeout     Timeout in milliseconds to wait for each reply. C:\> 

You can continuously send ICMP ECHO packets to a remote host using the -t syntax as shown below. You can stop the ping by pressing CTRL+C.

 C:\>  ping -t 207.212.78.107  Pinging 207.212.78.107 with 32 bytes of data: Reply from 207.212.78.107: bytes=32 time=30ms TTL=251 Reply from 207.212.78.107: bytes=32 time=20ms TTL=251 Reply from 207.212.78.107: bytes=32 time=50ms TTL=251 ^C C:\> 

In Chapter 4, "Troubleshooting TCP/IP," you learned about DNS. DNS maps an IP address to a host name or FQDN. These names are separated into zones and kept in what is called zone tables . A forward lookup zone searches by the host name or FQDN until it either finds an entry that matches or reaches the end of the zone table. When a user knows the IP address of a host and wants the associated name, the user can employ a reverse lookup ; a reverse lookup occurs when you use ping with the “a switch. This tells ping to display the host name along with the ICMP Echo Reply, like this:

 C:\>  ping -a 207.212.78.107  Pinging web1.digitalcrawlspaces.com [207.212.78.107] with 32 bytes of data: Reply from 207.212.78.107: bytes=32 time=20ms TTL=251 Reply from 207.212.78.107: bytes=32 time=20ms TTL=251 Reply from 207.212.78.107: bytes=32 time=20ms TTL=251 Ping statistics for 207.212.78.107:     Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds:     Minimum = 20ms, Maximum =  20ms, Average =  20ms C:\> 

The output above shows that the reply from the device was successful and that it took a total of 20ms for all three replies.

The -n syntax sends ICMP ECHO packets a specified number of times as shown below; in this example, the 5 specifies the number of ICMP ECHO packets. The default number of packets is 4.

 C:\>  ping -n 5 10.1.1.1  Pinging 10.1.1.1 with 32 bytes of data: Reply from 10.1.1.1: bytes=32 time<10ms TTL=30 Reply from 10.1.1.1: bytes=32 time<10ms TTL=30 Reply from 10.1.1.1: bytes=32 time<10ms TTL=30 Reply from 10.1.1.1: bytes=32 time<10ms TTL=30 Reply from 10.1.1.1: bytes=32 time<10ms TTL=30 Ping statistics for 10.1.1.1:     Packets: Sent = 5, Received = 5, Lost = 0 (0% loss), Approximate round trip times in milli-seconds:     Minimum = 0ms, Maximum =  0ms, Average =  0ms Persistent Routes:   None 

The -l syntax sends ICMP ECHO packets with data padded in the packet to a specific length consisting of a repeated string of the letters a through w . By padding the packet, you can increase the size of the sent packet, allowing you to increase or decrease the amount of bandwidth used. If you are trying to test the amount of bandwidth available on a higher end link, you could pad the ICMP ECHO packet, creating a larger packet size for each packet traversing the link you are testing. The ping sent below is set to a length of 128 bytes. The default packet length is 64 bytes, and the maximum is 8192 bytes.

 C:\>  ping -l 128 207.212.78.107  Pinging 207.212.78.107 with 128 bytes of data: Reply from 207.212.78.107: bytes=128 time=40ms TTL=251 Reply from 207.212.78.107: bytes=128 time=40ms TTL=251 Reply from 207.212.78.107: bytes=128 time=30ms TTL=251 Ping statistics for 207.212.78.107:     Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds:     Minimum = 30ms, Maximum =  40ms, Average =  35ms C:\> 
graphics/note_icon.gif

On an Ethernet network, specifying a length of more than 1,500 bytes causes the datagram to become fragmented . When that occurs, the data in the original packet is divided and sent in more than one packet.


Occasionally, gateways will fragment data along a route. Using the -f syntax sends a Do Not Fragment flag in the IP datagram packet, and ensures the ICMP ECHO-Request and ECHO-Reply datagrams are not fragmented. If you use the -l option and specify more than 1,500 bytes, the ICMP ECHO request will not be sent.

 C:\>  ping -f 207.212.78.107  Pinging 207.212.78.107 with 32 bytes of data: Reply from 207.212.78.107: bytes=32 time=30ms TTL=251 Reply from 207.212.78.107: bytes=32 time=21ms TTL=251 Reply from 207.212.78.107: bytes=32 time=30ms TTL=251 

The -i syntax can be used to specify a Time To Live (TTL) field in the IP datagram. The TTL value is the number of hops the ICMP ECHO packet can take before it expires . Values can range from 1 to 255. In the output below a TTL value is specified.

 C:\>  ping -i 5 207.212.78.107  Pinging 207.212.78.107 with 32 bytes of data: Reply from 207.212.78.107: bytes=32 time=31ms TTL=251 Reply from 207.212.78.107: bytes=32 time=20ms TTL=251 Reply from 207.212.78.107: bytes=32 time=20ms TTL=251 

When the number of hops to a destination device is greater than the allowed number of hops specified, the number of hops is illegal. This will cause you to receive an error such as the one below. Note that our host is three hops away and only one hop is specified.

 C:\>  ping -i 1 207.212.78.107  Pinging 207.212.78.107 with 32 bytes of data: Reply from 172.16.0.1: TTL expired in transit. Reply from 172.16.0.1: TTL expired in transit. Reply from 172.16.0.1: TTL expired in transit. 
graphics/note_icon.gif

The -v syntax is rarely used in Unix and stands for Verbose Mode. This command can be used to specify the value of the Type Of Service (TOS) field in an ICMP ECHO packet.


The -r syntax allows you to set the number of hosts along a route to display for an ICMP ECHO request and the ICMP ECHO reply packets. The number of hosts can be set between 1 and 9 and must be specified after the syntax is used. The output below sets the number of hosts to 3.

 C:>  ping r 3 207.212.78.107  Pinging 207.212.78.107 with 32 bytes of data: Reply from 207.212.78.107: bytes=32 time=40ms TTL=251     Route: 64.164.37.70 ->            64.171.152.66 ->            207.212.78.110 

The -s syntax specifies the timestamp for the number of hops specified by the value of count, with a maximum of 4. The output below specifies a count of 3.

 C:\>  ping -s 3 207.212.78.107  Pinging 207.212.78.107 with 32 bytes of data: Reply from 207.212.78.107: bytes=32 time=30ms TTL=251     Timestamp: 64.164.37.70 : 2225911648 ->                64.171.152.66 : 3097738496 ->                207.212.78.110 : 4101167234 Reply from 207.212.78.107: bytes=32 time=30ms TTL=251     Timestamp: 64.164.37.70 : 2225912648 ->                64.171.152.66 : 2577906944 ->                207.212.78.110 : 3598112898 Reply from 207.212.78.107: bytes=32 time=20ms TTL=251     Timestamp: 64.164.37.70 : 2225913648 ->                64.171.152.66 : 2209070336 ->                207.212.78.110 : 3229276290 Reply from 207.212.78.107: bytes=32 time=30ms TTL=251     Timestamp: 64.164.37.70 : 2225914648 ->                64.171.152.66 : 2024783104 ->                207.212.78.110 : 3044989058 Ping statistics for 207.212.78.107:     Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds:     Minimum = 20ms, Maximum =  30ms, Average =  27ms 

Using an illegal count will return an error as specified below.

 C:\>  ping -s 10 207.212.78.107  Bad value for option -s, valid range is from 1 to 4. C:\> 
graphics/note_icon.gif

The -j specifies loose source routing, where a list of hosts on the path are specified by host-list. The maximum number of hosts allowed by IP is 9. The -k specifies strict source routing. Consecutively displayed hosts cannot be separated by intermediate routers. The maximum number of hosts is 9. These two syntaxes are out of the scope of this exam so no output will be shown.


The -w syntax specifies a timeout interval in milliseconds as shown below. The timeout value is set to 30 milliseconds.

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


CCNP CIT Exam Cram 2 (642-831)
CCNP CIT Exam Cram 2 (Exam Cram 642-831)
ISBN: 0789730219
EAN: 2147483647
Year: 2003
Pages: 213
Authors: Sean Odom

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net