How do IP fragmentation and reassembly work?

Data is transported through a network using IP packets, each of which consists of a header and a data segment. There are two versions of IP packets: IPV4 and IPV6. In this Answer, we will look at IPV4.

The IPV4 packet has a maximum size of 65,53565,535bytes. Since the maximum field total length is1616 bits in the IPV4 header, the maximum size is 2161=65,5352^{16}-1=65,535.

The minimum header size is2020bytes.

Keeping this in mind, the maximum data that can be sent in a packet is65,53520=65,51565,535-20 = 65,515.

Why is fragmentation needed?

IPV4 can be used in many data link layers, each having its own maximum frame size or Maximum Transmission Unit (MTU). The MTU is the largest packet a data link layer can send, including its header. The MTU values of some commonly used data link layers are shown below.

Data link layer

MTU

Ethernet

1,500 bytes

IEEE 802.11 WiFi

2,304 bytes

Token Ring (802.15.4)

4,464 bytes

FDDI

4,352 bytes

As we can see in the table above, all of the MTU values are significantly smaller than the maximum size of an IPV4 packet. Therefore, to pass data safely through the network, the large IPV4 packet is fragmented into two or more IPV4 packets.

Fragmentation

Fragmentation is the breaking of an IPV4 packet that exceeds the MTU of the data link layer into smaller IPV4 packets. Fragmentation is a process performed by the sender or the forwarding routers.

Fragmentation relies on some of the fields in the IPV4 header, which are as follows:

  • Identification: To identify fragments, we use a 16-bit field.
    When the packet is fragmented, the identification field is copied into the fragmented packet headers to help determine that the packet belongs to a specific frame.

  • Fragment offset: This is a 13-bit field that is used to order the data into fragments; it helps in the rearranging part. As discussed above, the largest data offset can be65,51565,515, but we need1616 bits to represent this number. The solution is to scale down by introducing a scaling factor. As we can see below, the scaling factor is equal to88. This means all the fragments except the last one should have data in multiples of88.

  • MF (More fragments): It is a one-bit flag that specifies if there are more fragments of the frame. All the fragmented packets have this flag set to 11 except the last packet which sets this flag to 00. This flag along with the fragment offset helps the receiver identify the order during reassembly.

  • DF (Don't fragment): It is a one-bit flag that tells the routers whether to fragment the packet or not. If it is set to 00 then the packet can be fragmented.

Reassembly

The reassembly process is carried out at the destination. This is because packets take different routes through the network and arrive at different times.

The steps of the process of reassembly are as follows:

  1. The destination identifies that the packet has been fragmented using the MF and fragment offset fields.

  2. The destination categorizes the incoming packets according to their identification fields. Two packets with the same identification field are put in the same category.

  3. The packets within a category are sequenced using the MF and fragment offset. First, the packets with MF equal to 11 are sorted in ascending order based on their fragment offset values. Then the packet having an MF equal to 00 and a fragment offset not equal to 0 is placed at the end, since it's the last packet.

Example

Consider an example where a packet with a size of 4,2504,250 bytes arrives at an IP router with an MTU of 1,5001,500. As the packet size is greater than that of the MTU, it needs to be fragmented. The process of fragmentation is shown below:

1 of 5

Test yourself

Q

Given the sample MTU size of 100 and an IP packet of size 999, how many fragments will be created?

A)

11

B)

12

C)

13

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved