Understanding the Ping and Traceroute Commands_掘图志

当前位置: 主页 > 路由器设置 >

Understanding the Ping and Traceroute Commands

时间:2016-12-28 05:54点击:



This document illustrates the use of the ping and traceroute commands. With the aid of some debug commands, this document captures a more detailed view of how these commands work.

Note: Enabling any debug commands on a production router may cause serious problems. We recommend that you carefully read the section before you issue debug commands.

Prerequisites Requirements

There are no specific requirements for this document.

Components Used

This document is not restricted to specific software and hardware versions.

The information in this document was created from the devices in a specific lab environment. All of the devices used in this document started with a cleared (default) configuration. If your network is live, make sure that you understand the potential impact of any command.


For more information on document conventions, refer to the Cisco Technical Tips Conventions.

Background Information

In this document, we use the basic configuration shown below as a basis for our examples:


The Ping Command

The ping command is a very common method for troubleshooting the accessibility of devices. It uses a series of Internet Control Message Protocol (ICMP) Echo messages to determine:

Whether a remote host is active or inactive.

The round-trip delay in communicating with the host.

Packet loss.

The ping command first sends an echo request packet to an address, then waits for a reply. The ping is successful only if:

the echo request gets to the destination, and

the destination is able to get an echo reply back to the source within a predetermined time called a timeout. The default value of this timeout is two seconds on Cisco routers.

For all the options about this command, see "Ping" under Troubleshooting Commands.

The TTL value of a ping packet cannot be changed.

Here is an output example showing the ping command after enabling the debug ip packet detail command:


Warning: Using the debug ip packet detail command on a production router can cause high CPU utilization. This may result in a severe performance degradation or a network outage. We recommend that you carefully read before issuing debug commands.

Router1#debug ip packet detail IP packet debugging is on (detailed) Router1#ping Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 4/6/8 ms Router1# Jan 20 15:54:47.487: IP: s= (local), d= (Serial0), len 100, sending Jan 20 15:54:47.491: ICMP type=8, code=0 !--- This is the ICMP packet sent to !--- ICMP type=8 corresponds to the echo message. Jan 20 15:54:47.523: IP: s= (Serial0), d= (Serial0), len 100, rcvd 3 Jan 20 15:54:47.527: ICMP type=0, code=0 !--- This is the answer we get from !--- ICMP type=0 corresponds to the echo reply message. !--- By default, the repeat count is five times, so there will be five !--- echo requests, and five echo replies.

The table below lists possible ICMP-type values.

ICMP Type Literal

0 echo-reply

3 destination unreachable code 0 = net unreachable 1 = host unreachable 2 = protocol unreachable 3 = port unreachable 4 = fragmentation needed and DF set 5 = source route failed

4 source-quench

5 redirect code 0 = redirect datagrams for the network 1 = redirect datagrams for the host 2 = redirect datagrams for the type of service and network 3 = redirect datagrams for the type of service and host

6 alternate-address

8 echo

9 router-advertisement

10 router-solicitation

11 time-exceeded code 0 = time to live exceeded in transit 1 = fragment reassembly time exceeded

12 parameter-problem

13 timestamp-request

14 timestamp-reply

15 information-request

16 information-reply

17 mask-request

18 mask-reply

31 conversion-error

32 mobile-redirect

The table below lists the possible output characters from the ping facility:

Character Description

! Each exclamation point indicates receipt of a reply.

. Each period indicates the network server timed out while waiting for a reply.

U A destination unreachable error PDU was received.

Q Source quench (destination too busy).

M Could not fragment.

? Unknown packet type.

& Packet lifetime exceeded.

Why Can't I Ping?

If you are not able to successfully ping to an address, consider these causes:

Routing Issue

Here are examples of unsuccessful ping attempts, determining the problem, and what to do to resolve the problem.

This scenario is explained using the network topology diagram below: