A Network Switch is a Layer 2 device that connects devices within a Local Area Network (LAN) and uses MAC addresses to forward data to the correct destination. Unlike a hub, which broadcasts data to everyone, a switch intelligently directs traffic.
The MAC Address Table (CAM Table)
The core of switching logic is the MAC Address Table (Content Addressable Memory). This table maps MAC addresses to specific switch ports and VLANs.
How a Switch Learns (The Process)
- Learning (Source MAC): When a frame enters a port, the switch reads the Source MAC address. If it's not in the table, the switch adds it, associating it with that port and VLAN.
- Forwarding (Destination MAC): The switch then looks at the Destination MAC address.
- Known Unicast: If the destination MAC is in the table, the switch forwards the frame only to that specific port.
- Unknown Unicast / Broadcast: If the destination MAC is not in the table (or is FFFF.FFFF.FFFF), the switch floods the frame out all ports (except the incoming one).
Aging Timer
MAC address entries do not stay in the table forever. To keep the table current and save memory, switches use an Aging Timer.
- Default Time: 300 seconds (5 minutes).
- Function: If no traffic is received from a specific Source MAC for 300 seconds, the entry is removed from the table.
Frame Switching Methods
Switches use different methods to process and forward frames:
1. Store-and-Forward
The switch receives the entire frame and checks it for errors (CRC check) before forwarding. It is the most reliable but has higher latency.
2. Cut-Through
The switch starts forwarding the frame as soon as the Destination MAC is read. It is faster (lower latency) but may forward corrupted frames.
- Fast-Forward: Forwards immediately after reading destination address.
- Fragment-Free: Reads the first 64 bytes (collision window) to check for fragments before forwarding.
VLAN Tables
Switches also maintain VLAN information. The MAC table includes the VLAN ID for each entry. Traffic from one VLAN is never forwarded to a port in a different VLAN (unless routed by a Layer 3 device).
Switch# show mac address-table Mac Address Table ------------------------------------------- Vlan Mac Address Type Ports ---- ----------- -------- ----- 1 0001.42a1.3e01 DYNAMIC Fa0/1 10 0002.1b2c.4d02 DYNAMIC Fa0/2 20 0003.5c3d.5e03 DYNAMIC Fa0/3