Skip to content

OSPF — Open Shortest Path First

OSPF is a link-state routing protocol — routers communicate information about their own links to their neighbors, so that every router can build a complete map of the network. Faster convergence than RIP, and scales much better in large, dynamic environments. Runs on top of IP with protocol number 89.


Recap: Core Concepts

  • Link-state info = network ID + cost (based on bandwidth) of a link
  • Routers send out LSAs at regular intervals to keep neighbors up to date
  • Can account for multiple metrics → redundant paths, load balancing, QoS routing
  • Communication via multicast and unicast

Areas

An OSPF area is a group of routers that arrive at the same topology database.

Type Description
Single-area OSPF All routers in the same area — always use area 0 for future scalability
Multi-area OSPF Routers spread across multiple areas, all connected to area 0 (backbone area)

Routers on the border between the backbone and other areas → Area Border Routers (ABRs)

Benefits of multi-area

  1. Routing tables stay smaller → faster lookups
  2. Less OSPF overhead per area (fewer exchanged messages)
  3. The SPF algorithm converges faster on topology changes

OSPFv2 vs OSPFv3

OSPFv2 OSPFv3
IPv4 ✓ ✓
IPv6 — ✓

Message Types

Routers exchange information via 5 types of messages:

Type Function
Hello Establish and maintain neighbor adjacencies
Database Description (DBD) Exchange a summary of the topology database
Link-State Request (LSR) Request more detailed info
Link-State Update (LSU) Deliver detailed topology info
LS Acknowledge (LSAck) Confirm receipt of a DBD

LSR, LSU and LSAck are collectively called LSAs (Link-State Advertisements).


Tables

Every OSPF router builds three tables:

Table Contents Query
Neighbour table Neighbor routers in the area show ip ospf neighbor
Topology table Complete map of the area show ip ospf database
Routing table Best routes based on SPF show ip route

Neighbor Adjacencies

Hello messages are sent to multicast 224.0.0.5 (IPv4) or FF02::5 (IPv6).

Every router has a unique router ID (32-bit, looks like an IPv4 address) that is included in hello messages. When a router receives a hello with an unknown router ID → it adds it to the neighbor list → also sends a hello back → neighbor adjacency established.

Building the topology database

  1. After adjacency: exchange DBD messages
  2. Acknowledge DBD receipt with LSAck
  3. For unknown info: send an LSR
  4. The LSR is answered with an LSU
  5. LSUs are also sent on every topology change and by default every 30 minutes

Type Description
Stub network End network — a router connected to hosts/switches but no other routers
Point-to-point Direct connection between two routers
Multi-access Multiple routers connected to the same broadcast domain (via a switch)

OSPF Overhead & DR/BDR

On a multi-access link with many routers, the number of adjacencies rises quickly: n(n-1)/2. With 5 routers that's already 10 adjacencies — which produces a lot of OSPF traffic, especially with changes and the periodic LSUs.

Solution: elect a Designated Router (DR).

  • The DR collects all LSAs and distributes the topology info to all other routers
  • The BDR (Backup DR) takes over if the DR fails
  • All other routers are DROTHERs — they send only to the DR/BDR via 224.0.0.6 (IPv4) / FF02::6 (IPv6)

Router ID and Election

The router ID determines who becomes DR and BDR:

  • On a point-to-point link: the router with the highest ID starts sending DBDs first
  • On a multi-access link: the router with the highest ID becomes DR, the second-highest becomes BDR

Determining the router ID (in priority order): 1. Explicitly configured router ID 2. Highest IP of a loopback interface 3. Highest IP of an active physical interface