问题描述
在 IPv4 中,当设备收到数据包大小高于转发链路的 MTU 设置,将对数据包进行分片。在 IPv6 中,中间转发设备不对 IPv6 报文进行分片,报文的分片仅将在源节点进行。
那么在 IPv6 中,如果当设备收到数据包大小高于转发链路的 MTU 设置,该如何处理呢?
解决方案
在 IPv6 中,如果中间设备收到的数据包大小高于 MTU 设备:
1)中间设备将直接丢弃该数据包(数据完整性需要依靠上层协议来保证);
2)中间设备并返回 ICMPv6.Type = 2 报文,告诉源端其能接受的 MTU 值;
3)源端将使用该 MTU 进行后续的数据分片;
PMTU(Path MTU)就是路径上的最小接口 MTU 值;
PMTUD(Path MTU 发现机制)的主要目的是发现路径上的 PMTU,以避免数据包在从 SRC 到 DST 的过程中分段。
依赖 PMTUD 机制,数据的发送方可以使用所发现到的最优 PMTU 与目的地节点进行通信,这样可以避免数据包在从源传输到目的的过程之中,被中途的路由器分片而导致性能的下降。
交互示例
1)首先PC1用1500字节作为MTU向PC2发送IPv6数据包。
2)R1意识到数据包过大,出站接口MTU为1400字节,于是回复一个ICMPv6(Type=2)报文给PC1,指定MTU值为1400字节。
3)然后,PC1开始使用1400作为MTU发送IPv6数据。
4)数据包到达R2后,R2意识到出站接口MTU为1300字节,于是发送一个ICMPv6(Type=2)报文给PC1,指定MTU值为1300字节。
5)PC1开始使用1300作为MTU发送IPv6数据。
测试实验(Huawei)
// AR1,将 MTU 调小,以进行实验 [Interface] ipv6 mtu 1400 [Interface] mtu 1400 // AR2,发送 Ping 测试 ==> 出现丢包 <AR2>ping ipv6 -s 1452 2003::2 PING 2003::2 : 1452 data bytes, press CTRL_C to break Request time out Reply from 2003::2 bytes=1452 Sequence=2 hop limit=63 time = 40 ms Reply from 2003::2 bytes=1452 Sequence=3 hop limit=63 time = 30 ms Reply from 2003::2 bytes=1452 Sequence=4 hop limit=63 time = 40 ms Reply from 2003::2 bytes=1452 Sequence=5 hop limit=63 time = 40 ms --- 2003::2 ping statistics --- 5 packet(s) transmitted 4 packet(s) received 20.00% packet loss round-trip min/avg/max = 30/37/40 ms // 如果抓包,能够看到 ICMPv6 Type==1 Code==0 Too Big 报文 Frame 162: 1294 bytes on wire (10352 bits), 1294 bytes captured (10352 bits) on interface -, id 0 Ethernet II, Src: HuaweiTe_64:0e:23 (00:e0:fc:64:0e:23), Dst: HuaweiTe_60:33:15 (00:e0:fc:60:33:15) Internet Protocol Version 6, Src: 2003::1, Dst: 2002::2e0:fcff:fe60:3315 0110 .... = Version: 6 .... 0000 0000 .... .... .... .... .... = Traffic Class: 0x00 (DSCP: CS0, ECN: Not-ECT) .... .... .... 0000 0000 0000 0000 0000 = Flow Label: 0x00000 Payload Length: 1240 Next Header: ICMPv6 (58) Hop Limit: 64 Source Address: 2003::1 Destination Address: 2002::2e0:fcff:fe60:3315 [Destination 6to4 Gateway IPv4: 0.0.0.0] [Destination 6to4 SLA ID: 0] [Destination SA MAC: HuaweiTe_60:33:15 (00:e0:fc:60:33:15)] Internet Control Message Protocol v6 Type: Packet Too Big (2) Code: 0 Checksum: 0x29db [correct] [Checksum Status: Good] MTU: 1400 Internet Protocol Version 6, Src: 2002::2e0:fcff:fe60:3315, Dst: 2003::2 0110 .... = Version: 6 .... 0000 0000 .... .... .... .... .... = Traffic Class: 0x00 (DSCP: CS0, ECN: Not-ECT) .... .... .... 0000 0000 0000 0000 0000 = Flow Label: 0x00000 Payload Length: 1460 Next Header: ICMPv6 (58) Hop Limit: 63 Source Address: 2002::2e0:fcff:fe60:3315 Destination Address: 2003::2 [Source 6to4 Gateway IPv4: 0.0.0.0] [Source 6to4 SLA ID: 0] [Source SA MAC: HuaweiTe_60:33:15 (00:e0:fc:60:33:15)] Internet Control Message Protocol v6 Type: Echo (ping) request (128) Code: 0 Checksum: 0xe65c [unverified] [in ICMP error packet] [Checksum Status: Unverified] Identifier: 0xeaab Sequence: 256 Data (1184 bytes) Data: c2902500000000000000000000000000000102030405060708090a0b0c0d0e0f10111213… [Length: 1184]