gurfin / ENCOR #4 – OSPF basics

Created Tue, 21 Jan 2025 08:00:00 +0100 Modified Wed, 22 Jan 2025 23:03:43 +0000
895 Words

Open Shortest Path First (OSPF) πŸ—ΊοΈ

Areas are a way to divide an OSPF domain into smaller, logical chunks, which allows for less resources to be used by the OSPF process. Each interface on an OSPF router can only be member of a single area, however, an OSPF router can have interfaces in multiple areas, thus becoming an Area Border Router (ABR). A unique LSDB will be created for each area that a router is a member of.

All routers inside an area will maintain an identical LSDB on each router, which details the structure of the entire area. Then, Dijkstra’s Shortest Path First (SPF, as in OSPF) is run to determine which path is the best resulting in a Shortest Path Tree (SPT). This is used to extract routes from the LSDB and inject into the Route Information Base (RIB). Each time an interface that partakes in the area flaps, all routers within the area must update their LSDBs and then run the SPT calculations again. The building an OSPF network the scale and sectioning of each area should take into consideration the hardware capabilities of the devices used.

Routing between areas βœ‹πŸ»

By default, routes are only injected from other areas into the backbone area (area 0). The backbone are then spreads the routes to the other areas. Therefor, all areas must connect back to area 0, in an OSPF network in order to allow routes to traverse between the different areas. Area 0 should be viewed as “the area connecting other areas together”. ABRs must have at least one interface in the backbone area, otherwise they will be unable to properly exchange routes.

Routes passing within the same area are called intra-area routes (shown as ‘O’ in the RIB), while those being passed between areas are called inter-area routes (shown as ‘O IA’ in the RIB).

When OSPF neighbors communicate they use LSA packets to announce which networks they have available. These packets are flooded out all active OSPF interfaces and allows for the assembling of a correct LSDB on every router in the area. There are 6 different types of LSA packets:

Type Name Description
1 Router LSA This advertises the routes originating from within the given area.
2 Network LSA The will advertise multi-access networks.
3 Summary LSA This, unlike type 1 LSA, will advertise the routes originating from without the given area.
4 ASBR summary LSA Will advertise summary LSAs but for a specific ASBR.
5 AS external LSA Announces LSAs for routes that originate from without the given OSPF process (not area, there is a difference).
7 NSSA external LSA This will advertise routes being redistributed in a NSSA.

The important information sent in an LSA is:

  • Type
    • This denotes which, of the above listed, LSA type the given packet is.
  • Age
    • This is used to prevent stale entries in the LSDB. The originating router (the router which originally advertises this network) will announce their LSA with an age of 0. Each router that installs the route in the LSDB will then increment this age with 1 every second. When the age reaches 1 800 seconds on the originating router it will rebroadcast the information with an age of 0. If a router does not receive a new LSA with the age set to 0 before 3 600 seconds has elapsed, then the route is purged from the LSDB.
  • *Advertising router
    • This is the router that the route originates from. The RID is most commonly used, except for in networks where there are DRs present, in that case inte interface IP of the DR is the identifying attribute of the advertising router.
  • Sequence number
    • Much like in TCP, this is used to combat the issues that arise when OSPF packets arrive out of order. The sequence number is in control of versioning, ensuring that the most up to date information is being input into the LSDB, regardless of in which order the packets arrive.
  • Link data
    • Usually the IP of an interface, used to describe it.

Type 1 - Router LSA

The router LSA is announced by every OSPF router. These routes are for intra-area traffic and will not traverse between areas on the ABR. Initially the type 1 LSAs are used to describe each router more generally - information like link count and link ID. The link count lists the number of interfaces in the OSPF process.

show ip ospf database router

output from show ip ospf database router

Type 2 - Network LSA

These are intra-area traffic, so not shared outside the area in which they originate. The network LSA is advertised by the elected DR in a multi-access network.

show ip ospf database network

output from show ip ospf database network

Type 3 - Summary LSA

These advertisements are used for inter-area routes, that is when routes are sent between areas. When an ABR receives a type 1 or type 2 LSA it will convert it to a type 3 LSA before sending it into other areas. Along with this it also rewrites the “advertising router” with its own RID - much like the “next-hop-self” option in BGP. The behavior is what allows each area to obfuscate the adjacent areas.

When a route traverses multiple areas the metric is added in the type 3 LSAs, in order to still maintain a valid rating of the “usefullness” of a given route.

show ip ospf database summary