Intermediate · Spanning Tree and EtherChannel · topic 28 of 57 · 30 min
STP port states, RSTP and Rapid PVST+
Explanation
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.
| State | Forwards user frames? | Learns MACs? | Notes |
|---|---|---|---|
| Blocking | No | No | Only receives BPDUs. Stable state for non-designated ports. |
| Listening | No | No | Sends and receives BPDUs to settle the tree. Lasts one forward delay (15 s). |
| Learning | No | Yes | Fills the MAC table so it will not flood when it starts forwarding. Lasts 15 s. |
| Forwarding | Yes | Yes | Normal operation. Stable state. |
| Disabled | No | No | The 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 states | RSTP state |
|---|---|
| Disabled, blocking, listening | Discarding |
| Learning | Learning |
| Forwarding | Forwarding |
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.
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 28672root 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
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 EdgeRead 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".
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
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)
In classic STP, which state learns MAC addresses but does not yet forward user frames?
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.
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).
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
Read more (free)
Related help
Before this, learn
This topic builds on these. If something here feels new, open them first.
Related topics
- Protecting spanning tree: PortFast, BPDU Guard, Root Guard and Loop GuardSpanning Tree and EtherChannel · same module
- VLANs: what they are and why we use themSwitching and VLANs
- Inter-VLAN routingSwitching and VLANs
- Trunks and 802.1Q taggingSwitching and VLANs
- Minimum spanning treesData Structures and Algorithms (DSA) for interviews · Tries, union-find and bit manipulation
- Layer 2 security: port security, DHCP snooping, DAINetwork security
Questions people ask about this
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.
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.
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.
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
- 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.
- Module 6 exam: Spanning Tree and EtherChannel · 13 questions · 20 min, without help. 5 topics of this module still to finish first.
- 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