OSPF · Topic 1 of 5
Link State Database, Packet Types and Router ID
Learn the OSPF link state database, the five OSPF packet types, SPF calculation and how Junos chooses and sets the OSPF router ID for the JN0-352 exam.
- 5 min
- Routers flood LSAs, store them in the LSDB, then run SPF.
- All routers in one area hold an identical LSDB.
- Packet types: 1 Hello, 2 DBD, 3 LSR, 4 LSU, 5 LSAck.
What it is
OSPF is a link state protocol. Every router describes its own links in messages called link state advertisements (LSAs), and floods them to all routers in the area. Each router stores what it receives in the link state database (LSDB).
All routers in one area end up with an identical LSDB. Each router then runs the shortest path first (SPF) algorithm on that database, with itself as the root, and installs the best routes in the routing table.
The router ID is the 32-bit number, written like an IPv4 address, that identifies a router in the LSDB and in every OSPF packet it sends.
How it works
The link state database
The LSDB holds one LSA per advertising router and per link or prefix. An LSA is identified by its type, its link state ID and the advertising router. It also carries a sequence number and an age.
- A higher sequence number is a newer LSA.
- The originating router refreshes its LSAs before they expire, with a new sequence number. The standard refresh time is 30 minutes; Junos uses 50 minutes by default (
lsa-refresh-interval). - An LSA reaching an age of 60 minutes (MaxAge) is removed from the database.
When the topology changes, the router that sees the change floods a new LSA, and every router in the area re-runs SPF.
user@router> show ospf database
OSPF database, Area 0.0.0.0
Type ID Adv Rtr Seq Age Opt Cksum Len
Router *10.255.0.1 10.255.0.1 0x80000007 212 0x22 0x4a1c 60
Router 10.255.0.2 10.255.0.2 0x80000005 198 0x22 0x7e21 60
Network 10.1.1.2 10.255.0.2 0x80000002 198 0x22 0x91d0 32
The asterisk marks an LSA the local router originated. Add extensive for the full content, or a type (router, network, netsummary, asbrsummary, external, nssa) to filter. The LSDB is kept per area, so each area gets its own section.
The five OSPF packet types
OSPF runs directly over IP as protocol 89. It does not use TCP or UDP. OSPFv2 sends to the multicast address 224.0.0.5 (all OSPF routers) and, for the designated router, 224.0.0.6.
| Type | Name | Purpose |
|---|---|---|
| 1 | Hello | Discover neighbors, check parameters, keep adjacencies alive, elect the DR and BDR |
| 2 | Database description (DBD) | Summarize the contents of the LSDB when an adjacency forms |
| 3 | Link state request (LSR) | Ask for a full LSA the router is missing or has an old copy of |
| 4 | Link state update (LSU) | Carry full LSAs, used in flooding and in answers to requests |
| 5 | Link state acknowledgment (LSAck) | Confirm receipt of LSAs, which makes flooding reliable |
Hello packets carry values that must match for a neighbor to be accepted. These are the area ID, the hello and dead intervals, the authentication type and key, the subnet mask on broadcast links and the stub area flag. Junos defaults are a hello interval of 10 seconds and a dead interval of 40 seconds.
The router ID
Every OSPF router must have a unique router ID. Junos OS takes it from the first address it finds, which is normally the loopback address, unless you set it. Do not rely on that, because adding an interface address can change the router ID after a restart of the process.
Configure it explicitly under routing-options, because it is shared with other protocols such as BGP:
user@router# set routing-options router-id 10.255.0.1
| Fact | Detail |
|---|---|
| Format | 32 bits, written in dotted decimal |
| Must be unique | Duplicate router IDs in an area cause LSA conflicts and unstable routing |
| Must it be a reachable address | No, but using the loopback address is good practice |
| After you change it | The OSPF adjacencies are reset to use the new ID |
| OSPFv3 | Still a 32-bit ID; configure it, because an IPv6 only router has no IPv4 address to take it from |
user@router> show ospf overview
Instance: master
Router ID: 10.255.0.1
Route table index: 0
Area: 0.0.0.0
Stub type: Not Stub
Authentication Type: None
Area border routers: 0, AS boundary routers: 0
show ospf overview shows the router ID, the areas and their stub type and authentication.
When two routers appear as one in the LSDB, or an LSA keeps being replaced, suspect duplicate router IDs. Check show ospf overview on both routers.
Common mistakes
Letting Junos pick the router ID. It may change when interface addresses change. Set routing-options router-id and keep it stable.
Believing OSPF uses TCP or UDP. It is IP protocol 89, so a firewall filter must match protocol ospf.
Comparing an LSA's age with the refresh time. LSAs are refreshed before they reach 60 minutes (every 30 minutes in the standard, 50 minutes by default in Junos) and expire at 60 minutes.
Reading the LSDB as one table for the whole network. There is one LSDB per area, plus the AS wide external LSAs.
A firewall filter on lo0.0 that does not accept OSPF will stop adjacencies from forming. OSPF packets to the router are local traffic, so the loopback filter sees them.
What to remember for the exam
- Routers flood LSAs, store them in the LSDB, then run SPF.
- All routers in one area hold an identical LSDB.
- Packet types: 1 Hello, 2 DBD, 3 LSR, 4 LSU, 5 LSAck.
- OSPF is IP protocol 89, multicast
224.0.0.5and224.0.0.6. - Junos default hello 10 seconds, dead 40 seconds.
- LSAs age out at 60 minutes (MaxAge); they are refreshed before that, every 50 minutes by default in Junos.
- Set the router ID with
routing-options router-id; it must be unique. show ospf database,show ospf overviewandshow ospf neighborare the first commands.
Check yourself
Which OSPF packet type carries the full LSAs?
The link state update (type 4), which is used for flooding and for answering link state requests.
What are the Junos default hello and dead intervals?
Hello 10 seconds and dead 40 seconds.
Why should you configure the router ID explicitly?
Without it Junos picks an interface address, which may change, and a changed router ID resets the adjacencies and can create duplicates.
Topic 1 of 5 in OSPF
Test yourself on OSPF
The full Juniper JNCIS-ENT JN0-352 question bank has 846 questions, with timed practice exams and an explanation for every answer.
This study guide is independent and is not affiliated with, endorsed by, or sponsored by Juniper. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.