Skip to main content

5.3 Link State Routing (Dijkstra's Algorithm) & OSPF Internals

📚Module 05: Network Layer: Routing Protocols & Control PlaneTopic 5.3⏱️20 min read
🎯High-Yield For:Semester Exams (All Universities) • Placement Technical Rounds • Engineering Foundations

💡 Core Intuition: The Road Map GPS vs Asking for Directions​

🍳 The Everyday Analogy: Downloading the Full Highway Map​

Consider the difference between two ways of navigating an unfamiliar continent:

  • The Distance Vector Approach (Asking Bystanders): You drive without a map. At every intersection, you roll down your window and ask a stranger: "Which road should I take to reach Chicago, and how many miles is it?" You trust their second-hand hearsay without knowing whether a bridge has collapsed 100 miles100\text{ miles} ahead. If two bystanders get confused, you end up driving in circles indefinitely.
  • The Link State Approach (Satellite GPS Navigation): Before turning your engine on, your in-car GPS connects to a satellite and downloads the complete, exact blueprint of every road, bridge, and speed limit in the entire country.
    1. Every road agency periodically reports its local link status: "Interstate 80 between mile marker 40 and 60 is open, speed limit 65 mph."
    2. This update is flooded to every GPS unit across the continent.
    3. Because every car's GPS now possesses an identical, complete replica of the continental road map, each car runs an independent shortest-path calculation locally.
    4. Routing loops are mathematically impossible because every vehicle computes its path on a globally consistent, loop-free mathematical graph.

💻 Bridging to Computer Science: Global Topology vs Local Rumors​

In Distance Vector Routing (DVR), a router shares its computed distances to all destinations only with its immediate physical neighbors ("tell your neighbors about the entire world").

In Link State Routing (LSR), the philosophy is reversed: each router shares the status of its directly connected links with every router in the entire network domain ("tell the entire world about your immediate neighbors").

Every router in the network independently runs Dijkstra's Shortest Path First (SPF) algorithm on its local copy of the synchronized Link State Database (LSDB), constructing a shortest-path spanning tree rooted at itself to populate its forwarding table.



Link State Routing decouples network topology discovery from shortest-path computation through four sequential, deterministic phases:

Architecture Flow

The 4 Sequential Phases of Link State Routing

From physical link probe to global topology synchronization and local SPT derivation

🤝Phase 1

Neighbor Discovery

Periodic Hello packets identify live adjacent physical neighbors and negotiate parameters.

→
Adjacency Up
📏Phase 2

Cost Measurement

Computes link metrics based on interface bandwidth, transmission delay, or administrative weight.

→
Metrics Ready
📦Phase 3

LSP Generation

Constructs Link State Packet containing Router ID, neighbor list, link costs, sequence number, and age.

→
Flood Trigger
🌊Phase 4

Reliable Flooding

Floods LSPs across all interfaces with ACK verification, synchronizing identical LSDBs globally.

1. Neighbor Discovery (The Hello Protocol)​

When a router powers on, it learns who its immediate physical neighbors are by broadcasting a lightweight Hello packet across all active network interfaces.

  • Any router receiving the Hello packet replies with its own identity.
  • Two routers become adjacent once they confirm mutual reachability, matching subnet masks, and compatible Hello/Dead timer intervals.

The router assigns a scalar metric (cost) to each active link.

  • In simple models, cost can be physical delay, measured by sending an Echo packet that the neighbor timestamps and bounces back (Cost=RTT2Cost = \frac{\text{RTT}}{2}).
  • In modern enterprise protocols like OSPF, cost is inversely proportional to bandwidth: Cost=Reference BandwidthInterface Bandwidth\text{Cost} = \frac{\text{Reference Bandwidth}}{\text{Interface Bandwidth}}

Once neighbors are verified and link costs evaluated, the router builds a Link State Packet (LSP). A standard LSP contains five essential fields:

FieldPurposeExample Value
Source Router IDUnique 32-bit identifier of the originating router192.168.1.1
Neighbor List & CostsArray of directly connected adjacent neighbors and link weights[(R2, Cost=4), (R3, Cost=2)]
Sequence Number32-bit counter incremented each time an updated LSP is generated0x80000001
Age / Time-to-LiveCountdown timer in seconds decremented at each hop and every second in memory3600 (decrements to 0)
ChecksumValidates LSP payload integrity to prevent corrupt routing advertisements0x4F2A

4. Reliable Flooding and LSDB Synchronization​

The generated LSP is flooded across all active interfaces except the one it arrived on. To guarantee reliable synchronization and prevent infinite broadcast loops:

  1. Duplicate Detection via Sequence Numbers: When a router receives an LSP, it checks its local Link State Database (LSDB).
    • If the LSP is new (not in LSDB), the router installs it, immediately floods it out on all other interfaces, and sends an acknowledgment back.
    • If the sequence number is identical to an existing entry in the LSDB, the LSP is recognized as a duplicate and silently discarded.
    • If the sequence number is lower than the existing entry, the received packet is stale; the router discards it and sends its newer LSP back to the source to correct it.
    • If the sequence number is higher, the router overwrites its database with the new record and floods it outward.
  2. Age Expiration: Every LSP has an Age field that decrements continuously. When Age reaches 00, the link state is purged from the database and a purge notification is flooded, removing dead routers.

🧮 Dijkstra's Shortest Path First (SPF) Algorithm​

Once reliable flooding converges, every router in the network possesses an identical copy of the Link State Database (LSDB). Each router then models the network as a weighted directed graph G=(V,E)G = (V, E) and executes Dijkstra's Algorithm to compute the Shortest Path Tree (SPT) with itself as the root node.

Mathematical Formulation & Invariants​

Let:

  • VV be the set of all routers (vertices).
  • EE be the set of all active physical links (edges).
  • c(u,v)c(u, v) be the link cost between router uu and neighbor vv (with c(u,v)=∞c(u, v) = \infty if no direct link exists).
  • s∈Vs \in V be the source router (root of the tree).
  • P⊆VP \subseteq V be the Permanent Set (routers whose minimum distance from ss is finalized).
  • T=V∖PT = V \setminus P be the Tentative / Candidate Set (routers whose shortest paths are still being evaluated).
  • D(v)D(v) be the tentative shortest distance from source ss to vertex vv.
  • p(v)p(v) be the predecessor of vv on the current shortest path from ss.

Mathematical Formulation & Algorithmic Steps​

1. Initialization Phase:

  • Initialize the permanent set with the source node: P={s}P = \{s\}
  • Distance to source is zero: D(s)=0D(s) = 0
  • For all other routers v∈V∖{s}v \in V \setminus \{s\}:
    • Tentative distance: D(v)=c(s,v)D(v) = c(s, v) (where c(s,v)=∞c(s, v) = \infty if no direct link exists)
    • Predecessor pointer: p(v)=sp(v) = s (if c(s,v)<∞c(s, v) < \infty, otherwise NIL\text{NIL})

2. Iterative Exploration Loop: While P≠VP \neq V (unsettled candidate routers remain):

  1. Extract Minimum Candidate: Find an unvisited router u∈V∖Pu \in V \setminus P with the minimum tentative distance: D(u)=min⁡w∈V∖PD(w)D(u) = \min_{w \in V \setminus P} D(w)
  2. Finalize Router: Add uu to the permanent set: P=P∪{u}P = P \cup \{u\}.
  3. Edge Relaxation Step: For every adjacent neighbor v∈V∖Pv \in V \setminus P of uu: D(v)=min⁡(D(v),  D(u)+c(u,v))D(v) = \min\Big(D(v), \; D(u) + c(u, v)\Big) If the path through uu is shorter (D(u)+c(u,v)<D(v)D(u) + c(u, v) < D(v)), update the predecessor pointer: p(v)=up(v) = u

Computational Complexity Analysis​

  • Naive Array Implementation: Finding the minimum distance vertex in step 1 requires scanning all remaining vertices in V∖PV \setminus P, taking O(∣V∣)O(|V|) per iteration. Over ∣V∣|V| iterations, total time is O(∣V∣2)O(|V|^2).
  • Binary Min-Heap / Priority Queue Implementation: Extracting the minimum element takes O(log⁡∣V∣)O(\log |V|) time, and each edge relaxation takes O(log⁡∣V∣)O(\log |V|) time via decrease-key: Time Complexity=O((∣E∣+∣V∣)log⁡∣V∣)\text{Time Complexity} = O\Big((|E| + |V|) \log |V|\Big)
  • For sparse network graphs where ∣E∣≪∣V∣2|E| \ll |V|^2, the heap-based implementation enables sub-millisecond route calculations even across thousands of routers.

📊 Complete Tabular Walkthrough of Dijkstra's Algorithm​

Architecture Flow

6-Router Mesh Network Topology for Dijkstra SPF Evaluation

Bidirectional link weights between routers A through F

Cost: 2
Cost: 1
Cost: 3
Cost: 2
Cost: 3
Cost: 1
Cost: 2
🏠Source
Router A
Source (Root)
⚡Transit
Router B
c(A,B)=2
⚡Transit
Router D
c(B,D)=3
⚡Transit
Router C
c(A,C)=1
⚡Transit
Router E
c(C,E)=3
🎯Dest
Router F
Destination
💡Click or hover any card or transition arrow above to inspect deep-dive operational mechanics

Direct physical link costs:

  • c(A,B)=2,c(A,C)=1c(A, B) = 2, \quad c(A, C) = 1
  • c(B,D)=3,c(B,E)=2c(B, D) = 3, \quad c(B, E) = 2
  • c(C,E)=3c(C, E) = 3
  • c(D,F)=1c(D, F) = 1
  • c(E,F)=2c(E, F) = 2

We execute Dijkstra's algorithm to compute the shortest paths from source router AA to all destinations:

StepPermanent Set PPAdded Node uuD(B),p(B)D(B), p(B)D(C),p(C)D(C), p(C)D(D),p(D)D(D), p(D)D(E),p(E)D(E), p(E)D(F),p(F)D(F), p(F)Operation & Intuition
0{A}\{A\}AA2,A2, A1,A\mathbf{1, A}∞,−\infty, -∞,−\infty, -∞,−\infty, -Direct links from AA evaluated. Min is CC (D=1D=1).
1{A,C}\{A, C\}CC2,A2, A1, A∞,−\infty, -4,C4, C∞,−\infty, -Inspect CC's neighbors: D(E)=min⁡(∞,1+3)=4D(E) = \min(\infty, 1 + 3) = 4. Min across candidate set is BB (D=2D=2).
2{A,C,B}\{A, C, B\}BB2, A1, A5,B5, B4,C\mathbf{4, C}∞,−\infty, -Inspect BB's neighbors: D(D)=2+3=5D(D) = 2+3=5; D(E)=min⁡(4,2+2)=4D(E) = \min(4, 2+2) = 4 (no change). Min is EE (D=4D=4).
3{A,C,B,E}\{A, C, B, E\}EE2, A1, A5,B5, B4, C6,E6, EInspect EE's neighbors: D(F)=4+2=6D(F) = 4 + 2 = 6. Min across candidate set is DD (D=5D=5).
4{A,C,B,E,D}\{A, C, B, E, D\}DD2, A1, A5, B4, C6,E\mathbf{6, E}Inspect DD's neighbors: D(F)=min⁡(6,5+1)=6D(F) = \min(6, 5 + 1) = 6 (tied). Min is FF (D=6D=6).
5{A,C,B,E,D,F}\{A, C, B, E, D, F\}FF2, A1, A5, B4, C6, EAll vertices finalized in PP. Shortest Path Tree complete!

Resulting Forwarding Table at Router A​

Traced back from destination predecessors to determine the immediate Next Hop interface from router AA:

DestinationTotal Path CostFull Shortest PathNext Hop from AAEgress Interface
B22A→BA \to BBBeth0
C11A→CA \to CCCeth1
D55A→B→DA \to B \to DBBeth0
E44A→C→EA \to C \to ECCeth1
F66A→C→E→FA \to C \to E \to F (or A→B→D→FA \to B \to D \to F)CC (or BB)eth1 (or ECMP)

🏛️ Open Shortest Path First (OSPF) Protocol Architecture​

Open Shortest Path First (OSPF), defined in RFC 2328 (OSPFv2) and RFC 5340 (OSPFv3 for IPv6), is the industry-standard open interior gateway protocol implementing Link State Routing.

Architecture Flow
Step 1 of 4

Hierarchical OSPF 2-Tier Architecture & Area Topologies

Area 0 Backbone inter-connecting Area 1 and Area 2 via Area Border Routers (ABRs)

🌐OSPF Area 0 (Backbone Core)
🏢OSPF Area 1 (Branch Campus)
🗄️OSPF Area 2 (Data Center)
1LSA Type 3
2LSA Type 3
3Area 1 LSDB
4Area 2 LSDB
⚡Internal
Backbone Core R1
Router ID 10.0.0.1
🔀ABR
ABR Router 1
Borders Area 0 & 1
🔀ABR
ABR Router 2
Borders Area 0 & 2
💻Internal
Access Router A1
Floods Area 1 Only
🛡️DR
Designated Router
Multicast 224.0.0.6
💡Click or hover any card or transition arrow above to inspect deep-dive operational mechanics

1. Transport Layer Independence (Protocol 89)​

Unlike RIP (which runs on top of UDP port 520) and BGP (which runs on top of TCP port 179), OSPF encapsulates its packets directly inside the IPv4 datagram payload:

  • The IPv4 header Protocol field is set to 89.
  • OSPF does not rely on UDP or TCP; it implements its own lightweight sequence numbers, retransmission timers, and packet acknowledgments directly at Layer 3.

2. Hierarchical Areas​

To scale across massive enterprise networks with thousands of routers, OSPF divides an Autonomous System into Areas:

  • Area 0 (Backbone Area): Every Autonomous System must have a central Area 0 (0.0.0.0). All non-backbone areas must physically connect to Area 0.
  • Area Border Router (ABR): A router with interfaces in both Area 0 and a regular area. An ABR summarizes internal area topology into concise summary advertisements (LSA Type 3), shielding Area 0 routers from local link flaps in Area 1.
  • Autonomous System Boundary Router (ASBR): A router that connects the OSPF network to an external routing domain (e.g., BGP or static routes), injecting external routes (LSA Type 5).

3. Designated Router (DR) and Backup Designated Router (BDR)​

On a multi-access broadcast network (such as an Ethernet switch connecting nn routers), having every router establish an adjacency with every other router produces: Total Full-Mesh Adjacencies=n(n−1)2=O(n2)\text{Total Full-Mesh Adjacencies} = \frac{n(n - 1)}{2} = O(n^2) For n=10n = 10, this requires 4545 simultaneous neighbor peering sessions and quadratic flooding overhead!

To eliminate this bottleneck, OSPF elects a Designated Router (DR) and a Backup Designated Router (BDR):

  • All other routers (called DROthers) establish adjacencies strictly with the DR and BDR, reducing adjacencies to 2n−3=O(n)2n - 3 = O(n).
  • Multicast Addresses:
    • 224.0.0.5: All OSPF Routers multicast group (listened to by every OSPF router).
    • 224.0.0.6: All DR/BDR multicast group (used by DROther routers to send link updates to the DR/BDR).

Multi-Access Adjacencies: Full-Mesh vs DR/BDR Star Topology

Scaling control-plane state from quadratic O(n²) explosion down to linear O(n) efficiency

Without DR/BDR

Full-Mesh Adjacency Explosion

💥
Dominant Architecture / DomainQuadratic Overhead: O(n²)
  • •Every router establishes bidirectional adjacency with every other router.
  • •Total peering adjacencies: n(n - 1) / 2.
  • •For 10 routers, 45 full adjacencies generate excessive LSA flooding duplicate storms.
"Floods redundant LSAs across all peer links, saturating link capacity."
With DR/BDR

Designated Router Star Optimization

🛡️
Dominant Architecture / DomainLinear Efficiency: O(n)
  • •Routers elect a single Designated Router (DR) and Backup (BDR).
  • •All other routers (DROthers) peer strictly with DR and BDR via multicast.
  • •Total adjacencies reduced to 2n - 3 (only 17 for 10 routers!).
"Centralizes LSA collection and distribution, reducing flooding by up to 75%."

4. The 5 Standard OSPF Packet Types​

TypePacket NamePrimary Function
1HelloDiscovers and maintains neighbor adjacencies; sent every 10s on broadcast links.
2Database Description (DBD)Summarizes local LSDB content so a neighbor can detect missing link-state records.
3Link State Request (LSR)Requests the complete contents of specific, newer LSAs detected from a DBD.
4Link State Update (LSU)Carries one or more full LSAs flooded across the network in response to an LSR.
5Link State Acknowledgment (LSAck)Confirms reliable receipt of an LSU; prevents retransmission timeout stalls.

⚖️ Comprehensive Architectural Comparison: DVR vs LSR​

Distance Vector Routing (DVR) vs Link State Routing (LSR)

The fundamental architectural trade-off between localized simplicity and global topological precision

Distance Vector

Distance Vector (Bellman-Ford / RIP)

📢
Dominant Architecture / DomainSmall, Simple Networks (<= 15 hops)
  • •Routers know only distance and next-hop direction; zero global topology view.
  • •Advertises entire routing table periodically (every 30s) strictly to immediate neighbors.
  • •Slow convergence; susceptible to Count-to-Infinity and two-node routing loops.
  • •Extremely low CPU and memory consumption; O(V) storage requirement.
"Tells its immediate neighbors about the entire world based on second-hand hearsay."
Link State

Link State (Dijkstra / OSPF)

🗺️
Dominant Architecture / DomainLarge, Enterprise & Backbone Networks
  • •Every router maintains an identical, complete map of the entire network graph.
  • •Floods state of directly connected links globally to all routers on topology change.
  • •Instant convergence; mathematically immune to routing loops via Dijkstra SPF trees.
  • •Higher CPU and RAM demands; executes Dijkstra O((E + V) log V) on topological flaps.
"Tells the entire world about its directly connected physical neighbors."

8-Dimensional Metric Breakdown​

DimensionDistance Vector Routing (DVR / RIP)Link State Routing (LSR / OSPF)
Algorithmic FoundationDistributed Bellman-Ford algorithmDijkstra's Shortest Path First (SPF) algorithm
Topological ViewBlind to topology; knows only (Cost, Next-Hop)Full, identical graph of all nodes and edges (LSDB)
Advertisement ScopeTransmitted strictly to direct neighborsFlooded globally to all routers in the area
Advertisement ContentFull routing table (all known destinations)Local link state only (status of adjacent links)
Update TriggersPeriodic (e.g. 30s) + Triggered on link changesEvent-driven (on link flap) + periodic refresh (30 min)
Convergence SpeedSlow; step-by-step neighbor propagationRapid; flooded immediately at line-rate
Loop VulnerabilityProne to Count-to-Infinity; requires Split HorizonLoop-free; SPT is an acyclic tree by definition
Hardware OverheadMinimal CPU and RAM footprintHigh CPU for Dijkstra; memory for full LSDB

🏭 Real-World Production Context: Enterprise Campus & Data Center OSPF Fabrics​

1. Cisco IOS & FRRouting (FRR) Production Configuration​

In enterprise environments and Linux-based network routers (such as FRRouting running inside Kubernetes CNI or edge appliances), OSPF is activated with explicit router IDs and area assignments:

# Verify active OSPF neighbors and adjacency states
$ vtysh -c "show ip ospf neighbor"
Neighbor ID Pri State Dead Time Address Interface
10.0.0.2 1 Full/DR 00:00:34 192.168.1.2 eth0
10.0.0.3 1 Full/BDR 00:00:36 192.168.1.3 eth0

# Inspect local Link State Database (LSDB)
$ vtysh -c "show ip ospf database"
OSPF Router with ID (10.0.0.1)

Router Link States (Area 0.0.0.0)
Link ID ADV Router Age Seq# Cksum
10.0.0.1 10.0.0.1 412 0x80000004 0x2A1C
10.0.0.2 10.0.0.2 389 0x80000003 0x31B0

2. Equal-Cost Multi-Path (ECMP) Load Balancing​

When Dijkstra finds multiple paths to a destination with identical cumulative metrics (e.g., two parallel 10 Gbps10\text{ Gbps} links with cost 1010), modern hardware switches do not arbitrarily pick one. They install both paths into the ASIC Forwarding Information Base (FIB) and perform Equal-Cost Multi-Path (ECMP) hashing across the 5-tuple, doubling aggregate network throughput without reordering packets within individual TCP flows.


📐 Numerical Applications & Worked Examples​

Example 1: Full Dijkstra Execution & Cost Evaluation​

Problem Statement: A sub-network consists of 5 routers {U,V,W,X,Y}\{U, V, W, X, Y\}. The link costs are:

  • c(U,V)=2,c(U,W)=5,c(U,X)=1c(U, V) = 2, \quad c(U, W) = 5, \quad c(U, X) = 1
  • c(V,W)=3,c(V,X)=2c(V, W) = 3, \quad c(V, X) = 2
  • c(W,X)=3,c(W,Y)=1,c(X,Y)=6c(W, X) = 3, \quad c(W, Y) = 1, \quad c(X, Y) = 6

Compute the minimum cost to reach destination router YY starting from source router UU, and trace the exact path taken.

Step-by-Step Solution:

  1. Initialize from Source UU (P={U}P = \{U\}):

    • D(V)=2D(V) = 2, D(W)=5D(W) = 5, D(X)=1D(X) = 1, D(Y)=∞D(Y) = \infty.
    • Minimum non-permanent candidate: XX with D(X)=1D(X) = 1.
  2. Add XX to PP (P={U,X}P = \{U, X\}): Relax neighbors of XX (V,W,YV, W, Y):

    • D(V)=min⁡(2,D(X)+c(X,V))=min⁡(2,1+2)=2D(V) = \min(2, D(X) + c(X, V)) = \min(2, 1 + 2) = 2 (no change).
    • D(W)=min⁡(5,D(X)+c(X,W))=min⁡(5,1+3)=4D(W) = \min(5, D(X) + c(X, W)) = \min(5, 1 + 3) = 4 (improved from 5!).
    • D(Y)=min⁡(∞,D(X)+c(X,Y))=min⁡(∞,1+6)=7D(Y) = \min(\infty, D(X) + c(X, Y)) = \min(\infty, 1 + 6) = 7.
    • Current candidate distances: V:2, W:4, Y:7V: 2, \ W: 4, \ Y: 7.
    • Minimum candidate: VV with D(V)=2D(V) = 2.
  3. Add VV to PP (P={U,X,V}P = \{U, X, V\}): Relax neighbors of VV (WW):

    • D(W)=min⁡(4,D(V)+c(V,W))=min⁡(4,2+3)=4D(W) = \min(4, D(V) + c(V, W)) = \min(4, 2 + 3) = 4 (no change).
    • Current candidate distances: W:4, Y:7W: 4, \ Y: 7.
    • Minimum candidate: WW with D(W)=4D(W) = 4.
  4. Add WW to PP (P={U,X,V,W}P = \{U, X, V, W\}): Relax neighbors of WW (YY):

    • D(Y)=min⁡(7,D(W)+c(W,Y))=min⁡(7,4+1)=5D(Y) = \min(7, D(W) + c(W, Y)) = \min(7, 4 + 1) = \mathbf{5} (improved from 7!).
    • Remaining candidate: YY with D(Y)=5D(Y) = 5.
  5. Final Path and Cost Evaluation:

    • Minimum cost to reach Y=5Y = \mathbf{5}.
    • Path: U→X→W→YU \to X \to W \to Y (Costs: 1+3+1=51 + 3 + 1 = 5).
    • Notice that the direct link from X→YX \to Y has cost 66, but routing through intermediate node WW yields cost 1+3+1=51 + 3 + 1 = 5.

Example 2: OSPF Interface Cost Formula & Reference Bandwidth​

Problem Statement: An OSPF network uses the standard default reference bandwidth of 100 Mbps100\text{ Mbps} (108 bps10^8\text{ bps}).

  1. Calculate the OSPF cost for a FastEthernet link (100 Mbps100\text{ Mbps}) and a GigabitEthernet link (1 Gbps1\text{ Gbps}).
  2. Explain the fundamental flaw of this default configuration in modern networks, and determine the new costs if the administrator updates the reference bandwidth to 100 Gbps100\text{ Gbps} (1011 bps10^{11}\text{ bps}).

Step-by-Step Solution:

  1. Apply OSPF Cost Formula with Default Reference Bandwidth (108 bps10^8\text{ bps}): Cost=⌈Reference BandwidthInterface Bandwidth⌉\text{Cost} = \left\lceil \frac{\text{Reference Bandwidth}}{\text{Interface Bandwidth}} \right\rceil

    • For FastEthernet (100 Mbps=108 bps100\text{ Mbps} = 10^8\text{ bps}): CostFE=108108=1\text{Cost}_{FE} = \frac{10^8}{10^8} = \mathbf{1}
    • For GigabitEthernet (1 Gbps=109 bps1\text{ Gbps} = 10^9\text{ bps}): CostGE=108109=0.1  ⟹  1(minimum integer cost is 1)\text{Cost}_{GE} = \frac{10^8}{10^9} = 0.1 \implies \mathbf{1} \quad (\text{minimum integer cost is } 1)
  2. Identify Architectural Flaw:

    • Both 100 Mbps100\text{ Mbps}, 1 Gbps1\text{ Gbps}, and 10 Gbps10\text{ Gbps} links are assigned an identical cost of 11! OSPF cannot distinguish between a 100 Mbps100\text{ Mbps} bottleneck and a 10 Gbps10\text{ Gbps} fiber link!
  3. Recalculate with Reference Bandwidth =100 Gbps= 100\text{ Gbps} (1011 bps10^{11}\text{ bps}):

    • FastEthernet (100 Mbps=108 bps100\text{ Mbps} = 10^8\text{ bps}): CostFE=1011108=1,000\text{Cost}_{FE} = \frac{10^{11}}{10^8} = \mathbf{1,000}
    • GigabitEthernet (1 Gbps=109 bps1\text{ Gbps} = 10^9\text{ bps}): CostGE=1011109=100\text{Cost}_{GE} = \frac{10^{11}}{10^9} = \mathbf{100}
    • Ten-GigabitEthernet (10 Gbps=1010 bps10\text{ Gbps} = 10^{10}\text{ bps}): Cost10GE=10111010=10\text{Cost}_{10GE} = \frac{10^{11}}{10^{10}} = \mathbf{10}
    • Hundred-GigabitEthernet (100 Gbps=1011 bps100\text{ Gbps} = 10^{11}\text{ bps}): Cost100GE=10111011=1\text{Cost}_{100GE} = \frac{10^{11}}{10^{11}} = \mathbf{1}

Example 3: Multi-Access Adjacency Reduction via DR/BDR​

Problem Statement: An enterprise network connects 1616 routers to a single central Gigabit Ethernet switch.

  1. How many neighbor adjacencies would be required if all routers formed peerings directly with each other?
  2. How many adjacencies are formed when OSPF elects a Designated Router (DR) and a Backup Designated Router (BDR)?

Step-by-Step Solution:

  1. Full-Mesh Adjacency Formula without DR/BDR: Nadj_full=n(n−1)2=16×152=120 adjacenciesN_{\text{adj\_full}} = \frac{n(n - 1)}{2} = \frac{16 \times 15}{2} = \mathbf{120\text{ adjacencies}}

  2. Adjacency Formula with DR and BDR:

    • There are 22 designated routers (DR and BDR) and n−2=14n - 2 = 14 non-designated routers (DROthers).
    • Between DR and BDR: 11 adjacency.
    • Each of the 1414 DROther routers establishes exactly 22 adjacencies (one with DR, one with BDR): Nadj_DROther=14×2=28 adjacenciesN_{\text{adj\_DROther}} = 14 \times 2 = 28\text{ adjacencies}
    • Total adjacencies formed: Ntotal=1+28=29 adjacencies(Formula: 2n−3=2(16)−3=29)N_{\text{total}} = 1 + 28 = \mathbf{29\text{ adjacencies}} \quad \Big(\text{Formula: } 2n - 3 = 2(16) - 3 = 29\Big)
    • Result: DR/BDR reduces control-plane overhead by over 75%75\% (120→29120 \to 29).

🎯 Exam & Interview Pitfall Check​

Core Conceptual Questions
  • Why does OSPF encapsulate directly into IP (Protocol 89) instead of utilizing UDP or TCP?
    Because OSPF is an interior routing protocol that operates within a single administrative domain. Running over UDP would introduce unnecessary transport overhead without reliability benefits. Running over TCP would introduce head-of-line blocking, connection setup latency, and transport circularity (TCP needs routing tables to deliver packets, while routing tables need TCP to converge). OSPF implements its own reliable hop-by-hop flooding and acknowledgment mechanism tailored specifically for topology exchange.

  • Why does Dijkstra's algorithm fail when a graph contains negative-weight edge cycles?
    Dijkstra's algorithm relies on a greedy property: once a node is placed into the Permanent Set PP, its shortest distance is assumed finalized and is never reconsidered. If negative edges exist, reaching an already-finalized node through a subsequent negative path could yield a strictly smaller total distance, violating Dijkstra's core greedy invariant. (Bellman-Ford must be used when negative edges are present).

Common Interview Traps
  • Trap: Believing that OSPF elects a DR/BDR on Point-to-Point serial links.
    Debunked: DR and BDR election occurs strictly on Broadcast and Non-Broadcast Multi-Access (NBMA) networks (e.g. Ethernet). On Point-to-Point links connecting exactly two routers, there are only n=2n = 2 routers, so 2(1)2=1\frac{2(1)}{2} = 1 adjacency; electing a DR/BDR would provide zero reduction and is disabled by default.

  • Trap: Assuming that all non-backbone areas can interconnect arbitrarily without Area 0.
    Debunked: OSPF strictly enforces a two-tier hierarchy. All non-backbone areas must attach directly to Area 0. Inter-area traffic cannot transit directly from Area 1 to Area 2 without traversing Area 0. If a physical disconnect occurs, a Virtual Link must be explicitly configured through a transit area to restore logical continuity to Area 0.


💬

Discussion & Doubts