Skip to content

Intermediate · Spanning Tree and EtherChannel · topic 28 of 57 · 30 min

STP port states, RSTP and Rapid PVST+

Explanation

Classic STP moves a port through blocking, listening and learning before forwarding, using timers (hello 2 s, forward delay 15 s, max age 20 s), so it takes 30 to 50 seconds to react to a change. RSTP (802.1w) uses only discarding, learning and forwarding, adds alternate and backup roles, and converges in about a second. Cisco runs one tree per VLAN: PVST+ or Rapid PVST+. You pick the root with spanning-tree vlan 10 root primary or a priority such as 24576.

Classic STP port states

A port cannot jump straight from blocking to forwarding, because the switches need time to agree on the new tree. If a port forwarded too early, a temporary loop could form. So classic 802.1D STP moves the port through waiting states.

StateForwards user frames?Learns MACs?Notes
BlockingNoNoOnly receives BPDUs. Stable state for non-designated ports.
ListeningNoNoSends and receives BPDUs to settle the tree. Lasts one forward delay (15 s).
LearningNoYesFills the MAC table so it will not flood when it starts forwarding. Lasts 15 s.
ForwardingYesYesNormal operation. Stable state.
DisabledNoNoThe port is shut down by an administrator.

The timers

  • Hello time, 2 seconds: how often the root sends BPDUs.
  • Forward delay, 15 seconds: time spent in listening, and again in learning.
  • Max age, 20 seconds: how long a switch keeps the last BPDU it heard before deciding the path is gone.

So when a direct link fails, a blocked port takes 15 + 15 = 30 seconds to start forwarding. When the failure is indirect (the switch just stops hearing BPDUs), it first waits max age (20 s), so recovery takes 20 + 15 + 15 = 50 seconds. A PC that boots on a normal access port also waits 30 seconds before its traffic flows, which can make DHCP time out. Thirty to fifty seconds felt fine in 1990; today a 50-second outage drops every phone call and payment in progress.

RSTP: Rapid Spanning Tree (802.1w)

RSTP keeps the same election (root bridge, root ports, designated ports, costs) but changes how ports move to forwarding. Instead of waiting for timers, neighbouring switches negotiate directly with a proposal and agreement handshake on point-to-point links. Convergence typically takes about a second or less. RSTP is backward compatible: if it hears an old 802.1D BPDU on a port, it falls back to classic behaviour on that port.

802.1D statesRSTP state
Disabled, blocking, listeningDiscarding
LearningLearning
ForwardingForwarding

RSTP also names the roles of non-forwarding ports more precisely:

  • Root port and designated port: as in classic STP.
  • Alternate port: a discarding port with another path to the root. It is a ready-made replacement for the root port and can take over almost instantly.
  • Backup port: a discarding port that backs up a designated port on the same shared segment. You only see it with a hub, so it is rare today.
  • Edge port: a port to an end device (like a PC). It goes to forwarding at once. On Cisco this is what PortFast configures.

Cisco flavours: PVST+ and Rapid PVST+

The IEEE standards originally ran one tree for all VLANs. Cisco runs a separate tree for every VLAN: PVST+ (Per-VLAN Spanning Tree Plus, classic timers) and Rapid PVST+ (per-VLAN RSTP). One tree per VLAN lets you load-share: make SW1 the root for VLAN 10 and SW2 the root for VLAN 20, so each uplink is busy for some VLANs instead of one uplink sitting idle. A third option, MST (802.1s), maps many VLANs onto a few trees; it is for larger networks.

output
DSW1(config)# spanning-tree mode rapid-pvst
DSW1(config)# spanning-tree vlan 10 root primary
DSW1(config)# spanning-tree vlan 20 root secondary

DSW2(config)# spanning-tree mode rapid-pvst
DSW2(config)# spanning-tree vlan 20 priority 24576
DSW2(config)# spanning-tree vlan 10 priority 28672
Cisco IOS: DSW1 is root for VLAN 10 and backup root for VLAN 20; DSW2 the other way round.

root primary is a macro, not a permanent setting: when you type it, the switch sets its priority to 24576, or, if the current root already has a priority lower than that, to 4096 less than the current root. root secondary sets 28672. Setting the priority number yourself is clearer and does not change later.

Reading show spanning-tree

output
DSW2# show spanning-tree vlan 10

VLAN0010
  Spanning tree enabled protocol rstp
  Root ID    Priority    24586
             Address     0011.1111.1111
             Cost        4
             Port        1 (GigabitEthernet0/1)
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    28682  (priority 28672 sys-id-ext 10)
             Address     0022.2222.2222

Interface           Role Sts Cost      Prio.Nbr Type
------------------- ---- --- --------- -------- -----------
Gi0/1               Root FWD 4         128.1    P2p
Gi0/2               Desg FWD 4         128.2    P2p
Gi0/3               Altn BLK 4         128.3    P2p
Gi0/5               Desg FWD 4         128.5    P2p Edge
Cisco IOS: "protocol rstp" means Rapid PVST+ ("ieee" would mean classic PVST+). Root ID is the root; Bridge ID is this switch.

Read it top down: who is the root (Root ID), how far away it is (Cost), which port leads there (Port), then this switch's own ID, then one line per port with its role (Root, Desg, Altn, Back) and state (FWD, BLK, LRN). On the root bridge itself you see "This bridge is the root".

Careful: Common mistakes: leaving the root election to chance (the oldest switch may win); typing root primary and expecting it to adapt later (it is applied once); and mixing up the Root ID and Bridge ID sections of show spanning-tree. Set root and backup root priorities on your core or distribution switches for every VLAN.
Tip: Use Rapid PVST+ everywhere unless you have a reason not to. Many Cisco switches still default to classic PVST+; check with show spanning-tree summary.

Need help?

Stuck on a word or an idea? Search this course, or every course, and jump straight to the explanation or a worked question.

Try:

Watch the lesson

STP port states, RSTP and Rapid PVST+ · 1/7

STP states and RSTP

In this lesson you will learn how spanning tree ports move to forwarding, and how rapid spanning tree makes that much faster.

Prefer a video by a teacher? Find free videos on “rstp vs stp port states rapid pvst+ explained ccna” on YouTube ↗

In real life: UPI payments at a retail chain stop for 50 seconds

A retail chain's regional warehouse used classic PVST+. Whenever a distribution switch rebooted, the access switches lost their path to the root and waited 50 seconds (max age plus two forward delays) before unblocking their backup uplink. During that time the handheld scanners and UPI payment terminals could not reach the server. The network team switched every switch to spanning-tree mode rapid-pvst, set fixed root and backup root priorities for each VLAN, and enabled PortFast on device ports. The next planned reboot caused a hiccup of under a second.

Practice (0/4 done)

Task 1 · Question

In classic STP, which state learns MAC addresses but does not yet forward user frames?

Task 2 · Code · Python

Write classic_convergence(direct, forward_delay=15, max_age=20) that returns how many seconds classic STP takes before a blocked port forwards. For a direct failure (direct is True) the port goes through listening and learning: 2 × forward_delay. For an indirect failure it first waits max_age: max_age + 2 × forward_delay.

Task 3 · Code · Python

The root primary macro follows a simple rule. Write root_primary_priority(current_root_priority): if the current root's configured priority is higher than 24576, return 24576; otherwise return 4096 less than the current root's priority. If that would go below 0, return None (the macro fails).

Task 4 · Practice

Packet Tracer lab: two distribution switches (DSW1, DSW2, 3650 or 2960) and two access switches (ASW1, ASW2), each access switch with one uplink to each distribution switch. Create VLANs 10 and 20 everywhere and make the uplinks trunks. Turn on Rapid PVST+ on all four switches. Make DSW1 the root for VLAN 10 and backup root for VLAN 20, and DSW2 the opposite. Check where each VLAN is blocked.

Quick quiz

Question 1

1.What are the default STP hello time, forward delay and max age?

Question 2

2.Which three port states does RSTP use?

Question 3

3.In RSTP, what is an alternate port?

Question 4

4.Which command turns on Cisco's per-VLAN rapid spanning tree?

Question 5

5.What priority does spanning-tree vlan 10 root secondary set?

Read more (free)

Open a question to see the answer and why. The first ones are this topic's own quiz, so try the quiz above before you peek.

What are the default STP hello time, forward delay and max age?

Answer: 2 s, 15 s, 20 s

Hello 2 s, forward delay 15 s, max age 20 s.

Which three port states does RSTP use?

Answer: Discarding, learning, forwarding

RSTP merges disabled, blocking and listening into discarding.

In RSTP, what is an alternate port?

Answer: A discarding port with another path to the root, ready to replace the root port

The alternate port is a ready backup for the root port and can take over quickly.

Which command turns on Cisco's per-VLAN rapid spanning tree?

Answer: spanning-tree mode rapid-pvst

spanning-tree mode rapid-pvst enables Rapid PVST+.

What priority does spanning-tree vlan 10 root secondary set?

Answer: 28672

root secondary sets 28672, just below the default 32768 and above the root primary value.

A switch has the default priority. What priority does it show in VLAN 20?Related

Answer: 32788

Default 32768 plus the extended system ID (the VLAN number 20) gives 32788.

From Root bridge election, root ports and designated ports

What does a blocked STP port still do?Related

Answer: Receives BPDUs

A blocking port keeps listening to BPDUs, so it can take over if the active path fails.

From Why layer 2 loops are deadly

A port was err-disabled by BPDU Guard and you have removed the rogue switch. How do you bring it back by hand?Related

Answer: shutdown, then no shutdown

shutdown followed by no shutdown resets an err-disabled port once the cause is gone.

From Protecting spanning tree: PortFast, BPDU Guard, Root Guard and Loop Guard

A frame to ffff.ffff.ffff arrives on port 5 of a 24-port switch (all in one VLAN). Where does it go?Related

Answer: All ports except port 5

Broadcasts are flooded out of every port except the incoming one.

From How a switch learns and forwards

Pass the quiz (60% or more) or mark this topic as done when you are ready.

Your progress is saved on this device only.

Next steps

  1. 2 more topics in “Spanning Tree and EtherChannel” before its exam: Protecting spanning tree: PortFast, BPDU Guard, Root Guard and Loop Guard, EtherChannel: bundling links.
  2. Module 6 exam: Spanning Tree and EtherChannel · 13 questions · 20 min, without help. 5 topics of this module still to finish first.
  3. Then the next module, Routing: static routes and OSPF. 57 topics left in the course before the final exam.

← Previous: Root bridge election, root ports and designated ports