Course contents

Chapter 6: Spanning Tree ProtocolLesson 6 of 25

Spanning Tree port roles

Two uplinks are up, but only one leads towards the root in the active tree. How does the switch choose, and what job does the spare port have? Let's compare the information on each link.

Intermediate · 6 min read

A port's job is different from its current state

The root bridge is the elected reference switch for a spanning-tree instance. A port role describes how a switch port fits into that tree. Its state describes what it currently does with user frames. A port can already have the root role while it is still preparing to forward.

We follow VLAN 10 on the three-switch triangle. SW1 has configured bridge priority 24576; SW2 and SW3 use 32768. SW2 has the lower bridge MAC than SW3, so its bridge ID, priority plus the VLAN extension and MAC address, wins their tie. All inter-switch links are gigabit with short-method cost 4. Other cost methods can display different values.

PC A on SW2 is 192.168.10.10/24; PC B on SW3 is 192.168.10.20/24. Their addresses identify the endpoints, but STP chooses by bridge information and cost, not by those IP addresses. On SW2 and SW3, Gi1/0/1 reaches SW1, Gi1/0/2 joins SW2 to SW3, and Gi1/0/10 reaches the local PC.

Diagram
A port's job is different from its current state
A port's job is different from its current state
RoleShortRuleForwards?
Root portRP / RootBest path towards the root on a connected non-root switchWhen in forwarding state
Designated portDP / DesgAdvertises the best root information on a segmentWhen in forwarding state
Alternate (RSTP)AltnAnother path towards the root through a different bridgeNo, normally discarding
Backup (RSTP)BackRedundant connection from the same bridge to the same shared segmentNo, normally discarding
Not participatingDisabled / nonePort is shut down or has no operational linkNo
Read each row across: the left box names the item, the others describe it.

Root ports: compare paths towards the root

Every switch except the root asks: which of my ports has the lowest-cost way to reach the root? It looks at the BPDUs (Bridge Protocol Data Units), the control messages that arrive on each port. It takes the cost written in the BPDU and adds the cost of its own port.

Compare the direct and indirect paths in the triangle
Diagram
SW2 and SW3 choosing their root ports
SW2 and SW3 choosing their root ports
SW1priority 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.

  1. 1. SW2, option 1: the BPDU from SW1 says cost 0. SW2 adds its port cost (4). So the direct link costs 4.
  2. 2. SW2, option 2: SW3's BPDU says cost 4. Adding SW2's port cost makes 8. 4 is less than 8, so the direct port is SW2's root port.
  3. 3. SW3 does the same: 4 directly, or 8 through SW2. So its direct link is its root port too.
Both paths lead to the same root. Add the receiving port's local cost to the neighbour's advertised root cost. The direct path costs 4 instead of 8.
Illustrative Cisco IOS/IOS XE excerpt · VLAN 10, short cost method
SW2#show spanning-tree root
                                        Root    Hello Max Fwd
Vlan                   Root ID          Cost    Time  Age Dly  Root Port
---------------- -------------------- --------- ----- --- ---  ------------
VLAN0010         24586 0200.0000.0001         4    2   20  15  Gi1/0/1
The quickest way to see a switch's root port. Here it is Root Port Gi1/0/1, with a total Cost of 4.

When two paths cost the same

First prefer the lowest root ID if the advertised roots differ. Once both candidates describe the same root, compare the following values in order:

  1. Lowest root path cost.
  2. Lowest sender bridge ID: the BPDU from the better neighbour switch wins.
  3. Lowest sender port priority (default 128). This only matters when there are several links to the same neighbour.
  4. Lowest sender port number.
  5. Lowest local receiving port ID, if the received information still ties, for example through shared media.

Notice the word sender in rules 2–4. The switch looks at the neighbour's port at the other end of the cable first. A smaller local port number is not an earlier tie-breaker than the sender's bridge and port IDs.

Designated ports: compare information on each segment

A segment is the shared Layer 2 connection being considered. On each segment, the switch port advertising the best root information is designated. On the SW2–SW3 segment, both switches are cost 4 from SW1. SW2's lower bridge ID breaks the tie, so its end is designated and SW3's end is alternate.

Receiving a BPDU on a port is normal protocol behaviour, not proof by itself that a loop exists. The switch compares the received information with the information it would advertise. Classic STP relays updated root information on designated ports; RSTP bridges also generate periodic BPDUs from their own current information.

See the designated-port comparison on SW2–SW3
Diagram
Choosing one designated port on the SW2–SW3 link
Choosing one designated port on the SW2–SW3 link
SW1priority 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. Compare information on the shared segment. SW2 and SW3 can advertise SW1 as root. They compare the root cost and bridge ID to decide which end is designated.
  2. 2. Compare root path cost. Both are 4 away from the root. It's a tie.
  3. 3. Compare sender bridge ID. The priority is the same, and SW2's MAC is lower. So SW2's port wins and stays designated. SW3's port becomes alternate and blocks.
Equal root path costs leave the bridge ID comparison to decide the segment. The result assumes SW2's bridge ID is lower than SW3's.

The designated port is chosen in the same way:

  1. Lowest root path cost of the switch on each end.
  2. Lowest bridge ID of the switch on each end.
  3. Lowest port priority, then port number, of the port on each end.
Illustrative Rapid PVST+ excerpt · converged triangle, selected ports
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
Gi1/0/10            Desg FWD 4         128.10   P2p
On SW3: Root toward SW1, Altn BLK (alternate, blocking) toward SW2, and Desg (designated) toward PC B. Verify the mode with show spanning-tree summary; LED colours alone do not establish a port role or state.

The redundant port stays non-forwarding

Diagram
The converged tree
The converged tree
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. Loop-free: the cables still form a triangle, but traffic between SW2 and SW3 goes through SW1. The SW2–SW3 link waits as a backup.
For VLAN 10, SW3's alternate port does not forward user frames on the direct SW2–SW3 link. PC A reaches PC B through SW1. The physical backup cable remains connected.

An alternate port is a second path to the root. It is not used because another path is better. It stays blocked. If the root port fails, it may be selected as the replacement after the protocol validates the new topology. The timing depends on the mode, link type and failure.

What "segment" means

STP says "one designated port per segment", not per link. This is because STP was designed when several devices could share one segment through a hub. Today almost every segment is a single cable between two devices. So a link can usually has one of these combinations in a converged healthy tree:

Diagram
What "segment" means
What "segment" means
One endOther endTypical example
DesignatedRoot portEvery link that's part of the tree
DesignatedBlocked (alternate)A redundant link
DesignatedAn end device (it doesn't run STP)Ports to PCs, printers, servers
Read each row across: the left box names the item, the others describe it.

A converged participating segment selects one designated port for its tree. On a shared hub segment, the other switches could each have a root port or a blocked port there. But there was still only one designated port. RSTP's backup role can occur when two ports from one bridge reach that same shared segment. It is different from an alternate path through another switch.

Worked example: four switches in a square

All four switches have priority 32768. Every link is 1 Gbps (cost 4). The MAC addresses are: A …0A, B …0B, C …0C, D …0D.

Work through a second topology: four switches in a square
Diagram
Port roles in a four-switch square
Port roles in a four-switch square
DPRPDPRPDPRPDPBLKA (root)MAC …0ABMAC …0BCMAC …0CDMAC …0D

Device key: A (root), B, C, 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. Root and its ports. A has the lowest bridge ID (…0A), so it's the root. All its ports are designated.
  2. 2. Root ports for B and C: each one reaches A directly, at cost 4.
  3. 3. D has a tie: cost 8 through B, and cost 8 through C. The lower sender bridge ID wins, which is B (…0B). So D's root port faces B.
  4. 4. The C–D link: C is 4 from the root and D is 8. So C's end is designated and D's end blocks. The blocked port ends up on the switch furthest from the root.
This separate square keeps equal link costs and priorities. MAC order makes A root; sender bridge ID makes D prefer B, leaving D's port towards C non-forwarding.

Rules of thumb for port roles

  • The root has no root port for its own instance. Its ports on the independent links shown are designated.
  • A connected non-root switch chooses one root port per instance.
  • A segment selects one designated port per instance after convergence.
  • Compare root information and cost before bridge and port-ID tie-breakers.
  • Do not infer a blocked port's location from physical distance; the cost and identifier comparisons decide.

In practice, when a port blocks somewhere unexpected, the first thing to check is which switch is the root. Once the right switch is the root, the blocked ports usually move to where the design expects them.

Short lab: change one path cost and restore it

Use the isolated triangle with Rapid PVST+ already enabled, SW1 as root, SW3 Gi1/0/1 towards SW1 and Gi1/0/2 towards SW2. Both links initially have cost 4. Record the configuration and verify the topology before changing anything.

show spanning-tree summary show spanning-tree vlan 10 show running-config interface GigabitEthernet1/0/1 configure terminal interface GigabitEthernet1/0/1 spanning-tree vlan 10 cost 20 end show spanning-tree vlan 10

SW3 only, starting in privileged EXEC. Compare direct cost 20 with the path through SW2: SW2's cost 4 plus local Gi1/0/2 cost 4 equals 8. After convergence Gi1/0/2 should be SW3's root port.

On SW1–SW3, SW1 still advertises root cost zero, so its end remains designated. SW3's direct port becomes the alternate. Test PC A to PC B after convergence. Restore the exact original interface cost configuration: use no spanning-tree vlan 10 cost if no override existed, or reapply the recorded value. Confirm the original roles return. Never change mode or disable STP to make this comparison.

Test yourself on port roles

Predict · scenario 1

How many root ports does the root bridge have?

Predict · scenario 2

SW2 and SW3 advertise the same root and cost on their shared link. SW2 has the lower bridge ID. Which end is designated?

Predict · scenario 3

In the square, B's priority is changed to 61440. Which port does D block?

Sources: Cisco roles, states and BPDU comparison; Cisco IOS XE STP cost and verification commands. Outputs are illustrative, not captures from a tested switch image.