Sub topic 9
Timers and why classic STP converges slowly
This chapter assumes you know how BPDUs carry root and cost information, how the root bridge is elected, and what the root, designated, and blocked port roles mean. It also assumes you know the four classic 802.1D port states (blocking, listening, learning, forwarding). Here you will see the three timers that govern those states, work out how long a failure takes to heal, and learn why the numbers are what they are.
The three timers
Classic STP (IEEE 802.1D) is timer-driven. A switch does not know that the topology is loop-free. It waits long enough that stale information has expired everywhere before it lets a port forward. Three timers control this.
| Timer | Default | Set by | What it controls |
|---|---|---|---|
| Hello | 2 seconds | Root bridge | How often the root originates a configuration BPDU. Other switches relay it. |
| Forward delay | 15 seconds | Root bridge | How long a port spends in listening and again in learning. |
| Max age | 20 seconds | Root bridge | How long a switch keeps the best BPDU received on a port before declaring it stale. |
Only the values configured on the root bridge matter. The root writes its hello, forward delay, and max age into every BPDU it sends. Every other switch adopts those values and ignores its own local settings. This keeps the whole network on one clock. It also means that changing a timer on a non-root switch has no effect until that switch becomes the root.
Each BPDU also carries a message age field. The root sends it with an age of 0. Each switch that relays it adds about 1 second. A BPDU is discarded when its message age reaches max age. This ties max age to network size, and it is the reason for the "diameter" limit described later.
What happens after a failure
Consider a switch whose root port is on a link that goes down, while an alternate path exists through a blocked port. There are two very different cases.
Direct failure. The link carrying the root port loses its signal. The switch sees the failure immediately and does not need to wait for max age. It picks the blocked port as the new root port. That port still has to move through listening and learning before it forwards.
Indirect failure. The failure happens somewhere else, and the switch only learns of it because BPDUs stop arriving. For example, a link between the root and a neighbor fails, or a device in the middle stops forwarding BPDUs without dropping the link. The local port stays up. The switch has to wait for max age to expire before it treats the stored BPDU as stale.
The default worst-case recovery times follow from the timers:
| Case | Calculation | Time |
|---|---|---|
| Direct failure | Listening (15) + learning (15) | 30 seconds |
| Indirect failure | Max age (20) + listening (15) + learning (15) | 50 seconds |
During this time the affected part of the network has no forwarding path through the changed ports. Applications see a stall of 30 to 50 seconds, which is long enough to drop TCP sessions and VoIP calls.
Why the delays exist
The forward delay is deliberately long. A port that begins forwarding too early can create a temporary loop before the rest of the network has agreed on the new tree. A loop can saturate links in milliseconds, so STP prefers to be slow and safe.
Each of the two forward-delay intervals has a job:
- Listening (15 s). The port sends and receives BPDUs but does not learn MAC addresses or forward data. This gives any competing BPDUs time to arrive, so the switch can discover that it should not forward on this port after all.
- Learning (15 s). The port builds its MAC table from the frames it sees but still does not forward them. When forwarding starts, the table is already populated, so the switch avoids flooding unknown unicast traffic.
Max age exists for a similar reason. A switch cannot distinguish "the root is gone" from "a BPDU was lost" after one missed hello. It waits for several hello intervals' worth of time (default 20 s, ten hellos) before it acts on missing information.
Timer relationships and the diameter
The three values are not independent. The 802.1D standard gives these constraints:
- Max age must be at least 2 × (hello + 1).
- Max age must be no more than 2 × (forward delay − 1).
With the defaults, 2 × (2 + 1) = 6 and 2 × (15 − 1) = 28, so 20 sits inside the allowed range.
The defaults assume a network diameter of 7 switches, meaning no path between two switches crosses more than 7 bridges. Message age grows by about 1 per hop, so a BPDU that has crossed 7 switches is still well within max age. A larger network can need larger timers, and a smaller one can use smaller timers.
On Cisco IOS you do not set the three timers independently by guesswork. You can set the diameter on the root, and the switch computes timers from it:
! Cisco IOS: tell the root bridge the expected network diameter
configure terminal
spanning-tree vlan 10 root primary diameter 4
endYou can also set the timers directly on the root:
! Cisco IOS: set timers on the root bridge for VLAN 10
configure terminal
spanning-tree vlan 10 hello-time 2
spanning-tree vlan 10 forward-time 10
spanning-tree vlan 10 max-age 14
endThese values satisfy both constraints: 2 × (2 + 1) = 6 ≤ 14 ≤ 2 × (10 − 1) = 18.
Checking the timers
The show spanning-tree output lists the timers in effect. The root section shows the values the root advertises, and the bridge section shows the local configuration.
VLAN0010
Spanning tree enabled protocol ieee
Root ID Priority 4106
Address 0011.2233.4401
This bridge is the root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 4106 (priority 4096 sys-id-ext 10)
Address 0011.2233.4401
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300 secOn a non-root switch the Root ID lines show the timers learned from the root, and these are the ones in use. The Bridge ID lines show the switch's own configured values, which are used only if it becomes the root.
Common errors
- Setting timers on the wrong switch. The change has no effect because the root's values override it.
- Violating the timer constraints. Inconsistent values can make the switch reject the configuration or make the network unstable.
- Confusing a 30 second stall with a fault. With classic STP, a port coming up on a host-facing link takes 30 seconds to forward. This is why DHCP can time out on workstations when PortFast is missing.
- Blaming STP for aging time. The MAC aging time (default 300 s) is separate from the STP timers. After a topology change, the root sets the aging time to forward delay for a short period, which the next chapter covers.
Summary of key numbers
- Hello 2 s, forward delay 15 s, max age 20 s, all taken from the root.
- Listening and learning together take 2 × forward delay = 30 s.
- Indirect failure adds max age: 20 + 30 = 50 s.
- The defaults assume a diameter of 7.
Exercise
A non-root switch in VLAN 10 loses its root port when the cable is unplugged, and a blocked port on another link leads to the root. A different network has a switch whose root port stays up, but the neighbor on that link silently stops forwarding BPDUs. Using default timers, how long does each switch take to start forwarding on its new root port, and why do the times differ? Also, an administrator sets forward-time 5 on a non-root switch. What effect does that have?
Show answer
The first switch detects the loss of link immediately, so it only waits through listening (15 s) and learning (15 s), about 30 seconds. The second switch sees no link failure. It must wait for max age (20 s) to expire before it discards the stored BPDU, then go through listening and learning, about 50 seconds. The difference is the max age wait. Setting forward-time 5 on a non-root switch has no effect, because switches use the forward delay carried in the root's BPDUs. The value is used only if that switch becomes the root.
Exercise
Check whether these root-bridge timers are valid under the 802.1D constraints: hello 2, forward delay 7, max age 20.
Show answer
Max age must be no more than 2 × (forward delay − 1) = 2 × 6 = 12. Since 20 is greater than 12, the combination is invalid. Either lower max age to 12 or less, or raise forward delay to at least 11 (2 × 10 = 20).