关于 MTU 和 IP MTU 的作用范围,如下图所示:
| FCS | Data | TCP | IP | Label | Eth | | MTU (default 1500 byte) | | IP MTU | (注:上面的图是拿字符画的,手机上一自动换行就乱了,如果出现了变形,请在电脑上观看,下同)
如上图所示,当数据包中没有 MPLS 标签时,IP MTU = MTU。详情请看:《【实验】关于MPLS MTU的实验》。
实验环境:
操作系统:Windows 10(1607,14393.351,当时最新测试版),模拟器:GNS3 IOU for Windows 1.5.2(当时最新正式版)
注:当然,只要有思科模拟器都可以做这个实验

实验需求:
本实验借用了《【实验】IP L2VPN下,Point-to-Point的L2TPv3实验》的实验拓扑和配置来完成。强烈建议您先看看这篇文章,尤其文章结尾的数据包包头分析部分。
本文还有一篇姊妹篇:《【实验】关于MPLS L2VPN MTU的实验》,您可以先看看这篇文章,再来看本篇文章。
实验步骤:
1、先配置 IP 地址和 IGP(OSPF 234):
IOU2:
conf t int e 0/2 router ospf 234 int r e 0/2 , l 0 |
IOU3:
conf t int e 0/2 int e 0/3 router ospf 234 int r e 0/2-3 , l 0 |
IOU4:
conf t int e 0/3 router ospf 234 int r e 0/3 , l 0 |
|
IOU1:
conf t |
IOU7:
conf t |
IOU5:
conf t |
IOU6:
conf t |
IOU8:
conf t |
IOU9:
conf t |
2、配置 IOU1 和 IOU7 上的 IP / L2TPv3:
IOU2:
pseudowire-class T17 int s 2/0 |
IOU4:
pseudowire-class T17 int s 2/0 |
3、配置 IOU5 和 IOU6 上的 IP / L2TPv3:
IOU2:
pseudowire-class T56 int e 0/1 |
IOU4:
pseudowire-class T56 encapsulation l2tpv3 int s 2/1 |
4、配置 IOU8 和 IOU9 上的 IP / L2TPv3:
IOU2:
pseudowire-class T89 int e 1/0 |
IOU4:
pseudowire-class T89 int e 1/0 |
实验现象:
1、关于 IOU1 和 IOU7 之间的 L2TPv3 L2VPN 的 MTU(HDLC <······> HDLC):

我们先测试 IOU1 和 IOU7 之间的连通性:
IOU1#p 10.1.1.7 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 10.1.1.7, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 18/19/20 ms
看过《【实验】关于MPLS L2VPN MTU的实验》的朋友们都知道:在那个实验中,因为 MPLS L2VPN 下服务提供商上的设备(也就是IOU2/3/4)是不会对伪线上的数据包进行分片的,再加上 MPLS 标签和伪线控制字段都占用了一定的字节,所以如果我们在 IOU1 上 ping 10.1.1.7 size 1500 是不通的。
那在 L2TPv3 L2VPN 中,是否会出现像 MPLS L2VPN 上一样的情况呢?
IOU1#ping 10.1.1.7 size 1500
Type escape sequence to abort.
Sending 5, 1500-byte ICMP Echos to 10.1.1.7, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 36/37/38 ms
IOU1#ping 10.1.1.7 size 1500 df-bit
Type escape sequence to abort.
Sending 5, 1500-byte ICMP Echos to 10.1.1.7, timeout is 2 seconds:
Packet sent with the DF bit set
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 37/38/41 ms
如上图所示, ping 包的 IP MTU 设置成 1500 字节,无论允不允许分片,都通了!
如果我们将 ping 包的 IP MTU 设置成 1501 字节或者更大呢?
IOU1#ping 10.1.1.7 size 1501 Type escape sequence to abort. Sending 5, 1501-byte ICMP Echos to 10.1.1.7, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 37/38/40 ms IOU1#ping 10.1.1.7 size 1600 Type escape sequence to abort. Sending 5, 1600-byte ICMP Echos to 10.1.1.7, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 36/38/40 ms
没有问题!
那如果设置了不允许分片呢?
IOU1#ping 10.1.1.7 size 1501 df-bit Type escape sequence to abort. Sending 5, 1501-byte ICMP Echos to 10.1.1.7, timeout is 2 seconds: Packet sent with the DF bit set ..... Success rate is 0 percent (0/5) IOU1#ping 10.1.1.7 size 1600 df-bit Type escape sequence to abort. Sending 5, 1600-byte ICMP Echos to 10.1.1.7, timeout is 2 seconds: Packet sent with the DF bit set ..... Success rate is 0 percent (0/5)
设置了不允许分片,IP MTU 再大于 1500 字节,就 ping 不通了。
综上所述,L2TPv3 L2VPN 下的数据包的通信现象,跟正常的 IP 环境是一模一样的:
- IP MTU <= 1500 字节的数据包都可以正常转发出去;
- IP MTU > 1500 字节的数据包做了分片以后还是可以正常转发出去;
- 如果IP MTU > 1500 字节,又不允许分片,那么数据包就会丢包。
在数据包的 IP MTU > 1500 字节的情况下,MPLS L2VPN 和 L2TPv3 L2VPN 的比较:
- 在 MPLS L2VPN 下,伪线里的数据包在服务提供商上的设备(也就是IOU2/3/4)之间进行转发时,转发主要依靠的是 MPLS 标签,而 MPLS 标签自身是不带分片功能的,所以索性就不对伪线中的数据包进行分片了。
- 但是 L2TPv3 L2VPN 不同。在 L2TPv3 L2VPN 下,伪线里的数据包在服务提供商上的设备(也就是IOU2/3/4)之间进行转发时,转发主要依靠的是 IP 三层头部(而不是 MPLS 标签),所以分片其实是可以正常进行的。
那数据包具体是如何在服务提供商的设备(也就是IOU2/3/4)上做分片的?
答:如果在 IOU1 上 ping 10.1.1.7 size 1500 df-bit,那么 IOU1 会在数据包的 IP 三层头部中打上 df-bit(即不允许分片),如下图所示:
| FCS | ICMP | IP(带有 df-bit) | Cisco HDLC |
| 这一段等于 1500 byte |
通过《【实验】IP L2VPN下,Point-to-Point的L2TPv3实验》我们可以知道,在 IOU1 上 ping 10.1.1.7 时,在 IOU3 的 e 0/2 口抓包,数据包的报文结构是如下这个样子的:
| FCS | ICMP | IP | Cisco HDLC | L2TPv3 | IP | Ethernet |
如果我们暂不考虑分片的情况,那么在 IOU1 上 ping 10.1.1.7 size 1500 df-bit,然后在 IOU3 的 e 0/2 口抓包,数据包的报文结构是如下这个样子的:
| FCS | ICMP | IP(带有 df-bit) | Cisco HDLC | L2TPv3 | IP | Ethernet |
| 如果这一段等于 1500 byte |
| 那么这一段等于 1500 + 4 + 4 + 20 = 1528 byte |
因为多加了一个 4 字节的 Cisco HDLC 数据帧、一个 4 字节的 L2TPv3 报头和一个 20 字节的 IP 三层头部,所以数据包的 MTU 明显大于 1500 字节了。那么在 IOU2 和 IOU3 之间的链路上,其实该数据包是要做分片的。而这个分片信息会记录在最外层的 IP 三层头部中(如下图所示):
| FCS | ICMP | IP(带有 df-bit) | Cisco HDLC | L2TPv3 | IP(做分片) | Ethernet | | 分片后,这一段将小于或等于 1500 byte |
如上图所示,虽然最内层的 IP 三层头部上打上了不允许分片的标记,但是最外层的 IP 三层头部没说不允许分片呀,所以在 IOU1 上 ping 10.1.1.7 size 1500 df-bit 时,分片最终是在最外层的 IP 三层头部上做的。
其他相关文章:
- 为什么 HDLC 帧格式不是 8 个字节而是 4 个字节?这个问题在这篇文章中已经做了详细的解释:《【实验】关于MPLS L2VPN MTU的实验》。
为了验证上面的描述,我们现在抓个包看一下。
我们现在在 IOU1 上 ping 10.1.1.7 size 1500 df-bit,然后在 IOU3 的 e 0/2 口抓包,看数据包是什么样子的:
IOU1#ping 10.1.1.7 size 1500 df-bit
Type escape sequence to abort.
Sending 5, 1500-byte ICMP Echos to 10.1.1.7, timeout is 2 seconds:
Packet sent with the DF bit set
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 36/36/37 ms
抓包如下图所示,最内层的 IP 三层头部是打了不允许分片的标记的:

再如下图所示,最外层的 IP 三层头部上带有了分片的信息:

如上图所示,该数据包分片成了两个数据包。图示中展示的其实是分片的第二个数据包(分片的第二个数据包总共 1510 字节,分片的 payload 部分占其中的 1476 字节),而分片的第一个数据包还在该数据包的上面(分片的第一个数据包总共 66 字节,分片的 payload 部分占其中的 32 字节)。
也正是因为上图展示的数据包是分片的第二个数据包,同时也是分片的最后一个数据包,所以该数据包的 More Fragments 标识位标记为 0(More Fragments 标识位标记为 0 表示该数据包是该分片的最后一个数据包了)。
所以,虽然最内层的 IP 三层头部上打上了不允许分片的标记,但是最外层的 IP 三层头部没说不允许分片,分片最终是在最外层的 IP 三层头部上做的。
2、关于 IOU5 和 IOU6 之间的 L2TPv3 L2VPN 的 MTU(PPP <······> Ethernet):

我们先测试 IOU5 和 IOU6 之间的连通性:
IOU6#p 100.1.1.5 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 100.1.1.5, timeout is 2 seconds: .!!!! Success rate is 80 percent (4/5), round-trip min/avg/max = 10/10/10 ms
通了!
再来看看将 ping 包的 IP MTU 分别设置为 1500 字节、1501 字节和 1600 字节,看通不通:
IOU6#ping 100.1.1.5 size 1500 Type escape sequence to abort. Sending 5, 1500-byte ICMP Echos to 100.1.1.5, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 19/19/20 ms IOU6#ping 100.1.1.5 size 1501 Type escape sequence to abort. Sending 5, 1501-byte ICMP Echos to 100.1.1.5, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 19/19/21 ms IOU6#ping 100.1.1.5 size 1600 Type escape sequence to abort. Sending 5, 1600-byte ICMP Echos to 100.1.1.5, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 18/19/20 ms
都通了!
如果再设置不允许分片,看通不通:
IOU6#ping 100.1.1.5 size 1500 df-bit Type escape sequence to abort. Sending 5, 1500-byte ICMP Echos to 100.1.1.5, timeout is 2 seconds: Packet sent with the DF bit set !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 19/19/19 ms IOU6#ping 100.1.1.5 size 1501 df-bit Type escape sequence to abort. Sending 5, 1501-byte ICMP Echos to 100.1.1.5, timeout is 2 seconds: Packet sent with the DF bit set ..... Success rate is 0 percent (0/5) IOU6#ping 100.1.1.5 size 1600 df-bit Type escape sequence to abort. Sending 5, 1600-byte ICMP Echos to 100.1.1.5, timeout is 2 seconds: Packet sent with the DF bit set ..... Success rate is 0 percent (0/5)
设置了不允许分片后,IP MTU = 1500 字节还是通的,IP MTU > 1500 字节就不通了,跟 IOU1 和 IOU7 一样。
通过《【实验】IP L2VPN下,Point-to-Point的L2TPv3实验》我们可以知道,在 IOU6 上 ping 100.1.1.5 时,在 IOU3 的 e 0/2 口抓包,数据包的报文结构是如下这个样子的:
| FCS | ICMP | IP | L2TPv3 | IP | Ethernet |
如果我们暂不考虑分片的情况,那么在 IOU6 上 ping 100.1.1.5 size 1500 df-bit,然后在 IOU3 的 e 0/2 口抓包,数据包的报文结构是如下这个样子的:
| FCS | ICMP | IP | L2TPv3 | IP | Ethernet | | 1500 byte | | 那么这一段等于 1524 byte |
因为多加了一个 4 字节的 L2TPv3 报头和一个 20 字节的 IP 三层头部,所以数据包的 MTU 明显总共是 1524 字节了,所以显然是要做分片的。
分片自然也是在最外层的 IP 三层头部上做,这里不再赘述。
3、关于 IOU8 和 IOU9 之间的 L2TPv3 L2VPN 的 MTU(802.1Q <······> 802.1Q):

我们先测试 IOU8 和 IOU9 之间的连通性:
IOU8#p 200.1.1.9 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 200.1.1.9, timeout is 2 seconds: .!!!! Success rate is 80 percent (4/5), round-trip min/avg/max = 1/1/2 ms
通了!
再来看看将 ping 包的 IP MTU 分别设置为 1500 字节、1501 字节和 1600 字节,看通不通:
IOU8#ping 200.1.1.9 size 1500 Type escape sequence to abort. Sending 5, 1500-byte ICMP Echos to 200.1.1.9, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/2 ms IOU8#ping 200.1.1.9 size 1501 Type escape sequence to abort. Sending 5, 1501-byte ICMP Echos to 200.1.1.9, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/2 ms IOU8#ping 200.1.1.9 size 1600 Type escape sequence to abort. Sending 5, 1600-byte ICMP Echos to 200.1.1.9, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/2 ms
都通了!
如果再设置不允许分片,看通不通:
IOU8#ping 200.1.1.9 size 1500 df-bit Type escape sequence to abort. Sending 5, 1500-byte ICMP Echos to 200.1.1.9, timeout is 2 seconds: Packet sent with the DF bit set !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 19/19/19 ms IOU8#ping 200.1.1.9 size 1501 df-bit Type escape sequence to abort. Sending 5, 1501-byte ICMP Echos to 200.1.1.9, timeout is 2 seconds: Packet sent with the DF bit set ..... Success rate is 0 percent (0/5) IOU8#ping 200.1.1.9 size 1600 df-bit Type escape sequence to abort. Sending 5, 1600-byte ICMP Echos to 200.1.1.9, timeout is 2 seconds: Packet sent with the DF bit set ..... Success rate is 0 percent (0/5)
设置了不允许分片后,IP MTU = 1500 字节还是通的,IP MTU > 1500 字节就不通了,跟 IOU1 和 IOU7 一样。
通过《【实验】IP L2VPN下,Point-to-Point的L2TPv3实验》我们可以知道,在 IOU8 上 ping 200.1.1.9 时,在 IOU3 的 e 0/2 口抓包,数据包的报文结构是如下这个样子的:
| FCS | ICMP | IP | Ethernet | L2TPv3 | IP | Ethernet |
如果我们暂不考虑分片的情况,那么在 IOU8 上 ping 200.1.1.9 size 1500 df-bit,然后在 IOU3 的 e 0/2 口抓包,数据包的报文结构是如下这个样子的:
| FCS | ICMP | IP | Ethernet | L2TPv3 | IP | Ethernet | | 1500 byte | | 那么这一段等于 1538 byte |
因为多加了一个 14 字节的 Ethernet 二层头部、一个 4 字节的 L2TPv3 报头和一个 20 字节的 IP 三层头部,所以数据包的 MTU 明显总共是 1538 字节了,所以显然是要做分片的。
分片自然也是在最外层的 IP 三层头部上做,这里不再赘述。
本文完。如有疑问,欢迎在下方留言;如本文有什么错误,欢迎在下方留言指正,谢谢。
发表评论?