We know that STP can achieve link redundancy, but when the network link state changes, STP will re-elect the root switch, root port, designated port, etc., thus generating a new tree network topology. This election process makes STP convergence time longer (usually 30-50 seconds), and such a long convergence time is not enough for some applications. How to solve this problem? The convergence time can be significantly reduced (down to 1 second) by using an improved Rapid Spanning Tree Protocol (RSTP).

What is RSTP?

Rapid Spanning Tree Protocol was first proposed in IEEE 802.1W-2001. This protocol allows for faster convergence of the network when the network structure changes. It has one more port type than 802.1d: backup port type, which is used for backup of specified ports. STP is the abbreviation of Spanning Tree Protocol. This protocol can be applied to loop networks to achieve path redundancy through certain algorithms, and prune the loop network into a loop-free tree network, thus avoiding the proliferation and infinite loops of messages in the loop network.

1. Port States

In STP, ports may experience five operating states: blocking, listening, learning, forwarding and disabling. In RSTP, the port states are optimized and integrated, and the blocking, listening and disabling states of STP are combined into the discarding state, forming three states of discarding, learning and forwarding.

2. Port Roles

There are four types of port roles in STP: Root Port, Designated Port, Blocking Port, and Disabled Port. In addition to the port roles of STP, the port roles in RSTP add a backup port for the root port and a backup port for the designated port, which are Alternate Port (AP) and Backup Port (BP) respectively.

2.1. Root Port (RP)

The root port of RSTP is the same as the root port of STP. The root port is the port closest to the root switch on a non-root switch.

2.2. Designated Port (DP)

The Designated Port for RSTP is the same as the Designated Port for STP. The Designated Port is the port to which the switch is connected to the Ethernet and through which data is forwarded to the Ethernet.

2.3. Alternate Port (AP).

The Alternate Port is a new port role introduced by RSTP as a backup port to the root port. The replacement port can receive BPDU messages, but does not forward data. When the root port fails, the replacement port will become the root port.

2.4. Backup Port (BP).

Backup port is also a new port role introduced by RSTP, as a backup port for the specified port. The backup port can receive BPDU packets, but does not forward data. When the designated port fails, the backup port will become the designated port.

Why RSTP occur

Problems with STP:

  • Port state is too redundant (Listening, Learning, Blocking) state makes no difference to the user, are not forwarding user traffic
  • The algorithm is a passive algorithm, that is, how many seconds to wait before daring to judge the topology change
  • Slow convergence speed (passive algorithm 20s and port transition time 30s) [Listening to learning wait 15s, learning to forwarding wait 15s]
  • Not very scalable

The principle of STP is to block a port in the loop to achieve the purpose of breaking the loop, but then the loop problem is solved, but there is a new problem, that is, the convergence speed is too slow, especially with the increasing scale of LAN, the convergence problem becomes more and more serious, which prompted the creation of RSTP, which is mainly designed for the problem of slow convergence speed of STP.

Functions and Workflow of RSTP

1. Functions of RSTP

RSTP is fully backward compatible with the STP protocol. In addition to the same functions of loop avoidance and dynamic management of redundant links as the traditional STP protocol, RSTP greatly reduces topology convergence time. Under the ideal network topology size, all switching devices support RSTP protocol and are properly configured, the time to restore stability after topology change (link UP/DOWN) can be controlled in seconds, while the time required for the traditional topology to be stable and work properly is 50 seconds.

The main functions of RSTP can be summarized as the following two: discovering and generating an optimal tree topology for the LAN; discovering topology failures and recovering from them, automatically updating the network topology and enabling backup links, while maintaining the optimal tree structure.

The network switching device running RSTP protocol updates the system state machine, elects port roles and blocks certain ports by comparing the information of its own bridge with the information from other bridges in the received BPDUs, using the RSTP algorithm for calculation, cropping the ring network into a tree network, preventing the broadcast storms generated by message proliferation and infinite loops in the ring network, and avoiding the occurrence of the message processing capacity degradation problem brought about by this.

2. The workflow of RSTP

RSTP works with the same goal as STP, which is to produce a tree-like network. However, because RSTP uses a series of measures to improve the efficiency and shorten the convergence time.

Shorten Fault Discovery Time

In STP network, by default the root switch sends BPDUs from the designated port every 2 seconds (Hello Time), and when the non-root switch receives the BPDU, it will regenerate a new BPDU message and send it to the downstream switch from its own designated port. If the non-root switch does not receive a BPDU from the root switch port, it will not send a BPDU message to the downstream switch itself. In this way, when a switch in the network does not receive BPDU messages, it is not sure whether the link with the upstream switch has failed. It needs to wait until the switch’s survival timer reaches Maximum age (20 seconds by default) to determine that the network topology has changed and will send TCN BPDU messages to the root switch, which requires 20 seconds of waiting time, which is a long waiting time.

RSTP is different from STP. The RSTP root switch also sends BPDUs from the specified port every Hello Time (2 seconds by default) time, but for the non-root switch, it will send BPDUs containing its own information to the downstream switch every Hello Time time even if it does not receive BPDUs from the root switch. For the downstream switch, if the root port does not receive any BPDU message within 3 consecutive Hello Time times, then the switch will consider the link with the upstream switch to be faulty and perform aging process, and send TC BPDUs through other ports to notify other switches to perform aging process.RSTP does not have TCN BPDUs, so RSTP convergence time is greatly reduced.

Fast port state switching

In STP, after electing a port as the root port or a designated port, in order to prevent loop failures during the switching from blocking to forwarding state, the waiting delay time for the listening state (default 15 s) and learning state (default 15 s) is added to the switching process. the RSTP port can actively determine whether it can switch directly from the blocking state to the forwarding state, reducing the waiting time. For this purpose two new concepts, edge port and link type, are introduced in RSTP.

1. Edge ports.

An edge port is a port where the switch connects directly to a host; such ports do not generate link loops. It can directly switch from the blocking state to the forwarding state without a 30-second waiting delay and does not generate topology change notifications. If the edge port receives a BPDU message, it will immediately enter from the edge port state to the normal spanning tree port.

2. Link types.

In RSTP, the links are classified into point-to-point link types and shared link types. By default, if the port is working in full-duplex mode, then it is considered as point-to-point link type; if the port is working in half-duplex mode, then it is considered as shared link type.

In the point-to-point link type, the specified port on the RSTP switch can quickly switch from the blocking state to the forwarding state without waiting for the forwarding delay time (30 seconds) and without generating topology change notifications.

How to configure RSTP on a switch

By default, the Spanning Tree Protocol is off. To use the Spanning Tree Protocol, you must first enable it.

1. Enabling Spanning Tree Protocol

The command format to enable Spanning Tree Protocol is as follows.

  • switch(config)# spanning-tree

Using the no option of this command will turn off the spanning tree protocol, as in switch(config)#no spanning-tree.

2. Setting Spanning Tree Protocol Type

The switch has three types of Spanning Tree Protocol: Spanning Tree Protocol STP, Rapid Spanning Tree Protocol RSTP, and Multiple Spanning Tree Protocol MSTP. the default is Multiple Spanning Tree Protocol MSTP, and you can use the command to set the Spanning Tree Protocol type. The command format for setting the spanning tree protocol type is as follows.

  • switch(config)#spanning-tree mode mstp/rstp/stp

where mstp means multiple spanning tree protocol, rstp means fast spanning tree protocol, and stp means spanning tree protocol. To return the switch spanning tree protocol type to its default state, use the no spanning-tree mode command, such as switch(config)#no spanning-tree mode.

Tip: All switches in the network should have the same spanning tree type.

3. Setting switch priority

When the Spanning Tree Protocol elects the root switch, the switch with the lowest switch ID is elected as the root switch by comparing switch IDs.The switch ID is composed of “priority + MAC”.If you want a switch to be elected as the root switch, just set the switch priority to the highest (smallest value). The command format to set the switch priority is as follows.

  • switch(config)# spanning-tree priority priority

The priority is the switch priority, and the range is 0 to 61440, increasing in multiples of 4096. By default, the priority is 32768.

Tip: To restore the spanning-tree priority to the default value of 32768, you can use the no spanning-tree priority command, such as switch(config)#no spanning-tree priority.

4. Setting Port Priority

When the Spanning Tree Protocol elects the root port or designated port, it compares the port IDs of the switch ports, and the port with the smaller port D is elected as the root port or designated port. If you want a port to be elected as the root port or the designated port, just set the port priority to the highest (smallest) value. The command format for setting the port priority is as follows.

  • switch(config-if)#spanning-tree port-priority priority

The priority is the port priority, which ranges from 0 to 240, increasing in multiples of 16, and the default value is 128.

Tip: To restore the default mode, use the no spanning-tree port-priority command, such as switch(config-if)#no spanning-tree port-priority.

5. Displaying Spanning Tree Configuration Information

During the debugging process, it is often necessary to view the configuration information of the spanning tree protocol, including displaying the spanning tree configuration parameters and the port Spanning Tree status of ports, etc. The command format for displaying the switch spanning tree configuration information is as follows.

  • switch#show spanning-tree

The command format for displaying port spanning tree configuration information is as follows.

  • switch#show spanning-tree interface interface-id

The interface-id is the specified port type and number, for example, the command to show spanning-tree configuration information of Fa0/l port is switch #show spanning-tree interface fastethernet 0/1.

The command format for displaying port forwarding status information of spanning tree is as follows.

  • switch#show spanning-tree summary

Read More: