Open Shortest Path First Protocol

An open-standard link-state routing technology called Open Shortest Path First (OSPF) is utilized in Internet technology (IP) networks. It is categorized as an Interior Gateway Protocol (IGP), which means that it routes IP packets inside a single autonomous system (AS). The Internet Engineering Task Force (IETF) selected OSPF as its recommended IGP. While OSPFv3 (described in RFC 5340) is used for IPv6 routing and can additionally support IPv4 through address family setting, OSPFv2 is used for IPv4 routing (specified in RFC 2328).
Fundamentals of OSPF

The basic idea behind OSPF is that every router in an OSPF network creates an extensive topology map of the network. Three primary stages are used to accomplish this:
Neighbour and Adjacency Initialization
By sending Hello packets on a regular basis, routers create and preserve neighbour connections. For IPv4, these packets are sent to the multicast address 224.0.0.5. To establish an adjacency, routers need to meet characteristics such Area IDs, authentication, MTU, and Hello/Dead intervals. To create an adjacency, routers go through a number of states: Down, Attempt, Init, 2-Way, Exstart, Exchange, Loading, and Full. The “Full” state denotes full synchronization of link-state data. For correct operation, a Router ID (RID) is required, which is usually the highest IP address of a loopback interface or the highest active physical interface.
LSA Flooding and Link-State Database (LSDB)
Link-State Advertisements (LSAs) are used by routers to exchange network topology data. The router itself, its linked links (interfaces), IP addresses, and status are all described by LSAs, which are data structures. The Link-State Database (LSDB), which gives every router an identical and comprehensive map of the network topology in its region, contains all known LSAs. The router instantly uses Link-State Update (LSU) packets to flood its neighbours with the new LSA whenever an LSA changes (for example, when an interface fails). Every 30 minutes, unmodified LSAs are periodically reflooded.
SPF Tree Calculation
OSPF processes the LSDB using the Dijkstra Shortest Path First (SPF) algorithm. The least-cost routes from that router to each other subnet in its vicinity are displayed in an SPF tree created by this method. The optimal pathways are subsequently added to the router’s IP routing table using this tree, which directs data packet forwarding.
Also Read About Why Is IP Address Important & Different Types Of IP Address
OSPF Metric (Cost)
OSPF uses a statistic known as “cost” to determine the optimal course of action. The OSPF interface expenses for each outgoing interface in the path add up to the route’s cost. Higher bandwidth links are favored since they are less expensive, according to Cisco’s implementation, which uses the formula 10^8 / bandwidth (in bps) to determine interface cost. It is possible to manually set costs. In order to balance load, OSPF allows equal-cost multipath (ECMP) routing, which adds several routes with the same lowest metric to the routing table.
Hierarchical Design with Areas
OSPF divides the network into “areas” to enable a hierarchical network design. This architecture confines network instability, accelerates convergence, and reduces routing costs.
- Backbone Area (Area 0): Also known as area0 or area 0.0.0.0, the backbone area is the core segment of an OSPF network and acts as the hub connecting all other network areas. It disperses routing data among different kinds of non-backbone areas.
- Area Border Router (ABR): An ABR is a router that connects additional areas to the AS’s backbone. An ABR keeps summarized routes for every area in the network and distinct link-state databases for every area it serves.
- Autonomous System Boundary Router (ASBR): An ASBR is a router that makes connections between various autonomous systems. In order to communicate with other ASs, ASBRs usually employ static routes or an external routing protocol (like BGP).
- Area kinds: OSPF specifies a number of area kinds, such as:
Standard area: Non-backbone territory that is joined to the backbone is called the standard area. except for LSAs 4 and 5, supports all LSAs.
Also Read About IP Connectivity Requirements, How it Works, and Importance
Stub area: A stub area is one that only receives routing from a default route and does not get route ads from outside the AS. An ABR becomes the default gateway, removes type 4 and type 5 LSAs from internal routers, and transmits them the default route 0.0.0.0. For internal routers, this lowers the size of the routing table and LSDB.
Totally stubby area (TSA): Another type of stub region that doesn’t get any external or inter-area routes from other areas is called a totally stubby area (TSA). Its only default path is via an ABR to the backbone area.
Not-so-stubby area (NSSA): A unique stub area that is unable to accept AS-external routes from other areas but is able to import external routes using Type 7 LSAs and send them to other areas.
Totally Not-So-Stubby Area (NSSA): The NSSA stands for “Totally Not-So-Stubby Area.” The fully stubby NSSA, which combines the features of a TSA with the normal capabilities of an NSSA, prevents type 3 and type 4 summary routes from flooding into this kind of area. Both completely stubby and not-stubby areas can be designated; the former will only receive the default route from area 0.0.0.0, while the latter may have an autonomous system boundary router (ASBR) that takes in external routing data and injects it into the local area and back into area 0.0.0.0.
OSPF Packet Types
OSPF employs five different kinds of IP packets that are natively encapsulated in IP using protocol number 89 (rather than TCP or UDP):
Also Read About What is IP Routing, How IP Routing Works, and Types
- The Hello Packet is used to find neighbours and keep up with them.
- During the first communication between routers, the Database Description (DBD) packet summarizes the contents of the LSDB.
- A router sends a Link-State Request (LSR) packet to request particular LSAs that are absent from its LSDB.
- LSAs that are flooded or sent in response to an LSR are contained in the Link-State Update (LSU) packet.
- Link-State Recognition (LSAck) Packet: Ensures dependability by clearly verifying that LSUs were received.
Advantages and disadvantages of OSPF
Advantages of OSPF
OSPF is appropriate for big and complicated networks due to its many benefits:
- Fast Convergence: OSPF ensures low downtime and loop-free paths by promptly recalculating routes and updating routing tables in response to network changes, usually in a matter of seconds.
- Scalability: OSPF can handle big, sprawling networks thanks to its hierarchical design with regions, which lowers routing overhead and boosts productivity.
- Classless Protocol: Optimises the use of IP address space by supporting Classless Inter-Domain Routing (CIDR) and Variable Length Subnet Masking (VLSM).
- Load Balancing: Equal-cost multipath (ECMP) routing is supported by load balancing, allowing for effective bandwidth use across several paths with the same cost.
- Open Standard: OSPF is compatible with devices from various suppliers because it is an open standard protocol.
- Authentication: Enables authentication to guard against unwanted modifications and secure routing updates.
- Flexibility: Supports many traffic types (unicast, multicast, anycast) and network types (broadcast, point-to-point, non-broadcast multi-access).
Disadvantages of OSPF
OSPF has certain disadvantages in spite of its advantages:
- Configuration Complexity: Manually configuring OSPF can be time-consuming and needs sophisticated knowledge, particularly in larger networks.
- Resource Requirements: In comparison to simpler protocols, the SPF algorithm needs greater CPU processing power and more RAM to store the LSDB and neighbouring topologies.
- Complexity of Troubleshooting: Its intricacy may make troubleshooting more difficult.
Administrative Distance
The administrative distance (AD) of OSPF is set to 110 by default. Because of this, OSPF routes are more favoured than protocols like RIP (AD 120), but they are less favoured than static routes (AD 1) or EIGRP (AD 90 for internal routes).
Designated Router (DR) and Backup Designated Router (BDR)
To control the quantity of adjacencies and widespread LSA flooding on multi-access networks (such as Ethernet), OSPF chooses a Designated Router (DR) and a Backup Designated Router (BDR).
Designated Router (DR): A network’s designated router (DR) is chosen to reduce the quantity of OSPF adjacencies. It is in charge of sending all other routers Link State Advertisements (LSAs). The DR replies with updates after receiving LSR (Link State Request) messages in a broadcast network.
Backup Designated Router (BDR): In a broadcast network, the DR backup is provided by the Backup Designated Router (BDR). In the event of the DR’s failure, the BDR steps in and takes over the DR’s duties.
- When something changes, the DR is in charge of updating every other OSPF router on the multi-access network.
- The BDR keeps an eye on the DR and steps in if necessary.
- Only the DR and BDR establish adjacencies with the other routers, referred to as DROTHERs.
- This multicast address is used for DR and BDR updates.
- The highest OSPF priority determines the DR/BDR election; in the event of a tie, the highest Router ID acts as the tiebreaker. A router cannot become DR/BDR if its priority is 0. Point-to-point connections do not experience DR/BDR election.
OSPFv2 vs OSPFv3 (for IPv6)

Compared to OSPFv2, OSPFv3 introduces a number of changes:
- Protocol: OSPFv3 mainly supports IPv6 (and IPv4 through address family setting), whereas OSPFv2 supports IPv4.
- Addressing: OSPFv3 operates per link rather than depending on the subnet and only employs IPv6 link-local addresses for neighbour exchanges (apart from virtual links). OSPFv3 is protocol-independent since it eliminates IP prefix information from LSAs and Hello packets.
- Authentication: Unlike OSPFv2, which use plain text or MD5, OSPFv3 relies on the standard IPv6 protocol security (IPsec) and lacks internal authentication techniques.
- LSA Types: OSPFv3 renames some LSA types (e.g., Type 3 Summary-LSAs to “inter-area-prefix-LSAs”) and adds new ones, such as Link-LSA (Type 8) and Intra-Area-Prefix-LSAs (Type 9).
- Flooding Scope: Link-local, Area, and AS scope are the three distinct flooding scopes for LSAs that OSPFv3 provides.
Use cases
OSPF’s versatility and scalability have led to its widespread adoption in a variety of environments:
- Because of their efficiency and scalability, enterprise networks are used for internal routing in campus or multi-site networks.
- Internet service providers (ISPs) use service provider networks for intra-AS routing in order to control bandwidth and expedite data delivery.
- When designing multi-area networks that need dynamic route updates for more flexibility, data centres are essential.
In order to give the customer’s OSPF routing transparency, OSPF can also be utilized with MPLS VPNs, where the VPN backbone can integrate into OSPF backbone area 0. Additional topology information can be shared for traffic control and use on non-IP networks thanks to its Traffic Engineering extensions (OSPF-TE).
Also Read About History Of Virtual Private Network And How Does VPN Works?