{"id":340,"date":"2010-01-26T13:17:51","date_gmt":"2010-01-26T13:17:51","guid":{"rendered":"http:\/\/mccltd.net\/blog\/?p=340"},"modified":"2010-01-26T13:17:51","modified_gmt":"2010-01-26T13:17:51","slug":"ospf-costs-calculations","status":"publish","type":"post","link":"http:\/\/darenmatthews.com\/blog\/?p=340","title":{"rendered":"OSPF Costs &#8211; Calculations"},"content":{"rendered":"<p>Computed cost<br \/>\nEach interface has an associated cost. It is computed as follows:<!--more--><\/p>\n<p>reference bandwidth \/ configured bandwidth of interface in kbps<br \/>\nOn Cisco routers, the reference bandwidth defaults to 100000 kbps. So, a DS-3 interface, with a configured bandwidth of 45000 kbps, has a cost of:<\/p>\n<p>100,000,000 \/ 45,000 = 2222<br \/>\nThe interface bandwidth must be explicitly configured. If not, the router will probably get it wrong. It is configured using the following syntax:<\/p>\n<p>int h1\/0<br \/>\n\u00a0bandwidth 45000<br \/>\nDifferent manufacturers use different reference bandwidths. It is therefore common practice for every router to have it&#8217;s OSPF reference bandwidth set. Many sysadmins set it to 10000(k) using the following syntax:<\/p>\n<p>router ospf 100<br \/>\n\u00a0auto-cost reference-bandwidth 10000<br \/>\nThis reference bandwidth should be the same on all of your routers.<\/p>\n<p>Once this is done, our DS-3 interface will have a cost of:<\/p>\n<p>10,000,000 \/ 45,000 = 222<\/p>\n<p>Configured cost<br \/>\nYou may want to configure the costs on some of your interfaces, for instance to make the interface costs of both ends of a link match, to make path cost computation simpler for humans, or to force OSPF to prefer certain paths. To do this, use the following syntax:<\/p>\n<p>int h1\/0<br \/>\n\u00a0ip ospf cost 200<br \/>\nNow the OSPF cost of my DS-3 is 200.<\/p>\n<p>Route metrics<br \/>\nHere&#8217;s the easy part. To compute the OSPF cost of a route, start at the router doing the calculation and sum the costs of the interfaces used to exit each router that is traversed.<\/p>\n<p>Note that the costs of the same path in the reverse direction will be different, if the exit interfaces have different costs than the interfaces used in the forward direction. This causes asymmetrical path costs, and may result in asymmetrical routes. (There is nothing wrong with asymmetrical routes, per se.)<\/p>\n<p>Redistributed routes<br \/>\nAn ASBR is an OSPF router that redistributes routes into OSPF that were learned from another protocol. When doing this redistribution, the ASBR often sets a metric.<\/p>\n<p>For instance:<\/p>\n<p>router OSPF 100<br \/>\n\u00a0redistribute static subnets route-map REDIST-MAP<br \/>\n!<br \/>\nroute-map REDIST-MAP permit 10<br \/>\n\u00a0match ip address REDIST-LIST<br \/>\n\u00a0set metric 180<br \/>\n\u00a0set metric-type type-1<br \/>\n!<br \/>\nip access-list standard REDIST-LIST<br \/>\n\u00a0permit 81.0.0.0 0.255.255.255<br \/>\n\u00a0permit 82.0.0.0 0.255.255.255<br \/>\n!<br \/>\nip route 81.0.0.0 255.0.0.0 172.16.25.1<br \/>\nip route 82.0.0.0 255.0.0.0 172.16.25.1<br \/>\nThis code will tell OSPF that 81.x and 82.x are reachable via 172.16.25.1, with an OSPF metric of 180 and an OSPF metric type of E1 (external type 1). Some other router will calculate the cost to these networks by summing the exit interface costs to 172.16.25.1, and then adding 180.<\/p>\n<p>(Had the metric-type been E2 (external type 2), the other router would not include the interface costs, and would consider the route to have a metric of 180.)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Computed cost Each interface has an associated cost. It is computed as follows:<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[83],"tags":[20],"_links":{"self":[{"href":"http:\/\/darenmatthews.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/340"}],"collection":[{"href":"http:\/\/darenmatthews.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/darenmatthews.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/darenmatthews.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/darenmatthews.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=340"}],"version-history":[{"count":4,"href":"http:\/\/darenmatthews.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/340\/revisions"}],"predecessor-version":[{"id":344,"href":"http:\/\/darenmatthews.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/340\/revisions\/344"}],"wp:attachment":[{"href":"http:\/\/darenmatthews.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=340"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/darenmatthews.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=340"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/darenmatthews.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=340"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}