IP报文格式大全

IP报文格式大全光盘,主要包含了数据传输过程中用到的各种协议的数据包格式、报文示例。通过IP报文格式大全光盘,能够对各个协议报文有直观的认识,增强对各个协议报文的理解。

IP报文格式大全光盘,主要包含了数据传输过程中用到的各种协议的数据包格式、报文示例。通过IP报文格式大全光盘,能够对各个协议报文有直观的认识,增强对各个协议报文的理解。

IP报文格式

IP报文格式

IP协议(Internet Protocol)是TCP/IP协议族中最核心的协议,提供不可靠的、无连接的、尽力而为的数据报传输服务。

报文格式

图3-80 IP头格式
    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
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |Version|  IHL  |Type of Service|          Total Length         |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |         Identification        |Flags|      Fragment Offset    |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |  Time to Live |    Protocol   |         Header Checksum       |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                       Source Address                          |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                    Destination Address                        |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                    Options                    |    Padding    |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
表3-6 IP头字段解释

字段

长度

含义

Version

4比特

  • 4:表示为IPv4;
  • 6:表示为IPv6。

IHL

4比特

首部长度,如果不带Option字段,则为20,最长为60,该值限制了记录路由选项。以4字节为一个单位。

Type of Service

8比特

服务类型。只有在有QoS差分服务要求时这个字段才起作用。

Total Length

16比特

总长度,整个IP数据报的长度,包括首部和数据之和,单位为字节,最长65535,总长度必须不超过最大传输单元MTU。

Identification

16比特

标识,主机每发一个报文,加1,分片重组时会用到该字段。

Flags

3比特

标志位:

图3-81 IP Flag字段格式
           0     1      2
        +-----+------+------+
        |  0  |  DF  |  MF  |
        +-----+------+------+
  • Bit 0: 保留位,必须为0。
  • Bit 1: DF(Don't Fragment),能否分片位,0表示可以分片,1表示不能分片。
  • Bit 2: MF(More Fragment),表示是否该报文为最后一片,0表示最后一片,1代表后面还有。

Fragment Offset

13比特

片偏移:分片重组时会用到该字段。表示较长的分组在分片后,某片在原分组中的相对位置。以8个字节为偏移单位。

Time to Live

8比特

生存时间:可经过的最多路由数,即数据包在网络中可通过的路由器数的最大值。

Protocol

8比特

协议:下一层协议。指出此数据包携带的数据使用何种协议,以便目的主机的IP层将数据部分上交给哪个进程处理。

常见值:

  • 0: 保留
  • 1: ICMP, Internet Control Message [RFC792]
  • 2: IGMP, Internet Group Management [RFC1112]
  • 3: GGP, Gateway-to-Gateway [RFC823]
  • 4: IP in IP (encapsulation) [RFC2003]
  • 6: TCP Transmission Control Protocol [RFC793]
  • 17: UDP User Datagram Protocol [RFC768]
  • 20: HMP Host Monitoring Protocol [RFC 869]
  • 27: RDP Reliable Data Protocol [ RFC908 ]
  • 46: RSVP (Reservation Protocol)
  • 47: GRE (General Routing Encapsulation)
  • 50: ESP Encap Security Payload [RFC2406]
  • 51: AH (Authentication Header) [RFC2402]
  • 54: NARP (NBMA Address Resolution Protocol) [RFC1735]
  • 58: IPv6-ICMP (ICMP for IPv6) [RFC1883]
  • 59: IPv6-NoNxt (No Next Header for IPv6) [RFC1883]
  • 60: IPv6-Opts (Destination Options for IPv6) [RFC1883]
  • 89: OSPF (OSPF Version 2) [RFC 1583]
  • 112: VRRP (Virtual Router Redundancy Protocol) [RFC3768]
  • 115: L2TP (Layer Two Tunneling Protocol)
  • 124: ISIS over IPv4
  • 126: CRTP (Combat Radio Transport Protocol)
  • 127: CRUDP (Combat Radio User Protocol)
  • 132: SCTP (Stream Control Transmission Protocol)
  • 136: UDPLite [RFC 3828]
  • 137: MPLS-in-IP [RFC 4023]

Header Checksum

16比特

首部检验和,只检验数据包的首部,不检验数据部分。这里不采用CRC检验码,而采用简单的计算方法。

Source Address

32比特

源IP地址。

Destination Address

32比特

目的IP地址。

Options

可变

选项字段,用来支持排错,测量以及安全等措施,内容丰富(请参见表3-7)。选项字段长度可变,从1字节到40字节不等,取决于所选项的功能。

Padding

可变

填充字段,全填0。

IP Header Options

表3-7 IP Header Options

CLASS

常规的选项类别,0为“控制”,2为“查错和措施”,1和3保留。

NUMBER

指明一个选项。

长度

指明整个选项的长度。

含义

0

0

1字节

Code为0代表了选项列表的结束,放在所有选项链表的后面,用来补字节对齐。

该选项无长度字段,占一个字节。

选项格式如下:

        +--------+
        |00000000|
        +--------+
          Type=0

0

1

1字节

表示无操作的选项。用在各种选项之间,占一个字节。用于填充4字节对齐。

选项格式如下:

        +--------+
        |00000001|
        +--------+
          Type=1

0

2

11字节

表示安全和处理限制的选项。

该选项提供一种主机可以发送安全、分隔、处理限制及TCC(关闭使用组)的参数功能。

选项格式如下:

          +--------+--------+---//---+---//---+---//---+---//---+
          |10000010|00001011|SSS  SSS|CCC  CCC|HHH  HHH|  TCC   |
          +--------+--------+---//---+---//---+---//---+---//---+
           Type=130 Length=11
  • Type=130(10000010):占1字节,code 的值此处设为130
  • length=11:占1字节,长度选项固定为11,表示该选项的长度为11字节
  • SSS:占2字节,表示安全域,下面列出了16种不同的安全标准,其中8个至今还没使用,预留将来使用,列表如下:

    00000000 00000000 - Unclassified

    11110001 00110101 - Confidential

    01111000 10011010 - EFTO

    10111100 01001101 - MMMM

    01011110 00100110 - PROG

    10101111 00010011 - Restricted

    11010111 10001000 - Secret

    01101011 11000101 - Top Secret

    00110101 11100010 - (Reserved for future use)

    10011010 11110001 - (Reserved for future use)

    01001101 01111000 - (Reserved for future use)

    00100100 10111101 - (Reserved for future use)

    00010011 01011110 - (Reserved for future use)

    10001001 10101111 - (Reserved for future use)

    11000100 11010110 - (Reserved for future use)

    11100010 01101011 - (Reserved for future use)

  • CCC:占2个字节,表示分隔域,当传输的数据没被分隔的时候,此值设为0。
  • HHH:占2个字节,操作限制域。
  • TCC:占3个字节,传输控制码。提供一种传输隔离的手段,该值为3字母词,可用值从HQ DCA Code 530。

0

3

可变

松散的源站选路(为数据报指定一系列必须经过的IP地址)

选项格式如下:

        +--------+--------+--------+---------//--------+
        |10000011| length | pointer|     route data    |
        +--------+--------+--------+---------//--------+
         Type=131
  • Type: 类型。占1字节,此处设为131。
  • length: 占1字节,记录整个选项的长度。
  • pointer: 指针项,占1个字节,指向下一个被处理的源站地址,最小值为4。
  • route data: 路由数据。

0

7

可变

记录路径(让每个路由器都记下它的IP地址)。

选项格式如下:

        +--------+--------+--------+---------//--------+
        |00000111| length | pointer|     route data    |
        +--------+--------+--------+---------//--------+
          Type=7
  • Type: 指明IP选项的类型。此处值为7。
  • length: 选项的总字节长度。不包含填充的长度,IP填满时最大为39;。
  • pointer: 它是一个基于1的指针,指向存放下一个IP地址的位置。它的最小值为4,指向存放第一个IP地址的位置。随着每个IP地址存入清单,ptr的值分别为8,12,16,最大到36,当记录下9个IP地址后,ptr的值为40,表示清单已满。
  • route data: 路由数据。

0

8

4字节

流标识选项。该选项长度固定为4字节,code值为136,后面的字段固定为0x02,流ID为2字节。该选项提供了一种携带SATNET流标识符通过不支持流方式的网络。

选项格式如下:

        +--------+--------+--------+--------+
        |10001000|00000010|    Stream ID    |
        +--------+--------+--------+--------+
         Type=136 Length=4

0

9

可变

严格的源站选路选项。与宽松的源站选路类似,但是要求只能经过指定的这些地址,不能经过其他的地址。

选项格式如下:

        +--------+--------+--------+---------//--------+
        |10001001| length | pointer|     route data    |
        +--------+--------+--------+---------//--------+
         Type=137
  • Type=137(10001001):占1字节,code 的值此处设为137。
  • length:占1字节,记录整个选项的长度。
  • pointer:指针项,占1个字节,指向下一个被处理的源站地址,最小值为4。

2

4

可变

时间戳选项。

选项格式如下:

        +--------+--------+--------+--------+
        |01000100| length | pointer|oflw|flg|
        +--------+--------+--------+--------+
        |         internet address          |
        +--------+--------+--------+--------+
        |             timestamp             |
        +--------+--------+--------+--------+
        |                 .                 |
                          .
                          .
        Type = 68
  • Type (01000100):时间戳选项,代码为68;
  • length:选项的总长度(一般为36或40);
  • ponter:指向下一个可用空间的指针(5,9,13等);
  • oflw:表示溢出字段;
  • flg:表示标志字段:
    • 0:只记录时间戳。
    • 1:每台路由器都记录它的IP地址和时间戳。在选项列表中只有存放4对地址和时间戳的空间。
    • 3:发送端对选项列表进行初始化,存放了4个IP地址和4个取值为0的时间戳值。只有当列表中的下一个IP地址与当前路由器地址相匹配时,才记录它的时间戳。

报文示例

图3-82 IP报文
Frame 1: 94 bytes on wire (752 bits), 94 bytes captured (752 bits)
    Encapsulation type: Ethernet (1)
    Arrival Time: Jan 27, 2010 00:54:37.128187000
    [Time shift for this packet: 0.000000000 seconds]
    Epoch Time: 1264524877.128187000 seconds
    [Time delta from previous captured frame: 0.000000000 seconds]
    [Time delta from previous displayed frame: 0.000000000 seconds]
    [Time since reference or first frame: 0.000000000 seconds]
    Frame Number: 1
    Frame Length: 94 bytes (752 bits)
    Capture Length: 94 bytes (752 bits)
    [Frame is marked: False]
    [Frame is ignored: False]
    [Protocols in frame: eth:ethertype:ip:udp:gtp:ip:tcp]
    [Coloring Rule Name: TCP]
    [Coloring Rule String: tcp]
Ethernet II, Src: 00:18:82:c6:59:6a (00:18:82:c6:59:6a), Dst: 00:18:82:c6:57:df (00:18:82:c6:57:df)
    Destination: 00:18:82:c6:57:df (00:18:82:c6:57:df)
        Address: 00:18:82:c6:57:df (00:18:82:c6:57:df)
        .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
        .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
    Source: 00:18:82:c6:59:6a (00:18:82:c6:59:6a)
        Address: 00:18:82:c6:59:6a (00:18:82:c6:59:6a)
        .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
        .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
    Type: IP (0x0800)
Internet Protocol Version 4, Src: 10.206.184.1 (10.206.184.1), Dst: 10.206.130.115 (10.206.130.115)
    Version: 4
    Header Length: 20 bytes
    Differentiated Services Field: 0x48 (DSCP 0x12: Assured Forwarding 21; ECN: 0x00: Not-ECT (Not ECN-Capable Transport))
        0100 10.. = Differentiated Services Codepoint: Assured Forwarding 21 (0x12)
        .... ..00 = Explicit Congestion Notification: Not-ECT (Not ECN-Capable Transport) (0x00)
    Total Length: 80
    Identification: 0x1eec (7916)
    Flags: 0x00
        0... .... = Reserved bit: Not set
        .0.. .... = Don't fragment: Not set
        ..0. .... = More fragments: Not set
    Fragment offset: 0
    Time to live: 64
    Protocol: UDP (17)
    Header checksum: 0x6757 [validation disabled]
        [Good: False]
        [Bad: False]
    Source: 10.206.184.1 (10.206.184.1)
    Destination: 10.206.130.115 (10.206.130.115)
    [Source GeoIP: Unknown]
    [Destination GeoIP: Unknown]
User Datagram Protocol, Src Port: gtp-user (2152), Dst Port: gtp-user (2152)
    Source Port: gtp-user (2152)
    Destination Port: gtp-user (2152)
    Length: 60
    Checksum: 0x0000 (none)
        [Good Checksum: False]
        [Bad Checksum: False]
    [Stream index: 0]
GPRS Tunneling Protocol
    Flags: 0x32
        001. .... = Version: GTP release 99 version (1)
        ...1 .... = Protocol type: GTP (1)
        .... 0... = Reserved: 0
        .... .0.. = Is Next Extension Header present?: No
        .... ..1. = Is Sequence Number present?: Yes
        .... ...0 = Is N-PDU number present?: No
    Message Type: T-PDU (0xff)
    Length: 44
    TEID: 0x19086922
    Sequence number: 0x3cd9
T-PDU Data 40 bytes
Internet Protocol Version 4, Src: 10.96.106.89 (10.96.106.89), Dst: 10.137.190.243 (10.137.190.243)
    Version: 4
    Header Length: 20 bytes
    Differentiated Services Field: 0x00 (DSCP 0x00: Default; ECN: 0x00: Not-ECT (Not ECN-Capable Transport))
        0000 00.. = Differentiated Services Codepoint: Default (0x00)
        .... ..00 = Explicit Congestion Notification: Not-ECT (Not ECN-Capable Transport) (0x00)
    Total Length: 40
    Identification: 0x8764 (34660)
    Flags: 0x02 (Don't Fragment)
        0... .... = Reserved bit: Not set
        .1.. .... = Don't fragment: Set
        ..0. .... = More fragments: Not set
    Fragment offset: 0
    Time to live: 128
    Protocol: TCP (6)
    Header checksum: 0x9c35 [validation disabled]
        [Good: False]
        [Bad: False]
    Source: 10.96.106.89 (10.96.106.89)
    Destination: 10.137.190.243 (10.137.190.243)
    [Source GeoIP: Unknown]
    [Destination GeoIP: Unknown]
Transmission Control Protocol, Src Port: 10370 (10370), Dst Port: mstmg-sstp (6601), Seq: 1, Ack: 1, Len: 0
    Source Port: 10370 (10370)
    Destination Port: mstmg-sstp (6601)
    [Stream index: 0]
    [TCP Segment Len: 0]
    Sequence number: 1    (relative sequence number)
    Acknowledgment number: 1    (relative ack number)
    Header Length: 20 bytes
    .... 0000 0001 0000 = Flags: 0x010 (ACK)
        000. .... .... = Reserved: Not set
        ...0 .... .... = Nonce: Not set
        .... 0... .... = Congestion Window Reduced (CWR): Not set
        .... .0.. .... = ECN-Echo: Not set
        .... ..0. .... = Urgent: Not set
        .... ...1 .... = Acknowledgment: Set
        .... .... 0... = Push: Not set
        .... .... .0.. = Reset: Not set
        .... .... ..0. = Syn: Not set
        .... .... ...0 = Fin: Not set
    Window size value: 17520
    [Calculated window size: 17520]
    [Window size scaling factor: -1 (unknown)]
    Checksum: 0xcf19 [validation disabled]
        [Good Checksum: False]
        [Bad Checksum: False]
    Urgent pointer: 0

参考标准

标准

描述

RFC 791

INTERNET PROTOCOL

(Updated by: 1349, 2474, 6864 )

协议栈结构

                 +------+ +-----+ +-----+     +-----+
                 |Telnet| | FTP | | TFTP| ... | ... |
                 +------+ +-----+ +-----+     +-----+
                       |   |         |           |
                      +-----+     +-----+     +-----+
                      | TCP |     | UDP | ... | ... |
                      +-----+     +-----+     +-----+
                         |           |           |
                      +--------------------------+----+
                      |    Internet Protocol & ICMP   |
                      +--------------------------+----+
                                     |
                        +---------------------------+
                        |   Local Network Protocol  |
                        +---------------------------+
翻译
收藏
下载文档
更新时间:2025-08-12
文档编号:EDOC1100174722
浏览量:494366
下载量:15377
平均得分:4.22