How OSPF Routers Build Adjacency Explained

Adjacency is a relationship that allows OSPF routers to share routing information. OSPF routers go through seven steps to reach the adjacency. This tutorial explains these steps in detail.

Unlike other routing protocols, an OSPF router does not share routing information with all connected routers. It shares routing information only with adjacent neighbor routers. On an OSPF network, two routers first become neighbors. Only neighbors become adjacent. The entire process goes through the following seven states.

  1. Down state
  2. Init state
  3. Two ways state
  4. Exstart state
  5. Exchange state
  6. Loading state
  7. Full state

Routers use the first three states to become neighbors and the last four to become adjacent. Let us understand these states in detail.

Down state

In the down state, a router knows nothing about its neighbors. An OSPF process always starts with the down state. In this state, it selects the OSPF RID. An OSPF RID is a unique identity of a router on the OSPF network. Routers use it to identify each other. It is a 32-bit numeric ID. It has the same format an IP address uses in decimal notation.

A router checks the value of the following three options in the sequence to select the RID.
  1. The value of the router-id command
  2. The ip address of an active loopback interface
  3. The ip address of an active interface

If it finds the value of an option, it does not check the value of the next option.

After selecting the RID, the router sends Hello packets from all active interfaces and waits for a response from other OSPF routers. It uses the Hello protocol to send Hello packets. A Hello packet includes all the parameters other OSPF routers need to determine whether they will form neighborship with the sender router.

It uses OSPF multicast address to send Hello packets. It sends Hello Packets at a regular interval. The interval is called the Hello interval. It also listens to OSPF multicast address to receive Hello packets from other OSPF routers.

ospf neighbor state down

Init state

A router enters this state when it receives a Hello packet from a router not available in its neighbor list. The router matches the received Hello packet's parameters with the locally configured parameters. If the required parameters for the neighborship match, it adds the sender router to the neighbor list. After adding the sender router to the neighbor list, it replies with its Hello Packet. The Hello Packet contains the sender's RID in the neighbor list field.

ospf neighbor state init

Two way State

A router enters this state when it receives a reply from a router not available in its neighbor list. This message tells the router that another router that has added this router to the neighbor list exists on the network. If this router is willing to build the neighborship, it can reply with another Hello packet. If the router sends a reply Hello packet, both routers enter the Two-way state.

If two routers reach a 2-way state with each other, it means both routers meet all OSPF configuration requirements to become neighbors. Effectively, at that point, they are neighbors and ready to exchange their routing information.

ospf neighbor state two way

Exstart state

How they will share routing information depends on the network type. In a broadcast multi-access network, they share routing information through the DR and BDR. In a point-to-point network, they directly share routing information.

In a broadcast multi-access network, at this point, an election process takes place to elect the designated router (DR) and the backup designated router (BDR) on the segment. Routers select a DR and a BDR for every segment. Apart from the DR and BDR, all other routers in the segment are known as DROTHERs. The only exception of a segment not having a DR and BDR is on a WAN point-to-point link.

ospf dr and bdr

In each segment, routers form adjacencies only with the DR and BDR. An OSPF router talks to a DR using the IP multicast address The DR and the BDR talk to all OSPF routers using the multicast IP address.

In each adjacency, every router compares its RID with the RID of the DR. If it has a higher RID, it becomes the master. If it has a lower RID, it becomes the slave. Master starts the exchange process. The remaining router in the adjacency will be the slave.

start exchange process

Note that the DR is not necessarily the master of the exchange process. The router having the higher RID will be the master of the exchange process.

Exchange state

After finalizing their roles in the exchange process, they share a list of LSAs in their databases. An LSA is a small portion of a database. It contains information only about a specific link. Each LSA has a unique ID.

Routers use it to check which LSAs they already have and then ask the other router for only the LSAs they do not have.

exchange state

Let us take an example.

Master sends a list of LSAs in its database to the slave. The list contains information about ten LSAs. The slave checks its database and finds four of those LSAs. So, it will ask only for six LSAs using a Link-State Request packet. Similarly, the master compares the list it receives from the slave and requests for the LSAs it does not have in its database.

Loading state

In the loading state, the master and slave provide the requested LSAs and incorporate the received LSA in their database. Then, they send an acknowledgment LSA to update each other.

ospf neighbor loading state

Full state

Master and slave will repeat the exchange and loading states until they have an identical database. Once the master and the slave are synchronized, you can consider them the Full state.

ospf neighbor full state

That's all for this tutorial. In this tutorial, we learned the OSPF states: Down State, Init State, Two Ways State, Exstart State, Exchange State, Loading State, and Full State.

ComputerNetworkingNotes CCNA Study Guide How OSPF Routers Build Adjacency Explained