OSPF routers establish network connectivity through a four-step process: forming neighbor adjacencies, exchanging link state advertisements, building a shared link state database, and running Dijkstra's shortest path first algorithm to populate the routing table.
OSPF Process
Here's a quick rundown of the OSPF process. The first thing a router is going to do is start sending out hello packets to establish neighbor adjacencies, to figure out which routers, which layer 3 devices, that router is connected to.
Next, what it's going to do is exchange link state advertisements with those routers to figure out where all the links in the network are. It's going to build the link state database. Once it has the link state database fully built, then it can run through its Dijkstra algorithm, or the OSPF algorithm, the shortest path first algorithm, to create the shortest path first tree. And then once it has the tree, figuring out where all of the different ways are to get to each one of the networks, then it can use that to install the best route onto the routing table.
One of the first things that these routers will do is they'll reach out to each other and communicate with hello packets, and those hello messages that are being sent back and forth between these routers are going to establish some sort of neighbor adjacency.
Each one of these routers has a neighbor adjacency table that it will record its neighbors on. So for this layer 3 switch right here, it's going to say, I'm attached to R1. This Router 1 is going to say, well, I'm attached to Switch 1 and I'm also attached to Router 2, or I have an adjacency to Router 2. This Router 2 is going to say, well, I have a connection with Router 1 and Router 3. And this Router 3 is going to have a connection with Router 2.
So that is the first step, is establishing neighbors. With each one of these neighbors it records other information also. Notice that I have some blank fields here, because it records multiple things within here, but we're just going to keep it simple for the process of what we're doing right here.
Next in this process is they will exchange link state advertisements. So all of the link state advertisements get sent out across all of this topology here, and they'll exchange information about each one of the links.
So let's label each one of these links. This is link one right here, this is link two, and this is link three. And they'll start building out their link state database. So for instance, this Router 1 will see that link one is connected to HQ SW1 and it also is connected to Router 1. It will see that link 2 is connected to both Router 1 and Router 2, and it'll see that link 3 is connected to both Router 2 and Router 3.
And this information is passed to all of the devices, so they'll each one get the same information. Each of the link state database tables will be populated with all of the same information. So now what they can see is all of the links on the network, and all of who is connected to that link.
The next step in this process is to figure out the SPF algorithm, that Dijkstra algorithm. It takes this information of all of the links and then creates that SPF tree. And that SPF tree, in this example right here, is very simple, so pretty much it's a straight line, and we'll do that for each one of the networks that it's trying to get to. So for instance, HQ SW1 can go through R1 and R2 and R3 to get to this network right over here. So it's going to do that for each one of the networks, and it knows of that network that's hanging off of R3 here.
And then it will install that into the routing table. So that information then is compiled and goes into the routing table. What goes into the routing table is based off of cost, but what will happen is the best route is going to be installed on that routing table.
So at this point in time we have the full network, the full OSPF network is now converged. We have information in our neighbor table of all of the information of the connected layer 3 devices that are using OSPF in that area, and each one of those neighbor tables, remember, is different depending on which router you're looking at; they have different neighbors. Then the link state database is all the same there. So it creates that link state database, and then from that it creates that shortest path first tree to figure out what is going to be the cost for each one of those paths, and then it puts the best, the lowest cost path, into the routing table.
TechKnowSurge builds IT and cybersecurity professionals through hands-on, concept-first training built around real understanding — not memorization. Free interactive tools, structured programs, and 25+ years of real-world experience, all in one place.
Explore free tools and programs →