Learn how OSPF assigns interface costs, builds shortest paths, compares external routes, and influences SPF timing and redundancy decisions.
What you will be able to do
- Explain how Cisco IOS derives an OSPF interface cost from reference bandwidth and interface bandwidth.
- Identify two ways to control an OSPF interface cost.
- Describe how a router uses a shortest-path tree to select next hops.
- Distinguish Type 1 and Type 2 external path comparisons.
01
Cost as a Path Measure
OSPF assigns a metric, called cost, to interfaces and links. These values let a router compare possible paths instead of treating every available path as equivalent.
Interface cost and link-state metrics use the same units. Type 1 external metrics use those same units as well, so an internal OSPF cost and a Type 1 external component can participate in one cost scale.
02
How Cisco IOS Calculates Cost
By default, Cisco IOS derives an OSPF interface metric from the interface bandwidth. The calculation uses reference bandwidth divided by interface bandwidth.
Cisco IOS uses 108 as the default reference value. For a simple illustration, a reference value of 108 divided by an interface bandwidth of 54 produces a cost of 2.
03
Controlling an Interface Cost
You can change the reference value for an OSPF process with `router ospf process-id`, followed by `auto-cost reference-bandwidth ref-bw`. This changes the basis used for calculated interface metrics.
A different approach is to set one interface directly with `ip ospf cost cost`. Reference bandwidth changes calculation behavior, while the interface command explicitly assigns that interface's cost.
04
Why the Reference Value Matters
Because the metric is a ratio, changing the reference bandwidth changes the calculated costs for interfaces whose bandwidth values remain the same. The resulting values are then available for path comparison.
For example, if one path has interface costs of 3 and 4, its accumulated cost is 7. A competing path with costs of 2 and 6 also totals 8, so the first path has the smaller accumulated metric.
05
The Router’s Shortest-Path Tree
Each router builds a shortest-path tree with itself at the root. The tree represents the least-cost relationships that the router can derive from the link-state information available to it.
The routing table reflects next hops from absolute shortest paths. Thus, path selection is the result of the tree calculation, not merely a choice based on the number of links.
06
External Destinations and Type 1 Cost
Networks belonging to another autonomous system appear as external paths in the shortest-path tree. Their metrics can therefore include a component outside the internal route to the external destination.
For a Type 1 external path, total cost is the external component X plus the internal component Y. Since both components use the OSPF cost scale, the result combines the external and internal portions.
07
Type 2 External Comparison
Type 2 external metrics are handled differently from Type 1 metrics. An equal Type 2 external metric is compared by examining the distances to the paths’ forwarding addresses.
The contrast is important: Type 1 selection combines external and internal components, while equal Type 2 values use forwarding-address distances for the comparison.
08
Default Routes and SPF Timing
In one OSPF example, the presence of 172.16.0.0 allows 0.0.0.0 to be advertised externally with Type 2 and metric 5. This illustrates a specific external default path.
A default summary-LSA uses `DefaultDestination` as its Link State ID and `StubDefaultCost` as its metric. Separately, Cisco IOS can configure the delay between receiving a topology change and beginning SPF calculation.
09
Recap Before Practice and Prove
OSPF cost is a path-comparison metric. Cisco IOS normally derives interface cost from reference bandwidth divided by interface bandwidth, with 108 as the default reference value.
You can influence costs globally for an OSPF process with the reference-bandwidth setting or locally with `ip ospf cost cost`. These controls affect how interfaces contribute to path comparisons.
A router places itself at the root of a shortest-path tree and uses absolute shortest paths to determine routing-table next hops. External destinations appear as external paths in that tree.
Type 1 external cost combines external and internal components. Equal Type 2 external metrics instead use distances to forwarding addresses, so the comparison rule changes.
Before Practice and Prove, be ready to calculate a path cost, identify the control that sets it, and explain why the selected next hop follows the shortest-path result.