admin管理员组文章数量:1641842
一. ICMP协议设计的目的
由于IP协议并没有设计为绝对可靠,类似ICMP协议的控制协议,通过一些错误类型和错误码,可以反馈通讯过程中的一些问题,帮助网络工程人员更好的定位问题。
ICMP协议虽然可以反馈网络问题,但是并不能使网络通讯变得可靠,这需要更上层的协议来保证网络的可靠性。
二. ICMP数据报的格式
ICMP数据报使用的是基本的IP头部,ICMP的协议号是1。
IPv4数据抓包:
ICMP数据抓包:
ICMP数据报文格式如下:
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Code | Checksum | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | unused | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Internet Header + 64 bits of Original Data Datagram | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
三. ICMP报文类型(Type)和对应的编码(Code)
ICMP types
ICMP Type | Message |
---|---|
0 | Echo reply |
3 | Destination unreachable |
4 | Source quench |
5 | Redirect |
8 | Echo request |
9 | Router advertisement |
10 | Router selection |
11 | Time exceeded |
12 | Parameter problem |
13 | Timestamp |
14 | Timestamp reply |
15 | Information request |
16 | Information reply |
17 | Address mask request |
18 | Address mask reply |
30 | Traceroute |
ICMP Type 3: Destination Unreachable Codes
Destination Unreachable Code | Description |
---|---|
0 | Net is unreachable |
1 | Host is unreachable |
2 | Protocol is unreachable |
3 | Port is unreachable |
4 | Fragmentation is needed and Don't Fragment was set |
5 | Source route failed |
6 | Destination network is unknown |
7 | Destination host is unknown |
8 | Source host is isolated |
9 | Communication with destination network is administratively prohibited |
10 | Communication with destination host is administratively prohibited |
11 | Destination network is unreachable for type of service |
12 | Destination host is unreachable for type of service |
13 | Communication is administratively prohibited |
14 | Host precedence violation |
15 | Precedence cutoff is in effect |
ICMP Type 5: Redirect Codes
Redirect Code | Description |
---|---|
0 | Redirect datagram for the network (or subnet) |
1 | Redirect datagram for the host |
2 | Redirect datagram for the type of service and network |
3 | Redirect datagram for the type of service and host |
ICMP Type 11: Time Exceeded Codes
Time Exceeded Code | Description |
---|---|
0 | Time to Live exceeded in transit |
1 | Fragment reassembly time exceeded |
ICMP Type 12: Parameter Problem Codes
Parameter Problem Code | Description |
---|---|
0 | Pointer indicates the error |
1 | Missing a required option |
2 | Bad length |
四. ICMP type和code的常用的组合
TYPE | CODE | Description | Query | Error | Reference |
---|---|---|---|---|---|
0 | 0 | Echo Reply | x | RFC792 | |
3 | 0 | Network Unreachable | x | RFC792 | |
3 | 1 | Host Unreachable | x | RFC792 | |
3 | 2 | Protocol Unreachable | x | RFC792 | |
3 | 3 | Port Unreachable | x | RFC792 | |
3 | 4 | Fragmentation needed but no frag. bit set | x | RFC792 | |
3 | 5 | Source routing failed | x | RFC792 | |
3 | 6 | Destination network unknown | x | RFC792 | |
3 | 7 | Destination host unknown | x | RFC792 | |
3 | 8 | Source host isolated (obsolete) | x | RFC792 | |
3 | 9 | Destination network administratively prohibited | x | RFC792 | |
3 | 10 | Destination host administratively prohibited | x | RFC792 | |
3 | 11 | Network unreachable for TOS | x | RFC792 | |
3 | 12 | Host unreachable for TOS | x | RFC792 | |
3 | 13 | Communication administratively prohibited by filtering | x | RFC1812 | |
3 | 14 | Host precedence violation | x | RFC1812 | |
3 | 15 | Precedence cutoff in effect | x | RFC1812 | |
4 | 0 | Source quench | RFC792 | ||
5 | 0 | Redirect for network | RFC792 | ||
5 | 1 | Redirect for host | |||
5 | 2 | Redirect for TOS and network | RFC792 | ||
5 | 3 | Redirect for TOS and host | RFC792 | ||
8 | 0 | Echo request | x | RFC792 | |
9 | 0 | Router advertisement - Normal router advertisement | RFC1256 | ||
9 | 16 | Router advertisement - Does not route common traffic | RFC2002 | ||
10 | 0 | Route selection | RFC1256 | ||
11 | 0 | TTL equals 0 during transit | x | RFC792 | |
11 | 1 | TTL equals 0 during reassembly | x | RFC792 | |
12 | 0 | IP header bad (catchall error) | x | RFC792 | |
12 | 1 | Required options missing | x | RFC1108 | |
12 | 2 | IP Header bad length | x | RFC792 | |
13 | 0 | Timestamp request (obsolete) | x | RFC792 | |
14 | Timestamp reply (obsolete) | x | RFC792 | ||
15 | 0 | Information request (obsolete) | x | RFC792 | |
16 | 0 | Information reply (obsolete) | x | RFC792 | |
17 | 0 | Address mask request | x | RFC950 | |
18 | 0 | Address mask reply | x | RFC950 | |
20-29 | Reserved for robustness experiment | Zaw-Sing Su | |||
30 | 0 | Traceroute | x | RFC1393 | |
31 | 0 | Datagram Conversion Error | x | RFC1475 | |
32 | 0 | Mobile Host Redirect | David Johnson | ||
33 | 0 | IPv6 Where-Are-You | x | Bill Simpson | |
34 | 0 | IPv6 I-Am-Here | x | Bill Simpson | |
35 | 0 | Mobile Registration Request | x | Bill Simpson | |
36 | 0 | Mobile Registration Reply | x | Bill Simpson | |
39 | 0 | SKIP | Tom Markson | ||
40 | 0 | Photuris | RFC2521 |
本文标签: internetICMPcontrolprotocolMessage
版权声明:本文标题:ICMP (Internet Control Message Protocol) 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/dianzi/1729328429a1196067.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论