Spanning Tree Protocol
Classic Spanning Tree Protocol is IEEE 802.1D.
Switches from all vendors run STP by default.
STP prevents Layer 2 loops by placing redundant ports in a blocking state, essentially disabling the interface.
These interfaces act as backups that can enter a forwarding state if an active (=currently forwarding) interface fails.
Interfaces in a forwarding state behave normally. They send and receive all normal traffic.
Interfaces in a blocking stat only send or receive STP messages (called BPDU = Bridge Protocol Data Unit).
Bridges

Spanning Tree Protocol still uses the term bridge. However, when we use the term bridge, we really mean switch. Bridges are not used in a modern network.
By selecting which ports are forwarding and which ports are blocking, STP creates a single path to/from each point in the network. This prevents Layer 2 loops.
There is a set process that STP uses to determine which ports should be forwarding and which should be blocking.
STP-enabled switches send/receive Hello BPDUs out of all interfaces, the default time is 2 seconds (the switch will send a Hello BPDU out of every interface, once every 2 seconds).
If a switch receives a Hello BPDU on an interface, it knows that interface is connected to another switch (routers, PCs, etc. do not use STP, so the do not send Hello BPDUs).

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 are put in a forwarding state, and other switches in the topology must have a path to reach the root bridge.

The default bridge priority is 32768 on all switches, so by default, the MAC address is used as the tie-breaker (the lowest MAC address becomes the root bridge).
The Bridge Priority is compared first, if they tie -> MAC addresses are then compared.


Cisco switches use a version of STP called PVST (Per-VLAN Spanning Tree). PVST runs a separate STP instance in each VLAN, so in each VLAN different interfaces can be forwarding/blocking.

In the default VLAN of 1, the default bridge priority is actually 32769 (32768 + 1).
Root Bridge
All interfaces on the root bridge are designated ports. Designated ports are in a forwarding state.
When a switch is powered on, it assumes it is the root bridge.
It will only give up its position if it receives a superior BPDU (lower bridge ID).
Once the topology has converged and all switches agree on the root bridge, only the root bridge sends BPDUs.
Other switches in the network will forward these BPDUs, but will not generate their own original BPDUs.
Last updated