Link State Database

The Link State Database (LSDB) is the heart of OSPF operations. It contains all topology information within an area and is synchronized across all routers in that area.

LSDB Key Characteristics

  • Area-specific: Each area maintains its own LSDB
  • Synchronized: Identical across all routers in the area
  • Dynamic: Updated as network topology changes
  • Reliable: Uses flooding and acknowledgments
  • Aged: LSAs expire after MaxAge (3600 seconds)

LSDB Structure

The LSDB is organized by LSA type and contains multiple data structures:

LSA Storage
  • Type 1: Router LSAs
  • Type 2: Network LSAs
  • Type 3: Summary LSAs
  • Type 4: ASBR Summary LSAs
  • Type 5: External LSAs
  • Type 7: NSSA External LSAs
LSA Identification
  • LS Type: LSA category
  • Link State ID: Content identifier
  • Advertising Router: Originator
  • Sequence Number: Freshness
  • Checksum: Integrity
  • Age: Time since origination

LSA Aging Process

LSA Generated
Age = 0
Age Increments
Refresh @ 1800s
MaxAge @ 3600s

LSA Timers

Timer Default Value Purpose Action
LSRefreshTime 1800 seconds Refresh interval Re-originate LSA
MaxAge 3600 seconds LSA expiration Flush from database
MinLSInterval 5 seconds Rate limiting Minimum time between updates

LSDB Verification

Cisco LSDB Commands

# View complete LSDB
show ip ospf database

# View specific LSA types
show ip ospf database router
show ip ospf database network
show ip ospf database summary
show ip ospf database external

# View specific LSA
show ip ospf database router 192.168.1.1

# Database statistics
show ip ospf database database-summary

Juniper LSDB Commands

# View complete LSDB
show ospf database

# View specific LSA types
show ospf database router
show ospf database network
show ospf database summary
show ospf database external

# View detailed LSA
show ospf database router 192.168.1.1 detail

# Database statistics
show ospf database summary

Sample LSDB Output

OSPF Router with ID (192.168.1.1) (Process ID 1)

                Router Link States (Area 0)
Link ID         ADV Router      Age  Seq#       Checksum Link count
192.168.1.1     192.168.1.1     234  0x80000002 0x1234   2
192.168.1.2     192.168.1.2     156  0x80000001 0x5678   3

                Network Link States (Area 0)
Link ID         ADV Router      Age  Seq#       Checksum
192.168.1.1     192.168.1.1     234  0x80000001 0x9ABC

                Summary Net Link States (Area 0)
Link ID         ADV Router      Age  Seq#       Checksum
10.0.0.0        192.168.1.2     567  0x80000001 0xDEF0

Dijkstra's SPF Algorithm

The Shortest Path First (SPF) algorithm, developed by Edsger Dijkstra, calculates the shortest paths from a source router to all other routers in the network.

SPF Algorithm Key Concepts

  • Graph Theory: Network represented as weighted graph
  • Cost-based: Uses interface costs as edge weights
  • Loop-free: Guarantees shortest path tree
  • Efficient: O(n²) complexity for dense graphs
  • Deterministic: Same input produces same output

Cost Calculation

OSPF uses interface costs to determine the best path. The default cost calculation is:

Default Cost Formula

Cost = Reference Bandwidth / Interface Bandwidth

  • Reference Bandwidth: 100 Mbps (default)
  • Interface Bandwidth: Physical interface speed
  • Minimum Cost: 1 (for interfaces ≥ reference bandwidth)

Interface Cost Examples

Interface Type Bandwidth Default Cost Adjusted Cost (1Gbps Ref)
Serial (T1) 1.544 Mbps 64 647
Ethernet 10 Mbps 10 100
Fast Ethernet 100 Mbps 1 10
Gigabit Ethernet 1000 Mbps 1 1
10 Gigabit Ethernet 10000 Mbps 1 1

SPF Algorithm Steps

  • Candidate List: All routers with tentative distances
  • SPF Tree: Routers with confirmed shortest paths
  • Distance Array: Shortest distance to each router
  • Parent Array: Previous hop for path reconstruction

  • Set root distance to 0: Starting point
  • Add root to SPF tree: First confirmed node
  • Examine root's LSA: Find directly connected routers
  • Add neighbors to candidate list: With calculated distances

  1. Select closest candidate: Router with minimum distance
  2. Move to SPF tree: Confirm shortest path
  3. Process router's LSA: Examine all links
  4. Update distances: Relax adjacent nodes
  5. Repeat until candidate list empty

SPF Calculation Example

Network Topology

    R1 ----10---- R2
    |             |
    5             15
    |             |
    R3 ----20---- R4
Step Current Router Candidate List SPF Tree Best Path to R4
1 R1 (Root) R2(10), R3(5) R1(0)
2 R3 R2(10), R4(25) R1(0), R3(5) 25
3 R2 R4(25) R1(0), R3(5), R2(10) 25
4 R4 Empty R1(0), R3(5), R2(10), R4(25) 25 via R3

SPF Triggers

When SPF Runs

  • Topology Change: New or changed LSA received
  • Interface State Change: Link up/down events
  • Area Configuration Change: Area type modifications
  • Router ID Change: Requires process restart

SPF Timers Configuration

Cisco SPF Timers

# Configure SPF timers
router ospf 1
 timers spf 5 10 10000

# Throttle LSA generation
 timers lsa-group-pacing 240

# Show SPF statistics
show ip ospf statistics

Juniper SPF Timers

# Configure SPF timers
protocols {
    ospf {
        spf-options {
            delay 5;
            holddown 10;
            rapid-runs 3;
        }
    }
}

# Show SPF statistics
show ospf statistics

Route Calculation

After SPF calculation completes, OSPF translates the shortest path tree into routing table entries. Different route types have different calculation methods and preferences.

Route Types in OSPF

  • Intra-area routes: Destinations within the same area
  • Inter-area routes: Destinations in other OSPF areas
  • External Type 1 (E1): External routes with internal cost
  • External Type 2 (E2): External routes with external cost only

Route Preference Order

Preference Route Type Description Cost Calculation
1 (Best) Intra-area Routes within same area SPF tree cost
2 Inter-area Routes to other areas Cost to ABR + Type 3 LSA cost
3 External Type 1 External with internal cost Cost to ASBR + external cost
4 (Worst) External Type 2 External with external cost only External cost (+ ASBR cost for tiebreak)

Intra-area Route Calculation

Process

  1. SPF tree traversal: Follow shortest path tree
  2. Leaf network identification: Find stub networks
  3. Cost assignment: Use SPF calculated cost
  4. Next-hop determination: First hop from root

Inter-area Route Calculation

Type 3 LSA
Find ABR
Cost to ABR
Add LSA Cost
Install Route

Inter-area Calculation Steps

  • Examine all Type 3 LSAs from ABRs
  • Verify ABR is reachable via intra-area route
  • Calculate total cost: Cost to ABR + LSA metric
  • Compare costs from multiple ABRs

  • Select path with lowest total cost
  • Handle equal-cost paths (ECMP)
  • Set next-hop to ABR address
  • Install in routing table

External Route Calculation

Type 1 External (E1)

Cost = Cost to ASBR + External Cost

  • Includes internal path cost
  • Best for when internal topology matters
  • More accurate cost representation
  • Higher processing overhead
Type 2 External (E2)

Cost = External Cost Only

  • Ignores internal path cost
  • Default external route type
  • Simpler calculation
  • Uses ASBR cost for tiebreaking

Equal Cost Multi-Path (ECMP)

Load Balancing

OSPF supports equal-cost load balancing across multiple paths with the same cost. This provides:

  • Increased bandwidth: Traffic distributed across links
  • Redundancy: Automatic failover if one path fails
  • Better utilization: More efficient use of network resources

ECMP Configuration

Cisco ECMP Configuration

# Set maximum equal-cost paths
router ospf 1
 maximum-paths 8

# Verify load balancing
show ip route 10.0.0.0
show ip cef 10.0.0.0 detail

Juniper ECMP Configuration

# Configure load balancing
routing-options {
    forwarding-table {
        export load-balance;
    }
}

# Policy for load balancing
policy-options {
    policy-statement load-balance {
        from protocol ospf;
        then load-balance per-packet;
    }
}

Route Calculation Tips

  • Monitor SPF frequency: Frequent runs indicate instability
  • Use route summarization: Reduces routing table size
  • Consider ECMP limits: More paths = more memory usage
  • Verify next-hops: Ensure reachability to forwarding addresses

LSA Flooding

LSA flooding is the mechanism by which OSPF distributes topology information throughout the network. It ensures all routers have consistent database information for accurate path calculations.

Flooding Principles

  • Reliable delivery: Uses acknowledgments and retransmission
  • Loop prevention: Tracks LSA source and avoids back-sending
  • Duplicate detection: Sequence numbers prevent duplicates
  • Scope control: Different LSA types have different flooding scopes
  • Optimization: Uses designated routers on multi-access networks

Flooding Algorithm

Receive LSU
Validate LSA
Install in LSDB
Flood to Neighbors
Wait for LSAck

Flooding Validation Steps

  • Checksum verification: Ensure LSA integrity
  • LS Type validation: Check if type is supported
  • Age check: Discard if MaxAge exceeded
  • Scope verification: Ensure appropriate area/domain

  • Lookup existing LSA: Search by Type, LSID, AdvRouter
  • Sequence number comparison: Determine newer LSA
  • Age comparison: Handle special MaxAge case
  • Identical LSA detection: Avoid unnecessary processing

  • Install in database: If newer than existing
  • Send LSAck: Acknowledge receipt to sender
  • Flood to neighbors: Except the sender
  • Trigger SPF: If topology change detected

Flooding Scopes

LSA Type Flooding Scope Boundaries Special Handling
Type 1 (Router) Area-local Stops at area boundaries Generated by each router
Type 2 (Network) Area-local Stops at area boundaries Generated by DR only
Type 3 (Summary) Area-local Generated at area boundaries ABR regenerates per area
Type 4 (ASBR Sum) Area-local Generated at area boundaries ABR regenerates per area
Type 5 (External) AS-wide Blocked by stub areas Flooded throughout AS
Type 7 (NSSA Ext) NSSA-local Converted to Type 5 at ABR Special NSSA handling

Network Type Flooding Behavior

Broadcast Networks
  • DROther → DR/BDR: 224.0.0.6
  • DR → All: 224.0.0.5
  • Optimization: Reduces flooding
  • Acknowledgment: Back to DR
Point-to-Point
  • Direct flooding: Between neighbors
  • Multicast: 224.0.0.5
  • No DR/BDR: Simple flooding
  • Immediate Ack: Fast convergence

Flooding Optimization

Performance Optimizations

  • LSA Pacing: Controls LSA generation rate
  • Flooding Reduction: DR/BDR on multi-access networks
  • Incremental SPF: Partial recalculations
  • LSA Grouping: Multiple LSAs per LSU packet

Flooding Timer Configuration

Cisco Flooding Timers

# LSA pacing (default 240ms)
router ospf 1
 timers lsa-group-pacing 240

# Retransmission interval
interface GigabitEthernet0/0
 ip ospf retransmit-interval 5

# Show flooding statistics
show ip ospf statistics

Juniper Flooding Configuration

# Retransmission interval
protocols {
    ospf {
        area 0.0.0.0 {
            interface ge-0/0/0.0 {
                retransmit-interval 5;
            }
        }
    }
}

# Show flooding statistics
show ospf statistics

Troubleshooting Flooding Issues

Common Flooding Problems

  • Missing LSAcks: Check network connectivity
  • Excessive retransmissions: Adjust retransmit timers
  • Database inconsistencies: Verify flooding scope
  • High CPU during flooding: Consider LSA pacing