The reference model is an ideal data transfer model. OSI helps to illustrate the dependence of some protocols on others, and who drives whom, but it cannot dictate how they function.
MTU and OSI model
The transport layer protocols (TCP or UDP protocols), which use the network layer to send packets, consider that the maximum size of the data field of an IP packet is 65535 , and therefore can send it a message of such length for transport. The functions of the IP layer include splitting a message that is too long for a specific type of network component into shorter packets with the creation of corresponding service fields needed for the subsequent assembly of fragments into the original message.
In most types of local and global networks, such a concept is defined as the maximum size of a frame or packet data field into which the IP protocol should encapsulate. This value is usually called the maximum transfer unit - Maximum Transfer Unit, MTU. Ethernet networks have an MTU of 1500 bytes, FDDI networks have 4096 bytes, and X.25 networks most often work with a 128 byte MTU.
MTU is a data link layer characteristic of the OSI model. If the IP wants to send a datagram that is larger than the link level MTU, fragmentation is performed (fragmentation), and the datagram is split into smaller parts (fragments). Each fragment must be less than MTU.
The top level always knows about the bottom . When the IP layer receives an IP datagram that needs to be sent, it determines to which local interface the datagram is sent (or routed), and requests the interface to tell the size of its MTU. IP compares the MTU with the size of the datagram and, if necessary, performs fragmentation. Fragmentation can be performed both on the sending host and on the intermediate router.
Theoretically, the maximum size of an IP datagram is 65,535 bytes, due to the 16-bit full-length field in the IP header.
The user @Smithson gave you the correct answer, because IP works not only on Ethernet, it has its own size on each network.
Why do I need MTU?
When two computers communicate on the same network, the MTU for this network is important. However, when two computers communicate on different networks, each intermediate channel may have a different MTU. In this case, the important thing is not the MTU of the two networks to which the computers are connected, but the smallest MTU of any data channel between two computers. It is called a transport MTU (path MTU).
The transport MTU between any two hosts may not be permanent. MTU depends on the current channel load. It also depends on the route. The route may be asymmetric (the route from A to B may not be at all the fact that the route is from B to A), so the MTU may not be the same for these two directions.
TCP has MSS
There is such a thing as the maximum TCP Segment Size (MSS), which defines the maximum amount of data that a host wants to receive in a single TCP / IP datagram.
Moreover, this TCP / IP datagram may be fragmented at the IP level.
The MSS value is sent as an option to the TCP header only in the TCP SYN segment. Each side on a TCP connection reports its MSS value to the other side. The host sender is required to limit the size of the data in a single TCP segment to a value less than or equal to the MSS reported by the recipient host.
The mechanism of the MSS is as follows: when creating a TCP connection, the machine determines the size of the outgoing interface buffer and the MTU of this interface. Then these two numbers are compared and the smallest is selected. Here it should be noted that the MTU is chosen by the number according to the formula MTU minus 40 bytes, to account for TCP and IP headers. Then the selected number is compared with the size of the MSS transmitted by the receiving party, and the smallest value is again selected. MSS operation example:
- Machine A compares the size of its interface buffer (16 Kbytes) with the MTU value of this interface (1500–40 = 1460 bytes) and uses the smallest number as MSS when sending it to machine B.
- Machine B takes the MSS value of Machine A (1460) and compares it with the MTU value of its outgoing interface (4462 - 40 = 4422 bytes).
- Machine B chooses the smallest of the resulting values ​​(1460) as the MSS value when sending TCP segments to machine A.
- Machine B compares the size of its interface buffer (8 KB) with the MTU value of this interface (4462-40 = 4422 bytes) and uses the smallest number as the MSS when sent to machine A.
- Machine A takes the MSS value of Machine B (4422) and compares it with the MTU value of its outgoing interface (1500 - 40 = 1460 bytes).
- Machine A chooses the smallest of the resulting values ​​(1460) as the MSS value when sending TCP segments to machine B.
Thus, the MSS on both sides is set to 1460 bytes, this is the most common situation.