Skip to content
Ask AI

STP Configuration

Devices support users to configure STP/RSTP/MSTP as needed.

FeatureSTPRSTPMSTP
standardIEEE 802.1DIEEE 802.1wIEEE 802.1s
convergence rate30-50 seconds1-2 seconds1-2 seconds
VLAN supportSingle instanceSingle instanceMultiple instances
Load balancingNot supportedNot supportedSupport
Backup pathNot supportedSupportSupport
Applicable scenariossmall networkmedium-sized networkLarge, multi-VLAN network

Considering the actual usage effect, it is recommended that users directly use MSTP.

MSTP (Multiple Spanning Tree Protocol) is a protocol for creating multiple spanning trees based on STP/RSTP. Introduced in IEEE 802.1s, it binds multiple STP instances to a smaller set of VLANs. MSTP inherits all the advantages of STP/RSTP while addressing the issue of link underutilization. By forming multiple loop-free trees, MSTP resolves broadcast storms and provides redundancy. The multiple trees achieve load balancing between VLANs, directing traffic along different paths for different VLANs.

The principles and calculation methods of MSTP are in the same line with STP/RSTP. Its basic idea is to, through priority comparison, connect each secondary priority device in sequence from the root node with the highest priority in the network, thereby pruning the ring network into an acyclic tree. As shown in the figure:

Unlike STP/RSTP, MSTP introduces the concept of regions, which divides the entire network into different regions composed of multiple switches and the segments between them. Devices within the same MSTP region share the following characteristics:

  • All devices in the region run MSTP
  • All devices have same region name
  • All devices share the same VLAN-to-spanning-tree instance mapping configuration
  • All devices share the same MSTP revision level configuration

A local area network can have multiple MSTP regions, and these regions can be directly or indirectly connected physically. Users can utilize MSTP configuration commands to group multiple switches into the same MSTP region.

  1. By configuring, three regions (region1 to region3) are formed as shown in the diagram.
  2. In MSTP, instance 0 has a special significance known as CISTI (Common and Internal Spanning Tree Instance), while the remaining instances are referred to as MSTIs (Multiple Spanning Tree Instances). By default, all VLANs are bound to the CISTI, ensuring the security of the entire network.
  3. The CIST (Common and Internal Spanning Tree) is calculated using the STP or RSTP protocol and forms a single spanning tree that connects all switching devices within a network. The IST (Internal Spanning Tree) of all MST regions combined with the CST (Common Spanning Tree) forms a complete spanning tree known as CIST. Within each region, it acts as IST, pruning devices to create a spanning tree; between regions, it acts as CST, treating each region as a single node and pruning them to form a spanning tree. The resulting effects are illustrated in the diagram.

CIST prunes the circular network into a tree within each domain and trims the entire network into a loop-free tree across domains.

Due to the introduction of domains and instances, MSTP has two types of root nodes: the Common and Internal Spanning Tree Instance (CIST) root and the Domain root. The CIST root is a global concept and there is only one CIST root for all interconnected STP/RSTP/MSTP devices. It is also the root of the CIST. The Domain root, on the other hand, is specific to a particular domain and instance. It is a localized concept and is also the root of instance0 in region1.

MSTP divides the entire network into multiple MST domains, treating each domain as a node. The calculations between different MST domains are performed using the STP or RSTP protocol algorithms to generate the Common Spanning Tree (CST), which is a single spanning tree. The calculation of the MSTP vector priority is as follows:

Priority Vector NameDescription
Root bridge IDThe Root Bridge ID is used to select the root bridge in the Common and Internal Spanning Tree (CIST). It corresponds to the bridge ID in the BPDU and is calculated using the formula: Priority (16 bits) + MAC (48 bits).
External Root Path Cost (ERPC)The path cost from an MST domain root to the overall root. The external root path cost stored on all switches within the MST domain is the same. If the CIST root bridge is within the domain, the external root path cost stored on all switches in the domain is 0
Domain Root IDAlso known as the MSTI tree root, the Domain Root ID is used to select the root of the Multiple Spanning Tree Instances (MSTIs). It’s also elected based on the bridge ID and is calculated using the formula: Priority (16 bits) + MAC (48 bits)
Internal Root Path Cost (IRPC)The path cost from the local switch to the domain root bridge. Edge ports of the domain have a higher internal root path cost value (lower priority) compared to non-edge ports
Designated BridgeThe Designated Bridge for the CIST or an MSTI instance is the nearest upstream switch to the local switch on the path to the domain root. If the local switch is the overall root or domain root, the Designated Bridge is itself
Designated PortThe Designated Port is the port on the Designated Bridge that is connected to the local switch’s root port. Its Port ID = Priority (8 bits) + Port Number (8 bits)
Receiving PortThe Receiving Port is the port that receives the BPDU messages and its port priority must be a multiple of 16. Its Port ID = Priority (8 bits) + Port Number (8 bits). Port priority must be a multiple of 16

The lowest vector has the highest priority, and the comparison rules are as follows:

First, compare the Root Bridge ID. If the Root Bridge IDs are the same, proceed to compare the External Root Path Cost. If the External Root Path Costs are also the same, then compare the Domain Root IDs. If the Domain Root IDs are still the same, proceed to compare the Internal Root Path Costs. If the Internal Root Path Costs are still the same, then compare the Designated Bridge IDs. If the Designated Bridge IDs are still the same, proceed to compare the Designated Port IDs. If the Designated Port IDs are still the same, then compare the Receiving Port IDs.

  • CSTI Calculation

After the configuration message exchange comparison, select the switch with the highest priority as the root of the CIST in the entire network. Then, within each MST domain, calculate the IST (Internal Spanning Tree) using the MSTP protocol algorithm. At the same time, MSTP treats each MST domain as a single switch and calculates the CST (Common Spanning Tree) between MST domains using the STP or RSTP protocol algorithm.

The CST and IST together form the CIST for the entire switch network.

  • MSTI Calculation

Within an MST domain, MSTP generates different spanning tree instances (MSTIs) for different VLANs based on the mapping between VLANs and instances. The characteristics of MSTI calculation are as follows:

  • Each MSTI independently calculates its own spanning tree without interfering with others.
  • The calculation method for the spanning tree in each MSTI is similar to RSTP.
  • Each MSTI can have its own root and topology.
  • Each MSTI sends its own BPDU within its own spanning tree.
  • The topology of each MSTI is determined through configuration commands (not automatically generated).
  • The parameters for each port in different MSTIs can be different.
  • The role and status of each port in different MSTIs can also be different.

MSTI Spanning Tree Algorithm Implementation

At the beginning, each switch’s ports generate configuration messages with itself as the root bridge. These messages have a root path cost of 0, the specified bridge ID as its own switch ID, and the specified port as the current port. Each switch sends out its own configuration message and processes other configuration messages it receives as follows:

  • When a port receives a configuration message with a lower priority than its own (priority comparison is based on the vector priority comparison rules explained earlier), the switch discards the received configuration message and takes no action on the configuration message for that port.
  • When a port receives a configuration message with a higher priority than its own, the switch replaces the content of the received configuration message with the content of the port’s own configuration message. Then, the switch compares this port’s configuration message with the configuration messages on its other ports and selects the optimal configuration message.

Spanning Tree Calculation Steps

  1. Root Bridge Election: By comparing the root bridge IDs in the configuration messages sent by all switches, the switch with the smallest root bridge ID becomes the CIST root bridge or MST domain root bridge.
  2. Root Port Election on Non-Root Bridges: Each non-root bridge designates the port that receives the best configuration message as its root port.
  3. Designated Port Election: This step consists of the following two sub-steps: Switch calculates a standardized designated port configuration message for each port based on the root port’s configuration message and root port’s path cost. It replaces the root bridge ID with the root port’s configuration message root bridge ID, adds the root port’s path cost to the root port’s configuration message root path cost, replaces the designated bridge ID with its own switch ID, and replaces the designated port ID with its own port ID. Switch compares the calculated configuration message from the above rule with the original configuration message on the corresponding port. If the original configuration message is better, the port is blocked, and its configuration message remains unchanged. The port will only receive configuration messages but not forward data (acting as a root port). If the calculated configuration message is better, the switch designates the port as the designated port, replaces the port’s configuration message with the calculated one, and periodically sends it out.
  4. After the MSTI spanning tree topology convergence, regardless of whether non-root bridges receive messages from the root bridge, they periodically send BPDUs according to the Hello timer. If a port does not receive a BPDU from the designated bridge (the higher-level switch it is connected to) for 3 consecutive Hello times (default setting), the switch considers the link to that neighbor as failed.
ParameterDefault value
Spanning Tree Protocol Working ModeMSTP
MSTP FunctionGlobal MSTP function is not enabled, port-level MSTP function is not enabled
Instance Priority8
Port Priority8
Forward Delay Time15 seconds
Hello Time2 seconds
Max Age Time20 seconds
OperationCommandDescription
Enter the system configuration viewconfigure terminal
Enable STP working modestp enable* stp/rstp/mstp*
OperationCommandDescription
Enter the system configuration viewconfigure terminal
Configure STP forward delaystp forward_delay timeRange value: 4-30 seconds
Configure STP hello packet intervalstp hello timeRange value: 1-10 seconds
Configure STP aging timestp max_age timeRange value: 1-1000000 seconds
Configure STP domainstp name name
OperationCommandDescription
Enter the system configuration viewconfigure terminal
Create an MSTP instance and enter the instance configuration modestp instance instance-id
Bind a VLAN to the instancestp bind vlan instance-id vlan-id
Configure the instance prioritypriority numRange value: 0-15
Configure port priority within the instanceinterface priority num **interface ** [ethernet|link-aggregation] nameRange value: 0-15
OperationCommandDescription
Display MSTP informationshow stp atatus

Network requirements

All devices in the network belong to the same MST domain, and by configuring MSTP, messages from different VLANs are forwarded according to different MSTIs.

Procedure

  1. Device 1 configuraion # Create VLAN 40, 41, and add the interface to the VLAN
sonic(config)# vlan 40
sonic(config)# vlan 41
sonic(config)# interface ethernet 1
sonic(config-if-1)# switchport trunk vlan 40
sonic(config-if-1)# switchport trunk vlan 41
sonic(config)# interface ethernet 2
sonic(config-if-2)# switchport trunk vlan 40
sonic(config-if-2)# switchport trunk vlan 41

# Enable MSTP function and configure the domain name of MST domain as test

sonic(config)# stp enable mstp
sonic(config)# stp name test

# Configure MSTI instance and configure the instance priority of this device

sonic(config)# stp instance 40
sonic(config-stp-40)# priority 1
sonic(config)# stp instance 41
sonic(config-stp-41)# priority 5

# Bind VLAN and MSTI instance

sonic(config)# stp bind vlan 40 40
sonic(config)# stp bind vlan 41 41
  1. Device 2 configuration # Create VLAN 40, 41, and add the interface to the VLAN
sonic(config)# vlan 40
sonic(config)# vlan 41
sonic(config)# interface ethernet 1
sonic(config-if-1)# switchport trunk vlan 40
sonic(config-if-1)# switchport trunk vlan 41
sonic(config)# interface ethernet 2
sonic(config-if-2)# switchport trunk vlan 40
sonic(config-if-2)# switchport trunk vlan 41

# Enable MSTP function and configure the domain name of MST domain as test

sonic(config)# stp enable mstp
sonic(config)# stp name test

# Configure MSTI instance and configure the instance priority of this device

sonic(config)# stp instance 40
sonic(config-stp-40)# priority 5
sonic(config)# stp instance 41
sonic(config-stp-41)# priority 5

# Bind VLAN and MSTI instance

sonic(config)# stp bind vlan 40 40
sonic(config)# stp bind vlan 41 41
  1. Device 3 configuration

# Create VLAN 40, 41, and add the interface to the VLAN

sonic(config)# vlan 40
sonic(config)# vlan 41
sonic(config)# interface ethernet 1
sonic(config-if-1)# switchport trunk vlan 40
sonic(config-if-1)# switchport trunk vlan 41
sonic(config)# interface ethernet 2
sonic(config-if-2)# switchport trunk vlan 40
sonic(config-if-2)# switchport trunk vlan 41

# Enable MSTP function and configure the domain name of MST domain as test

sonic(config)# stp enable mstp
sonic(config)# stp name test

# Configure MSTI instance and configure the instance priority of this device

sonic(config)# stp instance 40
sonic(config-stp-40)# priority 5
sonic(config)# stp instance 41
sonic(config-stp-41)# priority 1

# Bind VLAN and MSTI instance

sonic(config)# stp bind vlan 40 40
sonic(config)# stp bind vlan 41 41

Verify configuration

  1. View spanning tree information on Device 1
sonic# show stp status
role Flags: Root - Root, Desg - Designated, Altn - Alternate, Back - Backup, Mstr - Master, Disa - Disabled
state Flags: disc - Discard/Blocking/Listening, lear - Learning, forw - Forwarding
Spanning-tree Mode: mstp
mst_instance port port_role stp_state
------ -------------- -------------------------------------------
40 Ethernet1 Desg forw
40 Ethernet2 Desg forw
41 Ethernet1 Desg forw
41 Ethernet2 Root forw
  1. View spanning tree information on Device 2
sonic# show stp status
role Flags: Root - Root, Desg - Designated, Altn - Alternate, Back - Backup, Mstr - Master, Disa - Disabled
state Flags: disc - Discard/Blocking/Listening, lear - Learning, forw - Forwarding
Spanning-tree Mode: mstp
mst_instance port port_role stp_state
------ -------------- -------------------------------------------
40 Ethernet1 Altn disc
40 Ethernet2 Root forw
41 Ethernet1 Root forw
41 Ethernet2 Altn disc
  1. View spanning tree information on Device 3
sonic# show stp status
role Flags: Root - Root, Desg - Designated, Altn - Alternate, Back - Backup, Mstr - Master, Disa - Disabled
state Flags: disc - Discard/Blocking/Listening, lear - Learning, forw - Forwarding
Spanning-tree Mode: mstp
mst_instance port port_role stp_state
------ -------------- -------------------------------------------
40 Ethernet1 Desg forw
40 Ethernet2 Root forw
41 Ethernet1 Desg forw
41 Ethernet2 Desg forw