Switching Fundamentals – Everything to Know
An Ethernet switch is a Layer 2 device. Therefore, the switch uses MAC addresses for switching decisions. It is unaware of the protocol being carried in the data portion of the frame, such as an IPv4 packet. The Ethernet hub repeats bits out of all ports except the incoming port, but 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 the Source and destination MAC Addresses
The switch automatically builds a MAC address table by examining the source MAC address of the frames received on any port. It forwards frames by searching for a match between the destination MAC address in the frame and an entry in the MAC address table. It checks each entering frame for new information, for example, examining the frame’s source MAC address and port number where the frame entered the switch.
If the source MAC address does not exist in the MAC address table, it and the incoming port number are added to the table. If the MAC address is found in the table, the frame will be sent out of the specified 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 exists in the table but on a different port, the switch treats this as a new entry. The entry was replaced using the same MAC address but with the more current port number.
Frame Forwarding Methods on Cisco Switches
Cisco switches support different frame-forwarding Methods. Frame Forwarding Methods determine how a switch receives, processes, and forwards a Layer 2 Ethernet frame. Important Switching methods are the following:-
Store-and-forward switching
The switch copies each incoming Ethernet frame into the switch memory in this method. During storage, the switch analyzes the frame for information about its destination and computes the Cyclic Redundancy Check (CRC) trailer for errors. If a Cyclic Redundancy Check (CRC) error is found, the Ethernet frames are then dropped, and if there is no Cyclic Redundancy Check (CRC) error, the switch forwards the Ethernet frame to the destination device.
The store-and-forward method can cause a delay because Cyclic Redundancy Check (CRC) takes time to calculate each Ethernet frame and is also the most processor-intensive. CRC uses a mathematical formula based on the number of bits (1s) in the frame to decide whether the received frame has an error.
After confirming the reliability of the frame, the frame was forwarded to the correct port and toward its destination. Discarding frames with errors reduces the amount of bandwidth consumed by corrupt data. The store-and-forward method requires Quality of Service (QoS)
Cut-Through Switching
In cut-through, the frame header is inspected, and the frame’s Destination MAC Address is copied into the switch’s internal memory before the frame is forwarded. This is the fastest switching method because the switch only analyzes the destination MAC address located in the first 6 bytes of the frame following the preamble. The switch looks up the destination MAC address in its Mac address table, determines the outgoing interface port, and forwards the frame to its destination through the designated switch port.
However, with speed comes some significance: the switch also forwards frames with errors. Because the switch does not perform any error checking on the frame, it is up to the destination switch to discard received frames with errors.
Switch operating in cut-through mode reduces delay because the switch starts to forward the Ethernet frame as soon as it reads the destination MAC address. The problem with the cut-through method is that the switch may forward bad frames. The cut-through method is the predominant switching method used on Cisco switches. There are two variants of cut-through switching:
Fast-forward switching
Fast-forward gives the lowest latency in switching because it starts forwarding before the entire packet has been received. There may be times when packets are relayed with errors, but this occurs infrequently, and the destination network adapter discards the faulty packet upon receipt. In fast-forward mode, latency is measured from the first bit received to the first bit transmitted. Fast-forward is the typical cut-through method of switching.
Fragment-free switching
Fragment-free is an advanced form of cut-through switching. It waits for the collision window, the first 64 bytes of a frame, to be accepted before forwarding the frame to its destination. The fragment-free method holds the packet in memory until the data portion reaches the switch. It only reads the destination MAC address field in the Ethernet frame before making a switching decision.
The switches operating in fragment-free mode read and store at least 64 bytes of the Ethernet frame before switching it to avoid forwarding Ethernet “runt” frames, which are smaller than 64 bytes.
Fragment-free switching can be viewed as a compromise between store-and-forward and fast-forward methods. Fragment-free switching stores only the first 64 bytes of the frame because most network errors and collisions occur during these bytes.
Fragment-free switching tries to improve fast-forward switching by performing a small error check on the first 64 bytes of the frame. Fragment-free switching compromises the high latency and high integrity of store-and-forward switching and the low latency and reduced integrity of fast-forward switching.
Some switches require configuration to do cut-through switching on a per-port basis until a user-defined error threshold is reached; then, they automatically change to store-and-forward. When the error rate falls below the threshold, the port returns to cut-through switching.