OSPF Interface Cost Calculator
Calculate OSPF interface cost from reference and interface bandwidth, compare manual overrides, and spot fast-link cost collapse before routing changes.| Cost factor | Value | Detail | Copy |
|---|---|---|---|
| {{ row.factor }} | {{ row.value }} | {{ row.detail }} |
| Check | Recommendation | Reason | Copy |
|---|---|---|---|
| {{ row.check }} | {{ row.recommendation }} | {{ row.reason }} |
| Interface speed | Auto cost | Raw ratio | Path note | Copy |
|---|---|---|---|---|
| {{ row.speedLabel }} | {{ row.costLabel }} | {{ row.rawRatioLabel }} | {{ row.note }} |
Introduction:
Small OSPF metric choices can move a surprising amount of traffic. Open Shortest Path First does not pick a route because an interface has the largest printed speed on its optics or switch port. It builds a link-state view of the area, adds the advertised costs along each candidate path, and prefers the path with the lower total. When two or more paths have the same total cost, routers may install equal-cost routes and share traffic across them.
Interface cost is therefore both a scale value and a design signal. It is an administrative routing metric, not a live measurement of delay, loss, utilization, or queue depth. A 10 Gb/s link and a 100 Gb/s link can both become cost 1 if the reference bandwidth is too low. A slow but low-latency private circuit can look worse than a faster but congested path if the only modeled input is bandwidth. Cost planning needs the arithmetic, but it also needs a network-design judgment about which links should be preferred.
The common auto-cost model starts with a reference bandwidth. The reference marks the speed that should receive the minimum cost. Interface bandwidth is divided into that reference, the result is converted to a whole number, and the final interface cost is advertised in OSPF link-state information. Older default references made sense when 100 Mb/s links were common. In modern networks, leaving that scale unchanged can flatten 1G, 10G, 25G, 100G, and faster interfaces into the same minimum metric.
| Concept | Plain meaning | Planning risk |
|---|---|---|
| Reference bandwidth | The domain-wide scale used as the numerator for automatic cost. | Too low a reference makes fast links look identical. |
| Interface bandwidth | The bandwidth value the routing process uses for that interface. | A configured bandwidth can differ from physical port capability. |
| Manual cost | An explicit interface metric set by configuration. | It can outlive later reference-bandwidth changes and surprise audits. |
| Path cost | The sum of the link costs along a candidate route. | One changed interface can move traffic through a different part of the network. |
Manual cost is useful when bandwidth is not the whole story. Operators use it to prefer a primary uplink, keep a backup circuit unattractive, avoid a maintenance path, or reflect latency and business policy that the bandwidth formula cannot see. The tradeoff is auditability. Formula-based costs move together when the reference is changed consistently; manual costs must be tracked one interface at a time.
A good OSPF cost plan does not try to make every speed unique. It separates the speeds and paths that need distinct routing behavior, keeps equal-cost paths intentional, and leaves enough room in the metric range for slower links, backup links, and future upgrades.
How to Use This Tool:
Use the calculator once for the current design and again for any proposed reference-bandwidth change. That makes it easier to see whether the new scale preserves the path choices you expect.
- Enter
Reference bandwidthand choose the matching unit. For OSPF reference-bandwidth commands, the ledger reports the equivalent Mbps value. - Enter
Interface bandwidth. Use the bandwidth value the routing stack uses for the interface, which may be a configured bandwidth rather than the physical port maximum. - Leave
Configured overrideat0when no interface-level cost is set. Enter a value from1through the selected ceiling to model a manual cost. - Open
Advancedonly when you need to compare integer handling or a nonstandard lab ceiling.Floor / truncatematches the most common auto-cost examples. - Fix any red input message before using the result. The reference must be at least
1 Mbps, interface bandwidth must be greater than0, and configured cost must fit the selected range. - Review
Cost Ledgerfirst, then usePath Guidance,Cost Separation Ladder, andSpeed Cost Tableto check whether common link tiers still separate cleanly.
For a change record, capture the effective cost, the raw cost ratio, the reference-bandwidth command value, the integer policy, and whether the result came from auto-cost or a manual override.
Interpreting Results:
Effective advertised cost is the value to read first. With no manual value, it matches Auto interface cost. When a manual cost is entered, the manual value becomes effective and the ledger keeps the formula result visible for comparison.
Raw cost ratio explains the boundary cases. A ratio below 1 reaches the minimum metric and becomes cost 1. A ratio above the selected ceiling is capped. A fractional ratio can change under Floor / truncate, Round nearest, or Ceiling, so compare that field when you need parity with a specific platform policy.
| Result state | Meaning | Check next |
|---|---|---|
Auto-cost active |
The effective cost follows the reference divided by interface bandwidth. | Check the sampled high-speed tiers for collapse to cost 1. |
Manual override active |
The configured interface cost replaces the formula value. | Document the reason before changing the domain reference. |
Minimum cost floor |
The selected interface is at or above the speed represented by the current reference. | Raise the reference if faster links need distinct automatic costs. |
Cost capped |
The rounded formula result exceeded the selected maximum. | Confirm the link speed, reference value, and accepted metric range. |
The cost separation ladder is a sanity check, not a full topology simulation. It shows how common interface speeds map under the selected reference. It does not know which neighbors exist, whether equal-cost multipath is enabled, or whether another area, redistribution rule, or external metric will dominate the final route choice.
Technical Details:
OSPF advertises an output cost for an interface in link-state information, then computes shortest paths by adding the costs of the constituent links. Because each router runs its own shortest-path calculation from the same flooded topology, a metric set on one interface can influence remote routers that choose paths through that link.
The automatic bandwidth model uses inverse scaling. A higher interface bandwidth produces a lower metric, while the reference bandwidth defines the scale for every automatically derived cost. The lowest usable interface cost is greater than zero, so any raw ratio below one still becomes cost 1. That minimum is why an old reference setting loses resolution when a network moves from 100M and 1G links into 10G, 25G, 100G, and faster Ethernet tiers.
Formula Core:
The primary calculation converts both bandwidths to Mbps, divides the reference by the interface bandwidth, applies the selected integer policy, clamps the result to the modeled metric range, and then applies a manual override when one is present.
| Symbol | Meaning | Visible field or result |
|---|---|---|
B_ref |
Reference bandwidth after conversion to Mbps | Reference bandwidth |
B_iface |
Interface bandwidth after conversion to Mbps | Interface bandwidth |
R_raw |
Fractional ratio before integer handling | Raw cost ratio |
C_auto |
Formula-derived cost after rounding and bounds | Auto interface cost |
C_effective |
Advertised cost after any manual override | Effective advertised cost |
For example, a 100 Gbps reference is 100,000 Mbps. A 10 Gbps interface is 10,000 Mbps. The raw ratio is 100,000 / 10,000 = 10, so the auto-cost is 10 under the normal floor policy. If a manual cost of 250 is configured, the advertised value becomes 250 while the formula-derived 10 remains useful as the audit baseline.
| Boundary | Rule modeled | Why it matters |
|---|---|---|
| Reference bandwidth | At least 1 Mbps and no more than 4,294,967 Mbps |
Matches common reference-bandwidth command limits. |
| Interface bandwidth | Greater than 0 |
The cost ratio cannot divide by zero. |
| Cost ceiling | 1 through 65,535 |
Models the common 16-bit interface metric ceiling. |
| Manual override | 0 means none; otherwise 1 through the selected ceiling |
An explicit interface cost bypasses the automatic bandwidth formula. |
| Integer policy | Floor / truncate, Round nearest, or Ceiling |
Controls fractional ratios before minimum and maximum bounds are applied. |
Changing the reference bandwidth does not change the OSPF standard's path-sum behavior. It changes the locally generated interface metrics that feed that path sum. For predictable results, the same reference should be deployed consistently across the OSPF domain unless a platform-specific design intentionally does otherwise.
Limitations and Privacy Notes:
This calculator uses the values entered on the page. It does not log in to routers, read live interface bandwidth, inspect neighbor state, query route tables, or verify the link-state database. Treat the result as a planning and audit aid, then confirm the final metric on the target platform.
Vendor behavior and CLI syntax can differ, especially around default reference bandwidth, rounding examples, interface bandwidth sources, and accepted manual-cost ranges. Use the integer policy and ceiling controls to model the design you need, but check platform documentation before a production change.
Reference-bandwidth changes can recalculate many interface costs at once. Test equal-cost paths, backup paths, redistribution boundaries, and maintenance-window impact before applying a new scale across an area or domain.
Worked Examples:
Modern reference for a 10G uplink:
A 100 Gbps reference and a 10 Gbps interface produce a raw ratio of 10.000. With Configured override left at 0, Auto interface cost and Effective advertised cost both show 10.
Old reference that collapses fast links:
A 100 Mbps reference and a 1 Gbps interface produce a raw ratio of 0.100. The automatic result reaches the minimum and becomes cost 1. The speed table can then show several faster tiers sharing the same minimum metric.
Manual traffic-engineering cost:
With the 100 Gbps reference and 10 Gbps interface still in place, entering 250 in Configured override makes the effective cost 250. The ledger still shows the auto-cost of 10, so the override delta is visible.
Input that needs correction:
If the reference is below 1 Mbps, the interface bandwidth is zero, or the configured override exceeds the selected ceiling, the summary changes to Review inputs. Fix the validation message before relying on the tables, chart, or JSON output.
FAQ:
What reference bandwidth should I use?
Use the same reference across the OSPF domain and choose a value high enough to separate the fastest links whose path preference should differ. A campus with only 1G and slower links may not need the same scale as a core with 100G uplinks.
Why do several speeds show cost 1?
Their raw ratios are below one, so the minimum OSPF interface cost applies. Raise the reference bandwidth if those speeds need distinct automatic costs.
Does a manual interface cost override auto-cost?
Yes. A configured value from 1 through the selected ceiling replaces the automatic result. Enter 0 when no manual cost is configured.
Should interface bandwidth equal physical line rate?
Not always. OSPF uses the bandwidth value exposed to the routing process. That can be a physical rate, a configured interface bandwidth, or a platform-specific value, so verify the source before comparing costs.
Can cost alone predict the final forwarding path?
No. Interface cost feeds the OSPF shortest-path calculation, but the final route can also depend on areas, route type, summarization, external metrics, equal-cost multipath settings, and policy outside this calculation.
Glossary:
- OSPF
- Open Shortest Path First, a link-state interior gateway protocol that calculates shortest paths inside routing areas.
- Reference bandwidth
- The scale value used by the automatic cost formula. A link at or above this speed reaches the minimum automatic cost.
- Interface cost
- The OSPF metric advertised for sending traffic out a router interface.
- LSA
- Link-state advertisement, the OSPF information routers flood so other routers can compute paths.
- ECMP
- Equal-cost multipath, where multiple routes with the same cost can be installed and used in parallel.