OSPF Cost
Calculate OSPF interface cost from link bandwidth using the reference bandwidth formula.
About OSPF Cost
OSPF calculates a link's cost by dividing a configurable reference bandwidth by the interface's actual bandwidth, then rounding down to the nearest integer, with a minimum cost of 1. The default reference bandwidth on Cisco devices is 100 Mbps, a value set when Fast Ethernet was considered fast — any link at or above 100 Mbps produces a cost of 1, which fails to distinguish a 1 Gbps link from a 100 Gbps link. For this reason, most modern OSPF deployments raise the reference bandwidth (e.g. to 10,000 or 100,000 Mbps) so that cost values properly differentiate across the full range of link speeds in use.
Formula
OSPF interface cost
cost = floor(reference_bandwidth / interface_bandwidth), minimum 1
- B_ref
- Reference bandwidth (default 100 Mbps)
- B_if
- Interface bandwidth
Worked example
With the default values below, OSPF Cost returns OSPF Interface Cost of 1. Change any input above and every figure here is recalculated in your browser.
Inputs used
- Interface Bandwidthminimum 0.001 Mbps
- 1,000 Mbps
- Reference Bandwidthminimum 1 Mbps
- 100 Mbps
Results
- OSPF Interface Cost
- 1
- Raw (Unrounded) Cost
- 0.1000
- Warning
- Interface bandwidth exceeds reference bandwidth — cost floored to 1 (no differentiation from slower links).
Step by step
- 1Values used
- 2OSPF interface cost
- 3OSPF Interface Cost= 1
- 4Raw (Unrounded) Cost= 0.1000
- 5Warning= Interface bandwidth exceeds reference bandwidth — cost floored to 1 (no differentiation from slower links).
Assumptions and limits
- The result is derived only from the 2 inputs listed above. Anything not among them is not part of the calculation.
- In particular, this calculator does not take inflation, tax, fees or charges or compounding frequency into account.
- Figures are rounded for display to 4 decimal places, so totals built from several rounded parts can differ slightly from the unrounded arithmetic.
How these calculators are built and tested is described on the Methodology page. If a figure looks wrong, please report it.
Frequently Asked Questions
Why is the default OSPF reference bandwidth only 100 Mbps?
The 100 Mbps default was set when OSPF (RFC 2328) was standardized in an era when Fast Ethernet was near the top of typical link speeds. It has never been changed in the default configuration of most vendor implementations for backward compatibility, even though it now makes every link at or above 100 Mbps compute to the same minimum cost of 1.
What happens if all my links show OSPF cost 1?
It means every link's bandwidth is at or above your configured reference bandwidth, so OSPF's shortest-path calculation can no longer distinguish a fast link from a much faster one — the protocol will treat a 1 Gbps and a 100 Gbps path as equally 'good,' which can lead to suboptimal path selection on networks with mixed link speeds above the reference value.
How do I fix cost values that don't differentiate between fast links?
Raise the reference bandwidth (via the 'auto-cost reference-bandwidth' command on Cisco devices, configured consistently across the entire OSPF area/domain) to a value comfortably above your fastest link speed — many networks with 10G/40G/100G links use a reference bandwidth of 100,000 Mbps or higher so all link speeds get a distinct, proportionally accurate cost.
