9.1 OSPFv2 Architecture & Neighbor State Machine
Key Takeaways
- OSPF is an open-standard link-state routing protocol (RFC 2328) executing Dijkstra's Shortest Path First (SPF) algorithm on an identical synchronized Link-State Database (LSDB) to construct a loop-free shortest path tree.
- Hierarchical multi-area design mandates Area 0 (Backbone Area) as the central transit core, requiring all non-backbone areas to attach directly to Area 0 to prevent inter-area routing loops.
- OSPF encapsulates control traffic directly in IP protocol 89 using five discrete packet types (Hello, DBD, LSR, LSU, LSAck) across multicast destinations 224.0.0.5 (AllSPFRouters) and 224.0.0.6 (AllDRouters).
- The neighbor state machine transitions through eight deterministic states (Down, Attempt, Init, 2-Way, ExStart, Exchange, Loading, Full), where 2-Way is a valid steady state for DROther pairs and Full represents complete LSDB synchronization.
- Designated Routers (DR) and Backup Designated Routers (BDR) are elected non-preemptively on broadcast and non-broadcast networks using interface priority (0-255) and tie-broken by Router ID (manual config > highest loopback > highest physical IP).
9.1 OSPFv2 Architecture & Neighbor State Machine
Open Shortest Path First version 2 (OSPFv2, defined in RFC 2328) is an interior gateway protocol (IGP) engineered for high scalability, rapid convergence, and hierarchical enterprise network routing. Unlike distance-vector routing protocols (such as RIP or legacy IGRP) where routers route "by rumor" based solely on neighbor advertisements, link-state protocols provide every participating router with a complete, topological view of the network domain.
+-----------------------------------------------------------------------------------+
| DISTANCE VECTOR VS. LINK-STATE ROUTING PRINCIPLES |
+-----------------------------------------------------------------------------------+
| DISTANCE VECTOR (e.g., RIP): |
| - Routers only know what their direct neighbors tell them ("routing by rumor"). |
| - Exchanges entire routing tables periodically or upon topology changes. |
| - Metric: Hop count or composite vector; limited view of overall topology. |
| |
| LINK-STATE (OSPFv2 / OSPFv3 / IS-IS): |
| - Every router advertises the state of its local links and connected neighbors. |
| - Link-State Advertisements (LSAs) are flooded to create an identical LSDB. |
| - Every router runs Dijkstra's algorithm independently on its local LSDB copy. |
| - Generates a guaranteed loop-free Shortest Path Tree (SPT) with itself as root. |
+-----------------------------------------------------------------------------------+
1. Link-State Concepts & Dijkstra's SPF Algorithm
OSPF organizes routing information into discrete data structures called Link-State Advertisements (LSAs). These LSAs are stored within the router's Link-State Database (LSDB). Within any single OSPF area, all routers maintain an identical LSDB representing a complete topological map of routers, transit links, point-to-point connections, and stub subnets.
+-----------------------------------------------------------------------------------+
| OSPF TOPOLOGY GRAPH & SPF TREE ROOT |
+-----------------------------------------------------------------------------------+
| |
| [ Router B ] ----------------( Cost: 10 )---------------- [ Router C ] |
| | | |
| (Cost: 1) (Cost: 1) |
| | | |
| [ Router A ] <---( Root: Self ) [ Router D ] |
| | | |
| (Cost: 5) (Cost: 10) |
| | | |
| [ Router E ] ----------------( Cost: 2 )----------------- [ Router F ] |
| |
| SPF Path Computation from Router A to Subnet behind Router D: |
| - Path 1: A -> B -> C -> D = 1 + 10 + 1 = Cost 12 |
| - Path 2: A -> E -> F -> D = 5 + 2 + 10 = Cost 17 |
| * Shortest Path Selected: Path 1 (Cost 12) installed into RIB / FIB |
+-----------------------------------------------------------------------------------+
Dijkstra's Shortest Path First (SPF) Mechanics
- Graph Construction: Each router treats itself as the root of a directed graph where vertices represent routers or transit networks, and edges represent links with assigned metric costs.
- Path Metric Accumulation: The metric for any destination prefix equals the cumulative sum of the egress interface costs along the path from the root router to the destination subnet.
- Loop Freedom: Because every node evaluates the full graph independently using consistent link costs, Dijkstra's algorithm mathematically guarantees a loop-free tree structure.
OSPF Cost Metric Formula
OSPF computes the cost of an interface as an inverse function of its configured bandwidth:
By default in Cisco IOS and IOS-XE, the Reference Bandwidth is 100 Mbps ($10^8$ bps). As a result, all link speeds of 100 Mbps and higher (FastEthernet, GigabitEthernet, 10GbE, 100GbE) evaluate to a default cost of 1, making OSPF unable to distinguish higher-speed uplinks without administrative tuning.
! Adjust the OSPF reference bandwidth to support modern high-speed links (e.g., 100 Gbps)
Router(config)# router ospf 1
Router(config-router)# auto-cost reference-bandwidth 100000
% OSPF: Reference bandwidth is changed.
Please ensure reference bandwidth is consistent across all routers
Interface Cost Comparison Across Reference Bandwidths
| Interface Type | Actual Bandwidth | Default Cost (100 Mbps Ref) | Modern Cost (100 Gbps Ref / 100,000 Mbps) |
|---|---|---|---|
| Serial (T1) | 1.544 Mbps | 64 | 64,766 |
| Ethernet | 10 Mbps | 10 | 10,000 |
| FastEthernet | 100 Mbps | 1 | 1,000 |
| GigabitEthernet | 1 Gbps (1,000 Mbps) | 1 (unscaled) | 100 |
| TenGigabitEthernet | 10 Gbps (10,000 Mbps) | 1 (unscaled) | 10 |
| FortyGigabitEthernet | 40 Gbps (40,000 Mbps) | 1 (unscaled) | 2.5 $\to$ 2 |
| HundredGigabitEthernet | 100 Gbps (100,000 Mbps) | 1 (unscaled) | 1 |
2. Area 0 Backbone Architecture & Multi-Area Rules
To prevent LSDB bloat and minimize CPU consumption from frequent SPF calculations in large enterprise networks, OSPF introduces a two-tier hierarchical area structure.
+-----------------------------------------------------------------------------------+
| OSPF HIERARCHICAL TWO-TIER DESIGN |
+-----------------------------------------------------------------------------------+
| |
| +-------------------------------------------------------------+ |
| | BACKBONE AREA (AREA 0 / 0.0.0.0) | |
| | - Core Transit Area; interconnects all peripheral areas | |
| | - Hosts ABRs and Core Backbone Routers | |
| +-------------------------------------------------------------+ |
| / | \ |
| [ ABR 1 ] [ ABR 2 ] [ ABR 3 ] |
| / | \ |
| +-------------------+ +-------------------+ +-------------------+ |
| | Standard Area 10 | | Stub Area 20 | | NSSA Area 30 | |
| | (Intra-Area SPF) | | (No Type 4/5 LSA)| | (Type 7 Ext LSAs) | |
| +-------------------+ +-------------------+ +-------------------+ |
+-----------------------------------------------------------------------------------+
Core Multi-Area Design Rules
- Mandatory Backbone Area (Area 0): Every multi-area OSPF deployment must have a contiguous Area 0 (or
0.0.0.0). Area 0 serves as the central hub through which all inter-area traffic must transit. - Direct Attachment to Area 0: All non-backbone areas must connect directly to Area 0 via at least one Area Border Router (ABR).
- Inter-Area Loop Prevention (Split-Horizon): An ABR will never advertise an inter-area summary route (Type 3 LSA) back into Area 0 if that route was learned from a non-backbone area. Inter-area traffic cannot flow directly between two non-backbone areas without passing through Area 0.
- Virtual Links for Discontiguous Backbone: If an area is physically severed from Area 0, or if Area 0 becomes partitioned, an OSPF Virtual Link can be deployed. A virtual link is a logical tunnel over a non-backbone transit area (which cannot be a stub area) that restores logical adjacency to Area 0.
3. OSPF Packet Types & Protocol Encapsulation
OSPF does not rely on transport-layer protocols such as TCP or UDP. Instead, OSPF packets are encapsulated directly within IPv4 packets with IP Protocol Number 89.
OSPF control packets utilize two dedicated link-local IPv4 multicast addresses (with TTL set to 1):
224.0.0.5(AllSPFRouters): Listened to by all OSPF-enabled routers. Used for Hello packets and LSU/LSAck packets on point-to-point links.224.0.0.6(AllDRouters): Listened to exclusively by the Designated Router (DR) and Backup Designated Router (BDR) on multi-access broadcast and NBMA links.
+-----------------------------------------------------------------------------------+
| OSPF PACKET ENCAPSULATION |
+-----------------------------------------------------------------------------------+
| IPv4 Header (Protocol 89 | Src: Interface IP | Dst: 224.0.0.5 or 224.0.0.6) |
+-----------------------------------------------------------------------------------+
| OSPF Common Header (24 Bytes): |
| - Version (2) | Type (1-5) | Packet Length | Router ID | Area ID |
| - Checksum | Auth Type | Authentication Data (8 Bytes) |
+-----------------------------------------------------------------------------------+
| OSPF Packet Type Specific Payload (Hello / DBD / LSR / LSU / LSAck) |
+-----------------------------------------------------------------------------------+
The Five OSPF Packet Types
+-----------------------------------------------------------------------------------+
| THE FIVE OSPF PACKET TYPES |
+-----------------------------------------------------------------------------------+
| Type 1: HELLO Discovers neighbors, forms adjacencies, and sends |
| keepalives to maintain neighbor relationships. |
| |
| Type 2: DATABASE DESCRIPTION Summarizes the local LSDB by exchanging LSA headers |
| (DBD / DDP) to determine which LSAs need to be requested. |
| |
| Type 3: LINK-STATE REQUEST Requests full, updated copies of specific LSAs that |
| (LSR) are missing or out-of-date in the local LSDB. |
| |
| Type 4: LINK-STATE UPDATE Transports one or more full LSA payloads to |
| (LSU) synchronize databases between adjacent neighbors. |
| |
| Type 5: LINK-STATE ACK Provides explicit, reliable acknowledgment of |
| (LSAck) received Link-State Update (LSU) packets. |
+-----------------------------------------------------------------------------------+
Mandatory Hello Negotiation Parameters
For two OSPF routers to establish a neighbor relationship, the parameters advertised in their Hello packets must match exactly on the shared link:
- Area ID: Routers must reside in the same OSPF area on that link.
- Area Type / Flags: Stub, NSSA, or Standard area flags (the E-bit and N-bit) must agree.
- Subnet Mask: The primary IPv4 subnet mask must match on broadcast and NBMA networks (ignored on point-to-point links).
- Hello Interval: Default is 10 seconds (broadcast/P2P) or 30 seconds (NBMA).
- Dead Interval: Default is 4 times the Hello interval (40 seconds or 120 seconds).
- Authentication: Authentication type (None, Simple Password, MD5, SHA) and shared cryptographic key must match.
- Unique Router IDs: Router IDs cannot overlap.
- MTU Setting: Interface Maximum Transmission Unit (MTU) is exchanged in DBD packets during the ExStart state. If MTUs mismatch, the adjacency will hang in the ExStart / Exchange state.
4. The 8-State Neighbor Finite State Machine (FSM)
OSPF neighbors transition through an 8-state state machine to progress from initial discovery to complete link-state database synchronization.
+-----------------------------------------------------------------------------------+
| OSPF NEIGHBOR ADJACENCY EXCHANGE |
+-----------------------------------------------------------------------------------+
| ROUTER A (RID: 1.1.1.1) ROUTER B (RID: 2.2.2.2) |
| |
| [ DOWN ] ------------------( Hello [Neighbors: None] )-------------> [ INIT ] |
| [ INIT ] <-----------------( Hello [Neighbors: 1.1.1.1] )----------- [ 2-WAY ] |
| [ 2-WAY ] -----------------( Hello [Neighbors: 2.2.2.2] )----------> [ 2-WAY ] |
| |
| === [ DR / BDR ELECTION OCCURS ON MULTI-ACCESS ] === |
| |
| [ ExStart ] <--( DBD: Init=1, More=1, Master=1, Seq=100 [R-B] )----> [ ExStart ] |
| [ ExStart ] ---( DBD: Init=0, More=1, Master=0, Seq=100 [R-A] )----> [ Exchange]|
| (Router B is Master due to higher RID 2.2.2.2; Router A adopts Seq 100) |
| |
| [ Exchange ] --( DBD LSA Summaries [Seq 101] )---------------------> [ Exchange]|
| [ Exchange ] <-( DBD LSA Summaries [Seq 102] )--------------------- [ Exchange]|
| |
| [ Loading ] ---( Link-State Request: LSR for LSA-X )---------------> [ Loading ] |
| [ Loading ] <--( Link-State Update: LSU with LSA-X )---------------- [ Loading ] |
| [ Loading ] ---( Link-State Ack: LSAck for LSA-X )-----------------> [ FULL ] |
| [ FULL ] |
+-----------------------------------------------------------------------------------+
Detailed State Breakdown
- Down: The initial state. No OSPF Hello packets have been received from the neighbor. Routers transmit periodic Hello packets to discover neighbors.
- Attempt: Applicable only on Non-Broadcast Multi-Access (NBMA) networks (e.g., Frame Relay, DMVPN) where neighbors are statically defined using the
neighbor <ip>command. The router sends unicast Hellos and waits for a response. - Init: A Hello packet has been received from the neighbor, but the receiving router's own Router ID is not listed in the received neighbor list. This indicates one-way communication.
- 2-Way: The router sees its own Router ID in the neighbor's Hello packet, confirming bidirectional communication. On multi-access broadcast and NBMA networks, the DR and BDR election occurs in this state. Non-DR/BDR routers (DROther) maintain persistent 2-Way state with each other.
- ExStart: The first step toward forming a full adjacency. Neighbors determine a Master/Slave relationship and negotiate an Initial Sequence Number (ISN) for DBD packets. The router with the higher Router ID becomes the Master. Interface MTU is also negotiated; if an MTU mismatch exists and
ip ospf mtu-ignoreis not enabled, neighbors remain stuck in ExStart. - Exchange: Routers exchange Database Description (DBD) packets containing LSA headers (Type, Link-State ID, Advertising Router, Sequence Number, and Checksum). The Master increments sequence numbers while the Slave acknowledges each DBD by echoing the Master's sequence number.
- Loading: Routers compare received LSA headers against their local LSDB. If a neighbor advertises a newer or missing LSA, the local router issues a Link-State Request (LSR). The neighbor responds with a Link-State Update (LSU) containing the full LSA, which is acknowledged with a Link-State Acknowledgment (LSAck).
- Full: Link-state databases between adjacent routers are 100% identical and fully synchronized. The routers run the Dijkstra SPF calculation to install the best paths into the routing information base (RIB).
Summary of OSPF Neighbor States
| State | Description | Packets Transmitted / Received | Steady State? |
|---|---|---|---|
| Down | No Hellos received from neighbor | Hello (Transmitted) | No |
| Attempt | Unicast Hellos sent to statically configured NBMA peer | Unicast Hello | No |
| Init | One-way communication detected | Hello | No |
| 2-Way | Bidirectional communication confirmed; DR/BDR elected | Hello | Yes (Between DROthers) |
| ExStart | Master/Slave & Initial Sequence Number negotiated | Empty DBDs | No (Stuck indicates MTU mismatch) |
| Exchange | LSA summary headers exchanged | DBDs, LSRs, LSUs | No |
| Loading | Missing/outdated LSAs requested and transferred | LSR, LSU, LSAck | No |
| Full | Complete LSDB synchronization achieved | LSU, LSAck, Periodic Hellos | Yes (Adjacent neighbors) |
5. DR/BDR Election & Router ID Selection Hierarchy
On multi-access networks (Broadcast Ethernet and Non-Broadcast networks), having every router form a full mesh of adjacencies with every other router creates severe scaling limitations. In a broadcast segment with $N$ routers, a full mesh requires:
For 10 routers, this represents 45 adjacencies and redundant LSA flooding. To solve this, OSPF elects a Designated Router (DR) and a Backup Designated Router (BDR). All other routers (DROther) form full adjacencies only with the DR and BDR, reducing total adjacencies to $2N - 3$ (17 adjacencies for 10 routers).
+-----------------------------------------------------------------------------------+
| DR / BDR MULTI-ACCESS FLOODING TOPOLOGY |
+-----------------------------------------------------------------------------------+
| |
| [ DROther 1 ] [ DROther 2 ] |
| \ / |
| \ / |
| Sends LSUs to \ / Sends LSUs to |
| 224.0.0.6 \ / 224.0.0.6 |
| v v |
| +--------------------------+ |
| | Designated Router (DR) | |
| +--------------------------+ |
| | |
| | Floods LSUs to 224.0.0.5 |
| v |
| +--------------------------------+ |
| | All OSPF Routers (224.0.0.5) | |
| +--------------------------------+ |
| / \ |
| v v |
| [ DROther 1 ] [ DROther 2 ] |
+-----------------------------------------------------------------------------------+
DR/BDR Election Rules
- Priority Hierarchy: The router with the highest OSPF interface priority (
ip ospf priority <0-255>) wins the election. The default priority is 1. - Priority 0 (Never Eligible): Setting priority to
0prevents a router from ever becoming a DR or BDR (forces DROther status). - Tie-Breaker (Highest Router ID): If priorities are equal, the router with the highest Router ID (RID) is elected.
- Non-Preemptive Election: DR/BDR elections are non-preemptive. If a router with a higher priority or higher RID boots onto an existing segment with an active DR and BDR, it will not preempt the current DR or BDR. It only assumes the role if the current DR or BDR fails or its OSPF process is reset.
Router ID (RID) Selection Hierarchy
Every OSPF router must possess a unique 32-bit Router ID (formatted as an IPv4 address). Cisco IOS-XE selects the RID using the following strict order of precedence:
+-----------------------------------------------------------------------------------+
| ROUTER ID SELECTION PRECEDENCE |
+-----------------------------------------------------------------------------------+
| 1. Explicit Configuration: 'router-id x.x.x.x' command (Highest Priority) |
| 2. Highest Loopback: Highest IPv4 address on an active up/up Loopback |
| 3. Highest Physical IP: Highest IPv4 address on an active up/up Physical int |
+-----------------------------------------------------------------------------------+
Important: Once an OSPF process selects a Router ID, it remains locked even if a higher IP address or loopback becomes active. Changing the Router ID requires executing
clear ip ospf processor reloading the router.
6. Cisco IOS-XE Configuration & Verification
1. Basic OSPFv2 Multi-Area Configuration
! Configure Core Router ABR-1 with manual RID and Reference Bandwidth
ABR-1(config)# router ospf 1
ABR-1(config-router)# router-id 1.1.1.1
ABR-1(config-router)# auto-cost reference-bandwidth 100000
ABR-1(config-router)# passive-interface GigabitEthernet0/0/2
! Enable OSPF on interfaces using modern interface-level syntax
ABR-1(config)# interface GigabitEthernet0/0/0
ABR-1(config-if)# ip address 10.0.0.1 255.255.255.252
ABR-1(config-if)# ip ospf 1 area 0
ABR-1(config-if)# ip ospf network point-to-point
ABR-1(config)# interface GigabitEthernet0/0/1
ABR-1(config-if)# ip address 10.10.1.1 255.255.255.0
ABR-1(config-if)# ip ospf 1 area 10
ABR-1(config-if)# ip ospf priority 255
ABR-1(config-if)# ip ospf hello-interval 5
ABR-1(config-if)# ip ospf dead-interval 20
2. Verification Commands & Output
ABR-1# show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
2.2.2.2 1 FULL/BDR 00:00:17 10.10.1.2 GigabitEthernet0/0/1
3.3.3.3 0 2-WAY/DROTHER 00:00:18 10.10.1.3 GigabitEthernet0/0/1
4.4.4.4 0 FULL/ - 00:00:19 10.0.0.2 GigabitEthernet0/0/0
ABR-1# show ip ospf interface GigabitEthernet0/0/1
GigabitEthernet0/0/1 is up, line protocol is up
Internet Address 10.10.1.1/24, Area 10, Attached via Interface Enable
Process ID 1, Router ID 1.1.1.1, Network Type BROADCAST, Cost: 100
Topology-MTID Cost Disabled Shutdown Topology Name
0 100 no no Base
Transmit Delay is 1 sec, State DR, Priority 255
Designated router (ID) 1.1.1.1, Interface address 10.10.1.1
Backup Designated router (ID) 2.2.2.2, Interface address 10.10.1.2
Timer intervals configured, Hello 5, Dead 20, Wait 20, Retransmit 5
Hello timer due in 00:00:02
Neighbor Count is 2, Adjacent neighbor count is 1
Adjacent with neighbor 2.2.2.2 (Backup Designated Router)
Two OSPFv2 routers connected over a direct GigabitEthernet link fail to establish a FULL adjacency. Output from 'show ip ospf neighbor' indicates that the neighbor state is perpetually stuck in 'EXSTART/EXCHANGE'. Inspection of the interface configurations reveals that Router A has an MTU of 1500 bytes while Router B has an MTU of 9000 bytes (jumbo frames enabled). What is the root cause of this failure?
A network engineer adds a new high-end core router (Router-Core) with an OSPF priority of 255 and Router ID 9.9.9.9 to an active multi-access broadcast subnet. The existing subnet currently has Router-1 (Priority 1, RID 1.1.1.1) acting as DR and Router-2 (Priority 100, RID 2.2.2.2) acting as BDR. What immediate role will Router-Core assume on the broadcast segment?
A newly booted Cisco router running OSPFv2 has the following active, up/up IPv4 interface configuration:
An enterprise network migrates core uplinks from 1 Gbps GigabitEthernet to 10 Gbps and 40 Gbps interfaces. The network administrator notices that OSPF continues to calculate equal path costs across both 1 Gbps and 10 Gbps paths. What configuration command must be executed on all OSPF routers to resolve this metric calculation limitation?