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. Switches 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 switch 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 switch that has all of its ports as the designated role or as the backup role is the root switch. The switch that has
at least one of its ports in the designated role is called the designated switch. 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. Switches send and receive spanning-tree
frames, called bridge protocol data units (BPDUs), at regular intervals. The switches do not forward these frames but use
them to construct a loop-free path. BPDUs contain information about the sending switch and its ports, including switch and
MAC addresses, switch priority, port priority, and path cost. Spanning tree uses this information to elect the root switch
and root port for the switched network and the root port and designated port for each switched segment.
When two ports on a switch are part of a loop, the spanning-tree port priority and path cost settings control which port is
put in the forwarding state and which is put in the blocking state. The spanning-tree port priority value represents the location
of a port in the network topology and how well it is located to pass traffic. The path cost value represents the media speed.
For detailed configuration information on STP see the following link:
http://www.cisco.com/c/en/us/td/docs/routers/access/interfaces/NIM/software/configuration/guide/4_8PortGENIM.html#pgfId-1079138
Important
|
If the router is factory-defaulted, write erased, or config-reset, the vlan database gets deleted. Even though the configuration
takes effect, interfaces need to be removed and re-applied.
|
Example: Spanning Tree Protocol Configuration
The following example shows configuring spanning-tree port priority of a Gigabit Ethernet interface. If a loop occurs, spanning
tree uses the port priority when selecting an interface to put in the forwarding state.
Router# configure terminal
Router(config)# interface GigabitEthernet 0/1/0
Router(config-if)# spanning-tree vlan 1 port-priority 64
Router(config-if)# end
The following example shows how to change the spanning-tree port cost of a Gigabit Ethernet interface. If a loop occurs, spanning
tree uses cost when selecting an interface to put in the forwarding state.
Router#configure terminal
Router(config)# interface GigabitEthernet 0/1/0
Router(config-if)# spanning-tree cost 18
Router(config-if)# end
The following example shows configuring the bridge priority of VLAN 10 to 33792:
Router# configure terminal
Router(config)# spanning-tree vlan 10 priority 33792
Router(config)# end
The following example shows configuring the hello time for VLAN 10 being configured to 7 seconds. The hello time is the interval
between the generation of configuration messages by the root switch.
Router# configure terminal
Router(config)# spanning-tree vlan 10 hello-time 7
Router(config)# end
The following example shows configuring forward delay time. The forward delay is the number of seconds an interface waits
before changing from its spanning-tree learning and listening states to the forwarding state.
Router# configure terminal
Router(config)# spanning-tree vlan 10 forward-time 21
Router(config)# end
The following example shows configuring maximum age interval for the spanning tree. The maximum-aging time is the number of
seconds a switch waits without receiving spanning-tree configuration messages before attempting a reconfiguration.
Router# configure terminal
Router(config)# spanning-tree vlan 20 max-age 36
Router(config)# end
The following example shows the switch being configured as the root bridge for VLAN 10, with a network diameter of 4.
Router# configure terminal
Router(config)# spanning-tree vlan 10 root primary diameter 4
Router(config)# exit