<> What is? MTU
Maximum Transmission Unit, abbreviation MTU, The Chinese name is ： Maximum transmission unit .
<> Which layer of network protocol is located ?
OSI Model function TCP/IP protocol family
Application layer file transfer , E-mail , File service , Virtual terminal TFTP,HTTP,SNMP,FTP,SMTP,DNS,Telnet
Presentation layer data formatting , Transcoding , No protocol for data encryption
There is no protocol for the session layer to cancel or establish contact with other contacts
The transport layer provides an end-to-end interface TCP,UDP
The network layer routes packets IP,ICMP,RIP,OSPF,BGP,IGMP
The data link layer transmits frames with addresses and error detection functions SLIP,CSLIP,PPP,ARP,RARP,MTU
The physical layer transmits data on the physical media in the form of binary data ISO2110,IEEE802,IEEE802.2
As can be seen from the above MTU At the data link layer .MTU The limitation is the data link layer payload（ Payload ）, That is, the size of the upper layer protocol , for example IP,ICMP,RIP etc.
<>MTU Value action
for instance ： Do you surf the Internet on your home phone , Using a router , The router connects to the telecommunication network , Then visit www.google.com, An Ethernet data frame from your mobile phone passes through the following paths in total ：
mobile phone -> Router -> Telecommunications room -> The server
among , Each node has one MTU value , as follows
1500 1500 1500 mobile phone -> Router -> Telecommunications room -> The server
Suppose I put my cell phone MTU The maximum value is set to 1700, Then sent an oversized ip data packet （2000）, At this time, it will be disassembled when transmitted over the Internet 2 Package , One 1700, One 300, Then add header information for transmission .
1700 1500 1500 mobile phone -> Router -> Telecommunications room -> The server
The router received a 1700 Frame of , It is found that it is greater than the maximum value set by yourself ：1500, If IP package DF Flag bit is 1, That is, subcontracting is not allowed , Then the router directly discards the packet , It won't reach the telecom room at all , You can't get to the server , therefore , Here we'll find ,
MTU In fact, it is the control value of each node , As long as it is a data frame greater than this value , Or choose slicing , Or throw it away .
<> Why 1500?
In fact, a standard Ethernet data frame size is ：1518, Header information has 14 byte , Tail checksum FCS Occupied 4 byte , Therefore, the size of data transmitted by the upper layer protocol is ：1518 - 14 - 4
= 1500, that ,1518 Where does this value come from ?
<> Suppose you take a larger value
hypothesis MTU Value sum IP Consistent packet size , One IP The packet size is ：65535, Then add the Ethernet frame header and tail , The size of an Ethernet frame is ：65535 + 14 + 4 =
65553, It looks perfect , The sender does not need to unpack , The recipient also does not need to restructure .
So suppose our current bandwidth is ：100Mbps
, Because Ethernet frame is the smallest identifiable unit in transmission , Mobile network type 0101 The corresponding optical signal , So we can only send one Ethernet frame in one bandwidth at the same time . If multiple messages are sent at the same time , Then the opposite end cannot re compose an Ethernet frame , stay
100Mbps In bandwidth （ It is assumed that there is no loss in the middle ）, Let's calculate the time it takes to send this frame ：
( 65553 * 8 ) / ( 100 * 1024 * 1024 ) ≈ 0.005(s)
stay 100M It is necessary to transmit a frame under the network 5ms, That is to say, this 5ms Other processes cannot send any data . If it's an earlier phone call , The network speed is only 2M In case of ：
( 65553 * 8 ) / ( 2 * 1024 * 1024 ) ≈ 0.100(s)
100ms, This is a nightmare . Actually, it's like a traffic light , The time should be set reasonably , Alternate traffic , Otherwise, if it's always green in the same direction , Then the other direction will be blocked into Xiang .
<> Since you're old, you can't , Can you set it smaller ?
hypothesis MTU The value is set to 100, Then the transmission time of a single frame , stay 2Mbps Bandwidth required
( 100 * 8 ) / ( 2 * 1024 * 1024 ) * 1000 ≈ 5(ms)
Time is acceptable , The problem is , No matter MTU What is the setting , The size of Ethernet header and footer is fixed , All 14 + 4, So in MTU by 100 When , The transmission efficiency of an Ethernet frame is ：
( 100 - 14 - 4 ) / 100 = 82%
Written as a formula is ：( T - 14 - 4 ) / T, When T When it goes to infinity , Efficiency approach 100%
, that is MTU The larger the value of , Highest transmission efficiency , However, based on the transmission time of the previous point , Let's make a compromise , Since head and tail are 18, Then round it up 1500, The total size is 1518, transmission efficiency ：
1500 / 1518 = 98.8%
100Mbps Transmission time ：
( 1518 * 8 ) / ( 100 * 1024 * 1024 ) * 1000 = 0.11(ms)
2Mbps Transmission time ：
( 1518 * 8 ) / ( 2 * 1024 * 1024 ) * 1000 = 5.79(ms)
Overall, the time was acceptable
<> The minimum value is limited to 64
This is actually related to the collision of Ethernet frames in half duplex
1518 This value is a compromise value in consideration of transmission efficiency and transmission time , And because there are too many nodes in the current network link , Of one of the nodes MTU If the value is different from other nodes , It is easy to bring the problem of unpacking and reorganization , It may even result in failure to send .