Open Shortest Path First – What is OSPF in Networking

In this article, we’ll discuss What is OSPF in networking and how OSPF works? We will also define its basic concepts, like why and how OSPF forms neighbors, its Pros and Cons, OSPF message format, and its packets.

What is OSPF in Networking – Basic OSPF Explained

OSPF, or Open Shortest Path First, is a link-state routing protocol for Internet Protocol (IP) networks. It uses the shortest path first (SPF) routing algorithm, is an Interior Gateway Protocol (IGP), and is used within Autonomous Systems (ASes).


In OSPF, each router maintains a complete map of the network topology. When a change occurs in the network, such as when a link goes down or comes back up, each router updates its map accordingly and then calculates the shortest path to every destination using Dijkstra’s algorithm. The resulting paths are then stored in the form of routing table entries and used to route packets accordingly.


OSPF has an Administrative Distance (AD) of 110 and uses a cost metric to determine the best route. The cost is calculated based on the bandwidth of the link. The lower the bandwidth, the higher the cost. Therefore, a lesser cost is always preferred.


OSPF is a widely used routing protocol, especially in large enterprise networks. It is also used as a base routing protocol or as a network backbone in some service provider networks. Most major router vendors, including Cisco, Juniper, etc., support OSPF.

OSPF is one of the oldest link-state routing protocols among the Interior Gateway Protocols (IGPs). The OSPF Working Group of the Internet Engineering Task Force (IETF) developed it in the mid-1980s.

OSPF was initially developed in RFC 1131 and has been updated several times since then. Its latest specifications are in RFC 2328.

OSPF Advantages and Disadvantages in Detail


CERTIFICATION
Advantages of OSPF
  • OSPF is a standard IGP protocol that is easy to configure and widely known and accepted among network engineers in enterprise networks and service provider networks.
  • OSPF supports IPv4 and IPv6 both.
  • OSPF supports plain text and MD5 authentication.
  • OSPF supports multiple areas, providing improved network scalability, easier troubleshooting, and reduced routing traffic.
  • OSPF offers fast convergence times, high scalability, and robustness compared to distance vector protocols like RIP
  • In addition to calculating routes, OSPF provides automatic fault detection and recovery capabilities, making it ideal for large enterprises.
  • OSPF can improve your network’s speed and performance, especially for larger LANs or WANs. 
  • OSPF uses VLSM and discontiguous networks.
  • You can manually summarize OSPF interarea routes at the ABR or ASBR.
  • Open Short Path First (OSPF) uses small hello packets to verify links first and ignores transferring large tables, which reduces traffic.
  • OSPF supports route tagging: Routes can be tagged to ease interoperability with arbitrary values.
  • Open shortest path first (OSPF) can route packets according to their ToS (Type of Service) field.
Notifications
Some Minor Drawbacks of OSPF
  • OSPF requires more configuration than other protocols like RIP or static routes.
  • It is a more complicated protocol to understand and master than other simpler routing protocols like RIP.
  • OSPF is a processor-intensive protocol, and you might need a router with a good amount of RAM before thinking of deploying OSPF in your network.
  • It maintains multiple copies of routing information, which is why it uses more memory.
  • Adding more routers to the routing domain doesn’t scale well, especially when using MPLS and other technologies on top of OSPF.

In my opinion, you can easily overcome these cons by carefully designing/planning networks and having a robust router.

How does OSPF work?

When configured, OSPF will listen to neighbors and collect all link state information available to build a topological map of all available paths within its network. Then it stores the information in its topological database, the Link State Database (LSDB).

After gathering the necessary information, it will calculate the shortest paths to each reachable subnets/network using a Shortest Path First (SPF) algorithm.

OSPF creates three tables to store the routing information:

Neighbor Table: This table contains all discovered OSPF neighbors with which OSPF will exchange routing information.

Topology Table: It contains the entire route map of the network with the available OSPF routers as well as the calculated best and alternative paths between any two nodes.

Routing Table: Contain the best current routes that OSPF will use to route data traffic between neighbors.

Why an OSPF router forms a neighbor relationship with another OSPF router?

OSPF forms neighbors for two primary reasons: 

To discover all possible/available paths between two nodes through which traffic might flow. Later, this information is used to find the best (shortest) path between two routers.

To ensure reliable transmission of routing information throughout the network.

What is OSPF in Networking

How a router forms an OSPF neighbor relationship?

OSPF uses a three-way handshake process to form neighbors; let us understand this with the below example:-

  • Router-1 and Router-2 have both been configured for OSPF. (And simplicity, let’s assume this is a point-to-point OSPF network.)
  • Router-1 sends a Multicast (224.0.0.5) Hello to Router-2.
  • Router-2 responds to the Hello to the Router-1 if all parameters (mentioned below) are matched properly.
  • Router-1 also responds to the Hello message of Router-2.
  • Then OSPF neighborship goes through multiple OSPF states, forms neighborship, and exchanges their OSPF Database.
  • OSPF neighborship turns into Full-state.

These parameters should match to form the OSPF neighborship:-

  • The OSPF area ID
  • The OSPF area type
  • The link maximum transmission unit (MTU)
  • The Hello interval
  • The dead interval
  • The OSPF link type (point to point, broadcast, and so on)
  • Network masks (except Point-point links)

The Hello packets are used to maintain neighbor relationships between routers. The OSPF neighbor is reset if a Hello packet is not received from a specific OSPF neighbor router at least once each dead interval.

On Cisco routers, the OSPF hello timer is set to 10 seconds and the dead interval to 30 seconds. However, some implementations allow the OSPF dead time to be set to one second (or even less) with correspondingly short dead times.

OSPF Message Format

Fields in an OSPF message format are mentioned below:

  • Type: 8-bit field used to identify the OSPF packet type.
  • Version: 8-bit field used to specify the OSPF protocol version.
  • Message: 16-bit field that defines the total length of the message, including the header. 
  • Source IP address: IP address of the source router from which the packets are sent. 
  • Area identification: OSPF area ID where routing is happening.
  • Checksum: Used for error detection and correction.
  • Authentication type: Two types of authentication, 0 and 1. 0 means no authentication, and 1 means password-based authentication.
  • Authentication: 32-bit field that contains the real authentication data, like passwords.

OSPF Hello Protocol 

There are six packet types in OSPF, including Hello protocol, Database Description Packet, Router Advertisement, Link State Request, Link state Update, and Link State Acknowledgment.

We will discuss the OSPF Hello protocol in this article.

A Hello packet play several roles in OSPF. They are responsible for:-

  • The discovery of neighbors, including the advertisement of parameters required for two routers to become neighbors.
  • Sending keepalives between OSPF neighbors.
  • Election of DR (Designated Router) and BDR (Backup Designated Routers) on Broadcast and NBMA networks.

The OSPF Hello packet contains all critical information about the originating router, including:-

  • The router ID, area ID, and address mask, 
  • Authentication type and information, 
  • Hello-interval and Dead-interval, 
  • Router priority, 
  • DR and BDR information (not applicable on point-to-point networks)
  • Five flag bits for optional capabilities. 
  • The hello packet also contains router IDs of the originating router’s neighbors.

Although all the above parameters do not need to match to become neighbors, I have already discussed those required parameters to establish neighborship in the OSPF neighbor section above.

What is OSPF Hello-Interval?

OSPF-speaking routers communicate with each other by periodically sending a hello packet out of each OSPF-enabled interface.

The default hello-interval is 10 seconds for broadcast networks and 30 seconds for non-broadcast networks.

The hello-interval can be configured on a per-interface basis with the “ip ospf hello-interval” command.

What is Router Dead-Interval?

The time after which a router will declare a neighbor down is called the dead interval. It usually does when it does not receive any hello in response from a neighbor and the dead-interval timers expire.

The default dead-Interval is four times the hello-interval, but you can change it with the command “ip ospf dead-interval.” 

Can we change the Hello-Interval and make it faster? 

One answer is the Fast-Hello packets, which configure OSPF to send hello packets within 1 second. But keep in mind that this might be taxing on routers. 

I would instead recommend BFD (Bi-Directional Forwarding Detection). BFD is a lightweight protocol and does the job better than fast-hellos.

But in case you want to configure fast hellos:-

  • Use “ip ospf dead-interval min hello-multiplier 10” – This will send 10 hello packets every 1 second with an interval of 100 ms.

I will discuss other OSPF Topics in Upcoming Posts.

Conclusion

In conclusion, OSPF is a robust link-state routing protocol widely used in enterprise networks to improve the efficiency of network communications. It has several advantages, including its ability to form neighbors and its support for multiple areas, which can be very useful in larger networks. However, it also has some disadvantages, including its complexity and the need for careful configuration. 

I hope you like the article; please let me know your thoughts and feedback in the comment section.

Leave a Reply

Your email address will not be published. Required fields are marked *