This post has been originally published on LinkedIn.
Spanning Tree Protocol (STP) is one of those protocols that I have to revisit and study over and over again. I have read the same technical details multiple times, but somehow they don't stick. Once more, I have spent an afternoon with STP, after stumbling upon a related question and realizing I couldn't answer it off the top of my head. In this post, I will teach you about STP, as I relearn it myself.
The whole operation of STP is based on the exchange of protocol messages called BPDUs and the ability to compare them. The logical, loop-free STP tree is calculated by finding the superior BPDUs.
NOTE: Only Configuration BPDUs, also referred to as Hello BPDUs, are compared.
To determine which BPDU out of a pair of BPDUs is superior, they are compared in the following sequence of values, looking for the first occurrence of a lower value:
- root bridge ID
- root path cost
- sender bridge ID
- sender port ID
- receiver port ID (not included in the BPDU, evaluated locally)
(The very last step is very uncommon and would only be seen in a specific case, such as a hub transmitting a single BPDU to multiple ports on the same switch.)
Selecting a single superior BPDU out of a set of BPDUs is at the core of STP’s capability to choose exactly one root bridge, exactly one Root Port on a non-root bridge, and exactly one Designated Port for each connected network segment.
Each port in STP stores, or remembers, the superior BPDU it has either sent or received. In other words, each port stores the Designated Port’s BPDU — whether it is the port itself acting as the Desginated Port or it is a neighbor’s port.
To determine which ports are forwarding and blocking, STP follows a three-step process.
1. Elect the root switch.
The root switch is the switch with the lowest bridge ID.
2. Find the Root Port on each non-root switch.
The Root Port is the one port on each non-root switch that receives the superior resulting BPDU among all received BPDUs on all its ports.
3. Determine the Designated Port for each segment.
The Designated Port is the port on the switch that forwards the superior BPDU from among all forwarded BPDUs on that segment.
Let's explore the details of each step in future posts!