OSPF Deep Dive: Areas, Costs, and Convergence

OSPF is the most widely used interior routing protocol. It finds the shortest path to every destination using Dijkstra's algorithm.

Break an OSPF link and trace the new path

Free interactive lab. No signup. Runs in your browser.

Quick Summary

What Is OSPF?

Open Shortest Path First (OSPF) is a link-state routing protocol used within a single autonomous system. Unlike distance-vector protocols (like RIP) where routers only know what their immediate neighbors tell them, OSPF routers build a complete topological map of the entire network. Every router in an OSPF area has an identical copy of the Link-State Database (LSDB), which describes every router, every link, and the cost of each link. From this database, each router independently runs Dijkstra's algorithm to calculate the shortest path tree rooted at itself.

OSPF was developed as a replacement for RIP, which had severe limitations -- a maximum hop count of 15, slow convergence (counting to infinity), and no support for variable-length subnet masks. OSPF, defined in RFC 2328 (OSPFv2 for IPv4) and RFC 5340 (OSPFv3 for IPv6), addresses all these limitations. It supports networks of virtually unlimited size, converges rapidly after topology changes, supports VLSM and CIDR, and uses bandwidth-based cost metrics instead of hop counts.

The name "Open Shortest Path First" refers to two things: "Open" means it is an open standard (not proprietary like EIGRP was originally), and "Shortest Path First" refers to Dijkstra's SPF algorithm that each router uses to compute optimal paths. OSPF is the most widely deployed interior gateway protocol (IGP) in enterprise and service provider networks.

Interactive: OSPF Cost and Convergence Simulator

Click on any link to "break" it (simulate a failure). Modify link costs using the controls below. Watch OSPF recalculate the shortest path tree and choose a backup route.

OSPF Area 0 (Backbone)

OSPF Area 0 R1 1.1.1.1 R2 2.2.2.2 R3 3.3.3.3 R4 4.4.4.4 R5 5.5.5.5 10 10 5 20 20 30 No direct link

Click any link (green line) to toggle it on/off. Modify costs below, then click "Run SPF".

OSPF adjacencies formed. All routers in Area 0. Click a link to break it or modify costs and run SPF...

How OSPF Works

1

Neighbor Discovery and Adjacency

OSPF routers discover each other by sending Hello packets to the multicast address 224.0.0.5 (AllSPFRouters). Hellos contain the router's ID, area ID, hello/dead timers, and the list of neighbors the router has heard from. Two routers become neighbors when they see each other's router ID in the Hello packets. On broadcast networks (like Ethernet), OSPF elects a Designated Router (DR) and Backup Designated Router (BDR) to reduce the number of adjacencies -- routers form full adjacencies only with the DR and BDR, not with every other router.

2

Link-State Advertisements (LSAs)

Once adjacency is established, routers exchange Link-State Advertisements (LSAs). Each LSA describes a piece of the network topology -- the router's interfaces, their costs, and which neighbors are reachable through each interface. LSAs are flooded throughout the OSPF area so every router has the same information. The collection of all LSAs forms the Link-State Database (LSDB). When a topology change occurs (a link goes down, a cost changes), the affected router generates a new LSA and floods it immediately, triggering all routers in the area to recalculate their routing tables.

3

SPF Calculation (Dijkstra's Algorithm)

With a complete map of the network in the LSDB, each router runs Dijkstra's Shortest Path First algorithm. Starting from itself, the router builds a shortest path tree (SPT) by iteratively selecting the unvisited router with the lowest cumulative cost. The algorithm explores all links and calculates the total cost to reach every other router in the area. The result is a routing table entry for each destination, showing the next hop and total cost. If two paths have equal cost, OSPF can install both routes for Equal-Cost Multi-Path (ECMP) load balancing.

4

OSPF Areas

Large OSPF networks are divided into areas to limit the scope of LSA flooding and reduce the size of the LSDB. Area 0 (the backbone) must be the center of the design -- all other areas must connect to Area 0. An Area Border Router (ABR) sits between areas and summarizes routes from one area into another. This hierarchical design means a link failure in Area 1 does not trigger SPF recalculation in Area 2, significantly improving convergence time and reducing CPU load in large networks.

OSPF Cost Metric

OSPF uses a cost metric that is inversely proportional to link bandwidth. The default formula is cost = reference bandwidth / interface bandwidth. With the default reference bandwidth of 100 Mbps: a 100 Mbps link has cost 1, a 10 Mbps link has cost 10, and a 1 Gbps link also has cost 1 (because the default reference is too low). Administrators often increase the reference bandwidth to 10000 (10 Gbps) or higher so that 1 Gbps and 10 Gbps links have different costs: ip ospf auto-cost reference-bandwidth 10000.

The total cost of a path is the sum of all link costs along that path. When OSPF compares two paths to the same destination, it chooses the one with the lower total cost. You can manually override the cost of any interface with the ip ospf cost command, which is useful for traffic engineering -- for example, forcing traffic over a fiber link instead of a copper link even if both have the same bandwidth. The cost manipulation is purely local to the router that sets it.

OSPF Network Types

🔌

Broadcast (Ethernet)

OSPF elects a DR and BDR on broadcast networks. All routers form adjacencies with the DR/BDR only. Hellos are sent to 224.0.0.5, LSA updates go to 224.0.0.6 (AllDRouters). This reduces the number of adjacencies from n*(n-1)/2 to just 2*(n-1).

🔄

Point-to-Point

Used on serial links and tunnels where only two routers exist. No DR/BDR election is needed since there are only two neighbors. Adjacency forms directly between the two routers. This is the simplest OSPF network type.

NBMA

Non-Broadcast Multi-Access networks (like Frame Relay) require manual neighbor configuration because multicast is not supported. A DR/BDR is still elected. This network type is increasingly rare as legacy WAN technologies are replaced by MPLS and SD-WAN.

Common OSPF Issues

Mismatched Timers

OSPF neighbors must agree on Hello and Dead timers. If one router uses Hello=10s/Dead=40s and the other uses Hello=30s/Dead=120s, they will never form an adjacency. Always verify timer settings when debugging neighbor issues.

Discontiguous Area 0

All OSPF areas must connect to Area 0. If Area 0 is split into two parts, inter-area routing breaks. Use virtual links to temporarily bridge a discontiguous backbone, but fix the physical design as soon as possible.

Reference Bandwidth Mismatch

If different routers use different reference bandwidths, they will calculate different costs for the same link. This causes asymmetric routing and suboptimal path selection. Set the same reference bandwidth on every router in the OSPF domain.

Frequently asked questions about OSPF

What does OSPF stand for?

OSPF stands for Open Shortest Path First. It is a link-state interior gateway protocol that uses Dijkstra's shortest path algorithm to build a routing table from a complete map of the network topology.

How does OSPF work?

Routers form adjacencies via Hello packets, then flood Link-State Advertisements (LSAs) describing their links. Every router builds an identical Link-State Database and independently runs Dijkstra's SPF algorithm to compute the shortest path tree from itself to every destination.

What is an OSPF area?

An OSPF area is a logical group of routers that share a full Link-State Database. Splitting a large network into areas limits LSA flooding, reduces SPF computation, and improves convergence. Area 0 is the backbone — every other area must connect to it via an Area Border Router (ABR).

How is OSPF cost calculated?

By default OSPF uses cost = reference-bandwidth / interface-bandwidth, with reference-bandwidth = 100 Mbps. That makes 100 Mbps and 1 Gbps both cost 1, so most operators raise the reference (e.g. 100000) so modern link speeds get distinct costs. You can also set the cost manually per interface.

Why won't my OSPF neighbors come up?

The usual suspects are mismatched Hello/Dead timers, mismatched area IDs, mismatched authentication, different subnet masks on the same segment, or a network-type mismatch (broadcast vs point-to-point). Check show ip ospf neighbor and show ip ospf interface on both routers.

Try OSPF yourself

You just learned how Hello, LSAs, SPF, and areas work together. Now unplug a link in a three-router OSPF topology and trace the path traffic takes instead, then switch OSPF off on one router to see what redundancy cannot save. Press Go Live and BIRD runs OSPF on real Linux routers.

Launch the OSPF lab →