Course contents

Chapter 6: Spanning Tree ProtocolLesson 9 of 25

Lab: manual STP computation

Work out the root bridge, every port role and the blocked port on paper, then check your answer.

Intermediate · 20 min read

Technical definition

The Spanning Tree computation is the process every switch running STP follows: elect the root bridge with the lowest bridge ID, choose one root port on each non-root switch with the lowest path cost to the root, choose one designated port on each segment, and block every remaining port.

Four switches and one slow link

Four switches, all with the default priority 32768. They run classic STP with short path costs. Notice that one link is slower than the others.

Diagram
Lab topology: four switches with one 100 Mbps link
Lab topology: four switches with one 100 Mbps link
1 Gbps · Gi0/1 ↔ Gi0/1100 Mbps · Gi0/2 ↔ Gi0/11 Gbps · Gi0/2 ↔ Gi0/11 Gbps · Gi0/2 ↔ Gi0/2SW-A32768 · …000ASW-B32768 · …000BSW-C32768 · …000CSW-D32768 · …000D

Device key: SW-A, SW-B, SW-C, SW-D (switch)

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.

  1. 1. Your job: work out the tree these switches will build. Write down each answer before you open it.
LinkSpeedSTP costPorts
SW-A – SW-B1 Gbps4A Gi0/1 ↔ B Gi0/1
SW-A – SW-C100 Mbps19A Gi0/2 ↔ C Gi0/1
SW-B – SW-D1 Gbps4B Gi0/2 ↔ D Gi0/1
SW-C – SW-D1 Gbps4C Gi0/2 ↔ D Gi0/2

Task 1: which switch is the root bridge?

Show answer

SW-A. All priorities are 32768, so the lowest MAC address wins: …000A.

Task 2: the root port and cost of each other switch

Start at the root and work outward: B first, then D, then C.

Show answer
Diagram
Task 2: the root port and cost of each other switch
Task 2: the root port and cost of each other switch
SwitchOptionsRoot portCost
SW-BDirect to A: 4Gi0/14
SW-DThrough B: 4 + 4 = 8 · through C: 4 + C's costGi0/1 (toward B)8
SW-CDirect to A: 19 · through D: 4 + 8 = 12Gi0/2 (toward D)12
Read each row across: the left box names the item, the others describe it.

The surprise is SW-C. Its direct link to the root costs 19. But the long way round, through D and B, costs only 12. STP compares cost, not the number of switches.

Task 3: the designated port on each link

Writing each switch's root path cost next to it on paper makes this step quick: on every link, the end with the lower number is designated.

Show answer
LinkCompare root path costDesignated port
A – BA 0 vs B 4SW-A Gi0/1
A – CA 0 vs C 12SW-A Gi0/2
B – DB 4 vs D 8SW-B Gi0/2
C – DD 8 vs C 12SW-D Gi0/2

Task 4: which port is blocked?

Show answer and the finished tree

SW-C Gi0/1, its port on the slow link to SW-A. It is not C's root port, and SW-A's end of the link is designated. So this port is blocked.

Diagram
Lab answer: the finished spanning tree
Lab answer: the finished spanning tree
DPRPDPBLKDPRPRPDPSW-A32768 · …000ASW-B32768 · …000BSW-C32768 · …000CSW-D32768 · …000D

Device key: SW-A, SW-B, SW-C, SW-D (switch)

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. SW-C's path to the root: C → D → B → A, total cost 12. It avoids the slow direct link.
  2. 2. The slow link is the backup. SW-C Gi0/1 is blocked. It only forwards if the path through D fails.

Bonus: upgrade the slow link

The A–C link is upgraded to 1 Gbps (cost 4). Work everything out again.

Show answer
  • SW-C: direct to A = 4, so its root port becomes Gi0/1 (cost 4).
  • SW-D: through B = 8, through C = 8. It's a tie. The lower sender bridge ID wins, which is SW-B (…000B). So D's root port stays Gi0/1.
  • Link C–D: C is cost 4, D is cost 8, so SW-C Gi0/2 is designated.
  • Blocked: SW-D Gi0/2 (toward C). The blocked port has moved to the other side of the square.