OSPF Cost Calculation with Interface Bandwidth

OSPF uses a formula to calculate a path cost when interface bandwidth is available.

If the interface bandwidth feature is disabled, OSPF calculates the cost as the reference-bandwidth divided by the fixed port bandwidth, as outlined in Changing the reference bandwidth for the cost on OSPF interfaces. When the interface bandwidth feature is enabled, OSPF calculates the cost as the reference-bandwidth divided by the interface bandwidth.

OSPF uses the following formula to calculate the path cost when interface bandwidth is available:

OSPF path cost = ((auto-cost × reference-bandwidth + interface bandwidth) -1) / interface bandwidth

In the preceding formula, the cost is calculated in megabits per second (Mbps). The auto-cost is configured using the auto-cost reference-bandwidth command in OSPF router configuration mode or OSPFv3 router configuration mode. For more information on changing the OSPF auto-cost reference-bandwidth, refer to Changing the reference bandwidth for the cost on OSPFv3 interfaces.