OSPF (Open Shortest Path First) is a link-state routing protocol, and the LSDB (Link-State Database) and SPF (Shortest Path First) algorithm are core to how OSPF calculates the best paths.
Let’s break them down.
🧠 What is the OSPF LSDB (Link-State Database)?
The LSDB is a map of the entire OSPF network area — each router stores a complete topology of its area.
🔍 Details:
-
Built from LSAs (Link-State Advertisements) exchanged between routers.
-
Contains info about:
-
Routers and their interfaces
-
Network segments
-
Neighbor relationships
-
-
Each OSPF router maintains an identical LSDB within the same area.
✅ Key Characteristics:
Feature Description Scope One LSDB per OSPF area Source Built from received LSAs Consistency All routers in an area have identical LSDBs Purpose Used as input for SPF algorithm to calculate best paths
⚙️ How the SPF Algorithm Works in OSPF
Feature | Description |
---|---|
Scope | One LSDB per OSPF area |
Source | Built from received LSAs |
Consistency | All routers in an area have identical LSDBs |
Purpose | Used as input for SPF algorithm to calculate best paths |
OSPF uses Dijkstra’s Shortest Path First (SPF) algorithm to compute the shortest (lowest-cost) path to every destination.
🧮 Step-by-Step: SPF Algorithm Process
-
Start with Self
The router places itself as the root of the shortest path tree. -
Add Direct Neighbors
It evaluates directly connected routers/networks and places them in a candidate list, ordered by cost. -
Select the Shortest Path
From the list, the node with the lowest cost is added to the SPF tree. -
Expand Outward
The router repeats the process for all newly added nodes, calculating cumulative costs. -
Complete the Tree
When all nodes are processed, the SPF tree is complete. The routing table is built from this tree.
🌐 Visual Example (Simplified):
Suppose R1 connects to R2 and R3:
-
R1 → R2 (Cost 10)
-
R1 → R3 (Cost 20)
-
R2 → R4 (Cost 5)
-
R3 → R4 (Cost 10)
SPF will find:
-
R1 → R2 → R4 (total cost = 15) is better than
-
R1 → R3 → R4 (total cost = 30)
So R1 routes to R4 via R2.
🧩 LSDB + SPF = OSPF’s Power
-
The LSDB gives a complete network map (in contrast to distance-vector protocols like RIP that only know about next hops).
-
The SPF algorithm guarantees loop-free, efficient path selection.
-
Whenever the LSDB changes (due to a topology update), the SPF is rerun to recalculate routes.
✅ Summary
Term | Meaning |
---|---|
LSDB | A synchronized map of OSPF area topology built from LSAs |
SPF Algorithm | Dijkstra-based logic that computes shortest paths from LSDB |
Result | A complete, loop-free routing table with lowest-cost paths |