OSPF Adjacencies

OSPF creates adjacencies between neighboring routers for the purpose of exchanging routing information. Not every neighbor becomes adjacent in a broadcast environment. The Hello protocol is responsible for establishing and maintaining an adjacency.

Hello packets are sent periodically out all router functional interfaces. Two-way communication is established when the router is listed in the neighbor’s Hello packet. On broadcast and NBMA networks, Hello packets are used to elect the DR/BDR.

After the two-way communication is established, the decision is made whether to form an adjacency with this neighbor. This decision is based on the neighbor state and network type. If the network type is broadcast or nonbroadcast, the adjacency is formed only with the DR and BDR routers. In all other network types, the adjacency is formed between two neighbor routers.

The first step in forming the adjacency is synchronization of the database. Each router describes its link-state database in the DBD packet. Only the LSA headers are exchanged between neighbors. Master and slave election takes place during this database exchange. Each router makes a note of the LSA headers that it receives during this DBD exchange. At the end of the DBD exchange, it sends the LS request packet to request LSAs whose headers have been seen during the DBD exchange. The neighbor router then replies with the LS update packet listing the entire content of those LSAs. This LS update packet is then acknowledged by sending the link-state acknowledgment packet. At this point, all the databases are fully exchanged, and the neighbor goes into Full state.

State Description
Down Indicates that the router has not received any OSPF Hello packets.
Init A Hello packet has been received from another router, but bidirectional communication has not been established.
2-Way Bidirectional communication has been established.
If a DR/BDR is needed, the election occurs during this state.
ExStart This is the first state of forming an adjacency.
Routers identify which router will be the master or slave for the LSDB synchronization.
Exchange During this state, routers are exchanging LSAs via DBD packets.
Loading LSR packets are sent to the neighbor asking for the more recent LSAs that have been discovered (but not received) in the Exchange state.
Full Neighboring routers are fully adjacent.

INIT State

Init state is a one-way Hello. R1 sends a Hello packet. Upon receiving this Hello, R2 declares a one-way state because R2 doesn’t see itself (its router ID) in that Hello packet.

OSPF Hello Packet with No Neighbor Detected

2-Way State

An OSPF neighbor reaches the 2-way state when bidirectional communication is established. This is the beginning of an OSPF adjacency. The DR and BDR are elected in this state. R2 sends a Hello packet that says that R2 has seen R1’s Hello; the router ID of R2 is higher, so it has also elected itself as a DR.

R1 and R2 both verify that the following parameters match:

  • Authentication
  • Area ID
  • OSPF Hello and Dead timers
  • RIDs are unique
  • Ensures that the interface share a common subnet. OSPF uses the interface’s primary IP address when sending out OSPF Hellos.
  • MTU. The OSPF protocol does not support the fragmentation, so the MTU on the interfaces should match.
  • Need for DR on the segment.
  • Area Type flags.
OSPF Hello Packet with Neighbors Detected

Exstart State

This state is used for initialization of the database synchronization process. Master and slave are elected in this state. The first sequence number for DBD exchange is also decided in this state. R1 sends the first DBD packet. R2 also sends it first DBD packet. The router that has the highest router ID becomes the master. R2 has a higher router ID, so R2 is the master.


Exchange State

In the Exchange state, the router describes its entire LSDB through DBD packets. Each DBD sequence is explicitly acknowledged. Only one outstanding DBD packet is allowed at a time. Link-state request packets are also sent in this state to request a new instance of the LSA.  R1 and R2 are exchanging their database information. The last arrow shows that the M bit is set to 0. This means that the master has no more data to send. At this stage R1, the slave will send whatever database is left, and R1 will also set the M bit to 0. This is the indication that both routers have exchanged the complete database.

Loading State

In the Loading state, LS request packets are sent to request the more recent instance of an LSA that has not been received during the exchange process. R1 is in the Loading state and is sending LS request packets to receive a more recent instance of an LSA.


Full State

This state means that the complete information has been exchanged between OSPF neighbors. R1 and R2 have exchanged their entire database information and are in the Full state.


OSPF adjacencies go through several stages before they are formed. The last state of adjacency is Full, which means that a complete database has been exchanged from the neighbor. On broadcast media, adjacencies are formed only with the DR and the BDR. All other neighbor goes up to the 2-way state. This is to reduce the number of adjacencies so that there will be less flooding traffic on the segment.

					R1#debug ip ospf adj
OSPF adjacency events debugging is on
*21:10:01.735: OSPF: Build router LSA for area 0, router ID, seq
0x80000001, process 1
*21:10:09.203: OSPF: 2 Way Communication to on GigabitEthernet0/0, state
*21:10:39.855: OSPF: Rcv DBD from on GigabitEthernet0/0 seq 0x1823 opt
0x52 flag 0x7 len 32  mtu 1500 state 2WAY
*21:10:39.855: OSPF: Nbr state is 2WAY
*21:10:41.235: OSPF: end of Wait on interface GigabitEthernet0/0
*21:10:41.235: OSPF: DR/BDR election on GigabitEthernet0/0
*21:10:41.235: OSPF: Elect BDR
*21:10:41.235: OSPF: Elect DR
*21:10:41.235:        DR: (Id)   BDR: (Id)
*21:10:41.235: OSPF: GigabitEthernet0/0 Nbr Prepare dbase exchange
*21:10:41.235: OSPF: Send DBD to on GigabitEthernet0/0 seq 0xFA9 opt
0x52 flag 0x7 len 32
*21:10:44.735: OSPF: Rcv DBD from on GigabitEthernet0/0 seq 0x1823 opt
0x52 flag 0x7 len 32  mtu 1500 state EXSTART
*21:10:44.735: OSPF: NBR Negotiation Done. We are the SLAVE
*21:10:44.735: OSPF: GigabitEthernet0/0 Nbr Summary list built, size 1
*21:10:44.735: OSPF: Send DBD to on GigabitEthernet0/0 seq 0x1823 opt
0x52 flag 0x2 len 52
*21:10:44.743: OSPF: Rcv DBD from on GigabitEthernet0/0 seq 0x1824 opt
0x52 flag 0x1 len 52  mtu 1500 state EXCHANGE
*21:10:44.743: OSPF: Exchange Done with on GigabitEthernet0/0
*21:10:44.743: OSPF: Send LS REQ to length 12 LSA count 1
*21:10:44.743: OSPF: Send DBD to on GigabitEthernet0/0 seq 0x1824 opt
0x52 flag 0x0 len 32
*21:10:44.747: OSPF: Rcv LS UPD from on GigabitEthernet0/0 length 76 LSA
count 1
*21:10:44.747: OSPF: Synchronized with on GigabitEthernet0/0, state FULL
*21:10:44.747: %OSPF-5-ADJCHG: Process 1, Nbr on GigabitEthernet0/0 from
LOADING to FULL, Loading Done

Leave a Reply

Related Post

How OSPF works?How OSPF works?

OSPF sends to neighboring routers link-state advertisements (LSAs) that contain the link state and link metric. The received LSAs are stored in a local database called the link-state database (LSDB),