Open In App

Fragmentation at Network Layer

Last Updated : 08 May, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

In computer networks, data is sent in small units called packets or datagrams. Sometimes, these datagrams are too large to pass through a network with a smaller size limit. To handle this, the datagram is broken into smaller parts is called fragmentation.

  • IPv4 datagram can be as large as 65,535 bytes.
  • Not all networks support such large packets due to their MTU (Maximum Transmission Unit).
  • Fragmentation splits a large datagram into smaller fragments.
  • Each fragment has its own header with necessary information.
  • Fragmentation can be done at the source or by routers along the path.
  • A datagram may be fragmented multiple times if needed.
  • All fragments travel separately and may take different paths to the destination.
  • Reassembly of fragments happens only at the destination.

Why is Fragmentation Needed?

When a large datagram is created by the source computer, it may need to travel through multiple networks to reach the destination. Each of these networks might support different maximum packet sizes. This leads to the need for fragmentation.

Although sending large datagrams is better for efficiency (because headers are not repeated), it’s not always possible due to the reasons below:

Reasons for Fragmentation

  • Different Network Limits: Each network has a Maximum Transmission Unit (MTU) which is the largest packet size it can handle. If a datagram is larger than the MTU, it must be broken into smaller fragments.
  • Unknown Path Information: The source computer doesn’t know the exact route the datagram will take, so it cannot predict the smallest MTU along the path.
  • Header Overhead: Every fragment gets its own header, which wastes bandwidth if too many small fragments are created unnecessarily.
  • Hardware and OS Limitations: Some systems have built-in limits on how much data they can send or receive in one packet.
  • Standard Compliance: Some national or international network standards require packet sizes to be within specific limits.
  • Protocol Differences: Different networks may use different protocols, and each protocol can have different allowed packet sizes.
  • Long Transmission Time for Large Packets: Large packets stay in the network for a longer time, which may delay other packets.
  • Error Handling: If a large packet gets corrupted, the entire packet must be retransmitted. With smaller fragments, only the affected one needs to be resent reducing error impact.
Datagram-Header-Format_
Header Format

The fields that are related to fragmentation and reassembly of an IPv4 datagram are:

Identification

  • This is a 16-bit field in the IPv4 header.
  • It gives a unique number to each datagram sent from the source.
  • The combination of the Identification field and source IP address helps to identify each datagram uniquely.
  • When a datagram is sent, the system copies a counter value into this field and then increases the counter by 1 for the next datagram.
  • If the datagram is broken into fragments, all fragments will have the same Identification number.
  • At the destination, this number helps to match and reassemble the fragments into the original datagram.

Flags

  • This is a 3-bit field in the IPv4 header.
  • First bit: Reserved (not used).
  • Second bit: Called the "Do Not Fragment (DF)" bit.
    • If set to 1, the datagram must not be fragmented.
    • If it cannot be sent due to size, it is discarded, and an ICMP error message is sent to the source.
    • If set to 0, fragmentation is allowed.
  • Third bit: Called the "More Fragments (MF)" bit.
    • If set to 1, it means more fragments are coming.
    • If set to 0, it means this is the last fragment or the datagram was not fragmented at all.

Fragment Offset

  • This is a 13-bit field.
  • It shows the position of the fragment in the original datagram.
  • It tells the destination where to place this fragment when reassembling the full datagram.
  • The offset is measured in units of 8 bytes.

Example:

Let’s say a large datagram has 4000 bytes of data. These bytes are numbered from 0 to 3999. Now, suppose this datagram is too large for the network and needs to be broken into 3 fragments.

Here’s how the fragmentation will happen:

First Fragment

  • Carries bytes: 0 to 1399
  • Fragment Offset: 0/8 = 0
  • Explanation: This fragment starts at the beginning of the data. So its offset is 0.

Second Fragment

  • Carries bytes: 1400 to 2799
  • Fragment Offset: 1400/8 = 175
  • Explanation: This fragment starts from byte 1400. Dividing by 8 gives offset 175.

Third Fragment

  • Carries bytes: 2800 to 3999
  • Fragment Offset: 2800/8 = 350
  • Explanation: This is the last part, starting from byte 2800. Offset becomes 350.
fragmentation
Fragmentation Example

Fragmentation of Datagram

When data travels through a network, it is placed into a unit called a datagram. Every network, whether a Local Area Network (LAN) or a Wide Area Network (WAN), has a limit on the maximum size of data it can handle at a time. This limit is known as the Maximum Transmission Unit (MTU).

Step-by-Step Process

  • Only the data part of the datagram is split into fragments.
  • The header of the original datagram is copied into each fragment. This ensures that each fragment carries the necessary information for reassembly.
  • Fragmentation can take place at:
    • The source computer, or
    • Any router along the path to the destination.

What Happens at Each Router

  • A router receives a datagram that is wrapped inside a frame.
  • The router performs the following tasks:
    1. Removes the frame to access the datagram (decapsulation).
    2. Checks the MTU of the next network. If the datagram is too large, it fragments it.
    3. Encapsulates the datagram or its fragments into a new frame suitable for the next network.
  • The format and size of the frame depend on the physical network the data is being sent to next.

Why Fragmentation May Happen More Than Once

  • The source computer does not know the exact path the datagram will take.
  • It also does not know the MTU of every network along the path.
  • Even if the source knows the MTU, the route may change in a connectionless network like the Internet.
  • Therefore, routers may need to fragment the datagram again if it passes through a network with a smaller MTU.

Reassembly of Fragments

It takes place only at the destination and not at routers since packets take an independent path(datagram packet switching), so all may not meet at a router and hence a need of fragmentation may arise again. The fragments may arrive out of order also. 

Algorithm:

  1. Destination should identify that datagram is fragmented from MF, Fragment offset field.
  2. Destination should identify all fragments belonging to same datagram from Identification field.
  3. Identify the 1st fragment(offset = 0).
  4. Identify subsequent fragments using header length, fragment offset.
  5. Repeat until MF = 0.

Efficiency:

Efficiency (e) = useful/total = (Data without header)/(Data with header) 
Throughput = e * B { where B is bottleneck bandwidth } 

Example: An IP router with a Maximum Transmission Unit (MTU) of 200 bytes has received an IP packet of size 520 bytes with an IP header of length 20 bytes. The values of the relevant fields in the IP header. 

Explanation: Since MTU is 200 bytes and 20 bytes is header size so, the maximum length of data = 180 bytes but it can't be represented in fragment offset since it is not divisible by 8 so, the maximum length of data feasible = 176 bytes. 
Number of fragments = (520/200) = 3. 
Header length = 5 (since scaling factor is 4 therefore, 20/4 = 5) 
Efficiency, e = (Data without header)/(Data with header) = 500/560 = 89.2 % 

Problems Caused by IP Fragmentation

  • Increased Load on Routers: When routers handle IP fragmentation, they must process and generate multiple fragments. This adds extra workload and can reduce overall network performance.
  • Transmission Inefficiency: If any fragment is lost during transmission, the entire original packet needs to be resent and fragmented again. This leads to wasted bandwidth and delays.
  • Out-of-Order Delivery: Fragments may arrive at the destination in a different order. Reordering them takes additional time and computing resources.
  • Routing and Firewall Challenges: Since only the first fragment carries the complete upper-layer headers, fragmented packets can interfere with proper routing and firewall operations.
  • NAT (Network Address Translation) Complications: IP fragmentation can disrupt NAT processes, as essential information might be missing in some fragments, causing issues in translating IP addresses correctly.

GATE Practice Questions -

  1. GATE CS 2013 | Question 65
  2. GATE-CS-2014-(Set-3) | Question 38
  3. GATE-CS-2015 (Set 2) | Question 65
  4. GATE-CS-2016 (Set 1) | Question 63
  5. GATE CS 2018 | Question 37

Next Article
Practice Tags :

Similar Reads