Discuss MTU of various link layers and TCP MSS

Source: Internet
Author: User

From: http://www.cnpaf.net/Class/TCPANDIP/200511/9898.html

According to the detailed description of TCP/IP, there are slight changes. If the author's rights and interests are infringed, contact me.

 

[Background Knowledge]

MTU: The maximum transmission unit of maxitum transmission unit (meaning different link layer bearer networks are used for Internet interconnection, such as Ethernet, PPP, and old slip,It is generally the maximum number of bytes of data frames except the link layer header and network layer header.)

MSS: Maximum shard size of maxitum segment size (segment is the PDU of TCP. MSS is used to notify the peer TCP of the maximum amount of TCP data that the peer can send in each shard,Generally MTUNumber of bytes except the TCP Header)

Pppoe: PPP over Ethernet (carrying the PPP protocol over Ethernet)

 

[Analysis process]

Let's talk about the MTU's maximum transmission unit, which is closely related to the link layer protocol. Let's recall the structure of the Ethernet frame.

Destinationmac + sourcemac + Type + Data + CRC
. Due to the electrical limitations of Ethernet transmission, each Ethernet frame has a minimum of 64 bytes and a maximum of 1518 bytes. For an Ethernet frame smaller than or greater than this limit, we can regard it as a wrong data frame, generally, Ethernet forwarding devices discard these data frames.

(Note: data frames smaller than 64 bytes are generally produced by "Fragmentation" caused by Ethernet conflicts, line interference, or bad Ethernet interfaces, for data frames larger than bytes, we generally call it a giant frame, which is generally generated by line interference or bad Ethernet ports)

Because the maximum data frame of Ethernet is 1518bytes, the frame header of the split Ethernet frame = destination MAC address 48bit (6 bytes) + source MAC address 48bit (6 bytes) + type domain 2 bytes (14 bytes in total) and frame end CRC verification Part 4 bytes (this department sometimes calls it "FCS ), then the rest of the places that carry the upper-layer protocol, that is, the maximum data domain can only have bytes, which we call MTU.

Conclusion: The MTU of Ethernet is 1500 bytes.

This is where the network layer protocol is very concerned, because the network layer protocol, for example, the IP protocol, determines whether to split the data transmitted from the upper layer based on this value. It is like a box that cannot hold a big chunk of bread. We need to cut the bread into slices and put it in multiple boxes.

When two remote PCs are interconnected, their data must pass through many routers and a variety of network media to reach the peer end. The MTU of different media in the network is different, it is better than a long pipe, which is composed of different water pipes of different thickness (different MTU). The maximum water volume of the pipe is determined by the finest water pipe in the middle.

For the upper-layer protocols at the network layer (we take the TCP/IP protocol family as an example), they do not care about the pipe width. They think this is the network layer. The Network Layer IP protocol checks the size of each packet from the upper layer protocol, and determines whether to perform "sharding" based on the MTU size of the local machine. The biggest disadvantage of sharding is that
This reduces the transmission performance. The tasks that can be done once are divided into multiple tasks. Therefore, you will pay attention to this issue when implementing a higher layer (Transport Layer) at the network layer! For some reason, some higher layers require that I cannot slice this bread. I want the full bread, so I will add it to the IP packet header.
Tags: DF (donot fragment ).

In this way, when the IP packet is transmitted in a large network (in the pipe), if the MTU is smaller than the IP packet, the forwarding device will discard the packet as required. Then, an error message is returned to the sender. This will often cause some communication problems, but fortunately most network links are mtu1500 or greater than 1500.

For UDP, this protocol itself is a connectionless protocol, which does not concern much about the arrival sequence of data packets and whether the packets arrive correctly. Therefore, UDP applications generally have no special requirements on fragment.

The TCP protocol is different. This protocol is a connection-oriented protocol. For TCP, it is very concerned about the arrival sequence of data packets and whether errors occur during transmission. Therefore, some TCP applications have requirements on fragment-they cannot fragment (DF ).

Special case -- MTU of pppoe

The so-called pppoe is to run the PPP protocol over Ethernet. Some people wonder, isn't the PPP protocol and Ethernet both a link layer protocol? Why does one link layer go to another link layer? Cannot it be upgraded to a network layer protocol. In fact, this is a misunderstanding: a certain layer of Protocol can only carry a higher layer of protocol.
Why is this strange demand? This is because with broadband access (this type of broadband access is generally cable modem, XDSL, or Ethernet Access) due to the lack of authentication and billing mechanisms for Ethernet, the traditional operator uses the PPP protocol to authenticate and charge for dial-up and other access services, so this is a freak: pppoe. (For details about pppoe, refer to the Introduction articles provided by Party v and other members of this site. I will not mention them here)

Pppoe brings both benefits and some disadvantages, such as resource consumption by secondary encapsulation and reduced transmission efficiency. I will not talk about these disadvantages, the biggest disadvantage is that pppoe makes MTU smaller.The MTU of Ethernet is 1500, minus the overhead (8 bytes) at the end of the PPP packet header ),PppoeThe MTU is changed to 1492.

Important: If pppoe is used in a network segment between two hosts, applications that cannot be split cannot communicate.
At this time, we need to adjust the MTU of the host to reduce the MTU of the host so that we can smoothly communicate with each other.

Of course, there are other solutions for TCP applications.
Please leave the third pig today: MSS.

The abbreviation of the Maximum Transmission size of MSS is a concept in TCP.
MSS is the maximum data segment that TCP data packets can transmit each time. To achieve optimal Transmission Performance, TCP usually needs to negotiate the MSS value of both parties when establishing a connection, this value is often replaced by the MTU value when the TCP protocol is implemented (the size of the IP packet header must be reduced by 20 bytes and the packet header of the TCP data segment is 20 bytes). Therefore, the MSS is usually 1460. Both parties will determine the maximum MSS value for this connection based on the MSS value provided by both parties.

Description: The fixed length of the IP header, that is, the minimum length is 20 bytes, which can be expanded to 60 bytes at most. The same is true for TCP.

After introducing these three pig s
Let's look back at the question in the preface. Let's think about it, if we adjust the maximum MSS of each TCP connection on the intermediate router so that the maximum mss value of the pppoe link plus the end Of the data packet header will not exceed the MTU size of pppoe 1492, this will not cause communication failure. therefore, the above problem can be solved through ip tcp adjust-MSS 1452.
Of course, the problem can also be solved by modifying the MTU of the PC.

 

Find a graph on the Wiki:

Application Layer | HTTP... |

----------

Network Transmission Layer | TCP/IP |

--------

Data link layer | PPP |

| Pppoe |

| Ethernet |

----------

The pppoe format of rfc2516 is as follows:

| Target MAC address | source MAC address | type | load | checksum |

Load format of Ethernet frames:

                        1                   2                   3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| VER | TYPE | CODE | SESSION_ID |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| LENGTH | payload ~
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+


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.