Tuesday, November 1, 2011

Layer 2 switch operation (How the MAC address table is populated)

After using my previous post, "New device connects to a network..what's next?" one might be curious that how Client A, with a newly assigned IP address communicates with the rest of the network.  In a switching environment, a switch must first learn what devices hang off which interface.  The way the switch "learns" this is by passing traffic.  Initially, a switch knows nothing of the devices hanging off its interfaces.  Therefore, when a frame is received that is destined for a MAC address unknown to the switch, the switch broadcasts the request out of every interface (except the one from which the frame entered).  First off, using the example from the Cisco press book, we can see that PC1 is trying to communicate with the server:

When SW1 receives the frame on Gi0/1 destined for an unknown MAC address, it floods out the frame out every other interface and adds PC1's MAC address of AAAA.AAAA.AAAA to the MAC address table (with exception to Gi0/4, because the interface is in a different VLAN).  When SW2 receives the broadcast, it first associates PC1's MAC address of AAAA.AAAA.AAAA to Gi0/1, being that it is the interface on which PC1's frame entered.  Upon receiving the broadcast, SW2 also broadcasts the request out of every other interface.  When the Server receives the broadcast, it responds back with an ARP reply.  Unlike the ARP request, the server responds via a unicast to PC1 with a destination MAC address of AAAA.AAAA.AAAA.  When SW2 receives the ARP reply, it adds an entry for MAC address BBBB.BBBB.BBBB to its MAC address table, and forwards it out Gi0/1.  When Switch 1 receives the ARP reply, it adds BBBB.BBBB.BBBB to its MAC address table, off of Gi0/2.  Finally, because Switch 1 knows the interface to reach AAAA.AAAA.AAAA, Switch 1 forwards the ARP reply out of interface Gi0/1.  Because PC1 knows the MAC address for the Server, PC1 can now normally connect to the server.

1 comment: