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
- ID comprises:
- the root is the switch with the lowest ID
- 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
- switch at the top of the hierarchy is the root
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-treecommand to report the current configuration spanning-tree id root primaryandspanning-tree id root secondaryassigns a main and backup priority values to switches
Port states for spanning tree:
| State | Forwards Frames? | Learns MACs? | Notes |
|---|---|---|---|
| Blocking | No | No | The port drops all frames other than BPDUs. |
| Listening | No | No | The port is listening for BPDUs to detect loops. |
| Learning | No | Yes | The port discovers the topology of the network and builds the MAC address table. |
| Forwarding | Yes | Yes | The port works as normal. |
| Disabled | No | No | The 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
- RSTP:
- STP is more likely to be implemented as 802.1D-2004/802.1w or Rapid STP (RSTP)
