After STP is enabled on all devices on a network, the devices initially all consider themselves as the root bridge. They only transmit and receive BPDUs and do not forward user traffic. In addition, all ports on the devices are in Listening state. The devices select the root bridge, root port, and designated ports based on configuration BPDUs.
Initialization
The root ID is the BID of the local bridge, the root path cost is the accumulative path cost from the port to the local bridge, the sender BID is the BID of the local bridge, and the PID is the ID of the port that sends the BPDU.
Root bridge election
During network initialization, every device considers itself the root bridge and sets the root ID to its own BID. The devices then exchange configuration BPDUs and compare their root IDs to find the device with the smallest BID. The device with the smallest BID becomes the root bridge.
Root port and designated port selection
Table 1 describes the process of selecting the root port and designated port.
Step |
Process |
---|---|
1 |
A non-bridge device selects the port that receives the optimal configuration BPDU as the root port. Table 2 describes the process of selecting the optimal configuration BPDU. |
2 |
The device generates a configuration BPDU for each port and modifies the following fields according to the configuration BPDU on the root port and the path cost of the root port:
|
3 |
The device compares the calculated configuration BPDU with the configuration BPDU received on the port:
|
Step |
Process |
---|---|
1 |
Each port compares the received configuration BPDU with its own configuration BPDU:
|
2 |
The device compares configuration BPDUs on all the ports and selects the optimal one. |
After the root bridge, root port, and designated ports are selected successfully, a tree topology is set up on the entire network. The following example illustrates how STP calculation is implemented.
In Figure 1, DeviceA, DeviceB, and DeviceC are deployed on the network, with priorities 0, 1, and 2, respectively. The path costs between DeviceA and DeviceB, DeviceA and DeviceC, and DeviceB and DeviceC are 5, 10, and 4, respectively.
Table 3 lists the initial state of each device.
Table 4 describes configuration BPDU comparison process and result.
Device |
Comparison |
Configuration BPDU After Comparison |
---|---|---|
DeviceA |
|
|
DeviceB |
|
|
|
|
|
DeviceC |
|
|
|
|
|
|
|
|
|
|
After the topology becomes stable, the root bridge continues to send configuration BPDUs at a specific interval. If the received configuration BPDU is superior, a non-root bridge replaces the configuration BPDU on the corresponding port with the received configuration BPDU. If the received configuration BPDU is inferior or the same, a non-root bridge discards the received configuration BPDU.