3.1 Layer 2 Switching
Key Concepts
- MAC Address Learning
- Forwarding and Filtering
- Collision Domains
- Spanning Tree Protocol (STP)
- VLANs (Virtual LANs)
MAC Address Learning
MAC Address Learning is the process by which a switch learns the MAC addresses of devices connected to its ports. When a device sends a frame, the switch records the source MAC address and the port it was received on in its MAC address table. This table is used to make forwarding decisions.
Example: Imagine a switch as a receptionist in an office. When an employee (device) enters and presents their ID (MAC address), the receptionist notes down their name and the room they are in (port). This helps the receptionist direct future visitors to the correct room.
Forwarding and Filtering
Forwarding is the process of sending a frame out of the appropriate port based on the destination MAC address. Filtering ensures that frames are only sent to the intended recipient, not broadcast to all ports. Switches use the MAC address table to determine the correct port for forwarding and filtering.
Example: Think of a switch as a mailroom. When a letter (frame) arrives with a specific address (destination MAC), the mailroom worker (switch) looks up the address in the directory (MAC address table) and sends the letter only to the intended recipient's mailbox (port), not to everyone.
Collision Domains
A collision domain is a network segment where data packets can collide with each other if they are transmitted simultaneously. Switches divide collision domains by creating separate broadcast domains for each port, reducing the likelihood of collisions.
Example: Consider a collision domain as a crowded street where cars (data packets) might crash into each other. A switch acts like a traffic light, dividing the street into lanes (ports) so that cars can move smoothly without collisions.
Spanning Tree Protocol (STP)
Spanning Tree Protocol (STP) is a network protocol that ensures a loop-free topology for Ethernet networks. It prevents broadcast storms and network instability by disabling redundant paths that could create loops. STP dynamically selects the best path for data to travel.
Example: Think of STP as a gardener pruning a tree to ensure it grows in the right direction without crossing branches (loops). The gardener (STP) removes excess branches (redundant paths) to maintain a healthy tree (network).
VLANs (Virtual LANs)
VLANs allow you to segment a physical network into multiple logical networks. This enhances security and performance by isolating traffic between different VLANs. Switches can tag frames with VLAN IDs to ensure they are sent to the correct VLAN.
Example: Imagine a large office building where each department (VLAN) has its own floor but shares the same elevator (switch). The elevator operator (switch) ensures that employees (frames) go to the correct floor by checking their department ID (VLAN tag).