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
- Root bridge
- Root port (RP)
- The port a switch will send traffic out of
- Designated port (DP)
- The port a network segment will send traffic towards
- Bridge Protocol Data Unit (BPDU)
- The packet format used to configure (R)STP
- Blocked Port (BP)
- Any port that is not an RP or DP after the algorithm has ran
Election
Root bridge
To elect the root bridge, the following values are used in order:
- Bridge priority, lower is better, multiples of 4096
- 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
- Lowest cost to the root bridge
- Neighbour with the lowest bridge ID
- 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
%20Inter-Networking%20and%20Routing/Attachments/Pasted%20image%2020250909113358.png)
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
%20Inter-Networking%20and%20Routing/Attachments/Pasted%20image%2020250909113559.png)
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
%20Inter-Networking%20and%20Routing/Attachments/Pasted%20image%2020250909113737.png)
Remaining ports (not root nor designated) are blocked
%20Inter-Networking%20and%20Routing/Attachments/Pasted%20image%2020250909113842.png)
If a link were to fail, the algorithm will recompute
%20Inter-Networking%20and%20Routing/Attachments/Pasted%20image%2020250909114005.png)