The Network Layer
The Network Layer is a providing facility for the source to destination delivery of a packet possibly across a multiple layer.
This figure shows how the network layer works. Suppose System A sends packet to system C then sends the packet to intermediate system which is router B. When it reaches router B it sees the destination address and according to this routing table, then decides which path he needs to go. Now router B sends a packet to its final destination which is C. So in the figure, the hop to hop delivery which is A to B is a data link layer work but for A to C transfer packet we require to use a Network Layer.
These are two main responsibilities of a network Layer:
Logical Addressing
Routing
Let’s start with first one,
Logical Addressing:
Why is it required? This is for a computer to communicate with another computer anywhere else in the world using the internet. The packet transmitted from a computer to reach its final destination anywhere requires to pass through many LAN and WAN connections. For this level of communication we require global addressing and it’s called IP addressing.
IPv4 addresses:
Address is 32 bits long.
They are unique which means addresses define one and only one connection to the internet.
The address space is 232 .
It comes with two notation types: binary and dotted.
In a binary notation it comes with 32 bits. Example:
10101010 00001111 00110011 11110000
So it is 4bytes. While in dotted notation dot separates bytes like this:
127.16.22.01.
And now due to an increased demand for address, IPv6 also comes which is a 128 bit addressing.
Routing:
When independent networks or links are connected to create inter networks or a large network, the connecting device route or switch, packets to a final destination. This is called routing.
For deliver method we use the router. Now the router uses a routing table for managing path source to destination. There are two types one is static routing table which manually contains information that is entered and basically used for small networks but doesn’t change very often. The second is a dynamic routing table in which the routing table is updated periodically by one of the routing protocol such as RIP, OSPF, and BGP.
Now RIP (routing Information protocol) use a distance vector protocol which uses the least distance route between any two nodes.
The OSPF (open shortage path vector) is based on a link state routing, where each router sends the state of its neighbourhood to every other router in area. A packet only sends if there is a change in the neighborhood.
It divides AS (Autonomous System which is a group of network and router in the authority of a single administrator) in to area, collection of network, hosts etc.
OSPF routing table are calculated by Dijkstra’s algorithm.
BGP (Border Gateway Protocol) is based on a routing protocol called path vector routing where a packet must pass then explicitly listed.