OSPF and Dijkstra Algorithm…

HarvinderSingh
3 min readJul 15, 2021

Working on through the internet has made our lives so much easier, the wires, cables, modems, or routers are installed in our homes or workplaces and are a very basic thing we want in our routine life. This might not grab everyone’s attention, but when you get into the research of how all this works, you get to know how the wires take your data to the routers and then to the servers. Data travels in the form of electrical signals as packets in electronic medium and in the form of light in optical fibre cables, the charged and uncharged ion indicates the binary data, higher bit is 1 and lower is 0. But when it comes to a wireless network the data travels in form of waves, crest represents higher bit, and trough represents lower bit.

Routers/ISPs connect through wires and help you to reach out to any site you want, ex. www.google.co.in. Your home router takes you to your Internet Service Provider, and further your ISP tries to figure out which path to choose to reach out to the site you want. But in some cases you are in a network setup where your device (laptop or a mobile phone) connects to a switch, and the switch further connects to a router and the process continuous, or in a case you want to connect to a device connected to the same network but different subnet (example, different labs in a college or different departments at a workplace belong to the organization’s network but connect belong to different subnets, Company net — 10.0.0.0/24 and subnet1–192.160.10.0/24, subnet 2- 192.168.20.0/24). Some standards and algorithms are used to perform this action. OSPF is one of them.

Open Shortest Path First (OSPF) is an open link state routing protocol. OSPF routers learn the entire network topology for their “area” (the portion of the network they maintain routes for, usually the entire network for small networks). OSPF routers send event-driven updates. If a network is converged for a week, the OSPF routers will send no updates. OSPF has far faster convergence than distance vector protocols such as RIP. Internally OSPF used Dijkstra Algorithm to achieve the shortest path.

Suppose you are on router 0 network and want to send data packets to the device marked as number 6. The ospf will take the help of dijkstra algo and will help you to find the shortest path, which can be seen in the image. The algo works using the concept of weights which here in the ospf is the distance or number of intermediates it will meet while transmitting data. We need to maintain two sets, one set contains routers/switches included in the shortest path graph, another set includes routers/switches not yet included in the shortest path graph. At every step of the algorithm, we find a switch/router which is in the other set (set of not yet included) and has a minimum distance from the source.

I hope you found it informative.

Thanks for reading. 😄

--

--