Fragmentation is a technique implemented on a datagram at the network layer if the size of the datagram is larger than the size of the datagram that the corresponding network can forward. This technique involves the division of the large size datagram into smaller fragments. In this section, we will study all about the fragmentation of datagram in the network layer.
Fragmentation in Networking
In our previous content, we have discussed the functions of the network layer where we have seen that the network layer receives the data to be transmitted from its upper layer along with some other pieces of information such as the length of data, ID of the protocol used, type of service logical address of the destination, and the logical address of the destination computer.
The network layer encapsulates this data by adding the header to this data and forms a datagram. Now the datagram is formed and further, we need to know why this datagram is fragmented.
Why Fragmentation is Needed?
The datagram created by the network layer at the source computer has to pass through several networks before it reaches the destination computer. Usually, the source computer prefers to send the datagrams of large size.
This is because if the datagram is split into small fragments, then for each fragmented datagram unit the header is repeated. This repetition of the header for each fragmented datagram wastes the network bandwidth.
But over this event, every network has a certain limit over the maximum size of the packet it can forward. The source computer is even not aware of the path the packet will take to reach the destination. So, it is unable to decide how small each fragmented datagram must be.
The limit over the size of a packet has several reasons behind it. We have discussed those reason in the list below:
- Hardware and operating system used puts a limit on the size of data.
- Protocols at each network allow different packet sizes.
- Compliance with the national and international standards.
- Large packets occupy the network for a long period as compared to small packets.
- Reduce the error induced during retransmission.
These are the reasons behind the fragmentation of a large size datagram in a small fragmented datagram. Before elaborating on fragmentation let us discuss the datagram on which fragmentation is implemented.
What is Datagram?
The data packet at the network layer is referred to as a datagram. The network layer receives the data from the upper layer, adds a header to it to encapsulates it. So, now each datagram consists of data along with the header which has information regarding the data and the services involved.
The header of the datagram can be from 20 bytes to 60 bytes and carries information about the version of the protocol used, length of the header (it is required as the length of the header varies), type of service used to handle the datagram, total length of the datagram.
Fragmentation of Datagram
As we know every LAN or WAN network has a limit over the size of the packet it can transmit. If the datagram created at the network layer is larger than this size limit then the datagram is fragmented. Only the data in the datagram is fragmented. Still, information inside the header of the datagram must be preserved even after fragmentation and for this, the header is repeated for each fragmented datagram.
The datagram is fragmented at the source computer, and also at each router, the datagram passes through to reach the destination. The fragmented datagram at the network layer is delivered to the data link layer where it is encapsulated in frames and then it is forwarded to the next router.
The format and size of the received frame at each router depend on the protocol used by the physical network from where the frame has arrived. The router decapsulates the datagram from the received frame, processes the datagram, and encapsulates it to forward it to the next router. The format and size of the forwarded frame depend on the physical network which the frame has to travel to reach the next router or the destination computer.
The maximum number of bytes in the datagram that can be communicated over the physical network is termed as Maximum Transfer Unit (MTU). However, the source computer is not aware of which path the frame is going to travel to reach the destination computer.
So, it is unable to decide how small the packet must be so that it can travel through all the routers without fragmentation. Even if anyhow the source computer gets to know about the MTU of the packet, but the packet may change its path suddenly in a connectionless network such as the Internet. That’s why the datagram is processed and fragmented at the network layer of each router.
The data link layer when encapsulates the fragmented datagram into the frame the total size of the datagram must be less than MTU. Even the fragmented datagram can be further fragmented at the routers if the network to which it will be forwarded has an even smaller MTU.
Remember while fragmenting a datagram, only the data inside the datagram is fragmented and the required part of the header is copied by all the fragments of the datagram.
The fields of the datagram header that are copied by all the fragmented datagram are the identification field, flag field, and fragmentation offset field.
Identification Field: This is a 16-bit field whose values identify a datagram at the source computer. The identification value’s combination with the source’s IP address identifies the datagram uniquely through the network. If a datagram is fragmented then this identification value is copied to the header of all the fragmented datagrams. This means all fragments have the same identification number as of original datagram.
Flag Field: The flag field is a three-bit field whose fist bit is reserved. The second bit is referred to as do not fragment bit, if the value of this bit is 1 then the routers in the path must not fragment this datagram further and if the value of this bit is 0 then the datagram can be fragmented. The third bit is referred to as more fragment bit, if it has value 1 then this fragmented datagram is not the last fragment of the datagram and if it has value 0 then it means this is either the last fragmented datagram or the only fragment of the datagram.
Fragmentation Offset: This field is used to recognize the position of a particularly fragmented datagram in the whole datagram. This is a 13-bit field that specifies the offset of data in the whole datagram. The value of the offset field is measured in the unit of 8 bytes.
So, this is all about fragmentation, we have seen its necessity, on what it is implemented, how it is implemented.