Hello Everyone,
In this document, I am going to present how OSPF calculates metric for external routes.
I am using the following scenario for this presentation.
There are two ASBRs in area 1. 88.88.88.88 and 99.99.99.99 are loopback interfaces on R1 and R2 and redistributed via "Redistribute connected Subnet metric-type 1". R3 and R4 and R6 are ABRs in this scenario.
Lets see the routing table on R7
Metric for 88.88.88.88 is 24. 20+1+1+1+1
When you redistribute any routes to OSPF, the default metric will be 20 expect BGP which is 1. Metric to ASBR will be added to 20. In our case, metric to ASBR is 4(metric of each link is 1).
As you see in the picture, the OSPF route type is E1.
If metric-type 2 is used in redistribution command, the metric for E2 routes will be 20 it means you do not see the cost from the router to ASBR. If you check each route individually, the cost to ASBR will be appeared as Forward Metric.
When the metrics for two external E2 routes are equal, Forward metric is used to determine the best route. This is the concept of Hop Potato. Getting rid of packets through the closet ASBR.
When to use route type E2? when one ABSR is preferred over the other one so you redistributes routes into OSPF on the preferred ASBR with lower metric
When to use route type E1? While load sharing across the ASBRs
Lets talk about LSA type 5. LSA type 5 is domain wise. It means it traverses all the areas with no change. I should mention that LSA 5 can not be filtered expect on ASBR or through "distribute-list in" on the local router. For example, R6(ABR) can not prevent advertising of 99.99.99.99 to R7. If you want to filter 99.99.99.99 on R7, you need to apply "distribute-list in" on R7.
Let see the LSA type 5 on R7
The adverting routers are 172.16.1.1 and 172.16.1.2(R1 and R2). If you check LSA type 5 on any routers in the OSPF domain, you will see the same output.
Lets check it on R3
The output on R3 is similar to the output on R7. It means LSA type 5 traverses to all the areas with no change. But the metric is 20. We saw in the previous picture that the metric in the routing table was 24. Where that 4 came from? OSPF uses LSA type 4 and type 1 to calculate the metric to ASBR. Also LSA 4 is used to determine the path to ASBR. As you see in the picture that advertising router is 172.16.1.1 which is router ID of R1. in OSPF, router ID can be anything and it is not necessary to advertise it so RID is unknown in the areas other than area which ASBR exists (in the area with ASBR RID is known by LSA type 1). We can conclude that, LSA type 4 does not exist in area which ASBR resides but it is necessary for the other areas unless Forward Address is used but still you see the LSA type 4 in the other areas.
Lets see what LSA type 4 look likes on R7
LSA type 4 is area wise. It means each ABR regenerates the LSA type 4 after adding the metric to the latest ABR to the received metric. The metric is 3 and the advertising router is 172.16.1.6. But still one piece of puzzle is missing. The cost to ABR(172.16.1.6 from R7). Metric for 172.16.1.6 is 1 so the total metric is 20+3+1
Lets see LSA type 4 on R5.
As I said, LSA type 4 is area wise. As you see, the advertising routers are R3 and R4 and metric is 1. This is the cost from R3 and R4 to ASBR. When R6 receives this LSA, it adds its own costs to the advertising routers and regenerate a new LSA. In this case 1 + 2( see the previous picture)
2 is cost from R6 to R3.
There is no LSA type 4 on R3 in area 1 because it is unnecessary. RID of ASBR is know in area 1.
Lets see how LSA 4 is generated. There is misconception that LSA type 5 triggers the LSA type 4 but it is not true. LSA type 4 is triggered by E bit in ASBR LSA type 1 advertisement. Lets see that bit
In our case, R3 generate two LSAs type 4 because it receives LSA type 1 from R1 and R2. It is the same on R4.
R5 receives four LSA type 4.
R5 advertises these four LSAs to R6. R6 is an ABR. ABR only regenerates the LSA type 4 with the best metric so R6 only regenerates two LSA type 4.
Lets prove that E bit triggers the LSA type 4. We use redistribution command on R1 and R2 but we filter all the external routes on R1 and R2. It means R1 and R2 are ABSR but they do not redistribute anything. But, you can still see LSA type 4 on R4.
On R7, we do not see the routes for 99.99.99.99 ad 88.88.88.88 but still we see LSA type 4.
Point:
When you are redistribution routes from an interface which is in in OSPF domain, OSPF advertises Forward Address in LSA type 5. Routers uses this Forward Address for calculating the metric and finding the best path to ASBR so LSA type 4 will become unnecessary but still ABR generates LSA type 4 even though Forward Address is present in LSA type 5. The reason is that Forward Address can be suppressed on ABR.
To find more information, please check my other document in my home page(NSSA and Forward Address)
Please rate if this document is beneficial for you. Wish you the best.
Masoud