So guys, next we will going to discuss an end to end example of layer three routing.
So in this example we have a four node topology.
This four node topology contains four routers.
The router names are VM, VM one V, m2 and M3.
In this example, we will going to see that how the packet is routed from the source router VM to the
destination router VM three.
So we will see that.
What is the role of intermediate routers, M1 and M2 and how the intermediate routers take their decision
in order to route a packet in the correct direction so that the packet eventually reaches its intended
destination.
You can see on the left hand side we have a L3 routing table.
So this is the L3 routing table entries for all the routers shown in the topology.
These L3 routing table entries are populated in a way such that every router in the topology is reachable
or pingable from every other router in the topology.
Now you already know the semantics of L3 routing table entry, so I expect you to go through this routing
table and understand that.
How every router in the topology is reachable from every other router in the topology.
You can also see a small boxes against each router in the diagram.
These small boxes denotes ARP table.
So you can see that for example, for virtual machine VM one there are two entries in the ARP table.
The number of entries in the ARP table is equal to the number of neighbors of a router.
So it is for this reason that for router VM one and router VM two, there are two entries in the ARP
table of these virtual machines.
So as we know, the ARP table contains the mapping of an IP address to a mac address for a neighbor.
So our problem statement is that from Virtual Machine VM, which is our source machine, we want to
send a data packet to destination IP address.
192.168.5.2, which is the IP address of local interface of virtual machine VM three.
And how L3 routing makes the packet journey possible from source machine to destination machine in the
layer three network.
So in the step one, VM wants to send a data packet to a destination IP address.
192.168.5.2.
VM checks if the destination IP address resides to one of its local subnet.
In this case, the destination IP address belongs to the remote subnet.
So in step two, as soon as the router comes to know that the destination IP address belongs to the
remote subnet and not local subnet, the next thing that the router does is to look up its L3 routing
table.
So in this lookup the router tries to find a matching entry which matches the destination IP address.
192.168.5.2.
So in this example, the entry number one of router VM will be picked up.
So in step three, using this matching entry, the router VM now knows that it has to send the data
packet out of interface Ethernet two towards the gateway.
192.168.4.1.
That is this gateway.
Now, after step three, the job of layer three routing is done.
Now the next thing that the router has to do is to know the Mac address of the.
Gateway to which it has to forward the packet.
So in step four router that is VM.
Now look up its ARP table using IP address of the next hop that is gateway as a key.
So the gateway is 192.168.4.1 and it finds that there is a mac address for this IP address in its ARP
table.
So this Mac address, let's say, is M.
So at this point of time, the router knows that the source Mac address will be the Mac address of outgoing
interface, which is the Ethernet to the destination.
Mac address will be the Mac address of the gateway, which is.
So source Mac address is known.
Destination Mac address is known source IP address is already the IP address of the current router VM
and the and destination IP address is an input from the user, which is this IP address.
So now the information regarding all these four fields that is Source Mac, Destination, Mac source
and destination IP is known.
So the router now is in a position to actually prepare a packet.
So we have now prepared a packet and following is the packet content.
The source Mac address, as you know, the Mac address of the outgoing interface, which is the destination
Mac address will be the source IP address will be taken as the IP address of the outgoing interface.
And of course the destination IP address is the user input.
So this is how the router actually prepares the packet and ships this packet on the wire.
So going forward we have one receives the packet ethernet layer of router one checks.
If destination Mac address in the packet is equal to Mac address of the receiving interface is in this
example it is true.
So the data link layer or ethernet layer on virtual machine VM one chop off the ethernet header and
hand over the rest of the packet to the layer operating on the top of data link layer that is network
layer.
Now what does network layer do?
The network layer on virtual machine VM one checks whether the destination IP address in the IP header
of the packet belongs to any of its local subnet.
In this case, no.
Right.
So VM one checks its routing table and search for a destination subnet, which hosts this destination
IP address.
In this case, the entry number one of router VM one is picked up.
That is this entry.
So now the router VM one also knows that it has to send the packet towards the gateway.
192.168.1.2 and the outgoing local interface is ethernet three.
So the network layer of the router VM one has decided that where to forward the packet to.
So again, Vm1 will do the same thing.
It will now look up its ARP table using next hop IP address.
192.168.1.2 as a key to know the next Hop Mac address.
And we know that the next hop Mac address will be MD.
So remember if the router VM one did not have this information that the next hop Mac address is empty,
then it would have launched ARP broadcast request.
But here we have assumed that all the routers in the topology already have ARP table populated.
So.
So we make our discussion simple by by not discussing ARP complexity here.
So v n1 now prepares the packet and sends the packet out of interface ethernet three.
So what will the packet content now?
So the packet content will be that source Mac address will be the destination, Mac address will be
empty and the source and destination IP address will stay unchanged.
So you can see that whenever the router forwards the packet, the source Mac address and the destination
Mac address in the packet keeps on changing.
So going forward, our packet has now reached to router Vm2.
So Vm2 receives the packet.
The ethernet layer checks.
If destination Mac address in the packet is equal to the Mac address of receiving interface.
So in this example it is.
Yes.
So the router does the same thing.
It chop off the ethernet header and head over the rest of the packet to the network layer.
The network layer of router vm2 checks whether destination IP address in the packet belongs to any of
its local subnet.
Now, in this case it will be true because the destination IP address in the packet is 192.168.5.2,
which belongs to the local subnet.
192.168.5.1 slash 24 and this is a local subnet to router vm2.
So destination IP address in the packet belongs to subnet three, which is a local subnet for router
VM two.
It means that the packet has now reached its intended remote subnet.
Now we aim to will deliver the packet to M3 using l3 routing only.
Now note here that the destination IP address in the packet belongs to a local subnet to router m2.
This is one case.
But the destination IP address in the packet do not exactly matches with the IP address of any local
interface of router vm2.
This is the second case.
So in the second case, when the destination IP address of the packet falls in the local subnet of a
router but do not exactly matches with the IP address of any local interface of a router.
VM two Then the router decides to forward the packet further using L2 routing only when the destination
IP address of the packet falls in the local subnet, but it do not exactly matches with the IP address
of any local interface of a router.
The router concludes that the packet is intended to reach a final destination machine which is present
to its one of the local subnet.
So here you can see that the router two now concludes that the packet is destined to a machine which
is present on its local subnet subnet three.
So now VM to will deliver the packet to VM three using l2 routing only.
So VM to now look up its ARP table using destination IP address.
192.168.5.2 As a key to know the next Hop Mac address which is mf, that is this Mac address.
So VM two now prepares the packet and sends the packet out of interface Ethernet two that is VM two
can now send a packet out of this local interface.
So the contents of the packet at this point of time will be that, that the source Mac address will
be M that is the Mac address of the leaving interface.
The destination Mac address will be the Mac address of the next hop and the source and destination IP
address remains unchanged.
Now at this point of time, our packet has reached to router VM three, so VM three receives the packet
Ethernet layer checks.
If Destination Mac address is equal to the Mac address of the receiving interface.
And it is, yes.
So again, the Ethernet layer chops off the Ethernet header and hand over the packet to the network
layer running on virtual machine VM three.
So VM three network layer checks that the destination IP address in the packet belongs to any of its
local subnet.
Now in this case, of course, the destination IP address in the packet falls in the subnet three and
subnet three is a local subnet for router VM three as well.
So in this case, yes, the destination IP address belongs to subnet three.
So router VM three now knows that the packet is destined to the local subnet.
Now VM three also checks that whether the destination IP address in the packet exactly matches to the
IP address of one of its local interface.
Now in this case the destination IP address in the packet matches with the IP address of the interface
Ethernet two.
So VM three now knows that the packet was destined to itself.
So three chops of the network layer header and delivers the rest of the packet to the transport layer.
So the transport layer finally processed the packet and delivers the packet to the application layer.
And because this router that is router VM three is an ultimate destination of the packet, it do not
forwards this packet any further, so there is no point of discussing the contents of the packet here.
So you can see that this is how the Layer three routing happens from source machine to destination machine.
The layer two and layer three routing plays their respective roles in order to take the packet from
one router to the next router and then from the next router to again to the next router and so on.
So in this example, Layer two, routing was responsible in order to take the packet from current router
to its neighbor router, whereas Layer three routing is responsible to decide that, which is the next
hop router which the current router should sends the packet to.
So I hope the concept of layer three routing is crystal clear with this example.
There is one more example which I found on the YouTube, and this is the best video that I could find
on the internet, which explains the concept of layer two routing and layer three routing in pretty
much detail.
So this is another example that you can follow or you must follow in order to understand the concept
of layer two and layer three routing.
It is very important from the interviews point of view that you will be straightaway asked by the interviewer
to explain the entire L2 and L3 routing concept, which is no different than what I have explained in
this lecture video.
And of course you should visit this YouTube link and try to grasp the idea.
This video explains that.
How?
Layer to table and layer three routing tables are populated.
And also it explains that how these tables are used in order to route the packet from source machine
to destination machine.
So I request you to watch this YouTube video again and again until you can explain the concept of L2
and L3 routing to your friend on your fingertips.
So that's all about routing.
Thank you.