Introduction - OSPF

Networking enables communication by forwarding data through interconnected devices (hops) until it reaches its destination. A crucial step in this process is defining routing protocols, which can be either:
Static Routing (manually configured routes)
Dynamic Routing (automatically adapting to network changes): RIP, OSPF, BGP

What is OSPF

Among dynamic routing protocols, OSPF (Open Shortest Path First) is one of IGP and uses link-state protocol designed for routing within an Autonomous System (AS).
Routers exchange routing info by Link-State Advertisements (LSAs) which store in LSDB, use Dijkstra’s Algorithm to calculate the shortest path, and encapsulate OSPF packets in IP (protocol number 89).

Area

Area0 is the backbone area, other areas use a router and at least 1 interface to connect area0. Routers connecting >=2 areas -> Area Border Router(ABR)
Routers’ some interfaces connecting to other AS -> Autonomous System Border Router(ASBR)

DR/BDR

If routers use serial interface(point to point link) won’t have DR/BDR, only works on ethernet interface which is multi-access networks, but Serial interface p2p can build OSPF neighbors.
Sometimes, who interfaces up first becomes DR. If you modify the router-id + reset OSPF process(have to), then DR is not you anymore.
Full mesh connection is n(n-1) / 2 . So I need to pick DR among >=3 routers. If any routing updater, routers send updates to DR, DR collects routing and advertises to all routers. If DR is down, BDR replaced; if BDR down, DROTHER replaced no matter if you change router-id higher in the middle which means if router-id setup and router keep running, its DR role won’t be stolen.

Neighbor

Infomation of Neighbor

1.Router use multicast to search neighbor
2.DR/BDR election(compare priority first, then router-id)
3.timer hello interval and dead interval

Neighbor table

Can see it when OSPF finishes connecting with neighbors and exchanges LSA.
Router ID: default neighbor’s IP; if no router-id, will use loopback interface biggest IP; if no loopback interface, choose another interface’s biggest IP who joins OSPF.
Priority: highest pri of router becomes DR. The second largest became BDR.
State: FULL/DR or FULL/BDR

OSPF message

  • HELLO message
    discover & maintain neighbors, sent at 10s intervals as default
  • Database Description(DD) message
    LSA summary, synchronize both of them’s LSDB
  • LinkStateRequest(LSR) message
    equest missing LSAs
  • LinkStateUpdate(LSU) message
    provide requested LSAs
  • LinkStateAck message
    confirm receive LSUs

OSPF status

There are status when building neighbors

  • Down
    not yet HELLO message yet
  • Init
    just sent HELLO message
  • 2-Way
    start communication, receive HELLO messages between each other. This time elect DR and BDR, if cannot become them, become DROTHER.
  • ExStart
    prepare to exchange link info
  • Exchange
    Exchange DBD(database description) and determine if LSA sync is needed. For this stage, only exchange LSA summary.
  • Loading
    Exchange specific LSAs to synchronize/ their LSDBs.(LSR, LSU,LSAck)
  • Full
    update to date LSDB across OSPF domain

OSPF LSAs Types

Type Name Purpose Generated By Flooding Scope
1 Router LSA Describes the router’s links and interfaces/cost within an area. Every OSPF router Within the same area
2 Network LSA Describes multi-access networks and the DR’s attached routers. Designated Router (DR) Within the same area
3 Summary LSA Advertises routes from one area to another (inter-area routes). Area Border Router (ABR) Across OSPF areas
4 ASBR Summary LSA Advertises the location of an ASBR. ABR Across OSPF areas
5 AS External LSA Advertises routes external to the OSPF domain (e.g., routes from BGP). ASBR Throughout the OSPF AS
7 NSSA External LSA Advertises external routes in a Not-So-Stubby Area (NSSA). ASBR in NSSA Within the NSSA area

OSPF Area Types

Stub area: only accept type 1,2,3 LSAs(will automatically add 0.0.0.0/0).
Totally Stub area: only accept type 1, 2 LSAs (will automatically add 0.0.0.0/0).
Above two efficiently reduce LSAs sending, decreasing bandwidth load, and making LSDB&routing table less workload. Usercase has internal routers and one ABR to reach other networks.
NSSA area: keep 1,2,3 type, remove 4&5, + 7
Totally NSSA: keep 1,2 type + type7
If one area connects to the External Network, can use NSSA(Not So Stubby area), all routers in this kind area set NSSA.

Path selection

  1. R1 provide four routes to reach 6.6.6.6 and metrics are same: will pick priority(high-low):
    via R5 Intra-area Router(O), via R4 inter-area Router(O IA), via R3 is E1 external Router(O E1)
  2. If same route type(inter, intra, external route)
    OSPF chooses metrics put into the route table.
Author: Yu
Link: https://yurihe.github.io/2025/04/03/6.ospf/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.