Sub topic 14
The link-state database
This chapter assumes you know how link-state routers flood advertisements (LSAs) and the basics of Dijkstra's algorithm. It covers what the database holds, how routers keep it consistent, and what goes wrong when it isn't.
What the database contains
The link-state database (LSDB) is the set of all LSAs a router has received, plus the ones it originated itself. Each LSA is one router's statement about its own links: its neighbors, the cost to each, and the attached networks.
Every router in the flooding scope (an OSPF area, or an IS-IS level) should hold an identical copy. Each router then runs SPF on its own copy. Identical input gives consistent paths, which is why link-state networks rarely form loops in steady state.
Anatomy of an LSA entry
Each entry carries bookkeeping fields next to its content.
| Field | Purpose |
|---|---|
| Advertising router | Identifies who originated the LSA |
| Sequence number | A higher number means newer information |
| Age | Counts up, and the entry is purged at the maximum age |
| Checksum | Detects corruption in storage or transit |
When an LSA arrives, the router compares it with the stored copy. A newer sequence number replaces the old entry, gets flooded onward, and triggers a new SPF run. An older or identical copy is discarded. The originator refreshes its LSAs periodically, which is how dead routers eventually disappear from the database.
From database to graph
SPF needs a graph, not a pile of advertisements. The router builds one from the LSDB and keeps a link only if both ends advertise it. This two-way check stops a router from using a link that the far side has stopped claiming.
lsdb = {
"A": {"B": 1, "C": 4},
"B": {"A": 1, "C": 2},
"C": {"A": 4, "B": 2, "D": 1},
"D": {"C": 1},
}
def to_graph(lsdb):
return {
r: {n: c for n, c in links.items() if r in lsdb.get(n, {})}
for r, links in lsdb.items()
}
print(to_graph(lsdb))If C stopped listing D, the link C–D would vanish in both directions, even though D still lists C.
Synchronization and common errors
A new adjacency does not start empty. The two routers first exchange summaries of their databases, then request only the entries they are missing. After that, flooding keeps the copies in step.
Typical failures:
- Stuck during database exchange. In OSPF, an MTU mismatch between neighbors is a frequent cause.
- Databases that differ. Routers in one area compute paths from different maps, which can cause loops or black holes.
- Duplicate router IDs. Two routers originate LSAs under one identity and overwrite each other's entries.
- Flapping links. Each change triggers flooding and SPF everywhere in the area, so a large database magnifies the cost.
Exercise
Router C's LSA lists a link to D with cost 1, but D's LSA no longer lists C. What does a router do with the C–D link when it builds the SPF graph, and why?
Show answer
It leaves the link out. The two-way check requires both routers to advertise the link. A one-sided claim may be stale or the link may be broken, so using it could send traffic into a dead path.