The Spanning-Tree Protocol (STP) is a Layer 2 protocol that prevents loops in a switched network. Without STP, redundant links can cause broadcast storms, multiple frame copies, and network instability. STP achieves loop prevention by selectively blocking redundant paths while still allowing failover in case of link failures.
STP uses the Bridge Protocol Data Unit (BPDU) to exchange information between switches and determine the optimal topology.
Over time, different versions of STP have been developed to improve convergence speed, scalability, and VLAN support.
STP (IEEE 802.1D):
RSTP (Rapid Spanning Tree Protocol, IEEE 802.1w):
MSTP (Multiple Spanning Tree Protocol, IEEE 802.1s):
VSTP (VLAN Spanning Tree Protocol, Junos-specific):
STP assigns roles to each port on a switch based on its position in the topology. These roles determine how traffic flows and which paths are blocked.
Root Port:
Designated Port:
Blocked Port:
Alternate Port (RSTP only):
Backup Port (RSTP only):
The Bridge ID determines the Root Bridge, which serves as the reference point for the spanning-tree topology.
Components:
Root Bridge Election:
Best Practice:
Assign a lower priority to critical switches to ensure they become the Root Bridge:
set protocols stp priority 4096
BPDUs are small frames exchanged between switches to share spanning-tree information.
Contents of a BPDU:
BPDU Types:
BPDU Guard:
Protects against unintended switches connecting to the network.
Disables a port if a BPDU is received on it:
set protocols stp bpdu-guard enable
STP convergence occurs during topology changes, such as when a link fails or a new switch is added.
Steps in Convergence:
Timers in STP:
Enable STP on a specific interface:
set protocols stp interface ge-0/0/1
Enable Rapid Spanning Tree Protocol on an interface:
set protocols rstp interface ge-0/0/2
Enable VSTP for VLAN 10:
set protocols vstp vlan vlan10
Set a lower priority for a critical switch:
set protocols stp priority 4096
What is PortFast?
Why Use PortFast?
Configuration Example:
set protocols rstp interface ge-0/0/1 edge
edge keyword enables PortFast on the specified interface.What is BPDU Guard?
Why Use BPDU Guard?
Configuration Example:
set protocols rstp bpdu-guard
set protocols rstp interface ge-0/0/1 edge
What is Root Guard?
Why Use Root Guard?
Configuration Example:
set protocols rstp root-protection
What is Loop Guard?
Configuration Example:
set protocols rstp loop-protection
Manually assign Root Bridge and Backup Root Bridge by configuring priorities.
Example:
set protocols rstp bridge-priority 4096
Customize the Hello, Max Age, and Forward Delay timers based on network size and requirements:
set protocols stp hello-time 1
set protocols stp max-age 10
set protocols stp forward-delay 4
When STP issues arise, follow these steps to identify and resolve the problem.
Ensure the intended switch is the Root Bridge:
show spanning-tree
Identify port roles (Root Port, Designated Port, Blocked Port) for each interface:
show spanning-tree interface
Ensure BPDUs are being sent and received correctly:
monitor traffic interface ge-0/0/1 matching bpdu
Verify spanning-tree settings:
show configuration protocols stp
Unexpected Root Bridge:
Blocked or Misconfigured Ports:
Broadcast Storms:
The Spanning-Tree Protocol (STP) prevents Layer 2 loops in Ethernet networks by blocking redundant paths while ensuring network redundancy. It dynamically recalculates paths when topology changes occur.
STP behavior can vary based on the spanning-tree variant used. Traditional STP (802.1D) operates on a per-bridge basis, meaning it creates a single tree for all VLANs. This is inefficient in VLAN-rich environments.
STP operates per-bridge, but with MSTP and VSTP, spanning-tree instances can map to individual or groups of VLANs for optimized resource usage.
MSTP (802.1s): Allows multiple VLANs to share a single spanning-tree instance (per-region configuration).
VSTP (Juniper-specific): Enables a unique spanning-tree instance per VLAN, offering fine-grained control.
In standard STP (802.1D), port states play a crucial role during convergence. Ports go through the following stages before becoming active:
Receives and processes BPDUs.
No MAC addresses are learned.
Duration: Forward Delay timer.
Starts learning MAC addresses to populate the MAC table.
Still does not forward frames.
Duration: Forward Delay timer.
Port does not forward or learn frames to avoid loops.
Monitors for topology changes.
These transition delays (typically 15 seconds each for Listening and Learning) contribute to the slow convergence of classic STP.
Rapid Spanning Tree Protocol (RSTP – 802.1w) introduces significant improvements over classic STP.
RSTP significantly reduces convergence time by eliminating the need for listening and learning states through real-time BPDU negotiation.
RSTP introduces edge ports, alternate ports, and faster port role transitions.
Typical convergence time is under 1 second in ideal conditions.
| Topic | Key Point |
|---|---|
| STP and VLANs | MSTP and VSTP allow mapping of VLANs to individual or shared spanning-tree instances for scalability. |
| STP State Transitions | Standard STP uses Listening → Learning → Forwarding process, each with delay timers. |
| RSTP Advantage | Achieves fast convergence by bypassing traditional states via real-time BPDU exchanges. |
How does Spanning Tree select the root bridge?
The switch with the lowest bridge ID becomes the root bridge.
The bridge ID consists of two components: bridge priority and the MAC address. During STP initialization, switches exchange Bridge Protocol Data Units (BPDUs) containing their bridge IDs. The switch with the lowest bridge ID is elected as the root bridge. Once the root bridge is determined, all other switches calculate the shortest path to reach it. Administrators often manually configure bridge priority to ensure a specific switch becomes the root.
Demand Score: 75
Exam Relevance Score: 84
Why does Spanning Tree block certain ports?
To prevent Layer-2 loops in the network.
Ethernet networks that contain redundant links can create loops where frames circulate indefinitely. These loops can cause broadcast storms and MAC table instability. STP prevents loops by placing redundant links into a blocking state. Only the best path toward the root bridge remains active, while alternate paths remain blocked but ready to activate if the active path fails.
Demand Score: 72
Exam Relevance Score: 82
What is the difference between STP and RSTP?
RSTP provides faster convergence than traditional STP.
Traditional Spanning Tree Protocol may take up to 30–50 seconds to converge after a topology change because of listening and learning states. Rapid Spanning Tree Protocol (RSTP) significantly reduces convergence time by using rapid state transitions and improved handshake mechanisms. This allows networks to recover from link failures more quickly.
Demand Score: 69
Exam Relevance Score: 80
What is a designated port in Spanning Tree?
A designated port is the port responsible for forwarding traffic toward a network segment.
For each network segment, STP elects one designated port that forwards frames toward the root bridge. The selection is based on path cost and bridge ID. Only one designated port exists per segment, ensuring a loop-free topology. Other ports on that segment may become blocked to prevent loops.
Demand Score: 66
Exam Relevance Score: 78