The relationship between Ethernet frame length, MTU, IP packet length, TCP packet length, and TCP MSS

Without considering jumbo frames in this article, let's deal with a few concepts. In daily discussions, these lengths are often easily confused. 64 bytes, 1518 bytes, 1500 bytes, 1460 bytes, we will introduce the sources of these common and confusing length values ​​next.

1. Ethernet frame length:

The length of the data frame represents the length of the Layer 2 Ethernet frame. As shown in the figure below, the IEEE802.3 protocol stipulates that the minimum frame length of an Ethernet frame is 64 bytes , and the maximum is 1518 bytes .
insert image description here
There is another algorithm here, which needs to add 7-byte preamble synchronization code + 1-byte frame start delimiter on the basis of the above picture to become 7-byte preamble synchronization code + 1-byte frame start delimiter Delimiter + 6-byte destination MAC + 6-byte source MAC + 2-byte frame type + 1500 + 4-byte FCS, the total length becomes 1518+7+1 = 1526 bytes ;
and some people discuss At this time, not only the preamble synchronization code and byte frame start delimiter are not considered, but also the FCS part (because these parts are often invisible in the packet capture software), then this becomes 1514 bytes .

2. MTU (Maximum Transmission Unit, maximum transmission unit):

MTU refers to the maximum packet size, in bytes, that the network is capable of transmitting. MTU is the concept of the data link layer. In Ethernet, it refers to the maximum value of the length of the effective data load (payload) part carried by the Ethernet frame. Networks with different link media types have different default MTU values. As shown in the figure below, we can know that the minimum effective data part of the Ethernet frame is 64-6-6-2-4 = 16 bytes, and the maximum is 1518 bytes through the frame length of the Ethernet frame is at least 64 bytes and the maximum is 1518 bytes -6 bytes target MAC address -6 bytes source MAC address -2 bytes data frame type -4 bytes check = 1500 bytes , this maximum value is called MTU, so it is usually 1500 bytes.
insert image description here

The MTU values ​​of all interfaces in the host can be viewed by the following command

sudo netstat -i

3. IP packet length:

Generally speaking, limited by the MTU, we believe that an IP packet is composed of a 20-byte IP header + a 1480-byte IP payload.
insert image description here
So the length of the IP payload is usually 1480 bytes.

4. TCP packet length:

Restricted by MTU (accurately limited by MSS, see the next chapter) the TCP packet length consists of a 20-byte TCP header + a 1460-byte TCP payload. The length of the TCP payload is 1460 bytes .
insert image description here

5、TCP MSS(Maximum Segment Size):

TCP MSS refers to the maximum message length allowed by the TCP protocol, that is, the length of the largest TCP maximum payload part that can be transmitted by a TCP data packet each time, excluding the TCP header. MSS refers to the maximum length of the payload part of TCP. Generally speaking, if we only consider the MTU of the host's current Ethernet interface card: TCP MSS = MTU - 20 bytes of IP header - 20 bytes of TCP header = 1460 bytes . In the actual network, the TCP MSS is not only limited by the MTU of the current network interface card of the host, but also limited by the MTU size of the network and the end host. For details, please refer to the calculation of TCP MSS and detailed explanation of TCP path MTU
(
PMTU ) Detailed explanation of the discovery process

insert image description here

Guess you like

Origin blog.csdn.net/meihualing/article/details/129824292