How to avoid IP Fragmentation? Part 1

IP Fragmentation occurs when the packets want to pass through a link with a smaller maximum transmission unit (MTU) than the original datagram size. The 16-bit identification field, 3-bit Flags field that includes more fragments, and don’t fragment bits and the 13-bit fragment offset fields in the IP protocol header are used for fragmentation and reassembly of IP datagrams.

 

In IPv4, if a router receives a protocol data unit (PDU) larger than the next hop’s MTU, it has two options:

  • Drop the PDU and send back an ICMP Destination unreachable, Fragmentation required and DF flag set error message (Type 3, code 4) (If the DF bit is set)
  • Fragment the IP packet and send it over the link with a smaller MTU.

 

IP Fragmentation though necessary, is expensive on the network resources. Let us assume that a packet of size 1481 is constructed, IP will add a header of minimum 20 bytes that will make the total packet size to 1501 bytes. If the link MTU is 1500 bytes then this packet should be fragmented into 2 parts, and each part will have its own headers. The first fragment will have 1480 bytes of data and remaining headers, while the second fragment will have only 1 byte of data and rest all headers. This is an overhead and takes up a lot of network bandwidth affecting other application data.

Also in case of reliable protocols like TCP, even if one fragment is lost, retransmission is required for all the previous fragments of the same packet. This is the main reason why fragmentation is not desirable and is usually avoided.

 

Fragmentation can be avoided using two different methods, which work in two different segments of the network.

 

Adjust MSS: Adjusting Maximum segment size is a method for avoiding fragmentation at the source.

When a TCP session is started from the client, a SYN packet is the first packet that is sent. This SYN packet contains a send MSS value, which tells the other end that this client can only receive packets of size equal to or less than the send MSS value. The smaller value between TCP buffer size and interface MTU is selected and 20 is subtracted from this value (IP header length). So if the TCP buffer size is 5000 and link MTU is 1500, then send MSS will be 1500-20=1480.

The other end on receiving the SYN packet replies with a SYN and ACK. This SYN contains the send MSS value of the other end. The send MSS value of client tells the server that client cannot accept a packet size of more than send MSS value. Thus the TCP on the server will segment the packets with size not more than the send MSS of the client. This will then be encapsulated in the IP header of size 20 bytes and will be sent without being fragmented at the source. Since the TCP never gives a segment of size larger than (MTU – 20) to the IP, hence IP never has to fragment the packets.

This technique is an inherent part of TCP and always works behind the scene. It only works in the cases where client and server are directly connected, or when the interface MTU across the network is same.

But what will happen in below network scenario?

IP Fragmentation

Host A will send a SYN packet with send MSS of 1480, Host D will reply by sending a SYN packet with send MSS of 1480. Now when Host A sends a packet with size of 1480, it will be encapsulated within the IP header and the resulting packet size will be 1500, which is equal to the interface MTU between the Host A and Host B. But when the packet reaches at Host B, the outgoing interface MTU is 512, which is less than the incoming interface MTU of 1500, at this point Host B has to fragment the packet. Thus MSS solution for avoiding fragmentation fails here. Here comes our second method for avoiding fragmentation, Path MTU Discovery. We will discuss this in part 2 of the article.

Facebook Comments

Share this post

Post Comment