The difference between STP, RSTP and MSTP, explained at once
In a switch network, loop prevention is crucial. Spanning Tree Protocol (STP), Rapid Spanning Tree Protocol (RSTP), and Multiple Spanning Tree Protocol (MSTP) are our most common loop protection mechanisms. Let's follow the god to understand the difference between them.
1. STP: Spanning Tree Protocol
The basic concept of STP: STP (Spanning Tree Protocol) is a protocol defined by IEEE 802.1D to avoid loops. Its core idea is to form a loop-free tree structure in the network by blocking some redundant links.
Working principle:
Root Bridge Election: Select a root bridge by comparing bridge IDs.
Path Cost Calculation: Non-root bridges determine their root ports by calculating the shortest path to the root bridge. Designated Port Election: The designated port of each non-root bridge
(Root Port). Designated Port Election: The designated port of each non-root bridge is responsible for forwarding data downward.
Blocked Port: Non-designated ports enter the blocked state to prevent loops.
Five port states:
Disabled: The port is closed.
Blocking: Block data flow and only receive BPDU.
Listening: Listen to BPDU, but do not learn MAC address.
Learning: Learn MAC address, but do not forward data.
Forwarding: Forward data normally.
Disadvantages:
Slow convergence speed (30-50 seconds).
Only supports spanning tree of a single VLAN, and cannot achieve multi-VLAN optimization.
2. RSTP: Rapid Spanning Tree Protocol
Basic concept: RSTP (Rapid Spanning Tree Protocol) is defined by IEEE 802.1w and is an enhanced version of STP. RSTP improves the convergence speed of the network by optimizing the port state transition, and can usually complete convergence within 1-2 seconds.
Main features:
Introducing Alternate Port: As an alternative path, it can quickly take over when the root port fails.
Introducing Backup Port: It provides redundant connections to prevent link failure.
Directly enter Forwarding state: The port can directly enter the Forwarding state without going through the Listening and Learning stages.
Port role:
Root Port(根連接埠): 到達根橋的最優路徑連接埠。
Designated Port(指定連接埠): 為下游設備提供轉送服務的連接埠。
Alternate Port(替代連接埠): 替代路徑,替代根連接埠。
Backup Port(備援端口): 備援指定端口,提供冗餘。
優點:
收斂速度快(通常在
1 秒內完成)。
The port can directly enter the forwarding state to optimize the data forwarding path.
3. MSTP: Multiple Spanning Tree Protocol
The basic concept of MSTP: MSTP (Multiple Spanning Tree Protocol) is defined by IEEE 802.1s. It can bind different VLANs to different spanning tree instances to achieve load balancing and loop protection for multiple VLANs.
Key features of MSTP:
MST area: Multiple switches form an MST area and share the same MST configuration.
Instance mapping: Map different VLANs to different MST instances (MSTI).
Multiple execution individual load balancing: Traffic sharing is achieved through different MST execution individuals to improve bandwidth utilization.
Three types of spanning trees in MSTP:
CIST (Common and Internal Spanning Tree): Responsible for managing spanning trees between MST areas.
MSTI (Multiple Spanning Tree Instances): Each instance maintains its own spanning tree.
IST (Internal Spanning Tree): The default spanning tree instance within the MST area.
Advantages:
Allow VLANs to share traffic and optimize bandwidth.
Provide cross-region spanning tree management.
4. Core differences between STP, RSTP and MSTP
5. Common configuration examples
Take ensp as an example:
STP settings:
RSTP configuration:
MSTP configuration: