Fragmentation
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
The Flags field in the IPv4 header is 3 bits long.
The first bit is reserved and not used.
The second bit is 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. If set to 0, fragmentation is allowed.
The third bit is the More Fragments (MF) bit. If set to 1, more fragments are coming. If
set to 0, this is the last fragment or the datagram was not fragmented.
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 1: 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.
Example 2: 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. Calculate the
values of the relevant fields in the IP header.
Given
MTU = 200 bytes
Total IP packet size = 520 bytes
IP header = 20 bytes
Step 1: Calculate Data Size
Total data = Total packet − Header
= 520 − 20 = 500 bytes
Step 2: Maximum Data per Fragment
MTU includes header, so:
Max data per fragment = 200 − 20 = 180 bytes
Fragment data must be divisible by 8 (because offset is in units of 8 bytes)
Closest multiple of 8 ≤ 180 = 176 bytes
Step 3: Number of Fragments
Total data = 500 bytes
Split into chunks of 176:
176 + 176 + 148 = 500
So, 3 fragments
Step 4: Fragment Details
Fragment 1
Data = 176
Header = 20
Total length = 176 + 20 = 196
Offset = 0
MF (More Fragments) = 1 (more fragments coming)
Fragment 2
Data = 176
Header = 20
Total length = 196
Offset = previous data / 8 = 176 / 8 = 22
MF = 1
Fragment 3 (last)
Remaining data = 500 − 352 = 148
Total length = 148 + 20 = 168
Offset = (176 + 176) / 8 = 352 / 8 = 44
MF = 0 (last fragment)
Step 5: Header Length = 5
IP header length is measured in 32-bit words (4 bytes)
So:
20 / 4 = 5
Fragment Data Total Length Offset MF
1 176 196 0 1
2 176 196 22 1
3 148 168 44 0
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.
Reassembly of Fragments
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.