Configuring Spanning Tree Protocol
Summary: Networking › Switching › Edge › Synapse
Overview of Spanning Tree Protocol
Spanning Tree Protocol is a Layer 2 management protocol that eliminates Layer 2 loops by selectively blocking redundant links in the network, and also has the function of link backup. Like the development process of many protocols, the Spanning Tree Protocol is constantly updated with the development of the network, from the original STP (Spanning Tree Protocol, Spanning Tree Protocol) to RSTP (Rapid Spanning Tree Protocol, Rapid Spanning Tree Protocol), to the latest MSTP (Multiple Spanning Tree Protocol). Comparison of three spanning tree protocols: Spanning Tree Protocol Features Application Scenario
STP
Form a loop-free tree, resolve broadcast storms and implement redundant backup. Slow convergence. There is no need to distinguish user or service traffic, all VLANs share a spanning tree.
RSTP
Form a loop-free tree, resolve broadcast storms and implement redundant backup. Convergence is fast.
MSTP
Form a loop-free tree, resolve broadcast storms and implement redundant backup. Convergence is fast. Multiple spanning trees implement load balancing among VLANs, and traffic of different VLANs is forwarded according to different paths. It is necessary to distinguish user or service traffic and implement load balancing. Different VLANs forward traffic through different spanning trees, and each spanning tree is independent of each other. STP
Requirement Background
STP is a protocol for eliminating loops in local area networks. Devices running this protocol discover loops in the network by exchanging information with each other, and appropriately block certain ports to eliminate loops. Due to the continuous growth of LAN scale, Spanning Tree Protocol has become one of the most important LAN protocols. Figure121 Schematic diagram of typical local area network In the network shown in Figure121, the following two situations will occur:
- Network unavailable due to broadcast storm.
The loop generates a broadcast storm, which can make the network unavailable. Assume that the STP protocol is not enabled on the switch device. If ServerA sends a broadcast request, then the broadcast packet will be received by the port port1 of the other two switching devices, and broadcast from the port port2 respectively, and then the port port2 will receive another switching device. The broadcast packets are forwarded from the ports port1 of the two switching devices respectively. Repeatedly, the entire network resources will be exhausted and the network will be paralyzed and unavailable.
- MAC address table flapping caused MAC address table entries to be destroyed.
Even unicast packets may cause confusion in the MAC address table entries of the switching device, thus destroying the MAC address table of the switching device. Assuming that there is no broadcast storm in the network shown, ServerA sends a unicast packet to ServerB. If ServerB is temporarily removed from the network at this time, then the MAC address entry about ServerB on the switching device will also be changed. been deleted. At this time, the unicast packet sent by ServerA to ServerB will be received by port 1 of switching device S1. Since there is no corresponding MAC address forwarding entry on S1, the unicast packet will be forwarded to port 2. Then the port port2 of the switching device S2 receives the unicast message sent from the peer port2 port, and then sends it out from port1. At the same time, the port port1 of the switching device S2 will also receive the unicast message sent by ServerA to ServerB, and then send it out from port2. So repeatedly, on the two switching devices, since the unicast packets from host A are continuously received from ports port1 and port2, the switching device will constantly modify its own MAC address entries. , thus causing the MAC address table to jitter. If this goes on, the MAC address entry will eventually be destroyed.
Basic Concepts
- One Root Bridge
For an STP network, there is only one root bridge in the entire network, which is the logical center of the entire network, but not necessarily the physical center. The root bridge changes dynamically according to changes in the network topology. After the network converges, the root bridge will generate and send configuration BPDUs at certain time intervals. Other devices will only process the packets and communicate the topology change records to ensure topology stability.
- Two metrics
The generation calculation of spanning tree has two basic metrics: ID and path cost.
ID
ID is divided into: BID (Bridge ID) and PID (Port ID). BID: Bridge ID The IEEE 802.1D standard stipulates that the BID is composed of the bridge priority (Bridge Priority) and the bridge MAC address. BID bridge priority occupies the upper 16 bits, and the remaining lower 48 bits are the MAC address. In an STP network, the device with the smallest bridge ID will be elected as the root bridge. PID: Port ID PID consists of two parts, the upper 4 bits are the port priority, and the lower 12 bits are the port number. PID is only useful for selecting the designated port in some cases.
Path cost
Path Cost is a port variable and a reference value used by the STP protocol to select links. The STP protocol selects the 'stronger' link by calculating the path cost, blocks the redundant links, and prunes the network into a loop-free tree network structure. In an STP network, the path cost from a port to the root bridge is the accumulation of the path costs of the outgoing ports on the bridges it passes through. This value is called the Root Path Cost.
- Three-element election
From ring network topology to tree structure, there are generally three elements: root bridge, root port and designated port. The following three elements are introduced in combination with Figure122. Figure122 STP network structure
Root Bridge RB
The root bridge is the bridge with the smallest bridge ID, and the smallest BID is selected by configuring the BPDU protocol packets interactively.
Root Port RP
The so-called root port is the port with the least path cost to the root bridge. The root port is responsible for forwarding data to the root bridge. The selection criteria of this port are determined based on the cost of the root path. Among all STP-enabled ports on a device, the one with the lowest root path cost is the root port. Obviously, there is only one root port on a device running the STP protocol, and there is no root port on the root bridge. Designated Port (Designated Port) See Table121 for the description of the designated bridge and designated port. Table121 Meaning of Designated Bridge and Designated Port Classification Specify bridge Designated port Device A device directly connected to this machine and responsible for forwarding configuration messages to this machine The designated bridge's port that forwards configuration BPDUs to the device LAN The device responsible for forwarding configuration messages to this network segment The designated bridge's port that forwards configuration BPDUs to the LAN As shown in , AP1, AP2, BP1, BP2, CP1, and CP2 represent the ports of devices S1, S2, and S3, respectively. S1 forwards configuration messages to S2 through port AP1, then the designated bridge of S2 is S1, and the designated port is port AP1 of S1. There are two devices connected to the local area network LAN: S2 and S3. If S2 is responsible for forwarding configuration messages to the LAN, the designated bridge of the LAN is S2, and the designated port is the BP2 of S2. Figure123 Designated Bridge and Designated Port Diagram Once the root bridge, root port, and designated port are elected successfully, the entire tree topology is established. After the topology is stable, only the root port and the designated port forward traffic, and other non-root and non-designated ports are in the blocking state. They only receive STP protocol packets and do not forward user traffic.
- Four comparison principles
STP election has four comparison principles to form a message priority vector: < root bridge ID, root path cost, sending device BID, sending port PID>. The main information of this port carried in the configuration BPDU is shown in Table122. Table122 Four Important Information Fields Field Content Brief Description
Root Bridge ID
There is exactly one root per STP network.
Root path cost
The distance from the port sending the configuration BPDU to the root bridge determines the path cost to the root bridge.
Sender BID
The BID of the device that sent the configuration BPDU.
PID
PID of the port that issued the configuration BPDU. Other devices in the STP network will compare the fields described in table after receiving the configuration BPDU message. The four basic comparison principles are as follows: Minimum BID: used to elect the root bridge. Select the smallest BID according to the root bridge ID field between devices running the STP protocol. Minimum root path cost: used to select root ports on non-root bridges. On the root bridge, the root path cost from each port to the root bridge is 0. Minimum sender BID: When a device running the STP protocol wants to select a root port among two or more ports with the same root path cost, it is calculated by the STP protocol, and the received configuration message will be selected. The port with the smaller sender's BID. As shown in Figure122, assuming that the BID of S2 is smaller than the BID of S3, if the root path costs in the BPDUs received by ports A and B of S4 are equal, then port B will become the root port . Minimum PID: When the root path cost is the same, the port with the smallest PID is not blocked, but the port with the larger PID value is blocked. The PID only works in the case shown in Figure124, the PID of port A of S1 is smaller than the PID of port B, because in the BPDUs received on the two ports, the root path overhead, sending exchange The device BIDs are the same, so the basis for eliminating the loop is only the PID. Figure124 Topology applied to PID for comparison
- Five Port States
The port status on the device running the STP protocol is shown in Table123. Table123 STP Port Status Port Status Purpose
Forwarding
The port both forwards user traffic and processes BPDUs. Only the root port or the designated port can enter the Forwarding state.
Learning
The device will build a MAC address table based on the received user traffic, but will not forward user traffic. Transition state, add Learning state to prevent temporary loops.
Listening
Determine the port role. The root bridge, root port and designated port will be elected. Transition state.
Blocking
The port only receives and processes BPDUs and does not forward user traffic. The final state of the blocked port.
Disabled
The port not only does not process BPDUs, but also does not forward user traffic. The port status is Down. The port state migration mechanism is shown in . Figure125 STP port state transition diagram For STP, the following 3 parameters affect port status and port convergence. • Hello Time The time interval at which the device running the STP protocol sends the configuration message BPDU, which is used by the device to detect whether the link is faulty. The device will send hello packets to surrounding devices every Hello Time to confirm whether the link is faulty. When the network topology is stable, the modification of this timer will only take effect after the root bridge is modified. The new root bridge will populate the appropriate fields in outgoing BPDUs to pass the timer modification information to other non-root bridges. But when the topology changes, the sending of TCN BPDUs is not managed by this timer. • Forward Delay Delay time for device state transition. A link failure will cause the network to recalculate the spanning tree, and the structure of the spanning tree will change accordingly. However, the new configuration message obtained by recalculation cannot immediately spread to the entire network. If the newly selected root port and designated port start data forwarding immediately, it may cause a temporary loop. For this reason, STP adopts a state transition mechanism. The newly selected root port and designated port can enter the forwarding state after 2 times of the Forward Delay. Configuration messages are propagated throughout the network, preventing temporary loops. Forward Delay Timer refers to the respective durations of a port in the Listening and Learning states. The default is 15 seconds. The Listening state lasts for 15 seconds, followed by the Learning state for another 15 seconds. Ports in these two states do not forward user traffic, which is exactly what STP is used to avoid temporary loops. • Max Age The aging time of BPDU packets of the port can be manually changed by commands on the root bridge. Max Age can be guaranteed to be consistent in the entire network by configuring the transmission of BPDU packets. After the non-root bridge device in the network running the STP protocol receives the configuration BPDU message, the Message Age and Max Age in the message will be compared: If Message Age is less than or equal to Max Age, the non-root bridge device continues to forward configuration BPDUs. If Message Age is greater than Max Age, the configuration BPDU will be aged out. The non-root bridge device directly discards the configuration BPDU. It can be considered that the network diameter is too large and the root bridge connection fails. If the configuration BPDU is sent by the root bridge, the Message Age is 0. Otherwise, Message Age is the total time from the root bridge to the BPDU received by the current bridge, including transmission delay, etc. In the actual implementation, when BPDU packets pass through a bridge, the Message Age is increased by 1.
Message Format
Information such as bridge ID, path cost, and port ID were introduced in the previous chapters, all of which are transmitted via BPDU protocol packets. The configuration BPDU is a heartbeat message. As long as the port is enabled with STP, the configuration BPDU will be sent from the designated port at the interval specified by the Hello Time timer. TCN BPDUs are sent when the device detects that the network topology has changed. BPDUs are encapsulated in Ethernet data frames, the destination MAC is multicast MAC: 01-80-C2-00-00-00, the Length/Type field is the MAC data length, followed by LLC header, LLC is followed by the BPDU header. The Ethernet data frame format is shown in Figure126. Figure126 Ethernet Data Frame Format
- Configuring BPDU
Most commonly referred to as BPDUs refer to configuration BPDUs. During initialization, each bridge actively sends configuration BPDUs. But after the network topology is stable, only the root bridge actively sends configuration BPDUs, and other bridges trigger to send their own configuration BPDUs after receiving configuration BPDUs from upstream. The length of the configuration BPDU must be at least 35 bytes, including parameters such as bridge ID, path cost, and port ID. Only when at least one of the sender's BID or port PID is different from the receiving port of the bridge, the BPDU will be processed, otherwise it will be discarded. This avoids processing BPDUs with the same port information. The configuration BPDU will be generated in the following 3 cases:
- As long as the port is enabled with STP, the configuration BPDU will be sent from the designated port at the interval specified by the Hello Time timer.
- When the root port receives a configuration BPDU, the device where the root port is located will copy a configuration BPDU to each of its designated ports.
- When the designated port receives a configuration BPDU that is worse than its own, it will immediately send its own BPDU to the downstream device.
The basic format of the configuration BPDU message is shown in Table124. Table124 BPDU basic format
Field
bytes
Protocol Identifier
Always 0.
Protocol Version Identifier
Always 0.
BPDU Type
Current BPDU type: 0x00: Configure BPDU. 0x80: TCN BPDU.
Flags
Network topology change flag: Lowest bit = TC (Topology Change) flag. Highest bit=TCA (Topology Change Acknowledgment, Topology Change Acknowledgment) flag.
Root Identifier
The BID of the current root bridge.
Root Path Cost
The total cost of this port to the root bridge.
Bridge Identifier
BID of this switching device.
Port Identifier
Port ID for sending this BPDU.
Message Age
The message age of this BPDU. If the configuration BPDU is sent by the root bridge, the Message Age is 0. Otherwise, Message Age is the total time from the root bridge to the BPDU received by the current bridge, including transmission delay, etc. In the actual implementation, when BPDU packets pass through a bridge, the Message Age is increased by 1.
Max Age
Message aging age.
Hello Time
The time interval between sending two adjacent BPDUs.
Forward Delay
Controls the duration of the Listening and Learning states. The flag field is shown in Figure127, only the highest and lowest bits are used in STP. Figure127 Flags field format
- TCN BPDU
TCN BPDU content is relatively simple, only the first 3 fields listed in Table124: protocol number, version and type. The type field is a fixed value of 0x80, and the length is only 4 bytes. TCN BPDU refers to sending a topology change notification to the upstream when the downstream topology changes, until the root node. TCN BPDU will be generated in the following two cases:
- The port status changes to Forwarding status.
- The designated port receives the TCN BPDU, copies the TCN BPDU and sends it to the root bridge.
Topology Calculation
After all devices in the network enable the STP protocol, each device considers itself to be the root bridge. At this point, each device only sends and receives configuration BPDUs without forwarding user traffic, and all ports are in the Listening state. After all devices exchange configuration BPDUs, they perform election work to elect the root bridge, root port and designated port.
- BPDU interaction process
As shown in Figure128, the quadruple marked with <> represents the root bridge ID (S1_MAC and S2_MAC represent the BIDs of two devices in the figure), the accumulated root path cost, An ordered group consisting of sender BID and sending port PID. The configuration BPDU will be sent at the interval specified by the Hello Timer. Figure128 Initial Information Interaction
Basic process of STP algorithm implementation
- Initial state
Because each bridge thinks it is the root bridge, in the BPDU sent by each port, the root bridge field uses its own BID, and the Root Path Cost field is accumulated to the root bridge. Overhead, the sender BID is its own BID, and the port PID is the port ID of the port that sent the BPDU.
- Select root bridge
When the network is initialized, all STP devices in the network consider themselves to be the 'root bridge', and the root bridge ID is its own device ID. By exchanging configuration messages, devices compare root bridge IDs, and the device with the smallest root bridge ID in the network is selected as the root bridge.
- Select root port and designated port
The selection process of root port and designated port is shown in Table125. Table125 Root port and designated port selection process Step
Process
The non-root bridge device will set the port that receives the optimal configuration message (the selection process of the optimal configuration message is shown in Table126) as the root port The device calculates a designated port configuration message for each port according to the configuration message of the root port and the path cost of the root port: Replace the root bridge ID with the root bridge ID of the configuration message of the root port; The root path cost is replaced by the root path cost of the root port configuration message plus the path cost corresponding to the root port; Replace the sender's BID with the ID of its own device; Replace the sending port PID with the own port ID. The device compares the calculated configuration message with the role-pending port's own configuration message: If the calculated configuration message is better, the port is determined to be the designated port, and its configuration message is also replaced by the calculated configuration message and sent out periodically; If the port's own configuration message is better, the port's configuration message will not be updated and the port will be blocked. This port will no longer forward data, and will only receive and not send configuration messages. Table126 Optimal configuration message selection process Step
Process
Each port compares the received configuration message with its own configuration message: If the received configuration message has a lower priority, it will be discarded directly, and its own configuration message will not be processed; If the received configuration message has a higher priority, replace the content of the configuration message with the content of the configuration message. The device compares the configuration messages of all ports and selects the optimal configuration message.
STP algorithm implementation example
Once the root bridge, root port and designated port are elected successfully, the whole tree topology is established. The following describes the specific process of implementing the STP algorithm with an example. Figure129 STP algorithm implementation process networking diagram and calculated topology As shown in the figure, the priorities of DeviceA, DeviceB, and DeviceC are 0, 1, and 2, respectively. The path cost of the links between DeviceA and DeviceB, between DeviceA and DeviceC, and between DeviceB and DeviceC 5, 10 and 4 respectively.
Initial state of each device
The initial state of each device is shown in the table below. Table127 Initial state of each device Device Port Name
Port configuration message
< Root bridge ID, cumulative root path cost, sender BID, sender port PID>
DeviceA
Port A1 <0,0,0,Port A1> Port A2 <0,0,0,Port A2>
DeviceB
Port B1 <1,0,1,Port B1> Port B2 <1,0,1,Port B2>
DeviceC
Port C1 <2,0,2,Port C1> Port C2 <2,0,2,Port C2>
Comparison process and results of each device
The comparison process and results of each device are shown in the table below. Table128 STP topology calculation process and results Device Comparison process Configuration message of port after comparison
DeviceA
Port A1 received the configuration message of Port B1 <1, 0, 1, Port B1>, and found that its configuration message < 0, 0, 0, Port A1> was better, so it throw away. Port A2 receives the configuration message <2, 0, 2, Port C1> of Port C1, and finds that its configuration message < 0, 0, 0, Port A2> is better, so it throw away. DeviceA finds that both the root bridge and the designated bridge in the configuration messages of its ports are itself, so it thinks that it is the root bridge, and the configuration messages of each port do not make any changes, and then periodically send out Send configuration message. Port A1: <0, 0, 0, Port A1> Port A2: <0, 0, 0, Port A2>
DeviceB
Port B1 receives the configuration message of Port A1 <0,0,0,Port A1>, and finds that it is better than its own configuration message <1,0,1,Port B1>, so Update your own configuration message. Port B2 receives the configuration message of Port C2 <2, 0, 2, Port C2>, and finds that its configuration message < 1, 0, 1, Port B2> is better, so it throw away. Port B1: <0, 0, 0, Port A1> Port B2: <1, 0, 1, Port B2> DeviceB compares the configuration messages of its own ports and finds that the configuration messages of Port B1 are optimal, so this port is determined as the root port, and its configuration messages remain unchanged. DeviceB calculates the configuration message <0, 5, 1, Port B2> of the designated port for Port B2 according to the configuration message and path cost of the root port, and then matches the configuration message of Port B2 itself < 1, 0, 1, and Port B2> are compared, and it is found that the calculated configuration message is better, so Port B2 is determined as the designated port, and its configuration message is also replaced with the calculated configuration message and sent out periodically. . Root port B1: <0, 0, 0, Port A1> Designated port B2: <0, 5, 1, Port B2>
DeviceC
Port C1 receives the configuration message of Port A2 <0,0,0,Port A2>, and finds that it is better than its own configuration message <2,0,2,Port C1>, so Update your own configuration message. Port C2 receives the configuration message <1, 0, 1, Port B2> before the update of Port B2, and finds that it is better than its own configuration message < 2, 0, 2, Port C2> , so update your own configuration message. Port C1 :<0, 0, 0, Port A2> Port C2: <1, 0, 1, Port B2> DeviceC compares the configuration messages of its own ports and finds that the configuration messages of Port C1 are optimal, so the port is determined as the root port, and its configuration messages remain unchanged. DeviceC calculates the configuration message <0, 10, 2, Port C2> of the designated port for Port C2 according to the configuration message and path cost of the root port, and then matches the configuration message of Port C2 itself < 1, 0, 1, Port B2> compare and find that the calculated configuration message is better, so Port C2 is determined as the designated port, and its configuration message is also replaced with the calculated configuration message. Root port C1: <0, 0, 0, Port A2> Designated port C2: <0, 10, 2, Port C2> Port C2 received the updated configuration message <0, 5, 1, Port B2> from Port B2, and found that it is better than its own configuration message <0, 10, 2, Port C2> , so update your own configuration message. Port C1 receives the configuration message <0, 0, 0, Port A2> periodically sent by Port A2, and finds that it is the same as its own configuration message, so it discards it. Port C1 :<0, 0, 0, Port A2> Port C2: <0, 5, 1, Port B2> DeviceC compares the root path cost 10 of Port C1 (the root path cost 0 in the received configuration message + the path cost 10 of the link where the port is located) and the root path cost 9 of Port C2 (received The root path cost in the configuration message is 5 + the path cost of the link where this port is located 4). It is found that the latter is smaller, so the configuration message of Port C2 is better, so Port C2 is determined as the root port, and its configuration message remains unchanged. DeviceC calculates the configuration message <0, 9, 2, Port C1> of the designated port for Port C1 according to the configuration message and path cost of the root port, and then matches the configuration message of Port C1 itself < 0, 0, 0, Port A2> compared, and found that its own configuration message is better, so Port C1 is blocked, and its configuration message remains unchanged. From now on, Port C1 will no longer forward data until a new situation that triggers spanning tree calculation occurs, such as the link between DeviceB and DeviceC is down. Blocking port C1: <0, 0, 0, Port A2> Root port C2: <0, 5, 1, Port B2> After the topology is stable, the root bridge still sends configuration BPDUs according to the interval specified by the Hello Timer. Non-root bridge devices receive configuration BPDUs from the root port and forward them through the designated port. If it receives a configuration BPDU with a higher priority than itself, the non-root bridge device will update the configuration BPDU information stored on its corresponding port according to the information carried in the received configuration BPDU.
STP topology change
The STP topology change processing process is shown in the figure below. Figure 1210 TCN sending and TC flooding After the network topology changes, the downstream device will continuously send TCN BPDUs to the upstream device. After the upstream device receives the TCN BPDU message from the downstream device, only the designated port processes the TCN BPDU message. Other ports may also receive TCN BPDUs, but will not process them. The upstream device will set the TCA bit of the Flags in the configuration BPDU message to 1, and then send it to the downstream device to tell the downstream device to stop sending TCN BPDU messages. The upstream device copies a TCN BPDU and sends it to the root bridge. Repeat steps 1, 2, 3, and 4 until the root bridge receives a TCN BPDU. The root bridge sets the TC and TCA bits of the Flags in the configuration BPDU message to 1 and sends it to notify the downstream device to delete the bridge MAC address entry directly. RSTP
Requirement Background
The 802.1w standard released by the IEEE in 2001 defines the Rapid Spanning Tree Protocol (RSTP), which is based on the STP protocol and makes more detailed modifications and additions to the original STP protocol.
STP deficiencies
Although the STP protocol can solve the loop problem, the slow convergence of the network topology affects the quality of user communication. If the topology in the network changes frequently, the network will also lose connectivity frequently, resulting in frequent interruption of user communication, which is unbearable for users. The disadvantages of STP are as follows: STP does not distinguish port status and port role in detail, which is not conducive to beginners' learning and deployment. The quality of a network protocol often depends on whether the protocol distinguishes each situation carefully. From the user's point of view, there is no difference between the Listening, Learning and Blocking states, and they also do not forward user traffic. From the perspective of usage and configuration, the most essential difference between ports is not the state of the port, but the role the port plays. The root port and the designated port can both be in the Listening state or both in the Forwarding state. The STP algorithm is a passive algorithm. It relies on the timer to wait to determine the topology change, and the convergence speed is slow. The STP algorithm requires that in a stable topology, the root bridge actively sends out configuration BPDUs, and other devices process them and spread them throughout the STP network. This is also one of the main reasons for slow topology convergence.
RSTP improves STP
According to the insufficiency of STP, RSTP deletes 3 port states, adds 2 new port roles, and fully decouples port attributes according to state and role; in addition, RSTP also adds some corresponding Enhanced features and protection measures to achieve network stability and rapid convergence, simplifies the understanding and deployment of Spanning Tree Protocol by adding port roles. Figure1211 Port Role Schematic As shown in the figure above, there are four types of RSTP port roles: root port, designated port, alternate port and backup port. The functions of the root port and the designated port are the same as those defined in the STP protocol. The description of the alternate port and the backup port is as follows: From the perspective of configuring BPDU sending: Alternate port is a port that is blocked due to learning configuration BPDUs sent by other bridges. The backup port is the port that is blocked due to learning the configuration BPDUs sent by itself. From a user traffic perspective: The Alternate port provides an alternate switchable path from the designated bridge to the root, acting as a backup port for the root port. The Backup port acts as a backup of the designated port, providing another backup path from the root bridge to the corresponding network segment. The process of assigning roles to all ports in an RSTP network is the process of topology convergence.
Repartition of port state
RSTP state specification reduces the original 5 states to 3. Divided according to whether the port forwards user traffic and learns the MAC address: If the user traffic is not forwarded and the MAC address is not learned, the port state is Discarding state. If the user traffic is not forwarded but the MAC address is learned, the port state is the Learning state. If both user traffic is forwarded and the MAC address is learned, the port state is the Forwarding state. As shown in Table129, the new port state is compared with the port state specified by STP. Port status and port role are not necessarily related. The table shows the port status that various port roles can have. Table129 STP and RSTP Port Status Role Correspondence Table STP port status RSTP port status The role of the port in the topology Forwarding
Forwarding
Include root port, designated port Learning
Learning
Include root port, designated port Listening
Discarding
Include root port, designated port Blocking
Discarding
Include Alternate port, Backup port Disabled Discarding
Include Disable port
The change of the configuration BPDU format makes full use of the Flag field in the STP protocol message and clarifies the port role. In addition to ensuring that the format of the BPDU is basically the same as the STP format, RSTP has made some minor changes: Type field, the configuration BPDU type is no longer 0 but 2, so the device running STP will discard the RSTP configuration BPDU when it receives it. Flags field, using the original reserved middle 6 bits, so the changed configuration BPDU is called RST BPDU, as shown in the following figure. Figure1212 RSTP Flag field format
- The processing of configuration BPDUs has changed
- Transmission frequency of configuration BPDUs
After the topology is stable, the root bridge sends configuration BPDUs at the interval specified by the Hello Timer. Other non-root bridge devices will trigger configuration BPDUs after receiving the configuration BPDUs sent by the upstream device. This method makes the calculation of the STP protocol complicated and slow. RSTP has been improved, that is, after the topology is stable, no matter whether the non-root bridge device receives the configuration BPDU from the root bridge or not, the non-root bridge device still follows the interval specified by Hello Timer. Sending a configuration BPDU, this behavior is entirely autonomous for each device.
- Shorter BPDU timeout
If a port does not receive a configuration BPDU from an upstream device within 3 consecutive Hello Time, the device considers that the negotiation with this neighbor has failed. Instead of waiting for a Max Age like STP.
- Process inferior BPDUs
When a port receives an RST BPDU from an upstream designated bridge, the port will compare its own stored RST BPDU with the received RST BPDU. If the priority of the RST BPDU stored by the port is higher than that of the received RST BPDU, the port will directly discard the received RST BPDU and immediately respond to its own stored RST BPDU. When the upstream device receives the RST BPDU responded by the downstream device, the upstream device will immediately update its stored RST BPDU according to the corresponding fields in the received RST BPDU. Therefore, RSTP processing inferior BPDUs no longer relies on any timer to solve topology convergence through timeout, thus speeding up topology convergence.
- fast convergence
- Proposal/Agreement mechanism
After a port is elected as the designated port, in STP, the port will wait at least one Forward Delay (Learning) time before transitioning to the Forwarding state. In RSTP, this port will first enter the Discarding state, and then quickly enter the Forward state through the Proposal/Agreement mechanism. This mechanism must be used on point-to-point full-duplex links. Proposal/Agreement mechanism is referred to as P/A mechanism.
- Root port fast switching mechanism
If a root port in the network fails, the optimal alternate port in the network will become the root port and enter the Forwarding state. Because there must be a designated port on the network segment connected through this alternate port that can lead to the root bridge.
Introduction of edge ports
In RSTP, if a designated port is located at the edge of the entire network, that is, it is no longer connected to other switching devices, but directly connected to terminal devices. This port is called an edge port. The edge port does not receive and process configuration BPDUs, and does not participate in RSTP operations. It can go to the Forwarding state directly from Disable without experiencing delay, just like disabling STP on the port. But once the edge port receives the configuration BPDU, it loses the edge port attributes, becomes a normal STP port, and recalculates the spanning tree, which causes network flapping.
- protection function
The protection functions provided by RSTP are shown in the table below. Table1210 Protection function Protection function Scene Principle
BPDU Protection
On switching devices, the ports directly connected to non-switching devices such as user terminals (such as PCs) or file servers are usually configured as edge ports. Normally, edge ports will not receive RST BPDUs. If someone forges an RST BPDU to maliciously attack a switching device, when an edge port receives an RST BPDU, the switching device will automatically set the edge port as a non-edge port and recalculate the spanning tree, causing network flapping . After the BPDU protection function is enabled on the switching device, if the edge port receives an RST BPDU, the edge port will be error-down, but the edge port attributes will remain unchanged, and the network management system will be notified at the same time.
Root Protection
Due to the misconfiguration of the maintenance personnel or the malicious attacks in the network, the legitimate root bridges in the network may receive RST BPDUs with higher priority, so that the legitimate root bridges lose their root status, thus causing the network topology Incorrect change of structure. This illegal topology change will cause traffic that should have passed through the high-speed link to be pulled to the low-speed link, causing network congestion. For the designated port with root protection function enabled, its port role can only remain as designated port. Once a designated port with the root protection function enabled receives a RST BPDU with a higher priority, the port state will enter the Discarding state and will no longer forward packets. After a period of time (usually twice the Forward Delay), if the port has not received RST BPDUs with higher priority, the port will automatically return to the normal Forwarding state. Description: Root protection can only be configured on designated ports.
Technical Principles
Proposal/Agreement mechanism The purpose is to make a designated port enter the Forwarding state as soon as possible. As shown in the figure below, a new link has been added between the root bridge S1 and S2. In the current state, the other ports p2 of S2 are alternate ports, p3 is the designated port and is in the forwarding state, and p4 is the edge port. Figure1213 Proposal/Agreement Process Diagram After the new link is successfully connected, the P/A mechanism negotiation process is as follows:
- Both ports p0 and p1 will immediately become designated ports and send RST BPDUs.
- The p1 port of S2 received a better RST BPDU, and immediately realized that it would become the root port, not the designated port, and stopped sending RST BPDUs.
- P0 of S1 enters the Discarding state, so the proposal is set to 1 in the sent RST BPDU.
- S2 receives the RST BPDU with proposal sent by the root bridge, and starts to set all its own ports into the sync variable.
- p2 has been blocked and the state remains unchanged; p4 is an edge port and does not participate in the operation; so only the non-edge designated port p3 needs to be blocked.
- After both p2 and p3 enter the Discarding state, the synced variable of the port is set, and the synced of the root port p1 is also set, so the response RST BPDU with the Agreement bit set is returned to S1. This RST BPDU carries the same information as the BPDU sent by the root bridge just now, except that the Agreement bit is set (the Proposal bit is cleared).
- When S1 determines that this is a response to the proposal just sent, port p0 immediately enters the Forwarding state.
The downstream device continues the P/A negotiation process. In fact, for STP, the selection of the designated port can be completed very quickly. The main speed bottleneck is: in order to avoid loops, it is necessary to wait long enough to make the port status of the entire network all determined, that is Says that all ports must wait for at least one Forward Delay before forwarding. The main purpose of RSTP is to eliminate this bottleneck by blocking its own non-root ports to ensure that there will be no loops. Using the P/A mechanism speeds up the upstream port's transition to the Forwarding state.
RSTP topology change processing
There is only one criterion for detecting topology changes in RSTP: a non-edge port migrates to the Forwarding state. Once a topology change is detected, the following processing will be performed: Start a TC While Timer for all non-edge designated ports of this switching device. The timer value is twice the Hello Time. During this time, clear the MAC addresses learned on all ports. At the same time, a RST BPDU is sent out from the non-edge port, with TC set. Once the TC While Timer times out, stop sending RST BPDUs. After receiving the RST BPDU, other switching devices clear all ports to learn the MAC address, except the port that received the RST BPDU. Then also start the TC While Timer for all non-edge designated ports and root ports, and repeat the above process. In this way, a flood of RST BPDUs will occur in the network.
RSTP and STP interoperability
RSTP can interoperate with STP, but the advantages of RSTP such as fast convergence will be lost at this time. When a network segment has both STP and RSTP switching devices, the STP switching device will ignore RSTP BPDUs. The switching device running RSTP receives the configuration BPDU sent by the switching device running STP on a port, and after two Hello Time times, it switches its port to STP working mode and sends the configuration BPDU , thus enabling interoperability. MSTP
Requirement Background
RSTP has been improved on the basis of STP to achieve rapid network topology convergence. But RSTP and STP still have the same defect: because all VLANs in the LAN share a spanning tree, load balancing of data traffic between VLANs cannot be achieved, and the link will not carry any traffic after it is blocked. traffic, resulting in wasted bandwidth, and may also cause some VLAN packets to fail to be forwarded. Figure1214 STP/RSTP defect diagram In the network shown above, STP or RSTP is applied in the local area network. The spanning tree structure is represented by a dotted line in the figure, and S6 is the root switching device. The links between S2 and S5 and between S1 and S4 are blocked. Except for the links marked 'VLAN2' or 'VLAN3' in the figure, the corresponding VLAN packets are allowed to pass through. The packets of VLAN2 and VLAN3 are not allowed to pass through. ServerA and ServerB belong to VLAN2, because the link between S2 and S5 is blocked, and the link between S3 and S6 does not allow packets from VLAN2 to pass, so ServerA and ServerB cannot communicate with each other. communicate with each other. In order to make up for the shortcomings of STP and RSTP, the 802.1S standard released by IEEE in 2002 defines MSTP. MSTP is compatible with STP and RSTP, which can not only converge quickly, but also provide multiple redundant paths for data forwarding to achieve load balancing of VLAN data during data forwarding. A switching network is divided into multiple regions through MSTP, and multiple spanning trees are formed in each region, and the spanning trees are independent of each other. Each spanning tree is called a Multiple Spanning Tree Instance (MSTI), and each region is called an MST Region (MST Region: Multiple Spanning Tree Region). Figure1215 Multiple spanning trees in the MST region As shown in the figure above, MSTP connects VLAN and MSTI by setting the VLAN mapping table (that is, the correspondence table between VLAN and MSTI). Each VLAN can only correspond to one MSTI, that is, the data of the same VLAN can only be transmitted in one MSTI, and one MSTI may correspond to multiple VLANs. After calculation, two spanning trees are finally generated: MSTI1 uses S4 as the root switching device to forward packets of VLAN2. MSTI2 uses S6 as the root switching device to forward packets of VLAN3. In this way, all VLANs can communicate with each other, and packets of different VLANs are forwarded along different paths, realizing load balancing. Basic Concepts
MSTP Network
As shown in the figure below, the MSTP network contains one or more MST regions (MST Regions), and each MST Region contains one or more MSTIs. MSTI is composed of switching equipment running STP/RSTP/MSTP. MSTI is a tree network formed by all switching equipment running STP/RSTP/MSTP after MSTP protocol calculation. Figure1216 MSTP Network Diagram
MST Region
The MST region is a Multiple Spanning Tree Region, which consists of multiple switching devices in the switching network and the network segments between them. Devices in the same MST region have the following characteristics:
- MSTP is enabled.
- Has the same region name.
- Has the same VLAN to Spanning Tree instance mapping configuration.
- Has the same MSTP revision level configuration.
A LAN can have multiple MST regions, and the MST regions are physically connected directly or indirectly. Users can divide multiple switching devices into the same MST region through MSTP configuration commands. As shown in the figure below, MST Region D0 consists of switching devices S1, S2, S3 and S4, and there are 3 MSTIs in the region. Figure1217 Basic Concept Diagram of MST Region
VLAN mapping table
VLAN mapping table is an attribute of MST region, which describes the mapping relationship between VLAN and MSTI. As shown in the figure above, the VLAN mapping table of MST region D0 is: VLAN1 maps to MSTI1 VLAN2 and VLAN3 are mapped to MSTI2 The rest of the VLANs are mapped to MSTI0
Regional Root
Regional Root is divided into IST (Internal Spanning Tree) regional root and MSTI regional root. The IST regional root is shown in Figure1219. In B0, C0 and D0, the switching device closest to the total root (CIST Root) in the IST spanning tree is the IST regional root. Multiple spanning trees can be generated in one MST region, and each spanning tree is called an MSTI. The MSTI regional root is the root of each multiple spanning tree instance. As shown in Figure1218, different MSTIs in the region have their own regional root. Figure1218 MSTI basic concept diagram MSTIs are independent of each other, and MSTIs can correspond to one or more VLANs. But a VLAN can only correspond to one MSTI.
Master Bridge
The Master Bridge, also known as the IST Master, is the switching device closest to the root in the region. S1 as in Figure1217. If the master root is in the MST region, then the master root is the master bridge for this region. CIST Root Figure1219 MSTP network basic concept diagram As shown above, the total root is the root bridge of CIST (Common and Internal Spanning Tree). The total root is a device in area A0.
CST
Common Spanning Tree (CST) is a spanning tree that connects all MST regions in a switched network. If each MST region is regarded as a node, the CST is a spanning tree calculated and generated by these nodes through the STP or RSTP protocol. As shown in Figure1219, thicker lines connect fields to form CST.
IST
Internal Spanning Tree IST (Internal Spanning Tree) is a spanning tree in each MST region. IST is a special MSTI, the ID of MSTI is 0, usually called MSTI0. IST is a fragment of CIST in the MST region. As shown in Figure1219, the thinner lines in the region connect all switching devices in the region to form the IST.
CIST
Common and Internal Spanning Tree CIST is calculated and generated by STP or RSTP protocol, connecting all switching devices in a single spanning tree in a switching network. As shown in Figure1219, the IST plus CST of all MST regions constitutes a complete spanning tree, namely CIST.
SST
There are two cases of forming a single spanning tree SST (Single Spanning Tree): A switching device running STP or RSTP can only belong to one spanning tree. There is only one switching device in the MST region, and this switching device constitutes a single spanning tree. As shown in Figure1219, the switching device in B0 is a single spanning tree.
Port role
MSTP adds 2 new ports based on RSTP. MSTP has 7 port roles: root port, designated port, alternate port, backup port, edge port, master port and regional edge port. The functions of root port, designated port, alternate port, backup port and edge port are the same as those defined in RSTP protocol. All port roles defined in MSTP are shown in the following table. Table1211 Port Role Port Role
Root port
On a non-root bridge, the port closest to the root bridge is the root port of this switch. The root switch device has no root port. The root port is responsible for forwarding data to the root of the tree. As shown in Figure1220, S1 is the root bridge, CP1 is the root port of S3, and BP1 is the root port of S2.
Designated port
For a switching device, its designated port is the port that forwards BPDUs to downstream switching devices. As shown in Figure1220, AP2 and AP3 are designated ports of S1, and CP2 is designated port of S3.
Alternate port
From the perspective of sending configuration BPDUs, the alternate port is a port that is blocked by learning configuration BPDUs sent by other bridges. From a user traffic perspective, the Alternate port provides another switchable path from the designated bridge to the root, acting as a backup port to the root port. As shown in Figure1220, BP2 is an alternate port.
Backup port
From the perspective of sending configuration BPDUs, the Backup port is a port that is blocked by learning the configuration BPDUs sent by itself. From the perspective of user traffic, the Backup port acts as a backup of the designated port, providing another backup path from the root node to the leaf node. As shown in Figure1220, CP3 is the backup port.
Master port
The master port is the port on the shortest path among all paths connecting the MST region to the general root. It is the port on the switching device that connects the MST region to the general root. The master port is the only way for packets in the region to go to the master root. The master port is a special regional edge port. The role of the master port on the CIST is the root port, and the role of the master port on other instances is the master port. As shown in Figure1221, the switching devices S1, S2, S3, S4 and the links between them constitute an MST region, and the port AP1 of the S1 switching device is in all ports in the region to the total root The path cost is the least, so AP1 is the master port.
Regional Edge Port
A regional edge port is a port located at the edge of an MST region and connected to other MST regions or SSTs. When performing MSTP calculations, the role of the regional edge port on the MSTI is the same as the role of the CIST instance. That is, if the role of the edge port on the CIST instance is the Master port (the port on the shortest path among all paths connecting the region and the general root), then its role on all MSTIs in the region is also the Master port. As shown in Figure1221, AP1, DP1 and DP2 in the MST region are directly connected to other regions, and they are all regional edge ports in this MST region. The role of regional edge ports on spanning tree instances is the same as on CIST. For example, in Figure1221, AP1 is the regional edge port, and its role in the CIST is the master port, then the role of AP1 in all spanning tree instances in the MST region is the master port.
Edge Port
If the designated port is located at the edge of the entire region and is no longer connected to any switching device, this port is called an edge port. Edge ports are generally connected directly to user terminal equipment. After the MSTP function is enabled on a port, the automatic edge port detection function will be enabled by default. When the port does not receive BPDUs within (2 × Hello Timer + 1) seconds, the port will be automatically set to Edge port, otherwise set to non-edge port. Figure1220 Root Port, Designated Port, Alternate Port and Backup Port Schematic Figure1221 Master Port and Regional Edge Port Diagram
MSTP port status
The port state defined by MSTP is the same as that defined in the RSTP protocol, as shown in the following table. Table1212 Port Status Port Status
Forwarding
In this state, the port both forwards user traffic and receives/sends BPDUs.
Learning
This is a transitional state. Under Learning, the switching device will build a MAC address table according to the received user traffic, but will not forward the user traffic, so it is called the learning state. The port in the Learning state receives/sends BPDUs and does not forward user traffic.
Discarding
The port in Discarding state only receives BPDU packets. Port status and port role are not necessarily related. The following table shows the port status that various port roles can have. Table1213 Port Status and Port Role Correspondence Table
Port Status
Root Port/Master Port Designated port Regional Edge Port Alternate port Backup port Forwarding Yes Yes Yes No No Learning Yes Yes Yes No No Discarding Yes Yes Yes Yes
Yes
Yes: indicates the port support status. No: indicates that the port is not supported.
Message Format
MSTP uses Multiple Spanning Tree Bridge Protocol Data Unit (MST BPDU) as the basis for spanning tree calculation. MST BPDUs are used to calculate spanning tree topology, maintain network topology, and communicate topology change records. The difference between configuration BPDUs defined in STP, RST BPDUs defined in RSTP, MST BPDUs defined in MSTP, and TCN BPDUs is shown in the following table. Table1214 Four BPDU Difference Comparison Version Type
Name
0x00
Configuration BPDU
0x80
TCN BPDU
0x02
RST BPDU
0x02 MST BPDU
MSTP message format
The structure of the MST BPDU is shown in the figure below. Figure1222 MST BPDU structure Whether it is an intra-region MST BPDU or an inter-region MST BPDU, the first 36 bytes are the same as the RST BPDU. Starting from the 37th byte is an MSTP-specific field. The last MSTI configuration information field consists of several MSTI configuration information groups concatenated. The main information in the MST BPDU is shown in the table below. Table1215 Main information description in MST BPDU
Field Content
bytes
Protocol Identifier
Protocol identifier.
Protocol Version Identifier
Protocol version identifier, STP is 0, RSTP is 2, MSTP is 3.
BPDU Type
BPDU type: 0x00: Configuration BPDU of STP 0x80: STP TCN BPDU (Topology Change Notification BPDU) 0x02: RST BPDU (Rapid Spanning-Tree BPDU) or MST BPDU (Multiple Spanning-Tree BPDU)
CIST Flags
CIST flag field.
CIST Root Identifier
CIST 's total root exchange device ID.
CIST External Path Cost
The CIST external path cost refers to the cumulative path cost from the MST region to which this switching device belongs to the MST region to which the CIST root switching device belongs. CIST external path cost is calculated based on link bandwidth.
CIST Regional Root Identifier
Indicates the ID of the regional root switching device on the CIST, that is, the IST master ID. If the root is in this region, the CIST Regional Root Identifier is the same as the CIST Root Identifier.
CIST Port Identifier
The designated port ID of this port in IST.
Message Age
BPDU lifetime.
Max Age
The maximum lifetime of a BPDU packet. If the timeout expires, the link to the root switching device is considered to be faulty.
Hello Time
Hello timer, the default is 2 seconds.
Forward Delay
Forward Delay timer, the default is 15 seconds. Version 1 Length Version1 BPDU length, the value is fixed to 0. Version 3 Length Version3 length of BPDU.
MST Configuration Identifier
51 MST configuration identifier, indicating the label information of the MST region, including 4 fields.
CIST Internal Root Path Cost
CIST internal path cost refers to the cumulative path cost from this port to the IST Master switching device. CIST internal path cost is calculated based on link bandwidth.
CIST Bridge Identifier
Indicates the ID of the designated switching device on the CIST. Indicates the remaining hops of the BPDU in the CIST. The remaining hops of the BPDU in the CIST. MSTI Configuration Messages(may be absent) 16 MSTI configuration information. The configuration information of each MSTI occupies 16 bytes. If there are n MSTIs, it occupies n×16 bytes. The maximum number of BPDUs that the port can send within each Hello Time is configurable Hello Time is used by the Spanning Tree Protocol to periodically send configuration messages to maintain the stability of the spanning tree. If the switching device does not receive a BPDU within a period of time, it will recalculate the spanning tree due to message timeout. When a switching device becomes the root switching device, the switching device will send BPDUs at the interval of the set value. The non-root switching device adopts the Hello Time value set by the root switching device. Topology Calculation
MSTP rationale
MSTP can divide the entire Layer 2 network into multiple MST regions, and CST is generated between each region through calculation. In the region, multiple spanning trees are generated by calculation, and each spanning tree is called a multiple spanning tree instance. where instance 0 is called IST, and the other multiple spanning tree instances are MSTI. MSTP, like STP, uses configuration messages to calculate spanning tree, but the configuration messages carry the configuration information of MSTP on the device. priority vector Both MSTI and CIST are calculated from priority vectors, which are included in the MST BPDU. The switching devices exchange MST BPDUs with each other to generate MSTI and CIST.
- Introduction to Priority Vectors
The priority vector participating in the CIST calculation is: < Root Switch ID, External Path Cost, Regional Root ID, Internal Path Cost, Designated Switch ID, Designated Port ID, Receive Port ID > The priority vector participating in MSTI calculation is: < Regional Root ID, internal path cost, designated switching device ID, designated port ID, receiving port ID > The priority of the vectors in parentheses decreases from left to right. The following table explains each priority vector. Table1216 Vector Description Vector Name
Root Switch Device ID
The root switch ID is used to select the root switch in CIST. Root Switch ID = Priority(16bits) + MAC(48bits). Where Priority is the priority of MSTI0. External Path Cost (ERPC) Path cost from the regional root of CIST to the total root. The external path cost stored on all switching devices in the MST region is the same. If the CIST root switching device is in the region, the external path cost stored on all switching devices in the region is 0.
Regional Root ID
Regional Root ID is used to select the regional root in MSTI. Regional Root ID = Priority(16bits) + MAC(48bits). Where Priority is the priority of MSTI0. Internal Path Cost (IRPC) The path cost of this bridge to reach the regional root. The internal path cost stored by the regional edge port is greater than the internal path cost stored by the non-regional edge port.
Specify switch device ID
The designated switching device of the CIST or MSTI instance is the nearest upstream bridge from this bridge to the regional root. If this bridge is the general root or regional root, specify the switching device as itself.
Specify port ID
Specify the port on the switching device that is connected to the root port on this device. Port ID = Priority(4 digits) + Port number(12 digits). The port priority must be an integer multiple of 16.
Receive port ID
The port that received the BPDU. Port ID = Priority(4 digits) + Port number(12 digits). The port priority must be an integer multiple of 16.
- Comparison Principle
Comparing the same vector, the vector with the smallest value has the highest priority. The priority vector comparison principle is as follows. First, compare the root swap device ID. If the root switch device ID is the same, then compare the external path cost. If the external path cost is the same, then compare the regional root ID. If the regional root ID is still the same, compare the internal path costs. If the internal path is still the same, then compare the designated switch ID. If the designated switch device ID is still the same, then compare the designated port ID. If the designated port ID is still the same, then compare the receiving port ID. If the configuration message contained in the BPDU received by the port is better than the configuration message saved on the port, the configuration message originally saved on the port is replaced by the newly received configuration message. The port also updates the global configuration message saved by the switching device. On the contrary, the newly received BPDU is discarded.
- Calculation of CIST
After comparing the configuration messages, select a switching device with the highest priority in the entire network as the root of the CIST. MSTP generates IST through calculation in each MST region; at the same time, MSTP treats each MST region as a single switching device, and generates CST between MST regions through calculation. CST and IST constitute the CIST of the entire switching device network.
- Calculation of MSTI
In the MST region, MSTP generates different spanning tree instances for different VLANs according to the mapping relationship between VLANs and spanning tree instances. Each spanning tree is calculated independently, and the calculation process is similar to that of STP. Characteristics of MSTI: Each MSTI calculates its own spanning tree independently and does not interfere with each other. The spanning tree calculation method of each MSTI is basically the same as that of STP. The spanning tree for each MSTI can have different roots and different topologies. Each MSTI sends BPDUs within its own spanning tree. The topology of each MSTI is determined by command configuration. The spanning tree parameters can be different for each port on different MSTIs. Each port can have different roles and states on different MSTIs. In a network running MSTP protocol, a VLAN packet will be forwarded along the following path: In the MST region, forward along its corresponding MSTI. Forwarding along CST between MST regions.
- MSTP handling of topology changes
MSTP topology change processing is similar to RSTP topology change processing, please refer to RSTP topology change processing. Fast Convergence Figure1223 P/A of MSTP Mechanism As shown in the figure above, in MSTP, the P/A mechanism works as follows: The upstream device sends a Proposal message requesting fast migration. After the downstream device receives it, it sets the port connected to the upstream device as the root port, and blocks all non-edge ports. The upstream device continues to send Agreement packets. After the downstream device receives it, the root port changes to the Forwarding state. The downstream device responds to the Agreement message. After the upstream device receives it, it sets the port connected to the downstream device as the designated port, and the designated port enters the Forwarding state.
Standard Specification
The protocol specifications related to spanning tree are:
- IEEE 802.1D: Media Access Control (MAC) Bridges
- IEEE 802.1w:Part 3: Media Access Control (MAC) Bridges—Amendment 2: Rapid Reconfiguration
- IEEE 802.1s: Virtual Bridged Local Area Networks—Amendment 3: Multiple Spanning Trees
Configuring
Default Configuration Parameters Default Working mode RSTP mode
Status
Global disabled, enabled on all ports
Device priority
32768
Port Priority
128
Calculation method of path cost
Dot1t, the IEEE 802.1t standard
Forward Delay Time
1500 centiseconds (15 seconds)
Hello Time
200 centiseconds (2 seconds)
Max Age Time
2000 centiseconds (20 seconds)
Configure STP Mode and Status
- Configure STP Mode
SWITCH(config)#spanning-tree mode <stp | rstp | mstp>
stp:Spanning tree protocol(IEEE 802.1d) rstp:Rapid spanning tree protocol(IEEE 802.1w) mstp:Multiple spanning tree protocol(IEEE 802.1s) The default is rstp mode. After the mode is switched, the spanning tree protocol is disabled by default and needs to be re-enabled. Global configuration mode.
SWITCH(config)#spanning-tree enable
SWITCH(config)#no spanning-tree enable
Enable/disable STP function; default disabled. Global configuration mode.
Configure STP Election Parameters
- Configure Device Priority
SWITCH(config)#spanning-tree priority <0-61440>
SWITCH(config)#no spanning-tree priority
SWITCH(config)#spanning-tree instance <1-63> priority <0-61440>
SWITCH(config)#no spanning-tree instance <1-63> priority
Configure/delete STP system priority; default 32768. Optional configuration. Global configuration mode.
SWITCH(config-if)#spanning-tree priority <0-240>
SWITCH(config-if)#spanning-tree instance <1-63> priority <0-240>
Configure port STP priority; default 128. Optional configuration. Interface configuration mode.
SWITCH(config-if)#spanning-tree path-cost <1-200000000>
SWITCH(config-if)#no spanning-tree path-cost
Configure/reset path cost of port; optional configuration. Interface configuration mode.
Configure Topology Convergence Parameters
- Configure Hello Time
SWITCH(config)#spanning-tree hello-time <1-10>
SWITCH(config)#no spanning-tree hello-time
Configure/reset the BPDU packet period, in seconds; the default is 2s. Optional configuration. Global configuration mode.
SWITCH(config)#spanning-tree forward-time <4-30>
SWITCH(config)#no spanning-tree forward-time
Config/reset STP port forwarding state delay time, in seconds; default is 15s. Optional configuration. Global configuration mode.
SWITCH(config)#spanning-tree max-age <6-40>
SWITCH(config)#no spanning-tree max-age
Configure/reset the lifetime of BPDU packets, in seconds; the default is 20s. Optional configuration. Hello Time, Forward-Delay Time, Max-Age Time need to follow the conditions: 2*(Hello Time + 1.0 seconds) <= Max-Age Time <= 2*(Forward-Delay – 1.0 seconds), otherwise it may lead to topology instability. The longest path of the STP/RSTP network is affected by this parameter. The default longest path is 20 devices. When there are more than 20 devices, the configuration needs to be modified (forward-delay 21s, max-age 40s can be configured) , the maximum support for the longest path is 40. Global configuration mode.
SWITCH(config)#spanning-tree max-hops <1-40>
SWITCH(config)#no spanning-tree max-hops
Configure/reset the maximum hop count for BPDU packets; the default is 20. Optional configuration. The longest path of the MSTP network is affected by this parameter. When there are more than 20 devices, the configuration needs to be modified, and the maximum is 40. MSTP is compatible with the max-age function, you need to adjust the max-age parameter at the same time, refer to the corresponding command. Global configuration mode.
Configure Edge Port
- Configure Edge Port
SWITCH(config-if)#spanning-tree <edgeport | autoedge>
SWITCH(config-if)#no spanning-tree <edgeport | autoedge>
Configure/delete the port Edge Port; if configured as edgeport, it means that the device directly connected to the port is not a bridge device and can be forwarded quickly; if configured as autoedge, it means that the port automatically identifies whether it is an edge port according to BPDU; it is disabled by default; Select configuration. Interface configuration mode.
SWITCH(config-if)#spanning-tree portfast
SWITCH(config-if)#no spanning-tree portfast
Configure/delete port portfast; the port will be forwarded directly after opening portfast. But the Port Fast Operational State will be disabled due to the receipt of BPDUs, so that it can normally participate in the STP algorithm and forwarding; it is disabled by default; optional configuration. Interface configuration mode.
Configure MST Parameters
- Enter MST Configuration Mode
SWITCH(config)#spanning-tree mst configuration
Enter MST configuration mode. Global configuration mode.
SWITCH(config-mst)# instance <1-63> vlan VLANID
SWITCH(config-mst)# no instance <1-63> vlan VLANID
Configure/delete the association between MST instance and VLAN; optional configuration. MST configuration mode.
SWITCH(config-mst)#region NAME
SWITCH(config-mst)#no region NAME
Configure/delete MST area name; optional configuration. MST configuration mode.
SWITCH(config-mst)#revision <0-65535>
Configure/delete the MST version number, the default is 0; optional configuration. MST configuration mode.
SWITCH(config-if)# spanning-tree instance <1-63>
SWITCH(config-if)# no spanning-tree instance <1-63>
Configure/delete port-instance association; optional configuration. By default, when configuring the instance and VLAN relationship, the system will automatically generate port and instance relationship data based on the VLAN and port relationship, and no manual configuration is required. After the instance configuration is ready, if the relationship between ports and VLANs is manually modified, such as adding/exiting all VLANs of an instance to ports, you need to manually maintain the relationship between ports and instances through this command. When there are major configuration changes, it is recommended to automatically generate port and instance data by reconfiguring the instance-VLAN relationship or restarting the device. MST configuration mode.
Configuration Protection Function
- Configure Root Guard
SWITCH(config-if)# spanning-tree guard root
SWITCH(config-if)#no spanning-tree guard root
Configure/delete port root guard; when the root guard function is enabled on an interface, the port role on all instances is forced to be the designated port. Once the port receives configuration information with a higher priority, the root guard The function will put the interface into the blocked state; default closed; optional configuration. Interface configuration mode.
SWITCH(config)#spanning-tree portfast bpdu-guard
SWITCH(config)#no spanning-tree portfast bpdu-guard
SWITCH(config-if)#spanning-tree portfast
SWITCH(config-if)#no spanning-tree portfast
or:
SWITCH(config-if)#spanning-tree bpdu-guard enable
SWITCH(config-if)#spanning-tree bpdu-guard disable
Configure/delete BPDU Guard; after the port has BPDU Guard enabled, if a BPDU is received on the port, it will enter the Error-disabled (blocked) state; optional configuration. Interface configuration mode.
SWITCH(config)#spanning-tree portfast bpdu-filter
SWITCH(config)#no spanning-tree portfast bpdu-filter
SWITCH(config-if)#spanning-tree portfast
SWITCH(config-if)#no spanning-tree portfast
or:
SWITCH(config-if)#spanning-tree bpdu-filter enable
SWITCH(config-if)#spanning-tree bpdu-filter disable
Configure/delete BPDU Filter; after the port opens BPDU Filter, it neither sends BPDU nor receives BPDU message; optional configuration. Interface configuration mode.
SWITCH(config-if)#spanning-tree restricted-tcn
SWITCH(config-if)#no spanning-tree restricted-tcn
SWITCH(config-if)#spanning-tree instance <1-63> restricted-tcn
SWITCH(config-if)#no spanning-tree instance <1-63> restricted-tcn
Configure/reset the topology change notification limit. After configuration, the port will not forward TC BPDUs, nor refresh the address table; optional configuration. Interface configuration mode.
SWITCH(config)#spanning-tree errdisable-timeout enable
SWITCH(config)#no spanning-tree errdisable-timeout enable
SWITCH(config)#spanning-tree errdisable-timeout interval <10-1000000>
SWITCH(config)#no spanning-tree errdisable-timeout interval
Configure/reset error port timeout feature. By default, the error port timeout function is not enabled, that is, the error port will never timeout and automatically recover, and must be recovered manually. The timeout unit is seconds, the default is 300 seconds; Optional configuration. Global configuration mode.
Other Optional Configuration
- Configure Transmit-Holdcount
SWITCH(config)#spanning-tree transmit-holdcount <1-10>
SWITCH(config)#no spanning-tree transmit-holdcount
Configure/reset the maximum number of BPDUs sent per second; default is 6. Optional configuration. Global configuration mode.
SWITCH(config-if)#spanning-tree link-type <auto | point-to-point | shared>
SWITCH(config-if)#no spanning-tree link-type
Configure/reset link type, default is auto. Optional configuration. auto: Automatic setting mode based on the duplex capability of link negotiation, full duplex is point-to-point connection. point-to-point: Enable fast forwarding. shared: Fast Forwarding is disabled. Interface configuration mode.
SWITCH#clear spanning-tree detected protocols
Force version checking on all ports. Execution mode.
SWITCH(config)#spanning-tree logging
SWITCH(config)#no spanning-tree logging
Configure logging. Global configuration mode.
Examples
Example for Configuring RSTP
Simplified topology: User P1 goes under S1, P2 goes under S2, P3{ 5> followed by S3; Requirement description: When the network is not faulty, the communication between users (ping)is ok When the network has a single chain failure, the communication between users is still ok Typical configuration: S1/S2/S3:
- Enter global configuration mode, configure to use rstp mode, enable stp switch:
Use rstp mode
spanning-tree mode rstp
Enable stp switch
spanning-tree enable
Example for Configuring MSTP
Simplified topology: Requirement description:
Users in the same VLAN communicate normally when the network is normal
Improve network reliability through redundant links; for example, for VLAN 10 20, a single link failure between Switch ABDs does not affect the communication of users under it. Configuration plan: The devices belong to the same region, the default ‘Default’ region is used here, no additional configuration is required VLAN 20 is a shared vlan and is directly assigned to CST Instance
VLAN
20 10 30 40 Typical configuration: Switch A : # Configure VLAN and port
SWITCH(config)#vlan 10,20,30,40
SWITCH(config)#interface gigabitEthernet0/9
SWITCH(config-if)#switchport mode trunk
SWITCH(config)#interface gigabitEthernet0/10
SWITCH(config-if)#switchport mode trunk
SWITCH(config-if)#switchport trunk allowed vlan 10,20
SWITCH(config)#interface gigabitEthernet0/11
SWITCH(config-if)#switchport mode trunk
SWITCH(config-if)#switchport trunk allowed vlan 20,30
# Configure MSTP instance
SWITCH(config)#spanning-tree mode mstp
SWITCH(config)#spanning-tree mst configuration
SWITCH(config-mst)#instance 1 vlan 10
SWITCH(config-mst)#instance 3 vlan 30
SWITCH(config-mst)#instance 4 vlan 40
# Enable MSTP
SWITCH(config)#spanning-tree enable
Switch B: # Configure VLAN and port
SWITCH(config)#vlan 10,20,30,40
SWITCH(config)#interface gigabitEthernet0/9
SWITCH(config-if)#switchport mode trunk
SWITCH(config-if)#switchport trunk allowed vlan 20,30
SWITCH(config)#interface gigabitEthernet0/10
SWITCH(config-if)#switchport mode trunk
SWITCH(config)#interface gigabitEthernet0/11
SWITCH(config-if)#switchport mode trunk
SWITCH(config-if)#switchport trunk allowed vlan 10,20
# Configure MSTP instance
SWITCH(config)#spanning-tree mode mstp
SWITCH(config)#spanning-tree mst configuration
SWITCH(config-mst)#instance 1 vlan 10
SWITCH(config-mst)#instance 3 vlan 30
SWITCH(config-mst)#instance 4 vlan 40
# Enable MSTP
SWITCH(config)#spanning-tree enable
Switch C: # Configure VLAN and port
SWITCH(config)#vlan 10,20,30,40
SWITCH(config)#interface gigabitEthernet0/9
SWITCH(config-if)#switchport mode trunk
SWITCH(config-if)#switchport trunk allowed vlan 20,40
SWITCH(config)#interface gigabitEthernet0/10
SWITCH(config-if)#switchport mode trunk
SWITCH(config-if)#switchport trunk allowed vlan 20,30
SWITCH(config)#interface gigabitEthernet0/11
SWITCH(config-if)#switchport mode trunk
SWITCH(config-if)#switchport trunk allowed vlan 20,30
# Configure MSTP instance
SWITCH(config)#spanning-tree mode mstp
SWITCH(config)#spanning-tree mst configuration
SWITCH(config-mst)#instance 1 vlan 10
SWITCH(config-mst)#instance 3 vlan 30
SWITCH(config-mst)#instance 4 vlan 40
# Enable MSTP
SWITCH(config)#spanning-tree enable
Switch D: # Configure VLAN and port
SWITCH(config)#vlan 10,20,30,40
SWITCH(config)#interface gigabitEthernet0/9
SWITCH(config-if)#switchport mode trunk
SWITCH(config-if)#switchport trunk allowed vlan 10,20
SWITCH(config)#interface gigabitEthernet0/10
SWITCH(config-if)#switchport mode trunk
SWITCH(config-if)#switchport trunk allowed vlan 20,40
SWITCH(config)#interface gigabitEthernet0/11
SWITCH(config-if)#switchport mode trunk
SWITCH(config-if)#switchport trunk allowed vlan 10,20
# Configure MSTP instance
SWITCH(config)#spanning-tree mode mstp
SWITCH(config)#spanning-tree mst configuration
SWITCH(config-mst)#instance 1 vlan 10
SWITCH(config-mst)#instance 3 vlan 30
SWITCH(config-mst)#instance 4 vlan 40
# Enable MSTP
SWITCH(config)#spanning-tree enable
Display Information
- View STP status
SWITCH# show spanning-tree
SWITCH# show spanning-tree mst instance <1-63>

