Spanning Tree Protocol (STP)


  • large networks use multiple switches configured in a mesh or partial mesh topology to implement redundant links
    • multiple paths are a good network design
    • increase resiliency
  • Ethernet has no concept of “time to live” value for frames
    • so layer 2 broadcast and flooded traffic could continue to loop through a network with multiple paths indefinitely
  • the spanning tree protocol (STP) is a means for bridges or switches to organize themselves into a hierarchy and block loops
    • switch at the top of the hierarchy is the root
      • the root is the switch with the lowest ID
        • ID comprises:
          • priority value
          • MAC address
    • each switch determines the shortest path to the root bridge by exchanging information with other switches
      • this info is packaged as bridge protocol data unit (BPDU) multicast frames
    • different port roles are assigned to the interfaces participating in the spanning tree
      • root port is the port that forwards up to the root, possibly via intermediate switches
      • designated ports are ports that can forward traffic down through the network with the least cost
    • bridges exchange topology change notifications if devices are added or removed
      • changes the status of forwarding/blocked ports appropriately

Example

Image shows minimum configuration necessary to prevent loops in a network with three bridges/switches:

  • Root Bridge has two designated ports (DP) connected to Bridge A and Bridge B
  • Bridges A and B both have root ports (RP) connected back to the interfaces on the root bridge
  • Bridges A and B also have a connection directly to each other
    • on Bridge A, this interface is active and traffic for Bridge B can be forwarded directly over it
    • on Bridge B, the interface is blocked (BP) to prevent a loop
      • traffic for Bridge A must be forwarded via the Root Bridge

Configuration

  • if a switch support spanning true, it should operate by default without configuration
  • admin should set the priority value to predetermine the root bridge selection
    • root is usually part of a high-bandwidth backbone or core switch group
    • performance will suffer if a switch on a low bandwidth segment becomes root
  • can use the show spanning-tree command to report the current configuration
  • spanning-tree id root primary and spanning-tree id root secondary assigns a main and backup priority values to switches

Port states for spanning tree:

StateForwards Frames?Learns MACs?Notes
BlockingNoNoThe port drops all frames other than BPDUs.
ListeningNoNoThe port is listening for BPDUs to detect loops.
LearningNoYesThe port discovers the topology of the network and builds the MAC address table.
ForwardingYesYesThe port works as normal.
DisabledNoNoThe port has been disabled by the administrator.
  • when all ports on all switches are in forwarding or blocking states, the network is converged
  • when the network is not converged, no communications can take place
  • under 802.1D standard, this made the network unavailable for extended periods (tens of seconds) during configuration changes
    • STP is more likely to be implemented as 802.1D-2004/802.1w or Rapid STP (RSTP)
      • RSTP:
        • creates outages of a few seconds or less
        • blocking, listening, disabled states are aggregated into a discarding state