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:
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.
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:
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 find 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.
Here’s an example of the different spanning tree costs for our topology:
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…
This picture needs some more explanation, so let me break it down:
- SW3 receives 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 (the shortest path to the root bridge is 19+19+4=42).
- 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 insert a cost of 42 in the root path cost field (19 + 19 + 4).
The complete picture will look like this: