STP protocol

Spanning-Tree Protocol prevents loops in a network
Problems that Spanning-Tree Protocol fixes:
  • Switches are interconnected with redundant links for resiliency, but that caused loops and broadcast storms.
  • Connecting switches like this also caused inconsistent MAC address tables because the switch would see the same host MAC address on two different ports.
  • If the switch doesn't know the MAC address it could send it back to the first switch on the redundant link.  Then the first switch sends it back on the other link. And the frame gets bounced around between switches without ever reaching its destination.
  • The same frame is sent out all ports that it wasn't received on.  This is how a broadcast storm is created.

Spanning-Tree Protocol overview:

  • Purpose is to avoid loops in Ethernet networks
  • STP does so by creating a (logical) tree with a single active path to all nodes
  • STP designates a single switch as the root bridge in a layer 2 network
  • The root bridge uses Bridge Protocol Data Units (BPDUs) to constantly communicate with all non-root bridges
  • Setting up redundant links is recommended as best practice
  • STP will elect the best path and disable any redundant links until the primary path goes down
  • STP uses bandwidth to calculate the cost of paths between switches and determines a single preferred path between two switches
  • STP designates the switch port of the preferred path as the Root Port (RP)

Spanning-Tree Protocol states:

  • Switchports can be in 1 of 5 states:
    • Blocking:
      • set on the redundant links
      • no user data is sent on this path
      • may go to forwarding state should the primary path fail
      • BPDUs are still received on a blocking port
    • Listening:
      • processes BPDUs
      • does not learn MAC addresses
      • does not forward frames
    • Learning:
      • processes BPDUs
      • does learn MAC addresses
      • does not forward frames
    • Forwarding:
      • normal operation
      • sends and receives user data
      • processes BPDUs
    • Disabled:
      • the switchport has been manually disabled
  • The time spent in Listening and Learning state is determined by the Forward Delay. It is set by the root bridge.  Default is 15 seconds.