OSPF Path Selection Process Explained

OSPF Path Selection Process Explained

Having a clear understanding of how OSPF determines the best path to a destination network is very important. In this article, we will discuss the steps that OSPF takes to determine the optimal path to each destination network and how you can manipulate some of the OSPF parameters to affect the overall behavior of the OSPF path selection process.

I recommend going through these posts to grasp the overall routing and OSPF concept.

What is Routing in Networking, and How does Routing work

What is a Routing table, explained with Show IP Route Command Cisco

Understanding Dynamic Routing Protocols Types

OSPF states Explained [with Infograhic]

OSPF Area Types – [Infographics]

What is the OSPF path selection process?

The Open Shortest Path First (OSPF) path selection process is a set of rules that determine the best path to use when multiple paths are available between two nodes in a network. The process considers factors such as path type, path cost, longest prefix match, etc.

OSPF Path Selection Process Explained

How many types of OSPF route entry OSPF has?

To understand the OSPF path selection process, we need to understand the different types of route entries in an OSPF routing table.

OSPF route entries are classified based on their destination type, which can be either “network” or “router.”

  • Network entries are the addresses of networks that packets can be routed to and are potential candidates for insertion into the routing table. This information can be seen using the command “show ip route OSPF.”
  • Router entries are routes to ABRs and ASBRs, which are kept in a separate internal OSPF router table. This information can be seen using the command “show ip OSPF border-routers.”

How does OSPF select the best route?

OSPF selects the best path to a destination based on the following criteria, and guess what? The OSPF cost is not the first criterion, but you might have guessed that.

OSPF Path Selection Process : 

  1. The longest match:- The longest match is always preferred inside Cisco and almost all vendor devices, no matter what.
  2. Most to least preferred path type : 
    • Intra-Area (O) –> Intra-area routes are local to an area and are always preferred the most.
    • Inter-Area (O IA) –> Then comes Inter-area routes, which are routes between two OSPF areas and within the OSPF AS (Autonomous system).
    • External Type 1 (E1) –> Then comes routes to external destination. E1 takes External costs + internal costs both into consideration.
    • NSSA Type 1 (N1) –> Then comes N1.
    • External Type 2 (E2) –> Then comes E2, which is also an external route to external destinations. Although, unlike E1, it only considers external costs to the destination. The default classification for OSPF external routes is E2.
    • NSSA Type 2 (N2) –> Then comes N2.
  3. Then comes the OSPF cost, and OSPF uses the lowest cost metric to decide the best routes, for example, between two O IA (Inter-Area routes), unless equal-cost paths exist. 

Let us look into the external routes (E1, N1, E2, and N2) in more depth and see how you can use them to manipulate the OSPF path selection process:-

  • The E1 and N1 metrics are both cumulative, meaning they consider the ASBR’s advertised cost and the internal OSPF cost to the ASBR. And that is the reason E1 and N1 are often called ‘metrics that increase hop-by-hop.
  • On the other hand, the E2 and N2 metrics are static, as advertised by ASBR. 
  • Use the E1 metrics when packets should exit the network at the closest exit point (within your OSPF AS).
  • Use the E2 metric when packets must exit the network at the closest point to the external destination (Outside your OSPF AS).
  • If two or more E2 routes have the same external cost, the internal cost is used as a deciding factor.

How are OSPF Costs calculated?

  • The OSPF metric is a 16-bit integer that ranges from 1 to 65535 and expresses cost.
  • Cisco’s default cost is 10^8 / BW of an interface in bits per second, expressed as a whole number. For example, an interface with a bandwidth of 100MB has a metric of 1 because 100000000/100000000 is 1. At the same time, an interface with a bandwidth of 10 Mb has a metric of 10.
  • BW is the configured bandwidth in kbps of the interface, and 10^8 is the reference bandwidth.
  • Nowadays, almost all modern media have bandwidths that exceed 100M, which creates a problem given the reference bandwidth of 10^8.
  • You can fix this by changing the default reference by using the “auto-cost reference-bandwidth” command. – Default Cost = Reference-BW/Interface-BW.

How can I modify OSPF Cost to influence OSPF path selection rules?

You can modify the OSPF cost with the following commands : 

  • Inside an Interface by using the command “bandwidth.” For example:- 

interface F0/1 

bandwidth 10000 kbps

Note: This will change the interface bandwidth in real-time, so make sure you use it wisely.

  • You can also straight change cost inside an Interface using the “ip OSPF cost” command. 

interface F0/1 

ip OSPF cost 10

Note: This command changes the outgoing interface cost for packets, not incoming.

  • You can even manipulate the reference bandwidth, which in turn will change the bandwidth and the cost of the interface. Use “auto-cost reference-bandwidth” inside the OSPF process to change it.

router OSPF 1

auto-cost reference-bandwidth 1000000000

  • Lastly, you can adjust the cost inside the OSPF process with the command “neighbor x.x.x.x cost.”

router OSPF 1

neighbor X.X.X.X priority 10 cost 1

Note: This command will only work on point-to-multipoint non-broadcast areas. 

How can the OSPF path computation process be improved?

You can use iSPF to improve OSPF path computation. OSPF is more efficient than the full SPF algorithm, allowing slightly faster convergence. This is because iSPF lets the system only recalculate the part of the SPF tree that has changed.

You can enable iSPF inside the OSPF process by:-

router OSPF 1

iSPF –> It enables iSPF.

Conclusion

In this article, we’ve looked at the OSPF path selection process and how you can change some parameters to change the OSPF paths to a destination network. We have also looked into how to use iSPF to improve OSPF path computation.

Thanks for reading till the end!

Copy AI is one of those AI writing tools that I trust and use extensively in all my writing endeavors.

Use the code BFCM40 to receive a 40% lifetime discount on all of their plans (offer valid until November 30th).

Afroz Ahmad
Afroz Ahmad

My name is Afroz. I am a CCIE, and I have been working in Networking Industry for more than 14 years. Currently, I work as a Network Designer for a large Organization. I write about technical topics and challenges a Network engineer faces in day-to-day life in my blog. I love to teach people, and I believe in the simple concept that teaching makes you a better learner.

Articles: 70

Leave a Reply

Your email address will not be published. Required fields are marked *