Huawei S Series Campus Switches Troubleshooting Guide(V100 and V200)
Ping and Tracert
Introduction to the Ping Command
The Ping command implementation is based on the Internet Control Message Protocol (ICMP). The source sends an ICMP Echo Request message to the destination, and determines reachability of the destination. If the source receives an ICMP Echo Reply message from the destination within a specified period (before the timer expires), the destination is reachable. Otherwise, the destination is unreachable. The source determines the quality of the link to the reachable destination based on the number of ICMP Echo Request messages it sends and ICMP Echo Reply messages it receives, and determines the distance between the source and destination according to the round-trip time (RTT) of ping packets.
Ping Command Format
This document lists only some commonly used parameters and their descriptions. For details, see ping under Network Management and Monitoring Commands > Ping and Tracert Configuration Commands in the Command Reference of the corresponding version.
ping [ ip ] [ -a source-ip-address | -c count | -f | -s packetsize | -t timeout ] *host
- -a: specifies the source IP address for sending Echo Request messages. If no source IP address is specified, the IP address of the outbound interface is used as the source IP address.
- -c: specifies the count for sending Echo Request messages. The default value is 5. You can increase the number of outgoing packets to detect the network quality based on the packet loss ratio.
- -f: Packets are not fragmented when they are sent. The device discards the packets if the packet size exceeds the MTU.
- -s: specifies the length of an Echo Request message excluding the IP header and ICMP header. The default value is 56 bytes.
- -t: specifies the timeout interval of Echo Reply messages. You can set a larger timeout interval if the network is unstable. The default value is 2s. If the device receives no Echo Response message within 2s, it determines that the destination is unreachable.
- host: specifies an IP address or a domain name. If it is a domain name, the device performs DNS resolution and displays the resolved IP address.
You can use the parameters -s and -f simultaneously to test the path MTU (PMTU). For example, if the ping operation succeeds when the parameter -s is set to 1472 but fails when the parameter is set to 1473, then the PMTU is 1500, which is the total sum of 1472, 20 (IP header), and 8 (ICMP header).
The ping function varies with the operating system of a PC. The following uses the Windows operating system as an example to illustrate the ping function on a PC.
ping [ -n number ] [ -t ] [ -l number ] [ -f ] [ -a ] ip-address
- -n: specifies the number of ping packets. The default value is 5.
- -t: indicates that the source sends Echo Request messages to the destination continuously until manual operations are involved. You can press Ctrl + Break to temporarily stop the ping command and view the statistics, and press Ctrl + C to terminate the ping operation.
- -l: specifies the number of bytes in the data part of a ping packet. The value ranges from 0 to 65500.
- -f: indicates that packets are not fragmented when they are sent. The device discards the packets if the packet size exceeds the MTU.
- -a: indicates that the device resolves an IP address into a host name.
- ip-address: specifies the destination IP address for the ping command.
Description of the ping Command Output
<HUAWEI> ping 10.135.18.118 PING 10.135.18.118: 56 data bytes, press CTRL_C to break Reply from 10.135.18.118: bytes=56 Sequence=1 ttl=255 time=1 ms Reply from 10.135.18.118: bytes=56 Sequence=2 ttl=255 time=1 ms Reply from 10.135.18.118: bytes=56 Sequence=3 ttl=255 time=2 ms Reply from 10.135.18.118: bytes=56 Sequence=4 ttl=255 time=1 ms Reply from 10.135.18.118: bytes=56 Sequence=5 ttl=255 time=2 ms --- 10.135.18.118 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 1/1/2 ms
In this example:
- The device sends five ping packets and receives response to all the five packets.
- The ping packets use the default size, 56 bytes.
- ttl=255 indicates that the source is directly connected to the destination.
- time=1ms indicates that the device receives an Echo Reply message 1 ms after it sends an Echo Request message. This parameter can be used to determine whether the network is congested.
The device sends five ping packets by default. You can set a larger value for -c to accurately detect the network status. The device determines the network status based on the number of ping packets returned.
Symptom |
Possible Cause |
---|---|
All packets can reach the destination but take a long time. |
|
No packet can reach the destination. |
|
Some packets cannot reach the destination. |
|
Introduction to the Tracert Command
The ping command checks whether the destination host is reachable and the tracert command tracks the gateways that packets pass through from the source host to the destination host. This helps check network connectivity and locate network faults.
The tracert command implementation is based on the ICMP. As shown in Figure 6-13, the working process of tracert is as follows:
- The source host (SwitchA) sends a UDP packet, whose TTL value is 1 and destination UDP port number is larger than 30000, to the destination host (log host). In most cases, the UDP port whose number is larger than 30000 is not used by any program.
- Upon receiving the UDP packet, the first-hop host (SwitchB) determines that the destination IP address of the packet is not the local IP address and decreases the TTL value by one. The TTL value then becomes 0, so SwitchB discards the UDP packet, and sends an ICMP Time Exceeded message containing its local IP address 10.1.1.2 to SwitchA. SwitchA then obtains the IP address of SwitchB.
- Upon receiving the ICMP Time Exceeded message from SwitchB, SwitchA sends a UDP packet with the TTL value of 2.
- Upon receiving the UDP packet, the second-hop host (SwitchC) returns an ICMP Time Exceeded message containing its local IP address 10.1.2.2 to SwitchA.
- This process is repeated until the destination host determines that the destination IP address of the UDP packet is its local IP address and processes the packet. The destination host searches for the upper-layer protocol that uses the destination port number of the packet. No program uses this UDP port number, so the destination host returns an ICMP Destination Unreachable message containing its local IP address 10.1.3.2.
- Upon receiving the ICMP Destination Unreachable message, the source host determines that the UDP packet has reached the destination host, so it stops tracert and generates the path of the UDP packet 10.1.1.2 -> 10.1.2.2 -> 10.1.3.2.
Tracert Command Format
tracert [ -a source-ip-address | -f first-ttl | -m max-ttl | -p port | -q nqueries | -w timeout ] *host
- -a: specifies the source address. If this parameter is not specified, the IP address of the outbound interface is used as the source IP address of outgoing packets.
- -f: specifies the initial TTL. If the number of hops is smaller than the initial TTL, the source host receives no ICMP Time Exceeded packet, because the value of the TTL field is greater than 0. If a maximum TTL is set, the initial TTL must be smaller than the maximum TTL.
- -m: specifies the maximum TTL. The maximum TTL is usually set to the number of hops through which a Tracert packet passes. If an initial TTL is set, the maximum TTL must be larger than the initial TTL. By default, the maximum TTL value is 30.
- -p: specifies the UDP port number of the destination host.
- If no UDP port number is specified for the destination, when you run the tracert command, a port with the port number greater than 32768 is randomly chosen for the destination to receive tracert packets.
- Before specifying the UDP port number for the destination, ensure that the port is not in use; otherwise, the tracert fails.
- -q: specifies the number of UDP probe packets to be sent each time. You can increase this value to ensure that UDP probe packets can reach the destination host in case of low network quality. By default, three UDP probe packets are sent each time.
- -w: sets the timeout interval of a reply message. If a tracert packet times out when reaching a gateway, an asterisk (*) is displayed. You are advised to increase the timeout interval when the network is unstable and the transmission speed is low. The default timeout interval is 5000 ms.
- host: specifies an IP address or a domain name. If it is a domain name, the device performs DNS resolution and displays the resolved IP address.
The tracert function varies with the operating system of a PC. The following uses the Windows operating system as an example to illustrate the tracert function on a PC.
tracert [ -d ] [ -h maximum_hops ] [ -j host-list ] [ -w timeout ] host
- -d: indicates that the host name is not resolved.
- -h: specifies the maximum TTL.
- -j: specifies the loose source address routing list.
- -w: sets the timeout interval for UDP packets, in milliseconds.
- host: specifies the domain name or IP address of the destination host.
Description of the tracert Command Output
<HUAWEI> tracert 10.135.18.118 traceroute to 10.135.18.118(10.135.18.118), max hops: 30 ,packet length: 40,press CTRL_C to break 1 192.168.200.100 10 ms 2 ms 2 ms 2 * * * 3 10.135.18.118 10 ms 1 ms 2 ms
Information displayed in a line includes the number, IP address that the packet reaches, and three response time. Asterisks (* * *) are displayed in the second line, indicating that the ping and tracert operations are not supported on this node.
The ping command can only determine whether the destination is reachable, whereas the tracert command can detect potential loops on a network. If a same address is displayed multiple times after you run the tracert command, a route loop occurs.