So welcome back, guys.
Now, in this slide, we will going to learn that how L2 switch, actually.
Performs machine learning and populate its Mac address table.
So we will go through the steps and see how L2 switch works.
So let us say in this example we have the following topology.
This is the L3 router and this L3 router is connected to the L2.
Switch to this l2 switch the three host machines that is host machine E, host machine D and F are connected
via ports, P4, P3 and P2.
So note that that all the host machines are present in the same subnet and the network ID of the subnet
is 12 .1.1.0 slash 24.
So this is the network ID of the subnet in which all the host machines are present.
So now let us say that in our example, the host machine wants to send a data packet to the host machine.
F So let us try to understand the role of L2 switch in taking a frame generated by a host machine to
the destination Host machine f.
Let us assume that initially the Mac address table of the L2 switch is completely empty.
So step one that is, E sends our broadcast request to learn host machine F's Mac address.
Right.
Because the host machine e needs to send a data frame to the destination host machine F The very first
thing that E needs is to know the Mac address of the destination host machine F, and therefore the
host machine e prepares to launch our broadcast request to learn Host machine F Mac address.
Now the broadcast request will contain ethernet header.
So here our interest is only in the content of ethernet header because the functioning of the L2 switch
completely depends on the ethernet header present in a frame.
So in this diagram I am showing you only the content of Ethernet header of our broadcast request message
that is generated by the host machine E.
So when this ARP broadcast request message is received on port P4 of L2 switch, the L2 switch reads
the source Mac address present in the Ethernet header of this ARP broadcast request message.
Now the source Mac address is M, so l2 switch concludes that the host machine E sits on port number
P4 that is this port number.
Therefore, the L2 switch makes an entry in the Mac table and floods the ARP request message on all
the ports.
So here you can see that the L2 switch has entered an entry in its Mac address table.
And this entry says that a host machine which has a mac address M sits behind the port number P4.
Now, of course, the L2 switch also inspects the destination Mac address present in the Ethernet header
of the frame.
But in this case, the destination Mac address is actually a broadcast address.
So whenever the destination Mac address is a broadcast address in the Ethernet header of a frame L2
switch blindly floods the Ethernet frame.
On all its ports, so it will flood our broadcast request message out of Port P3, P1 and P2.
Right.
But now we know the functioning of our protocol now.
So like earlier, only destination host machine replies to this ARP broadcast request message with the
ARP reply message.
Right.
And this ARP reply message will be destined to the source host machine.
E So in this arp reply message, the destination Mac address will be the Mac address of the destination
host machine.
E that is me.
So you can see here that following is the Ethernet header content of ARP reply message that is generated
by destination host machine F in response to the ARP broadcast message.
Now again, this ARP reply message will be received by L2 switch on port P2.
So again, the L2 switch inspects the source Mac address specified in the Ethernet header of this ARP
reply message.
Now this time the source Mac address specified is MF, so therefore the L2 switch again makes an entry
in its Mac address table.
So this time it makes this following entry.
Right?
And this entry says that the host machine with Mac address MF sits behind the port to.
Right.
So going forward in step number seven, L2 Switch also inspects the destination Mac address present
in the Ethernet header of the ARP reply message.
So it uses this destination Mac address to look up in its Mac address table.
Now the destination Mac address in the ARP reply message is the Mac address of machine E.
Right, so the matching entry that L2 switch finds in its Mac address table is the first entry and the
first entry says that L2 switch must forwards the packet out of port number P4.
So l2 switch forwards the ARP reply message out of local port P4.
Right.
So in step number eight, L2 Switch sees that the destination Mac address is equal to the Mac address
of host machine.
E Therefore L2 switch now knows that ARP reply message should be forwarded to port number four, so
l2 switch forwards ARP reply message to port number four and finally E receives the ARP reply message
and now he can prepare the ethernet frame to send to F.
So you can see that in this entire process, the L2 switch inspects the source Mac address of the Ethernet
header of the frame and the destination Mac address in the Ethernet header of the frame which it receives
from any port number and accordingly L2 switch does the Mac learning by inspecting the source Mac address
present in the Ethernet header of the frame and L2 switch tries to forward the packet out of the correct
port number by inspecting the destination Mac address present in the Ethernet header of the frame.
So let us conclude that what we learned regarding L2 switch.
So L2 switch is a layer two device and as you can observe, it works only with the Mac addresses.
So you can generalize this statement that if you are giving any device and you know the functioning
of that device is completely dependent on Mac addresses, then you can declare that that device is actually
an L2 device.
That is device which works at the layer two of OSI model.
And this completes our concept of L2 routing.
We will once again revisit L2 routing when we will be discussing VLANs in detail.
So going forward now you can see in this diagram that the table on the right hand side represents the
fully populated Mac address table of this L2 switch.
And you can see that the entries in this Mac address table is consistent with the topology shown in
this slide.
So you can see that the host machine, which has a mac address me, sits behind the port number P4 of
L2 switch.
Similarly, the router which has a mac address M-r sits behind the port number P1 of L2 switch and same
goes with host machine F and host machine D.
So this table actually shows us that the L2 switch has at least seen one frame generated by every host
machine present in this topology, including the router.
So that is why entry is corresponding to all the host machines and an L3 router is present in this Mac
address table.