简体   繁体   中英

Why Fragmentation is Done at IP why not for TCP/UDP

I am looking for the reason Why Fragmentation is Done at IP level but why not for TCP/UDP.

Suppose say my frame looks like this |MAC|IP|TCP|Payload|FCS. the whole size if say for eg: 1600. PathMTU happens here, why fragmentation is implemented @ IP level is my question and why not implemented @ TCP/UDP level/code.

Thank in advance.

That's exactly what multiple layers in the TCP/IP stack and in ISO/OSI model are for. TCP/UDP are transport protocols and they shouldn't care of fragmentation - it's not their problem. The IP level deals with the network and it deals with fragmentation since size of fragment depends on the network properties. The layer that has best conditions for solving the problem does solve it.

Some TCP implementations also determine the MTU and size their segments to avoid fragmentation as well. Doing so improves reliability under lossy conditions, as any TCP segment that is received can be acknowledged and not retransmitted. Only lost TCP segments are retransmitted. In contrast, if any IP datagram fragment is lost, then no useful information is received.

Layer-4 (TCP/UDP) comes into picture only at the end points (sender/receiver). layer-3 (IP) comes into picture per hop basis.

MTU is a property of the link, but fragmentation on the basis of this link property (MTU) always done at IP layer on a router (hop)

Now the link between each hop can be of different bandwidth, so at each hop it has to be decided how to forward the packet to the destination. As MTU is the maximum amount of data that can be pushed onto the link and if it it smaller than the size of packet to be send out, One has to fragment it into smaller chunks to accommodate onto the link.

As fragmentation and reassembly has many drawbacks like 1. small increase in CPU and memory overhead 2. more overhead per packet due to addition of fragment headers 3. If one fragment is lost sender has to transmit the entire packet

To solve above issues, 1. Path MTU Discovery can be used. 2. In Layer 4, TCP MSS-clamping can be used.

If fragmentation were performed on higher layers (TCP, UDP, etc.) then this would make fragmentation/reassembly redundantly implemented (once per protocol); if fragmentation were performed on a lower layer (Ethernet, ATM, etc.) then this would require fragmentation/reassembly to be performed on each hop (could be quite costly) and redundantly implemented (once per link layer protocol). Therefore, the IP layer is the most efficient one for fragmentation.

It makes less sense to fragment TCP than it does to fragment UDP. Since TCP provides a reliable segmentation/reassembly/retransmission mechanism, one can just send smaller TCP segments and avoid the whole necessity for fragmentation (this is what d3jones is talking about).

In UDP, however, fragmentation still makes sense. You can send a single UDP segment greater in length than the MTU. The IP layer will fragment it correctly and invisibly. The application developer doesn't have to determine the MTU or anything about the network in order to code the application layer protocol.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM