Understanding the OSPF Forming neighbor adjacencies process. By Gustavo Sibaja Back in the days when I was a CCNA candidate, I took the 2 first courses of the Cisco Networking Academy at a University here in Costa Rica. Networking Fundamentals and Routing Protocols and Concepts. That was my very first introduction into the Cisco world. Before starting the switching module I took the CCNA Voice book by Cisco Press and learned most of the concepts of the 3 rd CCNA module (Vlans, VTP, STP, RSTP and so on ) which are slightly mentioned in this book, I then decided to start the Switching course at the same University I had taken the 2 first courses in. Just to realize that all the concepts where already in my mind. When the time came to start the Introduction to the WAN course (4 th module) a very good idea crossed my mind Why not?? Why not study yourself, learn the concepts, get some equipment, spend a couple sleepless nights until you reach that point when you are at your highest inspiration moment right before noticing that it is only 4:00 am and you have to get to work by 7 (pretty funny by the way). And I did, I started studying on my own, using a technique that inspired me to become an instructor and that was teaching to myself, my girlfriend, my old NetAcad buddies and my parents (until my dad became frustrated because of the excessive amount of information, in his own words ) and most of them didn t even realize what I was doing and just thought I was fooling around throwing some concepts in the air. I got certified two weeks before my NetAcad group had finished the 4 th course. Right now I m using the very same technique to get my CCNP, and this is how I would like to deliver you, Networking Gurus at Cisco my very own understanding of the OSPF neighboring process. Regards.
Open Shortest Path First, in all its glory is a Link State routing protocol that does not only update routing tables with the lower cost route or best path to a destination or many, but maintains a full topological database among other features. Uses the SPF (Shortest Path First) algorithm developed by Dijkstra and some of its features are: Maintains 3 tables (neighbor, topology and routing). Divides networks into multiple areas, and supports summarization to reduce bandwidth and processor utilization. All areas must connect to area 0, unless a Virtual Link is implemented. Supports authentication (in plain text or using Md5 hashes). An efficient OSPF domain requires an IP addressing hierarchical design. Uses triggered updates generated by changes in the topology and Link State periodic updates on long intervals (usually every 30 minutes). But for all of this to happen, OSPF routers must establish a neighbor relationship (except the authentication which takes place during the process of forming the adjacency) with all the other OSPF routers that belong to the same network segment. The process usually takes a few seconds in broadcast shared networks (Ethernet) or Point to Point networks, and a little bit longer on Non Broadcast Multi-access Networks (Frame Relay). However the process is complex and is essential to know the phases and steps that it goes through in order to accurately troubleshoot any issues that might take place when using this protocol. 1. Determine the Router ID This is the identifier or name that the router will have in the OSPF process; there are three ways to determine this parameter. Manually configured ID (using the router-id command under the OSPF process). Highest loopback interface configured on the router. Highest ip address configured on an UP interface. A manually configured ID is preferred or beats the highest loopback or ip address configured on the router during the election, and a loopback is preferred over an ip. It is recommended that you manually set up the ID on your routers. There are several advanced configurations (like the Virtual Links) that require you to manually enter a neighbor s router ID. Once the router ID is chosen another election will take place only if the OSPF process is cleared using the clear ip ospf process command from privileged mode, or if the router gets reloaded.
Cisco routers do not reboot very often during production, imagine what could happen if you are running an advanced configuration that depends on one of your neighbor s ID and it is the highest loopback or ip; you then create a higher loopback for testing purposes on that neighbor and accidentally leave it on your router, once the router gets reloaded or the process cleared the new higher loopback will be elected and your configuration will make no sense at all. This is why Cisco recommends manually configured ID s. You can view the ID using the show ip protocols command or the show ip ospf (process ID) both from privileged mode. 2. Add interfaces to the Link State Database Once the Router ID has been defined it is time for OSPF to know which networks will be advertised in the OSPF process and on which interfaces will OSPF be running. This is defined via the network (A.B.C.D + wildcard bits + area) command under the OSPF process (configrouter). These configurations will be reflected in the show ip protocols command.
3. Send Hello messages on predefined interfaces Hello messages are the packets that build up and maintain the neighbor relationship; these are periodically sent every 10 seconds on broadcast and Point to Point networks, and every 30 seconds on Non Broadcast Multi-access Networks. After a period of time without receiving hellos on an interface a router takes down the neighbor relationship, this is known as a dead timer and is by default 4 times the hello timer (how often the router sends a hello message). These timers must match on the routers that are attempting to establish a relationship, are manually configurable (but it is not recommended to do so) and can be viewed by using the show ip ospf interface command. A router sends these packets on the interfaces that have assigned the addresses that where entered in the OSPF process using the network command. Once a router sends this packet for the very first time it reaches a down state that means the local router is waiting to hear back from the router that is to become a neighbor. 4. Receive Hello message There are several values that must match between 2 routers for them to become neighbors, here is the list: Area ID Subnet Mask Hello and dead timers
Authentication password The receive hello stage is where all these parameters are checked, and the routers ensure that their future neighbor matches with the local values, and then reaches the init state; you can view the output of these process by issuing the debug ip ospf adj or debug ip ospf events commands. All of these parameters are manually configurable. If you issue any of the previous debug commands or the show ip ospf neighbor command and you see a relationship bouncing between down state and init state it is because some of these values do not match between your routers, and the relationship will never reach a full state (final stage of the process). 5. Send reply Hello Routers send hello packets constantly to their neighbors, whenever a hello message is received on a router s interface after it has reached the init state the router must answer itself a question. Is the router I am receiving this hello message from already my neighbor? If it is, then the router just resets its local dead timer and continues with its full neighbor relationship. But if not the router will reach the 2-way state for this future neighbor and will continue in the process of adding this router as a neighbor. 6. Determine Master-Slave status in the relationship This stage is to determine basically who sends information first, and sets the routers in an exstart state, the information that the routers will be sending is known as a Database Description (DBD) and it s a small update or summary that includes the networks that are to be advertised in the OSPF process and some information of the router that is sending it. Each router sends its DBD and looks at the other router s or routers parameter called priority (which is by default 1). The router with the highest priority value will be elected as a MASTER and if there is a tie of priority values the highest router ID wins the election. The priority is a per interface value. You can view this event in real time by issuing the debug ip ospf adj command.
The priority is a manually configurable command, and it can be tuned by using the ip ospf priority command under the desired interface (must be the one connected to the other OSPF running router), highest configurable priority is 255 7. Database Descriptions acknowledged and reviewed Once the MASTER and SLAVE statuses are assigned the slave sends the first packet, which is a Link State Request that the MASTER responds with a Link State Update (packet that contains one or many of the 11-type Link State Advertisements). Then the MASTER sends a LSR to the SLAVE that will respond with another LSU. This is known as the loading state or on newer IOS versions exchange state and the routers are basically exchanging all the routing information like remote networks and best way to get to them, within an area (LSAs type 1 and 2), multiple areas (LSAs type 3) or even another routing protocol domain (redistribution, LSAs type 5). No need to worry if you issue the show ip ospf neighbor command and you see the relationship in the loading state for a while (usually longer periods on Non Broadcast Multi-access networks) routers are just exchanging their information and you can confirm that by using the debug ip ospf adj command..
8. Neighbors are synchronized After the loading or exchange stage is completed the routers reach the full state and neighbor relationship is finally completed, routers are fully synchronized. Behold the output of the entire process courtesy of the debug ip ospf adj command Notes: Do not use the debug commands on production hours; they can be very processor intense and cause major outages or at least slow performance of the network during the usage. Also there is no standard approach when it comes to troubleshooting but keep in mind that if end users report some outages, unreachable destinations or slow connections to other networks it might be a routing problem (most likely a routing loop or no route at all to the destination) and if you are using OSPF it is extremely helpful to accurately know this process, how it s supposed to look when fully converged, and what are the steps to get there.