Spanning Tree Protocol (STP) is a Layer 2 protocol designed to prevent loops in a switched network. It ensures there is only one active path between switches, preventing broadcast storms, MAC table instability, and duplicate frames.
Why is STP Needed?
In a redundant network, loops can form because switches forward Ethernet frames without a TTL (Time-to-Live) like routers do. Without STP:
π΄ Broadcast storms overwhelm the network.
π΄ MAC table flapping occurs as switches receive the same frame from multiple paths.
π΄ Multiple frame copies reach the destination, causing confusion.
How STP Works
STP builds a loop-free logical topology by:
β
Electing a Root Bridge (central switch for path calculations).
β
Blocking redundant paths to prevent loops.
β
Allowing backup paths to become active if the primary fails.
STP Election and Port Roles
1οΈβ£ Root Bridge Election
- Switch with the lowest Bridge ID (BID) becomes the Root Bridge.
- Bridge ID = Priority (default: 32768) + MAC address.
- The Root Bridge acts as the reference point in the network.
2οΈβ£ STP Port Roles
Once the Root Bridge is elected, STP assigns roles to switch ports:
| Port Role | Description |
|---|---|
| Root Port (RP) | The best path to the Root Bridge (only one per switch). |
| Designated Port (DP) | Forwarding port on each segment (best path to Root). |
| Blocking Port (BP) | A backup path that does not forward traffic (to prevent loops). |
STP Timers & Convergence
STP takes 50 seconds to converge (transition to a loop-free state).
- Hello Timer: 2 seconds (BPDU exchange interval).
- Listening (15s) β Learning (15s) β Forwarding.
β Fast Convergence? Use Rapid Spanning Tree Protocol (RSTP)!
Types of STP
| Type | Features | Convergence Time |
|---|---|---|
| Classic STP (802.1D) | Standard version, slow convergence | 50 sec |
| Rapid STP (802.1w) | Faster convergence, uses alternate ports | <6 sec |
| Multiple STP (802.1s) | Supports multiple VLANs in one instance | <6 sec |
| Per VLAN STP (PVST/PVST+) | Separate STP instance for each VLAN (Cisco) | 50 sec (STP) / Fast (PVST+) |
Basic STP Configuration (Cisco)
1οΈβ£ Set STP Mode
bashCopyEditSwitch(config)# spanning-tree mode rapid-pvst # Use RSTP for fast convergence
2οΈβ£ Manually Set Root Bridge Priority
bashCopyEditSwitch(config)# spanning-tree vlan 10 priority 4096
π Lower priority wins! Default is 32768.
3οΈβ£ Verify STP Status
bashCopyEditSwitch# show spanning-tree
Troubleshooting STP Issues
| Issue | Possible Cause | Solution |
|---|---|---|
| Switch not Root Bridge | Another switch has lower priority | Manually configure spanning-tree vlan X priority Y |
| Network loops | STP disabled/misconfigured | Ensure STP is enabled (show spanning-tree) |
| Slow convergence | Using classic STP (802.1D) | Use RSTP (802.1w) for faster recovery |
Conclusion
STP is essential for loop prevention in Layer 2 networks. By selecting a Root Bridge, defining port roles, and blocking redundant links, it ensures a stable network. π
Leave a comment