So guys, going forward now, let us discuss next that how network layer works and what are the operations
of network Layer.
So you can see that I have tried to capture the entire functioning of the network layer that is L3 layer
in this diagram.
The blue color region in this diagram represents the network layer.
So whenever you feel confused about network layer operations, then always switch back to this diagram
and revise it again and again.
This one single diagram worth more than 1000 words of explanation on L3 routing.
So let me explain what is the story going on in this diagram so you can see that we have a very simple
topology here.
We have an L three router, which has two interfaces on either side.
Let us suppose that the packet comes and enters into this router at interface Ethernet three.
Now obviously this packet will have source Mac and Destination Mac in its Ethernet header.
And this packet will also have source IP address and destination IP address in the IP header of this
packet.
So let us see what happens when this packet enters into this router on the interface Ethernet three.
So the very first thing that happens is the action that is taken by the data link layer.
What does Ethernet layer or data link layer do?
It compares the Mac address, which is configured on the receiving interface that is MD, which is the
Mac address of Interface Ethernet three.
So it compares the Mac address of the receiving interface with the destination Mac address, which is
specified in the Ethernet header of the packet.
And if the matches only then the data link layer chops off the ethernet header from the packet and hand
over the packet to the network layer.
So remember that even if the destination Mac address is specified in the packet, is the broadcast address,
then also the data link layer hand over the packet to the L3 layer for route lookup.
And if this condition is false, then the packet is dropped right away by the data link layer that is
network layer.
Do not even come to know about any such packet.
So let us assume that this condition is true and the packet is handed over to network layer for l3 route
lookup.
So when the packet is received by network layer, the packet would have only IP header followed by transport
header or application header.
It will certainly not have ethernet header because that ethernet header has been chopped off already
by the data link layer.
So in the interview, it is very pet questions that you are asked that.
What is the condition which determines that when a packet is subjected or promoted to L3 routing?
So the condition is this one.
That is the destination Mac address in the ethernet header of the packet must match with the Mac address
of the receiving interface.
Now our packet is in the hands of network layer now.
Now.
Network Layer examines the destination IP address present in the IP header of the packet.
And it performs the longest prefix match against the entries present in the routing table of an L three
router.
Right.
So now two outcomes are possible.
Either the matching entry is not found or the matching entry is found.
If there is no matching entries in the L three routing table of a router, it means that the router
will discard the packet simply because the router do not know what to do with this packet.
Now, on the other hand, it is possible that the router has an entry in its routing table which satisfies
the longest prefix match with the destination IP address of the packet.
Right.
So if that is the case, then the next check that is done by the network layer is that that whether
the matching entry of the routing table is one of the local subnet of this L3 router.
Right.
So for example, suppose this packet P comes and suppose that the packet falls in the subnet.
192.168.5.0 slash 24.
It means that there exists an entry in the layer three routing table in whose subnet the destination
IP address of the packet P is a member of.
Right.
And at the same time, this subnet is a local subnet of this router because this subnet is configured
on a directly connected physical interface.
Right.
So this subnet is a local subnet.
In other words, the packet that has just entered into this router belongs to one of the local subnet
of this L3 router.
So if that is the case, then the router decides to go for local packet delivery, right?
And if that is not the case, it means that the packet belongs to some remote subnet.
Right.
And if the packet belongs to some remote subnet, then obviously the L3 router will forward the packet
to the next router as per the routing table entry.
Now let us come to the local packet delivery.
Now here, local packet delivery again means two things, right?
First is that whether the destination IP address is specified in the IP header of the packet is equal
to the router's exact IP address.
Now, here it means that whether the destination IP address of the packet exactly matches to the IP
address configured on one of the local interface of a router.
So for example, suppose the packet P comes and the destination IP address that is specified in this
packet is 192.168.5.1.
So you can see that this IP address exactly matches with the IP address of local interface of this router.
Right or the destination IP address in the packet could be.
192.168.1.2.
Again, this.
IP address exactly matches with the IP address of one of the local interface of this router, which
is ethernet three.
Right.
So if this condition happens, it means that the router itself is a destination for the packet.
Right.
So it means that the router has to process the packet and therefore router then promotes the packet
to the next layer on the top of the network layer, which is transport layer, and the transport layer
does its purpose.
That is, it handovers the packet to the right application.
We will discuss that.
How transport layer determines that which application this packet is destined for.
Because there could be multiple applications that is running on the router.
Now coming to the else part.
So else part will be executed when this particular condition is false.
So this particular condition will be false when the destination IP address in the packet is a member
of one of the local subnet of a router.
So example of this case will be that that when the packet p contains an IP address, for example.
192.168.5.5.
Now this IP address do not exactly matches with the IP address configured on one of the local interface
of L3 router.
But this IP address is a member of Router's local subnet, which is 192.168.5.0 slash 24.
So as long as the packet with destination IP address such that the IP address belongs to one of the
local subnet of an L3 router, the router will choose to forward the packet using L2 routing.
So using L2 routing, the L3 router will try to deliver the packet to one of the machines present in
directly connected subnet using L2 routing concepts.
Right.
So it might be possible that on this interface there could be some host which has an IP address.
192.168.5.5 and the packet with this destination IP address is destined for this host machine, so the
L3 router will deliver the packet to this host machine using L2 routing.
And now we are very well aware that how L2 routing is used by L3 router in order to deliver the packet
to the host machine present in directly connected subnet.
So remember, this diagram is very important.
You can choose to take the printout of this diagram or do anything.
Just keep it in your good books so that you can always revise the concept of L3 routing by just having
a look at this diagram.
And remember L3 routing and L2 routing both concepts forms the core of entire networking.
So be prepared to be asked the questions on L3 routing and L2 routing.
In fact, the interviewer will straight away ask you to explain the entire mechanism of L2 routing and
L3 routing.
It is for this reason that I'm emphasizing again and again to have this concept learnt by heart.
So now next, let us summarize that what we have discussed in this diagram.
So the root lookup, so the router performs the root lookup to decide if the packet received is destined
to a machine in the local subnet of receiving router or remote subnet based on destination IP address.
So this is the purpose of root lookup.
The next the router performs the local packet delivery.
If the destination IP address in the packet that is received is exactly equal to the IP address of one
of the local interface of an LTE router.
If this condition is true, then router itself is the destination for the packet.
Right.
And if the destination IP address in the received packet belongs to one of the local subnet of l3 router
router forwards the packet using L2 routing to the machine present in its local direct subnet.
Right and Router decides to forward the packet if there is a matching entry in the routers routing table.
That is the entry which satisfies the longest prefix match criteria with the destination IP address
specified in the IP header of the packet.
So if this condition is true, then router forwards the packet as per the entry dictates.
And finally, if the packet that is received by L3 router do not meet the criteria for local packet
delivery or forwarding, then router discards the packet.
It has no choice.
So this slide summarizes everything that we had discussed in the previous diagram.
So guys, we have discussed the operations and how the network layer works.
Now, next, let us discuss step by step example to understand how routing is actually performed by
an L3 router.