Open Shortest Path First (OSPF) is a link-state interior gateway protocol. OSPF discovers neighbors and floods LSAs with routing information within an AS.
The Link State DataBase (LSDB) stores Link State Advertisements (LSAs) as a series of records. All routers in an OSPF-area must have an identical LSDB to ensure accurate routing.
The SPF- (or Dijkstra) algorithm is performed by creating a tree of the shortest paths and picking the best candidate from that tree.
The results of the algorithm are handed to the routing table for forwarding.
OSPF packet types;
Type 1: Hello.
Type 2: Database Description.
Type 3: Link-State Request. LSR
Type 4: Link-State Update LSU
Type 5: Link-State Acknowledgement LSAc
LSAs are flooded reliably through use of LSR, LSU and LSAc.
Type 1: Hello Packet.
Multicast Hello packets are periodically sent to 184.108.40.206 – the all OSPF routers address. They establish and maintain OSPF neighbor relationships and are sent every 10 seconds by default.
Hellos consist of the OSPF-header and include the following fields (bold must match);
• Network mask: evaluated only on broadcast links (not required on p2p-links).
• Hello interval: how often Hellos are sent.
• Dead Interval: (keepalive) time to wait before the adjacency is removed.
• Options: 8-bit field for things like Stub-area etc.
• Router, Priority, DR, BDR & Neighbor.
Type 2: Database Description (DD).
DD’s are only used during adjacency formation and have two purposes:
1. determine who is in charge of database synchronization (highest RID is master)
2. transfer LSA headers between routers
DD packets contain:
- 24-byte OSPF header
- sequence number (set by master)
Type 3 : Link State Request.
LSR is used to request the version of the database and consists of;
- header, link-state type, link-state ID and advertising router.
Example; after receiving DD’s, a router discovers new LSAs. The router will then sent LSR’s that contain the LSA header for the missing link.
Type 4: Link State Update.
Can carry multiple LSAs and are sent to 220.127.116.11 OR 18.104.22.168 (DRs).
LSU consists of OSPF header, number of advertisements and LSA’s.
Two start events can trigger LSU:
1. response to LSR during adjacency database synchronization
2. link changes
Type 5: LSAc.
LSAc’s are received in response to LSUs and contain 1 or more LSA-headers. LSAc’s are sent as unicast forming the basis of reliable flooding.
R1: LSR -> R2
OSPF adjacency formation.
1. Down: OSPF is awaiting a start event.
2. Init: Hello sent, bidirectional communication not yet established.
3. 2Way: Hello with neighbor RID received, bidirectional communication achieved.
4. ExStart: routers determine master of synchronization process.
5. ExChange: routers exchanging LSAs and transmitting LSRs.
6. Loading: router finished transmitting database but still receiving information.
7. Full: databases synchronized, network link can be advertised to OSPF network.
On a broadcast medium, a single DR represents the link to the rest of the network.
- DR: based on prio (default 128) and RID; remains DR until it leaves the network.
- BDR: monitors DR and serves as a backup. DR & BDR have full relation.
- DRother: forms two-way neighbor states with other DRothers, forms full with BDR and DR.
DR election takes 40 seconds. Mitigated by using ‘interface-type p2p’. Additional benefit of ‘p2p’: no type 2 LSA is generated describing the multi-access segment, thus reducing LSDB.
Areas restrict flooding and enable summarization (hides instability and reduces LSDB).
Routers maintain an identical copy of the LSDB on a per area basis. All areas must connect themselves to the backbone area (0).
Area Border Router: ABR. Router with links in two areas. Connects areas to the backbone.
Autonomous System Boundary Router: ASBR: router that injects information from outside the OSPF-AS.
Backbone Router: any router with a link to area 0.
Internal Router: all the routers’ links are within 1 area. If the area is 0, the router is a backbone router.
OSPF Area types.
OSPF-routing information is classified in;
- inter-area or internal routes: routes generated from within an area where the destination belongs to the area.
- intra-area or summary routes: routes that originate from other areas.
- external routes: routes originating from outside OSPF or another OSPF process.
Stub area: does not contain external routes and cannot contain ASBRs. Normally, a default route is injected into a stub area by an ABR (through explicit config).
Totally Stubby Area: receives only a default route from the backbone. ABRs do not flood LSA 3, 4 or 5.
NSSA: allows external routes to be flooded into the area. ABR still does not flood LSA 4&5 into NSSA.
Overview of LSA packet types.
Type 1, Router LSA:
describes the interfaces and neighbors of each OSPF router to all other OSPF routers within the same area (intra-area).
Type 2, Network LSA:
describe all routers attached to Ethernet-segment. Sent by DR to all routers within the same area.
Type 3, Summary LSA:
sent into other areas by ABR (interarea), describing Router & Network LSAs. As summary LSAs are injected into other areas, the LSA-type never changes. Cost and advertising router do change.
Type 4, ASBR summary:
describe router-id of ASBR located in remote areas. LSA is sent by ABR attached to the area. LSA type never changes, cost and advertising router does.
Type 5, External LSAs:
describe prefixes redistributed from other protocols. Sent by ASBR injecting externals into OSPF. By default, LSAs marked type 2 (unalterable cost), can be altered to type 1. Flooded to all areas except stub areas.
Type 7, NSSA external LSAs:
describe prefixes from other protocols sent by ASBR in NSSA. LSA type 7 are translated to type 5 LSA by ABR attached to NSSA area.
Stub area allows type 1, 2 and 3.
Totally stubby areas allow type 1 & 2. Only type 3 for default route allowed.
NSSA allows type 1, 2, 3 & 7.
Junos OS OSPF support.
Supports OSPFv2 & v3. Features include:
- Authentication: for OSPFv2 disabled by default. Simple, MD5 & IPsec supported.
- Summarization: on ABR.
- External prefix-limit: by default, no limit. Use ‘prefix-export-limit’.
- Graceful Restart (GR)
set protocols ospf area area-id area-options;
set protocols ospf area area-id interface interface-name interface-options;
set protocols ospf3 area area-id area-options;
set protocols ospf3 area area-id interface interface-name interface-options;
OSPF RID is a 32-bit number in dotted quad notation, used for DR election and LSA originator identification. Can be;
1. explicitly configured under [edit routing-options]
2. loopback IP configured with a non-127/8 IP
3. next-suitable address, typically management interface
To advertise lo0, include lo0 in OSPF configure. If mask <32, two prefixes are advertised.
cost = reference bandwidth / bandwidth
Default reference bandwidth is 100Mbps (100.000.000).
By default, lo0 metric is 0.
Redis policy is applied directly under OSPF.
To prevent adjacency from forming but still inject prefix, use ‘passive’ on OSPF interface config.
show ospf neighbor detail/extensive
clear ospf database -> destroy adjacency
show ospf route
show ospf database
show ospf statistics -> nr & type of OSPF packets sent/received
show ospf log -> spf calc entries
show ospf interface extensive -> interfaces running OSPF
Junos OS default LSA refresh rate; 50 minutes. Older LSAs are stale.
LSA < 3600 seconds are purged.
clear ospf database -> destroy dbs
clear ospf database purge -> set all LSAs to max age and flood all LSAs. All routers are then compelled to refresh LSA.
Problem / checklist:
- No neighbor detected:
Check cable, data-link, mismatched IP/snmask, area-id, area-type, authentication, hello/dead or network type.
- Stuck in ExStart:
Check if MTU matches.
- Stuck in 2-way:
Normal for DRother neighbor.