Jeremy’s IT Lab lecture video:

Day 20 - Spanning Tree Protocol (STP) (1)


Commands


Spanning Tree Protocol (STP) Info

Redundancy is an important part of modern network design, and the Spanning Tree Protocol (STP) was made to help with that.

Broadcast Storms

The Ethernet frame doesn’t have a Time-To-Live (TTL) field. Therefore, when a switch sends out a broadcast/unknown unicast message, to a network with a lot of switches, there’s a chance the messages will keep looping. Eventually, there will be a lot of looping broadcasts in the network which will lead to congestion in the network making it unusable for legitimate traffic. This is called a broadcast storm

Network congestions leads to MAC Address Flapping. Each time a frame arrives on a switchport, the switch uses the source MAC address to update its MAC address table. When frames with the same source MAC address repeatedly arrive on different interfaces, the switch is continuously updating the interface the interface in its MAC address table, which leads to MAC Address Flapping.


Classic Spanning Tree Protocol

The ‘Classic Spanning Tree Protocol’ is IEEE 802.1D. Switches from all vendors run STP by default.

  • STP prevents loops by placing redundant ports in a blocking state. These become disabled interfaces which can enter a forwarding state if a currently forwarding interface fails.
  • Forwarding interfaces send and receive all normal traffic as well as Bridge Protocol Data Units (BPDUs).
  • Blocking interfaces only send or receive STP messages called Bridge Protocol Data Units (BPDUs).

  • By selecting forwarding and blocking ports, STP creates a single path to/from each point in the network. This prevents Layer 2 loops.
  • STP-enabled switches send/receive Hello BPDUs out of all of their interfaces every 2 seconds (default timer).
  • If a switch receives a Hello BPDU on an interface, it knows that the interface its connected to belongs to another switch, as end hosts don’t use STP and therefore don’t send Hello BPDUs.

Bridge Protocol Data Unit

Switches use one field in the STP BPDU, the Bridge ID field, to elect a root bridge for the network.

The switch with the lowest Bridge ID becomes the root bridge. All ports on the root bridge must be in a forwarding state in each collision domain, and other switches must have a path to the root bridge.

Bridge ID Field
  • The bridge priority is 32768 by default.
  • The STP bridge priority can only be changed in units of 4096.
  • If all switches have the same bridge priority, the lowest MAC address becomes the root bridge.
  • (The Bridge Priority is compared first, if they tie, then the MAC address is used as a tie-breaker)
  • For Cisco switches, they use a version of STP called PVST (Per-VLAN Spanning Tree) which runs a separate STP instance in each VLAN, so in each VLAN, different interfaces could be either forwarding or blocking.
  • To calculate the total bridge priority, we add up the bridge priority and the extended system ID (VLAN ID).

Every switch assumes it’s the root bridge when it is powered on, and it will only give up that status if it receives a superior BPDU (a lower bridge ID)

Only the root bridge sends the BPDUs, other switches in the network will forward them, but not generate their own.


Spanning Tree Root Costs & Port Priority

The port priority of all interfaces is 128.interface-id by default.

  • Ex: Interface G0/1 would have a default port priority of 128.1

The Process of Assigning Ports in Spanning Tree

  1. One switch is the root bridge, and all the ports on it are designated ports (forwarding state)
    • Root bridge selection is done through:
      1. Lowest bridge ID
  2. Remaining switches will select one root port (forwarding state). Ports across from the root port are ALWAYS designated ports
    • Root port selection is done through:
      1. Lowest root cost
      2. Lowest neighbor bridge ID
      3. Lowest neighbor port ID
  3. Each remaining collision domain will select one designated port (forwarding state) and one non-designated port (blocking state)
    • Designated port selection is done through:
      1. Interface on switch with lowest root cost
      2. Interface on switch with lowest bridge ID