▸Protocol notes for this page (click to expand)

STP (Spanning Tree Protocol)

Why STP is needed

An Ethernet header has no TTL.

An IP packet's TTL drops by 1 at each hop and the packet is dropped at zero. An Ethernet frame has no such field, so a broadcast frame that enters a loop keeps circulating, and every switch that floods it makes more copies; within seconds link bandwidth and switch CPUs are saturated. This is a broadcast storm.

So when layer 2 has redundant links, a protocol must block one of them. STP (802.1D) is that protocol.

Converging in three steps

(1) Elect the root bridge: all switches compare Root ID (priority + MAC); the lowest becomes root;
(2) Compute cost: each switch computes its path cost to the root and picks one root port facing it;
(3) Block: the surplus port on the loop goes to blocking; it forwards no data frames but still receives BPDUs.

After these three steps the looped topology becomes a spanning tree, which has no loops.

Common misconceptions

A blocked port is a standby link. When the active path fails it moves to forwarding. In normal operation it carries no traffic, so in a dual-uplink access design half the uplink bandwidth sits idle; MLAG and routed designs were later introduced to fix this.

Classic STP takes 30-50 seconds to converge (15 seconds each for listening and learning). RSTP was introduced to shorten this.

Ports facing endpoints need not wait for convergence. They should be configured as portfast/edge and forward as soon as they come up.