Basic Concepts
Root Bridge
As defined in STP, the device that functions as the root of a tree network is called the root bridge.
There is only one root bridge on the entire STP network. The root bridge is the logical center, but not necessarily the physical center, of the network. The root bridge changes dynamically with the network topology.
After network convergence, the root bridge generates and sends configuration BPDUs at a specific interval. Upon receipt of the configuration BPDUs, non-root bridges compare whether the priority of the received BPDUs is higher than that of their local configuration BPDUs. If the priority is higher, the non-root bridges update their configuration BPDU information stored on their STP interfaces based on the information in the received BPDUs. If the priority is lower, the non-root bridges discard the received configuration BPDUs.
Metrics for Spanning Tree Calculation
A spanning tree is calculated based on the following metrics: bridge ID (BID), port ID (PID), and path cost.
BID and PID
IDs are classified into bridge ID (BID) and port ID (PID).
According to the IEEE 802.1D standard, a BID is composed of a bridge priority (leftmost 16 bits) and a bridge MAC address (rightmost 48 bits). On an STP network, the device with the smallest BID acts as the root bridge.
A PID is composed of a port priority (leftmost 4 bits) and a port number (rightmost 12 bits). The PID is used to select the designated port.
The port priority affects the role of a port in a spanning tree instance. For details, see STP Topology Calculation.
Path cost
The path cost is a port variable used for link selection. STP calculates path costs to select effective links, block redundant links, and trim the network into a loop-free tree topology.
On an STP network, a port's path cost to the root bridge is the sum of the path costs of all ports between the port and the root bridge. This path cost is called the root path cost.
Root Bridge, Root Port, and Designated Port
Three elements are involved in trimming a ring network into a tree network: root bridge, root port, and designated port. Figure 14-2 shows the three elements in the STP network architecture.
Root bridge
The root bridge is the bridge with the smallest BID as determined by exchanging configuration BPDUs.
Root port
The root port on an STP device is the port with the smallest path cost to the root bridge and is responsible for forwarding data to the root bridge. An STP device has only one root port, and there is no root port on the root bridge.
Designated port
Table 14-1 explains the designated bridge and designated port.
Table 14-1 Designated bridge and designated portReference Object
Designated Bridge
Designated Port
Device
A directly connected device that forwards configuration BPDUs to the device
The designated bridge's port that forwards configuration BPDUs to the device
LAN
A device that forwards configuration BPDUs to the LAN
The designated bridge's port that forwards configuration BPDUs to the LAN
In Figure 14-3, AP1 and AP2 are ports of S1; BP1 and BP2 are ports of S2; CP1 and CP2 are ports of S3.
S1 sends configuration BPDUs to S2 through AP1, so S1 is the designated bridge for S2, and AP1 is the designated port on S1.
S2 and S3 are connected to the LAN. If S2 forwards configuration BPDUs to the LAN, S2 is the designated bridge for the LAN, and BP2 is the designated port on S2.
After the root bridge, root ports, and designated ports are selected successfully, a tree topology is set up on the entire network. When the topology is stable, only the root port and designated ports forward traffic. The other ports are in Blocking state; they only receive STP BPDUs and do not forward user traffic.
Comparison Principles
During role election, STP devices compare the four fields of a BPDU priority vector {root ID, root path cost, sender BID, PID}.
Table 14-2 describes the four fields carried in a configuration BPDU.
Field |
Description |
---|---|
Root ID |
ID of the root bridge. |
Root path cost |
Path cost to the root bridge. It is determined by the distance between the port sending the configuration BPDU and the root bridge. |
Sender BID |
BID of the device that sends the configuration BPDU. |
PID |
PID of the port that sends the configuration BPDU. |
After a device on the STP network receives a configuration BPDU, it compares the fields listed in Table 14-2 with its own values. The four comparison principles are as follows:
- Smallest BID: used to select the root bridge. Devices on an STP network select the device with the smallest BID based on the root ID field in Table 14-2.
- Smallest root path cost: used to select the root port on a non-root bridge. On the root bridge, the path cost of each port is 0.
- Smallest sender BID: used to select the root port from ports with the same root path cost. The port with the smallest BID is selected as the root port in STP calculation. For example, S2 has a smaller BID than S3 in Figure 14-2. If the BPDUs received on port A and port B of S4 contain the same root path cost, port B becomes the root port on S4 because the BPDU received on port B has a smaller sender BID.
- Smallest PID: used to determine which port should be blocked when multiple ports have the same root path cost. The port with the greatest PID is blocked. A scenario where PIDs are compared is shown in Figure 14-4. The BPDUs received on ports A and B of S1 both contain the same root path cost and sender BID, but Port A has a smaller PID than port B. Therefore, port B is blocked to prevent loops.
Port States
Table 14-3 describes the possible states of ports on an STP device.
Port State |
Purpose |
Description |
---|---|---|
Forwarding |
A port in Forwarding state can forward user traffic and process BPDUs. |
Only the root port and designated port can enter the Forwarding state. |
Learning |
When a port is in Learning state, the device creates MAC address entries based on user traffic received on the port but does not forward user traffic through the port. |
This is a transitional state, which is designed to prevent temporary loops. |
Listening |
All ports are in Listening state before the root bridge, root port, and designated port are selected. |
This is a transitional state. |
Blocking |
A port in Blocking state receives and processes only BPDUs, and does not forward user traffic. |
This is the final state of a blocked port. |
Disabled |
A port in Disabled state does not process BPDUs or forward user traffic. |
The port is Down. |
Figure 14-5 shows the state transitions of a port.
By default, a Huawei network device uses MSTP mode. After a device transitions from MSTP mode to STP mode, its STP ports support only those states defined in MSTP, which are Forwarding, Learning, and Discarding. Table 14-4 describes the three port states.
Port State |
Description |
---|---|
Forwarding |
A port in Forwarding state can forward user traffic and process BPDUs. |
Learning |
This is a transitional state. When a port is in Learning state, it can send and receive BPDUs, but does not forward user traffic. The device creates MAC address entries based on user traffic received on the port but does not forward user traffic through the port. |
Discarding |
A port in Discarding state can only receive BPDUs. |
The following parameters affect the STP port states and convergence.
Hello Time
The Hello Time specifies the interval at which an STP device sends configuration BPDU packets to detect link failures.
When the Hello Time is changed, the new value takes effect only after a new root bridge is elected. The new root bridge includes the new Hello Time value in BPDUs it sends to non-root bridges. If the network topology changes, TCN BPDUs are immediately transmitted regardless of the Hello Time.
Forward Delay
The Forward Delay timer specifies the length of delay before a port state transition.
When a link fails, STP calculation is triggered and the spanning tree structure changes. However, new configuration BPDUs cannot be immediately spread over the entire network. If the new root port and designated port forward data immediately, transient loops may occur. Therefore, STP defines a port state transition delay mechanism. The newly selected root port and designated port must wait for two Forward Delay intervals before transitioning to the Forwarding state. During this period, the new configuration BPDUs can be transmitted over the network, preventing transient loops.
The default Forward Delay timer value is 15 seconds. This means that the port stays in Listening state for 15 seconds and then stays in Learning state for another 15 seconds before transitioning to the Forwarding state. The port is blocked when it is in Listening or Learning state, effectively preventing transient loops.
Max Age
The Max Age specifies the aging time of BPDUs. This parameter is configurable on the root bridge.
The Max Age is spread to the entire network with configuration BPDUs. After a non-root bridge receives a configuration BPDU, it compares the Message Age value with the Max Age value in the received configuration BPDU.- If the Message Age value is smaller than or equal to the Max Age value, the non-root bridge forwards the configuration BPDU.
- If the Message Age value is greater than the Max Age value, the non-root bridge discards the configuration BPDU. When this happens, the network size is considered too large and the non-root bridge disconnects from the root bridge.
If the configuration BPDU is sent from the root bridge, the Message Age value is 0. Otherwise, the Message Age value is the total time spent to transmit the BPDU from the root bridge to the local bridge, including the transmission delay. The Message Age value of a configuration BPDU increases by 1 each time the configuration BPDU passes through a bridge.
Table 14-5 provides the timer values defined in IEEE 802.1D.