Introduction
To prevent loops from causing broadcast storms and making the MAC address table unstable, the Spanning Tree Protocol (STP) runs switches when redundant links are used on the network.
STP is a basic feature of datacom products including switches, routers, and WLAN products. This chapter describes STP configurations on Huawei CloudEngine series switches.
Understanding STP
STP, defined by IEEE 802.1D, prevents loops on a local area network (LAN). Switching devices running STP exchange information with one another to discover loops on the network, and then block certain redundant links to eliminate loops. If an active link fails, STP activates a running standby link with the highest priority to ensure network connectivity.
As the scale of LANs continues to grow, STP has become an increasingly important LAN protocol.
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.
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. Typically, the root bridge should have high performance and be located at a higher layer of the network. When the network topology changes, the root bridge will be re-elected accordingly. It is recommended that you manually configure the root bridge and secondary root bridge. Configure an optimal core switch as the root bridge to ensure stability of the STP Layer 2 network. Otherwise, new access devices may trigger STP root bridge switching, causing short service interruptions.
Root port: The root port on an STP device has the smallest path cost to the root bridge and is responsible for forwarding data to the root bridge. Among all STP-capable ports on a device, the port with the smallest root path cost is a root port. An STP device has only one root port, and there is no root port on the root bridge.
Designated port: The designated port is located on a designated bridge and forwards configuration BPDUs to the device or LAN, as illustrated in Figure 1.
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.Figure 1-1 Designated bridge and designated port
In addition, a switching device has a bridge ID (BID) and a port on the switching device has a port ID (PID). A PID is composed of a port priority and a port number. A BID is composed of a bridge priority and a bridge MAC address. On an STP network, the device with the smallest BID acts as the root bridge.
After the root bridge, root port, 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.
BPDU Format
A BPDU carries the BID, root path cost, and PID. A BPDU is encapsulated in an Ethernet frame. Its destination MAC address is a multicast MAC address, 01-80-C2-00-00-00. The Length or Type field specifies the MAC data length, and is followed by the LLC header and BPDU header. Figure 2 shows the format of an Ethernet frame.
Figure 1-2 Format of an Ethernet frame
Each bridge actively sends configuration BPDUs during initialization. After the network topology becomes stable, only the root bridge proactively sends configuration BPDUs. Other bridges send configuration BPDUs only after receiving configuration BPDUs from upstream devices. A configuration BPDU is at least 35 bytes long and includes the parameters such as the BID, root path cost, and PID. A bridge processes a received configuration BPDU only if either the sender BID or PID is different from that on the local bridge receive port. If both fields are the same as those on the receive port, the bridge discards the configuration BPDU. Therefore, the bridge does not need to process BPDUs with the same information as the local port.