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 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 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.
Note |
The switch sends
keepalive messages (to ensure the connection is up) only on interfaces that do
not have small form-factor pluggable (SFP) modules.
|
Spanning-Tree Topology and BPDUs
The stable, active
spanning-tree topology of a switched network is controlled by these elements:
- The unique bridge ID (switch
priority and MAC address) associated with each VLAN on each switch.
- The spanning-tree path cost to
the root switch.
- The port identifier (port
priority and MAC address) associated with each Layer 2 STP-enabled interface.
When the switches in a
network are powered up, each functions as the root switch. Each switch sends a
configuration BPDU through all of its ports, or on the Cisco ME device, only
through the STP-enabled ports. The BPDUs communicate and compute the
spanning-tree topology. Each configuration BPDU contains this information:
- The unique bridge ID of the
switch that the sending switch identifies as the root switch
- The spanning-tree path cost to
the root
- The bridge ID of the sending
switch
- Message age
- The identifier of the sending
interface
- Values for the hello, forward
delay, and max-age protocol timers
When a switch receives a
configuration BPDU that contains superior information (lower bridge ID, lower
path cost, and so forth), it stores the information for that port. If this BPDU
is received on the root port of the switch, the switch also forwards it with an
updated message to all attached LANs for which it is the designated switch.
If a switch receives a
configuration BPDU that contains inferior information to that currently stored
for that port, it discards the BPDU. If the switch is a designated switch for
the LAN from which the inferior BPDU was received, it sends that LAN a BPDU
containing the up-to-date information stored for that port. In this way,
inferior information is discarded, and superior information is propagated on
the network
For more information on
BPDUs, see
Configuring Optional Spanning-Tree features.
Spanning-Tree Interface States
Propagation delays can
occur when protocol information passes through a switched LAN. As a result,
topology changes can take place at different times and at different places in a
switched network. When an STP port transitions directly from nonparticipation
in the spanning-tree topology to the forwarding state, it can create temporary
data loops. Interfaces must wait for new topology information to propagate
through the switched LAN before starting to forward frames. They must allow the
frame lifetime to expire for forwarded frames that have used the old topology.
Each Layer 2 interface
on a switch using spanning tree exists in one of these states:
- Blocking—The interface does not
participate in frame forwarding.
- Listening—The first
transitional state after the blocking state when the spanning tree determines
that the interface should participate in frame forwarding.
- Learning—The interface prepares
to participate in frame forwarding.
- Forwarding—The interface
forwards frames.
- Disabled—The interface is not
participating in spanning tree because of a shutdown port, no link on the port,
or no spanning-tree instance running on the port.
Configuring Port Priority
If a loop occurs,
spanning tree uses the port priority when selecting a spanning-tree port to put
into the forwarding state. You can assign higher priority values (lower
numerical values) to ports that you want selected first and lower priority
values (higher numerical values) to ones that you want selected last. If all
spanning-tree ports have the same priority value, spanning tree puts the port
with the lowest interface number in the forwarding state and blocks the other
interfaces.
Configuring Path Cost
The spanning-tree path
cost default value is derived from the media speed of an interface (port
running spanning tree or port channel of multiple ports running spanning tree).
If a loop occurs, spanning tree uses cost when selecting an interface to put in
the forwarding state. You can assign lower cost values to interfaces that you
want selected first and higher cost values that you want selected last. If all
NNIs (or port channels) have the same cost value, spanning tree puts the
interface with the lowest interface number in the forwarding state and blocks
the other interfaces.
Configuring the Switch Priority of a VLAN
You can configure the
switch priority and make it more likely that the switch is chosen as the root
switch.
Admin Edge and Auto Edge
These two values control
how a port is declared to be an edge port or not. An edge port, is a port which
is not connected to a bridge. If auto edge is enabled, then the port determine
whether a port is an edge port by registering for BPDUs, and if BPDUs are
received on that port.
The admin edge
determines what the port should start as being – edge or not.
Restricted Role and Restricted TCN
If restricted role is
enabled, it causes the port not to be selected as Root Port for the Common and
Internal Spanning Tree (CIST) or any Multiple Spanning Tree Instance (MSTI),
even if it has the best spanning tree priority vector. Such a port is selected
as an Alternate Port after the Root Port has been selected. If set, it can
cause lack of spanning tree connectivity. It can be set by a network
administrator to prevent bridges external to a core region of the network
influence the spanning tree active topology, possibly because those bridges are
not under the full control of the administrator. This feature is also known as
Root Guard.
If restricted TCN is
enabled, it causes the port not to propagate received topology change
notifications and topology changes to other ports. If set it can cause
temporary loss of connectivity after changes in a spanning tree's active
topology as a result of persistently incorrect learned station location
information. It is set by a network administrator to prevent bridges external
to a core region of the network, causing address flushing in that region,
possibly because those bridges are not under the full control of the
administrator or the physical link state of the attached LANs transits
frequently.