And Configuration
And Configuration
and Configuration
Contents
1 STP Overview
5 STP Advancement
Page 3 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Technical Background:
Redundancy and Loops on a Layer 2 Switching Network
A network without redundancy design Layer 2 loops introduced along with redundancy
Page 4 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Technical Background:
Layer 2 Loops Caused by Human Errors
Case 1 Case 2
Layer 2 SW1
loop
Layer 2
loop
SW2
Page 5 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Issues Caused by Layer 2 Loops
3 GE0/0/2
SW1 SW2 SW1 SW2
3
4 4
2 2
SW3 SW3
Page 6 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Introduction to STP
STP STP
Port SW3
BPDUs blocked
SW3
STP
When STP is deployed on a network, switches exchange STP BPDUs and calculate a loop-free topology. Finally,
one or more ports on the network are blocked to eliminate loops.
Page 7 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
STP Can Dynamically Respond to Network Topology Changes
and Adjust Blocked Ports
2
链路故障
1 3
Blocked Restored
port port
SW3 SW3
STP running on a switch continuously monitors the network topology. When the network topology changes,
STP can detect the changes and automatically adjust the network topology.
Therefore, STP can solve the Layer 2 loop problem and provide a solution for network redundancy.
Page 8 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Q&A: Layer 2 and Layer 3 loops
Layer 3 loop Layer 2 loop
Page 9 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Application of STP on a Campus Network
Internet
Layer 3 network
Layer 2 network
Running environment of STP
…… …… ……
Page 10 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
STP Overview
• Devices running STP exchange information with one another to discover loops on the
network, and block certain ports to eliminate loops.
• After running on a network, STP continuously monitors the network status. When the
network topology changes, STP can detect the change and automatically respond to the
change. In this way, the network status can adapt to the new topology, ensuring network
reliability.
Page 11 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Contents
1 STP Overview
5 STP Advancement
Page 12 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
STP Basic Concepts: BID
路由器
4096.4c1f-aabc-102a 4096.4c1f-aabc-102b
SW1 SW2 Bridge ID (BID)
• As defined in IEEE 802.1D, a BID consists of a 16-bit
bridge priority and a bridge MAC address.
• Each switch running STP has a unique BID.
• The bridge priority occupies the leftmost 16 bits and the
MAC address occupies the rightmost 48 bits.
• On an STP network, the device with the smallest BID acts
SW3 as the root bridge.
4096.4c1f-aabc-102c
Note: A bridge is a switch.
Page 13 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
STP Basic Concepts: Root Bridge
Root Bridge
• One of the main functions of STP is to calculate a loop-free STP
4096.4c1f-aabc-102a 4096.4c1f-aabc-102b
tree on the entire switching network.
SW1 SW2 • The root bridge is the root of an STP network.
• After STP starts to work, it elects a root bridge on the switching
Root bridge
network. The root bridge is the key for topology calculation of
the spanning tree and is the root of the loop-free topology
calculated by STP.
• On an STP network, the device with the smallest BID acts as the
root bridge.
During BID comparison, devices first compare bridge priorities. A
SW3 smaller priority value indicates a higher priority of a device. The
switch with the smallest priority value becomes the root bridge.
4096.4c1f-aabc-102c
If priority values are the same, the switch with the smallest MAC
address becomes the root bridge.
Page 14 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
STP Basic Concepts: Cost
Cost=500 Cost
SW1 SW2
Cost=500
Cost=20000 Cost=20000 • Each STP-enabled port maintains a cost. The cost of a
port is used to calculate the root path cost (RPC), that is,
the cost of the path to the root.
• The default cost of a port is related to the rate, working
mode, and STP cost calculation method used by a switch.
Cost=20000 Cost=20000 • A higher port bandwidth indicates a smaller cost.
• You can also run commands to adjust the cost of a port
SW3 as required.
Page 15 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
STP Basic Concepts: Cost Calculation Methods
Page 16 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
STP Basic Concepts: RPC
RPC=500+20000
Root bridge
Cost=500 Cost=500 RPC
SW1 1 SW2
Cost=20000 • The RPC from a port to the root bridge is the sum of
Cost=20000
costs of all inbound ports along the path from the root
bridge to the device.
Cost=20000 2 Cost=20000
SW3
Page 17 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
STP Basic Concepts: PID
PID=128.24 PID=128.24
SW1 SW2 Port ID (PID)
PID=128.23 PID=128.23 • A PID consists of the leftmost four bits (port priority)
and the rightmost 12 bits (port number).
SW3
Page 18 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
STP Basic Concepts: BPDU
Page 19 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Format of Configuration BPDUs
BPDU Message Hello Forward
PID PVI Flags Root ID RPC Bridge ID Port ID Max Age
Type Age Time Delay
Page 21 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Configuration BPDU Forwarding Process
Page 22 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Contents
1 STP Overview
5 STP Advancement
Page 23 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
STP Calculation (1)
Page 24 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
STP Calculation (2)
4096.4c1f-aabc-102a 4096.4c1f-aabc-102b
Select a Root Port on Each Non-root Bridge
SW1 R SW2
• Each non-root bridge selects a root port from its ports.
Configuration
R Root port
BPDU
Page 25 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
STP Calculation (3)
4096.4c1f-aabc-102a 4096.4c1f-aabc-102b
A designated port is elected on each link.
SW1 D R SW2
D D • After the root port is elected, the non-root bridge uses
the optimal BPDU received on the port to calculate the
configuration BPDU and compares the calculated
configuration BPDU with the configuration BPDUs
received by all ports except the root port.
➢ If the former is better, the port is a designated port.
R
4096.4c1f-aabc-102c ➢ If the latter is better, the port is not a designated port.
SW3 • In most cases, all ports on the root bridge are designated
ports.
Configuration R Root port D Designated
BPDU port
Page 27 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
STP Calculation (4)
SW3
Page 28 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
STP Port States
Port State Description
The port cannot send or receive BPDUs or service data frames. That is, the port is
Disabled
Down.
The port is blocked by STP. A blocked port cannot send BPDUs but listens to BPDUs.
Blocking In addition, the blocked port cannot send or receive service data frames or learn
MAC addresses.
STP considers the port in Listening state as the root port or designated port, but the
Listening port is still in the STP calculation process. In this case, the port can send and receive
BPDUs but cannot send or receive service data frames or learn MAC addresses.
A port in Learning state listens to service data frames but cannot forward them.
Learning
After receiving service data frames, the port learns MAC addresses.
A port in Forwarding state can send and receive service data frames and process
Forwarding
BPDUs. Only the root port or designated port can enter the Forwarding state.
Page 32 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
STP Port State Transition
Disabled or Down
1 1
When a port is initialized or activated, it automatically
5 enters the blocking state.
Blocking
5 2 The port is elected as the root port or designated port
2 and automatically enters the Listening state.
4 Listening
5 3 The Forward Delay timer expires and the port is still
3 the root port or designated port.
Page 33 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Contents
1 STP Overview
5 STP Advancement
Page 34 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Topology Change: Root Bridge Fault
Page 35 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Topology Change: Direct Link Fault
4096.4c1f-aabc-102a 4096.4c1f-aabc-102b
Direct Link Fault Rectification Process
SW1 SW2
A
On a stable network, when SW2 detects that the link of
the root port is faulty, the alternate port of SW2 enters the
Forwarding state after twice the value of the Forward
Delay timer (the default value is 15s).
• After SW2 detects a fault on the direct link, it switches
A the alternate port to the root port.
• If a direct link fails, the alternate port restores to the
SW3 Forwarding state after 30s.
4096.4c1f-aabc-102c
Page 36 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Topology Change: Indirect Link Fault
• When the indirect link fails, the alternate port on SW3 restores to the Forwarding
state. It takes about 50s to recover from an indirect link failure.
A R
SW3 SW3
4096.4c1f-aabc-102c 4096.4c1f-aabc-102c
Page 37 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
The MAC Address Table Is Incorrect Because the Topology Changes
SW1
MAC address table
GE0/0/1 GE0/0/2
MAC Port
00-05-06-07-08-AA GE0/0/1
00-05-06-07-08-BB GE0/0/3
Page 38 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
The MAC Address Table Is Incorrect Because the Topology Changes
SW1
MAC address table
00-05-06-07-08-AA GE0/0/3
00-05-06-07-08-BB GE0/0/1
00-05-06-07-08-BB GE0/0/2
1 .TCN
GE0/0/3 GE0/0/1
SW2 A SW3
• TCN BPDUs are generated when the network GE0/0/2 GE0/0/2
topology changes. 2 .TCA
GE0/0/1 GE0/0/3
• Packet format: protocol identifier, version 5 .TC
number, and type
• Topology change: The TCA and TC bits in the Host A Host B
Flags field of configuration BPDUs are used. 00-05-06-07-08-AA 00-05-06-07-08-BB
Page 39 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Contents
1 STP Overview
5 STP Advancement
Page 40 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Basic STP Configuration Commands (1)
1. Configure a working mode.
The switch supports three working modes: STP, RSTP, and Multiple Spanning Tree Protocol (MSTP). By default,
a switch works in MSTP mode.
2. (Optional) Configure the root bridge.
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.
Page 41 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Basic STP Configuration Commands (2)
1. (Optional) Configure the STP priority of a switch.
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.
Page 42 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Basic STP Configuration Commands (3)
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.
Page 43 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Case 1: Basic STP Configurations
SW1 configuration:
GE0/0/24 GE0/0/24
SW1 SW2
[SW1] stp mode stp
[SW1] stp enable
[SW1] stp priority 0
SW2 configuration:
• Deploy STP on the three switches to eliminate Layer 2 loops SW3 configuration:
on the network.
[SW3] stp mode stp
• Configure SW1 as the root bridge and block GE0/0/22 on SW3.
[SW3] stp enable
Page 44 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Case 1: Basic STP Configurations
Page 45 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Contents
1 STP Overview
5 STP Advancement
Page 46 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Disadvantages of STP
• STP ensures a loop-free network but is slow to converge, leading to service quality deterioration. If the network
topology changes frequently, connections on the STP network are frequently torn down, causing frequent service
interruption.
• STP does not differentiate between port roles according to their states, making it difficult for less experienced
administrators to learn about and deploy this protocol.
▫ Ports in Listening, Learning, and Blocking states are the same for users because none of these ports forwards service traffic.
▫ In terms of port use and configuration, the essential differences between ports lie in the port roles but not port states.
▫ Both root and designated ports can be in Listening state or Forwarding state, so the port roles cannot be differentiated
according to their states.
• The STP algorithm does not determine topology changes until the timer expires, delaying network convergence.
• The STP algorithm requires the root bridge to send configuration BPDUs after the network topology becomes
stable, and other devices process and spread the configuration BPDUs through the entire network. This also delays
convergence.
Page 47 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
RSTP Overview
• RSTP defined in IEEE 802.1w is an enhancement to STP. RSTP optimizes STP in many aspects,
provides faster convergence, and is compatible with STP.
• RSTP introduces new port roles. When the root port fails, the switch can enable the
alternate port to obtain an alternate path from the designated bridge to the root bridge.
RSTP defines three states for a port based on whether the port forwards user traffic and
learns MAC addresses. In addition, RSTP introduces the edge port. The port connecting a
switch to a terminal is configured as an edge port that enters the Forwarding state
immediately after initialization, thus improving the working efficiency.
Page 48 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Improvements Made in RSTP
• RSTP changes the configuration BPDU format and uses the Flags field to describe
port roles.
Page 49 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Port Roles in RSTP
• RSTP adds port roles to help understand RSTP and simplify RSTP deployment.
D D D D
R R R R
SW2 SW3 SW2 SW3
D A D B A
Page 50 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Edge Port
• An edge port is located at the edge of a region and does not connect to any switching device.
D D
R R E
SW2
SW3
Generally, an edge port is directly connected to a user terminal. The edge port can transition from the Disabled
state to the Forwarding state.
Page 51 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Port States in RSTP
• RSTP deletes two port states defined in STP, reducing the number of port states to three.
Page 52 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Contents
1 STP Overview
5 STP Advancement
Page 53 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Defects of STP/RSTP: All VLANs Share One Spanning Tree
SW1 SW2
Blocked port
VLAN1、2、3、…
Page 54 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
VBST
SW1 SW2
Page 55 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
MSTP
SW1 SW2
Page 56 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
MSTP Overview
• MSTP divides a switching network into multiple regions, each of which has multiple spanning
trees that are independent of each other.
• Binding multiple VLANs to a single MSTI reduces communication costs and resource usage.
• The topology of each MSTI is calculated independently, and traffic can be balanced among
MSTIs.
• 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.
Page 57 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Stack and Tree Networking of Campus Networks
Traditional STP Networking iStack Networking
STP blocks ports on the network, causing a failure to Aggregation switches are stacked to form a single logical
device, simplifying the network topology. In addition, link
fully utilize link bandwidth. aggregation is deployed between aggregation switches
and access switches to simplify the network topology to a
tree topology, eliminating Layer 2 loops and improving
link bandwidth utilization.
Page 58 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Smart Link
FW1 FW2 ⚫ Smart Link is tailored for dual-uplink networking.
⚫ Smart Link is deployed on two switches where a host is
dual-homed. When the network is normal, one of the two
uplinks is active, and the other is in standby state (does
SW1 SW2
NO STP not carry service traffic). In this way, a Layer 2 loop is
eliminated.
⚫ When the active link is faulty, traffic is switched to the
Port1 Port2
Master Port Slave Port standby link in milliseconds. This ensures proper data
forwarding.
SW3
⚫ Smart Link is easy to configure.
⚫ Smart Link does not involve protocol packet exchange,
therefore greatly improving speed and reliability.
Smart Link Group Active Status
Page 59 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
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.
Page 61 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.