How path cost is being calculated in STP is still not clear to me. Let's say we got this architecture, where all switches were just turned on for the first time:

enter image description here

During BPDUs exchange, every switch port will conform or discard the BPDU's according to the lowest priority logic. In first burst of BPDU's everyone advertises 0 path cost and every switch accommodates the configuration BPDU on the receiving port by comparing received config + existing config. In the next burst of BPDU's everyone will advertise the chosen bridge ID but still with path cost of 0. When it comes to choosing the port state (root port, designated, non designated), the switch must identify the least path cost on it's interfaces.

As an example For SW2:

  • On F0/1: cost is 19 (fast ethernet port)
  • On F0/2: cost is 19 (fast ethernet port)
  • On F0/3: cost is 19 (0 path cost from bpdu's of SW3 + interface cost of F0/3)

For SW4:

  • On G0/1: cost is 4 (gigabit port)
  • On G0/2: cost is 4 (0 path cost from bpdu's of SW3 + interface cost of G0/2)

However, I know this is wrong but I didn't managed to understand it properly so far. Functionally, for the above example, I would say the cost of SW4 G0/2 interface would be 4 (0+4) and for G0/1 would be the SUM of the interfaces of SW4, SW2 (one of them) + SW3...but this is not clear because SW2 advertises to SW4 (theoretically) two bpdus: first bpdu when it says he's the root bridge and secondly when it has the bridge id of SW3 but still with the path cost of it's own interface...

How does this path calculation works technically when bpdu's are being exchanged ? For example, if you would say that the path cost of G0/1 for SW4 is a different value; how did you came up to that number, what has happened during the BPDU's exchange to result in the specified number ?


1 Answer 1


You are using obsolete interface metrics from classic STP (IEEE 802.1D-1998). Current versions are RSTP and MSTP which use the standard metric 20 Tbit/s divided by link rate - which simplifies calculations with higher link rates.

A bridge uses that interface's metric and adds to it the root path cost from the connected bridge as reported in the received BPDUs.

Example: A gigabit link directly to the root bridge has a root path cost of 20,000. One hop (switch) further across another gigabit link, the total cost is 40,000. With Fast Ethernet instead of gigabit, the root path cost would be 220,000.

In your diagram, using the obsolete metrics, selected root path bold:

  • SW3 is the root bridge
  • SW2 has three potential root paths: direct with cost 19, across SW1 with cost 19+19=38, and across SW4 with cost 4+4=8.
  • SW4 has two root paths: direct with cost 4 and across SW2 with cost 4+19=23.

Note the disadvantages of the old metrics at higher speeds: if you picture all link speeds x10, SW2 has a direct root path with cost 4 (1G), and across SW4 with cost 2+2=4 (10G+10G). The latter is practically faster, but we don't know the interfaces indices or priorities, and the slower, direct path could actually be selected as root path.

Also note that you'd normally want to build a fat tree: faster links with/towards the root bridge, slower links elsewhere. With that in mind, you'd swap SW2's ports linking to SW3 and SW4.

  • Thank you Zac. Indeed, I'm trying first to understand how things started and then jump to RSTP and MSTP. To get back, You say that SW2 has 3 paths: Direct, SW1 and SW4. For the SW1 path cost of 38, how did SW2 knows that it cost 38 to get through SW1 ? It is it's own port cost + the cost from the BPDU that he had received previously ? In this case, did SW1 said "Hey, this is the root bridge ID, this is my bridge ID, and this is the cost to MYSELF (19)" ? If in the initial BPDU SW1 advertised cost of 0, in the next BPDU (after confirmation of SW3 is the root bridge), he sends it's own cost ?
    – Floji
    Commented Jun 13, 2023 at 5:22
  • Yes, pretty much so. I'd suggest starting with RSTP though, as it's no more complicated than classic STP and much more relevant today (and more logical).
    – Zac67
    Commented Jun 13, 2023 at 6:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.