Thursday, 14 June 2012

Understanding OSPF Neighbor Relationship

Understanding OSPF Neighbor Relationship

An OSPF router goes through several states before the neighbor is considered fully adjacent.

But, before going to the adjacent process, let’s understand some important terms in OSPF:


  • Router-ID simply means the name of this router in the OSPF domain.
  • Before an OSPF router can send any OSPF messages, it must choose a unique 32-bit identifier called the router identifier.
  • Cisco routers choose the following sequence to choose their Router-ID.
1.   If you configure Router-ID manually, it will be the Router-ID
2.   If the router-ID is not configured manually and the loopback interface exists, highest active Loopback address will be the Router-ID
3.   If Loopback interface doesn’t exists, then the highest active physical interface address.

Some important points to be noted about Router ID:
  • The Cisco OSPF will continue to use a RID learned from a physical interface even if the interface subsequently fails or deleted.
  • The RID does not have to reachable
  • The interface from which the RID is taken does not have to be matched by an OSPF network command
  • Routers consider changing the OSPF RID when the OSPF process is restarted or when the RID changed via the configuration.
  • If a RID changes, the rest of the routers in the same area need to perform a new SPF calculation.
  • If the RID is configured via Router-id command and the command remains unchanged, RID will never change for that router.
Hello Protocol:

The Hello protocol performs many functions:
  • Discover OSPF speaking neighbors
  • It advertises several parameters on which two routers must agree before they can become neighbors
  • Hello packets act as keepalives between the neighbors
  • OSPF speaking routers periodically send a Hello packet out each OSPF enabled interface. This period is called HelloInterval.
  •  In Cisco networks,
    • Hello messages sent once every 10Sec on Broadcast / P2P networks
    • Hello messages sent once every 30Sec on NBMA networks
Contents of Hello Packet:

  • Router-ID
  • Area ID *
  • Subnet Mask *
  • Hello Timer *
  • Dead Timer *
  • DR/BDR
  • Neighbors List
  • Priority
  • Authentication if any *
  • Stub flag
* Mandatory fields to be matched. If any of these parameters don’t match, the two routers don’t form a neighbor relationship.


  • In OSPF, each shared segment will have a DR and BDR, mainly to prevent the unnecessary flooding of the LSAs.
  • Without, DR/BDR, in any shared network, we should have n(n-1)/2 adjacencies.
  • Each router in a shared segment forms full adjacency with only DR and BDR.
  • There is no preemption in the DR/BDR elections.
  • DR/BDR elections are influenced by Priority and Router-ID.
    • Each OSPF interface has a priority value of 0-255.
    • In Cisco networks, default priority value is 1.
    • Routers with a priority of 0 are ineligible to become DR/BDR.
Election process for DR/BDR: (from Jeff Doyle TCP/IP Volume I)
  • After 2-way communication has been established with one or more neighbors, examine the priority, DR/BDR fields in a neighbor’s Hello packet.
  • List all the routers which are eligible for election, all routers declaring themselves to be the DR and all routers declaring themselves to be the BDR.
  • From this list of eligible routers make a subset of the routers, not claiming to be the DR (routers declaring themselves to be the DR cannot be elected BDR)
  • If one more neighbors in this subset include its own interface address in the BDR field, the neighbor with the highest priority becomes the BDR, in case of tie, highest Router ID will be chosen.
  • If no router in the subset claims to be the BDR, the neighbor with the highest priority becomes the BDR, in case of tie, highest Router ID will be chosen.
  • If one more of the eligible routers include their own address in the DR field, the neighbor with the highest priority becomes the DR, in case of tie, highest Router ID will be chosen.
  • If no router is claiming to be a DR, the newly elected BDR gets promoted to the DR.
  • When OSPF is discovering the neighbors, if a DR and BDR exist, the router accepts them. If there is no DR and BDR, then only elections will happen.
Different states in OSPF neighbor adjacency process:

  • Down State
  • Attempt
  • Init
  • 2-way
  • Exstart
  • Exchange
  • Loading
  • Full

This is the first OSPF neighbor state. It means that no Hello has been received from the neighbor.

This state is only valid for manually configured neighbors in an NBMA environment.

This state indicates that the router has received a hello packet from its neighbor, but the receiving router’s ID was not found in the Hello packet

This state indicates that the bi-directional communication has been established between the 2 neighbors.

Am I listed as your neighbor in your Hello packet?
Yes: reset the dead timer, and the Hello processing ends at this step.
No: Add as new neighbor
DR/BDR election occurs at the end of this stage.
In broadcast networks, DROTHERS will be always at 2-way state.
R1(config-router)#do show ip ospf nei
Neighbor ID Pri State Dead Time Address Interface2.2.2.2 1 2WAY/DROTHER 00:00:38 FastEthernet0/ 1 FULL/DR 00:00:39 FastEthernet0/0 1 FULL/BDR 00:00:32 FastEthernet0/0

R2(config-router)#do show ip ospf nei
Neighbor ID Pri State Dead Time Address Interface 1 2WAY/DROTHER 00:00:30 FastEthernet0/0 1 FULL/DR 00:00:37 FastEthernet0/0 1 FULL/BDR 00:00:31 FastEthernet0/0

R3(config-router)#do show ip ospf nei
Neighbor ID Pri State Dead Time Address Interface 1 FULL/DROTHER 00:00:38 FastEthernet0/0 1 FULL/DROTHER 00:00:35 FastEthernet0/0 1 FULL/BDR 00:00:39 FastEthernet0/0
In this state, the router and its neighbor establish a master/slave relationship and determine the initial DD sequence number in preparation for the exchange of Database Description (DBD) Packets.
The neighbor with the highest Router ID becomes the master.

In this state, OSPF router exchange DBD packets.
DBD packet contains the summary of the LSA headers.
DBDs are acknowledged and reviewed in this state.

Slave requests the details (LSR)
Master sends updates (LSU)
Master requests the details (LSR)
Slave sends updates (LSU)

In this state, routers are fully adjacent with each other and their database is synchronized.

It’s time to run the Dijkstra’s SPF algorithm!

No comments:

Post a Comment