Skip to main content

The Story of Spanning Tree Protocol (STP)

·654 words·
Spanning Tree Protocol Network Loops Broadcast Storm Root Bridge Redundant Links
Table of Contents

storystp

The Begining of the Story
#

Back in the early days of Ethernet, redundancy was necessary. If one cable or switch failed β†’ another path needed to take over.

πŸ‘‰ To achieve this, engineers connected switches in loops. Great idea… until it wasn’t.


🚨 The Problem – Loops Gone Wild
#

When redundant links formed loops, chaos followed:

  1. Broadcast Storms β†’ Broadcast frames (like ARP requests) endlessly circled β†’ consuming bandwidth & CPU.
  2. MAC Table Instability β†’ Switches kept updating MAC tables incorrectly β†’ same frame arriving from different ports.
  3. Duplicate Frames β†’ Devices received multiple copies β†’ inefficiency + confusion.

Networks basically choked themselves.


πŸ’‘ The Solution – A Tree, Not a Mess
#

Radia Perlman (often called the β€œMother of the Internet”) designed Spanning Tree Protocol (STP).

β†’ STP detects loops β†’ blocks redundant paths β†’ reactivates them only if needed. β†’ You can design networks with redundancy but still stay loop-free.


How Does STP Work?
#

When switches boot up on a redundant network:

  1. Each switch assumes it is the Root Bridge πŸ‘‘
  2. It starts sending BPDUs (Bridge Protocol Data Units) every 2 seconds β†’ β€œHey, I’m the root!”

πŸ† Root Bridge Election
#

Switches compare Bridge IDs to decide who’s the real Root Bridge.

Bridge ID = Bridge Priority + MAC Address

  • Default Bridge Priority = 32768 (range 0 – 65535)
  • If priorities are the same β†’ switch with the lowest MAC address wins πŸ₯‡

Once a switch hears a better BPDU β†’ it gives up and forwards that BPDU instead.


πŸŒ‰ Root Port Election
#

After the Root Bridge is chosen β†’ all other switches pick their Root Port.

  • The Root Port = port with the lowest cost path to reach the Root Bridge.
  • STP path costs depend on link speed:
Link SpeedSTP Cost
10 Mbps100
100 Mbps19
1 Gbps4
10 Gbps2

πŸ‘‰ Faster links = lower cost.


πŸ“ Designated & Blocking Ports
#

To break loops:

  • Each network segment (collision domain) must have one Designated Port β†’ the port with lowest cost to the Root Bridge.
  • All other redundant ports β†’ go into Blocking State.
  • Blocking Ports do not forward traffic β†’ preventing loops.

πŸ”„ STP Convergence
#

STP transitions ports through states before forwarding traffic:

STP StateWhat HappensTime
BlockingDoesn’t forward, only listens20 sec
ListeningListens for BPDUs15 sec
LearningBuilds MAC table15 sec
ForwardingFinally sends trafficForever

πŸ‘‰ Total recovery time from a failure = 50 seconds. That’s a lifetime in networking.


⚑ Failures & Recovery
#

Example: If a Root Port fails β†’

  1. Switch notices no more BPDUs.
  2. Blocked port moves β†’ Listening β†’ Learning β†’ Forwarding.
  3. Connectivity restored… after 50 seconds ⏳

πŸ’‘ Modern networks use RSTP (Rapid Spanning Tree Protocol) β†’ recovery in 1–2 seconds.


🧩 BPDU Basics
#

Each BPDU carries:

  1. Bridge ID (BID) = Priority + MAC Address
  2. Root Bridge ID = Who the root is (initially, itself)
  3. Path Cost = Total cost to reach the root

Cisco Configurations
#

STP is on by default in Cisco switches. But here are useful tweaks:

Enable STP (default PVST):

Switch(config)# spanning-tree mode pvst

Set a switch as Root Bridge (lower priority wins):

Switch(config)# spanning-tree vlan 10 priority 4096

Force port into specific STP role:

Switch(config-if)# spanning-tree port-priority 64

Enable RSTP for faster convergence:

Switch(config)# spanning-tree mode rapid-pvst

Limitations – No Load Balancing
#

STP builds a single active path β†’ no real load balancing.

If multiple equal-cost paths exist β†’ it simply picks the neighbor with the lowest Bridge ID. The rest sit idle in blocking state.


🌳 Wrapping Up
#

Without STP, networks with redundant links would collapse under their own loops.

  • Redundancy is good β†’ but needs control.
  • STP keeps one tree-like active topology.
  • RSTP makes it much faster in modern networks.

Every time you connect redundant switches, just remember β†’ Radia Perlman saved the day with a tree. 🌲

Anish Pant
Author
Anish Pant