OSPF Path Selection explained

Hello Sergei

Generally, the questions will be asked so that you have all the information you need to answer them correctly. If such a question comes up, you will be told which IOS is being used. Most of the updated content will focus on version 15.X IOS unless it is explicitly stated, so if you do come across something like this you can assume 15.X.

I hope this has been helpful!

Laz

1 Like

What is the significant difference between ospf and isis as both are link state routing protocols but it is usually said that ISIS is more scalable as compared to OSPF…Why is it said that ISIS is highly scalable as compared to OSPF??

Hello Swapnil

Both IS-IS and OSPF are link state protocols, and both use the same Dijkstra algorithm to compute the best path through the network. However, they do have a few differences in their architecture. You can read more about the differences here:


Specifically concerning scalability, IS-IS does not use as much bandwidth to function as OSPF and its algorithm is less CPU and memory intensive. As stated in the above link, “Given the same set of resources, IS-IS can support more routers in an area than OSPF.” This can be due in part to the fact that IS-IS doesn’t require a backbone area such as Area 0 like OSPF does, in the fact that IS-IS strictly functions at Layer 2, and that it has fewer extensions and optional features than OSPF.

I hope this has been helpful!

Laz

Hi,
What is metric type 1 and 2 here

redistribute connected subnets metric-type 1
redistribute connected subnets metric-type 2 

Thanks

Hello Sims

When configuring the redistribution of OSPF, the metric-type 1 keyword and value indicates that the redistributed path should be marked as External Type 1 (E1) while metric-type 2 indicates that the redistributed path should be marked External Type 2 (E2). These path types are further described in the lesson.

I hope this has been helpful!

Laz

Hi,
ospf metric and cost are same ?
Thanks

Sims,

Metric is used by routing protocols to determine the best path to reach a destination network.

  1. RIP uses hop count as its metric
  2. EIGRP uses bandwidth, load, delay, reliability, and MTU as its metric
  3. OSPF uses cost as its metric
  4. BGP uses a set of attributes as its metric

Regards,

1 Like

Hello Sims

sales2161 has got it. Keep in mind however, that these terms are often used interchangeably by professionals. We often say “how much a particular path costs” or “what the metric of a particular path is”. In general, the term metric is more official and refers to the value used to evaluate how good a particular path is. The unit of the metric depends on the protocol. While cost is used more casually to refer to the same thing, but can be used more casually.

I hope this has been helpful!

Laz

1 Like

hello rene
we have learned that we select the best path on the basis of cost but you are telling ospf first check the prefered path list then cost
so this scenerio apply only then when we have a same desination with multiple areas whether it is from O ,OIA,E1,N1,E2,N2 but this condition apply only for same destination like : I want to reach 1.1.1.1/32 network and i have multiple paths to reach it but where is cost because if we are changing cost it doesn’t affect for path selection so why we use cost . so what will be the purpose of using the cost ? PLEASE EXPLAIN IT

Hello Harshit

For the same destination, if you have multiple routes with varying types of routes, meaning O, OIA, EI, N1, E2, or N2, then this designation is checked first.

So let’s say you have a destination of 1.1.1.1/32 as you say, and OSPF provides us with the following alternatives:

An O route via 2.2.2.2
An OIA route via 3.3.3.3
An E2 route via 4.4.4.4

then the route that will be placed within the routing table is the first, REGARDLESS of what the cost of each route is.

This is because OSPF considers a route learned via its own area as the most reliable, and this is indeed the case. You don’t want to route a packet that seems to exist in your own area via another area, even if the cost is less.

I hope this has been helpful!

Laz

HI,
What is E1 and E2 routes ,

Thanks

Hello Sims

Take a look at this post which explains what the E1 and E2 routes are.

I hope this has been helpful!

Laz

Regarding these two commands to manipulate metrics in order to force OSPF prefer one path over the otherwise equal path to the same destination:
If I have router 1 with two interfaces connected to routers 2 and 3 and both routers 2 and 3 advertise the same network and I want the path to router 2 be a ‘primary’ path so I can use:

  1. ip ospf cost xxx command. I would need to apply it on router 1 interface to router 2 and also on router 2 interface to router 1. If I only apply it to one router, say router 1 interface to router 2, then which direction will be affected? Will traffic from router 1 be sent to router 2, with possibly return traffic coming back from either router 2 or 3? Or another way around - outbound traffic from router 1 will be load balanced between routers 2 and 3? In other words, applying ip ospf cost command on router interface will force router to consider path out of the interface as less preferable or it only tells its neighbor that ‘path to me is a higher cost for you’ ?

  2. Similar with ‘neigbor xxxx cost zzz’ command - does it affect local router to consider cost to neighbor higher or tells the neigbour that it needs to consider this path as most costly? And to avoid assymetric routing should this command be applied to both neighbors, as well?

Hello Vadim

All commands that are used to manipulate the routing of OSPF will only affect outbound traffic from the local router. For this reason, you should apply similar commands on the other end so that routing will be symmetric. Remember that you can only affect traffic that is outgoing. You can’t adjust what your neighbor sends to you, you are required to take it as it comes. But you can adjust what you send, and that’s what these commands do.

I hope this has been helpful!

Laz

Thanks, that makes sense. I was just confused because earlier (in the article or one of the questions on this forum) it seems to force router A send traffic to router B (instead of to router C) the command IP OSPF COST xxx was offered to be applied to interface on router B. Seems it must be an honest mistake as it wont make then a difference to router A, only to traffic sent from B to A.

HI,
" After the path selection it will look at the lowest cost path. To give a quick example…when Prefix “X” is learned as an intra-area route (O) and as an inter-area route (O IA) then OSPF will always select the intra-area route, even if the inter-area route has a lower cost"

Can you explain a scenario inter-area route has lower cost than intra area route

Thanks

Hello Sims

This is a somewhat exaggerated example, but it’s there to make the point. Take a look at the following OSPF topology:


The user is attempting to communicate with a host on the 1.1.1.0/24 subnet. The packet reaches R1. Now R1 has an intra-area path to this network via the six routers that connect to it. However, it also has an inter-area path via Area 1 that actually has a smaller metric. R1 will still choose to send the packet via the intra-area path rather than the inter-area path.

The whole logic behind this is that a correctly designed OSPF network should always prefer intra-area paths because they are more efficient, and they avoid the crossing of area borders. Needless to say, the above topology is an example of bad network design. Traffic across area borders should be used only when required. This “rule” keeps traffic within an area whenever possible, even if the metric is lower for an inter-area path.

I hope this has been helpful!

Laz

1 Like

Hi ,

I want load balance my icmp traffic over ospf on attached topology , so that number of icmp req/res should be shared equaly on GigabitEthernet1/0 and GigabitEthernet2/0 . i understand currently all icmp traffic(50 req and 50 res packets) getting forwarded/received through the link R1-R2 as ospf taking lowest router id of 10.1.1.2(R2) compared 10.1.1.3(R3) . How to achieve loadbalace the traffic so that i can get 50 Req + Res on the link R1-R2 and similarly 50 Req + Res on R1-R3 ?

Sending traffic

R1#ping  200.200.200.200 source loopback 0 repeat 50

Type escape sequence to abort.
Sending 50, 100-byte ICMP Echos to 200.200.200.200, timeout is 2 seconds:
Packet sent with a source address of 100.100.100.100
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Success rate is 100 percent (50/50), round-trip min/avg/max = 48/63/80 ms
  1. i have tried with maximum-paths 2 on R1 , below is my observations :
    50 icmp reply packets on the link from R1-R2 . And 50 ICMP Request on the link R1-R3 (shown as no response found on wireshark capture)

  2. i have deleted maximum-paths 2 config and tried with command traffic-share min across-interfaces command --> 50 icmp Req and 50 responses through the link R1-R2 . (Same beha)

  3. I configured R1 and R6 maximum-paths 2, behaviour is the same as case 1 as above.

Below is the common config for R2,R3,R4 and R5 :

router ospf 100
 router-id 10.1.1.2
 log-adjacency-changes
 network 0.0.0.0 255.255.255.255 area 0
!

On R1 : Extra interface is interface loopback 0 --100.100.100.100

R1#sho ip ospf neighbor

Neighbor ID     Pri   State           Dead Time   Address         Interface
10.1.1.3          1   FULL/DR         00:00:33    192.168.13.3    GigabitEthernet2/0
10.1.1.2          1   FULL/DR         00:00:33    192.168.12.2    GigabitEthernet1/0

R1#sho ip route 200.200.200.200
Routing entry for 200.200.200.200/32
  Known via "ospf 100", distance 110, metric 4, type intra area
  Last update from 192.168.13.3 on GigabitEthernet2/0, 00:13:23 ago
  Routing Descriptor Blocks:
    192.168.13.3, from 10.1.1.6, 00:13:23 ago, via GigabitEthernet2/0
      Route metric is 4, traffic share count is 1
  * 192.168.12.2, from 10.1.1.6, 00:13:23 ago, via GigabitEthernet1/0
      Route metric is 4, traffic share count is 1

On R6 : Extra interface is interface loopback 0 --200.200.200.200

R6#sho ip ospf nei

Neighbor ID     Pri   State           Dead Time   Address         Interface
10.1.1.5          1   FULL/DR         00:00:36    192.168.56.5    GigabitEthernet2/0
10.1.1.4          1   FULL/DR         00:00:31    192.168.46.4    GigabitEthernet1/0

R6#sho ip route 100.100.100.100
Routing entry for 100.100.100.100/32
  Known via "ospf 100", distance 110, metric 4, type intra area
  Last update from 192.168.56.5 on GigabitEthernet2/0, 00:19:52 ago
  Routing Descriptor Blocks:
    192.168.56.5, from 10.1.1.1, 00:19:52 ago, via GigabitEthernet2/0
      Route metric is 4, traffic share count is 1
  * 192.168.46.4, from 10.1.1.1, 00:19:52 ago, via GigabitEthernet1/0
      Route metric is 4, traffic share count is 1

Hello Sameer

Here are a few things you need to know about OSPF and load balancing.

  1. OSPF will load balance only if two paths are of equal cost. OSPF will not perform unequal cost load balancing, so from the start, the two paths MUST have the same cost.
  2. OSPF by default will load balance a maximum of four equal cost paths. The maximum-paths command can change this to up to 16. In your topology, the maximum-paths changes you made will have no affect since you have only 2 paths.
  3. The router ID is never used to determine the path a packet will take. Only cost is used. The lowest router ID is used when electing a DR/BDR.
  4. The traffic-share min across-interfaces command will also not change any OSPF behaviour because this is the default behaviour of OSPF. The “across-interfaces” parameter will only kick in if the maximum paths limit is exceeded and more than one route shares the same outgoing interface, which is not the case in your topology.
  5. From the point of view of a specific router, load balancing will occur only for outgoing traffic. For your pings from R1, the load balancing (as far as the R1 configuration goes) can only affect outgoing traffic. This means that only the ICMP echo requests can be expected to be load balanced. The replies may or may not be load balanced depending on the configuration of the rest of the routers on the network.

In your topology, assuming everything is set to the default, there should indeed be two routes in the routing table of R1 to the 200.200.200.200 destination. From you output, we can see that this is indeed the case.

Now notice that one of the two “routing descriptor blocks” has an asterisk (*) beside it. This is the preferred route at that particular time. This asterisk should alternate between the routes based on the load balancing algorithm that is in place.

The algorithm determines how the load balancing is applied. Load balancing can take place either on a per packet, or per destination basis depending on what kind of switching (routing) is enabled. Specifically:

  • For process-switching—load balancing is on a per-packet basis and the asterisk (*) points to the interface over which the next packet is sent.
  • For fast-switching—load balancing is on a per-destination basis and the asterisk (*) points to the interface over which the next destination-based flow is sent.

By default, most Cisco devices have fast switching enabled, so load balancing is applied on a per destination basis. Now because your pings all have the same destination, the same path is being chosen, so load balancing does not occur for pings.

You can find out more information about this at the following Cisco documentation;

I hope this has been helpful!

Laz

1 Like

HI Rene/Laz,

Up on emulating the path preference lab I got to know that when there are multiple routers with duplicate router-id the ospf prefers OIA route over O route for the same prefix. Is this expected behavior or just another ios bug? Later when I manually configured the router-id to be different on each router and reloaded the ospf process it went back normal ie. O > OIA

Thanks and Regards,
Teja