Tcp – Why do transport layer do data chunking. If there is fragmentation in Network Layer

ipv4layer3layer4tcp

I just curiously wanted to know about the question regarding L4, L3 Data Chunks, IP Fragmentation :

  1. Data chunking happened at Layer 4(Transport, TCP), and
  2. Fragmentation at Layer 3(Network, ipv4)

According to Wikipedia, data chunk happens at L4: "Transmission Control Protocol accepts data from a data stream, divides it into chunks, and adds a TCP header creating a TCP segment"
Source: https://en.wikipedia.org/wiki/Transmission_Control_Protocol#TCP_segment_structure

Also, there is fragmentation happening at Layer 3(Network)..
Now there are two questions here-

  1. I believe data chunking happening at L4 because of the MTU size limit exceeded, then why there is another process called Fragmentation?

  2. If data chunking is happening or not, there will be a sequence number for each TCP segment.. how can a TCP segment associated with each packet fragment in L3 for successful reassembly at receiver side?

Please see picture(for second query)-
enter image description here

Any help is greatly appreciated..

Best Answer

The transport-layer protocol needs to make sure that data can be properly packetized. It it lacks support for that (like UDP), the application layer needs to take care of that.

IP fragmentation in the network layer is an mechanism primarily intended to enable forwarding when the MTU within the path shrinks. It is not intended as the primary sizing mechanism due to its limitations:

  • IP fragmentation only supports 64 KB packets, various transport-layer protocols support any stream length
  • fragmentation is very inefficient when packets are lost - the network layer (IP) doesn't even try to recover lost fragments or even packets, and since the whole packet doesn't makes it through the stack when a single fragment is lost, the transport-layer protocol or the application would need to retransmit the entire packet
  • the transport layer can do quite a few things more than simple data chunking, like sub-addressing (ports), stream control, congestion control, error recovery, packet/segment reordering

Reassembly of fragmented packets happens at the network layer, before data is passed up the stack to the transport-layer protocol.

Not all transport-layer protocols support data segmentation (e.g. UDP doesn't), so datagrams too large for the MTU need to be fragmented or sent with smaller data chunks.

Initially, fragmentation was the strategy to deal with varying MTU sizes across a large network but due to increasing router load and being generally inefficient that has largely been replaced by path MTU discovery. For IPv6, routers do not support fragmentation at all, they drop oversized packets (the sending host may fragment though).