STP
STP
π COMPREHENSIVE NOTES ON SPANNING-TREE PROTOCOL (STP)
π§© I. STP FUNDAMENTALS & NECESSITY
A. Purpose of STP
- Prevents Layer 2 loops when redundant links exist between switches.
- Redundant links ensure redundancy but can cause broadcast storms without STP.
- STP ensures loop-free topology by blocking redundant paths dynamically.
B. The Loop Problem
- In a switched network, broadcasts (e.g., ARP) flood all ports except the ingress.
- With redundant links, broadcasts can loop indefinitely, creating:
- Continuous MAC table updates (CAM flapping)
- High CPU utilization
- Network congestion or outage
C. STP Mechanism
- STP detects redundant paths using BPDUs (Bridge Protocol Data Units).
- It blocks one or more redundant links to form a logical loop-free tree.
- Uses port roles and port states to control data flow.
ποΈ II. CORE STP CONCEPTS & ELECTION PROCESS
A. Root Bridge Election
- Role of Root Bridge:
- Central reference point of the STP topology (βKing of the networkβ).
- Determines which ports on other switches forward or block.
- Per VLAN Election:
- Only one Root Bridge per VLAN.
- PVST (Per-VLAN Spanning Tree) runs separate instances per VLAN.
- Root Bridge Selection Criteria:
- Lowest Bridge Priority
- If tied, lowest MAC Address
- Priority Details:
- Default priority:
32768 - Must be multiple of
4096 - If priorities are equal β Lowest MAC wins
- Default priority:
B. Bridge ID
- Bridge ID = System Priority + MAC Address
- Used in BPDU comparison; lower Bridge ID = higher priority.
βοΈ III. STP COST & PORT SELECTION CRITERIA
A. STP Cost
- STP assigns a cost value to each interface speed.
| Interface Type | Default Cost (PVST/Rapid PVST) |
|---|---|
| 10 Mbps (Ethernet) | 100 |
| 100 Mbps (Fast Ethernet) | 19 |
| 1 Gbps | 4 |
| 10 Gbps | 2 |
- Root Bridge advertises cost = 0
- Total Path Cost = Local Port Cost + Received BPDU Cost
B. Port Roles
| Port Role | Description | Notes |
|---|---|---|
| Root Port (RP) | Best path from a non-root bridge to the Root Bridge | 1 per switch/VLAN |
| Designated Port (DP) | Best port on a link to forward frames toward Root | 1 per segment |
| Non-Designated / Blocked | Prevents loops by staying blocked | Backup path |
C. Port Selection Criteria (Four-Way Tie Breaker)
- Lowest Path Cost to Root Bridge
- Lowest Sender Bridge ID
- Lowest Port Priority (Default = 128)
- Lowest Port Number
Key Rules:
- All Root Bridge ports are Designated & Forwarding.
- Every non-root switch must have one Root Port.
- On shared links, the switch with the lowest cost to the Root wins the Designated Port.
π IV. STP MODES & PORT STATES
A. Per-VLAN Spanning Tree (PVST)
| Port State | Function | Default Timer |
|---|---|---|
| Disabled | Admin down | N/A |
| Blocking | Receives BPDUs only | N/A |
| Listening | Sends/receives BPDUs, no MAC learning | 15s |
| Learning | Learns MACs, no frame forwarding | 15s |
| Forwarding | Full data forwarding | N/A |
Convergence Time:
β 32β34 seconds (15s Listening + 15s Learning + 2s Hello)
B. Rapid Per-VLAN STP (Rapid PVST / RSTP)
- Faster convergence (~6s or less).
- TCNs (Topology Change Notifications) are sent bidirectionally.
- Port States:
- Discarding (combines Disabled, Blocking, Listening)
- Learning
- Forwarding
Port Roles:
- Root Port (RP)
- Designated Port (DP)
- Alternate Port: Backup for Root Port
- Backup Port: Backup for Designated Port
C. Multiple Spanning Tree (MST)
- IEEE 802.1s standard (vendor-neutral).
- Groups multiple VLANs into a single STP instance to reduce CPU load.
Key Characteristics:
- Instance-based, not per VLAN.
- Configured per instance:
1
spanning-tree mst instance <id> priority <value>
Default Cost (Fast Ethernet) = 200,000
Boundary Port: Interface connecting MST to PVST domain.
π οΈ V. STP CONFIGURATION & ENHANCEMENTS
A. Influencing Root Bridge Selection
- Set Manual Priority
1
spanning-tree vlan <vlan-id> priority <value>
- Root Primary/Secondary Shortcuts
1
2
spanning-tree vlan <vlan-id> root primary
spanning-tree vlan <vlan-id> root secondary
root primarysets priority to 24576 (if all others are default)
B. Influencing Port Selection
- Change STP Cost (local influence)
1
spanning-tree cost <value>
- Change Port Priority (upstream influence)
1
spanning-tree port-priority <value>
C. STP Fast Convergence Features
1. PortFast
- Used for edge/access ports connected to end hosts.
- Immediately transitions to Forwarding state (skips Listening/Learning).
- Must not be used on switch-to-switch links.
Command:spanning-tree portfast
2. UplinkFast
- Enables fast failover for uplink/trunk ports.
- Works only for direct link failures.
- Adds cost +3000 and raises bridge priority to 49152 (in PVST).
- Not needed in Rapid PVST, as RSTP has it built-in.
βοΈ VI. LOAD BALANCING USING STP
- Achieved by assigning different Root Bridges for different VLAN ranges.
- Example:
- Switch1 β Root for VLANs 1β10
- Switch2 β Root for VLANs 11β4094
- Ensures VLAN-based traffic load sharing across redundant links.
π― KEY INTERVIEW REVISION POINTS
| Topic | Key Focus |
|---|---|
| Root Bridge Election | Priority (lowest wins) + MAC tie-breaker |
| STP Costs | Lower = preferred path |
| Port Roles | Root, Designated, Alternate, Backup |
| STP Timers | Hello (2s), Forward Delay (15s), Max Age (20s) |
| Rapid PVST Advantage | <6s convergence |
| MST Benefit | VLAN grouping = CPU optimization |
| PortFast Use Case | Host connections only |
| Load Balancing | Different roots for different VLANs |
π§ QUICK MEMORY TIPS
- STP = Loop Prevention @ Layer 2
- BPDU = Heartbeat of STP
- Root Bridge = Boss; RPs report to it
- PVST β Rapid PVST β MST = Ciscoβs STP evolution
- Fast Convergence = PortFast + UplinkFast (or RSTP)
π Connect With Me
This post is licensed under CC BY 4.0 by the author.