OSPF : A Dynamic Routing Protocol
Tags: networking, ospf, algorithms, dijkstra
Published: 2021-07-05 16:59:57

#What is Dynamic Routing?
- Dynamic Routing is a network routing procedure that facilitates the routers to pick and choose the routing paths depending on the network structure’s logical changes in real-time. This is opposite to the typical traditional static network routing. This is an automated routing technique that requires very less administration and supervision. Various protocols used in this routing method are Open Shortest Path First (OSPF), Routing Information Protocol (RIP), Border Gateway Protocol (BGP), and Enhanced Interior Gateway Routing Protocol (EIGRP).

#Introduction to OSPF:
- Open Shortest Path First (OSPF) is a standard routing protocol that’s been used the world over for many years. Supported by practically every routing vendor, as well as the open source community, OSPF is one of the few protocols in the IT industry you can count on being available just about anywhere you might need it. 

#Working of OSPF:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i7qzfvssbj65ylm94pnk.jpg)
  
- OSPF is based on link state routing algorithm in which each router contains the information of every domain and based on this information it defines the shortest path also known as Dijkstra algorithm. The OSPF learns about every router and subnet within entire network. A link-state routing protocol is a protocol which uses the concept of triggered updates, i.e., if there is a change observed in the learned routing table then the updates are triggered only
- The way through which OSPF learns about other routers is by sending Link State Advertisement or LSA. These LSA contains information about subnets, routers and some of the network information. Once all the LSA’s are transferred within network, OSPF put’s these in a database called as LSDB i.e Link State Database. The main goal here is to have each router with same information in their LSDB’s.
- OSPF maintains information in three tables named “Neighbor Table” that contain all discovered OSPF neighbor with whom routing information will be interchanged. “Topology Table” contains the entire road map of the network with all available OSPF routers and calculated best and alternative paths. The “Routing Table” where the current working best paths will store and it is used to forward the data traffic between neighbors.

#What is Dijkstra Algorithm? How OSPF uses Dijkstra behind the scene ?
- Dijkstra Algorithm is a very famous greedy algorithm. It is used for solving the single source shortest path problem. It computes the shortest path from one particular source node to all other remaining nodes of the graph.
- So it's not like we run Dijkstra's algorithm and it answers all of the best paths. We run it each time we have to get to a unique destination network. And the way that it works is it assigns a cost to the links. And when it gets to a certain point when it says oh, I got something better, I'm going to stop running that calculation because I've already established a better pathway to that destination. And so Dijkstra's algorithm, a complex algorithm, but ultimately it just tells us here's the best way to go, and then where does that information go inside of our router? Well that path with the shortest metric to get to that destination network ends up in our routing table.

- The way through which OSPF chooses best route is by a metrics called cost. OSPF cost is the value to given to a link based on the bandwidth of that interface.

- **Cost = Reference Bandwidth / Interface Bandwidth, where reference bandwidth is 100 Mb/s.**



#So That's It,Thank you for reading 😃


#Keep Learning, Keep Hustling🎯🎯


[You Can Connect with me on LinkedIn](https://www.linkedin.com/in/piyush-bagani/)