Infographic explaining OSPF cost calculation formula with reference bandwidth over interface bandwidth, including table of costs for Gigabit Ethernet (1), Fast Ethernet (10), Ethernet (100), and Serial 64 Kbps

Master OSPF Metric: Learn Cost Calculation for Optimal Routing (Updated 2025)

OSPF (Open Shortest Path First) relies on “cost” as its metric to select the best path in a network. For CCNA and CCNP students, understanding OSPF cost calculation is crucial for exam topics like route selection and optimization. The default reference bandwidth is 100 Mbps (or 10^8 bps), and lower costs indicate preferred paths. This metric reflects the overhead of sending packets over an interface, prioritizing higher-bandwidth links for faster routing.

The cost is inversely proportional to bandwidth: higher bandwidth = lower cost. For example, under default settings, a 100 Mbps link has a cost of 1, while a 10 Mbps link has 10.

The formula is: Cost = Reference Bandwidth (in bps) / Interface Bandwidth (in bps)

  • Default Reference Bandwidth: 100,000,000 bps (100 Mbps).
  • Result is an integer (floor division); if <1, set to 1.
  • Example: For 100 Mbps interface: 100,000,000 / 100,000,000 = 1.
  • For 1 Gbps (1,000,000,000 bps): 100,000,000 / 1,000,000,000 ≈ 0.1 → 1 (minimum).

This default doesn’t differentiate links faster than 100 Mbps, leading to suboptimal routing in modern networks with Gigabit+ interfaces.

Interface TypeBandwidth (bps)OSPF Cost (Default Ref 100 Mbps)
10 Gigabit Ethernet10,000,000,0001
Gigabit Ethernet1,000,000,0001
Fast Ethernet100,000,0001
Ethernet10,000,00010
Serial (T1)1,544,00064
Serial (128 Kbps)128,000781
Serial (64 Kbps)64,0001562

Note: Costs use floor division; Cisco often rounds down for consistency.

OSPF Accumulates Costs

Design 493116466
Master OSPF Metric: Learn Cost Calculation for Optimal Routing (Updated 2025) 5

OSPF sums costs along the path (outgoing interfaces only).

Example Topology:

  • R1 — FastEth (cost 1)– R4 –Eth (10 Mbps, cost 10)– R2
  • R1 — GigEth (cost 1)– R3 –Serial (128 Kbps, cost 781)– R2

Path 1 total cost: 1 + 10 = 11 (preferred). Path 2: 1 + 781 = 782.

For CCNA labs: Use show ip route to verify. To differentiate high-speed links, increase reference bandwidth (e.g., to 10,000 Mbps for 10G).

The routing table of Router1 for network 192.168.20.0 in Figure 3 confirms the OSPF metric to reach the Router2 LAN is a cost of 11.

OSPF Metric
Master OSPF Metric: Learn Cost Calculation for Optimal Routing (Updated 2025) 6

Adjusting the Reference Bandwidth

OSPF uses 100 Mbps bandwidth for reference to any links that are equal to or faster than a Fast Ethernet connection. Therefore, the cost assigned to a Fast Ethernet with a reference bandwidth of 100 Mbps would equal 1.

This calculation works for fast Ethernet interfaces, so links faster than 100 Mb/s are not easy to calculate because the OSPF metric only uses integers as its final cost of a link. If the calculation is less than an integer, OSPF protocol rounds up the value to the closest integer.

So, from the OSPF point of view, an interface with an interface bandwidth of 100 Mb/s has the same cost as an interface with a bandwidth of 1Gbps, 10Gbps and 100 Gbps. So, for making the best path determination, the reference bandwidth must be modified to a higher value than 100 Mbps to accommodate faster links than 100 Mbps.

Changing the Reference Bandwidth

Changing the reference bandwidth does not affect the actual bandwidth capacity on the link. It simply affects the OSPF metric calculation. We can change the reference bandwidth with router configuration mode <auto-cost reference-bandwidth Mbps>.

The configuration must be the same on every router in the OSPF domain. The value is in Mbps, so to adjust the costs for GigaEthernet, the command would <auto-cost reference-bandwidth 1000>and for 10 Gigabit Ethernet, <auto-cost reference-bandwidth 10000>.

To cancel the default reference bandwidth, use the command <auto-cost reference-bandwidth 100> in router configuration mode. The table in Figure 1 illustrates the OSPF cost if the reference bandwidth is set to Gigabit Ethernet (1000). The table in Figure 2 illustrates the OSPF cost if the reference bandwidth is set to 10 Gigabit Ethernet links. In Table 1, the OSPF makes better choices because it can now differentiate between Fast Ethernet and Gigabit Ethernet links. In Table 2 it is also differentiated between 100Mbps, 1G and 10G links.

📊 Interface Types and OSPF Cost Values (Reference Bandwidth: 1000 Mbps)

Interface TypeCost Value
10 Gigabit Ethernet (10 Gbps)1
Gigabit Ethernet (1 Gbps)1
Fast Ethernet (100 Mbps)10
Ethernet (10 Mbps)100
Serial (1.544 Mbps)647
Serial (128 Kbps)7812
Serial (64 Kbps)15625

🧠 Why This Matters

These cost values are derived from the formula:

Screen Shot 2025 10 07 at 6.26.44 AM
Master OSPF Metric: Learn Cost Calculation for Optimal Routing (Updated 2025) 7

With a reference bandwidth of 1000 Mbps, OSPF assigns higher costs to slower links, influencing route selection. For example:

  • A Gigabit Ethernet link (Cost = 1) is preferred over a Serial 64 Kbps link (Cost = 15625).
  • You can modify the reference bandwidth using:

Router(config-router)# auto-cost reference-bandwidth

FAQs

What is the OSPF cost formula and how does it work?

The OSPF cost formula is Cost = Reference Bandwidth (bps) / Interface Bandwidth (bps), using floor division with a minimum of 1. Default reference is 100,000,000 bps. For a 100 Mbps link, it’s 1; for 10 Gbps, it rounds to 1 under default, leading to no differentiation for high-speed links. Adjust the reference for better accuracy.

Why should you adjust the OSPF reference bandwidth?

Default 100 Mbps doesn’t distinguish between Gigabit and faster links, causing suboptimal paths. Set to 1000 or 10000 Mbps via auto-cost reference-bandwidth command to assign proper costs, like Fast Ethernet at 10 under 1000 Mbps ref. Apply domain-wide to prevent loops, ideal for modern networks in CCNP scenarios.

How does OSPF accumulate costs for route selection?

OSPF sums costs of outgoing interfaces from source to destination. In a topology, Path 1 (FastEth cost 1 + Eth cost 10 = 11) is preferred over Path 2 (GigEth 1 + Serial 781 = 782). Use show ip route to verify. This ensures lowest overhead paths

What are common pitfalls in OSPF cost calculation?

Inconsistent reference bandwidth across routers causes asymmetric routing or loops. Forgetting minimum cost of 1 for high-speed links, or confusing configured vs. actual bandwidth. Always verify with show ip ospf interface. In CCNP, manual overrides like ip ospf cost help tune unequal links.

How to verify OSPF costs in a Cisco network?

Use show ip ospf interface for per-interface costs, show ip route ospf for accumulated metrics, and show ip ospf for reference bandwidth. In labs, adjust and recheck to see changes. Essential for troubleshooting suboptimal routing.

Avatar of Asad Ijaz

Asad Ijaz

NetworkUstad's lead networking architect with CCIE certification. Specializes in CCNA exam preparation and enterprise network design. Authored 2,800+ technical guides on Cisco systems, BGP routing, and network security protocols since 2018. Picture this: I'm not just someone who writes about tech; I'm a certified expert in the field. I proudly hold the titles of Cisco Certified Network Professional (CCNP) and Cisco Certified Network Associate (CCNA). So, when I talk about networking, I'm not just whistling in the dark; I know my stuff! My website is like a treasure trove of knowledge. You'll find a plethora of articles and tutorials covering a wide range of topics related to networking and cybersecurity. It's not just a website; it's a learning hub for anyone who's eager to dive into the world of bits, bytes, and secure connections. And here's a fun fact: I'm not a lone wolf in this journey. I'm a proud member and Editor of Team NetworkUstad. Together, we're on a mission to empower people with the knowledge they need to navigate the digital landscape safely and effectively. So, if you're ready to embark on a tech-savvy adventure, stick around with me, Asad Ijaz Khattak. We're going to unravel the mysteries of technology, one article at a time!"