In this post, we will discuss the components involved with OSPF Neighbor Relationships. This is not a configuration guide but should be used as a reference for various OSPF states and concepts that the OSPF protocol goes through to establish connections to its neighbors.
- Determine your own Router ID. The router ID identifies the router and acts as its “name” when forming a neighbor relationship. This is typically decided by a loopback interface (which takes precedence over physical interfaces). This can be hard coded using the Router-ID command and must be unique.
- Add interfaces to the link state database which get identified via interface configuration or using the network command.
- The router will send HELLO messages on chosen interfaces. Once every 10 seconds on broadcast/P2p networks. Once every 30 seconds on NBMA (Non Broadcast Multi Access) networks. These HELLO messages contain information including the Router-ID, the Hello and Dead timers*, Network Mask*, Area ID*, Neighbors, Router Priority, DR/BDR IP addresses, and authentication password*. The ones that have stars next to them MUST match between neighbors otherwise a neighbor relationship will not form.
- Neighbor router receives HELLO. It verifies the HELLO/Dead interval along with the information that has stars next to it in step 3.
- Neighbor router sends a reply HELLO message and if it is listed as a neighbor in the HELLO packet it will reset the dead timer. If not it will add itself as a neighbor within the HELLO packet. The dead timer is used to determine if a neighbor is marked as down or not and if the topology must be reformed.
- Next, routers will determine the Master/Slaves. This is determined by the priority in the HELLO packet and the Router-ID will be used as a tie breaker with the higher ID being the Master. It can also be set manually. The Master router is in charge of sending database description (DBD) packets which includes information regarding the Link-State Database. The slave will follow up with sending it’s own DBD packet to the master. The Master will always transmit DBD’s with network information first.
- DBD’s are acknowledged and reviewed. If networks are found in the DBD’s that are not known by the Master or Slave routers they will begin to synchronize. For instance, the Slave requests details for networks it does not have. This is a Link State Request (LSR). The Master sends updates called Link State Updates (LSU). The Master will then request details from the slave (LSR) on networks it does not have. The Slave will provide those updates (LSU). This back and forth will continue as until…
- Full synchronization occurs. This means that the OSPF neighbor relationship has entered a Full State. Now that the neighbors are established and the network toplogies are known, Dijkstra SPF (Shortest Path First) algorithms will be run to figure out the best routes. More information on Dijkstra can be found here. It’s important to note that all modern routing protocols all use Dijkstra. Starting a new job? Don’t freak out if they use ISIS… It all comes down to Dijkstra’s algorithm.
Each state in OSPF has a name. These can be seen using debug messages and can help you easily determine the reason neighbor relationships may not be forming. Here are the 7 states of OSPF:
- Down: no OSPF neighbors detected at this moment.
- Init: Hello packet received.
- Two-way: own router ID found in received hello packet.
- Exstart: master and slave roles determined.
- Exchange: database description packets (DBD) are sent.
- Loading: exchange of LSRs (Link state request) and LSUs (Link state update) packets.
- Full: OSPF routers now have an adjacency.
This information is what separates the good Network Engineer from the great Network Engineer. The simple debug ip ospf packet command can go a long way with helping you be great at troubleshooting routing problems. Here is a summary of the steps listed initially:
- Hello: neighbor discovery, build neighbor adjacencies and maintain them.
- DBD: This packet is used to check if the LSDB between 2 routers is the same. The DBD is a summary of the LSDB.
- LSR: Requests specific link-state records from an OSPF neighbor.
- LSU: Sends specific link-state records that were requested. This packet is like an envelope with multiple LSAs in it.
- LSAck: OSPF is a reliable protocol so we have a packet to acknowledge the others.