What is OSPF PROTOCOL? Explained with Dijkstra’s Algorithm and Example.

The full form of OSPF is Open Shortest Path First, and It belongs to the family of IGP Protocols. This routing protocol uses a link-state routing protocol within an Autonomous Network System to discover the shortest path between the source and destination.

An autonomous network has a group of connected routers in a hierarchal manner. Each router can exchange its routing information to the adjacent node over TCP/IP. The protocol does not impose any upper limit on the number of routers.

The work of each node is to send topology information to the adjacent nodes. This process is continuous, meaning if one sends the information to the adjacent, the receiver will propagate the information further. Each node is independent, and it can find an appropriate and convenient path for the process itself.

A few OSPF terms are given below:

Router_Id:- it is similar that every person has a different identity to be recognized uniquely. A similar concept is applied to a router. We can assign a router-id manually, or it can be configured automatically by protocol.

Router Priority:-8 bit value that configures to a router to assign priority. A router that has a higher priority will start first, and this condition is called DR. If the router priority is the same, then the router with a higher id value will consider first. There is also a condition when the router-id is not defined. Then the priority will be considered on the basis of the active IP address.

Down:- down is a condition in which the router doesn’t send any packets or messages. That doesn’t mean the router is not working, which means OSPF is not started working yet.

Master-Slave Relation:- A router that has a higher priority acts as a master node, and the rest are called slave nodes. To identify the priority, some elections are taking place that tells which node will send the message first.

DBD(database description packet)

LSU(Link state update)

There are many algorithms in the OSPF protocol:

Shortest Path Routing: The protocol is also called Dijkstra’s algorithm. This is a very basic and important algorithm in OSPF. In this algorithm, we must find the shortest path between the nodes. Firstly, we have to decide on the initial and final points.

How does the OSPF protocol work?

For example, let’s suppose we have nine nodes in an autonomous system. Those connect to each other like a web of spiders. This means there are many ways between 2 nodes via other nodes, eg.

OSPF protocol example
OSPF protocol example

As shown in the figure, there are two paths to travel from 0 to 2: a direct link from 0 to 2 and the other via 1. So whenever we use this algorithm, we should consider every possibility of reaching from the source to the destination.

We can’t apply any kind of assumptions to Dijkstra’s algorithm. We can also find the shortest path with the help of programming. So if you are unfamiliar with programming, we can find this value manually also. Now I am going to solve one shortest path routing algorithm.

Let’s begin the algorithm by first looking at point 0. We will move towards point 8, so we have to pass another seven numbers sequentially. So, the 0 to 1 distance is three, which is quite simple because we have no other shortest way to reach 1.

Now 0 to 2, as you can see, there are two ways to reach point 2.  The first is 0 to 2, and another is 0 to 2 via 1, but both distances are the same, so we can use anyone from the two paths.

Now (0 to 3 ). From 0 to 3, we will go via 0,1,3, which is 3+5=9.

From 0 to 4, we will go from 0,1,4 .as we can see 3+4=7, and if we go from 0,2,4, then the distance is 6+5=11, so seven is the least.

From 0 to 5, we follow the distance 0,1,3,5. The distance would be 3+5+4=12

For 0 to 6, the shortest path will be 0,1,4,6, and the sum is 3+4+2=9, which is the shortest from other paths.

0 to 7 is 0,1,4,6,8,7 and the value is 3+4+2+4+2=15

0 to 8 distance will be 0,1,4,6,8, and the value is 3+4+2+4=13

Configuration: configuration is like an IP address assigned to the router. We can assign IP addresses manually to the router and computers. In Cisco, we can connect n number of routers, hubs, and computers with different IP addresses.

If we do not set the IP addresses properly, it will give an error because there is fix range of to

There are some steps to configure OSPF in a single area.

  • First, we have to switch on the router.
  • Second, we have to give commands to the router to enable the interface.
  • Third, enable the interfaces and identify the area in which we have to assign.
  • And last is assign the IP.