Open Short Path First Routing Protocol implemented using Dijkastra Algorithm
How Dijkstra’s Algorithm works
Routing Information Protocol (RIP)
It is one of the oldest distance-vector routing protocols that uses hop count as a routing metric to find the best path between the source and the destination network.
Hop count is the number of routers occurring in between the source and destination network. RIP prevents routing loops by limiting the number of hops allowed in a path from source and destination. In a vector routing protocol, the routers exchange network reachability information with their nearest neighbors.
A vector routing protocol floods reachability information throughout all routers participating in the protocol, so that every router has a routing table containing the complete set of destinations known to the participating routers.
Working of RIP protocol-----
Open Shortest Path First (OSPF)
Open Shortest Path First (OSPF) is a link-state routing protocol that is used to find the best path between the source and the destination router using its own Shortest Path First. In this, the routers exchange topology information with their nearest neighbors. The topology information is flooded throughout the Autonomous System (AS) so that every router within the AS has a complete picture of the topology of the AS.
This picture is then used to calculate end-to-end paths through the AS, normally using a variant of the Dijkstra algorithm. Therefore, in a link-state routing protocol, the next-hop address to which data is forwarded is determined by choosing the best end-to-end path to the eventual destination.
OSPF terms –
Dijkstra’s Algorithm: The Shortest Path Algorithm
What if you are provided with a graph of nodes where every node is linked to several other nodes with varying distance. Now, if you begin from one of the nodes in the graph, what is the shortest path to every other node in the graph?
Well simply explained, an algorithm that is used for finding the shortest distance, or path, from starting node to target node in a weighted graph is known as Dijkstra’s Algorithm.
This algorithm makes a tree of the shortest path from the starting node, the source, to all other nodes (points) in the graph.
Dijkstra's algorithm makes use of weights of the edges for finding the path that minimizes the total distance (weight) among the source node and all other nodes. This algorithm is also known as the single-source shortest path algorithm.
Recommended by LinkedIn
Duri
Algorithm Execution
Here’s how the algorithm is implemented:
Uses of Dijkstra’s Algorithm
Dijkstra’s Algorithm has several real-world use cases, including the following:
Now Let’S look at the implementation of OSPF-
Dijkstra’s algorithm is a graph traversing algorithm. It is responsible for choosing the path on which the sender will send data bits or frames of a message to the receiver. It is the algorithm who is responsible to find the shortest path i.e, with the smallest weight total encountered in the path traversal from source to destination i.e, sender to receiver.
Consider a network structure given below, the figure contains the nodes between A to H. We need to examine the shortest path, between A to Z, where A being the sender and D being the Receiver.
Here A is the source, and Z is the destination; it is an undirected weighted graph. From the graph, we can observe there are multiple paths from A to Z like a -> b ->f ->z, a ->c ->e ->z, and many more.
1. During the first stage, we need to find the shortest node from the neighbor nodes of the source node.
2. During the second stage, it looks for the second shortest path node, which can be a neighbor node of the source node or to the node found in the first stage.
3. During the third stage, the algorithm looks for the third shortest path node from the source node. This node can be the neighbor of the source node or the nearest node found from the first stage or second stage.
4. The process is repeated until all nodes are visited at least once and if all nodes are visited once, then we can find the shortest path from the source node to the destination.
With the help of this procedure, we can find the smallest distance between two routers to send & receive packets.