Octet

How is OSPF cost calculated, and why do people raise the reference bandwidth?

Show the answer

Say this first

Cost is reference bandwidth divided by interface bandwidth, rounded down, with a minimum of 1. The IOS default reference is 100 Mbps, so FastEthernet, 1G, 10G and 100G all cost 1 and OSPF cannot tell them apart. I raise it with auto-cost reference-bandwidth to above the fastest link, the same value on every router.

Go deeper

With the default of 100 Mbps

InterfaceBandwidthCost
Ethernet10 Mbps10
FastEthernet100 Mbps1
GigabitEthernet1 Gbps1
TenGigabitEthernet10 Gbps1

With auto-cost reference-bandwidth 100000 (100 Gbps)

InterfaceCost
100G1
40G2
10G10
1G100
100M1000
Cisco IOS
router ospf 1
 auto-cost reference-bandwidth 100000
% OSPF: Reference bandwidth is changed.
        Please ensure reference bandwidth is consistent across all routers.

The value is in Mbps. Interface cost tops out at 65535.

Why every router must match

Each router computes the cost of its own outgoing links. If R1 uses 100000 and R2 uses 100, R1's 10G links cost 10 and R2's cost 1, and paths become asymmetric and odd. Nothing warns you across routers.

Other platforms

Junos also defaults to 100 Mbps (reference-bandwidth under protocols ospf). NX-OS defaults to 40 Gbps.

Traps

  • Saying cost is based on delay or load. OSPF cost only uses bandwidth, or a value you set.
  • Changing the reference bandwidth on a few routers and calling it done.
How did you do?