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.
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:
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:
Andy if I understand your question correctly then I think no. The lowest switch port number is a local decision therefore it is not considering the port numbers of the upstream switch.
I also can be wrong… Maybe someone will correct me.
Marek
In the calculation , the switch , receive a bdpu with root path cost value ( the link cost is given by costs Of the 2 port ,upstream and downstream)
The switch add at this path cost value , cost Of the port whrere receive the bpdu… When sendig this bpdu out another port, the switch shoulds also add the cost Of the port which use to forward??
Hi Francesco,
The switch will add the cost of its root port when it forwards the BPDU. It never adds the cost of the interface that is used to send the BPDU.
The total cost to get to the root will be the sum of all root ports.
Rene
thanks so much—