With PVST (Per Vlan STP), there is a different instance of STP for each VLAN. To derive the VLAN BID, the switch picks a different MAC address from its base pool for each VLAN. Each VLAN has its own root bridge, root port, and so on. You can configure these so that data flow is optimized, and traffic load is balanced among the switches. Spanning Tree is enabled by default on every VLAN.
Configuring Spanning TreeTo change the STP priority value, use the following:
Switch (config)#
spanning-tree vlan vlan_no.
priority valueTo configure a switch as root without manually changing priority values, use the following:
Switch (config)#
spanning-tree vlan vlan_no.
root {primary | secondary}To change the STP port cost for an access port, use the following:
Switch(config-if)#
spanning-tree cost valueTo change the STP port cost for a VLAN on a trunk port, use the following:
Switch(config-if)#
spanning-tree vlan vlan_no.
cost valueTo display STP information for a VLAN, use the following:
Switch#
show spanning-tree vlan vlan_no.To display the STP information for an interface, use the following:
Switch #
show spanning-tree interface interface_no. [detail]To verify STP timers, use the following:
Switch #
show spanning-tree bridge brief
Spanning Tree Enhancements
Cisco has some proprietary enhancements to Spanning Tree that help speed up network convergence. They include:
PortfastPortfast is for access (user) ports only. It causes the port to bypass the STP listening and learning states and transition directly to forwarding. Connecting a switch to a Portfast port can cause loops to develop.
(config-if)#
spanning-tree portfastUplinkFastUplinkFast is for speeding convergence when a direct link to an upstream switch fails. The switch identifies backup ports for the root port (these are called an uplink group). If the root port fails, then one of the ports in the uplink group is unblocked and transitions immediately to forwarding—it bypasses the listening and learning stages. It should be used in wiring closet switches with at least one blocked port. The command to enable uplinkfast is shown below. Please note that uplinkfast is enabled globally, so the command affects all ports and all VLANs.
(config)#
spanning-tree uplinkfastBackboneFastBackboneFast is used for speeding convergence when a link fails that is not directly connected to the switch. It helps the switch detect indirect failures. If a switch running BackboneFast receives an inferior BPDU from its designated bridge, it knows a link on the path to the root has failed. (An inferior BPDU is one that lists the same switch for root
bridge and designated bridge.)
The switch then tries to find an alternate path to the root by sending a Root Link Query (RLQ) frame out all alternate ports. The root then responds with an RLQ response, and the port receiving this response can transition to forwarding. Alternate ports are determined in this way:
- If the inferior BPDU was received on a blocked port, then the root port and any other blocked ports are considered alternates.
- If the inferior BPDU was received on the root port, then all blocked ports are considered alternates.
- If the inferior BPDU was received on the root port and there are no blocked ports, the switch assumes it has lost connectivity with the root and advertises itself as root.
Configure this command on all switches in the network:
(config)#
spanning-tree backbonefastRapid Spanning Tree (RSTP)Rapid Spanning Tree (RSTP) 802.1w is a standards-based, non-proprietary way of speeding STP convergence. Switch ports exchange an explicit handshake when they transition to forwarding. RSTP describes different port states than regular STP, as shown in the Table 3-3.
RSTP Port RolesRSTP also defines different Spanning Tree roles for ports:
- Root port—The best path to the root (same as STP).
- Designated port—Same role as with STP.
- Alternate port—A backup to the root port.
- Backup port—A backup to the designated port.
- Disabled port—One not used in the Spanning Tree.
- Edge port—One connected only to an end user.
BPDU Differences in RSTPIn regular STP, BPDUs are originated by the root and relayed by each switch. In RSTP, each switch originates BPDUs, whether or not it receives a BPDU on its root port. All eight bits of the BPDU type field are used by RSTP. The TC and TC Ack bits are still used. The other six bits specify the port’s role and its RSTP state, and are used in the port handshake. The RSTP BPDU is set to Type 2, Version 2. PVST is done by Rapid PVST+ on Catalyst switches.
RSTP Fast ConvergenceThe Rapid Spanning tree process understands and incorporates topology changes much quicker than the previous version.
- RSTP uses a mechanism similar to BackboneFast—When an inferior BPDU is received, the switch accepts it. If the switch has another path the root, it uses that and informs its downstream switch of the alternate path.
- Edge ports work the same as Portfast ports—They automatically transition directly to forwarding.
- Link type—If you connect two switches through a point-to-point link and the local port becomes a designated port, it exchanges a handshake with the other port to quickly transition to forwarding. Full-duplex links are assumed to be point-to-point, half-duplex links are assumed to be shared.
- Backup and alternate ports—Ports that can transition to forwarding when no BPDUs are received from a neighbor switch (similar to UplinkFast).
If an RSTP switch detects a topology change, it sets a TC timer to twice the hello time and sets the TC bit on all BPDUs sent out to its designated and root ports until the timer expires. It also clears the MAC addresses learned on these ports.
If an RSTP switch receives a TC BPDU, it clears the MAC addresses on that port and sets the TC bit on all BPDUs sent out its designated and root ports until the TC timer expires.
Multiple Spanning Tree (MST)With Multiple Spanning Tree (MST), you can group VLANs and run one instance of Spanning Tree for a group of VLANs. This cuts down on the number of root bridges, root ports, designated ports, and BPDUs in your network. Switches in the same MST Region share the same configuration and VLAN mappings. Configure MST with these commands:
To be compatible with 802.1Q trunking, which has one common Spanning Tree (CST) for all VLANs, MST runs one instance of an Internal Spanning Tree (IST). The IST appears as one bridge to a CST area and is MST instance number 0. The original MST Spanning Trees (called M-Trees) are active only in the region—they combine at the edge of the CST area to form one.