The open shortest path first (OSPF) protocol enables link-state routing across large and complex IP networks. These link states help track the network's topology — or the organizational hierarchy of routers and systems — within a given environment. Such environments are often called "areas" since it's possible to subdivide OSPF autonomous systems. Link states can also change the routing tables when the best path goes down.
The Internet Engineering Task Force (IETF) created OSPF 1989. Since then, numerous protocol use cases (and corresponding RFC specifications) have emerged, including a 1999 OSPF version targeting IPv6 support. The current version of OSPF is detailed within RFC 2328, while OSPF for IPv6 is described under RFC 5340.
How does open shortest path first (OSPF) work?
Each network component within the environment broadcasts a link-state advertisement (LSA) to all other devices within the network boundary. This ensures that each component is system-aware and boosts observability across the network. LSA consists of a specialized data packet containing information about each networking component's virtual neighbor — including a calculated routing cost based on how long the overall path is between points A and B. The network will favor the quickest route for future data packets.
OSPF is considered an interior gateway protocol (IGP) because it's commonly used within automated systems to exchange routing table info between routers. It also uses the shortest path first (SPF) algorithm to identify the shortest transmission distance between two network nodes.
But how does an OSPF process work from start to finish? The following steps are vital to every OSPF Hello transaction:
The
EXSTART
process kicks off the link-state database information exchange when two systems determine which is the primary and which is the secondary. This helps synchronization and prevents database corruption through packet mismatches.The
EXCHANGE
phase occurs when these two systems inspect their respective databases for unfamiliar LSAs. The network enables these systems to share Database Description packets and determine link-state sharing back and forth.Next, the
LOADING
phase occurs when both systems exchange Link State Request (LSR) packets and transmit any LSAs that were stored during theEXCHANGE
process. The neighboring system answers this request by sending LSAs via Link State Update (LSU) packets.Finally, the
FULL
process initiates once these two systems are synced up, store matching link-state data, and establish that they're adjacent to each other.
This entire process can happen automatically, yet administrators (or the router settings themselves) can then periodically check for status changes. This keeps the network and systems current while promoting continual link-state discovery.
Types of link-state advertisements (LSAs)
Once this transaction is complete, these connected systems will typically send out Link State Acknowledgement (LSAck) packets to confirm they received new LSAs. There are numerous LSA varieties that have contextual importance within an OSPF autonomous system:
Router-LSA – Generated by every router within the network, this describes both the link status and associated path cost.
Network-LSA – Generated by a designated router (DR) and broadcast across the entire area, this describes the link status of all routers contained within.
Network-summary-LSA – Generated via area border routers (ABRs), these LSAs detail networking routes to a given segment within the specific network area.
ASBR-summary-LSA – Generated by ABRs, these describe available routes to a given autonomous system boundary router (ASBR). While surrounding network areas receive this information, the area in which the ASBR resides does not.
AS-external-LSA – Generated by ASBRs, these describe routes to network nodes that exist outside the autonomous system. This is advertised everywhere aside from not-so-stubby areas (NSSAs) and stubs. NSSAs enable external route injection and are special stub areas, whereas stubs carry their own LSA advertising policies.
NSSA-LSA – Generated by an ASBR, these are only advertised within NSSAs and share routes to destinations outside of the autonomous system.
Opaque-LSA – These allow for OSPF extensions and are universal. Depending on typing, these are advertised in various areas and have varied usefulness.
Each type of area will also support or not support each of the LSA varieties described above. Common areas are generally the most supportive of different types — while totally stubby areas (which restrict routes within the area and external prefixes) have the most exceptions.
What makes the open shortest path first (OSPF) protocol useful?
While OSPF makes networks, segments, and paths more visible, it also has the following benefits:
OSPF is performant and can calculate route length — and which paths are ideal — very quickly.
Because OSPF can help segment a network into specific autonomous systems and areas, it allows for separate topologies and improved efficiency by keeping traffic split.
OSPF supports equal-cost, multipath routing for greater flexibility.
OSPF allows distant routers in an AS to update their routing tables automatically when links on other routers degrade.
OSPF continues to evolve and gain more functionality as networking needs have changed — such as with the IPv6-specific version release.
Does HAProxy support the open shortest path first (OSPF) protocol?
Yes! HAProxy Enterprise's route health injection (RHI) module supports OSPF for equal-cost, multipath routing. The OSPF protocol helps monitor your load balancer's connectivity to backend servers — letting the module remove faulty load balancers from service as needed. It also works with the BIRD dynamic IP routing daemon to broadcast network routes.
To learn more about OSPF support in HAProxy, check out our route health injection documentation.