路由器接口MTU、TCP MSS设置
文章来自 山隈的博客 // 树欲静而风不止,子欲养而亲不待。。。
主页
|
About Me
|
归档
标签
现象描述: 组网: PC-AR2831-AR2880-CISCO设备组成的核心网-SERVER 网络运行MPLS VPN;AR2880为PE;AR2831为CE,PE、CE间运行OSPF,多CE配置;路由器各接口MTU、TCP MSS值采用默认设置 AR2880:Version 3.30, Release 0008 AR2831:Version 3.30, Release 0008 现象1: AR2880路由器的以太口MTU使用缺省设置时,使用的OA系统(BS架构)部分流程无法运行,上网发邮件时附件无法粘贴;但是在cisco设备上,同样的组网没有发现问题; 现象2: 将AR2880路由器的以太口MTU改为512测试,邮件附件可以粘贴,但OA主页打开后无内容,刷新不了;将AR2880路由器的以太口MTU改为1200测试,邮件附件可以粘贴,OA主页可以正常显示,但是点击OA系统的”起草公文”无页面弹出,正常状况下应弹出新建公文页面; 告警信息: 无 原因分析: 可能是应用软件问题;可能是MTU 、TCP MSS值协商配置问题; 具体分析: 1、接口MTU、TCP MSS采用缺省值1500时,无法贴附件; 这是因为应用了三层MPLS VPN技术,增加了8bit的标签,MTU值协商出现问题。 AR28XX路由器默认在接口上自动分片,所以在普通的应用中采用默认值不会影响业务。但路由器接口上收到一个报文长度大于本接口MTU值的报文,如果该报文被强制打上不分片的标记,将丢弃报文,并返回一个ICMP差错报文(type 3,code 4),通知报文发起者丢弃原因。报文发起者将发送比较小的报文。通过多次上述报文协商,将得到对于某一个固定路径上的最小Mtu值,这个过程叫做Mtu Discovery ,通过MTU Discovery来确定报文路径上最小可通过的MTU;如果两个设备相连,没有MTU Discovery功能并且MTU值不一致,将可能导致丢弃报文。只有把双方设备的Mtu为对端设备MRU的最小值,才能正常通信。由于某些组网考虑到网络安全问题和性能,往往会把ICMP报文过滤掉,引起Mtu Discovery不能正常运行;应用软件由于程序算法问题或根本没有相应协商功能,也会导致了部分应用异常。 2、更改接口MTU值以后,仍然有部分业务不正常; 这是因为TCP MSS值协商的问题。 一般的应用软件,当客户端和服务器端在建立TCP连接的时候需要根据实际传输的报文大小来协商TCP的窗口大小MSS。Tcp连接成功后会进行两次滑动窗口的协商,一次是pc与server,一次是与网关,然后在两次协商里选择一个较小的值作为窗口来发送报文。MSS值的计算方法是:MSS=MTU-IP-TCP(如果有其他pppoe、加密报文头的话也同样减去),也就是说MSS值其实就是TCP所承载的净载荷的长度。由于AR28XX接口缺省的MTU是1500字节,故一般要求加密报文头+链路层开销+IP头(20-60字节)+TCP报文(20字节)小于1500字节,即TCP分片配置1200左右比较适合。缺省情况下,TCP报文不分片。因此TCP MSS不匹配也会引起部分应用异常。 处理过程: 本例中通过修改路由器接口MTU、TCP MSS值,解决问题。 具体报文mtu 、tcp mss大小要根据具体应用,按经验值进行尝试,选择最佳值;其中MTU值的选择可以通过ping命令设置不分片来进行测试;TCP MSS值的选择则可以通过MTU减去相应其它加密、链路层开销、IP头、TCP头等字节计算。 具体过程如下: 1、本例中使用cisco路由器时相关应用正常。初步估计是mtu值问题,但是对普通应用AR28系列路由器会自动分片,不会影响业务。测试发现在client上ping大包的时候,如果不设置不允许分片,业务正常。看来客户应用中做了不允许分片的设置或其它原因mtu协商错误。更改路由器接口mtu为1500-8=1492以后,业务正常。 2、更改接口mtu以后,其它部分业务还不正常。分析原因是tcp mss值的问题。减小tcp mss值8字节1460-8=1452,但是还有部分业务不正常。询问软件集成商,得到答复部分软件中使用了加密技术。而且不同的应用加密强度不同。 3、逐步调整路由器接口的tcp mss值,减到到1200以后,所有业务测试通过。 命令说明: 1、mtu命令用来设置以太网接口的MTU(最大传输单元),undo mtu命令用来恢复MTU的缺省值。缺省的MTU为1500。使用mtu命令改变接口最大传输单元MTU后,需要先对接口执行shutdown命令,再执行undo shutdown命令将接口重启,以保证设置的MTU生效。 2、tcp mss命令用来配置TCP报文分片,undo tcp mss命令用来取消TCP报文分片。 由于我们接口缺省的MTU是1500字节,故一般要求加密报文头+链路层开销+IP头+TCP报文小于1500字节,即TCP分片配置1200左右比较适合。缺省情况下,TCP报文不分片。 注意:ADSL MTU 最大值应设为为1492 MTU,相信大家都很了解的。那么MSS就是属于MTU中的一部分。MSS=MTU-40。具体的请到百度搜下吧。 以下是实战篇: 网吧,50M电信,200台机器,路由ROS,限速BURST 10M、MAX 2M、TIME 20秒。问题是打开QQ空间时,要等一下才可以。按照速度来算的话,我这网吧的速度已经更快的了,空间应该是瞬间就打开,才是对的。 那么在网速够快的前提下,打开空间却慢,这时候第一个想到的就是MTU的问题。举个简单的例子: A机通过B机向C机发送数据,MTU分别为:A-1472、B-1440、C-1400。那么就可以看到了,A-B-C传输入数据时,MTU值不同,这时候就要取最小值,因为,要把大包分为小包,进行重组。问题就是在这了。 我们要找到一个合适的MTU值,即将MSS修改成一个合适的值。这个值,我们可以通过PING来获取: ping qzone.qq.com -f -l 1500 会返回:Packet needs to be fragmented but DF set.就表明没有通。继续 ping qzone.qq.com -f -l 1496 返回:Packet needs to be fragmented but DF set. 再继续,1500-1496是以每次减4来算的。 我这边一直到1472才通的。如: C:>ping qzone.qq.com -f -l 1472 Pinging qzone.qq.com [58.61.166.85] with 1472 bytes of data: Reply from 58.61.166.85: bytes=1472 time=41ms TTL=54 Reply from 58.61.166.85: bytes=1472 time=41ms TTL=54 Reply from 58.61.166.85: bytes=1472 time=41ms TTL=54 Reply from 58.61.166.85: bytes=1472 time=41ms TTL=54 Ping statistics for 58.61.166.85: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 41ms, Maximum = 41ms, Average = 41ms 这样的话,我这边的MSS值就改为1472。在ROS里添加 IP-FIREWALL-MANGLE-New TCP MSS 修改为你自己合适的值。 ![](https://leanote.com/api/file/getImage?fileId=5f0d714cab64412cdb00154a) ![](https://leanote.com/api/file/getImage?fileId=5f0d714cab64412cdb00154b) ![](https://leanote.com/api/file/getImage?fileId=5f0d714cab64412cdb001549)
Pre:
ROS禁止PING 方法
Next:
ROS等路由器MTU值取值及修改详解
Submit
Sign in
to leave a comment.
No Leanote account?
Sign up now.
0
comments
More...
No Leanote account? Sign up now.