How OSPF Builds Its View of the Network

Unlike distance-vector protocols (RIP, EIGRP) that only know "how far to get somewhere," OSPF is a link-state protocol โ€” every router builds a complete map of the entire topology. This map is called the LSDB (Link State Database). Once every router has an identical LSDB, they each independently run Dijkstra's shortest-path-first (SPF) algorithm to calculate the best routes.

This is why OSPF converges faster and avoids routing loops: every router has complete information, not just a rumor about the best next hop.

LSA Types: The Building Blocks of the LSDB

The LSDB is populated by LSAs. There are 7 relevant LSA types โ€” knowing which does what is critical for troubleshooting:

Type 1 โ€” Router LSA

Generated by every OSPF router. Describes the router's directly connected links and their states. Flooded only within the originating area.

Type 2 โ€” Network LSA

Generated by the DR (Designated Router) on multi-access networks (Ethernet). Represents the network segment and lists all attached routers. Also area-local.

Type 3 โ€” Summary LSA

Generated by ABRs (Area Border Routers). Carries route information between areas. This is how Area 1 learns about routes in Area 2 โ€” the ABR translates Type 1/2 LSAs into Type 3s and floods them into connected areas.

Type 4 โ€” ASBR Summary LSA

Also generated by ABRs. Tells routers in other areas how to reach an ASBR (Autonomous System Boundary Router) โ€” a router redistributing external routes into OSPF.

Type 5 โ€” AS External LSA

Generated by ASBRs. Carries external route information (routes redistributed from BGP, static routes, etc.) and flooded to the entire OSPF domain (except stub areas).

Type 7 โ€” NSSA External LSA

Like Type 5, but used within NSSA (Not-So-Stubby Areas). The ABR converts Type 7s to Type 5s when forwarding them to the backbone.

Area Design: Why It Matters

In a small network, one area (Area 0) is fine. But as networks grow, a flat OSPF design becomes a problem. Every topology change triggers an SPF recalculation on every router. With hundreds of routers and frequent changes, this is CPU-intensive and increases convergence time.

The solution: hierarchical area design. All areas connect to Area 0 (the backbone). ABRs sit at the boundary.

Area Types and Their Purpose

  • Backbone (Area 0): All inter-area traffic must transit Area 0. ABRs have one interface in Area 0.
  • Regular Area: Accepts all LSA types. Standard configuration.
  • Stub Area: Blocks Type 5 (external) LSAs. ABR injects a default route instead. Reduces LSDB size for areas with no need for external routes.
  • Totally Stubby Area (Cisco): Blocks Type 3, 4, and 5. Only a default route enters. Smallest possible LSDB. Best for remote branch areas with a single exit point.
  • NSSA: Allows redistribution of external routes within the area (via Type 7 LSAs) while still blocking Type 5s. Used when an area needs its own ASBR.

DR and BDR Elections

On multi-access networks (Ethernet segments with 3+ OSPF routers), OSPF elects a Designated Router (DR) and Backup DR (BDR). Without this, every router would form a full mesh of adjacencies โ€” n(n-1)/2 sessions.

Instead, all routers form adjacencies only with the DR and BDR. The DR is responsible for generating the Type 2 LSA and flooding updates on behalf of the segment.

Election process:

  1. Highest OSPF priority (0โ€“255, default 1) wins. Priority 0 = never become DR.
  2. Tie-break: highest Router ID (highest loopback IP, or highest interface IP).
  3. Election is non-preemptive once complete. A new, higher-priority router won't unseat an existing DR without a network event.
! Force a router to always become DR
interface GigabitEthernet0/0
 ip ospf priority 255

! Prevent a router from ever becoming DR
interface GigabitEthernet0/0
 ip ospf priority 0

The SPF Algorithm: Dijkstra Under the Hood

Once all LSAs are received and the LSDB is complete, OSPF runs Dijkstra's algorithm. The process:

  1. Place the local router in the SPF tree as root with cost 0
  2. Examine all links from the current node; calculate cumulative cost to each neighbor
  3. Add the lowest-cost unvisited neighbor to the tree
  4. Repeat from step 2 until all nodes are in the tree

The result is a shortest-path tree rooted at your router. OSPF cost is calculated as: reference bandwidth / interface bandwidth. Default reference: 100 Mbps.

! This means:
! FastEthernet (100Mbps): cost = 100/100 = 1
! GigabitEthernet (1Gbps): cost = 100/1000 = 0.1 โ†’ rounded up to 1
! (same as FastEthernet! Increase reference bandwidth)

router ospf 1
 auto-cost reference-bandwidth 10000   ! 10 Gbps reference
 ! Now GigabitEthernet cost = 10000/1000 = 10
 ! 10GigE cost = 10000/10000 = 1

OSPF Timers and Convergence Tuning

OSPF uses two critical timers for detecting link failures:

  • Hello interval: How often HELLO packets are sent (default 10s on broadcast, 30s on NBMA)
  • Dead interval: How long without a HELLO before the neighbor is declared dead (default 4ร— hello = 40s)

For fast convergence, you can reduce these โ€” but both sides must match:

interface GigabitEthernet0/0
 ip ospf hello-interval 1
 ip ospf dead-interval 3

For sub-second convergence, use BFD (Bidirectional Forwarding Detection) alongside OSPF. BFD detects link failures in milliseconds and notifies OSPF to trigger reconvergence immediately.

Troubleshooting Adjacency Issues

OSPF neighbors must agree on: hello/dead timers, area ID, authentication, stub area flag, and MTU (with ip ospf mtu-ignore if needed). The most common stuck state is 2WAY โ€” this is normal for non-DR/BDR routers on broadcast networks. The full adjacency state you want is FULL.

! Key diagnostic commands
show ip ospf neighbor          ! Check neighbor states
show ip ospf database          ! View the LSDB
show ip ospf interface brief   ! Verify areas, costs, DR/BDR
debug ip ospf adj              ! Watch adjacency formation (use carefully!)

Key Takeaways

  • OSPF builds a complete topology map (LSDB) from LSAs; each router runs SPF independently
  • Know your LSA types 1โ€“5 and 7 โ€” they're essential for troubleshooting inter-area routing
  • Use stub/totally stubby areas to reduce LSDB size in areas with single exit points
  • Always set reference bandwidth to match your fastest links
  • Use BFD for sub-second failure detection