1. STP Convergence Process
    1. Root Bridge Election
      1. Lowest Bridge ID (BID): Priority + MAC
        1. Lowest Priority
          1. Default 32,768
        2. Lowest MAC Address
    2. Root Port Selection
      1. Non-Root Switch
      2. Least Root Path Cost
        1. spanning-tree pathcost method short
          1. 10 Mbps: 100
          2. 100 Mbps: 19
          3. 1 Gbps: 4
          4. 10 Gbps: 2
        2. spanning-tree pathcost method long
          1. 10 Mbps: 2,000,000
          2. 100 Mbps: 200,000
          3. 1 Gbps: 20,000
          4. 10 Gbps: 2,000
          5. 100 Gbps: 200
          6. 1 Tbps: 20
          7. 10 Tbps: 2
      3. Tiebreakers:
        1. 1: Lowest Neighbor BPDU BID
        2. 3: Lowest Local BID
        3. 4: Lowest Local PID
    3. Designated Port Selection
      1. LAN Segment (Collision Domain)
      2. Least Root Path Cost listed in exchanged BPDU
      3. Tiebreakers:
        1. 1: Lowest Neighbor BPDU BID
        2. 2: Lowest Local BID
        3. 3: Lowest Local PID
    4. Block All Other Ports
      1. All non-root ports and all non-designated ports are blocked
  2. STP Operation
    1. STP BPDUs
      1. Types
        1. Topology Change Notification
        2. Configuration
      2. Format
        1. Protocol ID 16 bits
        2. Version 8 bits
        3. BPDU Type 8 bits
        4. Flags 8 bits
        5. Root ID 64 bits
        6. Root Path Cost 32 bits
        7. Bridge ID 64 bits
        8. Port ID 16 bits
        9. Message Age 16 bits
        10. Max Age 16 bits
        11. Hello Time 16 bits
        12. Forward Delay 16 bits
    2. Default Timers
      1. Hello
        1. 2s
      2. Forward Delay
        1. 15s
      3. Max Age
        1. 20s
    3. Path Selection
      1. 1
        1. Bridge with lowest root ID becomes the root
      2. 2
        1. Prefer the neighbor with the lowest cost to root
      3. 3
        1. Prefer the neighbor with the lowest bridge ID
      4. 4
        1. Prefer the lowest sender port ID
  3. STP Configuration
    1. PVST & PVST+ Configuration
      1. Enable STP.
        1. Switch(config)# spanning-tree <vlan-id>
      2. Set bridge priority.
        1. Switch(config)# spanning-tree vlan <vlan-id> priority <bridge-priority>
      3. Set root bridge (macro).
        1. Switch(config)# spanning-tree vlan vlan-id root {primary | secondary} [diameter diameter]
      4. Set port cost.
        1. Switch(config-if)# spanning-tree [vlan vlan-id] cost cost
      5. Set port priority.
        1. Switch(config-if)# spanning-tree [vlan vlan-id] port-priority port-priority
      6. Set STP timers.
        1. Switch(config)# spanning-tree [vlan vlan-id] hello-time seconds
        2. Switch(config)# spanning-tree [vlan vlan-id] forward-time seconds
        3. Switch(config)# spanning-tree [vlan vlan-id] max-age seconds
    2. RSTP Configuration
      1. Define an edge port.
        1. Switch(config-if)# spanning-tree portfast
      2. Override a port type.
        1. Switch(config-if)# spanning-tree link-type point-to-point
    3. MST Configuration
      1. Enable MST on a switch.
        1. Switch(config)# spanning-tree mode mst
      2. Enter MST configuration mode.
        1. Switch(config)# spanning-tree mst configuration
      3. Name the MST region.
        1. Switch(config-mst)# name name
      4. Set the configuration revision number.
        1. Switch(config-mst)# revision version
    4. STP Feature Configuration
      1. Set PortFast on an interface.
        1. Switch(config-if)# spanning-tree portfast
      2. Set UplinkFast on a switch.
        1. Switch(config)# spanning-tree uplinkfast [max-update-rate pkts-per-second]
      3. Set BackboneFast on a switch.
        1. Switch(config)# spanning-tree backbonefast
      4. Enable Root Guard on an interface.
        1. Switch(config-if)# spanning-tree guard root
      5. Enable BPDU Guard
        1. globally
          1. Switch(config)# spanning-tree portfast bpduguard default
        2. on an interface
          1. Switch(config-if)# spanning-tree bpduguard enable
      6. Enable Loop Guard
        1. globally
          1. Switch(config)# spanning-tree loopguard default
        2. on an interface
          1. Switch(config-if)# spanning-tree guard loop
      7. Enable UDLD
        1. globally
          1. Switch(config)# udld {enable | aggressive | message time seconds}
        2. on an interface
          1. Switch(config-if)# udld {enable | aggressive | disable}
      8. Enable BPDU Filter
        1. globally
          1. Switch(config)# spanning-tree bpdufilter default
        2. on an interface
          1. Switch(config-if)# spanning-tree bpdufilter enable
  4. STP Troubleshooting
    1. Displays STP information about all VLANs
      1. show spanning-tree
    2. Displays STP information about a specific VLAN
      1. show spanning-tree [vlan {vlan_id}]
    3. Displays the STP interface role, cost, port priority, and type for each VLAN on the switch
      1. show spanning-tree interface interface_type interface_number
    4. Displays detailed STP information about an interface, including the number of BPDUs sent and received and the STP features that have been enabled specifically on the interface
      1. show spanning-tree interface interface_type interface_number detail
    5. Displays the MST region name, revision number, and the instance to VLAN mappings
      1. show spanning-tree mst configuration
    6. Displays ports configured with Root Guard that have received superior BPDUs and ports configured with Loop Guard that are in the loop inconsistent state
      1. show spanning-tree inconsistentports
    7. Displays which STP features have been enabled globally on the switch
      1. show spanning-tree summary
  5. STP Features
    1. Enhancements
      1. PortFast
        1. Access Layer ports immediately transition to the forwarding state
      2. UplinkFast
        1. Distribution Layer switches maintain backup paths to root bridge. STP only.
      3. BackboneFast
        1. Core Layer switches shorten the expiration of the Max Age timer when an indirect link fails. STP only.
    2. Protections
      1. BPDU Guard
        1. Error-disables a port if a BPDU is received
      2. Root Guard
        1. Prevents a port from becoming the root port
      3. Loop Guard
        1. Prevents a blocked port from transitioning to Listening once the Max Age timer has expired
      4. BPDU Filter
        1. Disables STP. Use this feature on Access Layer ports and Routed Ports for security.
      5. UDLD
        1. Unidirectional Link Detection. Detects a one-sided link failure that causes a link to revert to half-duplex mode, fail to receive BPDUs, and potentially cause loops.
  6. STP Port States
    1. STP
      1. Stable
        1. Disabled
          1. Either administratively or err-disabled. Effectively placed in the shutdown state
        2. Forwarding
          1. Learns MAC addresses, forwards frames, and relays BPDUs
        3. Blocking
          1. Does not learn MAC addresses or forward frames. Listens for, but does not relay, BPDUs
      2. Transitory
        1. Listening
          1. Does not learn MAC addresses or forward frames. Listens for, but does not relay, BPDUs
        2. Learning
          1. Learns MAC addresses, but does not forward frames. Listens for, but does not relay, BPDUs
    2. RSTP
      1. Learning
        1. The port is not forwarding frames yet, but is populating its MAC-address-table
      2. Forwarding
        1. Learns MAC addresses, forwards frames, and relays BPDUs
      3. Discarding
        1. In RSTP, incoming frames are dropped and no MAC addresses are learned.
  7. RSTP Port Types
    1. Edge
      1. Connects to a single host; designated by PortFast
    2. Shared
      1. Potentially connects to multiple bridges (half duplex)
    3. Point-to-Point
      1. Connects to exactly one other bridge (full duplex)
  8. STP Port Roles
    1. STP
      1. Designated Port
        1. One nonroot port selected on a network segment, such that only one switch forwards traffic to and from that segment.
      2. Root Port
        1. A forwarding port that is the best port from non-root bridge to root bridge
      3. Disabled Port
        1. Administratively or err-disabled port
    2. RSTP
      1. Designated Port
        1. One nonroot port selected on a network segment, such that only one switch forwards traffic to and from that segment.
      2. Root Port
        1. A forwarding port that is the best port from non-root bridge to root bridge
      3. Disabled Port
        1. Either administratively or err-disabled. Effectively placed in the shutdown state
      4. Backup Port
        1. a port that provides a redundant (but less desirable) connection to a segment where another switch port already connects.
      5. Alternate Port
        1. a port other than the root port that has an alternative path to the root bridge.
  9. STP Modes
    1. PVST
      1. Per-VLAN Spanning Tree
    2. RPVST
      1. Rapid Per-VLAN Spanning Tree
    3. MST
      1. Multiple Instance Spanning Tree
  10. STP Standards
    1. IEEE
      1. IEEE 802.1D-1998 · Deprecated legacy STP standard
      2. IEEE 802.1w · Introduced RSTP
      3. IEEE 802.1D-2004 · Replaced legacy STP with RSTP
      4. IEEE 802.1s · Introduced MST
      5. IEEE 802.1Q-2003 · Added MST to 802.1Q
      6. IEEE 802.1Q-2005 · Most recent 802.1Q revision
    2. Cisco
      1. PVST · Per-VLAN implementation of legacy STP
      2. PVST+ · Added 802.1Q trunking to PVST
      3. RPVST+ · Per-VLAN implementation of RSTP