Network layer is the third layer in the OSI model of computer networks. It’s main function is to transfer network packets from the source to the destination. It is involved both at the source host and the destination host. At the source, it accepts a packet from the transport layer, encapsulates it in a datagram and then deliver the packet to the data link layer so that it can further be sent to the receiver. At the destination, the datagram is decapsulated, the packet is extracted and delivered to the corresponding transport layer.
- Main responsibility of Network layer is to carry the data packets from the source to the destination without changing or using it.
- If the packets are too large for delivery, they are fragmented i.e., broken down into smaller packets.
- It decides the root to be taken by the packets to travel from the source to the destination among the multiple roots available in a network (also called as routing).
- The source and destination addresses are added to the data packets inside the network layer.
The services which are offered by the network layer protocol are as follows:
- Packetizing –
The process of encapsulating the data received from upper layers of the network(also called as payload) in a network layer packet at the source and decapsulating the payload from the network layer packet at the destination is known as packetizing.
The source host adds a header that contains the source and destination address and some other relevant information required by the network layer protocol to the payload received from the upper layer protocol, and delivers the packet to the data link layer.
The destination host receives the network layer packet from its data link layer, decapsulates the packet, and delivers the payload to the corresponding upper layer protocol. The routers in the path are not allowed to change either the source or the destination address. The routers in the path are not allowed to decapsulate the packets they receive unless they need to be fragmented.
- Routing and Forwarding –
These are two other services offered by the network layer. In a network, there are a number of roots available from the source to the destination. The network layer specifies has some strategies which find out the best possible route. This process is referred to as routing. There are a number of routing protocols which are used in this process and they should be run to help the routers coordinate with each other and help in establishing communication throughout the network.
Forwarding is simply defined as the action applied by each router when a packet arrives at one of its interfaces. When a router receives a packet from one of its attached networks, it needs to forward the packet to another attached network (unicast routing) or to some attached networks(in case of multicast routing).
Some of the other services which are expected from the network layer are:
- Error Control –
Although it can be implemented in the network layer, but it is usually not preferred because the data packet in a network layer maybe fragmented at each router, which makes error checking inefficient in the network layer.
- Flow Control –
It regulates the amount of data a source can send without overloading the receiver. If the source produces a data at a very faster rate than the receiver can consume it, the receiver will be overloaded with data. To control the flow of data, the receiver should send a feedback to the sender to inform the latter that it is overloaded with data.
There is a lack of flow control in the design of the network layer. It does not directly provide any flow control. The datagrams are sent by the sender when they are ready, without any attention to the readiness of the receiver.
- Congestion Control –
Congestion occurs when the number of datagrams sent by source is beyond the capacity of network or routers. This is another issue in the network layer protocol. If congestion continues, sometimes a situation may arrive where the system collapses and no datagrams are delivered. Although congestion control is indirectly implemented in network layer, but still there is a lack of congestion control in the network layer.
Advantages of Network Layer Services :
- Packetization service in network layer provides an ease of transportation of the data packets.
- Packetization also eliminates single points of failure in data communication systems.
- Routers present in the network layer reduce network traffic by creating collision and broadcast domains.
- With the help of Forwarding, data packets are transferred from one place to another in the network.
Disadvantages of Network Layer Services :
- There is a lack of flow control in the design of the network layer.
- Congestion occurs sometimes due to the presence of too many datagrams in a network which are beyond the capacity of network or the routers. Due to this, some routers may drop some of the datagrams and some important piece of information maybe lost.
- Although indirectly error control is present in network layer, but there is a lack of proper error control mechanisms as due to presence of fragmented data packets, error control becomes difficult to implement.
- Selective forwarding Attack in wireless Sensor Network
- Inter VLAN Routing by Layer 3 Switch
- Integrated Services Digital Network (ISDN)
- Fragmentation at Network Layer
- Supernetting in Network Layer
- Traceroute in Network Layer
- Routing Tables in Computer Network
- Design Issues in Network Layer
- Routing v/s Routed Protocols in Computer Network
- Computer Networks | Network Layer | Question 2
- Computer Networks | Network Layer | Question 1
- Difference between Distance vector routing and Link State routing
- Difference between Secure Socket Layer (SSL) and Transport Layer Security (TLS)
- Difference between Classful Routing and Classless Routing
- Unicast Routing - Link State Routing
- Difference between layer-2 and layer-3 switches
- SSH Port Forwarding
- Internal/External Forwarding Rule in GCP
- Program for IP forwarding table lookup
- Cisco Discovery Protocol (CDP) and Link Layer Discovery Protocol (LLDP) in Data Link Layer