2.5 Interpret how Rapid PVST+ spanning tree operates

CCNA 200-301 v1.1 · 2.0 Network Access

Spanning tree stops Layer 2 loops by electing a root bridge and blocking the redundant ports that would close a loop. Rapid PVST+, the Cisco default on new switches, runs one Rapid STP (802.1w) instance per VLAN and converges in about a second. For the CCNA you predict the root and every port's role, and protect the edge with PortFast and the guards.

What you must know

Root bridge and port naming

Every switch has a bridge ID: a priority (default 32768) plus the VLAN number (the system ID extension), followed by its MAC address. The lowest bridge ID is the root. With default priorities the oldest switch, with the lowest MAC address, tends to win, so set the root on purpose.

spanning-tree mode rapid-pvst
spanning-tree vlan 10 root primary     ! priority 24576, or lower than the current root
spanning-tree vlan 20 root secondary   ! priority 28672
! or exact values, in steps of 4096:
spanning-tree vlan 10 priority 4096

Then each non-root switch picks one root port: its port with the lowest cost to the root. Each segment gets one designated port: the end closest to the root. Ties are broken by the lowest neighbor bridge ID, then the lowest neighbor port ID (port priority, default 128, then port number).

Link speedCost (short method)
10 Mbps100
100 Mbps19
1 Gbps4
10 Gbps2

In the drawing every port on SW1 is designated, because the root's ports are always designated. SW2 and SW3 use Gi0/1 as their root port. On the SW2–SW3 link both have the same cost to the root, so SW2 wins with the lower bridge ID: its Gi0/2 is designated and SW3's Gi0/2 becomes the alternate port.

Port roles and states

RoleWhat it isState
RootThe best path to the root bridge, one per non-root switch.Forwarding
DesignatedThe best port on a segment toward the root, one per segment.Forwarding
AlternateA second path to the root through another switch: the root port's ready-made replacement.Discarding
BackupA second port onto the same segment (rare: a hub).Discarding
DisabledShut down.Discarding

RSTP has three states: discarding, learning and forwarding. Classic 802.1D had blocking, listening, learning and forwarding, and took 30 to 50 seconds. RSTP is fast because neighbors agree on roles with a proposal and agreement handshake on point-to-point links, and an alternate port becomes the root port immediately when the root port fails.

PortFast

A port with PortFast is an edge port: it goes straight to forwarding when a host connects, and its link going up or down does not trigger a topology change. Use it only on ports to end hosts, never toward another switch.

interface GigabitEthernet0/5
 spanning-tree portfast
!
spanning-tree portfast default   ! every access port

Root guard, loop guard, BPDU filter and BPDU guard

FeatureWhereWhat it does
BPDU guardPortFast edge portsErr-disables the port when any BPDU arrives: someone plugged in a switch.
BPDU filterEdge ports, with careStops sending BPDUs. Globally it only applies to PortFast ports and turns PortFast off if a BPDU arrives; on an interface it disables STP there, which can cause a loop.
Root guardDesignated ports toward the access layerPuts the port in root-inconsistent (discarding) if a better BPDU arrives, so no switch down there can become root.
Loop guardRoot and alternate portsPuts the port in loop-inconsistent if BPDUs stop, instead of letting it forward: protects against one-way links.
interface GigabitEthernet0/5
 spanning-tree portfast
 spanning-tree bpduguard enable
!
interface GigabitEthernet0/24
 spanning-tree guard root
!
errdisable recovery cause bpduguard   ! optional automatic recovery

Commands

show spanning-tree vlan 10The root ID, this switch's bridge ID, and each port's role, state, cost and port ID.
show spanning-tree rootThe root bridge, cost and root port for every VLAN.
show spanning-tree summaryMode (rapid-pvst), and whether PortFast, BPDU guard and loop guard are on by default.
show spanning-tree interface Gi0/1 detailEverything about one port, including BPDUs sent and received.
show interfaces status err-disabledPorts shut by BPDU guard (or port security) and the reason.

Exam traps

Check yourself

SW1 has priority 32768 and MAC 0011.1111.1111; SW2 has priority 32768 and MAC 0011.0000.0001. Which is root for VLAN 1?
SW2. The priorities tie (32769 with the VLAN), so the lower MAC address wins.
A user plugs a small switch into a port with PortFast and BPDU guard. What happens?
The small switch sends BPDUs, so BPDU guard err-disables the port. It stays down until it is shut and unshut, or errdisable recovery brings it back.
What is the RSTP name for the 802.1D blocking state?
Discarding.
Which guard stops a switch in the access layer from becoming root?
Root guard, on the distribution switch's designated ports toward the access layer.

Labs

Try it live: Rapid PVST+ root bridge tuning

More topics in 2.0 Network Access