STP Topology Calculation
After STP is enabled on all devices on a network, all devices consider themselves the root bridge. All ports on the devices are in Listening state (they only transmit and receive configuration BPDUs and do not forward user traffic). Then the devices select the root bridge, root ports, and designated ports based on configuration BPDUs.
BPDU Exchange
Figure 9-8 shows the initial information exchange process. The four parameters in a pair of brackets represent the root bridge ID (S1_MAC and S2_MAC are BIDs of the two devices), root path cost, sender BID, and PID carried in configuration BPDUs. Configuration BPDUs are sent at Hello intervals.
STP Algorithm Implementation
Initialization
Because each bridge considers itself the root bridge, the BPDU sent from a port is set as follows:
The root bridge 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 bridge ID to its own BID. Then devices exchange configuration BPDUs and compare their root bridge IDs to find the device with the smallest BID, which finally becomes the root bridge.
Root port and designated port selection
Table 9-8 describes the process of selecting the root port and designated port.
Table 9-8 Selecting the root port and designated portStep Process 1 A non-bridge device selects the port that receives the configuration BPDU with the highest priority as the root port. Table 9-9 describes the process of selecting the configuration BPDU with the highest priority. 2 The device generates a configuration BPDU for each port and calculates the fields in the configuration BPDU based on the configuration BPDU on the root port and path cost of the root port. The details are as follows: - Replaces the root bridge ID with the root bridge ID in the configuration BPDU on the root port.
- Replaces the root path cost with the accumulated root path cost in the configuration BPDU on the root port and the path cost of the root port.
- Replaces the sender BID with the local BID.
- Replaces the PID with the local port ID.
3 The device selects the port state by comparing the calculated configuration BPDU with the configuration BPDU received on the port. The details are as follows: - If the calculated configuration BPDU is superior, the port is selected as the designated port and periodically sends the calculated configuration BPDU.
- If the port's own configuration BPDU is superior, the configuration BPDU on the port is not updated and the port is blocked. Then the port only receives BPDUs, and does not forward data or send BPDUs.
Table 9-9 Selecting the configuration BPDU with the highest priorityStep Process 1 Each port decides how to process the received configuration BPDU by comparing it with its own configuration BPDU. The details are as follows: - If the received configuration BPDU is inferior, the port discards the received configuration BPDU and retains its own configuration BPDU.
- If the received configuration BPDU is superior, the port replaces its own configuration BPDU with the received one.
2 The device compares configuration BPDUs on all the ports and selects the one with the highest priority.
Example of STP Topology Calculation
After the root bridge, root ports, 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.
As shown in Figure 9-9, 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.
Device | Port | Configuration BPDU |
---|---|---|
DeviceA | Port A1 | {0, 0, 0, Port A1} |
Port A2 | {0, 0, 0, Port A2} | |
DeviceB | Port B1 | {1, 0, 1, Port B1} |
Port B2 | {1, 0, 1, Port B2} | |
DeviceC | Port C1 | {2, 0, 2, Port C1} |
Port C2 | {2, 0, 2, Port C2} |
Device | Process | Resulting Configuration BPDU |
---|---|---|
DeviceA |
|
|
DeviceB |
|
|
|
|
|
DeviceC |
|
|
|
|
|
|
|
|
|
|
After the topology becomes stable, the root bridge still sends configuration BPDUs at intervals specified by the Hello timer. Each non-root bridge forwards the received configuration BPDUs through its designated port. When a non-root bridge receives a superior configuration BPDU on a port, the non-root bridge replaces the configuration BPDU on the port with the received configuration BPDU.
STP Topology Changes
Figure 9-10 shows the packet transmission process after an STP topology change.
The following is the process that takes place after a topology change occurs:
- When the status of the interface at point T changes, a downstream device continuously sends TCN BPDUs to the upstream device to inform the upstream device and root bridge of topology changes.
- The upstream device processes only the TCN BPDUs received on the designated port and drops TCN BPDUs on other ports.
- The upstream device sets the TCA bit of the Flags field in the configuration BPDUs to 1 and returns the configuration BPDUs to instruct the downstream device to stop sending TCN BPDUs.
- The upstream device sends a copy of the TCN BPDUs toward the root bridge.
- Steps 1, 2, 3 and 4 are repeated until the root bridge receives the TCN BPDUs.
- The root bridge sets the TC and TCA bits of the Flags field in the configuration BPDUs to 1. The TC bit of 1 informs the downstream device of topology changes and instructs the downstream device to delete MAC address entries. In this manner, fast network convergence is achieved. The TCA bit of 1 informs the downstream device that the topology changes are known and instructs the downstream device to stop sending TCN BPDUs.