OSPF Path Selection

OSPF executes Dijkstra’s shortest path first (SPF) algorithm to create a loop-free topology of shortest paths. All routers use the same logic to calculate the shortest path for each network. Path selection prioritizes paths by using the following logic:

  • Intra-area
  • Inter-area
  • External Type 1
  • External Type 2

Link Costs

Interface cost is an essential component for Dijkstra’s SPF calculation because the shortest path metric is based on the cumulative interface cost (that is, metric) from the router to the destination.

Intra-Area Routes

  • Routes advertised using a Type 1 LSA for an area are always preferred over Type 3 LSAs.
  • If multiple intra-area routes exist, the path with the lowest total path metric is installed in the OSPF RIB and is then presented to the router’s global RIB.
  • If there is a tie in metric, both routes are installed into the OSPF RIB.

Example:

  • R1 is computing the route to 10.4.4.0/24.
  • Instead of taking the faster Ethernet connection (R1→R2→R4), R1 takes the path across the slower serial link (R1→R3→R4) to R4 because that is the intra-area path.
R1# show ip route 10.4.4.0
Routing entry for 10.4.4.0/24
  Known via "ospf 1", distance 110, metric 111, type intra area
  Last update from 10.13.1.3 on GigabitEthernet0/1, 00:00:42 ago
  Routing Descriptor Blocks:
  * 10.13.1.3, from 10.34.1.4, 00:00:42 ago, via GigabitEthernet0/1
      Route metric is 111, traffic share count is 1

Inter-Area Routes

  • The next priority for selecting a path to a network is selection of the path with the lowest total path metric to the destination.
  • If there is a tie in metric, both routes are installed in the OSPF RIB.
  • All inter-area paths for a route must go through Area 0 to be considered.

Example:

  • R1 is computing the path to R6.
  • R1 uses the path R1→R3→R5→R6 because its total path metric is 35 rather than the R1→R2→R4→R6 path with a metric of 40.

External Route Selection

External routes are classified as Type 1 or Type 2.

  • Type 1 routes are preferred over Type 2 routes.
  • The Type 1 metric equals the redistribution metric plus the total path metric to the ASBR.
    • In other words, as the LSA propagates away from the originating ASBR, the metric increases.
  • The Type 2 metric equals only the redistribution metric.
    • The metric is the same for the router next to the ASBR as it is for the router 30 hops away from the originating ASBR.
    • This is the default external metric type that OSPF uses.

E1 and N1 External Routes

  • External OSPF Type 1 route calculation uses the redistribution metric plus the lowest path metric to reach the ASBR that advertised the network.
  • Type 1 path metrics are lower for routers closer to the originating ASBR, whereas the path metric is higher for a router 10 hops away from the ASBR.
  • If there is a tie in the path metric, both routes are installed into the RIB.
  • If the ASBR is in a different area, the path of the traffic must go through Area 0.
  • An ABR does not install O E1 and O N1 routes into the RIB at the same time.
    • O N1 is always given preference for a typical NSSA, and its presence prevents the O E1 from being installed on the ABR.

E2 and N2 External Routes

  • External OSPF Type 2 routes do not increment in metric, regardless of the path metric to the ASBR.
  • If there is a tie in the redistribution metric, the router compares the forwarding cost.
    • The forwarding cost is the metric to the ASBR that advertised the network, and the lower forwarding cost is preferred.
    • If there is a tie in forwarding cost, both routes are installed into the routing table.
  • An ABR does not install O E2 and O N2 routes into the RIB at the same time.
    • O N2 is always given preference for a typical NSSA, and its presence prevents the O E2 from being installed on the ABR.

Example:

R1 computing a path to the external network 172.16.0.0/24 that is being redistributed.

  • The path R1→R2→R4→R6 has a metric of 20, which ties with the path R1→R3→R5→R7.
  • The forwarding metric of the R1→R2→R4→R6 path is 31, and the forwarding metric of the R1→R3→R5→R7 path is 30.
  • R1 installs the R1→R3→R5→R7 path into the routing table.
R1# show ip route 172.16.0.0
Routing entry for 172.16.0.0/24
  Known via "ospf 1", distance 110, metric 20, type extern 2, forward metric 30
  Last update from 10.13.1.3 on GigabitEthernet0/1, 00:12:40 ago
  Routing Descriptor Blocks:
  * 10.13.1.3, from 192.168.7.7, 00:12:40 ago, via GigabitEthernet0/1
      Route metric is 20, traffic share count is 1

Equal-Cost Multipathing

  • If OSPF identifies multiple paths, those routes are installed into the routing table using equal-cost multipathing (ECMP).
  • The default maximum number of ECMP paths is four.
  • The default ECMP setting can be overwritten with the command maximum-paths maximum-paths under the OSPF process to modify the default setting.

Summary

OSPF path selection prefers..
  1. Intra-Area routes (O)
  2. Inter-Area routes (O IA)
  3. External Type 1 (E1)
  4. NSSA Type 1 (N1)
  5. External Type 2 (E2)
  6. NSSA Type 2 (N2)
Cannot be modified with metric or distance.
  • Cisco’s implementation uses BW based cost
    • Default Cisco Cost = 100Mbps / Link BW
    • Reference BW can be modified to accommodate higher speed links

Leave a Reply

Related Post