The understanding of MSS in TCP protocol

Source: Internet
Author: User
Tags ack
Before we introduce MSS, we have to understand several important concepts.
Mtu:maxitum Transmission Unit Max Transmission Unit
Mss:maxitum Segment size Max fragment sizes
PPPOE:PPP over Ethernet (the PPP protocol is hosted on Ethernet), it is because of this protocol that we need to modify our MSS or the MTU value.
MTU Maximum Transmission unit, the largest transmission unit is actually closely related to the link layer protocol, the structure of the ethernetii frame DMAC+SMAC+TYPE+DATA+CRC
Due to the electrical limitations of Ethernet transmission, each Ethernet frame has a minimum size of 64bytes maximum cannot exceed 1518bytes, for Ethernet frames less than or greater than this limit can be regarded as the wrong data frame, the general Ethernet forwarding device will discard these data frames.
Since the Ethernet ethernetii maximum data frame is 1518Bytes, the frame header of the Ethernet frame is planed (Dmac destination MAC address 48bit=6bytes+smac source MAC address 48bit=6bytes+ Type domain 2bytes) 14Bytes and frame tail CRC check part 4Bytes (this part is sometimes called FCS), then the rest of the upper layer protocol is the data domain is the largest can only have 1500Bytes, this value we call it the MTU. This is where the network layer protocol is concerned, because the network layer protocol, such as the IP protocol, determines whether or not to fragment the data passed down from the top.

When two remote PC interconnection, their data need to pass through a lot of routers and a variety of network media in order to reach the end of the network, the different media MTU varies. We can look at the following Simple Network Diagram.
PC1 (192.168.0.1) ―――router――――internet―――-www Server (238.136.1.1)
The TCP MSS size is negotiated on both sides of the TCP connection at three handshake times, as follows:
The PC1 sends a SYN message, where the option option fills the MSS field normally 1460, and the same WWW server sends a SYN+ACK message response after receiving the SYN message, and the option option fills the MSS field with 1460; The negotiation parties compare SYN and syn+ The size of the MSS field in the ACK message, select the smaller MSS as the size of the sending TCP shard. By comparison, the TCP MSS on both sides of the negotiation are 1460.

For the upper level protocol of the network layer (we take the TCP/IP protocol family as an example), the Network layer IP protocol checks the size of each packet from the upper layer protocol and determines whether to make "shard" processing based on the size of the native MTU. The biggest disadvantage of the Shard is to reduce the transmission performance, originally can be done, divided into several times, so in the network layer layer (is the transport layer) of the implementation of this will often be noted. So a tag is added to the IP packet header: DF (Donot Fragment). When this IP packet is routed through multiple routes, the forwarding device discards the packet if it encounters an MTU that is smaller than the IP packet. It then returns an error message to the sender. This often causes some communication problems, but fortunately most network links are MTU1500 or greater than 1500.
For UDP protocol, the Protocol itself is a non-connected protocol, the arrival order of packets and whether the correct arrival is not very concerned, so the general UDP application has no special requirements for the Shard.
This is not the case for the TCP protocol, which is a connection-oriented protocol that is very concerned about the order in which packets arrive and whether there are errors in the transmission for the TCP protocol. Therefore some TCP applications have requirements for shards---cannot be fragmented (DF). PPPoE is the so-called PPPoE is running on the Ethernet PPP protocol, is to add a layer of PPPoE header on the link layer protocol we transmit. This equates to the size of the entire packet.
Why is this strange demand? This is because with the broadband access (the broadband access is generally cable modem or xDSL or Ethernet access) due to the lack of Ethernet authentication billing mechanism and traditional operators through the PPP Protocol to dial-up access Services authentication billing, PPPoE brings benefits, but also brings some disadvantages, For example: two times the package consumes resources, reduces the transmission efficiency and so on, the biggest disadvantage is that PPPoE causes the MTU to become smaller, the MTU of Ethernet is 1500, minus the overhead of the packet tail of PPP (8Bytes), it becomes 1492.
If a network between two hosts uses PPPoE then it can cause some applications that cannot be fragmented to communicate.
This time we need to adjust the MTU of the host, by reducing the MTU of the host, so that we can communicate smoothly. When our PC is linked to the server, can only ping, but not through the Web access, then we need to consider the size of the MSS value is correct, in general, the MSS value is not caused by the wrong.

There are, of course, additional solutions for TCP applications. Is that there is an option in TCP there is an MSS options here. MSS is the maximum data segment that a TCP packet can transmit at a time. In order to achieve optimal transmission efficiency, the TCP protocol usually negotiates the MSS values of both sides when establishing the connection. This value TCP protocol in the implementation of the time is often replaced with the MTU value (need to subtract the size of the IP packet header 20Bytes and TCP data segment of the packet 20Bytes) so often MSS is 1460. Both sides of the communication will determine the maximum MSS value for this connection based on the MSS value provided by both parties. This is in the IPV4 protocol, and in the IPV6 protocol generally the value of MSS is 1440, this is because the IPv6 in the size of the IP header is 40bytes, larger than IPV4 20 bytes.

Let's just imagine, If we adjust the maximum MSS for each TCP connection on the intermediate router so that the maximum MSS value over the PPPoE link plus the packet end of the packet header will not exceed the MTU size of PPPoE 1492 this will not cause the problem of no communication. So the above problem can be caused by IP TCP Adjust-mss 1452来 solution. This configuration option is available on many router configurations. If the IPV6 can be adjusted to 1432. When we do not change the intermediate router, we can also change our host by the MTC to solve. When the MTU value of the host is changed from 1500 to 1492, it is equivalent to removing the length of the ethernetii and PPPoE headers.
Main reference: Http://www.net130.com/CMS/Pub/network/network_protocal/2005_09_22_97176.ht

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.