Switch Fundamentals – Learning MAC Address

An Ethernet switch is a Layer 2 (data link layer) device, therefore switch uses MAC addresses to make forwarding decisions. It is completely unaware of the protocol being carried in the data portion of the frame, such as an IPv4 packet. The switch makes its forwarding decisions based only on the Layer 2 Ethernet MAC addresses.

Not like an Ethernet hub that repeats bits out all ports except the incoming port, an Ethernet switch consults a MAC address table to make a forwarding decision for each frame. The MAC address table is sometimes called a content addressable memory (CAM) table.

Learning MAC Address Table

The switch automatically builds the MAC address table by examining the source MAC address of the frames received on any port. The switch forwards frames by searching for a match between the destination MAC address in the frame and an entry in the MAC address table. The following process performed on each Ethernet frame that enters a switch.

Learning the Source and destination MAC Addresses

The switch checked each frame enters a switch for new information to learn. It does this by examining the frame’s source MAC address and port number where the frame entered the switch.

If the source MAC address does not exist, it added to the table along with the incoming port number. See the table in the movie, PC-1 is sending an Ethernet frame to PC-6. The switch adds the MAC address for PC-1 to the table against port-1. If the destination MAC address is on the table, it will send the frame out the specified port. As you can see in the table there is no mac address entry so the switch will flood the packet to all ports except incoming port. All other will discard the packet and PC-6 will reply. When PC-6 Reply switch will add the mac address of PC 6 which is on port-6.By this method, the switch will add all mac addresses against each port. If the destination MAC address is a broadcast or a multicast; the switch flood the frame out to all ports except the incoming port.

If the source MAC address does exist, the switch updates the refresh timer for that entry. By default, most Ethernet switches keep an entry in the table for 5 minutes. If the source MAC address does exist in the table but on a different port; the switch treats this as a new entry. The entry replaced using the same MAC address but with the more current port number.