All variants of STP operate in a similar fashion: STP frames (known as bridge protocol data units (BPDUs)) are exchanged at
regular intervals over Layer 2 LAN segments, between network devices participating in STP. Such network devices do not forward
these frames, but use the information to construct a loop free spanning tree.
The spanning tree is constructed by first selecting a device which is the root of the spanning tree (known as the root bridge), and then by determining a loop free path from the root bridge to every other device in the network. Redundant paths are disabled by setting the appropriate ports into a blocked state,
where STP frames can still be exchanged but data traffic is never forwarded. If a network segment fails and a redundant path
exists, the STP protocol recalculates the spanning tree topology and activates the redundant path, by unblocking the appropriate
ports.
The selection of the root bridge within a STP network is determined by the lowest Bridge ID which is a combination of configured
bridge priority and embedded mac address of each device. The device with the lowest priority, or with equal lowest priority
but the lowest MAC address is selected as the root bridge.
Root port: is selected based on lowest root path cost to root bridge. If there is a tie with respect to the root path cost,
port on local switch which receives BPDU with lowest sender bridge ID is selected as root port.
Designated port: Least cost port on local switch towards root bridge is selected as designated port. If there is a tie, lowest
number port on local switch is selected as designated port.
The selection of the active path among a set of redundant paths is determined primarily by the port path cost. The port path
cost represents the cost of transiting between that port and the root bridge - the further the port is from the root bridge,
the higher the cost. The cost is incremented for each link in the path, by an amount that is (by default) dependent on the
media speed. Where two paths from a given LAN segment have an equal cost, the selection is further determined by the lowest
bridge ID of the attached devices, and in the case of two attachments to the same device, by the configured port priority
and port ID of the neighboring attached ports.
Once the active paths have been selected, any ports that do not form part of the active topology are moved to the blocking
state.