An Ethernet switch is a Layer 2 device, therefore 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 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 builds a MAC address table automatically 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 to the switch. If the source MAC address does not exist in the MAC address table, it added to the table along with the incoming port number. In case of founding MAC address in the table, it will send the frame out 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 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.
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:-
In this method, Switch copies each complete incoming Ethernet frame into the switch memory. During the storage process, the switch analyzes the frame for information about its destination and computes trailer for Cyclic Redundancy Check (CRC) for errors. If a Cyclic Redundancy Check (CRC) error is found the Ethernet frames than dropped and if there is no Cyclic Redundancy Check (CRC) error, the switch forwards the Ethernet frame to the destination device.
Store and forward method can cause a delay because Cyclic Redundancy Check (CRC) takes time for calculation each Ethernet frame and also is 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 forwarded out to the right port, toward its destination. Discarding frames with errors reduces the amount of bandwidth consumed by corrupt data. The store-and-forward method has required for Quality of Service (QoS)
In cut-through, the frame header is inspected and the Destination MAC Address of the frame is copied into the internal memory of the switch before the frame is forwarded. This is the fastest switching method because switch only analyzes the destination MAC address which is 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 onto its destination through the designated switch port.
However, with speed comes some significance in that 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. Problem-related 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 gives the lowest latency in switching because fast-forward starts forwarding before the entire packet has been received, there may be times when packets are relayed with errors. 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 is an advanced form of cut-through switching. It waits for the collision window; which is 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 is only read the destination MAC address field in the Ethernet frame before makes 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. Runt frames are the frame smaller than 64 bytes. Fragment-free switching can be viewed as a compromise between store-and-forward and fast-forward methods. The reason fragment-free switching stores only the first 64 bytes of the frame because the most network errors and collisions occur during the first 64 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 is a compromise between the high latency and high integrity of store-and-forward switching; and the low latency and reduced integrity of fast-forward switching.
Some switches required configuration to do cut-through switching on a per-port basis until a user-defined error threshold reached; and then they automatically change to store-and-forward. When the error rate falls below the threshold, the port automatically changes back to cut-through switching.