Spanning Tree Protocol (STP)
Spanning Tree Protocol (STP)
Spanning Tree Protocol (STP)
As the enterprise network expands, multi-switched networks are introduced to provide link layer
communication between a growing numbers of end systems. As new interconnections are formed
between multiple enterprise switches, new opportunities for building ever resilient networks are made
possible, however the potential for switching failure as a result of loops becomes ever more likely. It is
necessary that the spanning tree protocol (STP) therefore be understood in terms of behavior in
preventing switching loops, and how it can be manipulated to suit enterprise network design and
performance.
Layer 2 Redundancy
Enterprise growth results in the commissioning of multiple switches in order to support the
interconnectivity of end systems and services required for daily operations. The interconnection of
multiple switches however brings additional challenges that need to be addressed. Switches may be
established as single point-to-point links via which end systems are able to forward frames to
destinations located via other switches within the broadcast domain. The failure however of any point-
to-point switch link results in the immediate isolation of the downstream switch and all end systems to
which the link is connected. In order to resolve this issue, redundancy is highly recommended within any
switching network.
Redundant links are therefore generally used on an Ethernet switching network to provide link backup
and enhance network reliability. The use of redundant links, however, may produce loops that cause the
communication quality to drastically deteriorate, and major interruptions to the communication service
to occur.
Broadcast Storms
One of the initial effects of redundant switching loops comes in the form of broadcast storms. This
occurs when an end system attempts to discover a destination for which neither itself nor the switches
along the switching path are aware of. A broadcast is therefore generated by the end system which is
flooded by the receiving switch.
The flooding effect means that the frame is forwarded via all interfaces with exception to the interface
on which the frame was received. In the example, Host A generates a frame, which is received by Switch
B which is subsequently forwarded out of all other interfaces. An instance of the frame is received by
the connected switches A and C, which in turn flood the frame out of all other interfaces. The continued
flooding effect results in both Switch A and Switch C flooding instances of the frame from one switch to
the other, which in turn is flooded back to Switch B, and thus the cycle continues. In addition, the
repeated flooding effect results in multiple instances of the frame being received by end stations,
effectively causing interrupts and extreme switch performance degradation.
MAC Instability
Switches must maintain records of the path via which a destination is reachable. This is identified
through association of the source MAC address of a frame with the interface on which the frame was
received. Only one instance of a MAC address can be stored within the MAC address table of a switch,
and where a second instance of the MAC address is received, the more recent information takes
precedence.
In the example, Switch B updates the MAC address table with the MAC address of Host A and associates
this source with interface G0/0/3, the port interface on which the frame was received. As frames are
uncontrollably flooded within the switching network, a frame is again received with the same source
MAC address as Host A, however this time the frame is received on interface G0/0/2. Switch B must
therefore assume that the host that was originally reachable via interface G0/0/3 is now reachable via
G0/0/2, and will update the MAC address table accordingly. The result of this process leads to MAC
instability and continues to occur endlessly between both the switch port interfaces connecting to
Switch A and Switch C since frames are flooded in both directions as part of the broadcast storm effect.
Spanning tree works on the principle that redundant links be logically disabled to provide a loop free
topology, whilst being able to dynamically enable secondary links in the event that a failure along the
primary switching path occurs, thereby fulfilling the requirement for network redundancy within a loop
free topology. The switching devices running STP discover loops on the network by exchanging
information with one another, and block certain interfaces to cut off loops.
The removal of any potential for loops serves as the primary goal of spanning tree for which an inverted
tree type architecture is formed. At the base of this logical tree is the root bridge/switch. The root
bridge represents the logical center but not necessarily the physical center of the STP-capable network.
The designated root bridge is capable of changing dynamically with the network topology, as in the
event where the existing root bridge fails to continue to operate as the root bridge. Non-root bridges
are considered to be downstream from the root bridge and communication to non-root bridges flows
from the root bridge towards all non-root bridges. Only a single root bridge can exist in a converged STP-
capable network at any one time.
Bridge ID
Discovery of the root bridge for an STP network is a primary task performed in order to form the
spanning tree. The STP protocol operates on the basis of election, through which the role of all switches
is determined.
A bridge ID is defined as the means by which the root bridge is discovered. This comprises of two parts,
the first being a 16 bit bridge priority and the second, a 48 bit MAC address.
The device that is said to contain the highest priority (smallest bridge ID) is elected as the root bridge for
the network. The bridge ID comparison takes into account initially the bridge priority, and where this
priority value is unable to uniquely identify a root bridge, the MAC address is used as a tie breaker. The
bridge ID can be manipulated through alteration to the bridge priority as a means of enabling a given
switch to be elected as the root bridge, often in support of an optimized network design.
Bridge Protocol Data Unit
The spanning tree topology relies on the communication of specific information to determine the role
and status of each switch in the network. A Bridge Protocol Data Unit (BPDU) facilitates communication
within a spanning tree network. Two forms of BPDU are used within STP. A Configuration BPDU is
initially created by the root and propagated downstream to ensure all non-root bridges remain aware of
the status of the spanning tree topology and importantly, the root bridge. The Topology Change
notification (TCN) BPDU is a second form of BPDU, which propagates information in the upstream
direction towards the root and shall be introduced in more detail as part of the topology change
process.
Bridge Protocol Data Units are not directly forwarded by switches, instead the information that is
carried within a BPDU is often used to generate a switches own BPDU for transmission. A Configuration
BPDU carries a number of parameters that are used by a bridge to determine primarily the presence of a
root bridge and ensure that the root bridge remains the bridge with the highest priority. Each LAN
segment is considered to have a designated switch that is responsible for the propagation of BPDU
downstream to non-designated switches.
The Bridge ID field is used to determine the current designated switch from which BPDU are expected to
be received. The BPDU is generated and forwarded by the root bridge based on a Hello timer, which is
set to 2 seconds by default. As BPDU are received by downstream switches, a new BPDU is generated
with locally defined parameters and forwarded to all non-designated switches for the LAN segment.
Path Cost
Another feature of the BPDU is the propagation of two parameters relating to path cost. The root path
cost (RPC) is used to measure the cost of the path to the root bridge in order to determine the spanning
tree shortest path, and thereby generate a loop free topology. When the bridge is the root bridge, the
root path cost is 0.
The path cost (PC) is a value associated with the root port, which is the port on a downstream switch
that connects to the LAN segment, on which a designated switch or root bridge resides. This value is
used to generate the root path cost for the switch, by adding the path cost to the RPC value that is
received from the designated switch in a LAN segment, to define a new root path cost value. This new
root path cost value is carried in the BPDU of the designated switch and is used to represent the path
cost to the root.
Spanning Tree Port Roles
A converged spanning tree network defines that each interface be assigned a specific port role. Port
roles are used to define the behavior of port interfaces that participate within an active spanning tree
topology. For the spanning tree protocol, three port roles of designated, root and alternate are defined.
The designated port is associated with a root bridge or a designated bridge of a LAN segment and
defines the downstream path via which Configuration BPDU are forwarded. The root bridge is
responsible for the generation of configuration BPDU to all downstream switches, and thus root bridge
port interfaces always adopt the designated port role.
The root port identifies the port that offers the lowest cost path to the root, based on the root path
cost. The example demonstrates the case where two possible paths exist back to the root, however only
the port that offers the lowest root path cost is assigned as the root port. Where two or more ports
offer equal root path costs, the decision of which port interface will be the root port is determined by
comparing the bridge ID in the configuration BPDU that is received on each port.
Any port that is not assigned a designated or root port role is considered an alternate port, and is able to
receive BPDU from the designated switch for the LAN segment for the purpose of monitoring the status
of the redundant link, but will not process the received BPDU.
Port ID
The port ID represents a final means for determining port roles alongside the bridge ID and root path
cost mechanism. In scenarios where two or more ports offer a root path cost back to the root that is
equal and for which the upstream switch is considered to have a bridge ID that is equal, primarily due to
the upstream switch being the same switch for both paths, the port ID must be applied to determine the
port roles.
The port ID is tied to each port and comprises of a port priority and a port number that associates with
the port interface. The port priority is a value in the range of 0 to 240, assigned in increments of 16, and
represented by a value of 128 by default. Where both port interfaces offer an equal port priority value,
the unique port number is used to determine the port roles. The highest port identifier (the lowest port
number) represents the port assigned as the root port, with the remaining port defaulting to an
alternate port role.
Timers
The root bridge is responsible for the generation of configuration BPDU based on a BPDU interval that is
defined by a Hello timer. This Hello timer by default represents a period of 2 seconds. A converged
spanning tree network must ensure that in the event of a failure within the network, which switches
within the STP enabled network are made aware of the failure. A Max Age timer is associated with each
BDPU and represents life span of a BPDU from the point of conception by the root bridge, and ultimately
controls the validity period of a BDPU before it is considered obsolete. This MAX Age timer by default
represents a period of 20 seconds.
Once a configuration BPDU is received from the root bridge, the downstream switch is considered to
take approximately 1 second to generate a new BPDU, and propagate the generated BPDU downstream.
In order to compensate for this time, a message age (MSG Age) value is applied to each BPDU to
represent the offset between the MAX Age and the propagation delay, and for each switch this message
age value is incremented by 1.
As BPDU are propagated from the root bridge to the downstream switches the MAX Age timer is
refreshed. The MAX Age timer counts down and expires when the MAX Age value exceeds the value of
the message age, to ensure that the lifetime of a BPDU is limited to the MAX Age, as defined by the root
bridge. In the event that a BPDU is not received before the MAX Age timer expires, the switch will
consider the BPDU information currently held as obsolete and assume an STP network failure has
occurred.
Root Election Process
The spanning tree convergence process is an automated procedure that initiates at the point of switch
startup. All switches at startup assume the role of root bridge within the switching network. The default
behavior of a root bridge is to assign a designated port role to all port interfaces to enable the
forwarding of BPDU via all connected port interfaces. As BPDU are received by peering switches, the
bridge ID will be compared to determine whether a better candidate for the role of root bridge exists. In
the event that the received BPDU contains an inferior bridge ID with respect to the root ID, the receiving
switch will continue to advertise its own configuration BPDU to the neighboring switch.
Where the BDPU is superior, the switch will acknowledge the presence of a better candidate for the role
of root bridge, by ceasing to propagate BPDU in the direction from which the superior BPDU was
received. The switch will also amend the root ID field of its BPDU to advertise the bridge ID of the root
bridge candidate as the current new root bridge.
- An additional mechanism must be introduced to handle the MAC entries timeout period issue
that results in invalid path entries being maintained following spanning tree convergence. The
process implemented is referred to as the Topology Change Notification (TCN) process, and
introduces a new form of BPDU to the spanning tree protocol operation.
- This new BPDU is referred to as the TCN BPDU and is distinguished from the original STP
configuration BPDU through the setting of the BPDU type value to 128 (0x80). The function of
the TCN BPDU is to inform the upstream root bridge of any change in the current topology,
thereby allowing the root to send a notification within the configuration BPDU to all
downstream switches, to reduce the timeout period for MAC address table entries to the
equivalent of the forward delay timer, or 15 seconds by default.
- The flags field of the configuration BPDU contains two fields for Topology Change (TC) and
Topology Change Acknowledgement (TCA). Upon receiving a TCN BPDU, the root bridge will
generate a BPDU with both the TC and TCA bits set, to respectively notify of the topology
change and to inform the downstream switches that the root bridge has received the TCN BPDU,
and therefore transmission of the TCN BPDU should cease.
- The TCA bit shall remain active for a period equal to the Hello timer (2 seconds), following which
configuration BPDU generated by the root bridge will maintain only the TC bit for a duration of
(MAX Age + forward delay), or 35 seconds by default.
- The effect of the TCN BPDU on the topology change process ensures that the root bridge is
notified of any failure within the spanning tree topology, for which the root bridge is able to
generate the necessary flags to flush the current MAC address table entries in each of the
switches. The example demonstrates the results of the topology change process and the impact
on the MAC address table. The entries pertaining to switch B have been flushed, and new
updated entries have been discovered for which it is determined that Host B is now reachable
via port interface Gigabit Ethernet 0/0/1.