Post

STP & RSTP

STP & RSTP

🌐 Spanning Tree Protocol (STP) & Rapid Spanning Tree Protocol (RSTP) β€” Technical Notes

πŸ“Œ Introduction: Why STP is Critical

  • Ethernet LANs use redundant paths for fault tolerance.

  • Layer 2 Loops can occur due to lack of TTL (Time-to-Live) in Ethernet frames.

  • Loops cause:
    • Broadcast Storms (uncontrolled BUM traffic)

    • MAC Address Flapping (instability in switch MAC tables)

  • STP (802.1D) and RSTP (802.1w) solve these by:

    • Creating a loop-free logical topology

    • Blocking redundant links

πŸ”§ STP (Spanning Tree Protocol) - IEEE 802.1D / Cisco PVST+

πŸ”Έ STP Overview

  • Default protocol on Cisco switches.

  • PVST+: Cisco’s version β€” one STP instance per VLAN (Per-VLAN STP).

  • Operates via BPDU (Bridge Protocol Data Unit) exchanges every 2 seconds.

πŸ”Ή STP Algorithm: 3-Step Process

1. Root Bridge Election

Switch with the lowest Bridge ID (BID) becomes Root Bridge.

BID = Bridge Priority (default: 32768 + VLAN ID) + MAC Address.

Commands:

1
2
spanning-tree vlan 10 priority 0
spanning-tree vlan 10 root primary
  • Verify: show spanning-tree

2. Root Port Selection

  • On non-root switches, select port with lowest path cost to the root.

  • Tie-breakers (in order):

    • Lowest Root Path Cost

    • Lowest Neighbor BID

    • Lowest Neighbor Port ID

    • Lowest Local Port ID

  • Cost values:

    • 10 Mbps: 100

    • 100 Mbps: 19

    • 1 Gbps: 4

    • 10 Gbps: 2

3. Designated Port Selection

  • One Designated Port per segment (responsible for forwarding).

  • All other ports: Non-Designated (Blocking)

πŸ”Ή STP Port States

  1. Disabled – Admin down

  2. Blocking – No data traffic, receives BPDUs

  3. Listening – No traffic, sending/receiving BPDUs

  4. Learning – Learns MACs, no data forwarding

  5. Forwarding – Full forwarding

➑️ Transition: Listening (15s) β†’ Learning (15s) β†’ Forwarding

πŸ”Ή STP Timers

TimerDefaultPurpose
Hello2sBPDU interval
Forward Delay15sTime in Listening & Learning
Max Age20sTimeout for BPDU absence

➑️ Convergence Time: Up to 50 seconds

⚑ RSTP (Rapid STP) - IEEE 802.1w / Cisco Rapid PVST+

πŸ”Έ Key Improvements Over STP

FeatureSTPRSTP
Convergence SpeedUp to 50s< 1s (best case)
Port States5 (including disabled)3 (Discarding, Learning, Forwarding)
Transition MethodTimer-basedSync mechanism
Port RolesRoot, Designated, Non-designatedRoot, Designated, Alternate, Backup
BPDU BehaviorOnly Root sendsAll switches send BPDUs
Topology Change DetectionMax Age (20s)3 missed BPDUs (6s)

πŸ”Ή RSTP Port States

  • Discarding = Blocking + Listening

  • Learning

  • Forwarding

πŸ”Ή RSTP Port Roles

RolePurpose
RootBest path to root bridge
DesignatedOne per segment, forwards traffic
AlternateBackup path to root (on different switch)
BackupBackup path on same segment (same switch)

πŸ”Ή RSTP Link Types

TypeDescriptionBehavior
Point-to-PointFull-duplex links (default)Fast transitions
SharedHalf-duplex/hub linksFalls back to STP behavior
EdgeEnd-device portsInstant forwarding (PortFast)
  • Configure with:
1
2
spanning-tree portfast
spanning-tree link-type point-to-point

πŸ”Ή RSTP Path Costs

RSTP uses both short and long path costs:

SpeedShort CostLong Cost
10 Mbps1002,000,000
100 Mbps19200,000
1 Gbps420,000
10 Gbps22,000
100 Gbpsβ€”200
1 Tbpsβ€”20
10 Tbpsβ€”2

Configure:

1
spanning-tree pathcost method {short | long}

πŸ› οΈ Cisco STP Toolkit Features (STP & RSTP Enhancements)

FeatureFunction
PortFastEnables fast transition on edge ports (end hosts only).
BPDU GuardShuts down a PortFast port if BPDU is received.
Root GuardPrevents external switches from becoming root.
Loop GuardPrevents non-designated ports from errantly forwarding.
BPDU FilterStops BPDUs on specific ports (risky if misused).

πŸ”€ MSTP (Multiple Spanning Tree Protocol) - IEEE 802.1s

  • Solves scalability issues in PVST+ by grouping VLANs into MST instances.

  • Runs a single STP instance per group (not per VLAN).

  • Uses RSTP mechanics for fast convergence.

  • Example: VLANs 1–50 β†’ MSTI1, VLANs 51–100 β†’ MSTI2

🌐 ICCP STP Application (RFC 7727)

  • Used in Provider Edge (PE) redundancy scenarios.

  • Multiple PEs act as a virtual root bridge.

  • Uses ICCP TLVs for config/state sync:

    • STP Connect, Root Time, Region Config, etc.
  • Enables active-active operation, unlike VPLS (active-standby).

  • If a PE fails β†’ remaining PEs recalculate and reconverge.

πŸ“‘ RSTP Management via MIB – RFC 4318

  • Adds managed objects to Bridge MIB (RFC 4188).

  • Important Objects:

    • dot1dStpVersion

    • dot1dStpPortAdminEdgePort

    • dot1dStpPortOperEdgePort

    • dot1dStpPortAdminPathCost

  • Security Consideration: SNMPv3 recommended due to sensitivity of STP control.

πŸ” STP vs RSTP β€” Summary Table

FeatureSTP (802.1D / PVST+)RSTP (802.1w / Rapid PVST+)
Convergence TimeUp to 50s< 6s (often < 1s)
Port States53
Port RolesRoot, Designated, Non-DesignatedRoot, Designated, Alternate, Backup
BPDU HandlingOnly root bridge generatesAll switches generate
Topology Change Detection20s (Max Age)6s (3 missed BPDUs)
Edge Port BehaviorTriggers TCDoes not trigger TC
Link TypesN/AP2P, Shared, Edge
PortFast/Toolkit SupportYesYes
VLAN ScalingOne STP per VLAN (PVST+)Better with MSTP

βœ… Interview Tips

  • Be clear on Root Port vs Designated Port logic.

  • Understand BPDU Guard vs Root Guard vs Loop Guard differences.

  • Know the transition states and timers.

  • Practice troubleshooting scenarios with:

1
2
show spanning-tree
debug spanning-tree events

πŸ™Œ Connect With Me

GitHub LinkedIn YouTube Gmail

This post is licensed under CC BY 4.0 by the author.