What Does Path cost Mean?
This page mentions older exam versions. See the Current Exam Context and Legacy Exam Context sections below for the updated mapping.
On This Page
Quick Definition
Path cost is a number that helps network switches decide the best way to send data. Each link in a network gets a cost based on its speed. The switch picks the path with the lowest total cost. This prevents data loops and keeps the network running smoothly.
Commonly Confused With
Bridge priority is a value used to elect the root bridge in STP. It is a configuration setting on each switch, while path cost is a metric on each link. Bridge priority determines which switch is the root; path cost determines which port is used to reach the root.
You set bridge priority to 4096 on Switch A to make it root, but the path cost on a link determines whether Switch B uses its fast or slow port to connect to Switch A.
Port priority is a tie-breaker used when two ports on the same switch have equal path cost to the root bridge. Path cost is the primary metric; port priority only comes into play after path cost is compared.
Switch B has two 1 Gbps links to Switch A, both with cost 4. STP uses port priority (default 128) to decide which port becomes root port. Lower port priority wins.
Administrative distance is a routing protocol metric used by routers to choose between different routing protocols (e.g., OSPF vs EIGRP). Path cost is used by switches within the same STP domain. They operate at different layers of the OSI model.
A router may prefer OSPF (AD 110) over RIP (AD 120), but a switch uses path cost to prefer a 10 Gbps link over a 1 Gbps link within STP.
OSPF cost is a routing metric calculated from link bandwidth using a reference bandwidth (usually 100 Mbps). STP path cost uses a different formula and is used for layer 2 loop prevention, not for layer 3 routing.
An OSPF router might calculate a cost of 1 for a 100 Mbps link, while STP gives the same link a cost of 19.
Must Know for Exams
Path cost is a core topic in networking certification exams such as CompTIA Network+, Cisco CCNA, and Juniper JNCIA. In the CompTIA Network+ exam (N10-008 and N10-009), path cost appears under the objective "Explain the basics of switching and the Spanning Tree Protocol." You may be asked to identify the purpose of path cost or to interpret a simple STP topology with given costs. The exam does not require memorizing exact cost values, but you should understand that lower cost means a better path.
In the Cisco CCNA exam (200-301), path cost is more heavily tested. You must know the default cost values for common link speeds (e.g., 10 Gbps = 2 under classic STP, or 2000 under the revised standard). You will encounter questions that ask you to determine which port becomes the root port based on the cumulative path cost. You may also see configuration scenarios where you need to manually set the cost of an interface to influence STP root port selection. Troubleshooting questions often involve identifying why a particular port is blocking, which requires analyzing the path cost.
For the Juniper JNCIA-Junos exam, the concepts are similar but use Juniper terminology. Path cost is referred to as "interface cost" and can be set using the "cost" statement under the spanning-tree configuration hierarchy. The exam expects you to understand how STP uses path cost to build a loop-free topology. In all these exams, multiple-choice questions may present a network diagram with link speeds, and you must calculate or select the root bridge and root ports. Being comfortable with path cost arithmetic and the impact of manual cost changes is essential for scoring well.
Simple Meaning
Imagine you are driving to a friend's house and you have several routes to choose from. Some routes are short but have heavy traffic, while others are longer but smooth and fast. You would probably pick the route that gets you there in the least amount of time, considering both distance and traffic. In a computer network, path cost works similarly. Each connection between switches has a cost that is usually based on how fast it is. A 10 Gigabit connection is like a wide open highway and gets a low cost, while a 100 Megabit connection is like a narrow, crowded street and gets a higher cost.
The Spanning Tree Protocol (STP) uses these path costs to build a loop-free tree structure. It blocks some redundant links so that data only travels along one active path at a time. When you add up the costs of each link along a route, the switch can compare different paths to the same destination. The path with the lowest total cost becomes the preferred route. If that link fails, the switch can automatically switch to the next lowest-cost path.
This system prevents the nightmare of data looping endlessly, which would crash the network. Path cost makes the network both efficient and resilient. Without it, switches would send copies of the same data packet around in circles, wasting bandwidth and confusing devices. So path cost is the secret behind a well-behaved, self-healing network.
Full Technical Definition
In the context of Spanning Tree Protocol (STP), path cost is a metric used to select the best path to the root bridge in a bridged or switched network. The original IEEE 802.1D standard defined path cost as a 16-bit value that was inversely proportional to the link bandwidth. A 10 Mbps link had a default cost of 100, 100 Mbps had a cost of 19, 1 Gbps had a cost of 4, and 10 Gbps had a cost of 2. These values were derived from the formula 1000 / bandwidth in Mbps, which allowed STP to compare the cumulative cost of different paths.
With the evolution to faster Ethernet standards, the original cost values became too granular. IEEE 802.1t introduced a revised cost calculation using a 32-bit value and a different formula: 20,000,000 / bandwidth in Mbps. Under this new system, a 10 Mbps link has a cost of 2,000,000, 100 Mbps has a cost of 200,000, 1 Gbps has a cost of 20,000, 10 Gbps has a cost of 2,000, and 100 Gbps has a cost of 200. This change allowed for more accurate differentiation between high-speed links and future-proofed the protocol for even faster speeds.
Path cost is a key component in three critical STP decisions: root port selection, designated port selection, and alternate port blocking. When a switch receives Bridge Protocol Data Units (BPDUs) from multiple switches, it sums the path cost from its own ports to the root bridge. The port offering the lowest cumulative path cost becomes the root port. On a given network segment, the switch with the lowest path cost to the root bridge becomes the designated port, and other ports on that segment go into blocking state. The sum of all path costs along a path is called the root path cost, and it is advertised in BPDUs.
In real IT implementations, network administrators may manually adjust path costs to influence STP topology. This is done using the "spanning-tree cost" command on Cisco switches or equivalent commands on other vendor equipment. This allows an administrator to force traffic through a specific link, even if its bandwidth is lower, for load balancing or policy reasons. Understanding path cost is essential for designing redundant, loop-free networks and for troubleshooting STP convergence issues, such as suboptimal traffic flows or unexpected blocking states.
Real-Life Example
Think about a delivery company that has several warehouses in a city. Each warehouse has multiple routes to send packages to the main distribution center. Some routes are short but involve many traffic lights and narrow streets, while others are longer but use a highway. The company wants to send all packages through the fastest route to save time and fuel. They assign a cost to each road segment: a traffic-light-filled street might be cost 10 per mile, while a highway might be cost 2 per mile. The dispatcher adds up the costs of all segments along each possible route and chooses the one with the lowest total cost.
Now imagine that the company decides to build a new, super-fast tunnel that connects directly to the distribution center. This tunnel gets a very low cost of 1 per mile. Suddenly, many packages that used to go on the highway switch to the tunnel. The old highway route is still there, but it is not used as much unless the tunnel gets blocked or repaired. This is exactly how path cost works in a network. The switches constantly listen for changes and recalculate the best path.
If a delivery truck gets into an accident and blocks a street, the dispatcher immediately reroutes packages through the next cheapest path. The network does the same thing when a switch or cable fails. The Spanning Tree Protocol recalculates path costs and unblocks alternate paths to keep data flowing. This analogy shows why path cost is not just a number; it is the brain behind the network's ability to heal itself and always choose the most efficient route.
Why This Term Matters
Path cost matters because it directly affects network performance and reliability. In any switched network with redundant links, path cost is what prevents loops and ensures that data takes the most efficient route. Without a proper understanding of path cost, network engineers could end up with traffic flowing over slow backup links while faster primary links remain idle, or worse, they could create broadcast storms that bring down the entire network.
For professionals managing enterprise networks, knowing how to adjust path cost is a critical skill. For example, if you have a 1 Gbps link and a 10 Gbps link between two switches, STP will automatically prefer the 10 Gbps link because its path cost is much lower. But what if you want the 1 Gbps link to carry traffic for a specific VLAN for load balancing? You can manually increase the cost of the 10 Gbps port to make the 1 Gbps path appear cheaper. This kind of fine-tuning is common in data centers where every bit of bandwidth matters.
Path cost also plays a role in network convergence time. When a link fails, STP recalculates path costs to find an alternate path. The time this takes depends on the network size and the STP version. Rapid Spanning Tree Protocol (RSTP) and Multiple Spanning Tree Protocol (MSTP) converge faster than classic STP, but all rely on the same fundamental path cost logic. A solid grasp of path cost helps you predict how your network will behave under stress, which is essential for maintaining uptime in production environments.
How It Appears in Exam Questions
Exam questions about path cost appear in three main patterns: diagram-based, configuration-based, and troubleshooting-based. In diagram-based questions, you are shown a network of switches with link speeds labeled. You must determine which switch is the root bridge (based on lowest bridge priority or MAC address), then find the root port on each non-root switch by calculating the cumulative path cost to the root. For example, a question might show Switch A as root, with a 10 Gbps link to Switch B and a 1 Gbps link to Switch C. You need to know that Switch B's root port is the one connecting to A (cost 2 under classic STP), and Switch C will use the 1 Gbps link (cost 4) to reach the root.
Configuration-based questions ask you to identify or correct a command. For instance, a candidate might be shown the output of "show spanning-tree" and need to identify which interface has a manually configured cost. The question might ask: "Which command would change the path cost of GigabitEthernet0/1 to 100?" The correct answer is "spanning-tree cost 100" in interface configuration mode. These questions test your knowledge of syntax and the effect of manual cost on STP topology.
Troubleshooting questions are the most challenging. A typical scenario describes a network where users are experiencing slow performance, and the show spanning-tree output indicates an alternate path is blocking. You must analyze the path costs to determine if the blocking is correct. For example, if two switches are connected by a 10 Gbps link and a 1 Gbps link, but the 1 Gbps link is the designated port, you know something is wrong because the 10 Gbps link should have a lower cost. You would then check if the 10 Gbps port has a higher manual cost configured, or if the link is actually down. Understanding path cost helps you pinpoint misconfigurations.
Practise Path cost Questions
Test your understanding with exam-style practice questions.
Example Scenario
You are setting up a small office network with three switches: Switch A, Switch B, and Switch C. Switch A has the lowest bridge priority, so it becomes the root bridge. Switch B is connected to Switch A with a 1 Gbps cable, and also to Switch C with a 1 Gbps cable. Switch C is connected to Switch A with a slower 100 Mbps cable. The network has a loop because there are two paths from Switch B to Switch A (directly, and via Switch C). You need STP to block one path so that data does not loop forever.
First, STP calculates the path cost for each link. Using the classic cost values, a 1 Gbps link has a cost of 4, and a 100 Mbps link has a cost of 19. Switch B looks at its two paths to the root bridge. The direct link to Switch A has a cost of 4. The path through Switch C is: Switch B to Switch C (cost 4) plus Switch C to Switch A (cost 19) = total cost 23. Since 4 is much lower than 23, Switch B chooses the direct link as its root port and puts the other port toward Switch C into blocking state.
Now Switch C calculates its path to the root. It has a direct 100 Mbps link to Switch A (cost 19) and a path through Switch B (cost 19 from C to B, plus 4 from B to A = total cost 23). Switch C chooses the direct link as its root port because 19 is less than 23. The port on Switch B facing Switch C remains blocked. The network is now loop-free, and all traffic uses the fastest available routes. This scenario shows exactly how path cost drives STP decisions in a real network.
Common Mistakes
Confusing path cost with bandwidth or speed, thinking higher bandwidth always means higher cost.
Path cost is inversely related to bandwidth: a faster link has a lower cost, not a higher one. A 10 Gbps link has a cost of 2, while a 100 Mbps link has a cost of 19.
Remember the rule: lower cost = better path. Faster speed = lower cost.
Thinking the root bridge always has a path cost of zero everywhere.
The root bridge has a root path cost of zero on its own ports, but it still has a path cost for its own interfaces. The root path cost is zero only for the root bridge itself, not for other switches.
Only the root bridge has a root path cost of zero. Non-root switches have positive root path costs on their ports.
Forgetting to sum the path costs along the entire path to the root bridge, causing a wrong root port selection.
Path cost is cumulative. A switch must add the cost of each intermediate link to the root bridge, not just the cost of the immediate link.
Draw the path step by step: add the cost of the first link, then the second, etc., until you reach the root bridge.
Assuming path cost is the only factor in STP root port selection, ignoring bridge ID and port priority.
Path cost is the first tie-breaker, but if two paths have the same cumulative cost, the switch then compares the neighbor bridge ID, then the neighbor port priority, then the neighbor port number.
Always consider the full STP selection order: lowest path cost, then lowest neighbor bridge ID, then lowest neighbor port priority.
Exam Trap — Don't Get Fooled
{"trap":"Question gives a network with two switches connected by a 10 Gbps link and a 1 Gbps link. The candidate sees that the 1 Gbps link is blocking and assumes the 10 Gbps link is the root port. But the question asks which port is root.
The trap is that the 10 Gbps link might have a manually configured high path cost, causing the 1 Gbps link to be the root port instead.","why_learners_choose_it":"Learners assume default costs apply, so they think the 10 Gbps link (default cost 2) will always be the root port over the 1 Gbps link (default cost 4). They forget that manual configuration can override defaults."
,"how_to_avoid_it":"Always check if any manual cost commands have been applied. Look for \"spanning-tree cost\" or \"cost\" in the interface configuration. If the 10 Gbps port has a cost of 100, then the 1 Gbps link with cost 4 becomes the better path."
Step-by-Step Breakdown
Root Bridge Election
All switches exchange BPDUs. The switch with the lowest bridge priority (or lowest MAC address as tie-breaker) becomes the root bridge. Only the root bridge sends BPDUs with a root path cost of zero.
Determine Root Path Cost on Non-Root Switches
Each non-root switch receives BPDUs from the root. It records the root path cost advertised in the BPDU and adds the cost of the receiving port to calculate its own root path cost.
Select Root Port
On each non-root switch, the port with the lowest cumulative root path cost becomes the root port. This port is the best path to reach the root bridge. If there is a tie, the lowest neighbor bridge ID, then the lowest neighbor port priority, then the lowest neighbor port number are used.
Select Designated Ports
On each network link (segment), the switch with the lowest root path cost to the root bridge becomes the designated port for that segment. If two switches have the same root path cost, the one with the lowest bridge ID wins. The designated port is the only port on that segment allowed to send traffic.
Block Alternate Ports
All remaining non-root and non-designated ports are placed into the blocking state. These ports do not forward traffic but still listen for BPDUs. If the active path fails, STP recalculates path costs and unblocks an alternate path to restore connectivity.
Convergence and Continuous Monitoring
STP continues to send BPDUs every 2 seconds (default hello time) to maintain the topology. Any link failure changes path costs and triggers a recalculation. The network reconverges quickly, especially with RSTP or MSTP.
Practical Mini-Lesson
In a real-world network, path cost is not just a theoretical concept; it is a practical tool for optimizing traffic flow. Network engineers often need to override default path costs to implement specific traffic engineering policies. For example, if you have a data center with multiple 40 Gbps links between core switches, the default path cost for 40 Gbps is 500 (under the 802.1t standard). But you might want one link to carry backup traffic and another to carry primary traffic. You can manually raise the cost on the backup link to, say, 1000, forcing STP to prefer the primary link.
When configuring path cost on Cisco switches, you use the "spanning-tree cost" command in interface configuration mode. You can also set per-VLAN costs with MSTP or PVST+. In Juniper Junos, the command is "set protocols spanning-tree interface ge-0/0/0 cost 1000." Always verify your changes with "show spanning-tree" to see the cost values in the output. Pay attention to the port role column: if a port is showing as ALT (alternate) or BLK (blocking), but you expected it to be forwarding, check the path cost.
A common issue is a flapping link caused by inconsistent path cost configuration. If two switches have different cost values for the same link due to manual misconfiguration, STP may keep switching the root port, causing intermittent connectivity. Always ensure that both ends of a link are configured with the same cost, or better, rely on default costs unless you have a specific reason to change them. Another practical tip is to use the "spanning-tree pathcost method long" command to force the switch to use the updated 32-bit cost values, which gives you more fine-grained control and avoids the need for manual cost adjustments on very high-speed links.
Finally, remember that path cost is only part of the STP story. You also need to understand bridge assurance, loop guard, and root guard, which can override path cost decisions to protect the network topology. But if you master path cost, you have already solved the biggest piece of the STP puzzle.
Memory Tip
Low cost wins. Fast link = low cost. Think of cost like golf: the lowest score wins.
Covered in These Exams
Current Exam Context
Current exam versions that test this topic — use these objectives when studying.
200-301Cisco CCNA →N10-009CompTIA Network+ →Legacy Exam Context
Older materials may mention these exam versions, but learners should use the current objectives for their target exam.
N10-008N10-009(current version)Related Glossary Terms
802.1Q is the networking standard that allows multiple virtual LANs (VLANs) to share a single physical network link by tagging Ethernet frames with VLAN identification information.
802.1X is a network access control standard that authenticates devices before they are allowed to connect to a wired or wireless network.
AAA (Authentication, Authorization, and Accounting) is a security framework that controls who can access a network, what they are allowed to do, and tracks what they did.
Frequently Asked Questions
Can I manually change the path cost on a port?
Yes, you can manually set the path cost using the "spanning-tree cost" command on Cisco switches. This overrides the default cost based on link speed.
What is the path cost of a 10 Gbps link?
Under the original IEEE 802.1D standard, a 10 Gbps link has a cost of 2. Under the revised 802.1t standard, it is 2000. The exact value depends on which standard your switch uses.
What happens if two paths have the same root path cost?
STP uses tie-breakers: first, the lowest neighbor bridge ID, then the lowest neighbor port priority, then the lowest neighbor port number. The winning port becomes the root port.
Does path cost affect the root bridge election?
No, path cost does not affect the root bridge election. The root bridge is chosen based on bridge priority and MAC address. Path cost is used after the root is elected to determine best paths to it.
How does path cost differ between classic STP and Rapid STP?
The path cost values and calculation are the same for classic STP and Rapid STP (RSTP). RSTP converges faster but uses the same cost metrics for port role selection.
Why would I want to increase the path cost of a link?
You might increase the path cost to make STP prefer an alternate path for traffic engineering, load balancing, or to force a specific link to act as a backup.
Summary
Path cost is a core metric in the Spanning Tree Protocol that determines the most efficient path through a switched network. It is inversely related to link bandwidth: faster links have lower costs and are preferred. STP uses cumulative path cost to elect root ports and designated ports, while blocking redundant links to prevent loops. Understanding default cost values for common speeds, as well as how to manually adjust costs, is essential for network engineers and appears frequently in certification exams.
In practical terms, path cost gives you control over your network traffic flow. You can influence which links carry primary data and which remain as backups. When a link fails, STP recalculates path costs and activates the next best path, ensuring high availability. Mastering path cost helps you design resilient networks that converge quickly and use bandwidth efficiently.
For exam takers, path cost is a high-yield topic. You need to know the default costs, the selection logic, and the commands to modify costs. Common mistakes include confusing cost with bandwidth direction and forgetting cumulative cost calculations. Avoid exam traps by always checking for manual cost overrides. In the real world, path cost is the backbone of loop-free switching, and a solid understanding will serve you in both certification and your career.