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:
- Broadcast Storms β Broadcast frames (like ARP requests) endlessly circled β consuming bandwidth & CPU.
- MAC Table Instability β Switches kept updating MAC tables incorrectly β same frame arriving from different ports.
- 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:
- Each switch assumes it is the Root Bridge π
- 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 Speed | STP Cost |
---|---|
10 Mbps | 100 |
100 Mbps | 19 |
1 Gbps | 4 |
10 Gbps | 2 |
π 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 State | What Happens | Time |
---|---|---|
Blocking | Doesnβt forward, only listens | 20 sec |
Listening | Listens for BPDUs | 15 sec |
Learning | Builds MAC table | 15 sec |
Forwarding | Finally sends traffic | Forever |
π Total recovery time from a failure = 50 seconds. Thatβs a lifetime in networking.
β‘ Failures & Recovery#
Example: If a Root Port fails β
- Switch notices no more BPDUs.
- Blocked port moves β Listening β Learning β Forwarding.
- Connectivity restoredβ¦ after 50 seconds β³
π‘ Modern networks use RSTP (Rapid Spanning Tree Protocol) β recovery in 1β2 seconds.
π§© BPDU Basics#
Each BPDU carries:
- Bridge ID (BID) = Priority + MAC Address
- Root Bridge ID = Who the root is (initially, itself)
- 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. π²