【实验】关于MPLS MTU的实验

MTU(最大传输单元)指的是除去“Ethernet帧头部”和“FCS校验字段”以外的部分,这部分默认情况下最大为1500字节。详情请见下图。

|  FCS  |  Data  |  TCP  |  IP  |  Label  |  Eth  |
        |     MTU (default 1500 byte)     |

(注:上面的图是拿字符画的,手机上一自动换行就乱了,如果出现了变形,请在电脑上观看,下同)

因为加了一层MPLS标签,所以Label部分占了4个字节,那么剩余的MTU大小只剩1496字节了(如需查看“Ethernet帧格式”和“MPLS标签格式”请点击这里)。

这里还要回答一个非常重要的问题,MTU和IP MTU的区别是什么?

IP MTU是三层的特性,相比于MTU,除了不包含“Ethernet帧头部”和“FCS校验字段”以外,也不包含2.5层的头部(所谓的2.5层的头部包括MPLS标签和PPPoE等)。同时,扩展ping命令里可以设置的ping数据包的size(或称datagram size)指的就是IP MTU

MTU作为物理特性是不可以修改的,IP MTU可以修改(物理接口下可通过ip mtu xxxx命令修改IP MTU,xxxx的取值范围是68字节到1500字节)。

|  FCS  |  Data  |  TCP  |  IP  |  Label  |  Eth  |
        |     MTU (default 1500 byte)     |
        |         IP MTU        |

有的人一定会想,MTU就是IP + TCP + Data呀?!不包含Label吧?

回答:首先,MTU是包含Label的。如果你使用扩展ping命令将ping包的size(datagram size,也就是IP MTU)设置为1500字节,同时DF位设为1(即不允许分片),数据包是没法进入MPLS环境进行正常转发的。因为MTU包含了4字节的MPLS标签,这个时候MTU变成1504字节了,超过MTU的最大上限。如果将ping包的size设置为1496字节,再加上4字节的MPLS标签,刚好是MTU的最大上限,这个时候数据包正好可以进入MPLS环境进行正常转发。所以,MTU是包含Label的。

其次,是有IP MTU这个概念的。你会在物理接口下发现一个ip mtu xxxx这样的一条命令,xxxx的取值范围是68字节到1500字节。

最后,当没有Label的时候(或者叫做2.5层,包括MPLS标签和PPPoE等),IP MTU是等于MTU的,他们完全一致。

接下来会做一个实验验证一下上面那一大堆的话。

实验环境:

操作系统:Windows 10(1607,14393.351,当时最新测试版),模拟器:GNS3 IOU for Windows 1.5.2(当时最新正式版)
注:当然,只要有思科模拟器都可以做这个实验

【实验】关于MPLS MTU的实验
【实验】关于MPLS MTU的实验

实验步骤:

1、先完成基础配置(IP地址和IGP):

IOU1:

conf t
int l 0
ip add 1.1.1.1 255.255.255.255

int e 0/0
ip add 12.1.1.1 255.255.255.0
no sh

router isis 1
net 49.0001.0000.0000.0001.00
is-type level-1
pass l 0
adv pass

int r e 0/0
ip router isis 1

IOU2:

conf t
int l 0
ip add 2.2.2.2 255.255.255.255

int e 0/0
ip add 12.1.1.2 255.255.255.0
no sh

int e 0/1
ip add 23.1.1.2 255.255.255.0
no sh

router isis 1
net 49.0001.0000.0000.0002.00
is-type level-1
pass l 0
adv pass

int r e 0/0 , e 0/1
ip router isis 1

IOU3:

conf t
int l 0
ip add 3.3.3.3 255.255.255.255

int e 0/0
ip add 34.1.1.3 255.255.255.0
no sh

int e 0/1
ip add 23.1.1.3 255.255.255.0
no sh

router isis 1
net 49.0001.0000.0000.0003.00
is-type level-1
pass l 0
adv pass

int r e 0/0 , e 0/1
ip router isis 1

IOU4:

conf t
int l 0
ip add 4.4.4.4 255.255.255.255

int e 0/0
ip add 34.1.1.4 255.255.255.0
no sh

int e 0/1
ip add 45.1.1.4 255.255.255.0
no sh

router isis 1
net 49.0001.0000.0000.0004.00
is-type level-1
pass l 0
adv pass

int r e 0/0 , e 0/1
ip router isis 1

IOU5:

conf t
int l 0
ip add 5.5.5.5 255.255.255.255

int e 0/0
ip add 56.1.1.5 255.255.255.0
no sh

int e 0/1
ip add 45.1.1.5 255.255.255.0
no sh

router isis 1
net 49.0001.0000.0000.0005.00
is-type level-1
pass l 0
adv pass

int r e 0/0 , e 0/1
ip router isis 1

IOU6:

conf t
int l 0
ip add 6.6.6.6 255.255.255.255

int e 0/0
ip add 56.1.1.6 255.255.255.0
no sh

router isis 1
net 49.0001.0000.0000.0006.00
is-type level-1
pass l 0
adv pass

int r e 0/0
ip router isis 1

2、接着完成MPLS的配置:

IOU2:

mpls ip
mpls label protocol ldp
mpls ldp router-id Loopback0 force
mpls label range 2000 2999

int e 0/1
mpls ip

IOU3:

mpls ip
mpls label protocol ldp
mpls ldp router-id Loopback0 force
mpls label range 3000 3999

router isis 1
mpls ldp autoconfig

IOU4:

mpls ip
mpls label protocol ldp
mpls ldp router-id Loopback0 force
mpls label range 4000 4999

router isis 1
mpls ldp autoconfig

IOU5:

mpls ip
mpls label protocol ldp
mpls ldp router-id Loopback0 force
mpls label range 5000 5999

int e 0/1
mpls ip

3、我们先去ping一个IP MTU = 1500、DF位(Don’t Fragment,不允许分片)设为1的包看一下:

IOU6#ping 1.1.1.1 source 6.6.6.6 size 1500 df-bit 
Type escape sequence to abort.
Sending 5, 1500-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:
Packet sent with a source address of 6.6.6.6 
Packet sent with the DF bit set
MMMMM
Success rate is 0 percent (0/5)
IOU6#

注:“M”表示的意思是“数据无法分割”(如需查看更详细的ping返回符号的含义请点击这里)。

因为此时的MTU实际上等于1504字节(多了4字节的MPLS标签),数据包又不允许分片,所以ping失败。

IOU6#ping 1.1.1.1 source 6.6.6.6 size 1496 df-bit 
Type escape sequence to abort.
Sending 5, 1496-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:
Packet sent with a source address of 6.6.6.6 
Packet sent with the DF bit set
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/2 ms

然而IP MTU = 1496、DF位设为1的数据包是可以通过的(因为再加上4字节的MPLS标签,MTU正好是1500字节,没有超过MTU的最大取值)。

IOU6#ping 1.1.1.1 source 6.6.6.6 size 1497 df-bit 
Type escape sequence to abort.
Sending 5, 1497-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:
Packet sent with a source address of 6.6.6.6 
Packet sent with the DF bit set
MMMMM
Success rate is 0 percent (0/5)

如果IP MTU再大一个字节,变成IP MTU = 1497、DF位设为1的数据包,就没法通过了(因为此时MTU等于1501字节了,MTU已超过1500字节这个最大取值,所以路由器没法转发)。

那如何硬硬让IP MTU = 1500、DF位设为1的数据包通过呢?

4、尝试修改MTU和IP MTU:

我们试着修改一下MTU和IP MTU的取值,看能不能让IP MTU = 1500、DF位设为1的数据包通过。

当然,MTU是没法修改的。如下图所示,接口下设置MTU失败(log信息提示不支持用户设置MTU):

接口下设置MTU失败
接口下设置MTU失败
接口下设置MTU失败(设置小也不可以)
接口下设置MTU失败(设置小也不可以)

我们再试着设置IP MTU(可设置的范围在68到1500字节之间):

IOU5(config)#int e 0/1
IOU5(config-if)#ip mtu 1504
                          ^
% Invalid input detected at '^' marker.

IOU5(config-if)#ip mtu ?
  <68-1500>  MTU (bytes)

IOU5(config-if)#ip mtu 1496

经过尝试,我们没有办法将MTU的最大取值设置为1504字节;也没办法将IP MTU的最大取值设置为1504字节,只能设置得更小。所以,修改MTU和IP MTU是没法让IP MTU = 1500字节、DF位设为1的数据包通过MPLS环境的(再强调一下:在MPLS环境下IP MTU = 1500字节就意味着MTU = 1504字节,不要忘了4字节的MPLS标签)。

5、修改MPLS MTU:

那如何实现这个需求呢?请用这个命令:mpls mtu override 1504,这条命令可以让带有MPLS标签的数据包当做小巨型帧来处理。

小于等于1500字节的数据包,按标准以太网帧处理;
大于1500小于2000字节的数据包,按小巨型帧处理;
大于2000字节的数据包,按巨型帧处理。

IOU5上修改MPLS MTU:

IOU5(config)#int e 0/1
IOU5(config-if)#no ip mtu 1496
IOU5(config-if)#mpls mtu ?   
  <64-1500>  MTU (bytes)
  override   Override mpls mtu maximum of interface mtu

IOU5(config-if)#mpls mtu override ?
  <1501-1580>  MTU (bytes)

IOU5(config-if)#mpls mtu override 1504
IOU5(config-if)#
*Oct 23 15:34:51.951: %MFI-3-MPLS_MTU_SET: Setting mpls mtu to 1504 on Ethernet0/1
which is higher than the interface mtu 1500.  This could lead to packet forwarding
problems including packet drops.

IOU2/3/4的接口也要设置:

IOU2(config)#int e 0/1
IOU2(config-if)#mpls mtu override 1504

IOU3(config)#int r e 0/0 - 1
IOU3(config-if-range)#mpls mtu override 1504

IOU4(config)#int r e 0/0 - 1
IOU4(config-if-range)#mpls mtu override 1504

实验结果:

现在再ping一次:

IOU6#ping 1.1.1.1 source 6.6.6.6 size 1500 df-bit 
Type escape sequence to abort.
Sending 5, 1500-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:
Packet sent with a source address of 6.6.6.6 
Packet sent with the DF bit set
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/2 ms

通了!

再强调一遍,为什么命令mpls mtu override 1504配置了以后就通了?因为路由器里还有一个小巨型帧的概念,现在的路由器是支持小巨型帧的。这条命令允许MPLS使用小巨型帧。

最后,MPLS MTU的范围跟MTU的范围是一致的。

|  FCS  |  Data  |  TCP  |  IP  |  Label  |  Eth  |
        |     MTU (default 1500 byte)     |
        |         IP MTU        |
        |            MPLS MTU             |

 

其他相关文章:

本文完。如有疑问,欢迎在下方留言;如本文有什么错误,欢迎在下方留言指正,谢谢。

这篇文章对你有帮助吗?

相关文章

发表评论?

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据