This tutorial explains how the switch forwards and filters the MAC addresses. Learn how the switch processes incoming frames along with the types of frames which the switch always floods.
To send a large amount of data to other PC in the network, the sender PC breaks the data in several smaller pieces and packs each piece with the protocol information which the receiver PC needs to reassemble all pieces back into the original data stream.
To know what else information each piece contains or how the information is added to the piece or how the information is used to reassemble all pieces back to the data stream, see this tutorial.
OSI Layer model explained
The devices which work in the middle of the network and connect the sender PC with the receiver PC also use this information to process each piece intelligently. Each piece, known as the frame, along with several other information contains the hardware address of the sender and receiver PC. The hardware address is known as the MAC address.
A switch works in the middle of the network. It connects multiple devices. It uses MAC addresses of the sender and receiver devices to process the frame. When a switch receives a frame, it reads the source address of that frame and stores it into a table known as the CAM table. This process is known as the Learning addresses.
To understand the Learning process in detail, check this tutorial.
How switch learns the MAC address
After saving the source address in the CAM table, the switch reads the destination MAC address of the frame and finds an entry for this address in the CAM table. If the CAM table has an entry for the destination MAC address, the switch uses that entry to make the forward decision. This process is known as the Forwarding frames. The below section explain this process in more detail with examples.
Frame forwarding and filtering process
Above, we discussed the learning process before the forwarding process. But in reality, the forwarding process takes place before the learning process.
Forwarding the frames as soon as possible is the main goal of a switch, and you can bet on it that the switch achieves this goal really very fast. A switch can start the forwarding process even before pulling the frame completely inside.
To learn more about how quickly a switch starts the frame forwarding process, you can check this tutorial.
Switching methods and types explained
Switches use a relatively simple concept to forward a frame. This concept is the following.
Find the destination MAC address of the incoming frame in the CAM table and if the address is available in the table, forward the frame from the port which is connected with the destination MAC address otherwise forward the frame from all ports except the port on which it arrived.
Let’s understand this process in more detail with an example.
Suppose, in a network, four PCs are connected through a switch. PC-A sends a frame to the PC-B. The switch receives this frame on the F0 interface. The switch reads the destination address of the frame and finds it in the CAM table. Since the CAM table has no entry for this destination address, the switch floods this frame from all ports except the port F0. Besides forwarding the frame, the switch also stores the source address in the CAM table.
Now suppose, the PC-B responds to the PC-A with its frame. The switch receives this frame on the interface F1. This time, by looking at the CAM table, the switch knows where the PC-A is located. So, instead of flooding the frame out from all ports as it did earlier, this time the switch forwards this frame only from the port (F0) which is connected with the PC-A. Same as earlier, it also saves the MAC address of PC-B in the CAM table.
Types of frames which are always flooded through the switch
There are three types of address; unicast address, multicast address, and broadcast address. These address types respectively represent an individual end device, a group of devices and all devices of the network. Frames sent on these addresses are respectively known as the unicast frames, multicast frames, and the broadcast frames.
Switch processes these frames as the following.
Unicast frames
To know which port is connected with which address, the switch uses the CAM table. Based on the CAM table’s entries, a unicast address can be categorized into two types; known unicast address and unknown unicast address. If the address is available in the CAM table, it is a known unicast address otherwise it is an unknown unicast address.
Switch forwards a known unicast frame only from the port which is directly connected to the destination address of that frame while it forwards an unknown unicast frame from all of its ports, except the port on which it arrived.
In the above example: -
When PC-A sent a frame to PC-B, the destination address (2222.2222.2222) of the frame was unknown to the switch. So, the switch flooded this frame from all ports, except the port (F0) on which it arrived.
When PC-B replied to PC-A, the destination address (1111.1111.1111) was known to the switch. So, the switch, instead of flooding it from all ports, forwarded the frame only from the port which is connected with the destination address.
Switch floods a unicast frame only if the destination address of the frame is not known to the switch.
Multicast and broadcast frames
Both multicast and broadcast addresses represent more than one device. These addresses are the destination only addresses and cannot be used as the source address. An end-device uses these addresses only when it wants to send the same frame to a group of devices or all devices of the network.
For example, a network has 50 PCs and one of them wants to send a frame to all PCs. The PC has two choices here; either create 49 (excluding self) unicast frames and sends one to each PC or create a broadcast frame and send it to all. Since the second option is much easier and faster, a PC always uses it.
A switch always floods multicast and broadcast frames. It learns addresses by reading the source address field of incoming frames. Since both the multicast and broadcast addresses are never used in the source address field of a frame, a switch never learns these addresses. And since a switch never learns these addresses, it always floods the frames which have these addresses as the destination address.
That’s all for this tutorial. If you like this tutorial, please don’t forget to share it with friends through your favorite social channel.