当前位置:网站首页>Understand what MTU is

Understand what MTU is

2022-06-25 06:21:00 Programmer community

The link layer of Ethernet has a limit on the length of data frames , Its maximum value defaults to 1500 byte , This feature of the link layer is called MTU, That is, the largest transmission unit

MTU

MTU

Maximum Transmission Unit, Maximum transmission unit , It refers to the maximum of the data link layer payload, Set by the hardware network card MTU, It's a hard limit

 Understand what is MTU illustrations

Effective data of data link layer , Minimum 46byte, Maximum general 1500byte, The biggest thing here is MTU,MTU Indicates that the network layer must send to the network card API My bag <= 1500byte, Otherwise, the call fails

MTU It is the restriction of the link layer to the network layer , Ethernet link MTU The default is 1500byte, It means effective data of Ethernet data link layer payload The maximum number of bytes of cannot exceed 1500, What about this 1500 Does the byte contain the head and tail of the link layer ?

Of course, it doesn't include !

Here comes the question , Some Ethernet network cards are configured with VLAN tag, Data frames passing through this network card will carry VLAN tag,VLAN tag It should be counted in the link layer payload Li ? Or we can say MTU = 1500 It contains 802.1Q The head of VLAN tag Do you ?

contain !

 Understand what is MTU illustrations 1

When the network card is configured VLAN tag when ,VLAN tag + Data <= MTU, Sometimes VLAN tag Not just one , It could be a double label , So this one VLAN tag Namely 8 Bytes . By this time MTU If still 1500, Link layer payload It can't be 1500 了

What do I do ?

You can add 802.1Q Interface settings for MTU=1504 or 1508

Why would there be MTU

Ethernet initially had no limit on message length , The network layer can receive at most 65535 Bytes , But Ethernet can not reliably transmit long messages , And retransmission after loss will also occupy a lot of network resources , And limit the message to a certain length , Ethernet can transmit the message to the destination , So there was MTU

IP Fragmentation

Since the link layer payload Yes MTU Limit , This means that the data sent from the network layer to the link layer cannot exceed MTU, If you exceed , You need to partition in the network layer , Cut into pieces <=MTU Of IP Data packets

If the network layer finds the link layer MTU Less than IP The size of the bag ( The network layer can call functions to obtain link layer information ), It doesn't start dividing immediately , I still need to see IP Whether the packet is allowed to be partitioned DF(Don’t Fragment), If slicing is allowed , It will be divided into several ID Same IP package

The network layer of the host can be partitioned , The network layer of the router can also be partitioned , That is to say, the network interface of the router also has MTU Limit

Just like the barrel theory , How much water a barrel can hold depends on the shortest piece , The path of network communication IP Package size , Depending on the source host 、 Destination host 、 In router MTU The youngest one

UDP transmission

about UDP package , If MTU = 1500, that udp payload What is the maximum , So you don't have to split it ?

MTU(1500) = IPHeader(20) + UDPHeader(8) + Data
Data = 1500 -20 - 8 = 1472

If UDP Bag Data <= 1472 Bytes ,UDP package (UDPHeader+Data) In the network layer, there is no need to partition , Directly on the package IPHeader To the link layer

If UDP Bag payload > 1472, that UDP package (UDPHeader + Data) The network layer needs to be partitioned , How to slice ?

The network layer does not replicate once in each partition UDP head , It is a complete UDP Pericardiotomy , add IP Send your hair out , Except for the first segment UDP head , None of the following pieces contain UDP head

The network layer of the destination host receives multiple messages UDP After slicing , The network layer must be reorganized before it can be handed over to the upper layer , Why? ?

Because only the first of multiple partition packages has UDP The head of the , It can be based on UDP The port number in the header informs the corresponding application to take away , However, there is no such thing as UDP head , The transport layer is unable to deliver the fragment package to the correct application . therefore UDP Fragmented packets must be reassembled into a complete network layer UDP package , Give it to the transport layer for processing

According to what is the network layer reorganized ? Remember what it said , It will be divided into multiple pieces ID Same IP Is it a bag ?

If some fragmentation packets are not received by the network layer of the destination host , cause UDP Package reorganization failed , The receiver discards the entire packet , This is a UDP An indication of unreliable transmission . and TCP When a packet error occurs , The packet will be retransmitted , Ensure reliable transmission

about UDP Come on , General choice 576 Bytes of communication


原网站

版权声明
本文为[Programmer community]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202201245251256.html