The network layer function is to provide end-to-end communication between the two computers where the source and the destination computers may be in the different networks. When the source and destination computers communicate with each other the packet from the source has to travel through several LANs or WANs to reach the destination.
As the packet travels across different LANs and WANs both source and destination require a universal identification number (logical address) so that source and destination are recognized universally. It is the responsibility of the network layer to provides a logical address to the two communicating computers.
In this section, we will study the function of the network layer at the source computer, destination computer, and across all the intermediate nodes (switches, routers, and other connecting devices) in the network.
Network Layer Functions
- Network Layer Function at Source Computer
- Network Layer Function at Each Router
- Network Layer Function at Destination Computer
Function at Source Computer
Whenever the source computer wants to send data to the destination computer, the network layer at the source computer receives this data from its upper layer. This data includes some other information such as the length of the data, the protocol ID, the type of service used, and the logical address of the destination computer.
Now the network layer process all the received information from its upper layer to create packets and find the logical and physical address of the next hop in the network. So, the functions of the network layer at the source computer are packetizing, identify the logical address of the next hop in the network, identify the physical address of the next-hop and if required fragment the datagram.
1. Packetizing
In packetizing, the data received from the upper layer is encapsulated to form a datagram. In this process, a header is added to the data which gives information such as the length of the data, the ID of the protocol used, the logical address of the source computer, and the destination computer.
The upper layer only provides the logical address of the destination computer, the logical address of the source computer is added at the network layer itself. If the fragmentation is applied to the data, then the header also carries information about the fragmentation. Apart from this, a checksum is calculated over the header of the datagram.
2. Identifying Logical Address of Next Hop
The header of the datagram has information about the logical address of the source and the destination computer. But if the destination computer is not present in the same network as of source, then this datagram has to pass through several networks before reaching the final destination.
While passing through these networks the datagram has to pass through various routers. So, the datagram at the network layer of the source computer requires the logical address of just the next router connected to the network. The network layer of the source computer does not have this information so it refers to the routing table to get the logical address of the next router.
3. Identifying Physical Address of Next Hop
Though the network layer has identified the logical address of the next-hop or router to which the datagram has to be delivered but, it is not the responsibility of the network layer to deliver the datagram to the next router.
Instead, it is the data link layer that will deliver the datagram to the next router and the data link layer requires the physical address of the router. So, the network layer again refers to a routing table to map the logical address of the next router to its physical address.
For identifying the physical address of the next hop, the network layer uses a protocol ARP (Address Resolution Protocol).
4. Fragmentation
There is a limit over the size of the datagram to be delivered to the data link layer. If the size of the datagram prepared by the network layer is larger than the expected size then it has to be fragmented. While fragmenting the datagram, the information present in the header of the datagram must be preserved. So, the header is repeated for each fragmented datagram.
In addition to the information present in the header, some more information is added which will help in recognizing the position of each fragment in the whole datagram.
Network Layer Function at Router
The network layer of the router has to interact with the two data link layers. One with the data link layer of the incoming interface and the other with the data link layer of the outgoing interface. The network layer of the router receives the datagram from the data link layer of the incoming interface, if required this received datagram is fragmented, and then it is delivered to the data link layer of the outgoing interface.
Now to deliver the datagram to the data link layer of the outgoing interface the network layer of the router needs the logical and physical address of the next router. It is the responsibility of the network layer of the router to determine the logical and physical address of the next router or hop to which datagram has to be delivered.
So, the function of the network layer at each router is to identify the logical and physical address of the next-hop and if required it has to fragment the received datagram. But before all this, the network layer checks the validity of the received datagram by verifying the information present in the header of the datagram.
Network Layer Function at Destination Computer
The destination computer is the last node for the datagram as from here the datagram is not forwarded to any other node. So, the network layer at the destination computer has very little to do.
First, the data is validated by verifying the information present in the header of the datagram. After validation of the datagram, data is extracted from it and stored. The validation of the datagram also reveals the fragmented information. So, the network layer holds till all the data fragments reach the destination.
The entire received data is reassembled and then it is delivered to the upper layer of the destination. The network layer also sets up a reassembly timer, if this timer expires then the network layer at the destination destroys all the received fragments, sent an error message to the source, and request for resending the data.
This entire scene of fragmentation is not known to the upper layer as the network layer does not send data in the pieces as it receives, instead, it assembles the entire data and forwards it to the upper layer.
So, this is all about the functioning of the network layer at the source, intermediatory routers, and at the destination computer. We have seen how the network layer is efficient in establishing end-to-end communication between two computers across several networks.
Leave a Reply