NetworkTools
Sign In
1Switch Forwarding & MAC Tables2VLANs & Trunking3Spanning Tree Protocol4RSTP & MSTP5Link Aggregation (LACP)6LLDP & CDP7ARP
← Back to Switching & VLANs

Learning Objectives

  • Understand why Spanning Tree Protocol is necessary in redundant networks
  • Explain how STP elects a root bridge and blocks redundant paths
  • Trace the BPDU exchange used to converge the spanning tree

The Problem: Broadcast Storms

Redundant links are essential for network reliability — if one link fails, traffic can use the backup. But redundancy creates a problem: loops. In a layer 2 network with no loop prevention, a broadcast frame circulates forever, multiplying with each pass. This is called a broadcast storm.

Consider three switches connected in a triangle. Switch A sends a broadcast. Switches B and C receive it and each refloods it out every other port. Switch A receives the broadcast back from B and C and floods it again. Within seconds, the frames consume all available bandwidth, the switch CPUs hit 100%, and the network is unusable.

How STP Solves It

Spanning Tree Protocol (STP), defined in IEEE 802.1D, prevents loops by creating a loop-free logical topology — a spanning tree — over the physical mesh. It works by:

  1. Electing a root bridge — one switch is chosen as the central reference point
  2. Selecting root ports — each non-root switch picks its best path to the root
  3. Selecting designated ports — each segment picks one switch to forward traffic
  4. Blocking the rest — ports that aren't root or designated are placed in blocking state

The magic is that STP converges the network to a tree where there is exactly one active path between any two switches. The redundant links stay in blocking mode, ready to activate if the primary path fails.

STP BPDU Exchange

Bridge ID and Path Cost

STP uses two main criteria in its decisions. The Bridge ID is an 8-byte value combining a 2-byte priority (default 32768) and the switch's MAC address. The switch with the lowest Bridge ID wins the root election.

The Path Cost represents the cumulative cost from a switch back to the root bridge. Each link has a cost based on its speed:

| Link Speed | STP Cost (802.1D) | Rapid STP Cost | |---|---|---| | 10 Mbps | 100 | 2,000,000 | | 100 Mbps | 19 | 200,000 | | 1 Gbps | 4 | 20,000 | | 10 Gbps | 2 | 2,000 | | 100 Gbps | — | 200 |

The path cost is the sum of all link costs along the path to the root bridge. When two ports offer equal cost, STP uses the lowest neighbor bridge ID, then the lowest neighbor port ID, as tiebreakers.

Port States

An STP port transitions through these states:

| State | Purpose | Time in State | |---|---|---| | Blocking | No frames forwarded, no MAC learning | 20 sec (max age) | | Listening | Listening for BPDUs, no forwarding | 15 sec (forward delay) | | Learning | Learning MACs, no forwarding | 15 sec (forward delay) | | Forwarding | Full operation — forward + learn | Normal operation |

This 50-second convergence time (20 + 15 + 15) is one of STP's biggest drawbacks — it's slow. If a link fails, it takes 30-50 seconds for the backup link to start forwarding. This is the primary motivation for Rapid Spanning Tree Protocol (RSTP), covered in the next lesson.

STP Topology

SW1 is the root bridge. SW2's Gi0/2 is blocked (shown dashed) to break the loop. If Gi0/1 fails, Gi0/2 transitions through listening → learning → forwarding.

SW1 (Root) Priority: 4096SW2 Priority: 32768SW3 Priority: 32768

What is the primary purpose of Spanning Tree Protocol?

How long does classic STP typically take to converge after a link failure?

Key Takeaways

  • Redundant Layer 2 links create loops that cause broadcast storms
  • STP elects a root bridge and builds a loop-free tree by blocking selected ports
  • BPDUs carry bridge IDs and path costs to inform the election and port selection
  • Ports transition through blocking → listening → learning → forwarding
  • Classic STP convergence takes up to 50 seconds — too slow for modern networks
PreviousVLANs & TrunkingNextRSTP & MSTP