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.
| Role | Short | Rule | Forwards? |
|---|---|---|---|
| Root port | RP / Root | Best path towards the root on a connected non-root switch | When in forwarding state |
| Designated port | DP / Desg | Advertises the best root information on a segment | When in forwarding state |
| Alternate (RSTP) | Altn | Another path towards the root through a different bridge | No, normally discarding |
| Backup (RSTP) | Back | Redundant connection from the same bridge to the same shared segment | No, normally discarding |
| Not participating | Disabled / none | Port is shut down or has no operational link | No |
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
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. SW2, option 1: the BPDU from SW1 says cost 0. SW2 adds its port cost (4). So the direct link costs 4.
- 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. SW3 does the same: 4 directly, or 8 through SW2. So its direct link is its root port too.
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
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:
- Lowest root path cost.
- Lowest sender bridge ID: the BPDU from the better neighbour switch wins.
- Lowest sender port priority (default 128). This only matters when there are several links to the same neighbour.
- Lowest sender port number.
- 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
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. 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. Compare root path cost. Both are 4 away from the root. It's a tie.
- 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.
The designated port is chosen in the same way:
- Lowest root path cost of the switch on each end.
- Lowest bridge ID of the switch on each end.
- Lowest port priority, then port number, of the port on each end.
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
show spanning-tree summary; LED colours alone do not establish a port role or state.The redundant port stays non-forwarding
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. 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.
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:
| One end | Other end | Typical example |
|---|---|---|
| Designated | Root port | Every link that's part of the tree |
| Designated | Blocked (alternate) | A redundant link |
| Designated | An end device (it doesn't run STP) | Ports to PCs, printers, servers |
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
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. Root and its ports. A has the lowest bridge ID (…0A), so it's the root. All its ports are designated.
- 2. Root ports for B and C: each one reaches A directly, at cost 4.
- 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. 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.
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 10SW3 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
How many root ports does the root bridge have?
SW2 and SW3 advertise the same root and cost on their shared link. SW2 has the lower bridge ID. Which end is designated?
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.