OSPF Metric Calculation
The OSPF metric is a value that identifies a route's value (quality) to a certain network. For OSPF to select the best route to each destination, it must first calculate the metric for each interface and then find the total sum of all routes toward the destination.
The calculation of the OSPF metric is quite a simple process and is based on the bandwidth of the interface. The metric is called cost when using OSPF. On Cisco devices, the formula to calculate the OSPF cost is:
cost = reference bandwidth (100mbps) / interface bandwidth
The smaller the cost, the better the route. A router with multiple routes to the same network will always select the one with the lower cost. When several routes have the same cost, OSPF includes them all in the routing table. This is called load balancing.
Note: Keep in mind that the cost cannot go below 1. As a result, every link faster than 100 Mbps will be identified as equally good according to OSPF by default. Therefore, the reference bandwidth needs to be changed to a value equal to or higher than the fastest link in the topology to ensure accurate calculations.