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

0Net is unreachable
1Host is unreachable
2Protocol is unreachable
3Port is unreachable
4Fragmentation is needed and Don't Fragment was set
5Source route failed
6Destination network is unknown
7Destination host is unknown
8Source host is isolated
9Communication with destination network is administratively prohibited
10Communication with destination host is administratively prohibited
11Destination network is unreachable for type of service
12Destination host is unreachable for type of service
13Communication is administratively prohibited
14Host precedence violation
15Precedence cutoff is in effect

ICMP Type 5: Redirect Codes

Redirect Code

Description

0Redirect datagram for the network (or subnet)
1Redirect datagram for the host
2Redirect datagram for the type of service and network
3Redirect datagram for the type of service and host

ICMP Type 11: Time Exceeded Codes

Time Exceeded Code

Description

0Time to Live exceeded in transit
1Fragment reassembly time exceeded

ICMP Type 12: Parameter Problem Codes

Parameter Problem Code

Description

0Pointer indicates the error
1Missing a required option
2Bad length

四. ICMP type和code的常用的组合

TYPECODEDescriptionQueryErrorReference
00Echo ReplyxRFC792
30Network UnreachablexRFC792
31Host UnreachablexRFC792
32Protocol UnreachablexRFC792
33Port UnreachablexRFC792
34Fragmentation needed but no frag. bit setxRFC792
35Source routing failedxRFC792
36Destination network unknownxRFC792
37Destination host unknownxRFC792
38Source host isolated (obsolete)xRFC792
39Destination network administratively prohibitedxRFC792
310Destination host administratively prohibitedxRFC792
311Network unreachable for TOSxRFC792
312Host unreachable for TOSxRFC792
313Communication administratively prohibited by filteringxRFC1812
314Host precedence violationxRFC1812
315Precedence cutoff in effectxRFC1812
40Source quenchRFC792
50Redirect for networkRFC792
51Redirect for host
52Redirect for TOS and networkRFC792
53Redirect for TOS and hostRFC792
80Echo requestxRFC792
90Router advertisement - Normal router advertisementRFC1256
916Router advertisement - Does not route common trafficRFC2002
100Route selectionRFC1256
110TTL equals 0 during transitxRFC792
111TTL equals 0 during reassemblyxRFC792
120IP header bad (catchall error)xRFC792
121Required options missingxRFC1108
122IP Header bad lengthxRFC792
130Timestamp request (obsolete)xRFC792
14Timestamp reply (obsolete)xRFC792
150Information request (obsolete)xRFC792
160Information reply (obsolete)xRFC792
170Address mask requestxRFC950
180Address mask replyxRFC950
20-29Reserved for robustness experimentZaw-Sing Su
300TraceroutexRFC1393
310Datagram Conversion ErrorxRFC1475
320Mobile Host RedirectDavid Johnson
330IPv6 Where-Are-YouxBill Simpson
340IPv6 I-Am-HerexBill Simpson
350Mobile Registration RequestxBill Simpson
360Mobile Registration ReplyxBill Simpson
390SKIPTom Markson
400PhoturisRFC2521

本文标签: internetICMPcontrolprotocolMessage