Maintaining and Configuring STP
Identifying Spanning Tree Port states and timers

If a Layer 2 port were to transition directly from an STP blocking to the forwarding state, the port could temporary create a data loop if the switch was not aware of all topology information at the time. For this reason STP introduces delay timers and port states that ensure that all STP information has been propagated to that switch before it will transition a port to a forwarding state.

Each Layer 2 port on a switch running STP exists in one of these five port states:

  • Blocking – In this state, the Layer 2 port is a nondesignated port and does not participate in frame forwarding. The port receives BPDUs to determine the location and Root ID of the root switch and what port roles (root, designated, or nondesignated) each switch port should assume in the final active STP topology.
  • Listening – In this state, spanning tree has determined that the port can participate in frame forwarding according to the BPDUs that the switch has received thus far. At this point, the switch port is not only receiving BPDUs, it is also transmitting its own BPDUs and informing adjacent switches that the switch port is preparing to participate in the active topology.
  • Learning – In this state, the Layer 2 port prepares to participate in frame forwarding and begins to populate the CAM table.
  • Forwarding – In this state, the Layer 2 port is considered part of the active topology and forwards frames and also sends and receives BPDUs.
  • Disabled – In this state, the Layer 2 port does not participate in spanning tree and does not forward frames.

Spanning Tree Timers
The amount of time that a port stays in the various port states is dependent upon the BPDU timers. Only the switch in the role of root bridge may send information through the tree to adjust the timers. The following three timers affect STP performance and state changes:

  • hello time – The hello time is the time between each BPDU that is sent on a port. This is equal to 2 seconds by default, but can be tuned to be between 1 and 10 seconds.
  • forward delay – The forward delay is the time spent in the listening and learning state. This is by default equal to 15 seconds for each state, but can be tuned to be between 4 and 30 seconds.
  • max_age – The max age timer controls the maximum length of time a switch port saves configuration BPDU information. This is 20 seconds by default, but can be tuned to be between 6 and 40 seconds.

When STP is enabled, every switch port in the network goes through the blocking state and the transitory states of listening and learning at power up. The ports then stabilize to the forwarding or blocking state. During a topology change, a port temporarily implements the listening and learning states for a specified period called the "forward delay interval."

These values allow adequate time for convergence in a network with switches seven Layer 2 hops from the furthest switch to switch. This is referred to as an STP diameter, and a maximum of seven is permitted. The STP diameter value can be adjusted to a lower value that will automatically adjust the forward delay and max age timers proportionally for the new diameter.

CAUTION:

Best practice suggests not to individually alter the spanning tree timers but to adjust them indirectly by configuring the diameter to reflect the actual network topology.