OSPF costs.

OSPF routers run SPF to determine the shortest-path. During these SPF calculations, the costs of individual links are taken into consideration. A link that has higher costs associated with it will be less attractive to OSPF.

By default, OSPF calculates the cost in the following way;

cost = reference bandwidth / link bandwidth

The default reference bandwidth is 100Mbps. The (old) default formula does not differentiate between links of 100Mbit or faster. The minimum costs associated with a link is 1.

When SPF is run, the link-cost that is taken into consideration is determined by the cost of the outgoing link towards the destination. The following picture is an attempt to further explain this;



scenario


When two routers are connected together across a gigabit link, the associated cost of that link will be 1 by default. If we were to change the costs of R1's interface to R2, we will only impact the metrics associated with the routes on R1:



scenario


In a large and complex network, fully realizing all the effects of altering the costs of a single link can become quite complex.

You can easily run into the situation where routers do not agree on the costs associated with paths between them. This can result in asymmetric routing.



scenario


In the picture above, R1 will not send traffic to R4 or any subnets behind R4 via R2. This is because the path to R4 via R2 has a total cost of 51. The path via R3 only has a total cost of 2. The return traffic, however, will traverse this expensive link. This is because from R4's point-of-view, this path has the lowest total cost associated with it.

Besides the metric or costs associated with a link, external links also have a metric type associated to them. When you redistribute something into OSPF, by default, the route will have a type 2 metric. This means that the costs of the route will be the same throughout the entire AS. By using a policy, you can change the metric type to 1. When an external route has a metric type of 1 associated with it, the costs of the route will change on a hop-by-hop basis.

10-10-2014