Understanding OSPF Cost
Internal Route OSPF Cost
OSPF uses a value called cost for its metric when determining the metric for a particular routing prefix. OSPF defines the cost for a particular prefix according to the following formula:OSPF cost = cost from LSA + (incoming interface bandwidth/reference bandwidth)
OSPF uses 100 Mb/s for its default reference bandwidth on Cisco routers, but on routers that use Gigabit Ethernet or 10 Gigabit Ethernet, this value should be changed both on the router and everywhere else in the OSPF network. This can be changed using the auto-cost reference-bandwidth command:
R1(config-router)#auto-cost reference-bandwidth ?
<1-4294967> The reference bandwidth in terms of Mbits per second
Note that this is the configured bandwidth on the interface, not the actual bandwidth. The following table shows the OSPF cost for different link types and reference bandwidths:
Link Type | 100M (default) Reference Bandwidth | 1G Reference Bandwidth | 10G Reference Bandwidth |
56k serial | 1785 | 17857 | 178571 |
64k serial | 1562 | 15625 | 156250 |
T1 (1.544 Mbps serial) | 64 | 647 | 6476 |
E1 (2.048 Mbps serial) | 48 | 488 | 4882 |
Ethernet | 10 | 100 | 1000 |
Fast Ethernet | 1 | 10 | 100 |
Gigabit Ethernet | 1 | 1 | 10 |
The OSPF cost can also be manually set for an interface with the ip ospf cost interface subcommand.
R1(config-if)#ip ospf cost ?
<1-65535> Cost
The OSPF cost of an outgoing interface is not added to an outgoing LSA, rather the receiving router adds its own interface cost to the cost that was advertised in the LSA (and propagates that cost to other routers). In this way, the total cost is the cost of each outgoing interface on each router between a particular router and the router connected to a specific prefix.
The OSPF cost can be set for connected networks being advertised into OSPF using the ip ospf cost interface command. It is also possible to set the OSPF cost for a connected route using a route map and redistributing connected networks, though this causes the route to be considered an external route and the metric is determined initially by the set clause of the route map and propagated according to whether it is considered a type 1 external route or a type 2 external route (type 2 is default on the Cisco IOS platform).
It should also be noted that the bandwidth interface configuration command (which has no actual effect on available bandwidth) can modify the OSPF cost for an interface by overriding the bandwidth inferred from the interface type.
Inter-Area and External Route OSPF Cost and Path Selection
Inter-area routes add the cost of the ABR to reach a particular network with the cost to reach an ABR.External routes redistributed into OSPF are either considered type 2 or type 1 external routes. Type 2 is default and the cost used to determine the shortest path to the advertised network is solely the cost advertised by the ASBR for the prefix (not by the cost to reach any intermediate ABRs or other routers). For type 1 routes, routers add the cost to get to the ASBR to the cost advertised by the ASBR to determine the metric for the route as well as the cost to reach any intermediate ABRs or other routers.
Most of the examples that show routing differences between type 1 and type 2 external routes are theoretical. There aren't very many drivers from a network design standpoint to implement multiple interior gateway routing protocols in a new network or in a network that is being re-engineered or transitioning between routing protocols (ex. RIP -> OSPF or EIGRP -> OSPF). The drivers that do exist mainly involve migrations due to mergers and acquisitions or in high complexity service provider scenarios (mainly interior to a service provider's network or involved with layer 3 carrier MPLS solutions). For VoIP design, EIGRP and OSPF can both be tuned to have subsecond convergence assuming the correct level of redundancy exists in the network and redistribution is not typically required.
When thinking about OSPF costs, it is important to think about how OSPF chooses routes because the rules may supercede cost in a few different scenarios:
- OSPF prefers intra-area routes to inter-area routes, regardless of cost
- OSPF routes across area zero without routing across a non-backbone area if at all possible
- Finally, OSPF routes to the destination without traversing area 0
See Also
The Road to the CCIE
No comments:
Post a Comment