06 Switching+Basics+-+STP+Principles
06 Switching+Basics+-+STP+Principles
Faulty points
SW1
SW2
SW1 SW2
Loop
SW3
• Redundancy topology prevents a single point of failure, but results in a Layer 2 loop.
• Layer 2 loops also occur on the live network due to negligence.
• Layer 2 loops are harmful to the network.
Loop-induced Problem - Broadcast Storms
SW1 SW2
Broadcast
SW3
SW3 PC
SW1 SW2
STP blocked
SW3
SW1 SW2
STP unblocked
SW3
When the network topology changes, STP can automatic converge and adjust the port
status, so as to ensure that the network redundancy.
STP Operations
Root
Port1 Port1
SW1 100BASE-T
SW2
Po r t2
10
rt2 -T
Po
BA
E
AS
SE
B
10
-T
Po r t2
Root port
rt
1 Po
STP blocked
Designated port
SW3
BPDUs
BPDU
Port1 Port1
SW1 SW2
Po t2
rt2 r
Po
BP
U
DU Po 2
PD
rt ort
B
1 P
SW3
BPDUs
Byte Field Description
2 Protocol An upper-layer protocol. The value is fixed at 0.
1 Version The value is fixed at 0 for 802.1D.
BPDU type:
1 Type • 0: configuration BPDUs
• 80: topology change notification (TCN) BPDUs
• Least-significant valid bit: topology change (TC) flag
1 Flags
• Most-significant valid bit: topology change acknowledgment (TCA) flag
8 Root ID Bridge ID of a root bridge.
4 Path cost STP cost of a path to a root bridge.
8 Bridge ID ID of the BPDU sending bridge
2 Port ID Port ID (in the format of priority + port number) of a bridge sending BPDUs
Number of seconds elapsed since a BPDU is sent. The value decreases by 1 at each
2 Message age
bridge. The value is equal to the number of hops on a path to a root bridge.
If a bridge does not receive any BPDU and the Max age time elapses, the bridge
2 Max age
considers the link connected to the port faulty. The default value is 20s.
2 Hello time Interval at which a root bridge sends BPDUs. The default value is 2s.
2 Forwarding delay Period of time elapsed in the Listening and Learning states. The default value is 15s.
Key Configuration BPDU Parameters
Field Description
Sequence in comparison: Root Identifier > Root Path Cost > Bridge Identifier > Port Identifier
A smaller value indicates a higher priority.
Bridge ID
• A bridge ID is 8 bytes long. It consists of a 2-byte priority field and a 6-byte MAC
address field.
• The default bridge priority is 32768. The bridge priority can be manually modified.
• The MAC address is the backplane's MAC address on the switch.
• A switch with the smallest bridge ID on the network becomes the root bridge.
Bridge ID
2 bytes 6 bytes
Path Cost
• The path cost is set on a port and used by STP or Rapid Spanning Tree Protocol (RSTP) to
select links.
• The default path cost and value range are determined by a selected path cost algorithm. The
path cost is inversely proportional to the port bandwidth.
• Huawei network devices calculate the path cost in compliance with 802.1d-1998, 802.1t, or
Huawei-proprietary legacy standard.Huawei switches conforms to 802.1t by default.
Bandwidth 802.1t
10 Mbps 2,000,000
100 Mbps 200,000
1000 Mbps 20,000
10,000 Mbps 2,000
Path Cost
Port ID
1 bytes 1 bytes
STP Operations
10
E
BA
A S
SE
B
10 U
-T
PD
BP
Po 2
rt B
DU
rt o
1 P
Priority 32768
MAC 0c00.000a.0003
SW3
STP Operations
Root
10
E
BA
AS
SE
B
Po 10
-T
rt1 2
ort
Root port P
Designated port
SW3
STP Operations
Root
Port1 100BASE-T Port1
SW1 SW2
Po
rt
2 r t2
-T Po
10
E
BA
AS
SE
B
10
-T
Po
rt1 r t2
Root port Po
Designated port
SW3
STP Operations
10
E
BA
AS
SE
B
10
-T
Po t2
rt r
Root port
1 Po
STP blocked
Designated port
SW3
STP Port Status
A port in the Disabled state does not forward BPDUs or user traffic. The
Disable
port is Down.
• A port in Blocking state receives and processes BPDUs, but does not
forward user traffic or learn MAC addresses.
Blocking
• If the default Max age (20s) timer expires and the port does not
receive any BPDU, the port switches to the Listening state.
The port in the Listening state receives and sends BPDUs, but does not
Listening receive or forward user traffic or learn MAC addresses.
Port roles are determined, and election is to be performed.
The port in the Learning state receives and sends BPDUs and learns
Learning
MAC addresses, but does not receive or forward user traffic.
The port in the Forwarding state receives and forwards frames, receives
Forwarding
and sends BPDUs, and learns MAC addresses.
STP Topology Change Mechanism
Root
TCN BPDU 3
4 TCN ACK
Switch C
2 TCN BPDU
3
TCN ACK
1
Detects a link fault
Switch B
Switch A
STP Topology Change Mechanism
TCN BPDU 5 5
5 5
5
STP Topology Change Mechanism
Root
6 6 6
CAM entry lifetime = 15s CAM entry lifetime = 15s CAM entry lifetime = 15s
Basic STP Configuration
• A spanning tree protocol is specified. The value can be STP, RSTP, or MSTP.
[SW] stp mode { stp | rstp | mstp } # The default setting is MSTP.
• Set a switch priority.
[SW] stp priority pri # The default value is 32768.
• Configure the switch as the root bridge.
[SW] stp root primary
• Configure the switch as the secondary root bridge.
[SW] stp root secondary
• Enable the spanning tree.
[SW] stp enable
• Set a port STP priority.
[SW] port GigabitEthernet0/0/24
[SW-GigabitEthernet0/0/24] stp priority priority
• Set the path cost on the port.
[SW] port GigabitEthernet0/0/24
[SW-GigabitEthernet0/0/24] stp cost cost
Question 1: Does a Spanning Tree Protocol Need to Be Activated?
VLAN10
VLAN10
VLAN20
Loop Loop
Figure 1 Figure 2
Problem 3: Does a Loop Occur in the Following Environment?
A B
VLAN 30 SW2
SW1
B A
VLAN10
VLAN20
A B
SW3 SW4
B VLAN 40 A
No
Loop
Figure 3
STP Drawbacks
SW1 Da SW2
t a
of
all
V LA After SW3's upstream port on the right is
Ns blocked by STP, traffic of all VLANs has to
STP Blocked travel through the left link. The link on the
right of SW3 carries no traffic. This is
because all VLANs share the same
SW3 spanning tree.
VLANs 10, 20, 30, 40 …
Optimization Solution
SW1 SW2
Per-VLAN STP
SW1 VL SW2
AN Data of 0
…
s 1 of a ta 0, 4
0, D 2
30 Ns A better method is to map a VLAN to a
… LA
V spanning tree instance to allow several
Instance 2 Instance 1 VLANs to share a spanning tree. This
blocked blocked method tackles the two problems.
SW3
VLANs 10, 20, 30, 40 …
MSTP
• MSTP is compatible with STP and RSTP. MSTP uses multiple instances to isolate service
traffic and user traffic and provides multiple redundant paths for data forwarding and VLAN
data load balancing.
• In MSTP, several VLANs are mapped to an instance. MSTP runs a spanning tree for each
instance. The parameters, such as priorities and path costs can be set in each instance.
MSTP Configuration Example
SW1 SW2
Primary root of instance 1 Secondary root of instance 1
GE0/0/24 GE0/0/24
Secondary root of instance 2 primary root of instance 2
G 2 2
E0 0/
/ /
0/
21 E0
G
G 2 2
E0 0/
/ /
0/
21 E0
G
Instance 2 blocked
SW3
Instance 1 bocked VLANs 10, 20, 30, 40
Instance 1 vlan 10 20
Instance 2 vlan 30 40
MSTP Configuration Example: SW1
[SW1] stp mode mstp # Set the spanning tree protocol to MSTP.
[SW1-mst-region] quit
MSTP Configuration Example: SW1
# Set the priority of each instance and configure SW1 as the primary root bridge of instance 1 and the
secondary root bridge of instance 2.
[SW1] stp instance 1 root primary # Or, run: stp instance 1 priority 0
[SW1] stp instance 2 root secondary # Or, run: stp instance 2 priority 4096
[SW1] stp enable # Enable STP.
#
[SW1] port GigabitEthernet0/0/24
[SW1-GigabitEthernet0/0/24] port link-type trunk
[SW1-GigabitEthernet0/0/24] port trunk allow-pass VLAN 10 20 30 40
[SW1] port GigabitEthernet0/0/21
[SW1-GigabitEthernet0/0/21] port link-type trunk
[SW1-GigabitEthernet0/0/21] port trunk allow-pass VLAN 10 20 30 40
MSTP Configuration Example: SW2
[SW2] stp mode mstp # Set the spanning tree protocol to MSTP.
[SW2-mst-region] quit
MSTP Configuration Example: SW2
# Set the priority of each instance and configure SW2 as the primary root bridge of instance 2 and the
secondary root bridge of instance 1.
[SW2] stp instance 1 root secondary
[SW2] stp instance 2 root primary
[SW2] stp enable
#
[SW2] port GigabitEthernet0/0/24
[SW2-GigabitEthernet0/0/24] port link-type trunk
[SW2-GigabitEthernet0/0/24] port trunk allow-pass VLAN 10 20 30 40
[SW2] port GigabitEthernet0/0/22
[SW2-GigabitEthernet0/0/22] port link-type trunk
[SW2-GigabitEthernet0/0/22] port trunk allow-pass VLAN 10 20 30 40
MSTP Configuration Example: SW3
[SW3-mst-region] quit
G G
E0 E0
/0 2 2 /0 / 22
/2 0/ /2 /0
1
E 0/ Instance 2 1
E0
G blocked G
Instance 1
blocked
SW3 SW3