Thursday, July 22, 2010

Building MAC Address Tables in a Switch

A switch is a layer 2 device that can be used to forward data from one device to another device. It does that by comparing its database of MAC addresses with the incoming traffic MAC address and port, and where its destination MAC address and port. Although this data can be put in manually (static), it is easier to let the switch learn these MAC addresses automatically (dynamic). This is also useful when the end user devices such as PC connects and disconnects often on different ports.

Basically, a switch first time powered on switch has an empty table. When it received its first frame lets say from PC A, it will save the incoming packet’s MAC address and port on its table. Because it doesn’t know where to send the packets (since the table is empty), it will forward the packet to all ports except from the port it came from. It will then wait for the packet replied by one of the devices attached to it (e.g PC D that is the real destination) and save that MAC address and port. So, next time when another PC sends a packet to PC D it will then go directly to PC D because the switch knows already where to send the packet to based on its table. This goes so on with other packets until all the MAC table and ports are built completely.

In overall, there will be 4 possibilites for forwarding data in a switch. The first one is if there is unicast data from originating device to destination device. If the MAC address of the destination device is known, it will be forwarded to the specific port. Second one, if the data is unicast and the destination device is not known yet in the switch’s database, it will be sent out to every port except from where it came from. The third one is if the data is sent to a MAC address that is known to come from the same port it originates. In this case, this frame will be filtered by the switch and will not be forwarded by the switch to any port. The fourth and last one is multicast or broadcast (remember: broadcast uses ff:ff:ff:ff:ff:ff as destination address). In this case the switch will sent to the designated ports or every port except where it came from.

No comments:

Post a Comment