Lesson Overview

Spanning Tree Protocol (STP) and Rapid Spanning Tree Protocol (RSTP) are essential Layer 2 technologies used to prevent switching loops and maintain network redundancy in enterprise networks.


STP (IEEE 802.1D) creates a loop-free network topology by selecting a Root Bridge and determining forwarding and blocking ports. RSTP (IEEE 802.1w) improves convergence speed, enabling faster network recovery when topology changes occur.


This lesson covers STP and RSTP operation, Root Bridge election, port roles and states, convergence, Cisco switch configuration, verification commands, and troubleshooting techniques used in enterprise switching environments.

Pasted content image

STP keeps redundant Layer 2 links while logically blocking one path to prevent loops.


Learning Objectives

  • Explain why redundant Ethernet links can create broadcast storms, MAC-table instability, and duplicate frames.
  • Explain classic IEEE 802.1D STP before moving to IEEE 802.1w RSTP.
  • Interpret BPDU fields and determine which BPDU is superior.
  • Elect the root bridge and calculate the root port, designated port, and blocked/non-designated port in classic STP.
  • Explain classic STP states and timers and why convergence can be slow.
  • Explain RSTP root bridge, root port, designated port, alternate port, backup port, and edge port.
  • Explain RSTP discarding, learning, and forwarding states.
  • Explain point-to-point, shared, and edge link types.
  • Explain proposal/agreement synchronization step by step.
  • Explain rapid convergence during direct failure, alternate-port failover, and topology change.
  • Configure Cisco Rapid PVST+, deterministic root placement, path cost, port priority, and edge ports.
  • Interpret detailed show command output and identify exactly what must be checked.
  • Troubleshoot wrong-root, unexpected-blocking, slow-convergence, VLAN/trunk, BPDU, link-type, and forwarding issues.
  • Perform a complete hands-on lab with before/after failure verification.


1. Why Spanning Tree Is Required

Ethernet has no Layer 2 TTL field. A frame that enters a physical switching loop can circulate repeatedly. Redundant links are still desirable for resiliency, so STP creates a loop-free logical tree while preserving redundant physical paths for failover.


The topology provides redundant paths, but it also creates a Layer 2 loop if all links forward Ethernet frames without an appropriate loop-prevention mechanism.

Problem without STP

What happens

Operational symptom

Broadcast storm

Broadcast/unknown-unicast frames replicate around the loop indefinitely.

Link utilization and switch CPU rise sharply; the network can become unusable.

MAC-table instability

The same source MAC is learned alternately on different interfaces.

MAC addresses “flap”; unicast traffic follows unstable paths.

Duplicate frames

Multiple copies of the same frame reach the destination.

Applications receive duplicates; ARP/DHCP and other protocols behave unpredictably.

Control-plane overload

Switches spend resources processing large volumes of Layer 2 traffic.

High CPU, slow management access, packet loss, and outages.

 

1.1 How STP Solves the Problem

STP identifies a loop-free logical topology.

It allows the required forwarding paths while placing redundant ports into a non-forwarding state.

If an active path fails, STP or RSTP can activate an alternative path.

Core idea: Spanning Tree does not remove redundancy. It temporarily blocks selected redundant links and can activate them when the active topology changes.


1.2 How Spanning Tree Works

Spanning Tree uses a distributed election and calculation process.


Step 1 - Elect a Root Bridge

Switches exchange BPDUs to identify the switch with the best Bridge ID.

The switch with the lowest Bridge ID becomes the Root Bridge.


Step 2 - Select Root Ports

Each non-root switch identifies its best path toward the Root Bridge.

The interface selected for that path becomes its Root Port.


Step 3 - Select Designated Ports

For each network segment, STP selects a Designated Port responsible for forwarding traffic toward and away from that segment.


Step 4 - Identify Redundant Paths

Ports that provide redundant paths but are not required for the active topology become non-forwarding ports.

In RSTP, an Alternate Port can provide a backup path toward the Root Bridge.


Step 5 - Maintain the Topology

Switches continue exchanging BPDUs to monitor the topology.

When network conditions change, STP recalculates the forwarding topology as necessary.


2. Classic Spanning Tree Protocol (IEEE 802.1D)

Classic STP builds one loop-free tree for a Layer 2 topology. Cisco PVST+ applies classic STP logic per VLAN. Understanding classic STP is essential because RSTP retains the same root election and path-cost fundamentals but changes convergence behavior.


2.1 BPDUs - The Information STP Uses

Switches use Bridge Protocol Data Units (BPDUs) to describe the root bridge, path cost, sender bridge, sender port, and STP timers. The “best” or superior BPDU wins and is propagated through the tree.

Pasted content image

Figure 2.1 - Important STP/RSTP BPDU fields.


Decision order for a superior BPDU

Lower value wins

1. Root Bridge ID

Lowest Root BID

2. Root Path Cost

Lowest accumulated path cost to the root

3. Sender Bridge ID

Lowest upstream/sender BID

4. Sender Port ID

Lowest sender Port ID

Exam rule: When comparing two received BPDUs, compare fields in order. Stop at the first difference. Lower Root BID wins first; only when tied do you compare Root Path Cost, then Sender BID, then Sender Port ID.


2.2 Root Bridge Election

The root bridge is the reference point for the entire spanning tree. Every switch initially assumes it is root and advertises itself. When a switch receives a superior BPDU, it adopts the better root information.


Bridge ID (BID): Bridge priority + extended system ID (VLAN on Cisco per-VLAN STP) + bridge MAC address.

Priority: Lower is better. Cisco commonly defaults to 32768; valid configured values increment by 4096.

Tie-breaker: If effective priorities tie, the lowest MAC address wins.

Design recommendation: Choose the root deliberately. Do not allow a random-access switch to become root because its MAC happens to be lowest.

Pasted content image

Figure 2.2a - Root bridge election and port-selection sequence.


Deterministic root placement

SW1(config)# spanning-tree vlan 10 root primary

SW2(config)# spanning-tree vlan 10 root secondary

 

! Explicit-priority alternative

SW1(config)# spanning-tree vlan 10 priority 24576

SW2(config)# spanning-tree vlan 10 priority 28672

Pasted content image

Figure 2.2b - Primary/secondary root design and failover.


2.3 STP Path Cost

Every non-root switch chooses a Root Port based primarily on the lowest total path cost to the root. The cost is accumulated as BPDUs travel away from the root. Platforms may use short or long path-cost methods; always verify the actual values with "show spanning-tree".

Common link speed

Common short-method cost

Long-method example

10 Mb/s

100

2,000,000

100 Mb/s

19

200,000

1 Gb/s

4

20,000

10 Gb/s

2

2,000

100 Gb/s

1 (platform dependent)

200

Troubleshooting rule: Do not memorize cost alone and assume the path. Read the cost values shown by the actual switch and STP instance, especially across different platform generations.


2.4 Root Port Selection

Every non-root switch selects exactly one Root Port per STP instance. It is the port that receives the best BPDU / provides the best path toward the root.

Tie-break order

Meaning

1. Lowest Root Path Cost

Best total cost to root.

2. Lowest upstream/sender Bridge ID

Used if cost ties.

3. Lowest upstream/sender Port ID

Used if sender BID ties.

4. Lowest local Port ID

Final local tie-break in certain equal-path conditions.


2.5 Designated Port and Blocked Port

Each Layer 2 segment elects one Designated Port - the port that advertises the best BPDU onto that segment. On the root bridge, all active STP ports are Designated Ports. A redundant port that is neither Root nor Designated is blocked/non-designated in classic STP.

Pasted content image

Figure 2.5 - Root, designated, and alternate/blocked path concepts.


2.6 Classic STP Port States

State

Forwards user traffic?

Learns MAC addresses?

Purpose / behavior

Blocking

No

No

Prevents loops while still receiving BPDUs.

Listening

No

No

Participates in STP election and waits Forward Delay.

Learning

No

Yes

Builds MAC table while waiting another Forward Delay.

Forwarding

Yes

Yes

Carries user traffic and BPDUs.

Disabled

No

No

Administratively/operationally unavailable.

Important: Classic STP does not immediately move a newly selected path to forwarding. Listening and Learning are intentionally used to avoid a temporary loop while topology information stabilizes.


2.7 Classic STP Timers and Convergence

Pasted content image

Figure 2.7 - Classic STP timers compared with rapid behavior.


Timer

Default

Why it matters

Hello Time

2 seconds

Root sends configuration BPDUs periodically.

Max Age

20 seconds

How long old root information may remain valid before aging out.

Forward Delay

15 seconds

Used for Listening and Learning transitions.

Typical legacy indirect recovery

Can approach ~50 seconds

20-second Max Age + 15-second Listening + 15-second Learning in a timer-driven case.

Do not tune casually: Changing STP timers without a validated design can destabilize the Layer 2 domain. RSTP improves convergence by changing the mechanism, not simply by making all timers tiny.

2.8 Classic STP Topology Change Process

Classic STP uses Topology Change Notification (TCN) BPDUs to tell the root that the active topology changed. The…