Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Spanning Tree Path Cost Value

  • Last Updated : 18 Jan, 2022

Prerequisite: 

Spanning Tree Protocol (STP) is used to prevent loops in the network due to redundant connections between switches in the network. It determines a unique and shortest path from non-root switches to root switches with the help of Bridge Protocol Data Unit (BPDUs). BPDU contains information about switch ports which is used by switches to participate in Spanning Tree Protocol. It contains spanning-tree path cost value or root path cost value which is used to determine the root port of the switch.

BPDU

BPDU

Spanning tree path cost value can be defined as the sum of the port costs of all the ports included in the path from non-root switch to root switch. It is inversely proportional to the bandwidth of the path and hence path with the lowest path cost value is considered more efficient than one with a high path value.

Working:

In a network, every switch other than the root switch has to determine the root port from its available ports which will be used to reach the root switch. So, whenever a switch receives a BPDU at any of its ports it will increase the path cost value of BPDU by adding the port cost of the receiving port. Finally, the port with the lowest path cost value is selected as a root port for the switch. 

STP places root port in forwarding state and all other available ports of the non-root switch will be in blocked state i.e. it will not forward any frame or process any received frame except for important STP messages. Hence, by this process looping of frames can be avoided by placing ports or interfaces of non-root switches in different states.

Example:

Suppose there is a network with four switches connected in a cyclic fashion where each switch have port interfaces of different bandwidths and hence have different port cost. The following table provides information about the bandwidth and the cost of each link. 

Link

Bandwidth

Cost

110 Mbps100
2100 Mbps19
310 Mbps100
410 Mbps100

Now, we need to find a Spanning Tree Path Cost Value for switch 4 where switch 1 is considered as the root switch.

Root Bridge

Root Bridge

Switch 4 has two available paths to reach switch 1 (root switch) but it needs to determine the most efficient path between switch 1 and itself. So, to determine the most efficient path it will calculate the spanning-tree path cost value for switch 4. Let us calculate the spanning-tree path cost value for both paths:

  • Left path: In this path, switch 4 will connect to switch 2 which will further be connected to switch 1. Hence, link 1 and link 3 will be involved in this case. So, the spanning-tree path cost value for the left path will be 100+100=200 (link 1 cost + link 3 costs).
  • Right path: In this path, switch 4 will be connected to switch 3 which will further be connected to switch 1. Hence, link 2 and link 4 will be involved in this case. So, the spanning-tree path cost value for the right path will be 19+100=119 (link 2 cost + link 4 costs).

The spanning-tree path cost value via the left path is 200 whereas the spanning-tree path cost value via the right path is 119. 

So, the path cost value for the right path is lower than the left hence switch 4 will be connected via the right path and the port connecting to the right path (link 4) will be selected as the root port for the switch.

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!