Sub topic 8
The Link-State Database and LSA Flooding
This chapter covers how OSPF routers store topology information and how they distribute it. It assumes you know the neighbor state machine from the previous chapter, IPv4 addressing, and the basic idea that every router in an area must hold the same map before it runs SPF.
What the LSDB Is
The link-state database (LSDB) is the set of all link-state advertisements (LSAs) a router has received for an area. An LSA is a small record that describes one piece of the topology, such as a router's links or a multi-access segment.
Three rules define how the LSDB works:
- Every router in an area holds an identical LSDB for that area.
- Each router runs SPF on its own copy. The routing table is a result of the LSDB, not part of it.
- A router keeps a separate LSDB for each area it belongs to.
If two routers in the same area disagree about the LSDB, they can compute different paths, and that can cause loops. Flooding exists to prevent this.
Anatomy of an LSA
Every LSA starts with a 20-byte header. Three header fields identify an LSA, and three more decide which copy of it is newer.
| Field | Purpose |
|---|---|
| LS type | The kind of LSA (1 through 5 are covered in a later chapter) |
| Link-state ID | Identifies the piece of topology. Its meaning depends on the LS type |
| Advertising router | The router ID of the router that originated the LSA |
| LS sequence number | A 32-bit signed number that increases with each new version |
| LS age | Seconds since the LSA was originated, from 0 up to 3600 (MaxAge) |
| Checksum | Detects corruption of the LSA contents |
The LS type, link-state ID, and advertising router together form the LSA's unique key. Two LSAs with the same key are two versions of the same record.
Choosing the Newer Copy
When a router receives an LSA it already has, it must decide which copy is newer. It compares in this order:
- The higher sequence number wins.
- If the sequence numbers match, the higher checksum wins.
- If the checksums match, an LSA with age MaxAge wins.
- If the ages differ by more than 15 minutes (MaxAgeDiff), the younger one wins.
- Otherwise the copies are treated as identical.
The originating router increments the sequence number each time the LSA changes. It also refreshes every LSA every 30 minutes (LSRefreshTime) even if nothing changed, so a stable network still sees periodic traffic. Each refresh increments the sequence number. When an LSA reaches age 3600 seconds, routers remove it from their LSDBs.
The Three Packets Used to Exchange LSAs
The previous chapters introduced the five OSPF packet types. Three of them move LSAs:
- Link-State Request (LSR, type 3): asks a neighbor for specific LSAs by key.
- Link-State Update (LSU, type 4): carries one or more full LSAs.
- Link-State Acknowledgment (LSAck, type 5): confirms receipt of LSAs. It carries only LSA headers.
Database Description (DBD) packets, from the ExStart and Exchange states, carry LSA headers only. They let two neighbors compare databases without sending everything.
Initial Synchronization
During Exchange and Loading, neighbors synchronize their LSDBs.
- In Exchange, each router sends DBD packets that list the headers of every LSA it holds.
- Each router compares the received headers with its own LSDB.
- For any LSA it lacks, or any LSA for which the neighbor's copy is newer, it adds an entry to its request list.
- In Loading, it sends LSRs for those entries.
- The neighbor answers with LSUs containing the full LSAs.
- When every request is satisfied, the neighbors reach Full.
Only routers that reach Full are adjacent, and only adjacent routers exchange LSAs. This is why the DR election matters on multi-access segments: it limits how many adjacencies must be synchronized.
Flooding a Change
After initial synchronization, flooding keeps the databases aligned. When a link changes, the router that owns it originates a new LSA with a higher sequence number.
The flooding procedure for each received LSA works like this:
- Validate the checksum and the LS type. Discard invalid LSAs.
- If the router has no copy, or the received copy is newer, install it in the LSDB.
- Acknowledge the LSA.
- Forward it out every eligible interface except the one it arrived on. On a broadcast segment, the router sends to a multicast address instead of to each neighbor.
- Schedule an SPF run.
- If the router's own copy is newer, send that copy back to the neighbor.
A router that does not receive an LSAck retransmits the LSU to that neighbor. The default retransmit interval is 5 seconds. Flooding is therefore reliable, unlike the Hello protocol, which relies on repetition.
Flooding on Multi-Access Segments
On a broadcast segment, flooding uses two multicast addresses:
- 224.0.0.5 (AllSPFRouters) reaches every OSPF router.
- 224.0.0.6 (AllDRouters) reaches only the DR and BDR.
A DROther router that learns of a change sends its LSU to 224.0.0.6. The DR then floods the LSA to 224.0.0.5. The BDR listens and takes over if the DR fails to flood. This keeps the update count low: the change goes to the DR once, and the DR repeats it once for everyone.
Viewing the LSDB
Use the database command from the verification chapter to inspect the LSDB.
show ip ospf databaseThe output lists each LSA with its link-state ID, advertising router, age, sequence number, and checksum. Read it with these checks in mind:
- A very low age on an LSA that should be stable means it is being re-originated often. Look for a flapping link.
- Sequence numbers that climb fast point to the same cause.
- The same LSA with different sequence numbers on two routers means flooding has not finished, or is blocked.
Common Problems
- Stuck in Loading or ExStart: often an MTU mismatch. DBD packets are too large for one side. Both ends must agree on the interface MTU.
- LSDB differs between routers: a router without a Full adjacency does not receive LSAs. Check the neighbor table first.
- Constant SPF runs: a flapping link makes its owner originate new LSAs repeatedly. Every router in the area reruns SPF each time, so fix the link instead of tuning timers.
- Large LSDB on small routers: this is why areas exist. Each area has its own LSDB, so splitting a large network limits both memory use and flooding scope.
Exercise
Router A holds an LSA with sequence number 0x80000010 and age 120 seconds. A neighbor sends the same LSA (same type, link-state ID, and advertising router) with sequence number 0x80000012. What does Router A do, and which packet does it send back?
Show answer
The neighbor's copy has the higher sequence number, so it is newer. Router A installs it in its LSDB, replaces the old copy, schedules an SPF run, and floods the LSA out its other eligible interfaces. It sends a Link-State Acknowledgment (LSAck) to the neighbor to confirm receipt.
Exercise
On a broadcast segment, a DROther router detects a link change. To which multicast address does it send the LSU, and who forwards it to the rest of the segment?
Show answer
It sends the LSU to 224.0.0.6 (AllDRouters). The DR receives it and floods it to 224.0.0.5 (AllSPFRouters), so every router on the segment gets one copy.