0% found this document useful (0 votes)
97 views

01-14 STP RSTP Configuration

Uploaded by

KiKi Ma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
97 views

01-14 STP RSTP Configuration

Uploaded by

KiKi Ma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 67

S12700 Series Agile Switches

Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

14 STP/RSTP Configuration

About This Chapter

This chapter describes how to configure the Spanning Tree Protocol (STP) and
Rapid Spanning Tree Protocol (RSTP).

14.1 Introduction to STP/RSTP


14.2 Principles
14.3 Applications
14.4 Configuration Task Summary
14.5 Licensing Requirements and Limitations for STP/RSTP
14.6 Default Configuration
14.7 Configuring Basic STP/RSTP Functions
You can configure STP/RSTP on an Ethernet network to ensure that the network
has a loop-free tree topology.
14.8 Setting STP Parameters that Affect STP Convergence
STP cannot implement rapid convergence. However, STP parameters including the
network diameter, timeout interval, Hello timer interval, Max Age timer value, and
Forward Delay timer value can affect the STP convergence speed.
14.9 Setting RSTP Parameters that Affect RSTP Convergence
RSTP supports link type and fast transition configuration on ports to implement
rapid convergence.
14.10 Configuring RSTP Protection Functions
Huawei network devices provide the following RSTP protection functions.
14.11 Setting Parameters for Interoperation Between Huawei and Non-Huawei
Devices
To implement interoperation between a Huawei device and a non-Huawei device,
select a fast transition mode according to the Proposal/Agreement mechanism of
the non-Huawei device.
14.12 Maintaining STP/RSTP

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 674


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

14.13 Configuration Examples


14.14 FAQ

14.1 Introduction to STP/RSTP

Definition
Redundant links are used on an Ethernet switching network to implement link
backup and enhance network reliability. The use of redundant links, however, may
produce loops, causing broadcast storms and making the MAC address table
unstable. As a result, network communication may encounter quality deterioration
or even be interrupted. STP solves this problem.
Devices running STP exchange STP bridge protocol data units (BPDUs) to discover
loops on the network and block some ports. This ensures a loop-free tree network
and that the packet processing capabilities of switches is not impacted.
The STP network convergence speed is slow, so IEEE introduced RSTP (802.1w) in
2001 to improve the network convergence speed of STP.

Purpose
After a spanning tree protocol is configured on an Ethernet switching network, the
protocol calculates the network topology to implement the following functions:
● Loop prevention: The spanning tree protocol blocks redundant links to prevent
potential loops on the network.
● Link redundancy: If an active link fails and a redundant link exists, the
spanning tree protocol activates the redundant link to ensure network
connectivity.

14.2 Principles

14.2.1 Background
STP 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 ports to eliminate loops. As the scale of LANs continues to
grow, STP has become an increasingly important protocol.

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 675


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

Figure 14-1 Typical LAN networking


Host A

port1 port1
S1 S2
port2 port2

Host B
Data flow

On the network shown in Figure 14-1, the following situations may occur:
● Broadcast storms cause a breakdown of the network.
If a loop exists on the network, broadcast storms may occur. In Figure 14-1,
STP is not enabled on the switching devices. If Host A sends a broadcast
request, both S1 and S2 receive the request on port 1 and forward the request
through their port 2. Then, S1 and S2 receive the request forwarded by each
other on port 2 and forward the request through port 1. As this process
repeats, resources on the entire network are eventually exhausted, and the
network breaks down.
● MAC address flapping causes unstable MAC address entries.
Even unicast packets can cause MAC address flapping on switching devices.
HostA sends a unicast packet to HostB. If HostB is temporarily removed from
the network at this time, the MAC address entry for HostB will be deleted on
S1 and S2. When the unicast packet sent by HostA to HostB is received by
port 1 on S1, no matching MAC address entry is found, so the unicast packet
is forwarded to port 2.
Port 2 on S2 receives the unicast packet from port 2 on S1 and sends it out
through port 1. Port 1 on S2 also receives the unicast packet sent by HostA to
HostB, and sends it out through port 2. These transmissions repeat and port 1
and port 2 on S1 and S2 continuously receive unicast packets from HostA. S1
and S2 modify their MAC address entries each time, causing the MAC address
table to flap. As a result, MAC address entries are unstable.

14.2.2 Basic Concepts


Root Bridge
As defined in STP, the device that functions as the root of a tree network is called
the root bridge.

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 676


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

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.
NOTE

The port priority affects the role of a port in a spanning tree instance. For details, see
14.2.4 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.

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 677


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

Figure 14-2 STP network architecture

root bridge
A B S2
PC=100;RPC=0 PC=100;RPC=100
S1

B A
PC=100;RPC=0 PC=99;RPC=100

A B
PC=100;RPC=100 PC=99;RPC=199

B A
S3 PC=200;RPC=100 PC=200;RPC=300 S4

PC: path cost


RPC: root path cost
root port
designated port
blocked port

● 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 port

Reference Designated Bridge Designated Port


Object

Device A directly connected The designated bridge's port


device that forwards that forwards configuration
configuration BPDUs to BPDUs to the device
the device

LAN A device that forwards The designated bridge's port


configuration BPDUs to that forwards configuration
the LAN BPDUs to the LAN

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 678


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

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.

Figure 14-3 Designated bridge and designated port


S1

AP1 AP2

BP1 CP1
S2 S3

BP2 CP2

LAN

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.

Table 14-2 Four fields

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.

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 679


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

Field Description

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.

Figure 14-4 Scenario where PIDs need to be compared

S1 S2

A B

designated port
blocked port

Port States
Table 14-3 describes the possible states of ports on an STP device.

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 680


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

Table 14-3 STP port states


Port Purpose Description
State

Forwardi A port in Forwarding state can Only the root port and
ng forward user traffic and process designated port can enter the
BPDUs. Forwarding state.

Learning When a port is in Learning state, This is a transitional state, which


the device creates MAC address is designed to prevent temporary
entries based on user traffic loops.
received on the port but does not
forward user traffic through the
port.

Listenin All ports are in Listening state This is a transitional state.


g before the root bridge, root port,
and designated port are selected.

Blocking A port in Blocking state receives This is the final state of a


and processes only BPDUs, and blocked port.
does not forward user traffic.

Disabled A port in Disabled state does not The port is Down.


process BPDUs or forward user
traffic.

Figure 14-5 shows the state transitions of a port.

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 681


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

Figure 14-5 STP state transitions of a port


Disabled or
Down



Blocking


④ ⑤
Listening


④ ⑤
Learning


④ ⑤
Forwarding

1 The port is initialized or enabled, and enters the Blocking state.

2 The port is selected as the root or designated port, and enters


the Listening state.

3 When the time limit for keeping the port in a temporary state
expires, the port enters the next state (either Learning or
Forwarding). Then the port is selected as the root or designated port.
4 The port is not the root or designated port, and enters the
blocking state.
5 The port is disabled or the link fails.

NOTE

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.

Table 14-4 MSTP port states


Port Description
State

Forwardi A port in Forwarding state can forward user traffic and process
ng BPDUs.

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 682


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

Port Description
State

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.

Discardi A port in Discarding state can only receive BPDUs.


ng

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.

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 683


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

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.

Table 14-5 Values of STP timer parameters

Parameter Default Value Value Range

Hello Time 200 centiseconds (2 100-1000


seconds)

Max Age 2000 centiseconds (20 600-4000


seconds)

Forward Delay 1500 centiseconds (15 400-3000


seconds)

14.2.3 BPDU Format


A BPDU carries the BID, root path cost, and PID. There are two types of STP
BPDUs:

● Configuration BPDUs are heartbeat packets. STP-enabled designated ports


send configuration BPDUs at Hello timer intervals.
● Topology Change Notification (TCN) BPDUs are sent only after a device
detects a network topology change.

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 field specifies the number
of bytes of the Data field (excluding the CRC field). The LLC header and BPDU
packet header are appended to the Length field in sequence. Figure 14-6 shows
the Ethernet frame format.

Figure 14-6 Format of an Ethernet frame


6 bytes 6 bytes 2 bytes 3 bytes 43-1497 bytes 4 bytes

DMAC SMAC Length LLC Data CRC

Configuration BPDU
Configuration BPDUs are the most common type of BPDU and are sent to
exchange topology information among STP devices.

Each bridge actively sends configuration BPDUs during initialization. After the
network topology becomes stable, the designated port of each device periodically
sends configuration BPDUs.

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 684


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

A configuration BPDU is at least 35 bytes long and includes 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.

A configuration BPDU is sent in one of the following scenarios:


● After STP is enabled on ports of a device, the designated port on the device
sends configuration BPDUs at Hello timer intervals.
● When a root port receives a configuration BPDU with a priority higher than
that of its own configuration BPDU, the device where the root port resides
updates the configuration BPDU information stored on its STP ports based on
the information in the received configuration BPDU and sends the
information to a downstream device through a designated port. In contrast, if
the root port receives a configuration BPDU with a priority lower than that of
its own configuration BPDU, the root port discards the received configuration
BPDU.
● When a designated port receives an inferior configuration BPDU, the
designated port immediately sends its own configuration BPDU to the
downstream device.

Table 14-6 describes fields in a BPDU.

Table 14-6 Fields in a BPDU

Field Byte Description


s

Protocol Identifier 2 The value is fixed at 0, representing a spanning tree


protocol.

Protocol Version 1 The value is fixed at 0, representing a spanning tree


Identifier protocol.

BPDU Type 1 Indicates the type of a BPDU. The value is one of the
following:
● 0x00: configuration BPDU
● 0x80: TCN BPDU

Flags 1 Indicates whether the network topology has


changed.
● The rightmost bit is the Topology Change (TC)
flag.
● The leftmost bit is the Topology Change
Acknowledgment (TCA) flag.

Root Identifier 8 Indicates the BID of the current root bridge.

Root Path Cost 4 Indicates the accumulated path cost from a port to
the root bridge.

Bridge Identifier 8 Indicates the BID of the bridge that sends the BPDU.

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 685


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

Field Byte Description


s

Port Identifier 2 Indicates the ID of the port that sends the BPDU.

Message Age 2 Records the time that has elapsed since the original
BPDU was generated on 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.

Max Age 2 Indicates the aging time of a BPDU.

Hello Time 2 Indicates the interval at which BPDUs are sent.

Forward Delay 2 Indicates the period during which a port stays in


Listening and Learning states.

Figure 14-7 shows the Flags field. Only the leftmost and rightmost bits are used
in STP.

Figure 14-7 Format of the Flags field


Reserved

Bit7 Bit0

TCA (Topology Change TC (Topology


Acknowledgment flag) Change flag)

TCN BPDU
A TCN BPDU contains only three fields: Protocol Identifier, Version, and Type, as
shown in Table 14-6. The Type field is four bytes long and is fixed at 0x80.
When the network topology changes, TCN BPDUs are transmitted upstream until
they reach the root bridge. A TCN BPDU is sent in either of the following
scenarios:
● A port transitions to the Forwarding state.
● A designated port receives a TCN BPDU and sends a copy to the root bridge.

14.2.4 STP Topology Calculation


After STP is enabled on all devices on a network, all devices initially consider
themselves as the root bridge. They only transmit and receive BPDUs and do not

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 686


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

forward user traffic, and all ports on the devices are in Listening state. The devices
select the root bridge, root ports, and designated ports based on configuration
BPDUs.

BPDU Exchange
Figure 14-8 shows the initial information exchange process. The four parameters
in a pair of brackets represent the root ID (S1_MAC and S2_MAC are the BIDs of
the two devices), root path cost, sender BID, and PID carried in configuration
BPDUs. Configuration BPDUs are sent at Hello timer intervals.

Figure 14-8 Initial BPDU exchange


{S1_MAC,0,S1_MAC,A_PID}

A B
S1 {S2_MAC,0,S2_MAC,B_PID} S2

STP Algorithm Implementation


1. Initialization
Because each bridge considers itself the root bridge, the BPDU sent from a
port is set as follows:
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.
2. Root bridge election
During network initialization, every device considers itself the root bridge and
sets the root ID to its own BID. Then devices exchange configuration BPDUs
and compare their root IDs to find the device with the smallest BID, which
becomes the root bridge.
3. Root port and designated port selection
Table 14-7 describes the process of selecting the root port and designated
port.

Table 14-7 Selecting the root port and designated port


St Process
ep

1 A non-bridge device selects the port that receives the optimal


configuration BPDU as the root port. Table 14-8 describes the process
of selecting the optimal configuration BPDU.

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 687


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

St Process
ep

2 The device generates a configuration BPDU for each port and modifies
the following fields based on the configuration BPDU on the root port
and path cost of the root port:
● Replaces the root ID with the root ID in the configuration BPDU on
the root port.
● Replaces the root path cost with the sum of the 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 compares the calculated configuration BPDU with the


configuration BPDU received on the port:
● 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. After
that, the port only receives BPDUs, and does not forward data or
send BPDUs.

Table 14-8 Selecting the optimal configuration BPDU

St Process
ep

1 Each port compares the received configuration BPDU with its own
configuration BPDU:
● 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.
● If the received configuration BPDU is the same, the port discards
the received configuration BPDU.

2 The device compares configuration BPDUs on all the ports and selects
the optimal one.

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.

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 688


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

Figure 14-9 STP networking and calculated topology


DeviceA
Priority=0 DeviceA

Port A1 Port A2 Root Bridge


STP Topology
Calculation

Pa
=5

th
st

co
co

st
th

=1
Pa

0
Port B1 Port C1
Path cost=4
Port B2 Port C2
DeviceB DeviceC DeviceC
DeviceB
Priority=1 Priority=2
root port
designated port
blocked port

In Figure 14-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.
1. Initial state of each device
Table 14-9 lists the initial state of each device.
NOTE
The fields in a configuration BPDU are {root ID, root path cost, sender BID, PID}.

Table 14-9 Initial state of each device


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}

2. Configuration BPDU comparison and result


Table 14-10 describes configuration BPDU comparison process and result.

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 689


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

Table 14-10 Topology calculation process and result


Dev Comparison Configuration BPDU
ice After Comparison

Dev ● Port A1 receives the configuration BPDU ● Port A1: {0, 0, 0,


iceA {1, 0, 1, Port B1} from Port B1 and finds Port A1}
it inferior to its own configuration BPDU ● Port A2: {0, 0, 0,
{0, 0, 0, Port A1}, so Port A1 discards Port A2}
the received configuration BPDU.
● Port A2 receives the configuration BPDU
{2, 0, 2, Port C1} from Port C1 and finds
it inferior to its own configuration BPDU
{0, 0, 0, Port A2} superior, so Port A2
discards the received configuration
BPDU.
● DeviceA finds that the root bridge and
designated bridge specified in the
configuration BPDUs on its ports are on
itself. Therefore, DeviceA considers itself
as the root bridge and periodically
sends configuration BPDUs from each
port without modifying the BPDUs.

Dev ● Port B1 receives the configuration BPDU ● Port B1: {0, 0, 0, Port
iceB {0, 0, 0, Port A1} from Port A1 and finds A1}
it superior to its own configuration ● Port B2: {1, 0, 1, Port
BPDU {1, 0, 1, Port B1}, so Port B1 B2}
updates its configuration BPDU.
● Port B2 receives the configuration BPDU
{2, 0, 2, Port C2} from Port C2 and finds
it inferior to its own configuration BPDU
{1, 0, 1, Port B2}, so Port B2 discards the
received configuration BPDU.

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 690


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

Dev Comparison Configuration BPDU


ice After Comparison

● DeviceB compares the configuration ● Root port (Port B1):


BPDU on each port and finds that Port {0, 0, 0, Port A1}
B1 has an optimal configuration BPDU. ● Designated port
DeviceB selects Port B1 as the root port (Port B2): {0, 5, 1,
and retains the configuration BPDU on Port B2}
Port B1.
● DeviceB calculates the configuration
BPDU {0, 5, 1, Port B2} for Port B2
based on the configuration BPDU and
path cost of the root port, and
compares the calculated configuration
BPDU with the original configuration
BPDU {1, 0, 1, Port B2} on Port B2. The
calculated configuration BPDU is
superior to the original one, so DeviceB
selects Port B2 as the designated port,
replaces Port B2's configuration BPDU
with the calculated one, and periodically
sends configuration BPDUs from Port
B2.

Dev ● Port C1 receives the configuration BPDU ● Port C1: {0, 0, 0, Port
iceC {0, 0, 0, Port A2} from Port A2 and finds A2}
it superior to its own configuration ● Port C2: {1, 0, 1, Port
BPDU {0, 0, 0, Port C1}, so Port C1 B2}
updates its configuration BPDU.
● Port C2 receives the configuration BPDU
{1, 0, 1, Port B2} from Port B2 and finds
it superior to its own configuration
BPDU {1, 0, 1, Port C2}, so Port C2
updates its configuration BPDU.

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 691


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

Dev Comparison Configuration BPDU


ice After Comparison

● DeviceC compares the configuration ● Root port (Port C1):


BPDU on each port and finds that the {0, 0, 0, Port A2}
configuration BPDU on Port C1 is ● Designated port
optimal. DeviceC selects Port C1 as the (Port C2): {0, 10, 2,
root port and retains the configuration Port C2}
BPDU on Port C1.
● DeviceC calculates the configuration
BPDU {0, 10, 2, Port C2} for Port C2
based on the configuration BPDU and
path cost of the root port, and
compares the calculated configuration
BPDU with the original configuration
BPDU {1, 0, 1, Port B2} on Port C2. The
calculated configuration BPDU is
superior to the original one, so DeviceC
selects Port C2 as the designated port
and replaces its configuration BPDU
with the calculated one.

● Port C2 receives the configuration BPDU ● Port C1: {0, 0, 0, Port


{0, 5, 1, Port B2} from Port B2 and finds A2}
it superior to its own configuration ● Port C2: {0, 5, 1, Port
BPDU {0, 10, 2, Port C2}, so Port C2 B2}
updates its configuration BPDU.
● Port C1 receives the configuration BPDU
{0, 0, 0, Port A2} from Port A2 and finds
it the same as its own configuration
BPDU, so Port C1 discards the received
configuration BPDU.

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 692


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

Dev Comparison Configuration BPDU


ice After Comparison

● The root path cost of Port C1 is 10 (root ● Blocked port (Port


path cost 0 in the received configuration C1): {0, 0, 0, Port
BPDU plus the link patch cost 10), and A2}
the root path cost of Port C2 is 9 (root ● Root port (Port C2):
path cost 5 in the received configuration {0, 5, 1, Port B2}
BPDU plus the link patch cost 4).
DeviceC finds that Port C2 has a smaller
root path cost and therefore considers
the configuration BPDU of Port C2
superior to that of Port C1. DeviceC
then selects Port C2 as the root port
and retains its configuration BPDU.
● DeviceC calculates the configuration
BPDU {0, 9, 2, Port C1} for Port C1
based on the configuration BPDU and
path cost of the root port, and finds the
calculated configuration BPDU inferior
to the original configuration BPDU {0, 0,
0, Port A2} on Port C1. DeviceC blocks
Port C1 and does not update its
configuration BPDU. Port C1 no longer
forwards data until STP recalculation is
triggered, for example, when the link
between DeviceB and DeviceC is down.

After the topology becomes stable, the root bridge still sends 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.

STP Topology Changes


Figure 14-10 shows the packet transmission process after an STP topology
change.

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 693


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

Figure 14-10 Packet transmission after a topology change


Root Bridge Root Bridge

1. When the status of the interface at point T changes, a downstream device


continuously sends TCN BPDUs to the upstream device.
2. The upstream device processes only the TCN BPDUs received on the
designated port and discards TCN BPDUs received on other ports.
3. 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.
4. The upstream device sends a copy of the TCN BPDUs toward the root bridge.
5. Steps 1, 2, 3 and 4 are repeated until the root bridge receives the TCN BPDUs.
6. The root bridge sets the TC and TCA bits of the Flags field in the configuration
BPDUs to 1. The TC bit of 1 indicates that the root bridge notifies the
downstream device of deleting MAC address entries, and the TCA bit of 1
indicates that the root bridge notifies the downstream device of stopping
sending TCN BPDUs.

NOTE

● TCN BPDUs are used to inform the upstream device and root bridge of topology
changes.
● Configuration BPDUs with the TCA bit set to 1 are used by the upstream device to
inform the downstream device that the topology changes are known and instruct the
downstream device to stop sending TCN BPDUs.
● Configuration BPDUs with the TC bit set to 1 are used by the upstream device to inform
the downstream device of topology changes and instruct the downstream device to
delete MAC address entries. This increases network convergence speed.

14.2.5 Improvements in RSTP


In 2001, IEEE 802.1w was published to introduce the Rapid Spanning Tree Protocol
(RSTP), an extension of the Spanning Tree Protocol (STP). RSTP was developed
based on STP and makes additions and modifications to STP.

Disadvantages of STP
STP ensures a loop-free network but has a slow network topology convergence
speed, leading to service quality deterioration. If the network topology changes

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 694


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

frequently, the STP network will frequently lose connection and suffer service
interruptions, significantly impacting user experience.
STP has the following disadvantages:
● STP does not distinguish port states and port roles clearly.
– Ports in Listening, Learning, and Blocking states are the same to users
because they are all prevented from forwarding service traffic.
– From the perspective of port use and configuration, the essential
differences between ports lie in the port roles rather than port states.
Both root and designated ports can be in Listening or Forwarding state,
so the ports cannot be distinguished solely by their states.
● STP determines topology changes after the timer expires, which slows down
network convergence.
● STP requires that the root bridge send configuration BPDUs after the network
topology becomes stable and other devices process and spread the
configuration BPDUs to the entire network. This also slows down topology
convergence.

Improvements Made in RSTP


RSTP removes three port states, defines two new port roles, and distinguishes port
attributes based on port states and roles. In addition, RSTP provides enhanced
features and protection measures to ensure network stability and fast
convergence.

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 695


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

Figure 14-11 Diagram of port roles


S1
root bridge

B A

S2 S3
A A a

S1
root bridge

B A

S2 S3
A a
B A
b

root port
designated port

Alternate port
Backup port

● RSTP defines additional port roles to simplify the learning and deployment of
the protocol.
Figure 14-11 shows the four port roles defined in RSTP: root port, designated
port, alternate port, and backup port.
The functions of the root port and designated port are the same as those
defined in STP. The alternate port and backup port are defined as follows:
– From the perspective of configuration BPDU transmission:

▪ An alternate port is blocked after learning a configuration BPDU sent


from another bridge.

▪ A backup port is blocked after learning a configuration BPDU sent


from itself.
– From the perspective of user traffic:

▪ An alternate port acts as a backup of the root port and provides an


alternate path from the designated bridge to the root bridge.

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 696


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

▪ A backup port acts as a backup of the designated port and provides


a backup path from the root bridge to the related network segment.
After roles of all RSTP ports are determined, the topology convergence is
completed.
● RSTP redefines port states.
RSTP reduces the number of port states to 3. Depending on whether a port
can forward user traffic and learn MAC addresses, the port will be in one of
the following states:
– If the port does not forward user traffic or learn MAC addresses, it is in
the Discarding state.
– If the port does not forward user traffic but learns MAC addresses, it is in
the Learning state.
– If the port forwards user traffic and learns MAC addresses, it is in the
Forwarding state.
Table 14-11 compares the port states defined in STP and RSTP. Port states are
not necessarily related to port roles. Table 14-11 lists possible states for
different port roles.

Table 14-11 Comparison between port states defined in STP and RSTP
STP Port State RSTP Port State Port Role

Forwarding Forwarding Root port or designated port

Learning Learning Root port or designated port

Listening Discarding Root port or designated port

Blocking Discarding Alternate port or backup port

Disabled Discarding -

● RSTP changes the configuration BPDU format and uses the Flags field to
describe port roles.
RSTP retains the basic configuration BPDU format defined in STP with minor
changes:
– The value of the Type field is changed from 0 to 2. Devices running STP
will discard configuration BPDUs sent from devices running RSTP.
– The Flags field uses the six bits reserved in STP. This configuration BPDU
is called an RST BPDU. Figure 14-12 shows the Flags field in an RST
BPDU.

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 697


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

Figure 14-12 Format of the Flags field in an RST BPDU


Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
TCA Agreement Forwarding Learning Port role Proposal TC

Topology Change Topology


Acknowledgment flag Change flag
Port role = 00 Unknown
01 Alternate/Backup port
10 Root port
11 Designated port

● RSTP processes configuration BPDUs differently from STP.


– Configuration BPDU transmission
In STP, the root bridge sends configuration BPDUs at Hello timer intervals
after the topology becomes stable. Non-root bridges send configuration
BPDUs only after they receive configuration BPDUs from upstream
devices. This complicates the STP calculation and slows down network
convergence.
RSTP allows non-root bridges to send configuration BPDUs at Hello timer
intervals after the topology becomes stable, regardless of whether they
have received configuration BPDUs from the root bridge.
– BPDU timeout period
In STP, a device has to wait for a Max Age period before determining a
negotiation failure.
In RSTP, a device determines that the negotiation between its port and
the upstream device has failed if the port does not receive any
configuration BPDUs sent from the upstream device within the timeout
interval (Hello Time x 3 x Timer Factor).
– Processing of inferior BPDUs
When an RSTP port receives an RST BPDU from the upstream designated
bridge, the port compares the received RST BPDU with its own RST BPDU.
If its RST BPDU is superior to the received one, the port discards the
received RST BPDU and immediately responds to the upstream device
with its own RST BPDU. After receiving the RST BPDU, the upstream
device replaces its RST BPDU with the received RST BPDU. This allows
RSTP to rapidly process inferior BPDUs without relying on timers.
In this manner, RSTP processes inferior BPDUs more rapidly, independent
of any timer.
● Rapid convergence
– Proposal/Agreement mechanism
In STP, a port that is selected as a designated port needs to wait at least
one Forward Delay interval in the Learning state before it enters the
Forwarding state.
In RSTP, a port that is selected as a designated port enters the Discarding
state, and then the proposal/agreement mechanism allows the port to

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 698


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

immediately enter the Forwarding state. The proposal/agreement


mechanism must be applied on P2P links in full-duplex mode.
For details, see 14.2.6 RSTP Technology Details.
– Fast switchover of the root port
If a root port fails, the best alternate port becomes the root port and
enters the Forwarding state. This is because the network segment
connected to this alternate port has a designated port connected to the
root bridge.
When the port role changes, the network topology changes accordingly.
For details, see 14.2.6 RSTP Technology Details.
– Edge ports
In RSTP, a designated port on the network edge is called an edge port. An
edge port directly connects to a terminal and does not connect to any
other switching devices.
An edge port does not participate in RSTP calculation. This port can
transition from Disabled state to Forwarding state immediately. An edge
port becomes a common STP port once it is connected to a switching
device and receives a configuration BPDU. The spanning tree needs to be
recalculated, which leads to network flapping.
● Protection functions
RSTP provides the following functions:
– BPDU protection
On a switching device, ports directly connected to a user terminal such as
a PC or file server are edge ports. Usually, no RST BPDUs are sent to edge
ports. If a switching device receives malicious RST BPDUs on an edge
port, the switching device automatically sets the edge port to a non-edge
port and performs STP calculation. This causes network flapping.
BPDU protection enables a switching device to set the state of an edge
port to error-down if the edge port receives an RST BPDU. In this case,
the port remains the edge port, and the switching device sends a
notification to the NMS.
– Root protection
The root bridge on a network may receive superior RST BPDUs due to
incorrect configurations or malicious attacks. When this occurs, the root
bridge can no longer serve as the root bridge and the network topology
will incorrectly change. As a result, traffic may be switched from high-
speed links to low-speed links, leading to network congestion.
If root protection is enabled on a designated port, the port role cannot be
changed. When the designated port receives a superior RST BPDU, the
port enters the Discarding state and does not forward packets. If the port
does not receive any superior RST BPDUs within a specified period (two
Forward Delay periods by default), the port automatically enters the
Forwarding state.
NOTE

Root protection takes effect only on designated ports.


– Loop protection

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 699


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

On an RSTP network, a switching device maintains the states of the root


port and blocked ports based on RST BPDUs received from the upstream
switching device. If the ports cannot receive RST BPDUs from the
upstream switching device because of link congestion or unidirectional
link failures, the switching device re-selects a root port. Then, the
previous root port becomes a designated port and the blocked ports
change to the Forwarding state, which can lead to loops on the network.
In Figure 14-13, when the link between BP2 and CP1 is congested, the
root port CP1 on DeviceC cannot receive BPDUs from the upstream
device. After a specified period, the alternate port CP2 becomes the root
port and CP1 becomes the designated port. As a result, a loop occurs.

Figure 14-13 Topology change upon link congestion


DeviceA DeviceA

Root Bridge Root Bridge


AP1 AP2 AP1 AP2

BP1 CP2 BP1 CP2

BP2 CP1 BP2 CP1


DeviceB DeviceC DeviceB DeviceC
a. The link is normal. b. Congestion occurs in the link.

root port
designated port
Alternate port

If the root port or alternate port does not receive BPDUs from the
upstream device for a specified period, a switch enabled with loop
protection sends a notification to the NMS. The root port enters the
Discarding state and becomes the designated port, whereas the alternate
port remains blocked and becomes the designated port. In this case,
loops will not occur. After the link is no longer congested or
unidirectional link failures are rectified, the port receives BPDUs for
negotiation and restores its original role and status.
NOTE

Loop protection takes effect only on the root port and alternate ports.
– TC BPDU attack defense
A switching device deletes its MAC address entries and ARP entries after
receiving TC BPDUs. If an attacker sends a large number of malicious TC
BPDUs to the switching device within a short period, the device will
constantly delete MAC address entries and ARP entries. This increases the
load on the switching device and threatens network stability.

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 700


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

After enabling TC BPDU attack defense on a switching device, you can set
the number of TC BPDUs that the device can process within a specified
period. If the number of TC BPDUs that the switching device receives
within a given time period exceeds the specified threshold, the switching
device processes only the specified number of TC BPDUs. After the time
period expires, the switching devices process all the excess TC BPDUs
together. This function prevents the switching device from frequently
deleting MAC entries and ARP entries.

14.2.6 RSTP Technology Details


The Proposal/Agreement mechanism enables a designated port to enter the
Forwarding state quickly. In Figure 14-14, root bridge S1 establishes a link with
S2. On S2, p2 is an alternate port, p3 is a designated port in Forwarding state, and
p4 is an edge port.

Figure 14-14 Proposal/Agreement negotiation process


S1

p0 1 Proposal
3 Agreement

p1

S2
p2 E p4
p3

2 sync 2 sync 2 sync


(Leaves the port (Leaves the port
(Blocks the port)
state unchanged) state unchanged)

Designated port
Alternate port
E Edge port

The Proposal/Agreement mechanism works as follows:


1. p0 and p1 become designated ports and send RST BPDUs to each other.
2. The RST BPDU sent from p0 is superior to that of p1, so p1 becomes a root
port and stops sending RST BPDUs.
3. p0 enters the Discarding state and sets the Proposal and Agreement fields in
its RST BPDU to 1.
4. After S2 receives an RST BPDU with the Proposal field set to 1, it sets the sync
variable to 1 for all its ports.

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 701


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

5. As p2 has been blocked, its state remains unchanged. p4 is an edge port and
does not participate in calculation, so only the non-edge designated port p3
needs to be blocked.
6. After the synced variable of each port is set to 1, p2 and p3 enter the
Discarding state, and p1 enters the Forwarding state and returns an RST
BPDU with the Agreement field being set to 1 to S1.
7. After S1 receives this RST BPDU, it identifies that the RST BPDU is a response
to the proposal that it has sent. Then p0 immediately enters the Forwarding
state.

The proposal/agreement process can proceed to downstream devices.

STP can select designated ports quickly; however, to prevent loops, all ports must
wait at least one Forward Delay interval before initiating data forwarding. RSTP
blocks non-root ports to prevent loops and uses the proposal/agreement
mechanism to shorten the time that an upstream port waits before transitioning
to the Forwarding state.

NOTE

The proposal/agreement mechanism applies only to P2P full-duplex links between two
switching devices. When proposal/agreement fails, a designated port is elected after two
Forward Delay intervals, same as designated port election in STP mode.

RSTP Topology Changes


RSTP considers that the network topology has changed when a non-edge port
transitions to the Forwarding state.

When detecting a topology change, RSTP devices react as follows:


● The local device starts a TC While timer on each non-edge designated port
and root port. The TC While timer value is twice the Hello Time value.
Within the TC While time, the local device clears MAC address entries learned
on all ports.
At the same time, the non-edge designated ports and root ports send out RST
BPDUs with the TC bit set to 1. When the TC While timer expires, the ports
stop sending RST BPDUs.
● When other switching devices receive RST BPDUs, they clear MAC address
entries learned on all their ports except the ports that receive the RST BPDUs.
These switching devices also start a TC While timer on each non-edge
designated port and root port and repeat the preceding process.

RST BPDUs are then flooded on the entire network.

Interoperability with STP


RSTP can interoperate with STP, but doing so causes RSTP to lose its advantages,
such as fast convergence.

On a network with both STP-capable and RSTP-capable devices, STP-capable


devices discard RST BPDUs. If a port on an RSTP-capable device receives a
configuration BPDU from an STP-capable device, the port switches to the STP
mode and starts to send configuration BPDUs after two Hello timer intervals.

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 702


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

After STP-capable devices are removed, Huawei RSTP-capable devices can be


switched back to the RSTP mode.

14.3 Applications

STP Application
Loops often occur on a complex network, because multiple physical links are often
deployed between two devices to implement link redundancy. Loops may cause
broadcast storms and unstable MAC address entries on network devices.

Figure 14-15 Typical STP application

Network

PE1 Root PE2


Bridge

STP

CE1 CE2

PC1 PC2
Blocked port

In Figure 14-15, STP is deployed on the devices. The devices exchange information
to discover loops on the network and block ports. This ensures a loop-free tree
network and that the packet processing capabilities of switches is not impacted.

14.4 Configuration Task Summary


Table 14-12 summarizes STP/RSTP configuration tasks.

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 703


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

Table 14-12 STP/RSTP configuration task summary


Scenario Description Task

Configuring basic STP/ Configure STP/RSTP on 14.7 Configuring Basic


RSTP functions switching devices on a STP/RSTP Functions
network to ensure that
the network has a loop-
free tree topology.

Setting STP parameters STP cannot implement 14.8 Setting STP


that affect STP rapid convergence. Parameters that Affect
convergence However, you can set STP Convergence
STP parameters,
including the network
diameter, timeout
interval, Hello timer
interval, Max Age timer
value, and Forward
Delay timer value to
speed up convergence.

Setting RSTP parameters RSTP supports link type 14.9 Setting RSTP
that affect RSTP and fast transition Parameters that Affect
convergence configuration on ports to RSTP Convergence
implement rapid
convergence.

Configuring RSTP You can configure one or 14.10 Configuring RSTP


protection functions more functions RSTP Protection Functions
protection functions on a
Huawei device.

Setting parameters for To implement 14.11 Setting


interoperation between interoperation between a Parameters for
Huawei and non-Huawei Huawei device and a Interoperation Between
devices non-Huawei device, Huawei and Non-
select a fast transition Huawei Devices
mode according to the
Proposal/Agreement
mechanism of the non-
Huawei device.

14.5 Licensing Requirements and Limitations for STP/


RSTP

Involved Network Elements


Other network elements also need to support STP or RSTP.

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 704


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

Licensing Requirements
STP or RSTP is a basic feature of a switch and is not under license control.

Version Requirements

Table 14-13 Products and versions supporting STP or RSTP

Product Product Software Version


Model

S12700 S12708, V200R005C00, V200R006C00, V200R007C00,


S12712 V200R007C20, V200R008C00, V200R009C00,
V200R010C00, V200R011C10

S12710 V200R010C00, V200R011C10

S12704 V200R008C00, V200R009C00, V200R010C00,


V200R011C10

NOTE
To know details about software mappings, see Hardware Query Tool.

Feature Limitations
When STP or RSTP is enabled on a ring network, STP or RSTP immediately starts
spanning tree calculation. Parameters such as the device priority and port priority
affect spanning tree calculation, and the change of these parameters may cause
network flapping. To ensure fast and stable spanning tree calculation, configure
parameters such as the device priority and port priority before enabling STP or
RSTP.

On a switch enabled with a spanning tree protocol, when a terminal connects to


the switch, spanning tree calculation is performed again. As a result, it takes a
long period of time for the terminal to obtain an IP address. In this case, disable
the spanning tree protocol on the switch port connected to the terminal or
configure this switch port as the edge port.

14.6 Default Configuration

Parameter Default Setting

Working mode MSTP

STP/RSTP status Enabled globally and on an interface

Switching device priority 32768

Port priority 128

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 705


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

Parameter Default Setting

Algorithm used to calculate dot1t, IEEE 802.1t


the path cost

Forward Delay 1500 centiseconds (15 seconds)

Hello Time 200 centiseconds (2 seconds)

Max Age 2000 centiseconds (20 seconds)

14.7 Configuring Basic STP/RSTP Functions


You can configure STP/RSTP on an Ethernet network to ensure that the network
has a loop-free tree topology.

14.7.1 Configuring the STP/RSTP Mode


Context
A switching device supports three working modes: STP, RSTP, and MSTP. The
default working mode is MSTP. Use the STP mode on a ring network running only
STP, and use the RSTP mode on a ring network running only RSTP.

Procedure
Step 1 Run:
system-view

The system view is displayed.


Step 2 Run:
stp mode { stp | rstp }

The working mode of the switching device is set to STP or RSTP.


By default, the working mode of a switching device is MSTP. MSTP is compatible
with STP and RSTP.

----End

14.7.2 (Optional) Configuring the Root Bridge and Secondary


Root Bridge
Context
The root bridge of a spanning tree is automatically calculated. You can also
manually specify a root bridge or secondary root bridge.
● A spanning tree can have only one root bridge. When two or more devices are
specified as root bridges for a spanning tree, the device with the smallest
MAC address is elected as the root bridge.

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 706


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

● You can specify multiple secondary root bridges for each spanning tree. When
the root bridge fails or is powered off, a secondary root bridge becomes the
new root bridge unless a new root bridge is specified. If there are multiple
secondary root bridges, the one with smallest MAC address becomes the root
bridge of the spanning tree.

NOTE
It is recommended that you specify the root bridge and secondary root bridge when
configuring STP/RSTP.

Procedure
● Perform the following operations on the device you want to use as the root
bridge.
a. Run:
system-view

The system view is displayed.


b. Run:
stp root primary

The device is configured as the root bridge.


By default, a switching device does not function as the root bridge. After
you run this command, the priority value of the device is set to 0 and
cannot be changed.
● Perform the following operations on the device you want to use as the
secondary root bridge.
a. Run:
system-view

The system view is displayed.


b. Run:
stp root secondary

The device is configured as the secondary root bridge.


By default, a switching device does not function as the secondary root
bridge. After you run this command, the priority value of the device is set
to 4096 and cannot be changed.
----End

14.7.3 (Optional) Setting a Priority for a Switching Device


Context
An STP/RSTP network can have only one root bridge, which is the logical center of
the spanning tree. The root bridge should be a high-performance switching device
deployed at an upper network layer; however, such a device may not have the
highest priority on the network. Therefore, you need to set a high priority for such
a device to ensure that it can be selected as the root bridge.
Low-performance devices at lower network layers are not suitable for root bridges,
so you need to set low priorities for these devices.

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 707


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

A smaller priority value indicates a higher priority of the switching device. The
switching device with a higher priority is more likely to be elected as the root
bridge.

Procedure
Step 1 Run:
system-view

The system view is displayed.

Step 2 Run:
stp priority priority

A priority is set for the switching device.

The default priority value of a switching device is 32768.

If the stp root primary or stp root secondary command has been executed to
configure the device as the root bridge or secondary root bridge, run the undo stp
root command to remove those configurations. Then run the stp priority priority
command to set a priority.

----End

14.7.4 (Optional) Setting a Path Cost for a Port

Context
Path cost is the reference value used for link selection on an STP/RSTP network.

The path cost value range is determined by the calculation method. After the
calculation method is determined, it is recommended that you set smaller path
cost values for the ports with higher link rates.

In the Huawei calculation method, the link rate determines the recommended
value for the path cost. Table 14-14 lists the recommended path costs for ports
with different link rates.

Table 14-14 Mappings between link rates and path cost values

Link Rate Recommended Recommended Allowable Path


Path Cost Path Cost Range Cost Range

10 Mbit/s 2000 200 to 20000 1 to 200000

100 Mbit/s 200 20 to 2000 1 to 200000

1 Gbit/s 20 2 to 200 1 to 200000

10 Gbit/s 2 2 to 20 1 to 200000

Over 10 Gbit/s 1 1 to 2 1 to 200000

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 708


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

If a network has loops, it is recommended that you set a large path cost for ports
with low link rates so that STP/RSTP blocks these ports.

Procedure
Step 1 Run:
system-view

The system view is displayed.


Step 2 (Optional) Run:
stp pathcost-standard { dot1d-1998 | dot1t | legacy }

A path cost calculation method is specified.


By default, the IEEE 802.1t standard (dot1t) is used to calculate the path costs.
All switching devices on a network must use the same path cost calculation
method.
Step 3 Run:
interface interface-type interface-number

The view of an interface participating in STP calculation is displayed.


Step 4 Run:
stp cost cost

A path cost is set for the interface.


● When the Huawei calculation method is used, cost ranges from 1 to 200000.
● When the IEEE 802.1d standard method is used, cost ranges from 1 to 65535.
● When the IEEE 802.1t standard method is used, cost ranges from 1 to
200000000.

----End

14.7.5 (Optional) Setting a Priority for a Port


Context
In spanning tree calculation, priorities of the ports in a ring affect designated port
election.
To block a port on a switching device, set a greater priority value than the default
priority value for the port.

Procedure
Step 1 Run:
system-view

The system view is displayed.


Step 2 Run:
interface interface-type interface-number

The view of an interface participating in STP calculation is displayed.

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 709


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

Step 3 Run:
stp port priority priority

A priority is set for the interface.


The default priority value of a port on a switching device is 128.

----End

14.7.6 Enabling STP/RSTP


Context

NOTICE

Spanning tree calculations begin immediately after STP/RSTP is enabled on a ring


network. Configurations on a switching device, such as the device priority and port
priority, affect spanning tree calculation. Any change to those configurations may
cause network flapping. To ensure rapid, stable spanning tree calculation, perform
basic configurations on the switching device and its ports before enabling STP/
RSTP.

Procedure
Step 1 Run:
system-view

The system view is displayed.


Step 2 Run:
stp enable

STP/RSTP is enabled on the switching device.


By default, STP/RSTP is enabled on a device. If you specify a VLANIF interface of a
VLAN as the management network interface for an MSTP-enabled device, you can
run the ethernet-loop-protection ignored-vlan command to specify this VLAN as
an ignored VLAN. Interfaces in an ignored VLAN will not enter the Blocking state
and instead remain in the Forwarding state. Therefore, services will not be
interrupted on these interfaces.

----End

Follow-up Procedure
When the topology of a spanning tree changes, the forwarding paths for
associated VLANs are changed. Switching devices need to update the ARP entries
corresponding to those VLANs. STP/RSTP convergence mode can be set as fast or
normal, which changes how the switching device processes ARP entries.
● In fast mode, ARP entries to be updated are directly deleted.
● In normal mode, ARP entries to be updated are rapidly aged.
In normal mode, the remaining lifetime of ARP entries is set to 0 to
immediately age the ARP entries out. If the number of ARP aging probes is

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 710


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

greater than 0, the switching device performs aging probe for these ARP
entries.
Run the stp converge { fast | normal } command in the system view to configure
the STP/RSTP convergence mode.
The default and recommended mode for STP/RSTP convergence is normal. If the
fast mode is used, ARP entries will be frequently deleted, causing high CPU usage
and network flapping.

14.7.7 Checking the Configuration


Procedure
● Run the display stp [ interface interface-type interface-number | slot slot-id ]
[ brief ] command to view the spanning tree status and statistics.
----End

14.8 Setting STP Parameters that Affect STP


Convergence
STP cannot implement rapid convergence. However, STP parameters including the
network diameter, timeout interval, Hello timer interval, Max Age timer value, and
Forward Delay timer value can affect the STP convergence speed.

Pre-configuration Tasks
Before setting STP parameters that affect STP convergence, configure basic STP
functions.

14.8.1 Setting the STP Network Diameter


Context
Any two terminals on a switching network are connected through a specific path
spanning multiple devices. The network diameter is the maximum number of
devices between any two terminals. A larger network diameter indicates a larger
network scale.
A network diameter that is too large may cause slow network convergence and
affect communication. Run the stp bridge-diameter command to set an
appropriate network diameter based on the network scale to speed up
convergence.
It is recommended that all devices be configured with the same network diameter.

Procedure
Step 1 Run:
system-view

The system view is displayed.

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 711


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

Step 2 Run:
stp bridge-diameter diameter

The network diameter is configured.


By default, the network diameter is 7.

NOTE

● RSTP uses a single spanning tree instance on the entire network. As a result,
performance deterioration cannot be prevented when the network scale grows. To help
mitigate this, the network diameter should not be set larger than 7.
● It is recommended that you run the stp bridge-diameter diameter command to set the
network diameter. Then, the switching device calculates the optimal Forward Delay
timer value, Hello timer interval, and Max Age timer value based on the configured
network diameter.

----End

14.8.2 Setting the STP Timeout Interval


Context
If a device does not receive any BPDUs from the upstream device within the
timeout interval, the device considers the upstream device to be down and
triggers spanning tree recalculation.
Sometimes, a device cannot receive the BPDU from the upstream device within
the timeout interval because the upstream device is busy. In this case,
recalculating the spanning tree will waste network resources. Set a long timeout
interval on a stable network to avoid this.
The timeout interval is calculated as follows:
Timeout interval = Hello Time x 3 x Timer Factor

Procedure
Step 1 Run:
system-view

The system view is displayed.


Step 2 Run:
stp timer-factor factor

The Timer Factor value is set. This parameter determines the timeout interval
during which the device waits for BPDUs from the upstream device.
By default, the timeout period is 9 times the Hello Time value.

----End

14.8.3 Setting STP Timers


Context
The following timers are used in spanning tree calculation:

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 712


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

● Forward Delay: specifies the delay before a state transition. After the topology
of a ring network changes, it takes some time to spread the new
configuration BPDU throughout the entire network. As a result, the original
blocked port may be unblocked before a new port is blocked. This creates a
loop on the network. You can set the Forward Delay timer to prevent loops.
When the topology changes, all ports will be temporarily blocked during the
Forward Delay.
● Hello Time: specifies the interval at which hello packets are sent. A device
sends configuration BPDUs at the specified interval to detect link failures. If
the switching device does not receive any BPDUs within the timeout period
(timeout period = Hello Time x 3 x Timer Factor), the device recalculates the
spanning tree.
● Max Age: determines when BPDUs expire. A switching device determines that
a received configuration BPDU times out when the Max Age expires.
Devices on a ring network must use the same values for Forward Delay, Hello
Time, and Max Age.
You are not advised to directly change the preceding three parameters as they are
related to the network scale; therefore, it is recommended that you set the
network diameter so that the spanning tree protocol automatically adjusts these
timers. When the default network diameter is used, the three timers also use their
default values.

NOTICE

To prevent frequent network flapping, make sure that the Hello Time, Forward
Delay, and Max Age timer values conform to the following formulas:
● 2 x (Forward Delay - 1 second) >= Max Age
● Max Age >= 2 x (Hello Time + 1 second)

Procedure
Step 1 Run:
system-view

The system view is displayed.


Step 2 Set the Forward Delay, Hello Time, and Max Age timers.
1. Run:
stp timer forward-delay forward-delay

The Forward Delay timer is set for the switching device.


By default, the Forward Delay timer is 1500 centiseconds (15 seconds).
2. Run:
stp timer hello hello-time

The Hello Time is set for the switching device.


By default, the Hello Time is 200 centiseconds (2 seconds).
3. Run:

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 713


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

stp timer max-age max-age

The Max Age timer is set for the switching device.


By default, the Max Age timer is 2000 centiseconds (20 seconds).

----End

14.8.4 Setting the Maximum Number of Connections in an


Eth-Trunk that Affects Spanning Tree Calculation
Context
The path costs affect spanning tree calculation. Changes to path costs trigger
spanning tree recalculation. The path cost of an interface is affected by its
bandwidth, so changes to the interface bandwidth also affect spanning tree
calculation.
In Figure 14-16, SwitchA and SwitchB are connected through two Eth-Trunk links.
Eth-Trunk 1 has three member interfaces in Up state and Eth-Trunk 2 has two
member interfaces in Up state. Each member link has the same bandwidth, and
SwitchA is selected as the root bridge.
● Eth-Trunk 1 has higher bandwidth than Eth-Trunk 2. After STP calculation,
Eth-Trunk 1 on SwitchB is selected as the root port and Eth-Trunk 2 is selected
as the alternate port.
● If the maximum number of connections affecting bandwidth of Eth-Trunk 1 is
set to 1, the path cost of Eth-Trunk 1 becomes larger than the path cost of
Eth-Trunk 2. Therefore, the two devices perform spanning tree recalculation.
Afterwards, Eth-Trunk 1 on SwitchB becomes the alternate port and Eth-Trunk
2 becomes the root port.

Figure 14-16 Setting the maximum number of connections in an Eth-Trunk


SwitchA SwitchB
Before Eth-Trunk1
configuration Eth-Trunk2

Root Bridge

SwitchA SwitchB
Eth-Trunk1
After
configuration Eth-Trunk2

Root Bridge
Alternate port
Root port
Designated port

The maximum number of connections affects only the path cost of an Eth-Trunk
interface participating in spanning tree calculation, and does not affect the actual
bandwidth of the Eth-Trunk link. The actual bandwidth for an Eth-Trunk link
depends on the number of active member interfaces in the Eth-Trunk.

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 714


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

Procedure
Step 1 Run:
system-view

The system view is displayed.


Step 2 Run:
interface eth-trunk trunk-id

The Eth-Trunk interface view is displayed.


Step 3 Run:
max bandwidth-affected-linknumber link-number

The maximum number of connections affecting the Eth-Trunk bandwidth is set.


By default, the maximum number of connections affecting the bandwidth of an
Eth-Trunk is 8.

----End

14.8.5 Checking the Configuration


Procedure
● Run the display stp [ interface interface-type interface-number | slot slot-id ]
[ brief ] command to view the spanning tree status and statistics.
----End

14.9 Setting RSTP Parameters that Affect RSTP


Convergence
RSTP supports link type and fast transition configuration on ports to implement
rapid convergence.

Pre-configuration Tasks
Before setting RSTP parameters that affect RSTP convergence, configure basic
RSTP functions.

14.9.1 Setting the RSTP Network Diameter


Context
Any two terminals on a switching network are connected through a specific path
spanning multiple devices. The network diameter is the maximum number of
devices between any two terminals. A larger network diameter indicates a larger
network scale.
A network diameter that is too large may cause slow network convergence and
affect communication. Run the stp bridge-diameter command to set an
appropriate network diameter based on the network scale to speed up
convergence.

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 715


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

It is recommended that all devices be configured with the same network diameter.

Procedure
Step 1 Run:
system-view

The system view is displayed.


Step 2 Run:
stp bridge-diameter diameter

The network diameter is configured.


By default, the network diameter is 7.

NOTE

● RSTP uses a single spanning tree instance on the entire network. As a result,
performance deterioration cannot be prevented when the network scale grows. To help
mitigate this, the network diameter should not be set larger than 7.
● It is recommended that you run the stp bridge-diameter diameter command to set the
network diameter. Then, the switching device calculates the optimal Forward Delay
timer value, Hello timer interval, and Max Age timer value based on the configured
network diameter.

----End

14.9.2 Setting the RSTP Timeout Interval


Context
If a device does not receive any BPDUs from the upstream device within the
timeout interval, the device considers the upstream device to be down and
triggers spanning tree recalculation.
Sometimes, a device cannot receive the BPDU from the upstream device within
the timeout interval because the upstream device is busy. In this case,
recalculating the spanning tree will waste network resources. Set a long timeout
interval on a stable network to avoid this.
The timeout interval is calculated as follows:
Timeout interval = Hello Time x 3 x Timer Factor

Procedure
Step 1 Run:
system-view

The system view is displayed.


Step 2 Run:
stp timer-factor factor

The Timer Factor value is set. This parameter determines the timeout interval
during which the device waits for BPDUs from the upstream device.

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 716


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

By default, the timeout period is 9 times the Hello Time value.

----End

14.9.3 Setting RSTP Timers


Context
The following timers are used in spanning tree calculation:
● Forward Delay: specifies the delay before a state transition. After the topology
of a ring network changes, it takes some time to spread the new
configuration BPDU throughout the entire network. As a result, the original
blocked port may be unblocked before a new port is blocked. This creates a
loop on the network. You can set the Forward Delay timer to prevent loops.
When the topology changes, all ports will be temporarily blocked during the
Forward Delay.
● Hello Time: specifies the interval at which hello packets are sent. A device
sends configuration BPDUs at the specified interval to detect link failures. If
the switching device does not receive any BPDUs within the timeout period
(timeout period = Hello Time x 3 x Timer Factor), the device recalculates the
spanning tree.
● Max Age: determines when BPDUs expire. A switching device determines that
a received configuration BPDU times out when the Max Age expires.
Devices on a ring network must use the same values for Forward Delay, Hello
Time, and Max Age.
You are not advised to directly change the preceding three parameters as they are
related to the network scale; therefore, it is recommended that you set the
network diameter so that the spanning tree protocol automatically adjusts these
timers. When the default network diameter is used, the three timers also use their
default values.

NOTICE

To prevent frequent network flapping, make sure that the Hello Time, Forward
Delay, and Max Age timer values conform to the following formulas:
● 2 x (Forward Delay - 1 second) >= Max Age
● Max Age >= 2 x (Hello Time + 1 second)

Procedure
Step 1 Run:
system-view

The system view is displayed.


Step 2 Set the Forward Delay, Hello Time, and Max Age timers.
1. Run:
stp timer forward-delay forward-delay

The Forward Delay timer is set for the switching device.

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 717


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

By default, the Forward Delay timer is 1500 centiseconds (15 seconds).


2. Run:
stp timer hello hello-time

The Hello Time is set for the switching device.


By default, the Hello Time is 200 centiseconds (2 seconds).
3. Run:
stp timer max-age max-age

The Max Age timer is set for the switching device.


By default, the Max Age timer is 2000 centiseconds (20 seconds).

----End

14.9.4 Setting the Maximum Number of Connections in an


Eth-Trunk that Affects Spanning Tree Calculation
Context
The path costs affect spanning tree calculation. Changes to path costs trigger
spanning tree recalculation. The path cost of an interface is affected by its
bandwidth, so changes to the interface bandwidth also affect spanning tree
calculation.
In Figure 14-17, SwitchA and SwitchB are connected through two Eth-Trunk links.
Eth-Trunk 1 has three member interfaces in Up state and Eth-Trunk 2 has two
member interfaces in Up state. Each member link has the same bandwidth, and
SwitchA is selected as the root bridge.
● Eth-Trunk 1 has higher bandwidth than Eth-Trunk 2. After STP calculation,
Eth-Trunk 1 on SwitchB is selected as the root port and Eth-Trunk 2 is selected
as the alternate port.
● If the maximum number of connections affecting bandwidth of Eth-Trunk 1 is
set to 1, the path cost of Eth-Trunk 1 becomes larger than the path cost of
Eth-Trunk 2. Therefore, the two devices perform spanning tree recalculation.
Afterwards, Eth-Trunk 1 on SwitchB becomes the alternate port and Eth-Trunk
2 becomes the root port.

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 718


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

Figure 14-17 Setting the maximum number of connections in an Eth-Trunk


SwitchA SwitchB
Before Eth-Trunk1
configuration Eth-Trunk2

Root Bridge

SwitchA SwitchB
Eth-Trunk1
After
configuration Eth-Trunk2

Root Bridge
Alternate port
Root port
Designated port

The maximum number of connections affects only the path cost of an Eth-Trunk
interface participating in spanning tree calculation, and does not affect the actual
bandwidth of the Eth-Trunk link. The actual bandwidth for an Eth-Trunk link
depends on the number of active member interfaces in the Eth-Trunk.

Procedure
Step 1 Run:
system-view

The system view is displayed.

Step 2 Run:
interface eth-trunk trunk-id

The Eth-Trunk interface view is displayed.

Step 3 Run:
max bandwidth-affected-linknumber link-number

The maximum number of connections affecting the Eth-Trunk bandwidth is set.

By default, the maximum number of connections affecting the bandwidth of an


Eth-Trunk is 8.

----End

14.9.5 Setting the Link Type for a Port

Context
P2P links can implement rapid convergence. If the two ports connected by a P2P
link are root or designated ports, they can transition to the Forwarding state
quickly by sending Proposal and Agreement packets. This reduces the forwarding
delay.

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 719


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

Procedure
Step 1 Run:
system-view

The system view is displayed.

Step 2 Run:
interface interface-type interface-number

The view of an Ethernet interface participating in STP calculation is displayed.

Step 3 Run:
stp point-to-point { auto | force-false | force-true }

The link type is set for the interface.

By default, an interface automatically identifies whether it is connected to a P2P


link. P2P links implement rapid network convergence.

● If the Ethernet interface works in full-duplex mode, the interface is connected


to a P2P link. In this case, force-true can be specified in the command to
implement rapid network convergence.
● If the Ethernet interface works in half-duplex mode, you can run the stp
point-to-point force-true command to forcibly set the link type to P2P.

----End

14.9.6 Setting the Maximum Transmission Rate of an Interface

Context
If more BPDUs are sent from an interface within a Hello timer interval, more
system resources are consumed. Setting a proper transmission rate (packet-
number) on an interface prevents excess bandwidth usage when network flapping
occurs.

Procedure
Step 1 Run:
system-view

The system view is displayed.

Step 2 Run:
interface interface-type interface-number

The view of an Ethernet interface participating in STP calculation is displayed.

Step 3 Run:
stp transmit-limit packet-number

The maximum transmission rate of BPDUs in a specified period of time is set for
the interface.

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 720


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

By default, an interface sends a maximum of six BPDUs per second. If the same
maximum transmission rate of BPDUs needs to be set for each interface on a
device, run the stp transmit-limit (system view) command.

----End

14.9.7 Switching to the RSTP Mode

Context
If an interface on an RSTP-enabled device is connected to an STP-enabled device,
the interface switches to the STP compatible mode.

If the STP-enabled device is powered off or disconnected from the RSTP-enabled


device, the interface cannot automatically switch back to the RSTP mode. Run the
stp mcheck command to switch the interface to the RSTP mode.

You need to manually switch the interface to the RSTP mode in the following
situations:

● The STP-enabled device is shut down or disconnected.


● The STP-enabled device is switched to the RSTP mode.

Procedure
● Switching to the RSTP mode in the interface view
a. Run:
system-view

The system view is displayed.


b. Run:
interface interface-type interface-number

The view of an interface participating in spanning tree calculation is


displayed.
c. Run:
stp mcheck

The interface is switched to the RSTP mode.


● Switching to the RSTP mode in the system view
a. Run:
system-view

The system view is displayed.


b. Run:
stp mcheck

The device is switched to the RSTP mode.

----End

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 721


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

14.9.8 Configuring Edge Ports and BPDU Filter Ports


Context
A port that is located at the edge of a network and directly connected to a
terminal device is an edge port.
Edge ports can still send BPDUs, but if the BPDUs are sent to another network
then network flapping may occur on that network. To prevent this problem,
configure the BPDU filter function on edge ports so that the edge ports do not
process or send BPDUs.

NOTE

If all the ports are configured as both edge ports and BPDU filter ports in the system view,
none of ports on the local device can send BPDUs or negotiate STP states with directly
connected ports on peer devices. Additionally, all ports are in Forwarding state. This may
cause loops on the network, leading to broadcast storms. Exercise caution when deciding to
perform this configuration.
After a specified port is configured as both an edge port and a BPDU filter port in the
interface view, the port does not process or send BPDUs and cannot negotiate the STP state
with the directly connected port on the peer device. Exercise caution when deciding to
perform this configuration.

Procedure
● Configuring all ports as edge ports and BPDU filter ports
a. Run:
system-view

The system view is displayed.


b. Run:
stp edged-port default

All ports are configured as edge ports.


By default, all ports are non-edge ports.
c. Run:
stp bpdu-filter default

All ports are configured as BPDU filter ports.


By default, all ports are non-BPDU filter ports.
● Configuring a specified port as an edge port and BPDU filter port
a. Run:
system-view

The system view is displayed.


b. Run:
interface interface-type interface-number

The view of an Ethernet interface that participates in spanning tree


calculation is displayed.
c. Run:
stp edged-port enable

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 722


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

The port is configured as an edge port.

By default, all ports are non-edge ports.


d. Run:
stp bpdu-filter enable

The port is configured as a BPDU filter port.

By default, a port is a non-BPDU filter port.

----End

14.9.9 Checking the Configuration

Procedure
● Run the display stp [ interface interface-type interface-number | slot slot-id ]
[ brief ] command to view the spanning tree status and statistics.

----End

14.10 Configuring RSTP Protection Functions


Huawei network devices provide the following RSTP protection functions.

14.10.1 Configuring BPDU Protection on a Switching Device

Procedure
Step 1 Run:
system-view

The system view is displayed.

Step 2 Run:
stp bpdu-protection

BPDU protection is enabled on the switching device.

By default, BPDU protection is disabled on a switching device.

----End

Follow-up Procedure
If you want an edge port to automatically recover from the error-down state, run
the error-down auto-recovery cause bpdu-protection interval interval-value
command in the system view to configure the auto recovery function and set a
recovery delay on the port. Then a port in error-down state can automatically go
Up after the recovery delay. Note the following when setting the recovery delay:
● The auto recovery function is disabled by default and does not have a default
value for the recovery delay. When you enable the auto recovery function, you
must set a recovery delay.

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 723


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

● A smaller interval-value indicates a shorter time before an edge port goes Up,
and a higher frequency of Up/Down state transitions on the port.
● A larger interval-value indicates a longer time before an edge port goes Up,
and a longer service interruption time.
● The auto recovery function takes effect only for the interfaces that transition
to the error-down state after the error-down auto-recovery command is
executed.

14.10.2 Configuring TC Protection on a Switching Device


Context
If an attacker sends a large number of malicious TC BPDUs to a switching device
within a short period, the device will constantly delete MAC address entries and
ARP entries. This wastes resources on the device and threatens network stability.
To suppress TC BPDUs, enable TC protection on a switching device and set the
maximum number of TC BPDUs that the device can process within a given time
period. If the number of TC BPDUs that the switching device receives within a
given time period exceeds the specified threshold, the switching device processes
only the specified number of TC BPDUs. After the specified time period expires, the
switching devices process all the excess TC BPDUs together. This function prevents
the switching device from frequently deleting MAC entries and ARP entries.

Procedure
Step 1 Run:
system-view

The system view is displayed.


Step 2 Run:
stp tc-protection interval interval-value

The time period during which the device processes the maximum number of TC
BPDUs is set.
By default, the time period is the same as the Hello timer interval.
Step 3 Run:
stp tc-protection threshold threshold

The maximum number of TC BPDUs the switching device can process within a
specified time period is set.
By default, the device processes only one TC BPDU within a specified time period.
The switch only processes TC BPDUs up to the maximum specified by the stp tc-
protection threshold command within the time period specified by the stp tc-
protection interval command. Other packets are processed after a delay, so
spanning tree convergence speed is slower. For example, if the time period is set
to 10 seconds and the maximum of TC BPDUs is set to 5, the switch processes only
the first five TC BPDUs within 10 seconds. Subsequent TC BPDUs are processed
together after a 10 second delay.

----End

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 724


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

14.10.3 Configuring Root Protection on a Port


Procedure
Step 1 Run:
system-view

The system view is displayed.


Step 2 Run:
interface interface-type interface-number

The view of an interface participating in STP calculation is displayed.


Step 3 Run:
stp root-protection

Root protection is enabled on the interface.


By default, root protection is disabled on the interface. Root protection takes
effect only on designated ports. Generally, root protection is configured on the
interfaces of the root bridge.
Root protection and loop protection cannot be configured on the same interface.

----End

14.10.4 Configuring Loop Protection on a Port


Context
On an RSTP network, a switching device maintains the states of the root port and
blocked ports based on BPDUs received from an upstream switching device. If the
switching device cannot receive BPDUs from the upstream because of link
congestion or unidirectional-link failure, the switching device selects a new root
port. The original root port becomes a designated port, and the original blocked
ports change to the Forwarding state, which may cause loops on the network. To
prevent this problem, configure loop protection.
If the root port or alternate port does not receive BPDUs from the upstream device
for a specified period, a switch enabled with loop protection sends a notification
to the NMS. If the root port is used, the root port enters the Discarding state and
becomes the designated port. If the alternate port is used, the alternate port
remains blocked and becomes the designated port. In this case, loops will not
occur. After the link is no longer congested or unidirectional link failures are
rectified, the port receives BPDUs for negotiation and restores its original role and
status.

Procedure
Step 1 Run:
system-view

The system view is displayed.


Step 2 Run:

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 725


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

interface interface-type interface-number

The view of the root port or alternate port is displayed.


Step 3 Run:
stp loop-protection

Loop protection is enabled on the root port or alternate port.


By default, loop protection is disabled on a port.

NOTE

An alternate port is a backup for a root port. If a switching device has an alternate port,
configure loop protection on both the root port and the alternate port.
Root protection and loop protection cannot be configured on the same port.

----End

14.10.5 Checking the Configuration


Procedure
● Run the display stp [ interface interface-type interface-number | slot slot-id ]
[ brief ] command to view the spanning tree status and statistics.
----End

14.11 Setting Parameters for Interoperation Between


Huawei and Non-Huawei Devices
To implement interoperation between a Huawei device and a non-Huawei device,
select a fast transition mode according to the Proposal/Agreement mechanism of
the non-Huawei device.

Context
A switching device supports the following Proposal/Agreement modes:
● Enhanced mode: The device determines the root port when it calculates the
synchronization flag bit.
a. An upstream device sends a Proposal message to a downstream device to
request a fast state transition. After receiving the message, the
downstream device sets the port connected to the upstream device as the
root port and blocks all non-edge ports.
b. The upstream device sends an Agreement message to the downstream
device. After the downstream device receives the message, the root port
transitions to the Forwarding state.
c. The downstream device responds with an Agreement message. After
receiving the message, the upstream device sets the port connected to
the downstream device as the designated port, and then the designated
port transitions to the Forwarding state.
● Common mode: The device ignores the root port when it calculates the
synchronization flag bit.

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 726


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

a. An upstream device sends a Proposal message to a downstream device to


request a fast state transition. After receiving the message, the
downstream device sets the port connected to the upstream device as the
root port and blocks all non-edge ports. Then, the root port transitions to
the Forwarding state.
b. The downstream device responds with an Agreement message. After
receiving the message, the upstream device sets the port connected to
the downstream device as the designated port, and then the designated
port transitions to the Forwarding state.
On an STP network, if a Huawei switching device is connected to a non-Huawei
device that uses a different Proposal/Agreement mechanism, the two devices may
not be able to interoperate. Select the mode that matches the Proposal/
Agreement mechanism of the non-Huawei device.

Pre-configuration Tasks
Before setting parameters for interoperation between Huawei and non-Huawei
devices, configure basic STP/RSTP functions.

Procedure
Step 1 Run:
system-view

The system view is displayed.


Step 2 Run:
interface interface-type interface-number

The view of an interface participating in spanning tree calculation is displayed.


Step 3 Run:
stp no-agreement-check

The common fast transition mode is specified.


By default, the enhanced fast transition mode is used on a port.

----End

14.12 Maintaining STP/RSTP

14.12.1 Clearing STP/RSTP Statistics


Context

NOTICE

STP/RSTP statistics cannot be restored after being cleared. Exercise caution when
deciding to clear STP/RSTP statistics.

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 727


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

Procedure
● Run the reset stp [ interface interface-type interface-number ] statistics
command to clear spanning-tree statistics.
● Run the reset stp error packet statistics command to clear statistics about
error STP packets.

----End

14.12.2 Monitoring STP/RSTP Topology Change Statistics

Context
The statistics about STP/RSTP topology changes can be viewed. If the number of
network topology changes increase, network flapping is occurring on that
network.

Procedure
● Run the display stp topology-change command to view statistics about STP/
RSTP topology changes.
● Run the display stp [ interface interface-type interface-number | slot slot-id ]
tc-bpdu statistics command to view statistics about sent and received
TC/TCN packets.
● Run the display stp [ interface interface-type interface-number | slot slot-id ]
[ brief ] command to view the spanning tree status and statistics.

----End

14.13 Configuration Examples

14.13.1 Example for Configuring Basic STP Functions

Networking Requirements
On a complex network, multiple physical links are often deployed between two
devices for link redundancy (one as the active link and the others as standby
links). Redundant links may cause loops on the network, which result in broadcast
storms and unstable MAC address entries.

STP can be deployed on a network to eliminate loops by blocking ports. In Figure


14-18, a loop exists on the network, and SwitchA, SwitchB, SwitchC, and SwitchD
are all running STP. These devices exchange BPDUs to discover the loops and block
the appropriate ports in order to trim the ring topology into a loop-free tree
topology. The tree topology prevents infinite looping of packets, which in turn
helps improve packet processing performance.

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 728


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

Figure 14-18 Networking diagram of basic STP configurations

Network

GE1/0/3 GE1/0/3
Root
SwitchD GE1/0/1 GE1/0/1
Bridge

GE1/0/2 GE1/0/2 SwitchA

STP

GE1/0/3 GE1/0/3

SwitchC SwitchB
GE1/0/1 GE1/0/1
GE1/0/2 GE1/0/2

PC1 PC2
Blocked port

Configuration Roadmap
The configuration roadmap is as follows:
1. Configure the STP mode for the switches on the ring network.
2. Configure the primary and secondary root bridges.
3. Set a path cost for the ports to be blocked.
4. Enable STP to eliminate loops. Because ports connected to the PCs do not
participate in STP calculation, configure these ports as both edge ports.

Procedure
Step 1 Configure basic STP functions.
1. Configure the STP mode for the switches on the ring network.
# Configure the STP mode on SwitchA.
<HUAWEI> system-view
[HUAWEI] sysname SwitchA
[SwitchA] stp mode stp

# Configure the STP mode on SwitchB.


<HUAWEI> system-view
[HUAWEI] sysname SwitchB
[SwitchB] stp mode stp

# Configure the STP mode on SwitchC.

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 729


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

<HUAWEI> system-view
[HUAWEI] sysname SwitchC
[SwitchC] stp mode stp
# Configure the STP mode on SwitchD.
<HUAWEI> system-view
[HUAWEI] sysname SwitchD
[SwitchD] stp mode stp
2. Configure the primary and secondary root bridges.
# Configure SwitchA as the primary root bridge.
[SwitchA] stp root primary
# Configure SwitchD as the secondary root bridge.
[SwitchD] stp root secondary
3. Set a path cost for the ports to be blocked.
– The path cost value range depends on path cost calculation methods.
This example uses the Huawei proprietary calculation method and sets
the path cost to 20000 (the greatest value in the range).
– All switching devices on a network must use the same path cost
calculation method.
# On Switch A, set the path cost calculation method to the Huawei
proprietary method.
[SwitchA] stp pathcost-standard legacy
# On Switch B, set the path cost calculation method to the Huawei
proprietary method.
[SwitchB] stp pathcost-standard legacy
# On Switch C, set the path cost of GigabitEthernet1/0/1 to 20000.
[SwitchC] stp pathcost-standard legacy
[SwitchC] interface gigabitethernet 1/0/1
[SwitchC-GigabitEthernet1/0/1] stp cost 20000
[SwitchC-GigabitEthernet1/0/1] quit
# On SwitchD, set the path cost calculation method to the Huawei proprietary
method.
[SwitchD] stp pathcost-standard legacy
4. Enable STP to eliminate loops.
– Configure the ports connected to PCs as both edge ports.
# Configure GigabitEthernet1/0/2 of SwitchB as both an edge port.
[SwitchB] interface gigabitethernet 1/0/2
[SwitchB-GigabitEthernet1/0/2] stp edged-port enable
[SwitchB-GigabitEthernet1/0/2] quit
(Optional) Configure BPDU protection on SwitchB.
[SwitchB] stp bpdu-protection
# Configure GigabitEthernet1/0/2 of SwitchC as both an edge port.
[SwitchC] interface gigabitethernet 1/0/2
[SwitchC-GigabitEthernet1/0/2] stp edged-port enable
[SwitchC-GigabitEthernet1/0/2] quit
(Optional) Configure BPDU protection on SwitchC.
[SwitchC] stp bpdu-protection

NOTE
If edge ports are connected to network devices that have STP enabled and BPDU
protection is enabled, the edge ports will be shut down and their attributes
remain unchanged after they receive BPDUs.

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 730


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

– Enable STP globally.


# Enable STP globally on SwitchA.
[SwitchA] stp enable

# Enable STP globally on SwitchB.


[SwitchB] stp enable

# Enable STP globally on SwitchC.


[SwitchC] stp enable

# Enable STP globally on SwitchD.


[SwitchD] stp enable

Step 2 Verify the configuration.


After the preceding configuration is complete and the network becomes stable,
perform the following operations to verify the configuration:
# Run the display stp brief command on SwitchA to view the port states and
protection type. The following information is displayed:
[SwitchA] display stp brief
MSTID Port Role STP State Protection
0 GigabitEthernet1/0/1 DESI FORWARDING NONE
0 GigabitEthernet1/0/2 DESI FORWARDING NONE

After SwitchA is configured as the root bridge, GigabitEthernet 1/0/2 connected to


SwitchB and GigabitEthernet 1/0/1connected to SwitchD are elected as designated
ports through spanning tree calculation.
# Run the display stp interface gigabitethernet 1/0/1 brief command on
SwitchB to view status of GigabitEthernet 1/0/1. The following information is
displayed:
[SwitchB] display stp interface gigabitethernet 1/0/1 brief
MSTID Port Role STP State Protection
0 GigabitEthernet1/0/1 DESI FORWARDING NONE

GigabitEthernet 1/0/1 is elected as a designated port and is in the Forwarding


state.
# Run the display stp brief command on SwitchC to view the interface states and
protection type. The following information is displayed:
[SwitchC] display stp brief
MSTID Port Role STP State Protection
0 GigabitEthernet1/0/1 ALTE DISCARDING NONE
0 GigabitEthernet1/0/3 ROOT FORWARDING NONE

GigabitEthernet 1/0/3 is elected as a root port and is in the Forwarding state.


GigabitEthernet 1/0/1 is elected as an alternate port and is in the Discarding state.

----End

Configuration Files
● SwitchA configuration file
#
sysname SwitchA
#
stp mode stp
stp instance 0 root primary

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 731


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

stp pathcost-standard legacy


#
return
● SwitchB configuration file
#
sysname SwitchB
#
stp mode stp
stp bpdu-protection
stp pathcost-standard legacy
#
interface GigabitEthernet1/0/2
stp edged-port enable
#
return
● SwitchC configuration file
#
sysname SwitchC
#
stp mode stp
stp pathcost-standard legacy
stp bpdu-protection
#
interface GigabitEthernet1/0/1
stp instance 0 cost 20000
#
interface GigabitEthernet1/0/2
stp edged-port enable
#
return
● SwitchD configuration file
#
sysname SwitchD
#
stp mode stp
stp instance 0 root secondary
stp pathcost-standard legacy
#
return

Related Content
Videos
Configuring STP to Prevent Loops

14.13.2 Example for Configuring Basic RSTP Functions


Networking Requirements
On a complex network, multiple physical links are often deployed between two
devices for link redundancy (one as the active link and the others as standby
links). Redundant links may cause loops on the network, which result in broadcast
storms and unstable MAC address entries.
RSTP can be deployed on a network to eliminate loops by blocking ports. In
Figure 14-19, a loop exists on the network, and SwitchA, SwitchB, SwitchC, and
SwitchD are all running RSTP. These devices exchange BPDUs to discover the loops
and block the appropriate ports in order to trim the ring topology into a loop-free
tree topology. The tree topology prevents infinite looping of packets, which in turn
helps improve packet processing performance.

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 732


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

Figure 14-19 Networking diagram of basic RSTP configurations

Network

GE1/0/3 GE1/0/3
Root
SwitchD GE1/0/1 GE1/0/1
Bridge

GE1/0/2 GE1/0/2 SwitchA

RSTP

GE1/0/3 GE1/0/3

SwitchC SwitchB
GE1/0/1 GE1/0/1
GE1/0/2 GE1/0/2

PC1 PC2
Blocked port

Configuration Roadmap
The configuration roadmap is as follows:
1. Configure basic RSTP functions.
a. Configure the RSTP mode for the switches on the ring network.
b. Configure the primary and secondary root bridges.
c. Set a path cost for the ports to be blocked.
d. Enable RSTP to eliminate loops. Because ports connected to the PCs do
not participate in RSTP calculation, configure these ports as both edge
ports.
2. Configure RSTP protection functions. For example, configure root protection
on designated ports of the root bridge.

Procedure
Step 1 Configure basic RSTP functions.
1. Configure the RSTP mode for the switches on the ring network.
# Configure the RSTP mode on SwitchA.
<HUAWEI> system-view
[HUAWEI] sysname SwitchA
[SwitchA] stp mode rstp

# Configure the RSTP mode on SwitchB.

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 733


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

<HUAWEI> system-view
[HUAWEI] sysname SwitchB
[SwitchB] stp mode rstp

# Configure the RSTP mode on SwitchC.


<HUAWEI> system-view
[HUAWEI] sysname SwitchC
[SwitchC] stp mode rstp

# Configure the RSTP mode on SwitchD.


<HUAWEI> system-view
[HUAWEI] sysname SwitchD
[SwitchD] stp mode rstp

2. Configure the primary and secondary root bridges.


# Configure SwitchA as the primary root bridge.
[SwitchA] stp root primary

# Configure SwitchD as the secondary root bridge.


[SwitchD] stp root secondary

3. Set a path cost for the ports to be blocked.


– The path cost value range depends on path cost calculation methods.
This example uses the Huawei proprietary calculation method and sets
the path cost to 20000.
– All switching devices on a network must use the same path cost
calculation method.
# On Switch A, set the path cost calculation method to the Huawei
proprietary method.
[SwitchA] stp pathcost-standard legacy

# On Switch B, set the path cost calculation method to the Huawei


proprietary method.
[SwitchB] stp pathcost-standard legacy

# On Switch C, set the path cost of GigabitEthernet1/0/1 to 20000.


[SwitchC] stp pathcost-standard legacy
[SwitchC] interface gigabitethernet 1/0/1
[SwitchC-GigabitEthernet1/0/1] stp cost 20000
[SwitchC-GigabitEthernet1/0/1] quit

# On SwitchD, set the path cost calculation method to the Huawei proprietary
method.
[SwitchD] stp pathcost-standard legacy

4. Enable RSTP to eliminate loops.


– Configure the ports connected to PCs as both edge ports.
# Configure GigabitEthernet1/0/2 on SwitchB as both an edge port.
[SwitchB] interface gigabitethernet 1/0/2
[SwitchB-GigabitEthernet1/0/2] stp edged-port enable
[SwitchB-GigabitEthernet1/0/2] quit

(Optional) Configure BPDU protection on SwitchB.


[SwitchB] stp bpdu-protection

# Configure GigabitEthernet1/0/2 on SwitchC as both an edge port.


[SwitchC] interface gigabitethernet 1/0/2
[SwitchC-GigabitEthernet1/0/2] stp edged-port enable
[SwitchC-GigabitEthernet1/0/2] quit

(Optional) Configure BPDU protection on SwitchC.


[SwitchC] stp bpdu-protection

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 734


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

NOTE
If edge ports are connected to network devices that have STP enabled and BPDU
protection is enabled, the edge ports will be shut down and their attributes
remain unchanged after they receive BPDUs.
– Enable RSTP globally.
# Enable RSTP globally on SwitchA.
[SwitchA] stp enable
# Enable RSTP globally on SwitchB.
[SwitchB] stp enable
# Enable RSTP globally on SwitchC.
[SwitchC] stp enable
# Enable RSTP globally on SwitchD.
[SwitchD] stp enable

Step 2 Configure RSTP protection functions. For example, configure root protection on
designated ports of the root bridge.
# Enable root protection on GE 1/0/1 on SwitchA.
[SwitchA] interface gigabitethernet 1/0/1
[SwitchA-GigabitEthernet1/0/1] stp root-protection
[SwitchA-GigabitEthernet1/0/1] quit

# Enable root protection on GE 1/0/2 on SwitchA.


[SwitchA] interface gigabitethernet 1/0/2
[SwitchA-GigabitEthernet1/0/2] stp root-protection
[SwitchA-GigabitEthernet1/0/2] quit

Step 3 Verify the configuration.


After the preceding configuration is complete and the network becomes stable,
perform the following operations to verify the configuration:
# Run the display stp brief command on SwitchA to view the port roles and
states. The following information is displayed:
[SwitchA] display stp brief
MSTID Port Role STP State Protection
0 GigabitEthernet1/0/1 DESI FORWARDING ROOT
0 GigabitEthernet1/0/2 DESI FORWARDING ROOT

After SwitchA is configured as the root bridge, GigabitEthernet1/0/2 connected to


SwitchB and GigabitEthernet1/0/1 connected to SwitchD are elected as designated
ports through spanning tree calculation. Root protection is enabled on the
designated ports.
# Run the display stp interface gigabitethernet 1/0/1 brief command on
SwitchB to view the role and state of GigabitEthernet1/0/1. The following
information is displayed:
[SwitchB] display stp interface gigabitethernet 1/0/1 brief
MSTID Port Role STP State Protection
0 GigabitEthernet1/0/1 DESI FORWARDING NONE

GigabitEthernet1/0/1 is elected as a designated port and is in the Forwarding


state.
# Run the display stp brief command on SwitchC to view the port roles and
states. The following information is displayed:

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 735


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

[SwitchC] display stp brief


MSTID Port Role STP State Protection
0 GigabitEthernet1/0/1 ALTE DISCARDING NONE
0 GigabitEthernet1/0/2 DESI FORWARDING BPDU
0 GigabitEthernet1/0/3 ROOT FORWARDING NONE

GE1/0/1 is elected as an alternate port and is in the Discarding state.


GE1/0/3 is elected as a root port and is in the Forwarding state.

----End

Configuration Files
● SwitchA configuration file
#
sysname SwitchA
#
stp mode rstp
stp instance 0 root primary
stp pathcost-standard legacy
#
interface GigabitEthernet1/0/1
stp root-protection
#
interface GigabitEthernet1/0/2
stp root-protection
#
return
● SwitchB configuration file
#
sysname SwitchB
#
stp mode rstp
stp bpdu-protection
stp pathcost-standard legacy
#
interface GigabitEthernet1/0/2
stp edged-port enable
#
return
● SwitchC configuration file
#
sysname SwitchC
#
stp mode rstp
stp bpdu-protection
stp pathcost-standard legacy
#
interface GigabitEthernet1/0/1
stp instance 0 cost 20000
#
interface GigabitEthernet1/0/2
stp edged-port enable
#
return
● SwitchD configuration file
#
sysname SwitchD
#
stp mode rstp
stp instance 0 root secondary
stp pathcost-standard legacy
#
return

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 736


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

Related Content
Videos

Configuring STP to Prevent Loops

14.14 FAQ

14.14.1 How to Prevent Low Convergence for STP Edge Ports


that Connect Terminals?
Terminal devices cannot participate in the STP calculation or respond to STP
packets, causing low convergence. You can prevent low convergence for STP edge
switch ports for connecting user terminals or servers as follows:

● On a port, run the stp edge-port enable command to configure the port as
an STP edge port, and run the stp bpdu-filter enable command to enable
the BPDU packet filtering function and prevent the port from sending BPDU
packets.
● Run the stp disable command on the port to disable the STP protocol and
make the port remain in forwarding state.
To ensure availability and security, you are advised to configure the port as an STP
edge port. This is because when a loop occurs on a terminal device connected to
an edge port, the port automatically switches to a non-edge port and enables the
loop breaking function of STP.

14.14.2 Can Switches Using RSTP and STP Be Connected?

Switches using RSTP and STP can be connected. STP protocols include the STP,
RSTP, and MSTP protocols. These protocols support forward compatibility and
connection to a certain extent. The following table describes the connection
effects.

Scenario Connection Effect

An STP device connects to RSTP connects to the STP port, and the mode
an RSTP device. automatically changes to STP to implement slow
convergence.

An RSTP device connects The CIST can be connected. That is, instance 0 can
to an MSTP device. be connected. The connection ports are inter-AS
ports.

An MSTP device connects MSTP connects to the STP port, and the mode
to an STP device. automatically changes to STP to implement slow
convergence.

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 737


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

NOTE
When a port whose mode switches reconnects to another device, the original mode must
be restored by running the stp mcheck command.

14.14.3 Why Is the Recommended Value of STP Network


Radius Within 7?
According to the initial spanning tree protocol, the default interval for an STP
switch to send BPDUs is 2 seconds. Each switch receives and processes BPDUs for
about 1 second each time, and supports a maximum of 20 hops.
According to the RSTP protocol, packets are aged after three intervals (6 seconds)
by default. If a hop takes 1 second, a packet times out after 6 hops. Therefore, the
recommended value of STP network radius cannot be greater than 7.
There are also some other considerations such as bandwidth usage, storm range,
and the maintainability and manageability of the network.

14.14.4 In What Condition Do I Need to Configure STP Edge


Ports?
User-side devices such as servers do not need to run STP. If STP is enabled on
switch ports connected to these devices, the ports will alternate between Up and
Down or cannot enter the Forwarding state immediately after a topology change
on the STP network, which is unacceptable for some services. To prevent the
preceding problem, configure the ports that do not need to run STP as edge ports.
Edge ports can enter the Forwarding state immediately after they go Up. In
addition, edge ports do not send TC BPDUs and therefore do not affect services on
the STP network.

14.14.5 What Are Precautions for Configuring the Formats of


Sent and Received BPDUs on an STP Interface?
There are two STP BPDU formats: standard IEEE 802.1s format and proprietary
format. The switch supports both formats and works in auto mode by default. You
can run the stp compliance command on an STP interface to change the packet
format. In auto mode, an STP interface can parse BPDUs in any format received
from the peer interface.
When a Huawei switch is connected to another vendor' device, the two devices
may fail to communicate because of different keys in BPDUs even though they
have the same domain name, revision level, and VLAN mapping table. To solve
this problem, run the stp config-digest-snoop command to enable digest
snooping. This function enables the Huawei switch to keep its BPDU key
consistent with that used on the peer device.

14.14.6 How Do I Configure a User-Side Interface on an STP


Switch?
Terminal devices cannot participate in the STP calculation or respond to STP
packets. You can configure a user-side interface as follows:

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 738


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

● On a port, run the stp edge-port enable command to configure the port as
an STP edge port, and run the stp bpdu-filter enable command to enable
the BPDU packet filtering function and prevent the port from sending BPDU
packets.
● Run the stp disable command on the port to disable the STP protocol and
make the port remain in forwarding state.
To ensure availability and security, you are advised to configure the port as an STP
edge port. This is because when a loop occurs on a terminal device connected to
an edge port, the port automatically switches to a non-edge port and enables the
loop breaking function of STP.

14.14.7 How Do I Prevent Terminals' Failures to Ping the


Gateway or Low Speed in Obtaining IP Addresses When They
Connect to an STP Network?
Terminal devices such as servers or network management workstations do not
support STP. However, STP is enabled on switch interfaces by default. An STP
interface enters the Forwarding state 30 seconds after it changes to the Up state.
If an interface alternates between Up and Down states, the terminal connected to
the interface will fail to communicate with the gateway or spends a long time to
obtain an IP address.
To solve this problem, configure interfaces connected to terminals as edge ports or
disable STP on the interfaces.
To ensure availability and security, you are advised to configure the port as an STP
edge port. This is because when a loop occurs on a terminal device connected to
an edge port, the port automatically switches to a non-edge port and enables the
loop breaking function of STP.

14.14.8 Can the Switch Work with Non-Huawei Devices


Running STP or RSTP?
The switch adopts the standard STP or RSTP algorithm. Whether the switch can
work with the STP or RSTP devices of other vendors depends on the protocols
running on those STP or RSTP devices:
● If a non-Huawei device runs the standard STP or RSTP protocol, the switch
can interwork with it.
● If a non-Huawei device runs a non-standard STP or RSTP protocol, besides the
Cisco Per VLAN Spanning Tree (PVST) protocol, the switch can transparently
transmit the STP or RSTP packets from the device after the stp disable and
bpdu enable commands are run on the interface.
● If a non-Huawei device is a Cisco device that runs PVST, the Huawei switch
running a version earlier than V200R005 cannot negotiate with the device,
but can transparently transmit the packets from the non-Huawei device.
Huawei switches running V200R005 and later versions support the VLAN-
based Spanning Tree (VBST) protocol that can interwork with PVST.

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 739


S12700 Series Agile Switches
Configuration Guide - Ethernet Switching 14 STP/RSTP Configuration

14.14.9 What Is the Function of Automatic Edge-port


Detecting?
After STP is enabled on a port, edge-port detecting is started automatically. If the
port fails to receive BPDU packets within (2 x Hello Time + 1) seconds, the port is
set to an edge port. Otherwise, the port is set to a non-edge port. If the stp
edged-port enable or stp edged-port disable command is executed in the
interface view or the stp edged-port default command is configured in the
system view, automatic detection of the edge port becomes invalid.

Issue 15 (2021-09-17) Copyright © Huawei Technologies Co., Ltd. 740

You might also like