> ## Content Index
> Fetch the complete content index at: https://www.pinglabz.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# STP Path Cost and How Cisco Switches Calculate the Best Path
- URL: https://www.pinglabz.com/stp-path-cost-calculation/
- Published: 2026-03-27T05:16:12.000Z
- Updated: 2026-08-24T17:01:25.000Z
- Description: Path cost is the core metric STP uses to select root ports and designated ports. Understanding cost calculation, link speeds, and manual cost override is essential to designing networks with predictable failover behavior.
- Author: Jaime
- Tags: STP, #Import 2026-08-01 19:54

## Path Cost Fundamentals

**Path cost** is the metric spanning tree uses to determine the best (shortest/cheapest) path to the root bridge. Each link in the network has an associated cost based on its speed. The total **root path cost** is the sum of all link costs from a non-root switch to the root.

New to STP? Start with the [full spanning-tree guide](https://www.pinglabz.com/spanning-tree-protocol/), then come back here for the deep dive.

Example:

```
[SW1] ─────────── [SW2] ─────────── [SW3]
  (root)  1 Gbps    cost 4   1 Gbps    cost 4
                  Root path = 0 + 4 + 4 = 8 on SW3

```

Lower cost = better path = preferred for root port selection.

## Link Costs by Speed

Cisco defines path costs based on link speed. There are two standards: **802.1D old values** and **modern (802.1D-2004) values**. Modern switches default to the newer values, but both are valid.

### Cost Table

10 Mbps

802.1D Value100

Modern Value2,000,000

Ratio20,000×

100 Mbps

802.1D Value19

Modern Value200,000

Ratio\~10,500×

1 Gbps

802.1D Value4

Modern Value20,000

Ratio5,000×

10 Gbps

802.1D Value1

Modern Value2,000

Ratio2,000×

100 Gbps

802.1D Value \- 

Modern Value200

Ratio \- 

400 Gbps

802.1D Value \- 

Modern Value50

Ratio \- 

The modern values maintain 20,000,000 ÷ speed formula for future extensibility.

### Why Two Values?

The old values had minimal difference between fast links:

```
802.1D:
  1 Gbps: 4
  10 Gbps: 1 (only 4× faster, but cost is 1 instead of 4)
  100 Gbps: would be 0.01 (invalid)

```

Modern values scale better:

```
Modern:
  1 Gbps: 20,000
  10 Gbps: 2,000 (10× faster, cost is 10× lower)
  100 Gbps: 200 (100× faster, cost is 100× lower)
  400 Gbps: 50 (400× faster, cost is 400× lower)

```

### Checking Which Values Your Switch Uses

```
SW1# show spanning-tree pathcost method

Extended system ID           enabled
Pathcost method used         long

```

- **short**: Old 802.1D values (100, 19, 4, 1)
- **long**: Modern values (2,000,000, 200,000, 20,000, 2,000)

To change (if needed):

```
SW1(config)# spanning-tree pathcost method long

```

Cisco recommends **long** for all new deployments.

## Calculating Root Path Cost

Root path cost is calculated hop by hop. Each switch adds the cost of its port facing the next hop.

### Example 1: Linear Topology

```
[SW1] Eth0/0 ──── Eth0/0 [SW2] Eth0/1 ──── Eth0/1 [SW3] Eth0/2 ──── Eth0/2 [SW4]
(root)  1 Gbps                  1 Gbps                   1 Gbps
         cost 4                  cost 4                   cost 4

```

#### SW2's Calculation

SW2 receives BPDU from SW1 (root):

```
BPDU from SW1:
  Root ID = SW1
  Root Path Cost = 0 (SW1 is root)
  Sender Port ID = 128.1 (Eth0/0)

SW2 receives on Eth0/0 (cost 4):
  SW2's root path cost = 0 (from root) + 4 (SW2 Eth0/0) = 4

SW2 sends BPDU out Eth0/1:
  Root ID = SW1 (unchanged)
  Root Path Cost = 4 (what SW2 calculated)
  Sender Port ID = 128.2 (Eth0/1)

```

#### SW3's Calculation

SW3 receives BPDU from SW2:

```
BPDU from SW2:
  Root ID = SW1
  Root Path Cost = 4 (from SW2)
  Sender Port ID = 128.2

SW3 receives on Eth0/1 (cost 4):
  SW3's root path cost = 4 (from BPDU) + 4 (SW3 Eth0/1) = 8

SW3 sends BPDU out Eth0/2:
  Root ID = SW1
  Root Path Cost = 8
  Sender Port ID = 128.1 (Eth0/2)

```

#### SW4's Calculation

```
Root path cost = 8 (from BPDU) + 4 (SW4 Eth0/2) = 12

```

Result:

```
Root path costs toward root:
  SW1: 0 (is root)
  SW2: 4 (one hop)
  SW3: 8 (two hops)
  SW4: 12 (three hops)

```

### Example 2: Mixed Link Speeds

```
[SW1] ──────────── [SW2] ──────────── [SW3]
 (root)  10 Gbps    cost 2,000  1 Gbps   cost 20,000

```

#### Calculations

```
SW2:
  Root path cost = 0 + 2,000 = 2,000

SW3:
  Root path cost = 2,000 + 20,000 = 22,000

Preferred link for data (if equal cost):
  Direct 1 Gbps link would have cost 20,000
  Going through 10 Gbps then 1 Gbps has cost 22,000
  Direct is slightly preferred

```

But if the topology was:

```
[SW1] ──────────── [SW2]
 (root)  10 Gbps
          cost 2,000
            |
            ├── (to SW3 via 100 Mbps)
            │   cost 200,000
            │
            └── (to SW3 via 1 Gbps)
                cost 20,000

```

Then 1 Gbps is clearly preferred (20,000 << 200,000).

## Verifying Costs in Real Networks

### Show Spanning-Tree Interface Cost

```
SW2# show spanning-tree vlan 1

Interface        Role Sts Cost      Prio.Nbr Type
──────────────────────────────────────────────────────
Eth0/0           Root FWD    4      128.1    P2p
Eth0/1           Desg FWD    4      128.2    P2p
Eth0/2           Desg FWD    4      128.3    P2p
Eth0/3           Desg FWD   19      128.4    P2p

```

The **Cost** column shows the port's link cost:

- 4 = 1 Gbps
- 19 = 100 Mbps
- 1 = 10 Gbps

### Checking Root Path Cost

```
SW4# show spanning-tree vlan 1 root

                                        Root    Hello Max Fwd
Vlan                   Root ID          Cost    Age  Dly Root Port
──────────────────────────────────────────────────────────────────
VLAN0001           4096 aabb.cc00.1100   12      2    20   15   Eth0/0

```

Root **Cost** is 12, which matches our linear topology example: SW1 (0) + SW2 (4) + SW3 (4) + SW4 (4) = 12.

### Show Spanning-Tree Detail with Port Costs

```
SW4# show spanning-tree vlan 1 detail | include "Path Cost|port cost"

Port 1 (Ethernet0/0)
  Port path cost 4
  Designated root has priority 4096, address aabb.cc00.1100

```

The switch is advertising its port cost as 4 (the cost of its link to SW3).

## Manually Setting Port Cost

Sometimes default costs don't reflect your network design. You might want to force a particular path, even if it's technically "slower," due to quality, congestion, or failover design.

### Setting Cost on a Single Port

```
SW4(config)# interface ethernet 0/0
SW4(config-if)# spanning-tree cost 8
SW4(config-if)# exit

```

Now SW4's root path cost becomes:

```
Old root path cost: 12
New: 8 (root path cost advertised by SW3) + 8 (our port cost) = 16

That is worse, not better. Raising a port cost makes the path less attractive.

```

To prefer this path:

```
SW4(config)# interface ethernet 0/0
SW4(config-if)# spanning-tree cost 2

```

New root path cost:

```
8 (from BPDU) + 2 (our new port cost) = 10

Much better, now this path is preferred.

```

### Verifying Manual Cost

```
SW4# show spanning-tree vlan 1 interface ethernet 0/0

Vlan                   Interface        Role Sts Cost      Prio.Nbr Type
────────────────────────────────────────────────────────────────────
VLAN0001               Eth0/0           Root FWD 2        128.1    P2p

```

Cost shows 2 instead of the default 4.

## Cost and EtherChannel

When multiple ports are bundled into EtherChannel, STP sees the entire channel as a single "port" with a single cost.

### Example: EtherChannel Setup

```
[SW2] ---------- [SW3]
  4 x 1 Gbps links bundled into Port-Channel 1

Default cost of a single 1 Gbps port: 4
EtherChannel cost: 1

```

#### EtherChannel Cost Calculation

The cost of an EtherChannel is:

```
EtherChannel cost = (Individual link cost) / (Number of active links in channel)

Example: 4 × 1 Gbps links bundled:
  Individual cost = 4
  Number of links = 4
  EtherChannel cost = 4 / 4 = 1

```

### Verifying EtherChannel Cost

```
SW2# show spanning-tree vlan 1 interface port-channel 1

Vlan                   Interface        Role Sts Cost      Prio.Nbr Type
────────────────────────────────────────────────────────────────────
VLAN0001               Port-Ch1         Desg FWD 1        128.65   P2p

```

Port-Channel 1 shows cost 1 (instead of 4 for a single link), so it's very attractive for root port selection.

### Setting EtherChannel Cost Manually

```
SW2(config)# interface port-channel 1
SW2(config-if)# spanning-tree cost 2

```

## Cost Considerations for Network Design

### Scenario: Preferring Direct Links Over Hop Count

```
[SW1] Eth0/1          [SW2] Eth0/1
 |        1 Gbps        |
 |      cost 4          |
 Eth0/0                 Eth0/2
 |                      |
[SW4] ────────────── [SW3]
  (2 hops via SW2)  (direct)
  cost 4 + 4 = 8    cost 4

```

By default, SW4 prefers the direct link to SW3 (cost 4) over going through SW2 (cost 8). This is correct if SW3 connects to root.

But what if SW1 is the root and SW3 is just another switch?

```
[SW1] ← Root
  |
  Eth0/0 (1 Gbps, cost 4)
  |
[SW2]
  |
  Eth0/1 (1 Gbps, cost 4)
  |
[SW3] ──── [SW4]
  cost 8     (wants shortest path to SW1)

```

SW4's choices:

```
Option A: SW4 → SW3 → SW2 → SW1
  Cost = 4 (SW4-SW3) + 4 (SW3-SW2) + 4 (SW2-SW1) = 12

Option B: SW4 → SW3 (only path, but SW3 then routes to SW1)
  Cost = 4, but SW3's cost to root is 8, so SW4's total = 4 + 8 = 12

```

Both are equal, so STP uses tie-breaker: lowest sender bridge ID.

To prefer the direct path (less congestion, fewer hops):

```
SW3(config)# interface ethernet 0/0
SW3(config-if)# spanning-tree cost 1

```

Now:

```
Option B: SW4 → SW3 (cost 1 + SW3 to root cost 5) = 6 (much better)

```

### Scenario: Load Balancing Across VLANs

On a Catalyst 9300 running PVST+, each VLAN has its own spanning tree:

```
VLAN 10 (Users):
  Preferred root: SW1

VLAN 20 (Servers):
  Preferred root: SW2

[SW1] ─┬─ [SW2]
       │
     [SW3]

```

On VLAN 10, make SW1 the root and use direct link from SW3 to SW1.  
On VLAN 20, make SW2 the root and use direct link from SW3 to SW2.

This distributes traffic across both uplinks:

```
VLAN 10: SW3 → SW1 (40% of traffic)
VLAN 20: SW3 → SW2 (40% of traffic)
Remaining: Split or unused

```

Implementation:

```
! On SW1:
SW1(config)# spanning-tree vlan 10 priority 4096

! On SW2:
SW2(config)# spanning-tree vlan 20 priority 4096

! On SW3, make VLAN 10 prefer SW1:
SW3(config)# interface ethernet 0/0  ! To SW1
SW3(config-if)# spanning-tree vlan 10 cost 2

! On SW3, make VLAN 20 prefer SW2:
SW3(config)# interface ethernet 0/1  ! To SW2
SW3(config-if)# spanning-tree vlan 20 cost 2

```

Now each VLAN uses its preferred root.

## Verifying and Troubleshooting Cost

### Problem: Unexpected Root Port Selection

If a switch chose an unexpected root port:

```
SW3# show spanning-tree vlan 1 root

                                        Root    Hello Max Fwd
Vlan                   Root ID          Cost    Age  Dly Root Port
──────────────────────────────────────────────────────────────────
VLAN0001           4096 aabb.cc00.1100   22000   2    20   15   Eth0/2

```

Cost is 22,000 (higher than expected). Check:

1. Is Eth0/2 a 1 Gbps link (cost 20,000)?
2. Is the upstream switch's path cost 2,000 (10 Gbps link)?
3. Is the port cost manually overridden?

```
SW3# show spanning-tree vlan 1 interface ethernet 0/2

Vlan                   Interface        Role Sts Cost      Prio.Nbr Type
────────────────────────────────────────────────────────────────────
VLAN0001               Eth0/2           Root FWD 20000    128.3    P2p

```

Cost is default 20,000 for 1 Gbps. The root path cost (22,000) means upstream cost is 2,000, indicating a 10 Gbps link first, then 1 Gbps here.

### Problem: Manual Cost Not Applied

If you set a cost manually but STP still chose a different path:

```
SW4(config)# interface ethernet 0/0
SW4(config-if)# spanning-tree cost 1
SW4(config-if)# exit

SW4# show spanning-tree vlan 1 root

Cost: 12 (still high!)

SW4# show spanning-tree vlan 1 interface ethernet 0/0

Cost: 1 (our override is there)

```

The override is on the interface, so why is the root path cost still 12? Because a port cost only counts if that port is the root port. Check the role:

```
SW4# show spanning-tree vlan 1 interface ethernet 0/0

Vlan                   Interface        Role Sts Cost      Prio.Nbr Type
────────────────────────────────────────────────────────────────────
VLAN0001               Eth0/0           Desg FWD 1        128.1    P2p

```

Eth0/0 is **designated**, not root. Root port is elsewhere:

```
SW4# show spanning-tree vlan 1 brief

Interface        Role Sts Cost      Prio.Nbr
Eth0/0           Desg FWD 1        128.1
Eth0/1           Root FWD 12       128.2  ← This is the root port!

```

So Eth0/1 (cost 12) is root port, not Eth0/0\. The manually set cost on Eth0/0 doesn't matter; Eth0/1 is still preferred by STP's calculations. Check why:

```
SW4# show spanning-tree vlan 1 interface ethernet 0/1 detail

Root path cost = 4 (from upstream)
Port cost = 4 (default 1 Gbps)
Total = 8 + upstream cost = 12

But we set Eth0/0 cost to 1...
Check BPDU from that direction.

```

The issue: Eth0/0's upstream path has higher cost (via multiple hops), so even with cost 1 locally, the total isn't as good as Eth0/1's cost 12 from a shorter path.

## What's Next

Read **Article 7: 802.1D vs PVST+ vs Rapid PVST+ vs MST - Comparing STP Variants** to understand modern STP implementations and when to use each variant.

## Related STP Articles

- [STP Port Roles Explained: Root, Designated, Blocked, and Alternate](https://www.pinglabz.com/stp-port-roles-explained/)
- [How STP Works: Root Bridge Election, BPDUs, and the Spanning Tree Algorithm](https://www.pinglabz.com/how-stp-works-root-bridge-bpdus/)
- [Understanding STP Timers: Hello, Forward Delay, and Max Age](https://www.pinglabz.com/stp-timers-hello-forward-delay-max-age/)
- [STP and EtherChannel: Spanning Tree Behavior with Port Channels](https://www.pinglabz.com/etherchannel-spanning-tree/)

Build this yourself, on real gear

The PingLabz lab library: 74 hands-on labs on real Cisco IOS XE in Cisco Modeling Labs. Seven are free, no card required.

[Browse the labs](https://www.pinglabz.com/labs/)