Spanning Tree Protocol (STP)
STP prevents Layer 2 loops by selectively blocking ports. Without STP, a redundant link would cause broadcast storms, MAC instability, and network failure.
1. The Root Bridge Election
Every STP domain must have one Root Bridge. It is the focal point of the topology.
- Bridge ID (BID): 8 Bytes = Priority (2B) + MAC Address (6B).
- Winner: The switch with the Lowest BID.
- Priority: Default is 32768. Increments of 4096 (due to Extended System ID carrying the VLAN ID).
Best Practice: Always configure `spanning-tree vlan 10 priority 4096` on your core switch. Never leave election to chance (random MACs).
2. Port Roles & States
Once the Root is elected, every other switch calculates the shortest path to the Root.
| Role | Description | State |
|---|---|---|
| Root Port (RP) | The single port on a switch closest to the Root Bridge. | Forwarding |
| Designated Port (DP) | The port sending BPDUs away from the Root. One per link. | Forwarding |
| Alternate Port (Alt) | A redundant path. Kept as a backup. | Blocking / Discarding |
3. STP Flavors: 802.1D vs RSTP vs MST
| Protocol | Std | Convergence | Resource Usage |
|---|---|---|---|
| PVST+ (Legacy) | Cisco | Slow (30-50s) | High (1 Instance per VLAN) |
| Rapid-PVST+ | 802.1w | Fast (<1s) | High (1 Instance per VLAN) |
| MST (Multiple STP) | 802.1s | Fast (<1s) | Low (Maps multiple VLANs to 1 Instance) |
4. Rapid STP (802.1w) Mechanics
RSTP achieves sub-second convergence by introducing the Proposal/Agreement mechanism. It does not rely on timers expiring.
- Sync: When a link comes up, ports are blocked.
- Proposal: Switch A sends a "Proposal" BPDU to Switch B.
- Agreement: Switch B checks if A is superior. If yes, it syncs its ports and sends "Agreement".
- Result: Link goes to Forwarding immediately.
Ports connecting to end hosts (PCs, Printers) should be configured as Edge Ports. This skips the Proposal/Agreement process and goes straight to Forwarding. Without this, DHCP can timeout while the port initializes.
References
- IEEE 802.1D (STP) & 802.1w (RSTP) - The official standards for bridging and convergence.
- Understanding Rapid Spanning Tree Protocol (802.1w) - Cisco's guide to the Proposal/Agreement mechanism.