20 00020 00020 0003276800:00:5e:00:53:01SW1SW1 MAC tableA …:53:0aport 1DRD3276800:00:5e:00:53:02SW2RDR3276800:00:5e:00:53:03SW3AB
Blue-sealed envelope: A's broadcast · yellow envelopes: BPDUsCrown: the root bridgePort pucks: R root port · D designated · coral bar: blockedCoral cross: a cut cable, or a frame dropped at a blocked portThree switches in a triangle have two paths between every pair, so frames can loop. Ethernet frames carry no TTL, so without spanning tree a broadcast circles forever and MAC tables flap. Spanning tree elects the switch with the lowest bridge ID (priority 32768 by default, then MAC) as root, gives every other switch one root port and every link one designated port, and blocks the rest; if a link fails, a blocked port takes over. Switch and host MAC addresses (00:00:5e:00:53:xx) are RFC 7042 documentation values; ff:ff:ff:ff:ff:ff is the real broadcast address and 01:80:c2:00:00:00 the real address BPDUs are sent to. Host IPs are from 192.168.1.0/24 (RFC 1918). Real frames circle a loop millions of times a second; the figure slows everything down so you can watch.

The loop problem

  1. Three switches are cabled in a triangle. That gives a spare path: if one cable breaks, traffic can go round the other way. But the links also form a loop, a circle that frames can travel round and round.

Electing a tree

One path

Failure and recovery

Inside the switches

;; step 1/12 · loop
;; about: links, s1, s2, s3
SW1 port 1 ── SW2 port 1
SW1 port 2 ── SW3 port 1
SW2 port 2 ── SW3 port 2
Host A on SW2 port 3 · Host B on SW3 port 3
every link 1 Gb/s · one VLAN · no spanning tree yet

Many switches set the priority in steps of 4096 and add the VLAN number to it (IEEE 802.1t), so the default shows as 32769 on VLAN 1. The comparison works the same way. Path costs are the IEEE 802.1D-2004 recommended values (1 Gb/s = 20 000, 100 Mb/s = 200 000). The older 802.1D-1998 table used 4 and 19.