Layer 2 switching
Layer 2 switching (also known as the Data Link layer switching) is the process of using devices’ MAC addresses to decide where to forward frames in a LAN. Layer 2 switching is efficient because there is no modification to the data packet, only to the frame encapsulation of the packet.
In a typical LAN, all computers are connected to one central device. In the past, the device was usually a hub. But hubs have many disadvantages; they are not aware of traffic that passes through them, they create only a single collision domain, etc. To overcome these problems, bridges were created. They were better than hubs because they created multiple collision domains, but they had limited number of ports. Finally, switch were created and are still widely used in modern LANs. Switches have more ports than bridges and can inspect incoming traffic and make forwarding decisions accordingly.
Layer 2 switches are much faster than routers because they don’t take up time looking at the Network layer header information. Instead, they look at the frame’s hardware addresses to decide whether to forward, flood, or drop the frame. Here are the major advantages of Layer 2 switching:
- Hardware-based bridging (using ASICs)
- Wire speed
- Low latency
- Low cost
Switches usually perform these three functions:
- Address learning – switches learn MAC addresses by examining the source MAC address of each frame received by the switch.
- Forward/filter decisions – switches decide whether to forward or filter a frame, based on the destination MAC address.
- Loop avoidance – switches use Spanning Tree Protocol (STP) to prevent network loops while still permitting redundancy.