Open Shortest Path First (OSPF)

Simulation
Introduced by
John Moy
Year
1998
Type
link-state routing protocol
Family
Routing protocol

What does it do?

OSPF is a link-state interior gateway protocol (IGP) for routing within a single autonomous system.

Its version 2 specification, documented in RFC 2328 by John Moy (1998), describes how routers exchange topology information and compute paths. It is widely deployed in enterprise and ISP networks for intra-domain routing, although some large backbones prefer IS-IS.

The intuition behind the method

OSPF is a link-state protocol: each router floods information about its directly connected links to the other routers in its area. Once the flooding has synchronised, every router holds the same topology database and independently runs Dijkstra's algorithm over it to compute shortest paths. Distance-vector protocols such as RIP exchange only summaries of best paths, so no router sees the full topology and convergence is typically slower. Because all routers work from the same map, their forwarding decisions are mutually consistent, and where several paths tie on total cost, the shortest-path calculation can record all of them for equal-cost multipath (ECMP).

History

OSPF was developed as a link-state alternative to distance-vector protocols such as RIP. The version 2 specification used for IPv4 is documented in RFC 2328 by John Moy (1998). IPv6 support is specified separately as OSPFv3 in RFC 5340 (Coltun et al., 2008). Later extensions, such as the not-so-stubby area (NSSA), were added as separate specifications, and IS-IS is a different protocol rather than an OSPF feature.

When to use it

Choose OSPF for enterprise campus and mid-size ISP networks that need an open-standard IGP with fast convergence and a full topology view. It suits networks where the operator can plan areas and set link costs to reflect capacity or policy. Do not rely on OSPF alone for policy-based routing or for routing between autonomous systems, which is the role of BGP. For very large single-domain networks, many operators consider IS-IS; the choice is a design judgement rather than a fixed size threshold. Areas provide hierarchical scaling but add configuration complexity, so a single-area design can be simpler for small networks.

Limitations and considerations

  • Computation load: each router runs Dijkstra over its area topology, so CPU use grows with area size and topology churn.
  • Flooding overhead: LSA flooding and periodic refreshes consume bandwidth and processing, particularly in large or unstable areas.
  • Area design: the backbone (Area 0) must connect all areas, and inter-area traffic transits it, so poor area boundaries lead to suboptimal routing.
  • Intra-domain scope: OSPF does not carry inter-domain routing policy; BGP is used between autonomous systems.
  • Default cost depends on a reference bandwidth: the default cost is derived from a 100 Mbps reference, so networks with mixed link speeds usually need explicit cost tuning.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Fast convergence: a link change triggers flooding and a local shortest-path recalculation, so routers reconverge without waiting for periodic route updates.
  • Shortest-path routing: Dijkstra's algorithm gives each router minimum-cost paths over the topology it holds.
  • ECMP: when several paths tie on total cost, they can all be used for forwarding, spreading load across them.
  • Hierarchical areas: flooding is confined within an area, which limits the size of each router's database and the scope of flooding.
  • Cost-based metric: path cost is the sum of configured interface costs rather than a hop count, so paths can reflect link bandwidth or operator preference.

Applications

  • Enterprise campus networks: dynamic routing across multi-building campuses.
  • ISP edge networks: routing between edge routers and the core.
  • Data centre infrastructure: some fabric designs use OSPF or IS-IS as the underlying routing layer.
  • MPLS backbones: the IGP topology, which OSPF can provide, is used as the basis for label-switched path computation.
  • Backup routing: fast-reroute extensions, where an implementation supports them, can protect critical paths.

How it works

How it works

1

Each router discovers its neighbours by exchanging HELLO packets on its interfaces. The packets carry the router ID and network information that allow adjacencies to form. On multi-access segments (broadcast and NBMA networks), the HELLO exchange also elects a Designated Router (DR) and a Backup Designated Router (BDR). Routers then form full adjacencies only with the DR and BDR rather than with every other router, which keeps the number of adjacencies and LSA exchanges well below a full mesh. Each neighbour relationship progresses through the states Init, 2-Way, ExStart, Exchange, Loading and Full before the link-state databases are fully synchronised, and the hello and dead intervals must match between neighbours for this progression to succeed.

2

Each router describes its directly connected links and their costs in link-state advertisements (LSAs) and floods them to the other routers in its area.

3

Routers install received LSAs into a link-state database. Sequence numbers allow a router to recognise and discard duplicate or older copies, so every router in an area ends up with the same database.

4

Each router runs Dijkstra's shortest path first algorithm over the link-state database, rooted at itself, to build a shortest-path tree to every destination.

5

Forwarding uses routes derived from this tree. Where several paths have equal total cost, they can all be installed for ECMP. Precomputed backup paths for fast reroute are an extension offered by some implementations, not part of the base algorithm.

Common pitfalls

  • Area boundary errors: placing routers or links in the wrong area, or partitioning Area 0, can split the backbone and force inter-area traffic onto non-optimal paths.
  • Aggressive timer settings: very frequent LSA refresh increases CPU and flooding load, and hello and dead intervals must match between neighbours or adjacencies will not form.
  • Assuming ECMP is automatic: OSPF installs multiple next hops only when paths have equal cost, and how traffic is hashed across them depends on the platform.
  • Stub area mismatch: all routers attached to a stub area must agree on its configuration; a mismatch prevents adjacency and can remove external reachability from part of the area.

Frequently asked questions

What is an area in OSPF?

An area is a contiguous network segment. Area 0 (backbone) connects all areas. Routers flood LSAs only within areas, reducing overhead. Inter-area routing is handled by Area Border Routers (ABRs).

How does OSPF handle interface cost?

OSPF metric is the sum of link costs. By default, cost = 100 Mbps / interface bandwidth, that is, the default is calculated from a 100 Mbps reference bandwidth. Link cost is tunable, allowing operators to influence path selection.

What is ECMP in OSPF?

Equal-Cost Multipath: when several paths to a destination have the same total cost, OSPF can install all of them, and forwarding spreads traffic across them. OSPF computes these paths itself, but whether the platform actually distributes traffic over them depends on its forwarding configuration.

What are stub and NSSA areas?

Stub areas reduce LSA flooding by not receiving external routes (LSA type 5). NSSA (Not-So-Stubby Area) is a variant allowing selective external route advertisement.

Related methods

Sources

  1. Moy, J. T. (1998). OSPF Version 2. RFC 2328.

    Open publication reference
  2. Coltun, R., Ferguson, D., Moy, J., & Lindem, A. (2008). OSPF for IPv6. RFC 5340.

    Open publication reference