Post

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

  1. Role of Root Bridge:
    • Central reference point of the STP topology (β€œKing of the network”).
    • Determines which ports on other switches forward or block.
  2. Per VLAN Election:
    • Only one Root Bridge per VLAN.
    • PVST (Per-VLAN Spanning Tree) runs separate instances per VLAN.
  3. Root Bridge Selection Criteria:
    1. Lowest Bridge Priority
    2. If tied, lowest MAC Address
  4. Priority Details:
    • Default priority: 32768
    • Must be multiple of 4096
    • If priorities are equal β†’ Lowest MAC wins

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 TypeDefault Cost (PVST/Rapid PVST)
10 Mbps (Ethernet)100
100 Mbps (Fast Ethernet)19
1 Gbps4
10 Gbps2
  • Root Bridge advertises cost = 0
  • Total Path Cost = Local Port Cost + Received BPDU Cost

B. Port Roles

Port RoleDescriptionNotes
Root Port (RP)Best path from a non-root bridge to the Root Bridge1 per switch/VLAN
Designated Port (DP)Best port on a link to forward frames toward Root1 per segment
Non-Designated / BlockedPrevents loops by staying blockedBackup path

C. Port Selection Criteria (Four-Way Tie Breaker)

  1. Lowest Path Cost to Root Bridge
  2. Lowest Sender Bridge ID
  3. Lowest Port Priority (Default = 128)
  4. 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 StateFunctionDefault Timer
DisabledAdmin downN/A
BlockingReceives BPDUs onlyN/A
ListeningSends/receives BPDUs, no MAC learning15s
LearningLearns MACs, no frame forwarding15s
ForwardingFull data forwardingN/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

  1. Set Manual Priority
1
spanning-tree vlan <vlan-id> priority <value>
  1. Root Primary/Secondary Shortcuts
1
2
spanning-tree vlan <vlan-id> root primary
spanning-tree vlan <vlan-id> root secondary
  • root primary sets priority to 24576 (if all others are default)

B. Influencing Port Selection

  1. Change STP Cost (local influence)
1
spanning-tree cost <value>
  1. 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

TopicKey Focus
Root Bridge ElectionPriority (lowest wins) + MAC tie-breaker
STP CostsLower = preferred path
Port RolesRoot, Designated, Alternate, Backup
STP TimersHello (2s), Forward Delay (15s), Max Age (20s)
Rapid PVST Advantage<6s convergence
MST BenefitVLAN grouping = CPU optimization
PortFast Use CaseHost connections only
Load BalancingDifferent 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

GitHub LinkedIn YouTube Gmail

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