# OSPF Route Selection Process

Pls can anyone confirm that OSPF does really use the following alogorithm for route calculation:

1. Intra-Area
2. Inter-Area
3. Type-1
• if costs are equal then E1>N1
• If costs are not equal, the lowest cost where cost for Type-1 External Routes=(Redistribution seed metric + OSPF internal Cost)
4. Type-2
• If costs are equal then E2>N2
• If costs are not equal then lowest cost where External Type 2 cost is Redistribution seed metric + Forward Metric to ASBR(Intra-Area first otherwise Inter-Area)

Pls correct me if i am wrong.

Waiting eagerly fro your kind replies.[:)]

Regards.

• Pls can anyone confirm that OSPF does really use the following alogorithm for route calculation:

Well, rather than route calculation i would say for path selection

However to be precise, since there is a range of exceptions in the list you specified above, i would say :

1) Intra-area and Inter-area types are always preferred over external path types.

2) Type 1 external paths are preferred over Type 2 external

Then after this you should study when the exceptions occur to better understand when there is a tiebreaker for example in a particular scenario what it will happen to the topology and how OSPF reacts in function of the results.

• Dear pagllo;

As a general algorithm....like BGP Path Selection......is this list correct...?

PS: i have implmented this, and then formed this algorithm....[:)]

Regards.

• Intra-Area
Inter-Area
Type-1
• if costs are equal then E1>N1
• If costs are not equal, the lowest cost where cost for Type-1 External Routes=(Redistribution seed metric + OSPF internal Cost)
Type-2
• If costs are equal then E2>N2
• If costs are not equal then lowest cost where External Type 2 cost is Redistribution seed metric + Forward Metric to ASBR(Intra-Area first otherwise Inter-Area)

As a general list we can say that the first two points are correct.

The second two are not correct.

For type-1 and type-2 since now the new IOS images support compatibility with RFC 3101, the paths with the P-bit set are always preferred over the paths without P-bit set. Although you could revert this behavior manually the default states that N1 and N2 are preferred over E1 and E2 if total cost or external cost + forwarding metric are the same (type-1 or type-2). For not equal costs but for identical metric type the lowest path cost is preferred. However as i said before there are always exceptions to consider in this list.

• Dear pgallo;

P bit only comes into play if the ASBR redistributed into an NSSA and P bit is only used for Type-7/Type-5 Translation......Plus Brian mentions in CCIE Written v5 Course that E1>N1 and E2>N2 as per RFC......

plus paths with/without P-bit depends on:

"When an NSSA border router originates both a Type-5 LSA and a Type-7

`   LSA for the same network, then the P-bit must be clear in the Type-7   LSA so that it isn't translated into a Type-5 LSA by another NSSA   border router.  If the border router only originates a Type-7 LSA, it   may set the P-bit so that the network may be aggregated/propagated   during Type-7 translation."........RFC 3101 Section 2.4`

The point which you are mentioning for P bit preference is:

"Preference

`   between two Type-7 LSAs is determined by the following tie breaker   rules:      1. An LSA with the P-bit set is preferred over one with the P-bit         clear.      2. If the P-bit settings are the same, the LSA with the higher         router ID is preferred.`
`"....RFC 3101 Section 2.4.....`

`Which is just between Type-7 LSA which is NSSA LSA......thus no comparison between Type-5 (E2) vs Type-7 (N2) according to RFC 3101....`

Actually i will implemneting this in Junos OS thus want to ask according to RFC, not specific to IOS routers...

Regards.

• Hi,

first of all according to old releases of IOS the RFC1587 was the one in place that referenced this kind of behavior so probably if you tested this with old IOS code 12.x for example the result would be like the one you specified.

So this practically means that E1 is preferred over N1 assuming that all of the other cost parameters are still equal.

With new trains of code, RFC3101 is in place by default. So the behavior has changed unless you don't need to revert this manually. So this is still possible to do.

Then if you are testing this with Junos probably i think is better to post in the related section because this is a CCIE Routing & Switching technical section.

I honestly don't know how JunOS works but i can confirm to you that IOS respects the RFC since i tested this several times.

• ✭✭

I think based on what I understood from ATC Videos, OSPF is one of exceptional Routing protocol in such that it checks LSA Types first before considring the cost. another words, Cost or OSPF metric does not matter when we have different LSA Types.

in that case, Intra-area LSA has preferance over Inter-area LSA. E1 has preferance over N1. E2 has preferance over N2.

In other routing protocols like EIGRP,  Metric or shortest path comes first in comparison.

Thank you

• Hi,

The only certain rules for OSPF path selection process are, as also Pietro stated:

1) Intra-area and Inter-area types are always preferred over external path types.

2) Type 1 external paths are always preferred over Type 2 external.

Also, with Cisco, OSPF path selection is per the RFC's (cause there are couple of RFC's with OSPF).

1. Is intra-area always preferred over intera-area? In most cases yes, exception being when a non-area 0 also becomes transit (as a result of a virtual-link built through that area).

2. Is E1 always preferred over N1, or E2 always preferred over N2 (assuming cost for E1/N1 is the same and cost plus forwarding metric is the same for E2/N2)? It depends if the router is conform with old or new NSSA RFC, for the new NSSA RFC it also depends on the P-bit being set or not.

I could outline here the complete set of rules, BUT remember that you'll get nowhere by memorizing a set of rules, you need to understand the reasoning behind it (by reading and practicing a lot) and at that point that set of rules just makes sense and you own it, you can recreate it at any point in time NOT from memory, but by following a logical thinking process. Same goes for any technology that you learn. And i can't explain in a forum (it will be pages of examples and explanations) the reasoning of the actual complete algorithm for path selection.

Regards,

Cristian.

• Dear Christian Matei;