01-14 STP RSTP Configuration
01-14 STP RSTP Configuration
14 STP/RSTP Configuration
This chapter describes how to configure the Spanning Tree Protocol (STP) and
Rapid Spanning Tree Protocol (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.
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.
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.
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
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
● 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.
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.
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}.
Field Description
Field Description
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.
S1 S2
A B
designated port
blocked port
Port States
Table 14-3 describes the possible states of ports on an STP device.
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.
①
⑤
Blocking
②
④ ⑤
Listening
③
④ ⑤
Learning
③
④ ⑤
Forwarding
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.
Forwardi A port in Forwarding state can forward user traffic and process
ng BPDUs.
Port Description
State
The following parameters affect the STP port states and convergence.
● Hello Time
The Hello Time specifies the interval at which an STP device sends
configuration BPDU packets to detect link failures.
When the Hello Time is changed, the new value takes effect only after a new
root bridge is elected. The new root bridge includes the new Hello Time value
in BPDUs it sends to non-root bridges. If the network topology changes, TCN
BPDUs are immediately transmitted regardless of the Hello Time.
● Forward Delay
The Forward Delay timer specifies the length of delay before a port state
transition.
When a link fails, STP calculation is triggered and the spanning tree structure
changes. However, new configuration BPDUs cannot be immediately spread
over the entire network. If the new root port and designated port forward
data immediately, transient loops may occur. Therefore, STP defines a port
state transition delay mechanism. The newly selected root port and
designated port must wait for two Forward Delay intervals before
transitioning to the Forwarding state. During this period, the new
configuration BPDUs can be transmitted over the network, preventing
transient loops.
The default Forward Delay timer value is 15 seconds. This means that the port
stays in Listening state for 15 seconds and then stays in Learning state for
another 15 seconds before transitioning to the Forwarding state. The port is
blocked when it is in Listening or Learning state, effectively preventing
transient loops.
● Max Age
The Max Age specifies the aging time of BPDUs. This parameter is
configurable on the root bridge.
The Max Age is spread to the entire network with configuration BPDUs. After
a non-root bridge receives a configuration BPDU, it compares the Message
Age value with the Max Age value in the received configuration BPDU.
– If the Message Age value is smaller than or equal to the Max Age value,
the non-root bridge forwards the configuration BPDU.
– If the Message Age value is greater than the Max Age value, the non-root
bridge discards the configuration BPDU. When this happens, the network
size is considered too large and the non-root bridge disconnects from the
root bridge.
If the configuration BPDU is sent from the root bridge, the Message Age value
is 0. Otherwise, the Message Age value is the total time spent to transmit the
BPDU from the root bridge to the local bridge, including the transmission
delay. The Message Age value of a configuration BPDU increases by 1 each
time the configuration BPDU passes through a bridge.
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.
BPDU Type 1 Indicates the type of a BPDU. The value is one of the
following:
● 0x00: configuration BPDU
● 0x80: TCN BPDU
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.
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.
Figure 14-7 shows the Flags field. Only the leftmost and rightmost bits are used
in STP.
Bit7 Bit0
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.
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.
A B
S1 {S2_MAC,0,S2_MAC,B_PID} S2
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.
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.
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}.
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.
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.
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.
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.
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
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.
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:
Table 14-11 Comparison between port states defined in STP and RSTP
STP Port State RSTP Port State Port Role
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.
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.
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.
p0 1 Proposal
3 Agreement
p1
S2
p2 E p4
p3
Designated port
Alternate port
E Edge port
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.
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.
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.
Network
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.
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.
Licensing Requirements
STP or RSTP is a basic feature of a switch and is not under license control.
Version Requirements
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.
Procedure
Step 1 Run:
system-view
----End
● 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
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
Step 2 Run:
stp priority priority
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
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
10 Gbit/s 2 2 to 20 1 to 200000
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
----End
Procedure
Step 1 Run:
system-view
Step 3 Run:
stp port priority priority
----End
NOTICE
Procedure
Step 1 Run:
system-view
----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
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.
Pre-configuration Tasks
Before setting STP parameters that affect STP convergence, configure basic STP
functions.
Procedure
Step 1 Run:
system-view
Step 2 Run:
stp bridge-diameter diameter
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
Procedure
Step 1 Run:
system-view
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
● 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
----End
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
----End
Pre-configuration Tasks
Before setting RSTP parameters that affect RSTP convergence, configure basic
RSTP functions.
It is recommended that all devices be configured with the same network diameter.
Procedure
Step 1 Run:
system-view
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
Procedure
Step 1 Run:
system-view
The Timer Factor value is set. This parameter determines the timeout interval
during which the device waits for BPDUs from the upstream device.
----End
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
----End
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
Step 2 Run:
interface eth-trunk trunk-id
Step 3 Run:
max bandwidth-affected-linknumber link-number
----End
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.
Procedure
Step 1 Run:
system-view
Step 2 Run:
interface interface-type interface-number
Step 3 Run:
stp point-to-point { auto | force-false | force-true }
----End
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
Step 2 Run:
interface interface-type interface-number
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.
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
Context
If an interface on an RSTP-enabled device is connected to an STP-enabled device,
the interface switches to the STP compatible mode.
You need to manually switch the interface to the RSTP mode in the following
situations:
Procedure
● Switching to the RSTP mode in the interface view
a. Run:
system-view
----End
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
----End
Procedure
● Run the display stp [ interface interface-type interface-number | slot slot-id ]
[ brief ] command to view the spanning tree status and statistics.
----End
Procedure
Step 1 Run:
system-view
Step 2 Run:
stp bpdu-protection
----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.
● 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.
Procedure
Step 1 Run:
system-view
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
----End
Procedure
Step 1 Run:
system-view
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
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.
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
----End
NOTICE
STP/RSTP statistics cannot be restored after being cleared. Exercise caution when
deciding to clear STP/RSTP statistics.
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
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
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.
Network
GE1/0/3 GE1/0/3
Root
SwitchD GE1/0/1 GE1/0/1
Bridge
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
<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.
----End
Configuration Files
● SwitchA configuration file
#
sysname SwitchA
#
stp mode stp
stp instance 0 root primary
Related Content
Videos
Configuring STP to Prevent Loops
Network
GE1/0/3 GE1/0/3
Root
SwitchD GE1/0/1 GE1/0/1
Bridge
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
<HUAWEI> system-view
[HUAWEI] sysname SwitchB
[SwitchB] stp mode rstp
# On SwitchD, set the path cost calculation method to the Huawei proprietary
method.
[SwitchD] stp pathcost-standard legacy
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
----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
Related Content
Videos
14.14 FAQ
● 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.
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.
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.
NOTE
When a port whose mode switches reconnects to another device, the original mode must
be restored by running the stp mcheck command.
● 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.