This tutorial explains switching methods and types in detail. Learn what a switching method is and how a switch uses a switching method in its internal frame processing.
A switching method defines how a switch processes a frame. A frame is a piece of the data stream that is transferred between two devices in the network. It consists of four objects: the hardware address of the source device, the hardware address of the destination device, control options, and data.
Hardware addresses of the source and destination devices are respectively used to identify the sender and receiver devices of the frame. A hardware address is also known as the MAC address. Control options are mainly used for two purposes: to verify the integrity of the frame and to identify the upper-layer protocol that should be used to process the frame at the destination device. A frame is also known as the Ethernet frame.
The following image shows the basic structure of an Ethernet frame.
To process a frame, a switch uses the source MAC address, destination MAC address, and one control option (FCS) of the frame.
To learn more about an Ethernet frame and its structure, you can check the following tutorial.
Ethernet frame format explained
To learn how devices exchange data in the network, you can check the following tutorial.
A switch has multiple ports. These ports are used to connect various devices. To know which device is connected to which port, the switch stores MAC addresses of all connected devices with their related ports in a table that is known as the CAM table.
A CAM table entry consists of a local port number and the MAC address of the device that is connected to the port. If multiple devices are connected to a single port, MAC addresses of all connected devices are mapped to the same port.
The following image shows examples of CAM table entries.
To learn how a switch learns MAC addresses and how it builds the CAM table, you can check the following tutorial.
How a switch learns MAC addresses explainedInternal frame processing on switches
Internal frame processing describes how a switch processes frames. It has three phases: receiving, processing, and forwarding. In the receiving phase, a switch receives a frame on one of its ports. In the processing phase, the switch reads the destination MAC address of the frame and finds an entry for the destination MAC address in the CAM table. If the CAM table has an entry for the destination MAC address, the switch selects the port that is associated with the destination MAC address in the entry for the third phase. If the CAM table does not have an entry for the destination MAC address, the switch selects all ports for the third phase except the port on which the frame has been received. After selecting the port or ports for the third phase, the switch may validate the integrity of the frame. In the third phase, the switch forwards the frame from the selected port or ports.
The following image shows the first and second phases of internal frame processing.
Types of switching methods
A switching method explains how a switch starts the forwarding phase of internal frame processing. There are three types of switching methods: the store-and-forward method, the fragment-free method, and the cut-through method.
In all three methods, the first and second phases are the same. In the first phase, the switch receives a frame on one of its ports. For fast processing, the switch starts the second phase as soon as it receives the bits of the frame that contain the destination address. This mechanism allows the switch to select the forward port or ports for a frame even before the frame enters the switch.
After making the forwarding decision, the switch uses a different approach to start the third step in each method. Let’s understand how the switch initiates the third phase in each method.
The store-and-forward switching method
In this method, the switch waits till all bits of the frame are received. After receiving all bits of the frame, the switch verifies whether the received frame is error-free. If the received frame is error-free, the switch forwards the frame from the selected port or ports. If the received frame contains errors, the switch discards the frame.
To know the condition of a frame, the switch uses the FCS (frame check sequence) field of the frame. The FCS field contains a value known as the CRC value. The CRC value allows a receiving device to know whether the frame is exactly in the same state as the source packed it or it has been damaged or tempered in the middle.
After creating a frame, the sender or the source device runs the CRC (Cyclic Redundancy Check) algorithm on it. The value produced by this algorithm is known as the CRC value. The CRC value is stored in the FCS field of the frame. After storing the CRC value, the sender device loads the frame on the media.
Upon receiving the frame, the receiver or destination device runs the CRC algorithm on the frame and compares the result with the CRC value stored in the FCS field of the frame. If the result and the CRC value are the same, the frame is considered error-free. If they are not the same, the frame is considered as the damaged frame.
In this method, a switch only forwards error-free frames. This method provides the highest level of accuracy but at the cost of speed. If we compare all three methods of switching, this method respectively stands at the first and the last positions in terms of accuracy and speed.
The cut-through switching method
In this method, the switch starts the third phase as soon as the forward port is determined. An Ethernet frame stores the destination MAC address in the third field. To forward a frame, a switch only needs the destination MAC address of the frame. Since the destination MAC address occurs very early in the Ethernet frame, a switch can start forwarding the received bits of the frame before receiving all bits of the frame.
In this method, the switch does not check the condition of the frame before forwarding it. This reduces the latency, but it also propagates errors. From all three switching methods, this is the fastest method of switching. But it provides speed at the cost of having forwarded some frames that contain errors.
The fragment-free switching method
In this method, after determining the forward port, the switch waits till the first 64 bytes of the frame are received. The 64 bytes is the minimum legal size of an Ethernet frame. An Ethernet frame that is smaller than 64 bytes is known as the runt frame. A runt frame is a corrupt frame.
This method is the modified version of the cut-through switching method. This method reduces the number of runt frames that are being switched. Sometimes this method is also known as the modified cut-through or runtless switching method.
Comparing switching methods
The following table compares all three methods.
Methods/Compression | Store-and-forward | Fragment-free | Cut-and-through |
Frame processing starts | After receiving the complete frame and running the CRC algorithm. | After receiving the first 64 bytes. | After receiving the first 8 bytes. |
Position in term of speed | Third | Second | First |
Position in term of accuracy | First | Second | Third |
That’s all for this tutorial. If you like this tutorial, please don’t forget to share it with friends through your favorite social platform.