OSPF (Open Shortest Path First) is a link state routing Protocol, a type of the Internal Gateway Protocol (IGP), which was designed to scale and support more extensive networks. To find the shortest path between the nodes, OSPF uses Dijkstra’s algorithm. OSPF also uses the link cost as the metric, based on the link bandwidth to find out the shortest path between the source and the destination.
OSPF Routing Protocol Properties:
- To construct the entire network topology at its end, as mentioned before, a router uses the Dijkstra’s algorithm to find out the shortest path to any other router in the network and map the whole topology.
- OSPF is a standard protocol that means there is nothing proprietary in this protocol. So, if you want to use a Cisco router along with a Juniper router in an autonomous system and run the OSPF routing algorithm, it will work because this protocol has been standardized.
- There is unlimited hop count in the OSPF. If you remember from the routing protocol overview article, previous routing algorithms suffered from the countdown to infinity problem. Due to that, in the RIP, the total number of hops was limited to 16. However, it was all removed in the OSPF. Now, OSPF has the unlimited hop counts.
- It is a type of the link state routing protocol because it maintains the link states of the adjacent routers. Again, taking reference from the RIP protocol, it uses some of the features such as hello packet or the Keep-alive timer, etc. to maintain the states of the adjacent routers.
- OSPF uses link speed as the cost. It is calculated as follows:
link cost = 10^8/bandwidth
Let’s say the link speed between two routers is 1544 Kbps (1544000 bps) then the link cost would somewhere be around 64 by using the above formula. In this case, 64 becomes the link cost between two routers.
- OSPF uses the concept of an area which makes this protocol easier to manage and control traffic.
The OSPF uses different kinds of tables to keep track of the routers and maintain a set of the databases.
Neighbor tables contain the routers directly connected to different interfaces of a router. It is also known as the adjacency table. Neighbor table is often used in troubleshooting if there is no communication between two routers. Neighbor table of a router is checked at first hand to see if two routers make neighbors at all.
Database table also refers to LSDB (Link State Database). It contains all the possible routes to different routers in the network.
The routing table is used to find the best possible path to any router in the network.
There are seven stages in which OSPF works. Here are they:
A. Down State
Initially, all the routers will be in the down state. That means all the routers are oblivious to all the routers in an autonomous system.
B. Initialization State
Once a router is powered up, it begins advertising by sending hello packets to the adjacent routers. In the hello packet, it also sends the IP address of the interface through which it sends the hello packet. The hello packet is sent to a multicast address at 184.108.40.206 and is delivered to all the routers.
C. Two Way State
Once all the routers receive the hello packet. The routers open the hello packet and look at the IP address. After processing the hello packet, routers conclude that if the received packet is from the same network or not. If the received packet is from the same network, then they look at the interface from where the packet was received.
Once the interface has been identified, the other router receiving the packet replies to the first router by unicasting its own hello packet along with its IP address. This way, both the routers can know they’re neighbors. This is called two-way state because Router A becomes the neighbor of Router B and vice versa.
D. ExStart State
ExStart state is dependent on another concept used in the OSPF called Router ID. The Router ID is the name of the router.
Router ID is the highest physical interface of the router. Sometimes, a router might have a logical interface configured as well, in that case, the router Id will be the highest IP address of the logical interface.
Coming back to the ExStart State, it is not about exchanging the information between two routers, but it’s more about deciding which router shares the information first.
So, both the routers compare their router IDs. The router with the higher router ID will get the privilege to start sharing information first.
E. Exchange State
After the ExStart state, the real exchange happens in the exchange state only. The routers share summaries of the database that they have. The database is called LSDB (Link State Database).
F. Loading State
In the loading state, the router compares its database against the database it receives from the neighbors. That’s because OSPF relies on the fact that all the routers in the network should have the same network database and topology.
LSR (Link State Request)
In case there is a discrepancy in the link state database, the router sends the link state request, also known as LSR, to its neighbor requesting for more information about a particular network which is mismatched.
Link State Update (LSU)
Once a router receives the LSR, it replies with LSU which contains the updated information.
LSAck (Link State Acknowledgement)
Once the router receives the LSU, it sends the LSAck.
G. Full State
When all the routers have the same database, the network is in the final stage of the OSPF we call Full State. Now when a router receives a packet, based on the maintained databases, it calculates the best path and sends the packet.
Working as a cyber security solutions architect, Alisa focuses on application and network security. Before joining us she held a cyber security researcher positions within a variety of cyber security start-ups. She also experience in different industry domains like finance, healthcare and consumer products.