NetwNETW
Curriculum
CHAPTER 08

Switching, VLANs & STP

How Layer 2 really works in a LAN

12 min read5 sections
In this chapter
Collision vs broadcast domainsMAC learning802.1Q taggingSTP/RSTPPort security

01Collision vs broadcast domains

A hub shares one collision domain. A switch gives each port its own collision domain. A VLAN or router separates broadcast domains. Modern switches = many collision domains, one broadcast domain per VLAN.

02MAC learning

Switches build a MAC address table by reading source MACs of incoming frames. Entries age out (default 300s). Unknown unicast is flooded.

What a switch actually does

A switch is a box with many ports. It learns which device is on which port, then sends each frame only where it needs to go.

to
Switch MAC table
MACPort
empty
Press Send. The switch starts with an empty table.
learn
remember source port
lookup
find destination port
forward
one port, or flood

03802.1Q tagging

VLAN tag inserted into Ethernet frame: 4 bytes (TPID 0x8100 + PCP/DEI + 12-bit VLAN ID). Access ports untag; trunk ports tag. Native VLAN on a trunk is untagged.

04STP/RSTP

Elects a root bridge, blocks redundant ports to prevent loops, recomputes on topology change. RSTP converges in seconds; STP in 30-50s.

05Port security

Limits MACs per port, shuts down or restricts on violation. First line of defense against rogue devices.