What is OSPF (Open Shortest Path First)? How does it works? What are Areas and LSAs?

Muhammad Haris Maqsood
9 min readMay 14, 2023

--

WHAT IS OSPF AND HOW DOES IT WORK?

OSPF is a Link State Protocol that is considered may be the most famous protocol among the Interior Gateway Protocol (IGP) family, developed in the mid 1980’s by the OSPF working group of the IETF.

When configured, OSPF will listen to neighbors and gather all link state data available to build a topology map of all available paths in its network and then save the information in its topology database, also known as its Link-State Database (LSDB). Using the information from its topology database, it will calculate the best shortest path to each reachable subnet/network using an algorithm called Shortest Path First (SFP). OSPF will then construct three tables to store the following information:

  • Neighbor Table: Contains all discovered OSPF neighbors with whom routing information will be interchanged
  • Topology Table: Contains the entire road map of the network with all available OSPF routers and calculated best and alternative paths.
  • Routing Table: Contain the current working best paths that will be used to forward data traffic between neighbors.

UNDERSTANDING OSPF AREAS

OSPF offers a very distinguishable feature named: Routing Areas. It means dividing routers inside a single autonomous system running OSPF, into areas where each area consists of a group of connected routers.

The idea of dividing the OSPF network into areas is to simplify administration and optimize available resources. Resource optimization is especially important for large enterprise networks with a plethora of network and links. Having many routers exchange the link state database could flood the network and reduce its efficiency — this was the need that led to the creation of concept Areas.

Areas are a logical collection of routers that carry the same Area ID or number inside of an OSPF network, the OSPF network itself can contain multiple areas, the first and main Area is called the backbone area “Area 0”, all other areas must connect to Area 0 as shown in the diagram below:

All routers within the same Area have the same topology table -Link State Database- but different routing table as OSPF calculates different best paths for each router depending on its location within the network topology while they will all share the same Link State topology.

The goal of having an Area is to localize the network as follow:

· The Area boundaries will give the opportunity of using summarization, as it’s not possible to summarize network prefixes in normal link state protocols because routers are supposed to have the same map topology of the entire network coincide in all neighbors.

· Area boundaries will also help preventing fault containment by suppressing updates that take place when a change occurs in the network causing a flood of updates between routers. This also happens to be a weakness of link state protocols: When connecting large sized networks, it is very difficult to avoid link state database floods.

OSPF LINK STATE PACKET TYPES

OSPF routers generate packets of information that are exchanged with neighboring routers. These packets are designed for several purposes such as forming neighbor relations between routers, calculating cost and best path for a specific route and more.

The following is a list of the most frequently used OSPF packets:

  • Link State Advertisement (LSA): The primary mean of communication between OSPF routers, it’s the packet that carries all fundamental information about the topology and is flooded between areas to perform different functions.
  • Link State Database (LSDB): LSDB packet contains all updated link-state information exchanged among the network, and all routers within the same area have identical LSDB, and when two routers form new neighbor adjacency, they sync their LSDB to be fully adjacent.
  • Link State Request (LSR): Once neighbor adjacency is formed and LSDB is exchanged, neighbor routers may locate a missing LSDB information, they then send a request packet to claim the missing piece, neighbors receive this packet and respond with LSU.
  • Link State Update (LSU): A response packet sends a specific piece of LSDB information requested by an OSPF neighbor via LSR packet.
  • Link State Acknowledgment (LSAcK): The router that sends the LSR packet confirms receiving the LSU from neighbor by sending a confirmation packet acknowledging receiving the requested LSUs.

WORKING INSIDE OF A SINGLE AREA

Working inside of an Area is hierarchically organized among routers that share this area and are categorized as:

Area Border Router (ABR):

Routers located on the borders of each Area connect to more than one OSPF area from which one is area 0, are called ABR Routers. ABR Routers are responsible for summarizing IP addresses of each area and suppressing updates among areas to prevent fault containment.

Autonomous System Boundary Router (ASBR):

An ASBR is a router that has interfaces connected to one or more OSPF areas, similarly as the ABR, however the difference with an ASBR is that it also connects to other routing systems such as BGP, EIGRP, Internet and others. An ASBR router normally advertises routes from other routing systems into the OSPF area to which it belongs.

Designated Router (DR):

A Designated Router is elected by the routers on multi-access segments (e.g. Local Area Network), based on its priority (Router ID, priority). The DR router performs special functions such as generating Link State Advertisements (LSAs) and exchanging information with all other routers in the same Area. Every router in the same Area will create an adjacency with the DR and BDR.

The DR sends updates to all Area routers using the Multicast address 224.0.0.5. All OSPF routers except the DR use Multicast address 224.0.0.6 to send Link State Update (LSU) and Link State Advertisements (LSAs) packets to the DR.

Backup Designated Router (BDR):

The BDR is a router that becomes the DR should the existing DR fail. The BDR has the second highest priority (the DR having the highest priority) in the OSPF network. When the BDR becomes a DR, a new election is made to find a new BDR.

OSPF NEIGHBOR STATES

When OSPF forms adjacency with neighbors, the connection goes through several states before the routers are fully adjacent with each other, this section describes each state in detail. Following are the OSPF States we’ll be examining:

LSA TYPES

Before we begin, let’s take a quick look at the different type of OSPF LSA packets we’ll cover:

  • LSA Type 1: OSPF Router LSA
  • LSA Type 2: OSPF Network LSA
  • LSA Type 3: OSPF Summary LSA
  • LSA Type 4: OSPF ASBR Summary LSA
  • LSA Type 5: OSPF ASBR External LSA
  • LSA Type 6: OSPF Group Membership LSA
  • LSA Type 7: OSPF Not So Stubby Area (NSSA) External LSA
  • LSA Type 8: OSPF External Attributes LSA (OSPFv2) / Link Local LSA (OSPFv3)
  • LSA Type 9: OSPF Link Scope Opaque (OSPFv2) / Intra Area Prefix LSA (OSPFv3)
  • LSA Type 10: OSPF Area Scope Opaque LSA
  • LSA Type 11: OSPF AS (Autonomous System) Scope Opaque LSA

The LSA payload varies in size according to the LSA type and the information it includes. The diagram below clearly shows how LSAs are contained within LSUs:

LINK STATE ADVERTISEMENT (LSA) PACKET STRUCTURE (WITHIN A LINK STATE UPDATE — LSU)

Each LSA packet consists of a header and a body that contains all the information needed to exchange network information within an OSPF network. The diagram below shows the structure of an OSPF LSA packet:

The LSA header is a 20 byte (32x5 = 160 bits) section that consists of the following fields:

  • LS Age (2 Bytes): Time passed since the LSA was generated (in seconds).
  • Options (1 Byte): Indicates the OSPF features and options the origin can support.
  • LS Type (1 Byte): Defines the LSA type (all types will be explained later).
  • Link State ID (4 Bytes): Identifies the network link between OSPF routers (usually IP address).
  • Advertising Router (4 Bytes): Indicates the origin router’s ID.
  • LS Sequence Number (4 Bytes): A specific digit on each LSA packet to filter old and repeated
  • LS Checksum (2 Bytes): A certain digit given to LS to compare and detect errors.
  • Length (2 Bytes): Represents LSA packet length.

LSA Type 1 (Router LSA):

  • LSA Type 1 flooded by new router in that particular area.
  • Describes the cost of the links of router to the area.
  • It never crosses the area in flood in that area only.

LSA Type 2 (Network LSA):

  • LSA Type 2 generate in a broadcast multi access (BMA) network.
  • Only DR originates this LSA.
  • LSA Type 2 also flooded on multicast IP of 224.0.0.5 in that particular area.
  • Describes all the routers attached to the network.
  • It never crosses the area in flood in that area only.

LSA Type 3 (Summary LSA):

  • LSA Type 3 generated by ABR Router.
  • Describes information (Inter-Area Routes) about particular area.
  • Flooded to the single area.

LSA Type 4 (Summary LSA):

  • LSA Type 4 also generated by ABR Router and if it is the IP address or router ID of ASBR then it is LSA 4.
  • Flood information about ASBR (Router ID or IP address of ASBR).

LSA Type 5 (External LSA):

  • LSA Type 5 generated by ASBR.
  • Describes information of external routes to the AS.
  • Two types of external LSA.
  1. E1 = Total cost to the external destination.
  2. E2 = Cost of outgoing interface to the external destination.

LSA Type 7 (NSSA External LSA):

  • LSA Type 7 also generated by ASBR.
  • Function is same as Type 5 to describe information about external routes, but in a NSSA (Not So Stubby Area).
  • In NSSA, area will be stub and we can also place ASBR.

Summary:

OSPF Special Areas

Stub Area:

  • OSPF Stub Area is that area in which LSA Type 5 cannot enter.
  • It is RFC Compliant.
  • All routers in stub area must be configured as Stub Area.
  • A default route is generated with LSA Type 3 instead of external routes.
  • ASBR cannot place in Stub Area.
  • Area 0 cannot configure as a stub (i.e. Backbone Area can never be a stub).

Configuration:

R1(config)#router ospf 1
R1(config-router)#area 2 stub

R7(config)#router ospf 1
R7(config-router)#area 2 stub

R6(config)#router ospf 1
R6(config-router)#area 2 stub

Totally Stub Area:

  • OSPF Totally Stub Area is that area in which LSA Type 5(external LSA) and LSA Type 3 (generated by ABR) cannot enter.
  • It is Cisco Propriety.
  • ABR is configured as Totally Stubby Area.
  • A default route is generated instead of external routes and summary routes.
  • ASBR cannot place in Totally Stubby Area.

Configurations:

R1(config)# router ospf 1
R1(config-router)# area 2 stub no-summary

Not-So-Stubby Area:

  • OSPF Not-So-Stubby Area is same as Stub Area but we can also place ASBR in it.
  • LSA Type 7 is generated by ASBR for advertising external routes.
  • Then ABR converts this LSA Type 7 into LSA Type 5 for backbone area.
  • It is RFC Compliant.
  • We need to insert default route manually in NSSA by using following configuration.

Configurations:

R1(config)# router ospf 1
R1(config-router)# area 2 nssa
R1(config-router)#area 2 nssa default-information-originate

R7(config)# router ospf 1
R7(config-router)# area 2 nssa

R6(config)# router ospf 1
R6(config-router)# area 2 nssa

Summary:

Note: Like, share and follow, if you like this article 😃

--

--

Muhammad Haris Maqsood
Muhammad Haris Maqsood

No responses yet