Sub topic 12
Rapid STP: Faster Convergence with the Same Tree Logic
This chapter assumes you know how classic STP (802.1D) elects a root bridge, how bridge IDs and path costs work, and how root, designated and blocked ports are chosen. It also assumes you can read a switch command-line interface. Rapid Spanning Tree Protocol (RSTP, IEEE 802.1w) keeps all of that logic. It changes how switches move ports to forwarding, and that change cuts recovery time from tens of seconds to about a second or less.
What stays the same
RSTP builds the same kind of tree as 802.1D:
- The switch with the lowest bridge ID becomes the root bridge.
- Each non-root switch picks one root port, the port with the lowest root path cost.
- Each segment gets one designated port, the one with the best path to the root.
- Ports that are neither root nor designated stay out of the forwarding path.
If you give RSTP and 802.1D the same topology, costs and priorities, they select the same root and the same forwarding links. The difference is in how a switch decides it is safe to start forwarding, and how it learns that a neighbor has failed.
One cost detail does change. RSTP uses a larger default cost scale, so a 1 Gbps link costs 4 and a 10 Gbps link costs 2. The classic short scale used 4 for 1 Gbps and 2 for 10 Gbps as well, but it gave 1 for anything above 10 Gbps. The long scale gives every speed a distinct value. A mismatch in cost method between switches can change which path wins, so use the same method everywhere.
Why classic STP is slow
In 802.1D a port passes through blocking, listening, learning and forwarding. The listening and learning stages each last the forward delay, 15 seconds by default. A switch also waits for the max age timer, 20 seconds, before it decides that a root bridge has disappeared. After an indirect failure, recovery can take up to 50 seconds. The timers exist because the switch cannot otherwise know whether a neighbor is about to forward and create a loop.
RSTP replaces timer-based waiting with explicit communication between neighbors, so most ports move to forwarding without waiting for a timer.
New port roles and states
RSTP defines five port roles. Two are the familiar root and designated roles. The other two describe ports that are not forwarding, and they are the reason RSTP can recover quickly:
- Alternate port: a standby path to the root through a different switch. It receives better BPDUs from another bridge. If the root port fails, the alternate port replaces it immediately.
- Backup port: a redundant path to a segment where this same switch already has a designated port. It appears only when two ports of one switch connect to the same shared segment, for example through a hub. It is rare.
- Disabled port: a port that is administratively down or has no link, so it takes no part in spanning tree.
RSTP also reduces the four 802.1D states to three:
| 802.1D state | RSTP state | Forwards frames | Learns MAC addresses |
|---|---|---|---|
| Disabled | Discarding | No | No |
| Blocking | Discarding | No | No |
| Listening | Discarding | No | No |
| Learning | Learning | No | Yes |
| Forwarding | Forwarding | Yes | Yes |
The role and the state are separate in RSTP. A port can be an alternate port in the discarding state, or a designated port that is still moving to forwarding.
How BPDUs change
In 802.1D only the root generates BPDUs, and other switches relay them. If a switch stops receiving them, it waits for max age. In RSTP every switch sends its own BPDU every hello interval (2 seconds by default), whether or not it hears from the root. The BPDU is version 2 and carries a flags field that encodes the port's role and state, plus proposal, agreement and topology change bits.
A switch treats a neighbor as lost after missing three hellos in a row, which is 6 seconds. In practice, link failure is detected much sooner, because a link going down is noticed directly. The 6 second path matters for failures that do not drop the link, such as a one-way fiber fault or a device that stops forwarding while the port stays up.
RSTP is backward compatible. If a port receives an 802.1D BPDU, that port falls back to 802.1D behavior and uses classic timers. This keeps mixed networks working, but that segment loses the fast convergence.
Link types and the proposal/agreement handshake
RSTP classifies each port by link type, derived from duplex:
- Point-to-point: full duplex. Rapid transitions are allowed.
- Shared: half duplex. Rapid transitions are not used, so the port behaves like classic STP.
- Edge: a port that connects to an end host, covered below.
On a point-to-point link, a newly designated port does not wait for timers. It runs a handshake:
- The designated port sends a BPDU with the proposal bit set and enters the discarding state.
- The neighbor receives the proposal. If the proposal comes from a better path to the root, the neighbor makes that port its root port.
- The neighbor then performs a sync. It blocks all of its other non-edge ports, which prevents a loop from forming while the topology is in flux.
- The neighbor replies with an agreement BPDU.
- The proposing port moves immediately to forwarding.
- The neighbor repeats the handshake toward its own downstream switches.
The handshake travels down the tree one link at a time, and each hop takes only the time to exchange BPDUs. Sync is the reason a topology change can briefly interrupt traffic on non-edge ports. It is also the reason edge ports matter: they are excluded from the sync and never need to be blocked.
Edge ports
An edge port faces a device that cannot be another switch, usually a host or server. It goes to forwarding at once, with no handshake. On Cisco IOS this is configured with PortFast. If an edge port receives a BPDU, it loses its edge status and becomes a normal spanning tree port, because a switch has apparently been attached. For that reason, edge ports are normally paired with BPDU Guard, covered in a later chapter.
Responding to failures
The following diagram shows the three outcomes when a link fails.
When a root port fails and an alternate port exists, the alternate port takes over without any wait. This is the case classic STP handles worst, since it makes the blocked port go through listening and learning.
Topology changes in RSTP
In 802.1D, any link change triggers a topology change notification that travels to the root and then out, and every switch shortens its MAC table aging time. RSTP handles this differently:
- Only a non-edge port moving to forwarding counts as a topology change. A host connecting or disconnecting does not.
- The switch that detects the change sends a BPDU with the topology change flag to its neighbors. Each switch that receives it flushes the MAC addresses learned on its other ports right away, instead of waiting for shortened aging.
- The flag floods through the network without going to the root first.
Flushing is correct, because stale MAC entries would point to ports that no longer lead to the host. The cost is a short burst of unknown-unicast flooding while tables relearn.
Enabling and checking RSTP
On Cisco switches, Rapid PVST+ runs RSTP per VLAN. It is configured as follows:
! Cisco IOS: use Rapid PVST+ and make this switch the root for VLAN 10
configure terminal
spanning-tree mode rapid-pvst
spanning-tree vlan 10 root primary
endThen check the result:
show spanning-tree vlan 10
show spanning-tree summaryIn the output, look at the role and status columns. Ports show Root, Desg, Altn or Back, with states FWD, LRN or BLK. The Type column shows P2p for point-to-point links, P2p Peer(STP) if a classic neighbor was detected, and Shared for half-duplex links. A Shared type on a link you expect to be full duplex usually means a duplex mismatch, and it disables the rapid handshake on that link.
On Linux, the kernel bridge supports STP but not RSTP in its default mode. For RSTP on Linux you need a user-space daemon such as mstpd, so a bridge created with stp_state 1 runs classic 802.1D.
Common mistakes
- Mixing classic and rapid switches without noticing. A single 802.1D neighbor pulls that link back to classic timers.
- Half-duplex or mismatched duplex links. The port is treated as shared and converges slowly.
- Leaving host ports as normal ports. Without PortFast, a host port runs the full handshake, and it counts as a topology change when it comes up.
- Assuming RSTP changes root election. It does not. Priorities and costs still decide the tree.
Exercise
A switch has a root port to Switch A and a blocked port to Switch B that receives better BPDUs from Switch B than its own would be. The link to Switch A fails. In 802.1D this port would take about 30 seconds to forward. What is its RSTP role, and what happens in RSTP?
Show answer
The blocked port is an alternate port, a standby path to the root. When the root port link fails, the alternate port becomes the new root port immediately and moves to forwarding with no timer wait. The switch then sends a topology change so other switches flush MAC entries learned through the old path.
Exercise
A port connected to a server shows type Shared in show spanning-tree. Why is this a problem, and what is the likely cause?
Show answer
Shared means the port is treated as half duplex, so RSTP does not use the rapid proposal and agreement handshake on it and it converges like classic STP. The likely cause is a duplex mismatch or auto-negotiation failure. Fix the duplex setting so the link is full duplex, and configure the port as an edge port with PortFast if it faces a host.