Basic Concepts of STP
Root Bridge
A tree topology must have a root. 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. Although the root bridge is not necessarily at the physical center of the network, it functions as its logical center. The root bridge changes dynamically with the network topology.
After network convergence, the root bridge generates configuration BPDUs and sends them to other devices at specific intervals. Other devices process and forward the configuration BPDUs to communicate the topology changes to downstream devices.
Metrics for Spanning Tree Calculation
A spanning tree is calculated based on the following metrics: ID and path cost.
ID
Bridge ID (BID)
According to IEEE 802.1D, 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 is elected as the root bridge.
Port ID (PID)
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 specified 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 robust links, blocks redundant links, and finally trims 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 the root path cost.
Root Bridge, Root Port, and Designated Port
Three elements are involved in pruning a ring network into a tree network: root bridge, root port, and designated port. Figure 9-2 shows the three elements in the STP network architecture.
Root bridge
The root bridge is the bridge with the smallest BID, which is discovered 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 9-2 explains the designated bridge and designated port.
Table 9-2 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 9-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 four fields, which form a BPDU priority vector {root bridge ID, root path cost, sender BID, PID}.
Table 9-3 describes the four fields carried in a configuration BPDU.
Field |
Description |
---|---|
Root bridge ID |
ID of the root bridge. Each STP network has only one 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 9-3 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 to become the root bridge. This BID is then used as the root bridge ID field in Table 9-3.
- Smallest root path cost: used to select the root port on a non-root bridge. The port with the smallest root path cost is selected as the root port. On the root bridge, the path cost of each port is 0 and there is no root port.
- Smallest sender BID: used to select the root port among ports with the same root path cost. The port with the smallest sender BID is selected as the root port in STP calculation. For example, S2 has a smaller BID than S3 in Figure 9-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 smallest PID is not blocked. The PIDs are compared in the scenario shown in Figure 9-4. The BPDUs received on port A and port B of S1 contain the same root path cost and sender BID. Port A has a smaller PID than port B. Therefore, port B is blocked to prevent loops.
Port States
Table 9-4 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 9-5 shows the state transitions of a port.
Table 9-5 describes the MSTP 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, 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. |
After a Huawei device transitions from the Multiple Spanning Tree Protocol (MSTP) mode (default mode) to the STP mode, its STP ports support only those states defined in MSTP, which are Forwarding, Learning, and Discarding. The Forwarding and Learning states are the same as the corresponding STP states. A port in Discarding state can only receive BPDUs.
The following parameters affect the STP port states and convergence speed.
Hello Time
The Hello Time specifies the interval at which an STP device sends configuration BPDUs 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 adds the new Hello Time value in BPDUs it sends to non-root bridges. When the network topology changes, Topology Change Notification (TCN) BPDUs are transmitted immediately, irrespective 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, because new configuration BPDUs cannot be immediately spread over the entire network, convergence takes some time. If the new root port and designated port forward data before convergence, 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 time, the new configuration BPDUs can be transmitted over the network, preventing transient loops during convergence.
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 does not forward user traffic when it is in Listening or Learning state, which is key to 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 either forwards or discards the configuration BPDU by comparing the Message Age value with the Max Age value. The details are as follows:- If the Message Age value is less than or equal to the Max Age value, the non-root bridge forwards the configuration BPDU.
- If the Message Age value is larger 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 value of Message Age is 0. Otherwise, the value of Message Age is the total time spent to transmit the BPDU from the root bridge to the local bridge, including the transmission delay. In real-world situations, the Message Age value of a configuration BPDU increases by 1 each time the configuration BPDU passes through a bridge.
Table 9-6 provides the timer values defined in IEEE 802.1D.