zoukankan      html  css  js  c++  java
  • MSS:The TCP Maximum Segment Size Option(wireshark抓包查看)

    MSS相关概念:

    MSS全称是 Maximum Segment Size,表示TCP握手时通信双方协商的最大报文段长度。

    MSS计算方式: THE TCP MAXIMUM SEGMENT SIZE IS THE IP MAXIMUM DATAGRAM SIZE MINUS FORTY.(RFC879)

    即MSS = MTU - IP HEADER(20字节) - TCP HEADER(20字节)

    RFC6691关于MSS的说明:

    When calculating the value to put in the TCP MSS option, the MTU value SHOULD be decreased by only the size of the fixed IP and TCP headers and SHOULD NOT be decreased to account for any possible IP or TCP options; conversely, the sender MUST reduce the TCP data length to account for any IP or TCP options that it is including in the packets that it sends. The rest of this document just expounds on that statement, and the goal is to avoid IP-level fragmentation of TCP packets.

    The size of the fixed TCP header is 20 bytes [RFC793], the size of the fixed IPv4 header is 20 bytes [RFC791], and the size of the fixed IPv6 header is 40 bytes [RFC2460].

    简单来说,数据接收方声明MSS值时,只需要考虑MTU减去固定IP头(-20)减去固定TCP头(-20);反过来,数据发送方必须再减去数据包中所包含的IP或TCP可选信息(Options)。

    MSS声明而非MSS协商:

    This Maximum Segment Size (MSS) announcement (often mistakenly called a negotiation) is sent from the data receiver to the data sender and says "I can accept TCP segments up to size X". The size (X) may be larger or smaller than the default. The MSS can be used completely independently in each direction of data flow. The result may be quite different maximum sizes in the two directions.

    MSS声明(通常被错误称为协商),即数据接收方告诉数据发送方本端能接受的最大消息段长度。

    MSS值可以在数据流的两个方向上不同,即A<---tcp--->B,A和B可以向对方声明各自的MSS,且双方MSS在传输过程中不同。

    MSS设置过大或者过小

    MSS值过小:数据传输效率降低

    MSS值过大:导致数据包可以封装很大,那么在IP传输中分片的可能性就会增大,接受方在处理分片包所 消耗的资源和处理时间都会增大,如果分片在传输中还发生了重传,那么其网络开销也会增大。因此合理的 MSS是至关重要的。MSS的合理值应为保证数据包不分片的最大值。

    对于以太网MSS可以达到1460byte = MTU(1500) - IP头(20) - TCP头(20) (即:TCP一次发送的应用数据大于MSS,会分段成多个TCP包发送出去)

    Whireshark抓包

    1. TCP握手时,通信双方发送各自的MSS字段,均为1460;
    2. TCP连接建立好后,发送数据最大长度(1448)=MSS(1460)-可选TCP信息(Options 12) octets
  • 相关阅读:
    Visual C#动态生成控件
    (转)GridView 72般绝技
    ASP.NET给DataGrid,Repeater等添加全选批量删除等功能(转)
    JS操作字符串
    在IE中调试客户端脚
    一组很棒的button样式 (转)
    c#实现随机字符串(不包含数字)
    1996年4月全国计算机等级考试二级C语言笔试试题
    ASP.NET 2.0站点登录、导航与权限管理 转
    1996年9月全国计算机等级考试二级C语言笔试试题
  • 原文地址:https://www.cnblogs.com/taouu/p/13926800.html
Copyright © 2011-2022 走看看