Skip to main content

IPv6报文格式

IPv6(Internet Protocol Version 6)是网络层协议的第二代标准协议,也被称为IPng(IP Next Generation),它是Internet工程任务组(IETF)设计的一套规范,是IPv4 [RFC 791]的升级版本。

协议栈结构

IPv6协议栈结构
+------+ +-----+ +-----+     +-----+
|Telnet| | FTP | | TFTP| ... | ... |
+------+ +-----+ +-----+     +-----+
     |   |         |           |
    +-----+     +-----+     +-----+
    | TCP |     | UDP | ... | ... |
    +-----+     +-----+     +-----+
       |           |           |
   +-------------------------------+
   |         IPv6 & ICMPv6         |
   +-------------------------------+
   |       L2 Type = 0x86dd        |
   +-------------------------------+
   |             L1                |
   +-------------------------------+
IPv6报文头格式
 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| Traffic Class |           Flow Label                  |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|         Payload Length        |  Next Header  |   Hop Limit   |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+                     Source Address [128bits]                  +
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+                   Destination Address [128bits]               +
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                      Extension Headers                        |
+                         ... ...                               +
IPv6头字段解释
字段 长度 含义
Version 4比特 4:表示为IPv4;6:表示为IPv6。
Traffic class 8比特 流量类别。该字段及其功能类似于IPv4的业务类型字段。该字段以区分业务编码点(DSCP)标记一个IPv6数据包,以此指明数据包应当如何处理。
Flow Label 20比特 流标签。该字段用来标记IP数据包的一个流,当前的标准中没有定义如何管理和处理流标签的细节。
Payload length 16比特 该字段表示有效载荷的长度,有效载荷是指紧跟IPv6基本报头的数据包,包含IPv6扩展报头。
Next header 8比特 下一报头,该字段指明了跟随在IPv6基本报头后的扩展报头的信息类型。
Hop limit 8比特 跳数限制,该字段定义了IPv6数据包所能经过的最大跳数,这个字段和IPv4中的TTL字段非常相似。
Source Address 128比特 该字段表示该报文的源地址。
Destination Address 128比特 该字段表示该报文的目的地址。
Extension Headers 可变 扩展报头。

IPv6取消了IPv4报头中的选项字段,并引入了多种扩展报文头,在提高处理效率的同时还增强了IPv6的灵活性,为IP协议提供了良好的扩展能力。当超过一种扩展报头被用在同一个分组里时,报头必须按照IPv6扩展报头封装排列表所列顺序出现。

不是所有的扩展报头都需要被转发路由设备查看和处理的。路由设备转发时根据基本报头中 Next Header 值来决定是否要处理扩展头。除了目的选项扩展报头出现两次(一次在路由扩展报头之前,另一次在上层扩展报头之前),其余扩展报头只出现一次。

IPv6扩展报头封装排列表
Value 含义 说明
Null IPv6基本报头 *
0 逐跳选项扩展报头  
60 目的选项扩展报头 指那些将被分组报文的最终目的地处理的选项
43 路由扩展报头 用于源路由选项和Mobile IPv6
44 分片扩展报头 在源节点发送的报文超过Path MTU时对报文分片时使用
51 授权扩展报头 用于IPSec,提供报文验证、完整性检查。定义和IPv4中相同
50 封装安全有效载荷扩展报头 用于IPSec,提供报文验证、完整性检查和加密。定义和IPv4中相同
* Other 详细请参见IPv6扩展头协议号及其含义对应表
IPv6扩展头协议号及其含义对应表
扩展头协议号 含义 相关标准
0 IPv6 Hop-by-Hop Option RFC 8200
1 ICMP RFC 792
2 IGMP RFC 1112
3 GGP (Gateway-to-Gateway) RFC 823
4 IPv4 encapsulation RFC 2003
5 Stream RFC 1190, RFC 1819
6 TCP RFC 793
7 CBT -
8 EGP (Exterior Gateway Protocol) RFC 888
9 IGP -
10 BBN RCC Monitoring -
11 Network Voice Protocol RFC 741
12 PUP -
13 ARGUS (deprecated) -
14 EMCON -
15 XNET (Cross Net Debugger) -
16 CHAOS -
17 UDP RFC 768
18 MUX -
19 DCN-MEAS (DCN Measurement Subsystems) -
20 HMP (Host Monitoring) RFC 869
21 PRM (Packet Radio Measurement) -
22 XNS-IDP -
23 TRUNK-1 -
24 TRUNK-2 -
25 LEAF-1 -
26 LEAF-2 -
27 RDP (Reliable Data Protocol) RFC 908
28 IRTP (Internet Reliable Transaction) RFC 938
29 ISO-TP4 (ISO Transport Protocol Class 4) RFC 905
30 NETBLT (Bulk Data Transfer Protocol) RFC 969
31 MFE-NSP (MFE Network Services) -
32 MERIT-INP (MERIT Internodal Protocol) -
33 DCCP (Datagram Congestion Control Protocol) RFC 4340
34 3PC (Third Party Connect Protocol) -
35 IDPR (Inter-Domain Policy Routing Protocol) -
36 XTP -
37 DDP (Datagram Delivery Protocol) -
38 IDPR-CMTP (IDPR Control Message Transport Protocol) -
39 TP++ Transport Protocol -
40 IL Transport Protocol -
41 IPv6 encapsulation RFC 2473
42 SDRP (Source Demand Routing Protocol) -
43 Routing Header for IPv6 RFC 2460
44 Fragment Header for IPv6 RFC 2460
45 IDRP (Inter-Domain Routing Protocol) RFC 2205, RFC 3209
46 RSVP (Reservation Protocol) RFC 2205, RFC 3209
47 GRE (Generic Routing Encapsulation) RFC 2784
48 DSR (Dynamic Source Routing Protocol) RFC 4728
49 BNA -
50 ESP (Encap Security Payload) RFC4303
51 AH (Authentication Header) RFC4302
52 I-NLSP (Integrated Net Layer Security TUBA) -
53 SWIPE (deprecated) (IP with Encryption) -
54 NARP (NBMA Address Resolution Protocol) RFC 1735
55 IP Mobility Transport Layer Security -
56 TLSP (Protocol using Kryptonet key management) -
57 SKIP -
58 ICMP for IPv6 RFC 8200
59 No Next Header for IPv6 RFC 8200
60 Destination Options for IPv6 RFC 8200
61 Destination Options for IPv6 any host internal protocol RFC 8200
62 CFTP -
63 any local network -
64 SAT-EXPAK (SATNET and Backroom EXPAK) -
65 Kryptolan -
66 RVD (MIT Remote Virtual Disk Protocol) -
67 IPPC (Internet Pluribus Packet Core) -
68 any distributed file system -
69 SAT-MON (SATNET Monitoring) -
70 VISA (VISA Protocol) -
71 IPCV (Internet Packet Core Utility) -
72 CPNX (Computer Protocol Network Executive) -
73 CPHB (Computer Protocol Heart Beat) -
74 WSN (Wang Span Network) -
75 PVP (Packet Video Protocol) -
76 BR-SAT-MON (Backroom SATNET Monitoring) -
77 SUN-ND (SUN ND PROTOCOL-Temporary) -
78 WB-MON (WIDEBAND Monitoring) -
79 WB-EXPAK (WIDEBAND EXPAK) -
80 ISO-IP (ISO Internet Protocol) -
81 VMTP -
82 SECURE-VMTP -
83 VINES -
84 TTP (Transaction Transport Protocol) -
84 IPTM (Internet Protocol Traffic Manager) -
85 NSFNET-IGP -
86 DGP (Dissimilar Gateway Protocol) -
87 TCF -
88 EIGRP RFC 7868
89 OSPF IGP RFC 1583, RFC 2328, RFC 5340
90 Sprite RPC Protocol -
91 LARP (Locus Address Resolution Protocol) -
92 MTP (ulticast Transport Protocol) -
93 AX.25 Frames -
94 IP-within-IP Encapsulation Protocol -
95 MICP (deprecated) (Mobile Internetworking Control Protocol) -
96 SCC-SP RFC 3378
97 ETHERIP (Ethernet-within-IP Encapsulation) -
98 ENCAP (Encapsulation Header) -
99 any private encryption scheme -
100 GMTP -
101 IFMP (Ipsilon Flow Management Protocol) -
102 PNNI over IP -
103 PIM (Protocol Independent Multicast) RFC 7761
104 ARIS -
105 SCPS -
106 QNX -
107 Active Networks -
108 IPComp (IP Payload Compression Protocol) RFC 2393
109 SNP (Sitara Networks Protocol) -
110 Compaq Peer Protocol -
111 IPX in IP -
112 VRRP (Virtual Router Redundancy Protocol) -
113 PGM (PGM Reliable Transport Protocol) -
114 any 0-hop protocol -
115 L2TP (Layer Two Tunneling Protocol) -
116 DDX (D-II Data Exchange) -
117 IATP (Interactive Agent Transfer Protocol) -
118 STP (Schedule Transfer Protocol) -
119 SRP (SpectraLink Radio Protocol) -
120 UTI -
121 SMP (Simple Message Protocol) -
122 SM (deprecated) (Simple Multicast Protocol) -
123 PTP (Performance Transparency Protocol) -
124 ISIS over IPv4 -
125 FIRE -
126 CRTP (Combat Radio Transport Protocol) -
127 CRUDP (Combat Radio User Datagram) -
128 SSCOPMCE -
129 IPLT -
130 SPS (Secure Packet Shield) -
131 PIPE (Private IP Encapsulation within IP) -
132 Fibre Channel -
133 RSVP-E2E-IGNORE RFC 3175
134 Mobility Header RFC 6275
135 Mobility Header RFC 6275
136 UDPLite RFC 3828
137 MPLS-in-IP RFC 4023
138 MANET Protocols RFC 5498
139 Host Identity Protocol RFC 7401
140 Shim6 Protocol RFC 5533
141 WESP (Wrapped Encapsulating Security Payload) RFC 5840
142 ROHC (Robust Header Compression) RFC 5858
143-252 Unassigned -
253 Use for experimentation and testing RFC 3692
254 Use for experimentation and testing RFC 3692
255 Reserved -

参考标准

标准 Description
RFC 2460 Internet Protocol, Version 6 (IPv6) Specification(Updated by RFC 5095, RFC 5722, RFC 5871, RFC 6437, RFC 6564, RFC 6935, RFC 6946, RFC 7045, RFC 7112)