06 STP Principles and Configuration
06 STP Principles and Configuration
Configuration
and other Huawei trademarks are trademarks of Huawei Technologies Co., Ltd.
All other trademarks and trade names mentioned in this document are the property of their
respective holders.
Notice
The purchased products, services and features are stipulated by the contract made
between Huawei and the customer. All or part of the products, services and features
described in this document may not be within the purchase scope or the usage scope.
Unless otherwise specified in the contract, all statements, information, and
recommendations in this document are provided "AS IS" without warranties, guarantees or
representations of any kind, either express or implied.
The information in this document is subject to change without notice. Every effort has been
made in the preparation of this document to ensure accuracy of the contents, but all
statements, information, and recommendations in this document do not constitute a
warranty of any kind, express or implied.
Website: https://e.huawei.com/
Huawei Certification System
Huawei Certification follows the "platform + ecosystem" development strategy,
which is a new collaborative architecture of ICT infrastructure based on "Cloud-
Pipe-Terminal". Huawei has set up a complete certification system consisting of
three categories: ICT infrastructure certification, platform and service
certification, and ICT vertical certification. It is the only certification system that
covers all ICT technical fields in the industry. Huawei offers three levels of
certification: Huawei Certified ICT Associate (HCIA), Huawei Certified ICT
Professional (HCIP), and Huawei Certified ICT Expert (HCIE). Huawei
Certification covers all ICT fields and adapts to the industry trend of ICT
convergence. With its leading talent development system and certification
standards, it is committed to fostering new ICT talent in the digital era, and
building a sound ICT talent ecosystem.
Huawei Certified ICT Associate-Datacom (HCIA-Datacom) is designed for
Huawei's frontline engineers and anyone who want to understand Huawei's
datacom products and technologies. The HCIA-Datacom certification covers
routing and switching principles, basic WLAN principles, network security
basics, network management and O&M basics, SDN and programmability and
automation basics.
The Huawei certification system introduces the industry, fosters innovation,
and imparts cutting-edge datacom knowledge.
Contents
1.1 Foreword
On an Ethernet switching network, redundant links are used to implement link
backup and enhance network reliability. However, the use of redundant links
may produce loops, leading to broadcast storms and an unstable MAC address
table. As a result, communication on the network may deteriorate or even be
interrupted. To prevent loops, IEEE introduced the Spanning Tree Protocol (STP).
Devices running STP exchange STP Bridge Protocol Data Units (BPDUs) to
discover loops on the network and block appropriate ports. This enables a ring
topology to be trimmed into a loop-free tree topology, preventing infinite looping
of packets and ensuring packet processing capabilities of devices.
IEEE introduced the Rapid Spanning Tree Protocol (RSTP) to improve the network
convergence speed.
1.2 Objectives
On completion of this course, you will be able to:
Describe the causes and problems of Layer 2 loops on a campus switching
network.
Describe basic concepts and working mechanism of STP.
Distinguish STP from RSTP and describe the improvement of RSTP on STP.
Complete basic STP configurations.
Understand other methods to eliminate Layer 2 loops on the switching
network except STP.
STP Principles and Configuration Page 2
With the growth in scale of LANs, STP has become an important protocol for a
LAN.
Full-duplex 4 20,000 20
1000 Mbit/s Aggregated
3 10,000 18
link: two ports
Full-duplex 2 2000 2
10 Gbit/s Aggregated
1 1000 1
link: two ports
Full-duplex 1 500 1
40 Gbit/s Aggregated
1 250 1
link: two ports
Full-duplex 1 200 1
100 Gbit/s Aggregated
1 100 1
link: two ports
The cost has a default value and is associated with the port rate. When the
device uses different algorithms, the same port rate corresponds to different cost
values.
5、RPC
STP Principles and Configuration Page 10
Each port on an STP-enabled switch has a port ID, which consists of the port
priority and port number. The value of the port priority ranges from 0 to 240,
with an increment of 16. That is, the value must be an integer multiple of 16. By
default, the port priority is 128. The PID is used to determine the port role.
7、BPDU
STP uses only the leftmost two bits and the rightmost two
1 Flags bits: Topology Change Acknowledgment (TCA) and
Topology Change (TC).
STP cost of the path from the current port to the root
4 RPC
bridge.
Protocol Identifier
BPDU Type
Flags
Root Identifier
Bridge Identifier
Port Identifier
Message Age
Max Age
Hello Time
Forward Delay
The last step of STP operations is to block the non-designated port on the
network. After this step is complete, the Layer 2 loop on the network is
eliminated.
What is a non-designated port (alternate port)?
After the root port and designated port are determined, all the remaining
non-root ports and non-designated ports on the switch are called alternate
ports.
Blocking alternate ports
STP logically blocks the alternate ports. That is, the ports cannot forward the
frames (user data frames) generated and sent by terminal computers.
Once the alternate port is logically blocked, the STP tree (loop-free topology)
is generated.
Note:
The blocked port can receive and process BPDUs.
The root port and designated port can receive and send BPDUs and forward
user data frames.
1.4.7 Quiz 2: Identify the Root Bridge and Port Roles in the
Following Topology
1.4.8 Quiz 3: Identify the Root Bridge and Port Roles in the
Following Topology
The figure shows the STP port state transition. The STP-enabled device has the
following five port states:
Forwarding: A port can forward user traffic and BPDUs. Only the root port or
designated port can enter the Forwarding state.
Learning: When a port is in Learning state, a device creates MAC address entries
based on user traffic received on the port but does not forward user traffic
through the port. The Learning state is added to prevent temporary loops.
Listening: A port in Listening state can forward BPDUs, but cannot forward user
traffic.
Blocking: A port in Blocking state can only receive and process BPDUs, but
cannot forward BPDUs or user traffic. The alternate port is in Blocking state.
Disabled: A port in Disabled state does not forward BPDUs or user traffic.
BPDUs becomes invalid. In this case, the non-root bridges send configuration
BPDUs to each other to elect a new root bridge.
Port state:
The alternate port of SW3 enters the Listening state from the Blocking state
after 20s and then enters the Learning state. Finally, the port enters the
Forwarding state to forward user traffic.
Convergence time:
It takes about 50s to recover from a root bridge failure, which is equal to the
value of the Max Age timer plus twice the value of the Forward Delay timer.
2、Direct Link Fault
The switch supports three working modes: STP, RSTP, and Multiple Spanning
Tree Protocol (MSTP). By default, a switch works in MSTP mode. On a ring
network running only STP, the working mode of a switch is configured as STP; on
a ring network running RSTP, the working mode of a switch is configured as
RSTP.
Configure the switch as the root bridge. By default, a switch does not function as
the root bridge of any spanning tree. After you run this command, the priority
value of the switch is set to 0 and cannot be changed.
Configure the switch as the secondary root bridge. By default, a switch does not
function as the secondary root bridge of any spanning tree. After you run this
command, the priority value of the switch is set to 4096 and cannot be changed.
STP Principles and Configuration Page 26
Configure a path cost calculation method. By default, the IEEE 802.1t standard
(dot1t) is used to calculate path costs.
All switches on a network must use the same path cost calculation method.
Configure a priority for a port. By default, the priority of a switch port is 128.
Enable STP, RSTP, or MSTP on a switch. By default, STP, RSTP, or MSTP is enabled
on a switch.
SW2 configuration:
STP Principles and Configuration Page 27
SW3 configuration:
RSTP is evolved from STP and has the same working mechanism as STP. When
the topology of a switching network changes, RSTP can use the
Proposal/Agreement mechanism to quickly restore network connectivity.
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.
RSTP is backward compatible with STP, which is not recommended because STP
slow convergence is exposed.
Improvements made in RSTP:
RSTP processes configuration BPDUs differently from STP.
When the topology becomes stable, the mode of sending configuration
BPDUs is optimized.
RSTP uses a shorter timeout interval of BPDUs.
RSTP optimizes the method of processing inferior BPDUs.
RSTP changes the configuration BPDU format and uses the Flags field to
describe port roles.
RSTP topology change processing: Compared with STP, RSTP is optimized to
accelerate the response to topology changes.
1.7.2 VBST
Huawei provides the VLAN-based Spanning Tree (VBST). VBST constructs a
spanning tree in each VLAN so that traffic from different VLANs is load balanced
along different spanning trees.
STP Principles and Configuration Page 31
1.7.3 MSTP
To fix the defects, the IEEE released the 802.1s standard that defines the
Multiple Spanning Tree Protocol (MSTP) in 2002.
MSTP is compatible with STP and RSTP, and can rapidly converge traffic and
provides multiple paths to load balance VLAN traffic.
Multiple VLANs with the same topology can be mapped to a single MSTI. The
forwarding state of the VLANs for an interface is determined by the interface
state in the MSTI.
1.8 Quiz
1. (Single)Which statement about the STP port state is false? ( )
A. The blocked port does not listen to or send BPDUs.
B. A port in learning state learns MAC addresses but does not forward data.
C. A port in Listening state keeps listening to BPDUs.
D. If a blocked port does not receive BPDUs within a specified period, the port
automatically switches to the Listening state.
2. (Single)What port states does a standard spanning tree have? ( )
A. 3
B. 4
STP Principles and Configuration Page 34
C. 5
D. 6
3. (Single)Which of the following statements about STP are correct? ( )
A. The root bridge does not have a designated port.
B. The root bridge does not have a root port.
C. A non-root bridge may have one root port and multiple designated ports.
D. A non-root bridge may have multiple root ports and a designated port.
4. (Multiple)Which of the following statements about STP are correct? ( )
A. Two different switches cannot have the same priority.
B. The smaller the bridge ID of a switch, the more likely it is to become the
root bridge.
C. The PID value does not affect the election result of the root bridge.
D. The priority of the bridge ID ranges from 0 to 65535.
5. (True or False)In STP, the default Hello Time of BPDUs is set to 1s. ( )
A. True
B. False
6. (True or False)The blocked port on the STP can learn the MAC address of user
traffic but cannot forward user traffic. ( )
A. True
B. False
1.9 Summary
STP prevents loops on a LAN. Devices running STP exchange information with
one another to discover loops on the network, and block certain ports to
eliminate loops. With the growth in scale of LANs, STP has become an important
protocol for a LAN.
After STP 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.
STP cannot meet requirements of modern campus networks. However,
understanding the working mechanism of STP helps you better understand the
working mechanism and deployment of RSTP and MSTP.