简介
Internet控制消息协议ICMP(Internet Control Message Protocol)是网络层的一个重要协议。ICMP协议用来在网络设备间传递各种差错和控制信息,并对于收集各种网络信息、诊断和排除各种网络故障等方面起着至关重要的作用。使用基于ICMP的应用时,需要对ICMP的工作原理非常熟悉。
ICMP用来传递差错、控制、查询等信息
ICMP重定向
ICMP差错检测
- ICMP Echo Request和ICMP Echo Reply分别用来查询和响应某些信息,进行差错检测
ICMP错误报告
- 当网络设备无法访问目标网络时,会自动发送ICMP目的不可达报文到发送端设备
ICMP数据包格式
- Type表示ICMP消息类型,Code表示同一消息类型中的不同信息
ICMP消息封装格式
ICMP消息头部格式
ICMP消息类型和编码类型
类型 | 编码 | 描述 |
---|---|---|
0 | 0 | Echo Reply |
3 | 0 | 网络不可达 |
3 | 1 | 主机不可达 |
3 | 2 | 协议不可达 |
3 | 3 | 端口不可达 |
5 | 0 | 重定向 |
8 | 0 | Echo Request |
更多见:报文格式大全.chm
ICMP应用-ping
<Huawei>ping ?
-a Select source IP address, the default is the IP address of the
output interface
-c Specify the number of echo requests to be sent, the default is
5
-d Specify the SO_DEBUG option on the socket being used
-f Set Don't Fragment flag in packet (IPv4-only)
-h Specify TTL value for echo requests to be sent, the default is
255
-i Select the interface sending packets
-m Time in milliseconds to wait for sending next packet, the
default is 500ms
-n Numeric output only. No attempt will be made to lookup host
addresses for symbolic names
-name Display the host name of the destination address
-p No more than 8 "pad" hexadecimal characters to fill out the
sent packet. For example -p f2 will fill the sent packet with
f and 2 repeatedly
-q Quiet output. Nothing is displayed except the summary lines at
startup time and when finished
-r Record route. Includes the RECORD_ROUTE option in the
ECHO_REQUEST packet and displays the route
-s Specify the number of data bytes to be sent, the default is
56bytes
-si Set the specified interface as the source interface of ping
---- More ----
ICMP应用-Tracert
<Huawei>tracert ?
-a Set source IP address, the default is the IP address of the
output interface
-f First time to live, the default is 1
-m Max time to live, the default is 30
-p Destination UDP port number, the default is 33434
-q Number of probe packet, the default is 3
-vpn-instance Specify VPN-Instance of MPLS VPN
-w Timeout in milliseconds to wait for each reply, the default is
5000ms
STRING<1-255> IP address or hostname of a remote system
ipv6 IPv6 Protocol
lsp LSP traceroute
vc PWE3 traceroute
<Huawei>tracert 30.0.0.2
Tracert to 30.0.0.2(30.0.0.2), max hops:30, packet length:40,
press CTRL_C to break
1 10.0.0.2 130 ms 50 ms 40 ms
2 20.0.0.2 80 ms 60 ms 80 ms
3 30.0.0.2 80 ms 60 ms 70 ms