Network LAN Cable

Networking Basics – Stepping into OSPF

Here are my notes on OSPF.

Open Shortest Path First (OSPF) is an IGP protocol. It is an example of a link-state routing protocol. Specifically, the name of the algorithm used in OSPF is Dijkstra’s Algorithm. The primary way of functioning of a Link State Protocol (and hence OSPF), is exchanging the topology information using the link-states. The link-state implies that we include information about the link as well as the current state of the link. All the link states together form the Link State Database (LSDB).

The steps into enabling and running OSPF in a network are as follows:

  • Identify the OSPF routers by marking each of them with a unique router-id.
  • Establish adjacency and neighbor relations between the router in the network.
  • Exchange the link-state database so that each router can calculate the shortest path to each link using the SPF algorithm.
  • An update is triggered when an addition of a new link or a change in topology occurs. If no changes occur, then the link information is refreshed after 30 mins to ensure that the database state is accurate and current.

Assigning the Router ID

The router-id is used to identify the router. It is of the 4 byte IP address format A.B.C.D. It is not an address that needs to be reachable using the routing table. The ID can be explicitly mentioned or can be derived from the existing IP addresses on the router.

The sequence to be used is –

  1. If an explicit router-id is mentioned, then this id is preferred. Usually, the command is router-id \<A.B.C.D>.
  2. If no router-id is mentioned explicitly, then use the highest IP address from the available up and running loopback interfaces.
  3. If no loopback interfaces are present, then use the highest IP address from the available up and running physical interfaces.

A router-id once configured (or derived), doesn't change till the OSPF process is refreshed in the router. If a router-id changes, then all routers in the network need to rerun their SPF calculations.

Router-ids are used to identify the routers, and they are also used in many other steps during the setting up of OSPF adjacency.

OSPF Messages

OSPF is a pure Layer 3 routing protocol, and the messages are encapsulated directly into IP packets. The IP protocol number for OSPF is 89.

Every step in OSPF be it the establishment of neighbor relationships, exchanging of the link-state database and establishing the complete adjacency, is done with the help of OSPF messages (or packets). A term used to describe all link-state packets is Link State Advertisements (LSA).

There are 5 different types of OSPF messages –

  1. Hello Packets – Used for finding neighbors, establishing neighbor relationships, and checking the liveliness and availability of the neighbor.
  2. Database Description (DBD) Packets – Used to exchange the LSA headers so that a router creates a list of LSAs that it needs from a neighbor.
  3. Link-State Request (LSR) Packets – These packets contains a list of one or more LSAs which the router requires from its neighbors.
  4. Link-State Update (LSU) – These packets the complete LSAs. These are sent usually in response to an LSR message.
  5. Link-State Acknowledgement (LSAck) – These packets are sent to confirm receipt of an LSU message.

States of an OSPF Router

  1. Init – As soon as OSPF is enabled on a router, the Init state is achieved.
  2. 2-Way – An OSPF router transitions to 2-Way state once the bi-directional hello exchange has been done per router. DR and BDR election is done during this state if required.
  3. ExStart – During this state, a Master-Slave relationship is achieved between each neighbor. This is based on the Router IDs of the neighbors.
  4. Exchange – During this state, DBD packets are exchanged between the neighbors and the routers create LSRs.
  5. Loading – The actual exchange of the LSAs occur during this state using LSRs, LSUs, and LSAcks.
  6. Full – Once all LSAs have been exchanged, the router transitions to Full State.
Featured Image courtesy Jordan Harrison at Unsplash