
Spanning Tree Protocol explained
Spanning Tree Protocol stops a switched network from bringing itself down. Connect two switches with two cables, or plug both ends of a patch lead into the same switch, and without it traffic circles endlessly until the network grinds to a halt. STP finds the loops and switches the redundant links off until they are needed.
Why loops are a problem
A switch forwards a broadcast out of every port except the one it came in on. With a loop in the network, that broadcast comes back, is sent out again, and multiplies with every round. Ethernet frames have no hop limit, unlike IP packets, so nothing ever stops them. Within seconds the links are full, the switches’ address tables keep changing their minds about where each device is, and the network stops working. That is a broadcast storm.
Redundant links are still useful: a second cable between two switches keeps the network up if the first one fails. Spanning Tree Protocol, first standardised as IEEE 802.1D, makes that possible by keeping exactly one active path between any two points and holding the others in reserve.
- Root bridge The switches elect one root, the switch with the lowest bridge ID: a priority value followed by its hardware address.
- Root port Every other switch picks the port with the lowest path cost to the root. Cost depends on link speed, so faster links win.
- Designated port On every link, the port with the lowest cost to the root is chosen to forward traffic onto that link.
- Blocked port Every remaining port stops forwarding, which breaks the loop. If an active link fails, a blocked port takes over.
STP, RSTP and MSTP
| Version | Standard | Recovery after a change | What it adds |
|---|---|---|---|
| STP | IEEE 802.1D | Typically 30 to 50 seconds | The original: one tree for the whole network |
| RSTP | IEEE 802.1w, now part of 802.1D | Usually within a few seconds | Faster convergence, with alternate and backup ports ready to take over |
| MSTP | IEEE 802.1s, now part of 802.1Q | As fast as RSTP | Several trees, each carrying a group of VLANs, so redundant links can carry traffic |
| Rapid PVST+ | Cisco’s own | As fast as RSTP | A separate rapid tree for every VLAN |
Classic STP moves a port through blocking, listening, learning and forwarding, which is why a port could take half a minute or more to come up. RSTP reduces that to discarding, learning and forwarding, and uses a handshake between switches instead of timers. How VLANs divide a network in the first place is explained in What is a VLAN?.
Setting up spanning tree well
Left on its defaults, spanning tree works, but not always the way you would choose.
Choose the root yourself
Give the core switch the lowest priority, and a second switch the next one. Otherwise the oldest switch with the lowest hardware address may become root, wherever it sits.
Edge ports with BPDU guard
Ports for desks, printers and access points are set as edge ports, so they start forwarding at once. BPDU guard shuts such a port if a switch is plugged into it.
Aggregation where you want both links
Spanning tree blocks a second cable. Link aggregation with LACP bundles both into one logical link, so both carry traffic and spanning tree sees a single path.
Where our work stops
This is an explanation, not a training course; for network certification you need a training provider. We design, configure and manage switched networks, spanning tree included: see Managed network and Networking equipment. Many unmanaged switches do not take part in spanning tree at all, which is one of the differences explained in Managed vs unmanaged switch, and what a switch does compared with a router is in Router vs switch. New cable routes through walls are building work, done by a contractor.
What it connects to
These pages cover the neighbouring part of the same environment.
Questions we get about this
The ones that come up most, answered briefly.
What does Spanning Tree Protocol do?
It prevents loops in a switched network. Switches elect a root bridge, work out the best path to it, and block any port that would create a loop. If an active link fails, a blocked port takes over.
What is the difference between STP and RSTP?
RSTP is the rapid version. Classic STP relies on timers and can take 30 to 50 seconds to recover after a change; RSTP uses a handshake between switches and usually recovers within a few seconds.
What is a root bridge?
The switch at the centre of the spanning tree. It is the switch with the lowest bridge ID, a priority value plus its hardware address. It is best to set that priority deliberately on the core switch.
Do you run network training or do building work for new cable routes?
No. We are not a training provider, and new routes through walls are building work for a contractor. We design, configure and manage switched networks and lay the data cabling.
Curious what we would take over?
In a thirty-minute conversation we go through your current IT landscape and tell you honestly whether managed IT suits your situation.
Practical IT knowledge in your inbox
New guides on management, security and the workplace, written by the people doing the work. No sales talk, and you can unsubscribe in one click.