Calculation process of the STP algorithm
In STP calculation, a device compares the priorities of the received configuration BPDUs from different ports, and elects the root bridge, root ports and designated ports. When the spanning tree calculation is completed, a tree-shape topology forms.
The spanning tree calculation process described in the following sections is an example of a simplified process.
Network initialization
Upon initialization of a device, each port generates a BPDU with the following contents:
The port as the designated port.
The device as the root bridge.
0 as the root path cost.
The device ID as the designated bridge ID.
Root bridge selection
The root bridge can be selected in the following methods:
Automatic election—Initially, each STP-enabled device on the network assumes itself to be the root bridge, with its own device ID as the root bridge ID. By exchanging configuration BPDUs, the devices compare their root bridge IDs to elect the device with the smallest root bridge ID as the root bridge.
Manual assignment—You can configure a device as the root bridge or a secondary root bridge of a spanning tree.
A spanning tree can have only one root bridge. If you configure multiple devices as the root bridge for a spanning tree, the device with the lowest MAC address is selected.
You can configure one or multiple secondary root bridges for a spanning tree. When the root bridge fails or is shut down, a secondary root bridge can take over. If multiple secondary root bridges are configured, the one with the lowest MAC address is selected. However, if a new root bridge is configured, the secondary root bridge is not selected.
Root port and designated ports selection on the non-root bridges
Step | Description |
---|---|
1 | A non-root-bridge device regards the port on which it received the optimum configuration BPDU as the root port. Table 8 describes how the optimum configuration BPDU is selected. |
2 | Based on the configuration BPDU and the path cost of the root port, the device calculates a designated port configuration BPDU for each of the other ports.
|
3 | The device compares the calculated configuration BPDU with the configuration BPDU on the port whose port role will be determined. Then, the device acts depending on the result of the comparison:
|
When the network topology is stable, only the root port and designated ports forward user traffic. Other ports are all in the blocking state to receive BPDUs but not to forward BPDUs or user traffic.
Table 8: Selecting the optimum configuration BPDU
Step | Actions |
---|---|
1 | Upon receiving a configuration BPDU on a port, the device compares the priority of the received configuration BPDU with that of the configuration BPDU generated by the port.
|
2 | The device compares the configuration BPDUs of all the ports and chooses the optimum configuration BPDU. |
The following are the principles of configuration BPDU comparison:
The configuration BPDU with the lowest root bridge ID has the highest priority.
If configuration BPDUs have the same root bridge ID, their root path costs are compared. For example, the root path cost in a configuration BPDU plus the path cost of a receiving port is S. The configuration BPDU with the smallest S value has the highest priority.
If all configuration BPDUs have the same root bridge ID and S value, the following attributes are compared in sequence:
Designated bridge IDs.
Designated port IDs.
IDs of the receiving ports.
The configuration BPDU that contains a smaller designated bridge ID, designated port ID, or receiving port ID is selected.
A tree-shape topology forms when the root bridge, root ports, and designated ports are selected.