1️⃣ The Problem: Why Do We Need STP?
In a redundant Layer 2 network, multiple paths exist between switches to improve reliability. However, this can cause switching loops, leading to:
🚨 Broadcast Storms – Frames endlessly circulate, consuming bandwidth.
🚨 MAC Table Instability – Switches receive frames on multiple interfaces, confusing MAC address learning.
🚨 Multiple Frame Copies – The same frame reaches the destination multiple times.
Example: A Loop Without STP
- PC1 sends a broadcast frame.
- SW1 and SW2 forward the frame to each other endlessly.
- The network becomes unusable due to excessive traffic.
2️⃣ STP: The Solution to Prevent Loops
Spanning Tree Protocol (STP) ensures a loop-free topology by:
✅ Electing a Root Bridge.
✅ Assigning Port Roles (Root, Designated, Blocking).
✅ Blocking redundant paths while keeping a backup route ready.
3️⃣ Step-by-Step: How STP Works
Step 1: Root Bridge Election
- All switches send Bridge Protocol Data Units (BPDUs) to elect a Root Bridge.
- The switch with the lowest Bridge ID (Priority + MAC) becomes the Root Bridge.
📝 Bridge ID = Priority (Default: 32768) + MAC Address
✅ Lower priority wins (MAC address used as a tiebreaker).
Step 2: Assigning Port Roles
Once the Root Bridge is chosen, all switches determine the best path to reach it.
🔹 Root Port (RP) – The best path to the Root Bridge (lowest cost).
🔹 Designated Port (DP) – The forwarding port on each segment.
🔹 Blocking Port (BP) – Redundant path, blocked to prevent loops.
STP Path Cost (Default IEEE 802.1D)
| Link Speed | STP Cost |
|---|---|
| 10 Mbps | 100 |
| 100 Mbps | 19 |
| 1 Gbps | 4 |
| 10 Gbps | 2 |
✅ The lower the cost, the better the path!
Step 3: Ports Transition Through STP States
To prevent loops, STP gradually transitions ports through different states:
1️⃣ Blocking – Listens for BPDUs but does NOT forward traffic.
2️⃣ Listening – Processes BPDUs, but still no forwarding.
3️⃣ Learning – Starts learning MAC addresses.
4️⃣ Forwarding – Fully operational, forwarding traffic.
🚨 Total Convergence Time: 50 sec (STP), <6 sec (RSTP)!
Step 4: Handling Network Changes
If a link fails, STP automatically reconfigures by:
- Unblocking a previously blocked port to restore connectivity.
- Sending new BPDUs to update switch topology.
✅ This prevents downtime while maintaining a loop-free network.
4️⃣ STP Variants for Faster Convergence
| STP Type | Features | Convergence Time |
|---|---|---|
| STP (802.1D) | Standard, slow (50 sec) | 50 sec |
| RSTP (802.1w) | Rapid recovery, new port roles | <6 sec |
| MSTP (802.1s) | Optimized for multiple VLANs | <6 sec |
| PVST+ (Cisco) | Per-VLAN STP instance | 50 sec (STP) / Fast (PVST+) |
5️⃣ STP Troubleshooting Commands
🔍 Check STP Status
Switch# show spanning-tree
🔍 Check Root Bridge
Switch# show spanning-tree root
🔍 Check Active Ports
Switch# show spanning-tree interface GigabitEthernet0/1
Conclusion
Spanning Tree Protocol (STP) prevents loops in a redundant Layer 2 network by selecting a Root Bridge, assigning port roles, and blocking unnecessary paths.
Leave a comment