Course contents

Chapter 6: Spanning Tree ProtocolLesson 2 of 25

What Spanning Tree does

Can we keep the backup cable without letting broadcasts run around the triangle? Let's follow the paths that spanning tree allows, then fail one link in an isolated lab.

Beginner · 5 min read

Keep the cable, change its forwarding state

SW1, SW2 and SW3 form a triangle. PC A connects to SW2 and PC B to SW3. Both PCs belong to VLAN 10, the same logical Layer 2 network. PC A is 192.168.10.10/24 and PC B is 192.168.10.20/24. They can communicate directly through the switches without an IP routing hop.

Spanning Tree Protocol (STP) makes selected ports stop forwarding user frames for a tree so that no active Layer 2 circle remains. It does not unplug the cable or run shutdown. The switch still needs to receive the protocol information used to decide whether that port should remain non-forwarding.

A Bridge Protocol Data Unit (BPDU) is the control message used to exchange that information. A root bridge is the switch elected as the reference point for path selection. SW1 is our root; it is not a default gateway, and user traffic does not have to visit it unless the selected path requires that.

The cables stay a triangle, the paths become a tree

STP doesn't change the cables. It only changes which ports are allowed to forward traffic. The physical topology (how the cables connect) is still a triangle. The logical topology (the paths traffic can really use) becomes a tree. A tree has exactly one path between any two switches, so a frame has no circle to go round.

Diagram
Spanning Tree blocks one port to break the loop
Spanning Tree blocks one port to break the loop
DPRPDPRPDPALTSW1priority 24576SW2priority 32768SW3priority 32768PC APC B

Device key: SW1, SW2, SW3 (switch) · PC A, PC B (computer)

Lines show the example’s network connections. The coloured path and envelope follow the current step; its text identifies the sender, receiver and traffic type. Blocked: forwarding prevented by a port or policy. Down: failed link. Read the step for the cause.

  1. 1. The same broadcast as in the last lesson… PC A sends one broadcast.
  2. 2. SW2 floods it… to SW1 and to SW3, the same as before.
  3. 3. …but one port is blocked. STP has blocked SW3's port on the SW2–SW3 link. So SW3 throws away the copy from SW2.
  4. 4. Exactly one copy arrives. The copy from SW1 reaches PC B. There is no loop and no storm.
SW3's side of the SW2–SW3 link is non-forwarding for this tree. PC B receives the broadcast through SW1; the direct copy from SW2 is discarded at SW3.

Why one blocked port is enough: a loop needs a full circle of forwarding ports. Break the circle in one place and the loop is gone. In a larger topology, the switches make the same kind of selection per tree instance, leaving a loop-free connected set of paths where the links are healthy.

What a blocked port still does

Here blocked is the familiar classic-STP term for a healthy non-forwarding port. Rapid Spanning Tree Protocol (RSTP) calls the comparable state discarding. Cisco output can still display BLK. A port role explains the port's job; a state explains whether it is currently learning or forwarding.

OperationHealthy blocked/discarding portForwarding port
Forwards user framesNo: throws them awayYes
Learns MAC addressesNoYes
Receives BPDUs (STP messages)Yes: keeps listeningYes
Physical linkCan remain upMust be operational to carry traffic

A blocked port is not broken. It is a standby path. It keeps receiving BPDUs. When the topology changes, the protocol can select another forwarding path. Detection and transition take time; this is not a promise of instant recovery.

A port LED alone is not a reliable STP diagnosis: colours and meanings depend on the switch and selected LED mode. Check the interface link state and spanning-tree output. An interface can be up/up while user forwarding is deliberately blocked for a VLAN.

When a link fails, STP unblocks the backup

SW3 normally uses its direct link to SW1. Its other uplink towards SW2 is an alternate port in RSTP: a different path towards the root. If the direct link fails, that alternate can become SW3's root port, the selected port towards the root bridge.

Diagram
Spanning Tree unblocks the backup path after a failure
Spanning Tree unblocks the backup path after a failure
DPRPDPRPDPALTSW1priority 24576SW2priority 32768SW3priority 32768PC APC B

Device key: SW1, SW2, SW3 (switch) · PC A, PC B (computer)

Lines show the example’s network connections. The coloured path and envelope follow the current step; its text identifies the sender, receiver and traffic type. Blocked: forwarding prevented by a port or policy. Down: failed link. Read the step for the cause.

  1. 1. Normal. PC B reaches SW1 directly.
  2. 2. The SW1–SW3 cable fails. SW3 stops hearing from SW1 on that cable.
  3. 3. The backup takes over. STP unblocks SW3's port toward SW2. Now traffic goes through SW2. How fast this happens depends on the STP version (Modules 2 and 4).
The direct SW3–SW1 link is down. SW3 can reach SW1 through SW2 after the protocol selects and activates the replacement path. Recovery timing depends on the mode and failure.

Original STP uses timer-driven listening and learning stages before ordinary ports begin forwarding. RSTP adds faster role transitions and a proposal/agreement exchange on suitable point-to-point links. Mixed legacy neighbours, shared links and failure detection can change the outcome. Check the switch's active mode with show spanning-tree summary; do not infer it from the device being a Cisco switch.

Three things STP gives you, and one cost

  • Loop-free forwarding: a connected tree has one selected path between switch pairs for that instance.
  • Automatic backup: spare paths stay connected and are turned on when needed.
  • Automatic calculation: switches exchange control messages and select roles; engineers still plan the root and protection policy.

The downside: an independent path carries no user traffic for the tree that blocks it, so that tree does not use all physical capacity at once. Control traffic still matters. Per-VLAN Spanning Tree (Module 3) can block different links for different VLANs, so more links are used.

Short lab: fail the active uplink and restore it

Use an isolated Cisco IOS/IOS XE triangle with VLAN 10, Rapid PVST+ already working, SW1 as root and SW2's bridge ID lower than SW3's. SW3 Gi1/0/1 connects to SW1; Gi1/0/2 connects to SW2. Check these cables first. Gigabit links use cost 4 in the short-cost example; a long-cost method displays different numbers.

Illustrative Rapid PVST+ excerpt · selected uplinks, not a lab capture
SW3#show spanning-tree vlan 10
Interface        Role Sts Cost      Prio.Nbr Type
Gi1/0/1          Root FWD 4         128.1    P2p
Gi1/0/2          Altn BLK 4         128.2    P2p
Before failure, Gi1/0/1 is the root-facing forwarding port and Gi1/0/2 is the alternate. Altn is the role; BLK is the displayed non-forwarding state.
configure terminal interface GigabitEthernet1/0/1 shutdown end show spanning-tree vlan 10

SW3 only, isolated lab. Disable the verified direct uplink to SW1 and check the role of Gi1/0/2 after convergence. It should become the root-facing forwarding port through SW2.

Test PC A to PC B and record any loss; do not assume recovery is lossless. Restore SW3 Gi1/0/1 with no shutdown, then confirm it is Root/FWD again and Gi1/0/2 returns to the alternate role. Leave STP enabled and the original cable state restored.

Test yourself on blocked ports

Predict · scenario 1

Does STP physically disconnect the redundant cable?

Predict · scenario 2

SW3's uplink is up/up but shows Altn BLK for VLAN 10. What does that mean?

Predict · scenario 3

A network has 4 switches in a square (4 links). How many ports must STP block to remove the loop?

Sources: Cisco RSTP roles, states and transitions; Cisco STP modes and verification. Commands and output are illustrative and not captures from a tested switch image.