CiscoSwitch SpanningTreeProtocol
CiscoSwitch SpanningTreeProtocol
Note For complete syntax and usage information for the commands used in this chapter, refer to
Understanding How Spanning Tree Works, page 8-1 Default Spanning-Tree Conguration, page 8-12 Conguring Spanning-Tree, page 8-12
Spanning Tree Overview, page 8-2 Election of the Root Switch, page 8-2 Bridge Protocol Data Units, page 8-3 Spanning-Tree Timers, page 8-3 Creating the Spanning-Tree Topology, page 8-4 STP Port States, page 8-4 MAC Address Allocation, page 8-11 Spanning Tree and IEEE 802.1Q Trunks, page 8-11 Understanding How Spanning-Tree for Token Ring Works, page 8-11
Engine III or III F with a NetFlow Feature Card (NFFC) or NFFC II, you cannot enable or disable STP on a per-VLAN basis. STP must be enabled or disabled for all VLANs on the switch using the set spantree {enable | disable} all command.
When you create fault-tolerant internetworks, you must have a loop-free path between all nodes in a network. The spanning-tree algorithm calculates the best loop-free path throughout a switched network. Switches send and receive spanning-tree frames at regular intervals. The switches do not forward these frames, but use the frames to construct a loop-free path. Multiple active paths between stations cause loops in the network. If a loop exists in the network, hosts might receive duplicate messages. In addition, switches might learn host Media Access Control (MAC) addresses on multiple switch ports. These conditions result in an unstable network. Spanning tree denes a tree with a root switch and a loop-free path from the root to all switches in the extended Layer 2 network. STP 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.
The election of a unique root switch for each instance of spanning tree The election of a designated switch for every switched LAN segment The removal of loops in the switched network by blocking switch ports connected to redundant links
The switch with the highest bridge priority (the lowest numerical priority value) is elected as the root switch. If all switches are congured with the default priority (32768), the switch with the lowest MAC address in the Layer 2 network becomes the root switch. The spanning-tree root switch is the logical center of the spanning-tree topology in a switched network. All paths that are not needed to reach the root switch from anywhere in the switched network are placed in STP blocking mode.
8-2
BPDUs contain information about the transmitting switch and its ports, including switch and port MAC addresses, switch priority, port priority, and port cost. The STP uses this information to elect the root switch and root port for the switched network, as well as the root port and designated port for each switched segment.
The unique bridge ID (MAC address) associated with each switch The path cost to the root associated with each switch port The port identier (MAC address) associated with each switch port
The switch sends conguration BPDUs to communicate and compute the spanning-tree topology. Each conguration BPDU contains the following minimal information: The unique bridge ID of the switch that the transmitting switch believes to be the root switch The cost of the path to the root from the transmitting port The identier of the transmitting port
When a switch transmits a BPDU frame, all switches connected to the LAN on which the frame is transmitted receive the BPDU. When a switch receives a BPDU, it does not forward the frame but instead uses the information in the frame to calculate a BPDU, and, if the topology changes, initiate a BPDU transmission. A BPDU exchange results in the following:
One switch is elected as the root switch. The shortest distance to the root switch is calculated for each switch. A designated switch is selected. This is the switch closest to the root switch through which frames will be forwarded to the root. A root port for each switch is selected. This is the port providing the best path from the switch to the root switch. Ports included in the spanning tree are selected.
Spanning-Tree Timers
Table 8-1 describes the spanning-tree timers that affect the entire spanning-tree performance.
Table 8-1 Variable Hello timer Forward delay timer Maximum age timer Spanning-Tree Timers Description Determines how often the switch broadcasts Hello messages to other switches. Determines the amount of time a port will remain in the listening and learning states before entering the forwarding state. Determines the amount of time protocol information received on a port is stored by the switch.
Spanning-Tree Topology
RP C
DP
S5688
When the spanning-tree topology is calculated based on default parameters, the path between source and destination stations in a switched network might not be ideal. For instance, connecting higher-speed links to a port that has a higher number than the current root port can cause a root-port change. The goal is to make the fastest link the root port. For example, assume that port 2 on Switch B is a ber-optic link, and that port 1 on Switch B (an unshielded twisted-pair [UTP] link) is the root port. Network trafc might be more efcient over the high-speed ber-optic link. By changing the spanning-tree port priority or port cost for port 2 to a higher priority (lower numerical value) than port 1, port 2 becomes the root port.
8-4
From initialization to blocking From blocking to listening or to disabled From listening to learning or to disabled From learning to forwarding or to disabled From forwarding to disabled
Power-on initialization
Blocking state
Listening state
Disabled state
Learning state
When you enable spanning tree, every switch in the network goes through the blocking state and the transitory states of listening and learning at power up. If properly congured, each port stabilizes to the forwarding or blocking state. When the spanning-tree algorithm places a port in the forwarding state, the following process occurs:
1 The port is put into the listening state while it waits for protocol information that suggests it
S5691
Forwarding state
Blocking State
A port in the blocking state does not participate in frame forwarding, as shown in Figure 8-3. After initialization, a BPDU is sent to each port in the switch. A switch initially assumes it is the root until it exchanges BPDUs with other switches. This exchange establishes which switch in the network is the root. If there is only one switch in the network, no exchange occurs, the forward delay timer expires, and the ports move to the listening state. A switch always enters the blocking state following switch initialization.
Figure 8-3 Port 2 in Blocking State
Segment frames
Forwarding
BPDUs
Filtering database
System module
Frame forwarding
BPDUs
Data frames
Port 2
Blocking
Segment frames
Discards frames received from the attached segment. Discards frames switched from another port for forwarding. Does not incorporate station location into its address database. (There is no learning on a blocking port, so there is no address database update.) Receives BPDUs and directs them to the system module. Does not transmit BPDUs received from the system module. Receives and responds to network management messages.
8-6
Listening State
The listening state is the rst transitional state a port enters after the blocking state. The port enters this state when STP determines that the port should participate in frame forwarding. Figure 8-4 shows a port in the listening state.
Figure 8-4 Port 2 in Listening State
Forwarding
BPDUs
Filtering database
System module
Frame forwarding
Listening
Discards frames received from the attached segment. Discards frames switched from another port for forwarding. Does not incorporate station location into its address database. (There is no learning at this point, so there is no address database update.) Receives BPDUs and directs them to the system module. Processes BPDUs received from the system module. Receives and responds to network management messages.
Learning State
A port in the learning state prepares to participate in frame forwarding. The port enters the learning state from the listening state. Figure 8-5 shows a port in the learning state.
Figure 8-5 Port 2 in Learning State
Forwarding
BPDUs
Filtering database
System module
Frame forwarding
BPDUs
Port 2
Learning
Discards frames received from the attached segment. Discards frames switched from another port for forwarding. Incorporates station location into its address database. Receives BPDUs and directs them to the system module. Receives, processes, and transmits BPDUs received from the system module. Receives and responds to network management messages.
8-8
Forwarding State
A port in the forwarding state forwards frames, as shown in Figure 8-6. The port enters the forwarding state from the learning state.
Figure 8-6 Port 2 in Forwarding State
Forwarding
BPDUs
Filtering database
System module
Frame forwarding
Station addresses
BPDUs
Port 2
Forwarding
Forwards frames received from the attached segment. Forwards frames switched from another port for forwarding. Incorporates station location information into its address database. Receives BPDUs and directs them to the system module. Processes BPDUs received from the system module. Receives and responds to network management messages.
Disabled State
A port in the disabled state does not participate in frame forwarding or STP, as shown in Figure 8-7. A port in the disabled state is virtually nonoperational.
Figure 8-7 Port 2 in Disabled State
Forwarding
BPDUs
Filtering database
System module
Frame forwarding
Data frames
Disabled
Discards frames received from the attached segment. Discards frames switched from another port for forwarding. Does not incorporate station location into its address database. (There is no learning, so there is no address database update.) Receives BPDUs, but does not direct them to the system module. Does not receive BPDUs for transmission from the system module. Receives and responds to network management messages.
8-10
The Catalyst 5000 family switches use the IEEE 802.1D and IBM STPs on TrBRFs. The STP that runs on the TrCRF is either the Cisco or IEEE STP, depending on the bridging mode you congured for the TrCRF with the set vlan command.
Caution Certain TrBRF STP and TrCRF bridge mode congurations are incompatible and can
place the TrCRFs in a blocked state. For more information about these congurations, see the Setting the Spanning-Tree Port State section on page 8-19.
Conguring Spanning-Tree
These sections describe how to congure STP on any Ethernet, Fast Ethernet, Gigabit Ethernet, and Token Ring port-based VLANs:
8-12
Enabling Spanning Tree, page 8-13 Conguring the Root Switch, page 8-13 Conguring a Secondary Root Switch, page 8-14 Conguring the Global Port Priority, page 8-15 Conguring the Port-VLAN Priority, page 8-15 Conguring Global Port Cost, page 8-16 Conguring Port-VLAN Cost, page 8-17 Conguring the Bridge Priority, page 8-17 Conguring the Hello Time, page 8-18 Conguring the Forward-Delay Time, page 8-18 Conguring the Maximum Aging Time, page 8-18 Setting the STP Type for a TrBRF, page 8-19 Setting the Spanning-Tree Port State, page 8-19 Specifying the STP Functional Address for a TrBRF, page 8-20 Disabling STP, page 8-20
Depending on your hardware, you can enable spanning tree on a per-VLAN or a global basis. In either case, the switch maintains a separate instance of spanning tree for each VLAN (except on VLANs on which you disable spanning tree). On Catalyst 5000 family switches with Supervisor Engine II G or III G, or with Supervisor Engine III or III F with NFFC or NFFC II, you must enable spanning tree globally for all VLANs using the all keyword. If you do not specify the vlans, VLAN 1 is assumed. To enable spanning tree on a per-VLAN or global basis, perform this task in privileged mode:
Task
Step 1 Step 2
Command Enable spanning tree on a per-VLAN or global basis. Verify that spanning tree is enabled. set spantree enable [vlans] set spantree enable all show spantree [vlan]
This example shows how to enable spanning tree globally for all VLANs on a Catalyst 5000 family switch with Supervisor Engine III G:
Console> (enable) set spantree enable all Spantree enabled. Console> (enable)
Configuring Spanning-Tree
For example, if all switches in the network have the bridge priority for VLANs 100 through 200 set to the default value of 32768, entering the set spantree root 100-200 command on a switch will set the bridge priority for VLANs 100 through 200 to 8192, causing the switch to become the root switch for those VLANs. However, if the bridge priority for VLAN 150 on one of the other switches in the network is set to 4000, entering the set spantree root 100-200 command on another switch will set the bridge priority for VLANs 100 through 200 to 3999, again causing the switch to become the root switch for those VLANs. If reducing the bridge priority to 1 still does not make the switch the root switch for the specied VLANs, the system displays a message.
Note The root switch for each instance of spanning tree should be a backbone or distribution
Use the dia network_diameter keywords to specify the Layer 2 network diameter (that is, the maximum number of bridge hops between any two hosts in the Layer 2 network). When you specify the network diameter, the switch automatically picks an optimal Hello time, forward delay time, and maximum age time for a network of that diameter, which can signicantly reduce the spanning-tree convergence time. You can use the hello hello_time keywords to override the automatically calculated Hello time.
Note We recommend that you avoid conguring the Hello time, forward delay time, and maximum
To congure a switch as the root switch, perform this task in privileged mode:
Task Congure a switch as the root switch. Command set spantree root vlans [dia network_diameter] [hello hello_time]
This example shows how to congure the switch as the root switch for VLANs 110, with a network diameter of 4:
Console> (enable) VLANs 1-10 bridge VLANs 1-10 bridge VLANs 1-10 bridge VLANs 1-10 bridge Switch is now the Console> (enable) set spantree root 1-10 dia 4 priority set to 8192 max aging time set to 14 seconds. hello time set to 2 seconds. forward delay set to 9 seconds. root switch for active VLANs 1-6.
8-14
You can run this command on more than one switch to congure multiple backup root switches. Use the same network diameter and Hello time values as you used when conguring the primary root switch. To congure a switch as the secondary root switch, perform this task in privileged mode:
Task Congure a switch as the secondary root switch. Command set spantree root secondary vlans [dia network_diameter] [hello hello_time]
This example shows how to congure a switch as the secondary root switch for VLANs 22 and 24:
Console> (enable) set spantree root secondary 22,24 dia 5 hello 1 VLANs 22,24 bridge priority set to 16384. VLANs 22,24 bridge max aging time set to 10 seconds. VLANs 22,24 bridge hello time set to 1 second. VLANs 22,24 bridge forward delay set to 7 seconds. Console> (enable)
Command Change the global port priority for a switch port. Verify the port priority setting. set spantree portpri mod_num/port_num priority show spantree [mod_num/port_num]
This example shows how to change the global port priority for a port and verify the conguration:
Console> (enable) set spantree portpri 1/2 20 Bridge port 1/2 port priority set to 20. Console> (enable) show spantree 1/2 Port Vlan Port-State Cost Priority --------- ---- ------------- ----- -------1/2 1 blocking 19 20 1/2 100 forwarding 19 20 1/2 521 blocking 19 20 1/2 522 blocking 19 20 1/2 523 blocking 19 20 1/2 524 blocking 19 20 1/2 1003 not-connected 19 20 1/2 1005 not-connected 19 4 Console> (enable)
Group-method ------------
Configuring Spanning-Tree
To change the port-VLAN priority for a port, perform this task in privileged mode:
Task
Step 1 Step 2
Command Change the port-VLAN priority for a VLAN on a switch port. Verify the port-VLAN priority setting. set spantree portvlanpri mod_num/port_num priority [vlans] show spantree [mod_num/port_num]
This example shows how to change the port-VLAN priority on a port and verify the conguration:
Console> (enable) set spantree portvlanpri 1/2 1 100 Port 1/2 vlans 1-99,101-1004 using portpri 32. Port 1/2 vlans 100 using portpri 1. Port 1/2 vlans 1005 using portpri 4. Console> (enable) show spantree 1/2 Port Vlan Port-State Cost Priority Fast-Start --------- ---- ------------- ----- -------- ---------1/2 1 blocking 19 32 disabled 1/2 100 forwarding 19 1 disabled 1/2 521 blocking 19 32 disabled 1/2 522 blocking 19 32 disabled 1/2 523 blocking 19 32 disabled 1/2 524 blocking 19 32 disabled 1/2 1003 not-connected 19 32 disabled 1/2 1005 not-connected 19 4 disabled Console> (enable)
Group-method ------------
Command Change the global port cost for a switch port. Verify the port cost setting. set spantree portcost mod_num/port_num cost show spantree [mod_num/port_num]
This example shows how to change the global port cost on a port and verify the conguration:
Console> (enable) set spantree portcost 1/2 10 Spantree port 1/2 path cost set to 10. Console> (enable) show spantree 1/2 Port Vlan Port-State Cost Priority --------- ---- ------------- ----- -------1/2 1 forwarding 10 20 1/2 100 forwarding 10 20 1/2 521 forwarding 10 20 1/2 522 forwarding 10 20 1/2 523 forwarding 10 20 1/2 524 forwarding 10 20 1/2 1003 not-connected 10 20 1/2 1005 not-connected 10 4 Console> (enable)
Group-method ------------
8-16
Command Change the port-VLAN cost for a VLAN on a switch port. Verify the port-VLAN cost setting. set spantree portvlancost mod_num/port_num cost cost [vlans] show spantree [mod_num/port_num]
This example shows how to change the port-VLAN cost on a port and verify the conguration:
Console> (enable) set spantree portvlancost 1/2 cost 10 100 Port 1/2 VLANs 1-99,101-1005 have path cost 19. Port 1/2 VLANs 100 have path cost 10. Console> (enable) show spantree 1/2 Port Vlan Port-State Cost Priority Fast-Start Group-method --------- ---- ------------- ----- -------- ---------- -----------1/2 1 blocking 19 20 disabled 1/2 100 forwarding 10 20 disabled 1/2 521 blocking 19 20 disabled 1/2 522 blocking 19 20 disabled 1/2 523 blocking 19 20 disabled 1/2 524 blocking 19 20 disabled 1/2 1003 not-connected 19 20 disabled 1/2 1005 not-connected 19 4 disabled Console> (enable)
spantree root and set spantree root secondary commands to modify the bridge priority and related parameters.
To congure the spanning-tree bridge priority for a VLAN, perform this task in privileged mode:
Task
Step 1 Step 2
Command Set the bridge priority for a VLAN. Verify the conguration. set spantree priority bridge_priority [vlan] show spantree [vlan]
This example shows how to change the spanning-tree bridge priority for VLAN 100 to 8192:
Console> (enable) set spantree priority 8192 100 Spantree 100 bridge priority set to 8192. Console> (enable)
Configuring Spanning-Tree
spantree root and set spantree root secondary commands to modify the Hello time and related parameters.
To congure the spanning-tree bridge Hello time for a VLAN, perform this task in privileged mode:
Task
Step 1 Step 2
Command Set the Hello time for a VLAN. Verify the conguration. set spantree hello interval [vlan] show spantree [vlan]
This example shows how to change the spanning-tree Hello time for VLAN 100 to 7 seconds:
Console> (enable) set spantree hello 7 100 Spantree 100 hello time set to 7 seconds. Console> (enable)
spantree root and set spantree root secondary commands to modify the forward delay time and related parameters.
To congure the spanning-tree forward delay time for a VLAN, perform this task in privileged mode:
Task
Step 1 Step 2
Command Set the forward delay time for a VLAN. Verify the conguration. set spantree fwddelay delay [vlan] show spantree [vlan]
This example shows how to change the spanning-tree forward delay time for VLAN 100 to 21 seconds:
Console> (enable) set spantree fwddelay 21 100 Spantree 100 forward delay set to 21 seconds. Console> (enable)
Note Exercise care using this command. For most situations, we recommend that you use the set
spantree root and set spantree root secondary commands to modify the maximum aging time and related parameters.
To congure the spanning-tree maximum aging time for a VLAN, perform this task in privileged mode:
Task
Step 1 Step 2
Command Set the maximum aging time for a VLAN. Verify the conguration. set spantree maxage agingtime [vlan] show spantree [vlan]
This example shows how to change the spanning-tree maximum aging time for VLAN 100 to 36 seconds:
Console> (enable) set spantree maxage 36 100 Spantree 100 max aging time set to 36 seconds. Console> (enable)
TrBRF is running the IBM STP and the TrCRF is in SRT mode. TrBRF is running the IEEE STP and the TrCRF is in SRB mode.
For more information, see the Setting the Spanning-Tree Port State section on page 8-19. To specify the STP type for a TrBRF, perform this task in privileged mode:
Task Specify the STP type for a TrBRF. Command set vlan vlan_num stp {ieee | ibm}
This example shows how to specify the STP type for a TrBRF:
Console> (enable) set vlan 950 stp ieee Vlan 950 configuration successful Console> (enable)
TrBRF is running the IBM STP and the TrCRF is in SRT mode. TrBRF is running the IEEE STP and the TrCRF is in SRB mode.
Note If one of these congurations occurs, the logical ports are put in a blocked state and no STP
is run.
Configuring Spanning Tree 8-19
Configuring Spanning-Tree
You can use the set spantree portstate command to manually set the state of a logical port to blocked or forwarding mode. To set the state of a logical port manually, perform this task in privileged mode:
Task Manually set the state of a logical port. Command set spantree portstate trcrf {auto | block | forward} [trbrf]
Note If you disable spanning tree for a TrBRF using the set spantree disable command, the logical
ports of the TrBRF are placed in the forwarding state regardless of the state you congured using the set spantree portstate command.
This example shows how to manually set the STP state of a logical port:
Console> (enable) set spantree portstate 950 forward Portstate successfully set for tokenring crf 950 Console> (enable)
Disabling STP
Depending on your hardware, you can disable spanning tree on a per-VLAN or a global basis. On Catalyst 5000 family switches with Supervisor Engine II G or III G, or with Supervisor Engine III or III F with NFFC or NFFC II, you must disable spanning tree globally for all VLANs using the all keyword.
Note In a Token Ring environment, if you disable STP for a TrBRF, then all ports in TrCRFs with
If you do not specify the vlans, VLAN 1 is assumed. To disable spanning tree on a per-VLAN or global basis, perform this task in privileged mode:
Task Disable spanning tree on a per-VLAN or global basis. Command set spantree disable [vlans] set spantree disable all
8-20