What is Spanning Tree Protocol (STP)?

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

2️⃣ STP Port Roles

Once the Root Bridge is elected, STP assigns roles to switch ports:

Port RoleDescription
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).

βœ… Fast Convergence? Use Rapid Spanning Tree Protocol (RSTP)!


Types of STP

TypeFeaturesConvergence Time
Classic STP (802.1D)Standard version, slow convergence50 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

IssuePossible CauseSolution
Switch not Root BridgeAnother switch has lower priorityManually configure spanning-tree vlan X priority Y
Network loopsSTP disabled/misconfiguredEnsure STP is enabled (show spanning-tree)
Slow convergenceUsing 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. πŸš€

renjithbs Avatar

Posted by

Leave a comment