Spanning-Tree Cost Calculation

Non-root bridges need to find the shortest path to the root bridge. What will happen if we have a mix of different interface types like Ethernet, FastEthernet and Gigabit? Let’s find out!

Here’s the topology I will use to explain the spanning-tree cost calculation:

spanning tree cost calculation example

In the picture above we have a larger network with multiple switches. You can also see that there are different interface types, we have Ethernet (10 Mbit), FastEthernet (100Mbit) and Gigabit (1000Mbit). SW1 on top is the root bridge so all other switches are non-root and need to find the shortest path to the root bridge.

Bandwidth Cost
10 Mbit 100
100 Mbit 19
1000 Mbit 4

Spanning-tree uses cost to determine the shortest path to the root bridge. The slower the interface, the higher the cost is. The path with the lowest cost will be used to reach the root bridge.

Here’s where you can find the cost value:

BPDU Header

In the BPDU you can see a field called root path cost. This is where each switch will insert the cost of its shortest path to the root bridge. Once the switches found out which switch is declared as root bridge they will look for the shortest path to get there. BPDUs will flow from the root bridge downwards to all switches.

If you studied CCNA or CCNP ROUTE then this story about spanning-tree cost might sound familiar. OSPF (Open Shortest Path First) also uses cost to calculate the shortest path to its destination. Both spanning-tree and OSPF use cost to find the shortest path but there is one big difference. OSPF builds a topology database (LSDB) so all routers know exactly what the network looks like. Spanning-tree is “dumb”…switches have no idea what the topology looks like. BPDUs flow from the root bridge downwards to all switches, switches will make a decision based on the BPDUs that they receive!

Here’s an example of the different spanning-tree costs for our topology:

spanning tree cost root port

SW2 will use the direct link to SW1 as its root port since this is a 100 Mbit interface and has a cost of 19. It will forward BPDUs towards SW4; in the root path cost field of the BPDU you will find a cost of 19. SW3 is also receiving BPDUs from SW1 so it’s possible that at this moment it selects its 10 Mbit interface as the root port. Let’s continue…

spanning tree cost root port 2

This picture needs some more explanation so let me break it down:

  • SW3 will receive BPDUs on its 10 Mbit interface (cost 100) and on its 1000 Mbit interface (cost 4). It will use its 1000 Mbit interface as its root port.
  • SW3 will forward BPDUs to SW4. The root path cost field will be 100.
  • SW4 receives a BPDU from SW2 with a root path cost of 19.
  • SW4 receives a BPDU from SW3 with a root path cost of 100.
  • The path through SW2 is shorter so this will become the root port for SW4.
  • SW4 will forward BPDUs towards SW3 and SW5. In the root path cost field of the BPDU we will find a cost of 38 (its root path cost of 19 + its own interface cost of 19).
  • SW3 will forward BPDUs towards SW5 and inserts a cost of 42 in the root path cost field (19 + 19 + 4).

The complete picture will look like this:

We're Sorry, Full Content Access is for Members Only...

If you like to keep on reading, Become a Member Now! Here is why:

  • Learn any CCNA, CCNP and CCIE R&S Topic. Explained As Simple As Possible.
  • Try for Just $1. The Best Dollar You've Ever Spent on Your Cisco Career!
  • Full Access to our 654 Lessons. More Lessons Added Every Week!
  • Content created by Rene Molenaar (CCIE #41726)

540 Sign Ups in the last 30 days

satisfaction-guaranteed
100% Satisfaction Guaranteed!
You may cancel your monthly membership at any time.
No Questions Asked!

Forum Replies

  1. Hi Rene,

    I am not clear about the root bridge. I mean why are we finding the root port(for non-root bridge) to reach the root bridge. Is it like in practical scenario, the root bridge is set as destination to one of the server?

  2. Hi Rene,

    I have a question to the description on the third topology. You say:

    “SW3 will receive BPDUs on its 10 Mbit interface (cost 100) and on its 1000 Mbit interface (cost 4). It will use its 1000 Mbit interface as its root port.”

    Should SW3 receive on 10Mbit interface BPDUs of 0 instead of 100 because they are generated by the root? And then SW3 add its port cost of 100 and send it to SW4 and SW5?

    Is it correct that the BPDU sending SW don’t add the costs of the outgoing interface/link, only the links that left behind? So the receiving SW has to add the co

    ... Continue reading in our forum

  3. Hello Laz,
    I have one question and I am going to use the below topology.

    SWITCH_1=================SWITHC_2

    FA0/11-------------------------------------FA0/1
    FA0/22------------------------------------FA0/2

    In this scenario, I have switch 1 connected to switch 2 through two Fast Ethernet links as it is drawn above. Switch 1 is the root bridge. Switch 2 has to pick one link between fa0/1 and fa0/2 links as the root port and block another one. Therefore, Switch 1 will look at the cost of fa0/1 and fa0/2 links and they both are the same which is 19. Now Switch 1 wi

    ... Continue reading in our forum

  4. Hi Laz,
    great, thank you very much
    Regards

44 more replies! Ask a question or join the discussion by visiting our Community Forum