SaveMyCert
Log in
5 of 5 free questions left today·for 10 a day
Switching and Network Access

CCNA Rapid PVST+: Root Election, Port Roles and Guards

21 min readCCNA · Switching and Network AccessUpdated

Rapid PVST+ (Rapid Per-VLAN Spanning Tree Plus) is Cisco's per-VLAN version of the IEEE 802.1w Rapid Spanning Tree Protocol: it blocks redundant Layer 2 paths separately in every VLAN so there are no loops, and it fails over to a backup path in about a second. This lesson covers how the root bridge is elected and pinned with root primary/secondary, how root, designated, alternate and backup ports are chosen, the discarding/learning/forwarding states, why convergence is rapid, PortFast edge ports, and the three guards — BPDU guard, root guard and loop guard — along with the show output that reveals each one.

What you’ll learn
  • Elect the root bridge from bridge IDs, explain the extended system ID, and predict the priority written by spanning-tree vlan root primary and root secondary
  • Calculate root path costs and apply the root-port tie-breakers (sender bridge ID, sender port priority, sender port number), and choose between port cost and port priority to steer the result
  • Identify designated, alternate and backup ports and the discarding, learning and forwarding states, including how they appear in show spanning-tree
  • Explain what makes Rapid PVST+ converge quickly: per-switch hellos, alternate ports, proposal/agreement with sync, link types and RSTP topology changes
  • Configure PortFast on access and trunk ports, and predict what happens when an edge port receives a BPDU
  • Choose and place BPDU guard, root guard and loop guard, and recover a port from each one's blocked or err-disabled state
  • Design per-VLAN root placement so two distribution switches load-share uplinks and back each other up

What is Rapid PVST+ and how do you turn it on?

Rapid PVST+ (Rapid Per-VLAN Spanning Tree Plus) is Cisco's implementation of IEEE 802.1w Rapid Spanning Tree Protocol (RSTP) that runs one separate spanning-tree instance for every VLAN. Each instance elects its own root bridge, chooses its own root, designated and alternate ports, and blocks its own redundant links, so a loop-free Layer 2 topology exists per VLAN while redundant links stay ready as backups.

Spanning tree exists because Ethernet frames have no time-to-live: if two switches are joined by more than one active path, broadcasts circulate forever (a broadcast storm), MAC tables flap and the network stops forwarding. Spanning tree logically blocks just enough ports to leave exactly one active path between any two points, then unblocks a backup port when the active path fails.

SW1(config)# spanning-tree mode rapid-pvst
SW1# show spanning-tree vlan 10
VLAN0010
  Spanning tree enabled protocol rstp

The output line protocol rstp confirms the switch is running Rapid PVST+ for that VLAN. Because every VLAN is its own instance, almost every spanning-tree setting can be made per VLAN: spanning-tree vlan 10 priority …, spanning-tree vlan 10 root primary, and on an interface spanning-tree vlan 10 cost … or spanning-tree vlan 10 port-priority …. The same command without a VLAN number (for example spanning-tree cost 100 on an interface) applies to every VLAN on that port.

Rapid PVST+ keeps the classic timer values for compatibility — hello 2 seconds, forward delay 15 seconds, max age 20 seconds — but in normal operation it rarely waits for them, as later sections explain.

How is the root bridge elected?

The root bridge is the switch with the lowest bridge ID (BID) in that VLAN. The BID is compared as one number whose high-order part is the bridge priority and whose low-order part is the switch's MAC address, so priority is compared first and the MAC address only breaks a tie. A switch with a lower priority wins no matter how high its MAC address is.

The extended system ID

The 16-bit priority field is split: the top 4 bits are the configurable priority, and the low 12 bits carry the extended system ID, which equals the VLAN number. Two consequences follow:

  • You can only configure priorities in multiples of 4096, from 0 to 61440 (16 values). A value such as 5000 or 30000 is rejected.
  • show spanning-tree displays the configured priority plus the VLAN number. The default 32768 in VLAN 40 shows as 32808, and 4096 in VLAN 7 shows as 4103. The bracket spells it out:
  Bridge ID  Priority    32808  (priority 32768 sys-id-ext 40)
             Address     5c8a.38f1.2e00

The displayed sum is never something you type; you configure the multiple of 4096 that appears in the bracket.

Why the default election is risky

If no priorities are configured, every switch ties at 32768 plus the VLAN number and the lowest MAC address wins. That is often an old or newly installed access switch rather than the distribution or core switch you want, and the whole tree reshapes around it. When comparing MAC addresses, compare them as hexadecimal numbers digit by digit (hex c is 12, so …2c00 is higher than …2900). Boot order, link speed and path cost play no part in the root election.

root primary and root secondary

Two macros pick a priority for you:

CommandPriority it writes
spanning-tree vlan X root primary24576 — or, if a current root already has a priority lower than 24576, 4096 below that lowest priority
spanning-tree vlan X root secondary28672, a fixed value between the primary's 24576 and the default 32768

The macro runs once, looking at the roots it can see at that moment, and saves an ordinary spanning-tree vlan X priority N line in the configuration. It does not keep tracking the network: a switch added later with any lower priority still takes over the root. To make a root robust, configure an explicitly low priority (for example 4096 or 0) on the intended root and/or protect the edge of the distribution layer with root guard. If you list several VLANs (spanning-tree vlan 10,20 root primary) the macro computes a value for each VLAN separately and makes the switch root for all of them.

How does a switch choose its root port?

Every non-root switch chooses exactly one root port per VLAN: the port with the lowest root path cost, which is the cumulative cost of the path to the root. Each BPDU carries the sender's own root path cost; the receiving switch adds the cost of the port the BPDU arrived on. The root advertises 0.

Default port costs

Link speedShort (16-bit) costLong (32-bit) cost
10 Mbps1002,000,000
100 Mbps19200,000
1 Gbps420,000
10 Gbps22,000

The method in use (spanning-tree pathcost method short|long) is shown by show spanning-tree summary; the short values are the ones most CCNA material uses. Either way, faster links cost less.

Work outward from the root

Calculate each switch's best cost before using it as an advertised cost further downstream. A switch with a slow direct link to the root may reach it more cheaply through a neighbour: with a 10 Mbps direct link (100) and a path of three 1 Gbps hops (4 + 4 + 4 = 12), the indirect path wins, and that switch advertises 12, not 100, to the switches below it. A direct connection to the root wins only when its total is lowest.

Tie-breakers

If two ports give the same root path cost, the switch compares, in order:

  1. the lowest sender bridge ID (the neighbour that sent the BPDU);
  2. the lowest sender port priority (0–240 in steps of 16, default 128);
  3. the lowest sender port number.

All three are values from the neighbour's BPDU, never the receiving switch's own port numbers. Sender port priority and number only matter when both links lead to the same neighbour (otherwise the sender bridge IDs already differ). With two parallel links to one switch, the receiving port cabled to the neighbour's lower-numbered port wins; the receiving switch's own port numbers are not compared at all.

Cost versus port priority

SettingWho it affectsUse it to…
Port cost (spanning-tree [vlan X] cost N)The local switch: it is added to costs received on that port, and it is compared before any tie-breakerMake a switch prefer or avoid one of its own uplinks
Port priority (spanning-tree [vlan X] port-priority N)The neighbour: it travels in the BPDUs this port sends, as part of the sender port IDSteer which of several parallel links a downstream switch chooses

So to change a switch's own root port, lower the cost of the port you want (or raise the other) on that switch; changing its own port priority does nothing for its own choice. If only the upstream switch may be changed, lower the port priority on the upstream port you want used. A cost configured on the root's own port has no effect on the downstream choice, because the root advertises 0 and the cost is added by the receiver. Using the per-VLAN form (spanning-tree vlan X cost N) moves one VLAN while the others keep their root port; the form without a VLAN number changes every VLAN on that port.

Reading the result

  Root ID    Priority    8242
             Address     3a7f.91c0.4400
             Cost        12
             Port        26 (GigabitEthernet1/0/26)

The Cost under Root ID is this switch's total root path cost through its root port. The Cost column in the interface table is each port's own cost. Subtracting gives what the neighbour advertised: here, a total of 12 through a port costing 4 means the upstream neighbour advertises 8.

How are designated, alternate and backup ports chosen?

After root ports are chosen, every segment (link) elects one designated port: the port on the switch that advertises the lowest root path cost onto that segment, then the lowest bridge ID, then the lowest port ID. The designated port forwards and sends BPDUs onto the segment. Every other non-root port then gets the alternate or backup role and discards.

  • The root bridge advertises cost 0, so it wins every segment it is attached to: all its ports are designated and forwarding (unless two of its own ports sit on the same shared segment).
  • On a link between two non-root switches, compare the cost each switch advertises (its own root path cost), not the link's cost. The lower advertised cost wins outright; bridge priority matters only if those costs tie.

RSTP port roles

Role (show output)What it isState
Root (Root)The non-root switch's best path to the rootForwarding
Designated (Desg)The best port on a segment, forwarding toward that segment (including edge ports to hosts)Forwarding
Alternate (Altn)Hears a better BPDU from a different switch but is not the root port: a pre-computed standby path to the rootDiscarding
Backup (Back)Hears a better BPDU from its own switch: a second port on a shared segment (for example a hub) the switch already servesDiscarding
DisabledAdministratively down or not participatingDiscarding

The alternate/backup distinction is simply whose superior BPDU the port hears. Two ports of one switch plugged into the same hub: one becomes designated (the lower port ID), the other hears its sibling's BPDUs and becomes backup. A port that hears a neighbour switch's better BPDU but would give a worse path to the root than the current root port becomes alternate — it does not replace the root port just because it receives a BPDU.

Which port states does Rapid PVST+ use?

Rapid PVST+ uses three port states: discarding, learning and forwarding. RSTP grouped the old 802.1D states by what the port does with frames, so disabled, blocking and listening — which all drop user frames and learn nothing — merged into a single discarding state.

802.1D stateRapid PVST+ stateForwards user frames?Learns MAC addresses?
Disabled, Blocking, ListeningDiscardingNoNo
LearningLearningNoYes
ForwardingForwardingYesYes

In the learning state the port reads source MAC addresses into the MAC table, so the switch does not flood unnecessarily once it starts forwarding, but it still does not pass user frames. Ports in every state keep receiving and processing BPDUs, which is how a discarding alternate port knows it can take over.

Cisco IOS still prints BLK in the Sts column for a discarding port, so Altn BLK means an alternate port in the discarding state. LRN is learning, FWD forwarding, and BKN* a port broken by a guard or inconsistency (explained in the guard section).

How does Rapid PVST+ converge so quickly?

Rapid PVST+ converges in about a second or less because it replaces timer waits with pre-computed backups and an explicit handshake. Four mechanisms do the work.

1. Every switch sends BPDUs as keepalives

In 802.1D only the root originated BPDUs on its own timer; other switches sent BPDUs only when the root's BPDU arrived. In RSTP every bridge sends its own BPDUs every hello time (2 seconds) on its designated ports. If a port misses three consecutive hellos (about 6 seconds), the information is aged out at once instead of waiting for the 20-second max age. That ageing is only needed when a link stays up but BPDUs stop; a link that goes physically down is detected immediately.

2. The alternate port is a ready-made root port

Because an alternate port already receives BPDUs that lead to the root, when the root port's link fails the switch moves the alternate port straight to the root role in the forwarding state — no listening or learning.

3. Proposal/agreement and sync

When a designated port comes up on a point-to-point link it sends a proposal. The neighbour, before accepting the port as its root port, syncs: it puts all of its non-edge designated ports into discarding (edge ports are left alone because they lead only to hosts), so forwarding on the new root port cannot create a loop. It then returns an agreement and the upstream port forwards immediately. The neighbour's blocked designated ports repeat the same handshake with their own neighbours, so convergence ripples outward in well under a second.

4. Link type decides whether the handshake can run

The proposal/agreement exchange runs only on point-to-point links, which the switch infers from full duplex. A half-duplex port is treated as shared (Shr) and falls back to the forward-delay timers — about 30 seconds through discarding and learning. Fix a duplex mismatch, or override the inference with spanning-tree link-type point-to-point (or shared) when you know better.

If a neighbour sends legacy 802.1D BPDUs, the port shows Peer(STP) and uses 802.1D behaviour on that link, because an 802.1D switch cannot answer a proposal. After the neighbour is migrated, clear spanning-tree detected-protocols makes the port re-detect it.

Port situationRapid transition?
Edge port (PortFast) to a hostYes — forwards immediately
Point-to-point (full duplex) to an RSTP neighbourYes — proposal/agreement
Shared (half duplex, or forced link-type shared)No — timer-based
Neighbour running 802.1D (Peer(STP))No — timer-based

Topology changes

RSTP treats a topology change differently from 802.1D: only a non-edge port moving to forwarding triggers one. The switch that sees it flushes MAC addresses learned on its other non-edge ports and sends BPDUs with the TC flag set, and neighbours do the same. A port merely going down does not make that switch originate a topology change (the switch at the other end does, if its alternate port moves to forwarding), and edge ports never generate topology changes, whether they come up or go down — another reason to make every host port an edge port.

What does PortFast do, and how is it configured?

PortFast makes a port an edge port that moves to forwarding as soon as the link comes up, skipping discarding and learning. It is meant for ports that connect only to end hosts. Without it, a designated port facing a PC sends proposals that nobody answers, falls back to the forward-delay timer, and spends about 30 seconds discarding and learning — long enough for DHCP requests after a reboot to time out.

CommandWhereEffect
spanning-tree portfastInterfaceEdge port on an access (non-trunking) port. On a trunk it is accepted with a warning and only takes effect if the port stops trunking
spanning-tree portfast trunkInterfaceEdge port on a trunk to a single host, such as a hypervisor carrying VM VLANs
spanning-tree portfast defaultGlobalPortFast on every non-trunking port that does not override it; never covers trunks
spanning-tree portfast disableInterfaceExcludes one port from the global default

Some platforms and software releases spell these spanning-tree portfast edge and spanning-tree portfast edge trunk; the behaviour is the same. An edge port shows Edge in the Type column of show spanning-tree.

PortFast sets the administrative edge status, but the port still listens for BPDUs. If a BPDU arrives — someone plugs a switch into the wall jack — the port immediately loses its operational edge status and takes part in spanning tree as a normal port. That prevents a loop, but it lets an unauthorised switch influence the topology; stopping that is BPDU guard's job. PortFast never affects the root election or port costs.

How do BPDU guard, root guard and loop guard differ?

The three guards protect the spanning tree from different failures. BPDU guard shuts down a port that receives any BPDU; root guard blocks a port that receives a superior BPDU; loop guard blocks a port that stops receiving BPDUs.

BPDU guardRoot guardLoop guard
TriggerAny BPDU receivedA superior BPDU (one that would make the neighbour root or the port a root port)BPDUs stop arriving on a root or alternate port
Where to configureEdge/access ports to end hostsDesignated ports facing switches that must never become root (distribution ports toward the access layer, ports to a partner)Root and alternate ports on non-root switches (uplinks)
Interface commandspanning-tree bpduguard enablespanning-tree guard rootspanning-tree guard loop
Global commandspanning-tree portfast bpduguard default (PortFast ports only)Nonespanning-tree loopguard default
ActionErr-disables the whole interfaceRoot-inconsistent (*ROOT_Inc), discarding for that VLAN; interface stays upLoop-inconsistent (*LOOP_Inc), discarding for that VLAN; interface stays up
RecoveryManual: shutdown then no shutdown, or errdisable recovery cause bpduguardAutomatic when superior BPDUs stopAutomatic when BPDUs resume

BPDU guard

Any BPDU proves a switch is attached to a port that should only see hosts, so the port is err-disabled and logs %SPANTREE-2-BLOCK_BPDUGUARD and %PM-4-ERR_DISABLE. There are two ways to enable it, with different scope:

  • The global spanning-tree portfast bpduguard default applies only to ports that are operating as PortFast edge ports. A port without PortFast is not covered, and re-entering the global command does not change that.
  • The interface spanning-tree bpduguard enable protects that port whether or not PortFast is configured.

Removing the offending device does not bring the port back. Without errdisable recovery cause bpduguard (which re-enables the port after a recovery interval, 300 seconds by default) an engineer must bounce the interface: err-disable is cleared only by shutdown/no shutdown or by errdisable recovery, never by spanning-tree commands or by changing the port's configuration.

Root guard

Root guard keeps a designated port designated. Inferior BPDUs are processed normally, so the link keeps forwarding with a neighbour that runs spanning tree; only a superior BPDU puts the port into root-inconsistent state (log %SPANTREE-2-ROOTGUARD_BLOCK), and when those stop the port recovers by itself (ROOTGUARD_UNBLOCK). Place it on designated ports facing switches that should sit below it in the tree. Any port that legitimately receives the best BPDUs in the VLAN — a root port, an alternate port, or the path the secondary root relies on — is the wrong place: root guard there blocks the very path to the root it should protect. That is why root guard suits a partner link that must keep exchanging BPDUs, where BPDU guard would err-disable the link on the first ordinary BPDU.

Loop guard

Loop guard handles a unidirectional link, such as a fibre or transceiver fault that stops a port receiving while it can still transmit. Without it, a root or alternate port that stops hearing BPDUs ages out the stored information, becomes designated and forwards toward a switch that is already forwarding — a loop. Loop guard holds the port in loop-inconsistent state instead, and it recovers automatically once BPDUs arrive again. It belongs on the receiving (root/alternate) side; on a designated port it has no BPDUs to miss.

The interface command spanning-tree guard takes one value — loop, root or none — so a port runs root guard or loop guard, not both. This is consistent with their placement: root guard on designated ports, loop guard on root and alternate ports.

How do you read show spanning-tree output?

show spanning-tree vlan X answers almost every Rapid PVST+ question: the top block identifies the root and this switch, and the interface table lists each port's role, state, cost, port ID and link type.

AS5# show spanning-tree vlan 60
VLAN0060
  Spanning tree enabled protocol rstp
  Root ID    Priority    4156
             Address     3a7f.91c0.4400
             Cost        4
             Port        25 (GigabitEthernet1/0/25)
  Bridge ID  Priority    32828  (priority 32768 sys-id-ext 60)
             Address     5c8a.38f1.2e00

Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Gi1/0/7          Desg FWD 19        128.7    P2p Edge
Gi1/0/14         Desg FWD 4         128.14   P2p
Gi1/0/25         Root FWD 4         128.25   P2p
Gi1/0/26         Altn BLK 4         128.26   P2p
FieldMeaning
Root ID Cost / PortThis switch's total root path cost and its root port (absent when the switch is itself the root, which shows "This bridge is the root")
Bridge ID PriorityConfigured priority + VLAN number (sys-id-ext)
RoleRoot, Desg, Altn, Back
StsFWD forwarding, LRN learning, BLK discarding, BKN* broken by an inconsistency
CostThe port's own cost (not the total)
Prio.NbrPort ID: port priority . port number
TypeP2p point-to-point, Shr shared, Edge PortFast edge, Peer(STP) legacy 802.1D neighbour, *ROOT_Inc / *LOOP_Inc root guard / loop guard blocking

show spanning-tree interface Gi1/0/20 shows one port across all its VLANs, which is useful for confirming a trunk is (or is not) an edge port, and show spanning-tree summary shows the mode, the path-cost method and which global PortFast, BPDU guard and loop guard defaults are on. Err-disabled ports appear in show interfaces status err-disabled.

Tip. Questions on Rapid PVST+ are mostly evidence-first: the stem gives bridge IDs, a link-and-cost diagram, configuration lines, syslog messages or show spanning-tree output and asks which switch becomes root, which port becomes root or alternate, what priority a macro writes, why a link converges slowly, or what state a guarded port is in now. Expect to work costs outward from the root, apply the tie-breaker order using the sender's values, tell alternate from backup, and tell the three guards apart by trigger, placement and recovery. Design items ask where to place root guard or loop guard, which change moves one VLAN's root port without touching others, or how to split VLAN roots between two distribution switches with a defined backup.

Key takeaways
  • The root bridge has the lowest bridge ID: priority first, MAC address only as a tie-breaker; with all defaults the lowest MAC wins.
  • Priority is configured in multiples of 4096 (0–61440); show output displays it plus the VLAN number (the extended system ID).
  • root primary writes 24576, or 4096 below a lower existing root; root secondary writes 28672; both are one-time macros saved as plain priority lines.
  • The root port has the lowest cumulative root path cost; ties go to the lowest sender bridge ID, then sender port priority, then sender port number.
  • Port cost steers the local switch's own root port; port priority is sent to neighbours and steers their choice between parallel links.
  • Alternate = better BPDU from another switch (standby path to the root); backup = better BPDU from the same switch on a shared segment. Both discard.
  • Rapid PVST+ states are discarding, learning and forwarding; IOS still shows a discarding port as BLK.
  • Rapid transitions need an edge port or a full-duplex point-to-point link to an RSTP neighbour; Shr and Peer(STP) ports fall back to timers.
  • PortFast makes an edge port that forwards at once; a received BPDU removes edge status; trunks need portfast trunk; edge ports never cause topology changes.
  • BPDU guard err-disables on any BPDU (manual or errdisable recovery); root guard blocks on superior BPDUs and loop guard on missing BPDUs, both recovering automatically.

Frequently asked questions

What is the difference between Rapid PVST+ and PVST+?

Both run one spanning-tree instance per VLAN, but PVST+ is based on the original 802.1D protocol while Rapid PVST+ is based on 802.1w RSTP. Rapid PVST+ uses discarding, learning and forwarding states, has every switch send BPDUs every 2 seconds, pre-computes alternate ports and uses a proposal/agreement handshake, so it converges in about a second instead of 30 to 50 seconds. It is enabled with spanning-tree mode rapid-pvst.

Why does show spanning-tree show a bridge priority of 32769 instead of 32768?

Cisco switches use the extended system ID: the low 12 bits of the bridge priority field carry the VLAN number. The displayed priority is the configured priority plus the VLAN, so the default 32768 in VLAN 1 appears as 32769. That is also why only multiples of 4096 can be configured.

What priority does spanning-tree vlan root primary set?

It sets 24576 if that is low enough to make the switch root. If a current root already has a priority below 24576, it sets 4096 less than that lowest priority. The value is saved as an ordinary priority command and is not recalculated, so a switch added later with a lower priority can still become root. root secondary always writes 28672.

What is the difference between an alternate port and a backup port?

Both discard. An alternate port receives a better BPDU from a different switch and is a pre-computed backup path to the root bridge, ready to become the root port at once. A backup port receives a better BPDU from its own switch, which only happens when two of the switch's ports share one segment, such as a hub.

Does PortFast stop loops if someone plugs a switch into the port?

Partly. A PortFast port still listens for BPDUs, and when one arrives it loses its edge status and runs spanning tree normally, so a loop is prevented. The attached switch can still join and influence the topology, though. To shut the port down when any BPDU arrives, add BPDU guard.

How do you recover a port err-disabled by BPDU guard?

Remove the device that sent BPDUs, then enter shutdown followed by no shutdown on the interface. Alternatively, configure errdisable recovery cause bpduguard so the switch re-enables the port automatically after the recovery interval. Root guard and loop guard ports do not need this, because they block logically and recover by themselves.

Where should root guard and loop guard be configured?

Root guard goes on designated ports facing switches that must never become root, typically distribution ports toward the access layer or links to another organisation. Loop guard goes on root and alternate ports, usually access and distribution uplinks, to protect against unidirectional link failures. A single port can run only one of the two, set with spanning-tree guard root or spanning-tree guard loop.

Why does a Rapid PVST+ link still take 30 seconds to forward?

The proposal/agreement handshake that makes RSTP fast only works on point-to-point links to RSTP neighbours. A half-duplex port is treated as a shared link, and a port facing a legacy 802.1D switch shows Peer(STP); both fall back to the 15-second forward-delay timer twice. A host port without PortFast also waits, because no switch answers its proposals.

Source

This lesson covers the "Switching and Network Access" domain of the official CCNA exam guide. Vendors revise their guides — check the source for the current version.

Test yourself on this topic
Practice now

Sign up free to mark lessons complete, bookmark topics and track your exam readiness.

Spotted a mistake in this lesson?