The Wayback Machine - https://web.archive.org/web/20241125114346/https://www.geeksforgeeks.org/spanning-tree-path-cost-value/
Open In App

Spanning Tree Path Cost Value

Last Updated : 18 Jan, 2022
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

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

1 10 Mbps 100
2 100 Mbps 19
3 10 Mbps 100
4 10 Mbps 100

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.



Previous Article
Next Article

Similar Reads

Difference between Spanning Tree Protocol (STP) and Rapid Spanning Tree Protocol (RSTP)
Spanning Tree Protocol (STP) and Rapid Spanning Tree Protocol (RSTP), are designed to avoid network loops in Ethernet. It provide loop-free logical topology. They were both designed to provide network reliability and particularly avoid broadcast radiation, but the major differences are on the rate, functionality and versatility. In this article we
5 min read
Root Bridge Election in Spanning Tree Protocol
Redundant links are used to provide a backup path when one link goes down but a Redundant link can sometimes cause switching loops. The main purpose of Spanning Tree Protocol (STP) is to ensure that you do not create loops when you have redundant paths in your network. Spanning Tree Protocol (STP) - As IEEE STP is used to make a loop-free network b
4 min read
Types of Spanning Tree Protocol (STP)
Prerequisite - Spanning Tree Protocol Spanning Tree Protocol (STP) is used to make a loop free network by monitoring the network to track all the links and shut down the least redundant ones. Root bridge is a switch in a single VLAN or whole topology (according to the type of STP standard used) which is responsible for distributing BPDUs and block
3 min read
What is MSTP(Multiple Spanning Tree Protocol)?
The Multiple Spanning Tree Protocol (MSTP) and algorithm, gives both straightforward and full network doled out to any given Virtual LAN (VLAN) all through a Bridged Local Area Network. MSTP employments BPDUs to trade data between spanning-tree consistent gadgets, to avoid circles in each MSTI (Multiple Spanning Tree Instances) and within the CIST
2 min read
Working of Spanning Tree Protocol (STP)
Spanning Tree Protocol (STP) prevents the looping of the frame by putting the interfaces of the switch in either forwarding or blocking state. How Switch is able to decide which interface should be in forwarding or blocking state. We’ll learn the answer to this question in this article. Before we further proceed, we must know some terms. BID – It s
3 min read
Introduction of Spanning Tree Protocol (STP)
In a LAN, redundant links are added to improve the network availability of LAN. But these redundant links may cause the frame to loop in the network for an infinite time until some action is taken, e.g, some links are taken down. To cope with the problem of frame looping, Spanning Tree Protocol (STP) comes into play. Need for Spanning Tree: Conside
3 min read
Spanning Tree Topology (STP) Convergence
Once the Spanning Tree Topology (STP) is established, STP continues to work until some changes occurs. Manual changes that Network Engineer can apply are configuration of Bridge ID and port costs. Also there are other changes like the addition of switch or failure of port of an existing switch. The reaction of STP when some changes occurs by reconf
2 min read
How Spanning Tree Protocol (STP) Select Designated Port?
Spanning tree protocol is a type of communication protocol that functions to build a loop-free topology, which means the arrangement of elements in a computer network. STP commonly works for layer-2 bridges and switches. It also provides a backup link for the network system if the active link fails. Layer-2 devices send the data in the form of fram
3 min read
Spanning Tree Port States
Spanning tree protocol prevent looping of frames around LAN by placing ports of switch in different states based on the criteria such as selection of root switch, switch's root cost, etc. There are five Spanning Tree Port States : 1. Blocking State : Switch port enters the blocking state at time of election process, when a switch receives a BPDU on
3 min read
Rapid Spanning Tree Protocol
RSTP is the more improved and advanced version of STP which is a layer 2 protocol that prevents bridge loops and broadcast storms in local networks with redundant connections. Rapid spanning tree protocol has faster convergence and it is also backward-compatible with STP. To make sure a loop-free topology, the Rapid Spanning Tree Protocol (RSTP) pr
5 min read
Topology Changes in Spanning Tree Protocol (STP)
Spanning Tree Protocol (STP) is used to prevent loops in the network due to redundant connections between switches in the network. It determines an efficient path from non-root switches to root switches with the help of Bridge Protocol Data Unit (BPDUs). BPDU carries information regarding topology changes within the network to notify all the switch
4 min read
Configuring Spanning Tree Protocol Portfast
Spanning Tree Protocol is a data link layer or layer-2 protocol whose prime objective is to prevent loops in the different network configurations or network topologies. It tracks all the links and closes the redundant ones. It uses the spanning tree algorithm(STA) to create a topology database and then search out the redundant links to disable them
5 min read
Amazon Web Services - Introduction to AWS Cost Explorer & Cost Management
AWS Cost Explorer will help you to visualize, understand, and manage your AWS costs and usage over time. Use Cost explorer to find your higher spending first and start from there. There has been a lot of product updates that will help with costs. AWS released cost categories where you can group your cost together and deal with some of the misspelle
4 min read
Difference between Binary Tree and Binary Search Tree
Binary Tree Data Structure:A tree whose elements have at most 2 children is called a binary tree. Since each element in a binary tree can have only 2 children, we typically name them the left and right children. Binary Search Tree Data Structure (BST):A binary search tree is a hierarchical data structure where each node has at most two children, wi
2 min read
EIGRP Cost Calculation
Prerequisite - EIGRP As Enhanced Interior Gateway Routing Protocol (EIGRP) is a hybrid vector routing protocol as it contains features of both distance vector routing protocol and link-state routing protocol. It is a network layer protocol which uses protocol number 88. Cost Calculation - Composite matrix is used to calculate the cost and also used
3 min read
On-Premises Cost Estimates of Virtualization
Prerequisite - Virtualization and types of virtualization, Characteristics of Virtualization On-Premises cost is calculated on the basis of various factors such as hardware type, operating system used, storage, database, virtualization tools, and various others. The default cost rate can be estimated with the help of Cost Estimator. In the cloud co
5 min read
Measures of Query Cost in DBMS
Query Cost is a cost in which the enhancer considers what amount of time your query will require (comparative with absolute clump time). Then the analyzer attempts to pick the most ideal query plan by taking a glance at your inquiry and insights of your information, attempting a few execution designs, and choosing the most inexpensive of them. The
4 min read
Probabilistic shortest path routing algorithm for optical networks
Data transfer operations is a crucial aspect in case of networking and routing. So efficient data transfer operations is a must need, with minimum hardware cost (Optical Cables, WDM Network components, Decoders, Multiplexers) and also in the minimum time possible. Thus, the need is to propose an algorithm that finds the shortest path between two no
5 min read
Open Shortest Path First (OSPF) Protocol fundamentals
Open shortest path first (OSPF) is a link-state routing protocol that is used to find the best path between the source and the destination router using its own shortest path first (SPF) algorithm. A link-state routing protocol is a protocol that uses the concept of triggered updates, i.e., if there is a change observed in the learned routing table
5 min read
Open shortest path first (OSPF) router roles and configuration
Prerequisite - Open shortest path first (OSPF) Open shortest path first (OSPF) is a link-state routing protocol which is used to find the best path between the source and the destination router using its own SPF algorithm. Open shortest path first (OSPF) router roles - An area is a group of contiguous networks and routers. Routers belonging to same
3 min read
Open shortest path first (OSPF) - Set 2
OSPF is abbreviated as Open Shortest Path First. OSPF is an intradomain routing protocol and it is the implementation of link state routing protocol. It falls into the group of interior gateway protocols (IGPs), operating within a single autonomous system (AS). OSPF was designed as an interior gateway protocol. It is used in an autonomous system su
4 min read
Proof that Path Selection Decision problem is NP-Complete
Prerequisite – NP-Completeness The decision problem of path selection problem asks if it is possible to select at least k paths from the given paths of a graph such that no two selected paths share any vertex. To prove that a problem is NP-Complete, we need to show that it is both NP and NP-Hard. We use PSP to denote our path selection decision pro
5 min read
Path Traversal Attack and Prevention
A path traversal attack allows attackers to access directories that they should not be accessing, like config files or any other files/directories that may contains server's data not intended for public. Using a path traversal attack (also known as directory traversal), an attacker can access data stored outside the web root folder (typically /var/
2 min read
Shortest Path Algorithm in Computer Network
In between sending and receiving data packets from the sender to the receiver, it will go through many routers and subnets. So as a part of increasing the efficiency in routing the data packets and decreasing the traffic, we must find the shortest path. In this article, we are discussing the shortest path algorithms. What is Shortest Path Routing?
6 min read
How does the Packet Find the Shortest Path in a Computer Network?
Answer: Packets find the shortest path in a computer network using routing algorithms like OSPF or BGP, which calculate the most efficient route based on various metrics.Routing AlgorithmsVarious routing algorithms determine the shortest path for packets to travel from the source to the destination. Examples include Dijkstra's algorithm, Bellman-Fo
1 min read
LiFi: The path to a new way of communication
We all must have heard and used wifi for communication, but what if I say that there is a technology that is 100 times faster than current average wifi speeds! Yes, this technology exists, and this is known as Light Fidelity (LiFi). So this article we will understand the LiFi concept in detail and its advantages over wifi and its real-world use in
5 min read
Open Shortest Path First (OSPF) protocol States
Prerequisite - OSPF fundamentals Open Shortest Path First (OSPF) is a link-state routing protocol that is used to find the best path between the source and the destination router using its own Shortest Path First). OSPF is developed by Internet Engineering Task Force (IETF) as one of the Interior Gateway Protocol (IGP), i.e, the protocol which aims
4 min read
Boundary Value Analysis - Triangle Problem
The triangle problem is a classic example of using boundary value analysis to test a software program. The problem involves determining if three values, representing the lengths of the sides of a triangle, form a valid triangle. To perform boundary value analysis, we start by selecting test cases that include values at the boundaries of the input d
4 min read
How to calculate P Value?
P-value, also referred to as probability value is a statistical measure used to determine whether to accept or reject the Null Hypothesis, considering the Null Hypothesis to be True. For calculating the p-value, we perform an experiment and based on the observations of the test-statistic we make decisions, i.e., if the measure is statistically belo
4 min read
Lowest Common Ancestor in a Binary Tree | Set 3 (Using RMQ)
Given a rooted tree, and two nodes are in the tree, find the Lowest common ancestor of both the nodes. The LCA for two nodes u and v is defined as the farthest node from the root that is the ancestor to both u and v. Prerequisites: LCA | SET 1 Example for the above figure : Input : 4 5 Output : 2 Input : 4 7 Output : 1 Converting LCA to RMQ(Range M
15+ min read
three90RightbarBannerImg