Spanning Tree

A bridge that receives a frame addressed to somewhere it has not yet learned sends it out of every other port, and it does the same with a broadcast. That is the whole of what a learning bridge does, it is why Ethernet needed no configuration, and it is fatal the moment there is a loop: the copies go round, get flooded again, and multiply. There is no hop count in an Ethernet frame to stop them. Radia Perlman's answer was to have the bridges agree, among themselves and with nobody's help, on which links to switch off, so that what is left has no loop in it and still reaches everywhere. This page runs the agreement and then floods one frame into the network both ways, counting.

One spare cable, and the network drowns

1 A bridged network with more links than it needs, which is what a spare cable is

Pick a network. The blocked links are the ones the bridges themselves decided to stop using.

linkjoinscoststate
0bridge 1 to bridge 210forwarding
1bridge 2 to bridge 310forwarding
2bridge 3 to bridge 410blocked
3bridge 4 to bridge 510forwarding
4bridge 5 to bridge 110forwarding

2 The root elected and every port given a cost, so some links stop forwarding

DerivedElecting a root, by telling the neighbours

Every bridge starts believing it is the root and says so. A bridge that hears of a better root, or a cheaper way to the one it knows, believes it and passes it on. Nothing here is central and nothing is configured.

bridgecost to rootreaches it byDijkstra says
bridge 10it is the root0
bridge 210link 0, towards bridge 110
bridge 320link 1, towards bridge 220
bridge 420link 3, towards bridge 520
bridge 510link 4, towards bridge 110

Bridge 1 is the root, and the exchange settled after 3 rounds. The last column is Dijkstra's shortest distance to that root, worked out separately: if it ever differed from the third column, the election would be wrong.

3 One frame flooded into both versions, and the copies counted until a step limit

MeasuredOne frame, flooded both ways

One frame is flooded from the first bridge and its copies are counted, first with every link forwarding and then with the links the election switched off.

16 every link on

4 on the tree

stepevery link onthe tree
122
222
320
420
520
620
720
820
in all164

With every link forwarding, one frame has cost 16 transmissions after 8 steps and has not finished. With the tree, it cost 4 and was over in 3 steps.

4 What the safety cost: the links left idle, and how changing the root changes which

What the safety cost

linkjoinscost
2bridge 3 to bridge 410

1 of 5 links carry nothing. The algorithm is a shortest-path tree to whichever bridge is root, so moving the root moves which cable is the wasted one, and there is no setting where none of it is wasted.

Union-find, which never saw the election, agrees: 4 links, no cycle, nothing cut off.

Redundant cable that is not allowed to carry ordinary traffic is the bargain, and it was the right one in 1985: a network that stays up beats a network that uses all its links and melts. It is also why the successors exist. Rapid spanning tree made the recovery faster without changing the bargain. TRILL, which is Perlman's own answer twenty years later, changed it by putting a hop count in the frame so a loop stops being fatal and every link can carry traffic; shortest path bridging, standardised separately as 802.1aq, reaches a similar place by a different route.

These ran in this browser when the page loaded. Each claim, whether it held, and the number behind it.

Each claim, whether it held, and the values behind it
claimheldmeasured
what is left forwarding is a spanning tree, checked by union-findyesall 4 networks: no cycle, nothing cut off, and one link fewer than there are bridges
and the costs the exchange settled on are Dijkstra's, computed separatelyyesevery bridge of every network, message passing against shortest paths
one frame into the meshed network becomes hundreds, and is still growingyes242 copies transmitted in 8 steps, per step: 2, 4, 8, 12, 20, 36, 60, 100
and into the pruned one it stops, having crossed each link onceyes5 transmissions, one per link of the tree, then nothing: 1, 2, 1, 1, 0
a ring does not multiply the frame, it just never lets go of ityes2 copies in flight at every one of 8 steps, going round in both directions and never reaching zero. Growing without bound and never stopping are different failures and only one of them is exponential.
every network here with a spare link storms, and none of the pruned ones doyes4 networks, flooded both ways
the safety is paid for in cable nobody is allowed to useyes3 of 8 links sit blocked, which is exactly the number more than a tree needs
make any bridge the root and it is still a shortest-path treeyesall 6 bridges in turn, each elected by priority and each producing a tree whose costs match Dijkstra's
with no priorities set, the lowest-numbered bridge is the rootyesall 4 networks elect bridge 1

What is real here, and what is not

The election is a message exchange, the check is not

Bridges are modelled the way they behave: each one starts believing it is the root, tells its neighbours, and the belief spreads until a round changes nothing. That is deliberately not a shortest-path algorithm, because a shortest-path algorithm is what checks it. Dijkstra runs separately from the elected root and its distances must equal the ones the exchange settled on, and a union-find that has never seen either must agree that what forwards is a tree.

The storm runs for eight steps and then the page stops counting

A flood in a looped network does not finish, so the simulation has a stated limit rather than a claim of infinity. Eight steps is enough to show a mesh multiplying and a ring circulating; it is not a measurement of how long a real network survives, which depends on frame size, link speed and how quickly somebody pulls the cable.

A ring and a mesh fail differently, and the page says which

In a mesh the copies multiply, roughly doubling per step here. In a ring they do not multiply at all: two copies go round in opposite directions forever. Both are fatal and only one is exponential, and calling them both a storm that grows would be wrong about the ring.

Point-to-point links only, so a segment has no designated bridge

802.1D is written for shared segments, where several bridges hang off one wire and one of them is elected the designated bridge for it. Every link here joins exactly two bridges, which is what modern switched Ethernet actually looks like, and for that case the tree is simply the union of the root ports. The designated-port election is real and is not modelled. Blocking is also a PORT state in the standard rather than a property of a link, and a blocked port is not dead: it goes on receiving the protocol's own messages, which is how it learns that the topology changed and it should start forwarding. This page blocks whole links and counts no protocol traffic at all, so what it calls a link carrying nothing is a link carrying no data.

No timers, no topology changes, no learning table

There is no hello time, no max age, no listening or learning state and no thirty-second delay before a port starts forwarding, which is the part that made the original protocol painful and is what rapid spanning tree fixed. There is also no MAC address table: every frame here is flooded, which is the worst case and the case the loop makes fatal.

The costs are made up, and their ordering is the point

Link costs of 10, 20, 30 and 40 stand in for the real table, which is derived from link speed and has changed twice as Ethernet got faster. Nothing on the page depends on the actual numbers; what it depends on is that the cheap path is sometimes the long one, which is why one network here has a direct link between two bridges costing 40 while the two-hop path between the same pair costs 20, so the cheap way round is the long way round. The first draft of this sentence said four times, comparing the direct link with a single hop rather than with the path it competes against; the gate that demands every number on a page be pinned by a test is what caught it.

Sound: no

The measurement is a count of frames per step. A tone per frame would be a mood rather than the quantity, and the quantity is already a column of integers.

Sources