Fragmentation at Network Layer
Fragmentation at Network Layer
Overview
Fragmentation is a process that divides packets into smaller pieces (fragments) so that the resulting
pieces can travel across a link with a smaller maximum transmission unit (MTU) than the original
packet size. The network layer fragments data when the maximum size of a datagram exceeds the
maximum size of data that can be retained in a frame, i.e., its Maximum Transmission Unit (MTU). So
that data flow is not impeded, the network layer separates the datagram received from the
transport layer into fragments. The receiving host reassembles the fragments.
An IP packet cannot be larger than the maximum size allowed by that local network when sent over
the network by a host. The network's data link and IP Maximum Transmission Units (MTUs), which
are typically the same, determine its size. 1500 byte MTUs are standard for modern Ethernet-based
office, campus, or data center networks.
However, packets initially delivered across a network with one MTU may need to be routed over
networks with a smaller MTU (such as a WAN or VPN tunnel). If the packet size in these
circumstances is greater than the lower MTU, the data in the packet must be fragmented (if
possible). This indicates that it is divided into fragments carried in brand-new packets (fragments)
that are equal to or less than the lower MTU. This is known as fragmentation, and when the
fragments arrive at their destination, the data is usually put back together.
Why is Fragmentation Needed?
The datagram generated by the network layer at the source computer must traverse many networks
before arriving at the destination computer. Typically, the source computer favors sending large
datagrams. This is because if the datagram is broken up into smaller pieces, the header will be
repeated for each datagram unit. The header is repeated for every fragmented datagram, wasting
network bandwidth.
However, each network has a cap on the largest packet size it can send during this occurrence. Even
worse, the source computer is unaware of the packet's route to get to its destination. It cannot,
therefore, determine how small each fragmented datagram must be. The reasons for fragmenting a
large datagram into a small fragmented datagram are listed below:
The capacity of data is limited by the hardware and operating system employed.
Conformity with national and international norms.
Each network's protocols allow for different packet sizes.
Large packets occupy the network for a longer time than small packets.
Reduce the mistakes caused by retransmission.
A datagram is a data packet at the network layer. The network layer gets the data from the upper
layer and encapsulates it with a header. So, each datagram now consists of data and a header
containing information about the data and the services involved.
The datagram's header, which can be between 20 and 60 bytes long, contains:
Details about the protocol version being used.
The length of the header (which varies).
The kind of service used to handle the datagram.
The overall length of the datagram.
Fragmentation of Datagram
The maximum size of an IP datagram is 2 − 1 = 65535 bytes, as the IP header has a total length
of 16 bits.
It is performed by the network layer at the destination side, typically at routers. Due to intelligent
(excellent) segmentation by the transport layer, the source side does not require fragmentation.
Specifically, the transport layer looks at the datagram and frame data limits and segments the data
so that it can easily fit in a frame without the need for fragmentation.
The receiver uses the identification (16 bits) field in the IP header to identify the packet. The
identification number for each frame fragment is the same. The receiver uses the fragment offset(13
bits) field in the IP header to identify the series of frames.
The extra header created by fragmentation results in overhead at the network layer.
Fragmentation of Datagram
Every LAN or WAN network has a restriction on the size of the packets that can be transmitted.
The datagram is fragmented if it exceeds this size limit and is created at the network layer.
The data is the only entity in the datagram that is fragmented. The datagram's header is
repeated for each fragmented datagram to ensure that the information inside the header is
kept intact even after fragmentation.
The datagram is fragmented at both the source computer and every router it goes through on
its way to the destination. The network layer delivers the fragmented datagram to the data
link layer, where it is encapsulated in frames and routed to the following router.
The protocol employed by the physical network from whence the frame has arrived
determines the format and size of the received frame at each router. To send the datagram
to the following router, the router decapsulates the datagram from the received frame,
processes it, and then re-encapsulates it. The size and format of the forwarded frame are
determined by the physical network over which the frame must travel to reach the next router
or target computer.
Maximum Transfer Unit (MTU) refers to the maximum number of bytes in a datagram that
can be transferred across a physical network. On the other hand, the source computer has no
idea which path the frame will take to reach the target computer.
As a result, it cannot determine how short the packet needs to be to get through all routers
without fragmenting. Even if the source computer somehow learns the packet's MTU, the
packet may nevertheless abruptly change its path in a connectionless network like the
Internet. Because of this, each router's network layer processes and fragments the datagram.
The overall size of the datagram must be less than MTU when the data link layer encapsulates
it into the frame. Even a fragmented datagram can be further fragmented at the routers if the
network to which it will be sent as a smaller MTU.
Keep in mind that only the data inside a datagram is fragmented, and all of the datagram's fragments
copy the necessary portion of the header.
Process of Fragmentation
RFC 791 specifies IP packet fragmentation, transmission, and reassembly mechanism.
RFC 815 specifies a streamlined reassembly algorithm. The Identification field in the IP header, along
with the foreign and local internet addresses and the protocol ID, and the Fragment offset field in the
IP header, coupled with the Don't Fragment and More Fragments flags, are used for fragmentation
and reassembly of IP packets.
If a receiving host receives a fragmented IP packet, it must put the packet back together and send it
to the higher protocol layer. Reassembling is supposed to occur in the receiving host, but in reality, it
might be carried out by an intermediate router. For instance, network address translation (NAT) can
need to reassemble fragments to translate data streams.
Identification Field (16 bits):- It is used to recognize fragments of the same frame.
Fragment Offset Field (13 bits):- It is used to determine the sequence of pieces in the frame. It often
denotes the number of data bytes preceding or preceding the fragment. Maximum fragment offset
possible
= 65535 − 20 = 65515,
where 65535 is the maximum datagram size, and 20 is the minimum IP header size. As a result, a
fragment offset requires:
2
=8
2
As a result, all fragments except the last should have data in multiples of 8, so that fragment offset
belongs to N.
More Fragments Field (MF):- This field tells if there are more fragments ahead of this fragment, i.e.,
if MF = 1, there are more fragments ahead of this fragment, and if MF = 0, it is the last fragment.
Don’t Fragment Field (DF):- If we don't want the packet to be fragmented, we set DF to 1.
IP Fragmentation Examples
The concept of IP fragmentation is best explained with the aid of examples.
Step 1:
Step 2:
The router determines the amount of data that should be transmitted in each fragment. The router
is aware of:
The quantity of data delivered in a single fragment is chosen in such a way that:
The router determines a maximum of 176 bytes of data that can be sent in one fragment.
This is because it is the highest figure that is less than MTU and a multiple of 8.
Step 3:
The router splits the original datagram into three parts where:
Step 4:
Preventing Fragmentation
A node can prevent fragmentation of packets by setting the Don't Fragment (DF) flag in such packets
to 1. Packets that must be fragmented but contain the DF bit are ignored. This is described in depth
by the PMTUD concept.
If any packets need to be fragmented as they travel to their destination, the router concerned discards
them as the DF bit is set. The router should then return to the source and ICMP error of type 3:
'Destination Unreachable,' code 4: 'Fragmentation required, and DF set.' This message should include
a 16-bit *Next-Hop MTU *field containing the value, in bytes, of the biggest packet that may be routed
without fragmentation to the next hop (including the IP header). It also includes the IP header of the
fragmented packet and 64 bits (8 bytes) of its payload, which would generally contain the transport
layer header's source and destination port fields. In the RFC, this ICMP message is referred to as a
Datagram Too Big message.
When the sending host receives an ICMP message, it will generally reduce the size of packets
forwarded to the destination based on the Next-Hop MTU field value in the message. The host should
store this path MTU information in some way, which generally (as indicated by the RFC) takes the form
of a particular routing table entry for the destination address. The reduced path MTU should be
communicated to the transport layer protocol (indicated in the ICMP message by the IP header of the
rejected packet). The application that sent the data (identified by the wasted packet's 64-bit payload
in the ICMP message) should be notified that the original packet was discarded.
This operation is repeated if a lower MTU is reached farther along the path.
Keep in mind that PMTUD functions separately in each path direction between two hosts (if both hosts
support it and have it enabled). These pathways (as well as the MTU of the networks they are a part
of) could differ.
Reassembly Algorithm
Since packets take distinct paths (datagram packet switching), the reassembly of Fragments only
occurs at the destination and not at routers. As a result, all packets may not collide at a router, and
fragmentation may be required once more. Additionally, the fragments could show up out of order.
Algorithm
1. The destination should be able to tell that the datagram is fragmented based on the MF,
Fragment offset field.
2. From the Identification field, the destination should identify all fragments belonging to the
same datagram.
3. Determine the first fragment (offset = 0).
4. Using header length and fragment offset, identify subsequent fragments.
5. Continue until MF = 0.
Example:- An IP packet of 520 bytes with an IP header of 20 bytes was received by an IP router with a
Maximum Transmission Unit (MTU) of 200 bytes. The values of the necessary IP header fields.
Solution:
Since the MTU is 200 bytes and the header size is 20 bytes, the maximum data length is 180 bytes.
However, since this length cannot be expressed in a fragment offset since it is not divisible by 8, the
greatest length of data that is practical is 176 bytes.
e(efficiency) is given by (Data without header)/(Data with header) is equal to 500/560 = 89.2 % .
Another issue with IP fragmentation is that if any fragment is dropped during transmission, the whole
process has to start again. The original packet, which is discarded during fragmentation, must be
retransmitted, fragmented, and reassembled. This makes the fragmentation process inefficient and
resource-heavy. For this reason, network administrators avoid IP fragmentation whenever possible.
IP fragmentation can also cause disordered packet delivery, which results in the need to reorder
packets. This is most common when only some packets are fragmented, or if link aggregation or other
path-splitting technologies are in use. (IP fragmentation can cause problems when used in conjunction
with path-splitting technologies because the fragmentation process can result in packets being
transmitted over different paths; causing them to arrive at their destination out of order.)
Out-of-order packet delivery and dropped fragments can cause other common issues. As only the first
fragment contains the high-layer headers, fragmentation can cause problems with routing, firewall
functionality, and NAT (Network Address Translation) functionality.
2. Inefficient transmission: If any fragments are dropped during transmission, the original
packet must be retransmitted and fragmented again, making the process highly inefficient
and resource-intensive.
3. Disordered packet delivery: If packets are delivered out of order, they may need to be
reordered, which can be time-consuming and require additional resources.
4. Routing and firewall issues: Because only the first fragment contains the high-layer headers,
fragmentation can cause issues with routing and firewall functionality.
5. NAT issues: Fragmentation can cause problems with NAT (Network Address Translation)
functionality.