Information About Spanning Tree Protocol
The following sections provide information about spanning tree protocol (STP), about BPDU, about RSTP and configuring STP.
About Spanning Tree Protocol
Spanning Tree Protocol (STP) is a Layer 2 link management protocol that provides path redundancy while preventing loops in the network. For a Layer 2 Ethernet network to function properly, only one active path can exist between any two stations. Multiple active paths among end stations cause loops in the network. If a loop exists in the network, end stations might receive duplicate messages. Devices might also learn end-station MAC addresses on multiple Layer 2 interfaces. These conditions result in an unstable network. Spanning-tree operation is transparent to end stations, which cannot detect whether they are connected to a single LAN segment or a switched LAN of multiple segments.
The STP uses a spanning-tree algorithm to select one device of a redundantly connected network as the root of the spanning tree. The algorithm calculates the best loop-free path through a switched Layer 2 network by assigning a role to each port based on the role of the port in the active topology:
-
Root—A forwarding port elected for the spanning-tree topology
-
Designated—A forwarding port elected for every switched LAN segment
-
Alternate—A blocked port providing an alternate path to the root bridge in the spanning tree
-
Backup—A blocked port in a loopback configuration
The device that has all its ports as the designated role or as the backup role is the root device. The device that has at least one of its ports in the designated role is called the designated device.
Spanning tree forces redundant data paths into a standby (blocked) state. If a network segment in the spanning tree fails and a redundant path exists, the spanning-tree algorithm recalculates the spanning-tree topology and activates the standby path.
About Bridge Protocol Data Unit
Devices send and receive spanning-tree frames, called bridge protocol data units (BPDUs), at regular intervals. The devices do not forward these frames but use them to construct a loop-free path. BPDUs contain information about the sending device and its ports, including device and MAC addresses, device priority, port priority, and path cost. Spanning tree uses this information to elect the root device and root port for the switched network and the root port and designated port for each switched segment.
About RSTP
Rapid Spanning Tree Protocol (RSTP) is an optimized version of the STP protocol. In RSTP the delay of entering the forwarding state is reduced when a port is selected as a root port and a designated port. This provides rapid convergence for the network to reach the topology stability.
The following lists the conditions under which RSTP works on ports.
-
Rapid convergence of the port state of the root port occurs when the previous root port on the device has stopped forwarding data and the upstream port has started forwarding data.
-
Rapid convergence of the port state of the designated port occurs when the designated port either is an edge port or connected to a point-to-point link.
If the designated port is an edge port, then the designated port can directly forward data.
If the designated port is connected with a point-to-point link, the device can forward data only after receiving the handshake from the downstream device.
Although RSTP can provide rapid convergence, compared to a STP it has certain limitations which are as follows.
-
All bridges in a LAN share the same spanning tree.
VLAN based redundant links cannot be blocked.
All VLAN messages are forwarded along a spanning tree.
Configuring STP
To configure STP on a device, you need to perform the following configurations.
-
Enable the STP. By default, all ports are included in the spanning tree topology. To disable spanning tree on a port, use the no spanning-tree command in configuration mode. After the spanning tree is enabled globally, RSTP is selected by default.
-
Configure time parameters. The device has the following three time parameters
-
Forward delay:
The default is 15 seconds. If the forward delay value is too small, a temporary redundant path is introduced. If the forward delay value is too big, the network does not resume communication for a long time. The range is 4-30 seconds.
The forward delay value must be greater than or equal to hello time interval.
-
Hello Time:
The default value is 2 seconds. A long Hello time value causes the bridge to consider a link failure and recalculate the spanning tree topology due to link message loss. A short Hello time value causes the bridge to constantly send configuration information which increases the internet and CPU load. The range is 1-10.
The Hello time value must be less than or equal to forward delay value
-
Max Age:
Max Age sets the maximum time interval for an STP message. If the time interval times out, the message is discarded. The Max Age time interval depends on the network diameter of the switching network. The default is 20 seconds. If the interval is too small, spanning tree calculation occurs more frequently and network congestion may be mistaken for network link failure. If the interval is too large, the network is not able to detect link failure. The Max Age interval ranges from 6-40.
Configure these three parameters on the switch for STP or RSTP calculation.
-
-
Configure path cost of a port. Configuring path cost of a port allows the port to easily become a root port or a designated port. The path cost of a port is dependent on the port speed. The higher the port speed, the smaller is the path cost of the port. STP automatically converts the port speed into the corresponding path cost.
Configuring the path cost of an Ethernet port will cause the spanning tree recalculations. The path cost range of a port is from 1 to 65,535. It is recommended to use the default value. The STP protocol calculates the path cost of the current port. By default, the path cost is determined from the speed of a specific port. The default value changes based on the port speed. For example, if the port speed is 10M, then the default value is 20,00,000, if the port speed is 100M, then the default value is 200,000 and if the port speed is 1000M the default value is 20,000. If the port speed is not available, then the path cost is set to 200,000 by default.
-
Configure port priority. Configuring the priority of a port, allows the port to become a root port. The lower the priority value is, the higher is the priority of the port. Changing the priority of an Ethernet port each time will cause the spanning tree recalculations. The priority values range from 0 to 240. The priority value must be an integer multiple of 16. By default, the priority of a port is set to 128.
-
Configure Mcheck. A device in RSTP mode is compatible with a device in STP mode. However, if two devices are in STP mode and one of the device changes to RSTP mode, then the devices continue communicating in STP mode. The Mcheck feature allows a port to send RSTP message to an adjacent port to confirm whether the adjacent port can work in RSTP mode also. Once a confirmation is received both ports work in RSTP mode.
-
Configure point to point link. In RSTP mode, a port enters a forwarding state immediately. Configuring a point to point link on a port stops the port from being a shared media link. You can either specify the link type of a port, or allow the link type to be determined automatically based on the port duplex mode.
The following list the conditions under which a port is and is not considered as a point to point link
-
A port in configured and full duplex mode is considered as a point to point link.
-
A port in half duplex mode is not considered as a point to point link.
-
A device with force mode set to true, the port is considered as a point to point link.
-
A device with force mode set to false, the port is not considered as a point to point link.
-
-
Configure a port as an edge port. An edge port is referred to a port if the port is connected to a terminal device such as a host, and if ports enters forwarding state in a short time after the linkup. Configuring the edge port is valid for RSTP mode only.
-
Set port to send the maximum rate of BPDU messages. The maximum rate of BPDU messages send by a port is the maximum number of BPDU messages send in each Hello time.
By default, a port sends 3 BPDU messages per Hello time.
-
Configure root protection for a port. A root bridge can receive a higher priority configuration message either due to human error or malicious attack on the network. This causes a change in the root bridge which affects network topology calculations. In this case, if the traffic was forwarded over a high-speed link, then the network topology change causes the traffic passing through the high-speed link to be traced to the low-speed link resulting in network congestion. Configuring root protection for the port avoids this.
A port with root protection enabled can only be a designated port. For a high priority configuration received on the port, the following two options are available for configuring the status of these ports:
-
Block-port: The port state is set to discard. BPDU configuration messages are discarded and data packets are not forwarded.
-
Drop-packets: The port state is set to forward. BPDU configuration messages are discarded, and data packets are forwarded.
-
-
Configure loop-guard. If a port in blocked state does not receive a BDPU confirmation message, it changes to a forwarding state. A loop-guard prevents a port in blocked state to change to forwarding state even if it does not receive a BDPU configuration message.
-
Configure BPDU committed access rate (CAR). A large number of BPDU messages forwarded to the CPU can affect CPU performance. Configuring the BPDU CAR limits the rate of BPDU messages forwarded to the CPU.
This feature is enabled by default.
-
Discard external BPDU messages. The discard external BPDU messages feature is used to drop BPDU messages from other networks which affects the spanning tree topology calculations.
Discard external BPDU messages feature is usually enabled on the edge port. You can enable this feature either globally or locally. To enable only certain designated ports to discard BPDU external messages, enable locally.
This feature is disabled by default.

Feedback