← Module 02 · Layer 2: Data Link

Spanning Tree Protocol (802.1D)

Redundant links are good for resilience and terrible for Ethernet, which has no TTL (Time To Live). STP is what keeps the second one from destroying the network.

Why a backup cable can take down a whole network

Wiring two switches together twice sounds like sensible redundancy. On an IP (Internet Protocol) network it would be, because IP packets carry a TTL that gets decremented and eventually killed off. An Ethernet frame carries no such thing. If three switches are cabled in a triangle with no loop prevention, a single broadcast frame gets flooded out every other port, arrives at the next switch, gets flooded again, and keeps circulating forever, doubling in volume every trip around the loop. This is a broadcast storm, and it can saturate a network in seconds.

Picture three neighborhoods connected by three roads forming a loop, with no traffic authority. One piece of junk mail addressed to "everyone" gets photocopied and forwarded at every intersection, forever, in both directions. The fix isn't removing a road, it's temporarily closing exactly one of them until it's needed.

  1. Elect a root bridge. Every switch advertises a Bridge ID (priority + MAC, or Media Access Control, address) in a BPDU (Bridge Protocol Data Unit). The switch with the lowest Bridge ID becomes the root of the tree everyone else measures distance from.
  2. Every other switch picks a root port. The port with the lowest-cost path back to the root bridge stays forwarding.
  3. Every segment picks a designated port. The switch with the lowest-cost path to the root, for that specific segment, forwards on it.
  4. Everything else blocks. Any port that isn't a root port or a designated port goes into blocking: physically still connected, but not forwarding data, so the loop never closes.
ROOT SW1 SW2 SW3 root port (forwarding) designated (forwarding) blocked: would complete the loop
SW2 and SW3 both have a path to the root already. The direct link between them stays physically connected but blocked, ready to take over if either forwarding link fails.

Port states and why convergence is slow

A port doesn't jump straight to forwarding. It steps through Blocking → Listening → Learning → Forwarding, spending time in each state so the switch can rebuild its view of the topology safely before trusting it with real traffic. Combined with the standard timers, a topology change under classic 802.1D can take 30–50 seconds to fully converge, an outage that's very noticeable to anyone using the network at the time.

TimerDefaultWhat it's waiting for
Hello2 secondsHow often BPDUs are sent to confirm the topology hasn't changed
Forward delay15 secondsTime spent in Listening, then again in Learning
Max age20 secondsHow long a switch waits without hearing from the root before assuming it's gone
THE OBVIOUS NEXT QUESTION

30–50 seconds of downtime every time a link changes is a real problem on a busy network. The next topic, RSTP, is the fix: same core idea (root bridge, one active path per segment), a much faster handshake to get there.