STP & RSTP

What

Builds a loop free topological network of switches, a spanning tree
Disables links that are not part of this tree
Leaving a single active link between any two nodes

Why

When switches do no yet know where to send a packet, they will broadcast it
If there exist loops in the network, these broadcasts will keep circling
Broadcast storms like that can take down a network

Concepts

Election

Root bridge

To elect the root bridge, the following values are used in order:

  1. Bridge priority, lower is better, multiples of 4096
  2. MAC Address, lower is better
    Priority and MAC concatenated make the bridge ID

Path to root bridge

To determine the best path to the root bridge (used for both root port and designated port), the following values are used

  1. Lowest cost to the root bridge
  2. Neighbour with the lowest bridge ID
  3. Lowest port ID

How

The root bridge of the tree is the bridge with the lowest bridge ID, in the below example, this is bridge 3
Pasted image 20250909113358.png|400
Every switch will choose it's root port: which port to send upstream traffic out of
If every LAN segment has a cost of 1, bridge 4 -> bridge 3 goes through c
Therefore, the root port for bridge 4 is the one on LAN segment c
Pasted image 20250909113559.png|400
Each network segment (cloud with letter) will choose a designated port: which port to send traffic to
The least cost path to the root from a LAN segment
The least cost from e goes through bridge 92
Pasted image 20250909113737.png|400
Remaining ports (not root nor designated) are blocked
Pasted image 20250909113842.png|400

If a link were to fail, the algorithm will recompute
Pasted image 20250909114005.png|400