Table of Contents
- Introduction
- What is Spanning Tree Protocol (STP)?
- Why Do We Need STP?
- Understanding Layer 2 Switching Loops
- Problems Caused by Switching Loops
- How STP Solves Layer 2 Loops
- STP Terminology
- Bridge ID (BID)
- Root Bridge Election Process
- Bridge Priority and MAC Address
- BPDU (Bridge Protocol Data Unit)
- Example Network
- Summary
1. Introduction
Modern computer networks rely heavily on Ethernet switches to interconnect devices efficiently. Unlike hubs, switches learn the MAC addresses of connected devices and intelligently forward frames only to the correct destination. This significantly improves performance and reduces unnecessary traffic.
As organizations grow, network designers often connect multiple switches together to increase scalability and provide redundant links. Redundancy is essential because it eliminates a single point of failure. If one cable or switch fails, another path is available, ensuring continuous connectivity.
However, redundancy introduces a major problem at Layer 2: switching loops.
Unlike routers, Ethernet frames do not include a Time to Live (TTL) field. If a Layer 2 loop exists, frames can circulate indefinitely, consuming bandwidth and overwhelming network devices.
To solve this problem, the IEEE developed the Spanning Tree Protocol (STP), standardized as IEEE 802.1D. STP intelligently detects loops and blocks redundant paths while keeping them available as backups.
In simple terms:
STP creates a loop-free logical topology while allowing physical redundancy in the network.
2. What is Spanning Tree Protocol (STP)?
Spanning Tree Protocol (STP) is a Layer 2 protocol designed to prevent switching loops in Ethernet networks.
Instead of allowing all redundant links to forward traffic simultaneously, STP identifies unnecessary paths and places them into a blocking state. If the active path fails, STP automatically activates one of the blocked links, maintaining network connectivity.
IEEE Standard
- IEEE 802.1D
OSI Layer
- Layer 2 (Data Link Layer)
Protocol Purpose
- Prevent switching loops
- Eliminate broadcast storms
- Prevent MAC table instability
- Provide network redundancy
- Automatically recover from failures
3. Why Do We Need STP?
Imagine three switches connected in a triangle.
Switch A
/ \
/ \
Switch B ------- Switch C
This design provides redundancy. If one link fails, traffic can use another path.
However, because all three links are active, Ethernet frames can travel in circles forever.
Unlike IP packets, Ethernet frames have no TTL (Time To Live) field.
As a result:
- Frames never expire.
- Broadcast traffic keeps circulating.
- Unknown unicast frames continue flooding.
- Switches repeatedly relearn MAC addresses on different ports.
Eventually, the network becomes unusable.
STP prevents this by logically disabling one of the redundant links while keeping it available for failover.
4. Understanding Layer 2 Switching Loops
A switching loop occurs when there are multiple active Layer 2 paths between switches.
Example:
PC1
|
Switch A
/ \
/ \
B-------C
Suppose PC1 sends an ARP broadcast.
Since broadcasts are flooded:
- Switch A forwards to B and C.
- B forwards to C.
- C forwards to A.
- A receives the same broadcast again.
- A floods it once more.
The cycle repeats indefinitely.
Because Ethernet has no mechanism to stop this repetition, the frame loops forever.
This is called a Layer 2 loop.
5. Problems Caused by Switching Loops
Switching loops can lead to several critical issues.
5.1 Broadcast Storm
A broadcast storm occurs when broadcast frames continuously circulate through the network.
Each switch floods the broadcast frame out all ports except the one on which it was received. In a looped topology, the same frame keeps returning and being retransmitted.
Broadcast
A → B → C → A → B → C → A
The amount of broadcast traffic grows exponentially.
Effects:
- Network bandwidth becomes saturated.
- CPU utilization on switches increases.
- End devices struggle to communicate.
- Applications become slow or unresponsive.
- In severe cases, the network may completely fail.
5.2 MAC Address Table Instability
Switches learn MAC addresses by recording the source MAC address of incoming frames.
Example:
Initially, Switch A learns:
MAC Address Port
AAAA Fa0/1
Because of the loop, the same frame later arrives on another interface.
Now Switch A updates its table:
AAAA Fa0/3
Moments later:
AAAA Fa0/1
Then:
AAAA Fa0/3
The MAC address constantly changes ports.
This behavior is called MAC Address Table Instability or MAC Flapping.
Consequences:
- Incorrect forwarding decisions
- High CPU usage
- Packet loss
- Network instability
5.3 Duplicate Frames
Because multiple paths exist, the destination may receive identical copies of the same frame.
For example:
PC1 ---- Switch A
/ \
Switch B Switch C
\ /
PC2
PC2 may receive:
Frame #1
Frame #1
Frame #1
Applications are generally not designed to process duplicate Ethernet frames, leading to inconsistent behavior.
5.4 Multiple Frame Copies
Broadcasts continue multiplying.
One frame becomes:
1
2
4
8
16
32
64
Within seconds, millions of frames can flood the network.
This exponential growth quickly consumes available bandwidth.
6. How STP Solves Layer 2 Loops
Instead of removing redundant links physically, STP creates a logical tree topology.
Only one active path remains between any two switches.
Example:
Without STP:
A
/ \
/ \
B-----C
Loop exists.
With STP:
A
/ \
/ X
B-----C
One link is placed into the Blocking state.
Traffic flows without loops.
If an active link fails:
A----B
X
C
STP automatically activates the previously blocked link.
Redundancy is preserved without creating loops.
7. STP Terminology
Understanding STP terminology is essential before diving into its operation.
Term
Description
Bridge
Another name for an Ethernet switch in STP terminology.
Root Bridge
The switch elected as the central reference point for the STP topology.
Non-Root Bridge
Any switch that is not elected as the Root Bridge.
Bridge ID (BID)
A unique identifier used to elect the Root Bridge.
Root Port (RP)
On a non-root switch, the port with the lowest path cost toward the Root Bridge.
Designated Port (DP)
The forwarding port for a network segment, chosen based on the best path to the Root Bridge.
Non-Designated Port
A redundant port placed into the Blocking state to prevent loops.
Path Cost
A numerical value representing the cost of reaching the Root Bridge over a link. Lower is better.
BPDU
Bridge Protocol Data Unit used by switches to exchange STP information.
8. Bridge ID (BID)
Every switch participating in STP has a Bridge ID (BID). This identifier is used during the election of the Root Bridge.
A Bridge ID consists of:
Bridge ID
=
Bridge Priority
+
Extended System ID (VLAN ID)
+
MAC Address
For IEEE 802.1D, the Bridge ID is 8 bytes (64 bits):
- Bridge Priority (4 bits effective + VLAN System ID Extension): Configurable in increments of 4096. Default priority is 32768.
- Extended System ID (12 bits): Typically carries the VLAN ID in per-VLAN STP implementations.
- MAC Address (48 bits): The unique hardware address of the switch.
Example:
Priority : 32768
VLAN : 10
MAC :
00:1A:2B:3C:4D:5E
The Bridge ID is represented as:
32778.001A.2B3C.4D5E
(32768 priority + VLAN ID 10 = 32778)
Key Point: A lower Bridge ID is always preferred.
9. Root Bridge Election Process
The Root Bridge is the most important switch in the STP topology because all path calculations are made relative to it.
The election process follows these rules:
- Every switch initially assumes it is the Root Bridge.
- Each switch sends Bridge Protocol Data Units (BPDUs) advertising its own Bridge ID.
- When a switch receives a BPDU with a lower Bridge ID, it stops claiming to be the root and accepts the sender as superior.
- This comparison continues until all switches agree on a single Root Bridge.
Election Criteria (in order)
- Lowest Bridge Priority
- Lowest MAC Address (used only if priorities are equal)
Example
Switch
Priority
MAC Address
Bridge ID Result
Switch A
32768
00:AA:AA:AA:AA:01
Lowest
Switch B
32768
00:AA:AA:AA:AA:05
Higher
Switch C
32768
00:AA:AA:AA:AA:09
Highest
Since all priorities are equal, Switch A becomes the Root Bridge because it has the lowest MAC address.
If an administrator configures Switch C with a priority of 24576, then Switch C becomes the Root Bridge even though its MAC address is higher, because priority takes precedence over the MAC address.
10. Bridge Priority and MAC Address
To influence which switch becomes the Root Bridge, administrators usually adjust the bridge priority.
Common priority values are:
Priority
0
4096
8192
12288
16384
20480
24576
28672
32768 (Default)
36864
40960
45056
49152
53248
57344
61440
Because the priority field changes in increments of 4096, values such as 32769 or 10000 are not valid bridge priorities.
11. BPDU (Bridge Protocol Data Unit)
STP switches communicate using Bridge Protocol Data Units (BPDUs).
A BPDU carries the information needed for switches to agree on a loop-free topology.
Important BPDU fields include:
- Root Bridge ID
- Root Path Cost
- Sender Bridge ID
- Sender Port ID
- Hello Time
- Max Age
- Forward Delay
The Root Bridge originates Configuration BPDUs at regular intervals (by default every 2 seconds). Non-root switches receive these BPDUs, update relevant information such as path cost, and forward the superior information toward downstream switches. By continuously exchanging BPDUs, all switches maintain a consistent view of the spanning-tree topology.
12. Example Network
Consider three switches:
Switch A
/ \
/ \
Switch B ------ Switch C
All switches start by believing they are the Root Bridge.
After exchanging BPDUs:
- Switch A has the lowest Bridge ID.
- Switch B receives A's superior BPDU and accepts A as the Root Bridge.
- Switch C does the same.
The network now agrees on Switch A as the Root Bridge. In the next phase (covered in Part 2), STP selects the Root Ports, Designated Ports, and any Blocking Ports based on path cost, creating a loop-free logical topology while preserving physical redundancy.
Summary
In this first part, we established why Spanning Tree Protocol is essential in Ethernet networks:
- Ethernet redundancy can create Layer 2 loops.
- Loops lead to broadcast storms, duplicate frames, and MAC address table instability.
- STP (IEEE 802.1D) prevents loops by building a loop-free logical topology.
- Every switch has a Bridge ID, composed of a configurable priority, the VLAN system ID extension, and a MAC address.
- The Root Bridge is elected using the lowest Bridge ID, with bridge priority compared first and MAC address used as a tie-breaker.
- Switches exchange BPDUs to share topology information and maintain a consistent spanning tree.
Up Next: Part 2
The next part will explain the operational details of STP, including:
- How Root Path Cost is calculated
- IEEE path cost values for different interface speeds
- Root Port selection
- Designated Port selection
- Blocking (Non-Designated) ports
- STP port states (Blocking, Listening, Learning, Forwarding, Disabled)
- STP timers (Hello, Max Age, Forward Delay)
- A complete step-by-step topology example showing how STP converges and prevents loops.
Spanning Tree Protocol (STP) Explained – Complete Guide
Part 2: Port Cost, Port Roles, Port States, STP Timers, and Convergence
Table of Contents
- Review of Part 1
- Understanding STP Topology
- Root Path Cost
- STP Path Cost Table
- How STP Calculates the Best Path
- Root Port (RP) Selection
- Designated Port (DP) Selection
- Non-Designated (Blocking) Port Selection
- STP Tie-Breaker Rules
- Port States
- STP Timers
- Complete STP Convergence Process
- Real-World Example
- Cisco Verification Commands
- Summary
1. Review of Part 1
In the previous part, we learned:
- Why Ethernet loops occur
- Problems caused by switching loops
- Broadcast storms
- MAC address table instability
- Duplicate frames
- Bridge ID (BID)
- Root Bridge Election
- BPDU Basics
Now, we'll explore how STP builds a loop-free topology by selecting the best paths and blocking redundant links.
2. Understanding the STP Topology
Once the Root Bridge has been elected, every switch must determine the most efficient route to reach it.
STP builds a tree using three fundamental rules:
- There must be only one Root Bridge.
- Every non-root switch must have one Root Port.
- Every network segment must have one Designated Port.
Any additional redundant ports are placed into the Blocking state.
Think of STP as a road navigation system. If several roads lead to the same destination, it chooses the shortest route and temporarily closes the others to avoid traffic loops.
3. Root Path Cost
A Root Path Cost is the cumulative cost from a switch to the Root Bridge.
Each Ethernet link has a numerical cost based on its speed. STP sums these values along the path.
Formula:
Root Path Cost = Sum of all link costs to the Root Bridge
The lower the cost, the better the path.
Example
Root Bridge
|
1 Gbps
Cost = 4
|
Switch A
|
100 Mbps
Cost = 19
|
Switch B
Root Path Cost for Switch B:
4 + 19 = 23
If another path has a cost of 42, STP chooses the path with 23.
4. IEEE STP Path Cost Table
The original IEEE 802.1D standard assigned path costs based on interface speed. Newer revisions use larger values to better distinguish faster links.
Original IEEE Cost Table
Link Speed
STP Cost
10 Mbps
100
100 Mbps
19
1 Gbps
4
10 Gbps
2
Revised IEEE Long Path Cost
Link Speed
Cost
10 Mbps
2,000,000
100 Mbps
200,000
1 Gbps
20,000
10 Gbps
2,000
40 Gbps
500
100 Gbps
200
CCNA Tip: Most Cisco CCNA lab questions still use the original short cost values (19, 4, 2), unless otherwise specified.
5. How STP Calculates the Best Path
Consider this topology:
Root Bridge
/ \
Cost 4 Cost 19
/ \
Switch A ------- Switch B
\ /
Cost 19
\ /
Switch C
Path 1
Switch C → Switch A → Root
19 + 4 = 23
Path 2
Switch C → Switch B → Root
19 + 19 = 38
STP chooses Path 1 because 23 < 38.
The port on Switch C leading toward Switch A becomes the Root Port.
6. Root Port (RP)
A Root Port is the port on a non-root switch that provides the lowest-cost path to the Root Bridge.
Important Rules
- Only one Root Port exists on each non-root switch.
- The Root Bridge never has a Root Port.
- The Root Port is always in the Forwarding state.
Example
Root
|
|
Switch A
/ \
/ \
Switch B Switch C
Switch B selects the interface toward Switch A as its Root Port.
Switch C also selects the interface toward Switch A as its Root Port.
Root Port Selection Criteria
If there are multiple paths with different costs, the lowest cost wins.
If costs are equal, STP applies tie-breakers in the following order:
- Lowest Root Path Cost
- Lowest Sender Bridge ID
- Lowest Sender Port ID
- Lowest Local Port ID
Example 1
Switch B
Port Fa0/1 → Cost 19
Port Fa0/2 → Cost 38
Winner:
Fa0/1
Example 2 (Equal Cost)
Switch A ---- Switch B
\
\
Switch C
If both links have equal cost:
- Compare the Bridge ID of the neighboring switches.
- The port connected to the switch with the lower Bridge ID becomes the Root Port.
7. Designated Port (DP)
A Designated Port is the forwarding port selected for each network segment.
It is responsible for sending frames toward that segment.
Rules
- Every network segment has exactly one Designated Port.
- The Root Bridge's ports are always Designated Ports.
- Designated Ports always forward traffic.
Example
Root Bridge
/ \
/ \
Switch B -------- Switch C
Both ports on the Root Bridge are Designated Ports because they connect directly to different network segments.
Designated Port Selection
The switch with the lowest Root Path Cost on a segment becomes the Designated Bridge, and its port on that segment becomes the Designated Port.
If the costs are equal:
- Lowest Bridge ID wins.
- If still tied, lowest Port ID wins.
8. Non-Designated Port (Blocking Port)
Once STP has selected the Root Port and Designated Port, any remaining redundant port is placed into the Blocking state.
This port:
- Does not forward user traffic.
- Still receives BPDUs.
- Prevents switching loops.
- Can quickly transition to forwarding if the active path fails.
Example
Root
/ \
/ \
B---------C
Assume the link between B and C is redundant.
One side is elected the Designated Port.
The other side becomes the Blocking (Non-Designated) Port.
The physical cable remains connected, but no data frames traverse it unless STP activates it.
9. STP Tie-Breaker Rules
Sometimes, multiple paths appear equally good. STP resolves these situations using a defined sequence of comparisons.
Priority
Decision
1
Lowest Root Path Cost
2
Lowest Root Bridge ID
3
Lowest Sender Bridge ID
4
Lowest Sender Port ID
5
Lowest Local Port ID
This deterministic process ensures all switches independently reach the same topology.
10. STP Port States
Classic IEEE 802.1D defines five operational port states.
1. Blocking
- Receives BPDUs
- Does not learn MAC addresses
- Does not forward frames
- Prevents loops
2. Listening
The switch has decided the port may become active.
Actions:
- Receives and sends BPDUs
- Does not learn MAC addresses
- Does not forward data traffic
Duration: 15 seconds (default Forward Delay)
3. Learning
The port starts learning MAC addresses.
Actions:
- Learns source MAC addresses
- Does not forward user traffic
- Continues BPDU processing
Duration: 15 seconds
4. Forwarding
The port is fully operational.
It:
- Learns MAC addresses
- Sends and receives frames
- Sends and receives BPDUs
5. Disabled
The interface is administratively down or has failed.
No STP activity occurs.
Port State Transition
Blocking
↓
Listening
↓
Learning
↓
Forwarding
This sequence helps prevent temporary loops while topology changes are being validated.
11. STP Timers
Timers control how quickly STP reacts to changes.
Hello Timer
- Default: 2 seconds
- Determines how often the Root Bridge sends Configuration BPDUs.
Forward Delay
- Default: 15 seconds
- Time spent in Listening.
- Time spent in Learning.
Total:
15 + 15 = 30 seconds
before a port reaches Forwarding.
Max Age
- Default: 20 seconds
- The maximum age of BPDU information before it is considered invalid.
Convergence Time
In classic STP:
20 + 15 + 15
= 50 seconds (worst case)
This relatively slow convergence was one of the motivations for Rapid Spanning Tree Protocol (RSTP), which we will cover in Part 3.
12. Complete STP Convergence Process
Let's walk through the sequence from startup to a stable topology.
Step 1
All switches power on and assume:
"I am the Root Bridge."
They begin sending BPDUs advertising their own Bridge IDs.
Step 2
Switches compare received BPDUs.
The switch with the lowest Bridge ID is elected Root Bridge.
Step 3
Each non-root switch calculates the lowest Root Path Cost and selects its Root Port.
Step 4
On every shared segment, STP elects a Designated Port based on the lowest path cost (and tie-breakers if needed).
Step 5
All remaining redundant ports transition to the Blocking state.
Step 6
Ports move through Listening and Learning before entering the Forwarding state.
The network is now loop-free while retaining backup links.
13. Real-World Example
SW1
(Root Bridge)
/ \
1G 1G
/ \
SW2 --------100M------ SW3
Link Costs
- SW1 ↔ SW2 = 4
- SW1 ↔ SW3 = 4
- SW2 ↔ SW3 = 19
Root Bridge: SW1
SW2 Root Port: Toward SW1 (Cost 4)
SW3 Root Port: Toward SW1 (Cost 4)
On the SW2–SW3 segment, both switches advertise the same Root Path Cost (4). STP therefore compares their Bridge IDs. The switch with the lower Bridge ID becomes the Designated Bridge for that segment, and its port remains forwarding. The other switch's port transitions to Blocking.
The result is a single active path between every pair of switches with a standby link ready for failover.
14. Cisco Verification Commands
Verify STP status with these commands:
show spanning-tree
Displays:
- Root Bridge
- Local Bridge ID
- Port roles
- Port states
- Timers
Check a specific VLAN:
show spanning-tree vlan 10
Display interface details:
show spanning-tree interface GigabitEthernet0/1
View bridge information:
show spanning-tree root
Check blocked interfaces:
show spanning-tree blockedports
CCNA Interview Questions
Q1. How many Root Bridges can exist in one STP instance?
Answer: One.
Q2. Can the Root Bridge have a Root Port?
Answer: No. All of its active ports are Designated Ports.
Q3. What determines the Root Bridge?
Answer: The lowest Bridge ID (lowest bridge priority first, then lowest MAC address if priorities are equal).
Q4. How many Root Ports can a switch have?
Answer: Exactly one per STP instance on each non-root switch.
Q5. Why are some ports blocked?
Answer: To eliminate Layer 2 loops while preserving redundant physical links.
Summary
In this second part, we examined how STP transforms a redundant physical topology into a loop-free logical topology:
- Root Path Cost is the cumulative cost from a switch to the Root Bridge.
- Each non-root switch selects a single Root Port with the lowest path cost.
- Each network segment elects one Designated Port to forward traffic.
- Redundant ports become Blocking (Non-Designated) Ports, preventing loops without removing cables.
- Classic STP ports transition through Blocking → Listening → Learning → Forwarding, with convergence typically taking up to 50 seconds in the worst case.
- Cisco IOS provides commands such as show spanning-tree to inspect the active topology and troubleshoot elections.
Coming in Part 3 (Advanced STP)
The final part will cover:
- IEEE 802.1D vs RSTP (802.1w) vs MSTP (802.1s)
- PVST+, Rapid PVST+, and Cisco's per-VLAN spanning tree implementations
- Cisco enhancements: PortFast, BPDU Guard, Root Guard, Loop Guard, UplinkFast, and BackboneFast
- Topology change notifications (TCN)
- Real-world enterprise design recommendations
- Common troubleshooting scenarios
- Best practices
- CCNA and CCNP interview questions with answers
- A comparison table of all STP variants and when to use each.
Spanning Tree Protocol (STP) Explained – Complete Guide
Part 3: RSTP, MSTP, PVST+, Cisco Enhancements, Troubleshooting, Best Practices, and Interview Questions
Estimated Reading Time: 20–25 Minutes
Table of Contents
- Introduction
- Limitations of Traditional STP
- Rapid Spanning Tree Protocol (RSTP)
- Multiple Spanning Tree Protocol (MSTP)
- PVST and Rapid PVST+
- STP Versions Comparison
- Cisco STP Enhancements
- STP Topology Change Process
- STP Failure Scenarios
- STP Best Practices
- Cisco STP Commands
- Troubleshooting STP
- Interview Questions
- Conclusion
1. Introduction
In Parts 1 and 2, we learned how IEEE 802.1D Spanning Tree Protocol (STP) prevents Layer 2 loops by electing a Root Bridge, selecting Root Ports and Designated Ports, and placing redundant ports into a Blocking state.
Although classic STP is highly reliable, it has one major drawback: slow convergence. When a topology changes—such as a link or switch failure—classic STP may take 30 to 50 seconds to restore connectivity. In modern enterprise networks, this delay can interrupt voice calls, video conferencing, and critical business applications.
To overcome this limitation, IEEE introduced Rapid Spanning Tree Protocol (RSTP) and later Multiple Spanning Tree Protocol (MSTP). Cisco also developed several enhancements to improve convergence and protect the network from misconfigurations.
2. Limitations of Traditional STP (IEEE 802.1D)
Traditional STP works well but has several limitations:
1. Slow Convergence
Ports transition through:
Blocking
↓
Listening (15 sec)
↓
Learning (15 sec)
↓
Forwarding
Worst-case convergence:
20 (Max Age)
+15 (Listening)
+15 (Learning)
-----------------
50 Seconds
2. Wasted Bandwidth
Redundant links remain idle until a failure occurs.
3. One Spanning Tree
Classic STP builds only one logical tree for the entire switched network, even if multiple VLANs exist.
4. Large Network Issues
Large enterprise networks require faster recovery and better load balancing.
3. Rapid Spanning Tree Protocol (RSTP)
IEEE Standard: 802.1w
RSTP is an improved version of STP designed for fast convergence.
Instead of taking up to 50 seconds, RSTP usually converges within 1–6 seconds, depending on the network.
Advantages
- Very fast convergence
- Backward compatible with STP
- Better use of redundant links
- Faster failure detection
RSTP Port Roles
RSTP introduces two new port roles.
1. Root Port (RP)
Best path to Root Bridge.
2. Designated Port (DP)
Best port for each LAN segment.
3. Alternate Port
Provides an alternate path to the Root Bridge.
Immediately becomes active if the Root Port fails.
4. Backup Port
Provides backup to a Designated Port on the same shared segment.
Rare in modern switched Ethernet.
RSTP Port States
Unlike STP's five states, RSTP simplifies operation into three.
STP
RSTP
Blocking
Discarding
Listening
Discarding
Learning
Learning
Forwarding
Forwarding
Disabled
Discarding
RSTP combines Blocking, Listening, and Disabled into a single Discarding state.
This simplification contributes to faster convergence.
RSTP Edge Ports
An Edge Port connects directly to an end device such as:
- PC
- Printer
- IP Phone
- Server
Because no switch is expected on the other end, an Edge Port immediately enters the Forwarding state, eliminating the normal listening and learning delays.
Cisco implements this behavior through the PortFast feature.
4. Multiple Spanning Tree Protocol (MSTP)
IEEE Standard: 802.1s
Enterprise networks often have dozens or hundreds of VLANs.
Running one spanning tree per VLAN consumes CPU and memory.
MSTP solves this by allowing multiple VLANs to share the same spanning-tree instance.
Example:
VLAN
MST Instance
10
Instance 1
20
Instance 1
30
Instance 2
40
Instance 2
This reduces processing overhead while still allowing traffic engineering.
5. Cisco PVST+ and Rapid PVST+
Cisco developed Per-VLAN Spanning Tree to optimize VLAN environments.
PVST+
- One STP instance per VLAN
- Better load balancing
- Cisco proprietary
Example:
VLAN 10
Root = Switch A
VLAN 20
Root = Switch B
This allows different VLANs to use different active paths.
Rapid PVST+
Rapid PVST+ combines:
- RSTP speed
- One spanning tree per VLAN
Advantages:
- Fast convergence
- VLAN load balancing
- Widely deployed in Cisco enterprise networks
6. STP Versions Comparison
Feature
STP
RSTP
MSTP
IEEE
802.1D
802.1w
802.1s
Convergence
30–50 sec
1–6 sec
1–6 sec
VLAN Support
Single Tree
Single Tree
Multiple Instances
Port Roles
3
4
4
Port States
5
3
3
Speed
Slow
Fast
Fast
Scalability
Low
Medium
High
7. Cisco STP Enhancements
7.1 PortFast
Normally, STP waits before forwarding traffic.
End devices do not create loops.
PortFast allows access ports to move immediately to the Forwarding state.
Configure
Switch(config)# interface fa0/1
Switch(config-if)# spanning-tree portfast
Never enable PortFast on links between switches.
7.2 BPDU Guard
PortFast assumes an end device is connected.
If someone accidentally connects another switch, a loop could form.
BPDU Guard protects the network by disabling the port when a BPDU is received.
PC Port
↓
Receives BPDU
↓
Port Shutdown (Err-disabled)
Configuration:
Switch(config-if)# spanning-tree bpduguard enable
7.3 Root Guard
Prevents an unauthorized switch from becoming the Root Bridge.
If a superior BPDU is received, the port enters the Root Inconsistent state instead of allowing the new root.
Useful on ports where you never want downstream switches to influence the root election.
7.4 Loop Guard
Protects against unidirectional link failures.
Without Loop Guard:
- BPDUs stop arriving.
- STP incorrectly believes the path is free.
- The blocked port may begin forwarding.
- A Layer 2 loop forms.
Loop Guard keeps the port in a loop-inconsistent state until BPDUs return.
7.5 UplinkFast
Cisco proprietary enhancement for classic STP.
Purpose:
Rapidly activates a backup uplink after failure.
Mainly used before RSTP became common.
7.6 BackboneFast
Improves recovery after indirect failures elsewhere in the topology.
Also largely superseded by RSTP.
8. STP Topology Change Process
When a network change occurs (for example, a link fails or a switch reboots), STP must inform all switches so they can update their forwarding decisions.
Traditional STP
- Detect failure.
- Generate a Topology Change Notification (TCN) BPDU.
- Upstream switches relay the notification to the Root Bridge.
- The Root Bridge sets the Topology Change flag in Configuration BPDUs.
- All switches reduce their MAC address aging time temporarily, allowing stale entries to be removed more quickly.
- Switches relearn MAC addresses based on the new topology.
RSTP streamlines this process by rapidly propagating topology changes through proposal/agreement mechanisms, resulting in much faster convergence.
9. Common STP Failure Scenarios
Scenario 1: Root Bridge Failure
- New Root Bridge election begins.
- Switches recalculate Root Ports.
- Redundant links may transition to Forwarding.
Scenario 2: Link Failure
Primary Link Down
↓
Blocked Port Activated
↓
Traffic Restored
Classic STP may take up to 50 seconds, whereas RSTP typically restores connectivity within a few seconds.
Scenario 3: Misconfigured Priority
If an access switch is configured with a lower bridge priority than the intended core switch, it may become the Root Bridge.
This can lead to inefficient traffic paths and increased latency.
Scenario 4: Unidirectional Link
A fiber transmit or receive failure may create a one-way communication path.
Loop Guard helps prevent loops in this situation.
10. STP Best Practices
1. Manually Select the Root Bridge
Do not rely on the default election.
Example:
Switch(config)# spanning-tree vlan 1 priority 4096
2. Configure a Secondary Root
Switch(config)# spanning-tree vlan 1 priority 8192
This ensures predictable failover if the primary root becomes unavailable.
3. Enable PortFast on Access Ports
Improves end-device startup time and user experience.
4. Enable BPDU Guard on Access Ports
Protects against accidental switch connections.
5. Avoid Connecting Two Access Ports Together
This common mistake can create loops if STP protections are absent or misconfigured.
6. Monitor STP Regularly
Use monitoring systems and periodic audits to ensure the intended Root Bridge and blocked ports remain unchanged.
7. Use RSTP or MSTP
Modern networks should avoid classic STP unless legacy compatibility is required.
11. Useful Cisco Commands
Display spanning-tree information:
show spanning-tree
Show Root Bridge:
show spanning-tree root
Show VLAN STP:
show spanning-tree vlan 10
Show interface details:
show spanning-tree interface gi0/1
Display bridge information:
show spanning-tree summary
Verify PortFast:
show spanning-tree interface gi0/1 detail
Check err-disabled ports:
show interfaces status err-disabled
12. Troubleshooting STP
When troubleshooting STP:
- Verify the intended Root Bridge using show spanning-tree root.
- Confirm Root Port and Designated Port roles.
- Look for unexpected Blocking ports.
- Check bridge priorities on all switches.
- Verify interface speeds and duplex settings, as these affect path cost.
- Investigate frequent topology changes, which may indicate unstable links or devices.
- Ensure PortFast and BPDU Guard are only enabled on access ports.
13. STP Interview Questions
Q1. Which switch becomes the Root Bridge?
Answer: The switch with the lowest Bridge ID (lowest bridge priority, then lowest MAC address).
Q2. Does the Root Bridge have a Root Port?
Answer: No. All of its active ports are Designated Ports.
Q3. What is the default bridge priority?
Answer: 32768.
Q4. Which protocol converges faster?
Answer: RSTP (IEEE 802.1w).
Q5. Why is PortFast used?
Answer: To allow end-device ports to transition immediately to the Forwarding state.
Q6. What does BPDU Guard do?
Answer: It disables a PortFast-enabled access port if it receives a BPDU, protecting against accidental switch connections.
Q7. Which protocol supports multiple spanning-tree instances?
Answer: MSTP (IEEE 802.1s).
Q8. Can STP prevent physical loops?
Answer: No. STP does not remove physical links; it creates a logical loop-free topology by blocking selected redundant ports.
Q9. Why is Root Guard useful?
Answer: It prevents unauthorized or incorrectly configured switches from becoming the Root Bridge.
Q10. Which Cisco STP implementation is commonly used in VLAN-based enterprise networks?
Answer: Rapid PVST+.
Key Differences at a Glance
Final Conclusion
Spanning Tree Protocol remains one of the foundational technologies of Ethernet switching. Although modern networks increasingly use technologies such as TRILL, Shortest Path Bridging (SPB), and EVPN-VXLAN in data centers, STP and its variants continue to be widely deployed in campus and enterprise access networks.
Understanding STP is essential for every network engineer because it directly affects network stability, redundancy, and availability. Mastering concepts such as Bridge ID, Root Bridge election, Root Path Cost, Port Roles, Port States, BPDUs, and Cisco enhancements like PortFast, BPDU Guard, and Root Guard will prepare you for real-world troubleshooting as well as CCNA, CCNP, and network engineering interviews.
🎓 CCNA/CCNP Exam Tips
- Remember the default Bridge Priority = 32768.
- Bridge priority changes in increments of 4096.
- The switch with the lowest Bridge ID becomes the Root Bridge.
- Every non-root switch has exactly one Root Port.
- Every network segment has exactly one Designated Port.
- The Root Bridge has no Root Port.
- RSTP (802.1w) converges much faster than classic STP.
- MSTP (802.1s) maps multiple VLANs to fewer spanning-tree instances to improve scalability.
- Use PortFast only on access ports.
- Pair PortFast with BPDU Guard to protect the network.
Author:
Samir Khatib
Related Links:
Do visit our channel to know more: SevenMentor
Samir Khatib
Expert trainer and consultant at SevenMentor with years of industry experience. Passionate about sharing knowledge and empowering the next generation of tech leaders.