分析IPv6报文头

Last Updated: 2023-04-21 10:09:00 Friday

-- TOC --

IPv6报文的整体结构:

|   IPv6 Header   | Extension Headers | PDU |
<-  IPv6 Header  ->
                  <-      Payload          ->
<-               IPv6 Packet               ->

Extension Header属于payload。

The IPv6 packet payload is the combination of the IPv6 extension headers and the upper-layer PDU. Normally, it can be up to 65,535 bytes long (Payload Length field is 16bit). IPv6 packets with payloads larger than 65,535 bytes in length, known as jumbograms, can also be sent.

IPv4报文头分析

IPv6报文头格式如下,IPv6 Header Format:

from RFC8200

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Version| Traffic Class |           Flow Label                  |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|         Payload Length        |  Next Header  |   Hop Limit   |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
+                                                               +
|                                                               |
+                         Source Address                        +
|                                                               |
+                                                               +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
+                                                               +
|                                                               |
+                      Destination Address                      +
|                                                               |
+                                                               +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Version,4-bit Internet Protocol version number = 6,0x0110。

Traffic Class,8-bit Traffic Class field

Like the Type of Service field in the IPv4 header, the first 6 bits of the Traffic Class field are the DSCP field as defined in RFC 2474 and the last 2 bits are used for ECN as defined in RFC 3168.

Flow Label,20-bit flow label, 这是个在IPv4报文头中没有对应的新字段。

The flow label is used for prioritized delivery, such as delivery needed by real-time data (voice and video). For default router handling, the Flow Label field is set to 0. To distinguish a given flow, an intermediate router can use the packet’s source address, destination address, and flow label. Therefore, there can be multiple flows between a source and destination, as distinguished by separate non-zero flow labels. The details of the use of the Flow Label field are described in RFC 3697.

Payload Length,16-bit unsigned integer. 所有非此header,都算payload,包括扩展header。

With 16 bits, an IPv6 payload of up to 65,535 bytes can be indicated. For payload lengths greater than 65,535 bytes, the Payload Length field is set to 0 and the Jumbo Payload option is used in the Hop-by-Hop Options extension header.

Next Header,8-bit selector. Identifies the type of header immediately following the IPv6 header. Uses the same values as the IPv4 Protocol field. 下一个header可能是个Extension Header,或者是一个PDU Header。在每一个Extension Header内,也有一个Next Header,指向下一个header,这样就形成了一个链。

Hop Limit,8-bit unsigned integer. Decremented by 1 by each node that forwards the packet. When forwarding, the packet is discarded if Hop Limit was zero when received or is decremented to zero. A node that is the destination of a packet should not discard a packet with Hop Limit equal to zero; it should process the packet normally. 减到0或收到0,直接丢弃,除非已经达到目的地址。

Source Address,128-bit address of the originator of the packet.

Destination Address,128-bit address of the intended recipient of the packet (possibly not the ultimate recipient, if a Routing header is present).

IPv6报文头,大小固定为40Bytes。(IPv6地址长度是IPv4地址长度的4倍,如果不考虑IPv4报文头中的Options,IPv6报文头的长度刚好是IPv4报文头长度的2倍)

本文链接:https://cs.pynote.net/net/ip/202303311/

-- EOF --

-- MORE --