OSPF Notes
Introduction to OSPF
OSPF (Open Shortest Path First) is a link-state routing protocol, offering an alternative to the distance vector Routing Information Protocol (RIP). It provides faster convergence and better scalability for larger networks.
OSPFv2 is used for IPv4 networks.
OSPFv3 is used for IPv6 networks.
The primary focus is single-area OSPFv2.
Key features:
Areas: OSPF divides the routing domain into areas to control routing update traffic.
Link-state: OSPF uses link-state information, which includes network prefix, prefix length, and cost, to determine the best path to a destination.
Components of OSPF
Routing protocols like OSPF share similar components:
Routing Protocol Messages: Used to exchange route information.
Hello packet
Database description packet
Link-state request packet
Link-state update packet
Link-state acknowledgment
Data Structures: Messages help build data structures.
Adjacency database (neighbor table)
Link-state database (LSDB) topology table)
Forwarding database (routing table)
Routing Algorithm: Data structures are then processed using a routing algorithm.
Dijkstra shortest-path first (SPF) algorithm: Calculates the best routes based on cumulative cost to reach a destination.
OSPF maintains three databases:
Adjacency Database: Stores a list of neighboring routers.
Link-State Database (LSDB): Creates the topology table.
Forwarding Database: Creates the routing table.
Link-State Operation
OSPF routers follow a generic link-state routing process to achieve convergence:
Establish Neighbor Adjacencies
Exchange Link-State Advertisements
Build the Link State Database
Execute the SPF Algorithm
Choose the Best Route
Detailed Steps
Establish Neighbor Adjacencies: OSPF-enabled routers discover each other by sending Hello packets out of all OSPF-enabled interfaces.
Exchange Link-State Advertisements (LSAs): After establishing adjacencies, routers exchange LSAs, which contain the state and cost of each directly connected link. LSAs are flooded to adjacent neighbors until all routers in the area have all LSAs.
Build the Link-State Database (LSDB): OSPF-enabled routers build the topology table (LSDB) based on the received LSAs. The LSDB holds all information about the topology of the area.
Execute the SPF Algorithm: Routers execute the SPF algorithm to create the SPF tree.
Choose the Best Route
Single-Area and Multiarea OSPF
Single-Area OSPF: All routers are within one area; area 0 is the recommended best practice.
Multiarea OSPF: OSPF is implemented using multiple areas in a hierarchical fashion. All areas must connect to the backbone area (area 0). Routers interconnecting areas are Area Border Routers (ABRs).
Multiarea OSPF
Multiarea OSPF divides a large routing domain into smaller areas to support hierarchical routing. This approach offers several advantages:
Smaller Routing Tables: Reduced number of routing table entries due to network address summarization between areas.
Reduced Link-State Update Overhead: Minimizes processing and memory requirements through smaller areas.
Reduced Frequency of SPF Calculations: Limits the impact of topology changes within an area.
When a router receives new information about a topology change within its area, it must rerun the SPF algorithm, create a new SPF tree, and update the routing table. Routers in other areas only update their routing tables and LSDB, but do not rerun the SPF algorithm.
OSPFv3
OSPFv3 is the OSPFv2 equivalent for IPv6 networks. It exchanges routing information to populate the IPv6 routing table with remote prefixes.
Key points:
OSPFv3 Address Families supports both IPv4 and IPv6 (beyond the scope).
OSPFv3 uses IPv6 as the network layer transport, communicating with OSPFv3 peers and advertising IPv6 routes.
OSPFv3 uses the SPF algorithm to determine the best paths throughout the routing domain.
OSPFv2 and OSPFv3 have separate adjacency tables, topology tables, and IP routing tables.
Types of OSPF Packets
OSPF uses link-state packets (LSPs) to establish neighbor adjacencies and exchange routing updates:
Type 1: Hello packet: Used to establish and maintain adjacency with other OSPF routers.
Type 2: Database Description (DBD) packet: Contains an abbreviated list of the LSDB of the sending router; used by receiving routers to check against the local LSDB.
Type 3: Link-State Request (LSR) packet: Used by receiving routers to request more information about entries in the DBD.
Type 4: Link-State Update (LSU) packet: Used to reply to LSRs and to announce new information; contains different types of LSAs.
Type 5: Link-State Acknowledgment (LSAck) packet: Confirms receipt of the LSU (data field is empty).
Link-State Updates
Routers initially exchange Type 2 DBD packets, which are abbreviated lists of the LSDB of the sending router. Then, a Type 3 LSR packet is used by the receiving routers to request more information about an entry in the DBD. The Type 4 LSU packet is used to reply to an LSR packet. A Type 5 packet is used to acknowledge the receipt of a Type 4 LSU. LSUs are also used to forward OSPF routing updates, such as link changes.
An LSU contains one or more LSAs.
Hello Packet
The OSPF Type 1 packet is the Hello packet. Hello packets are used to:
Discover OSPF neighbors and establish neighbor adjacencies.
Advertise parameters on which two routers must agree to become neighbors.
Elect the Designated Router (DR) and Backup Designated Router (BDR) on multiaccess networks like Ethernet. Point-to-point links do not require DR or BDR.
OSPF Operational States
When an OSPF router is initially connected to a network, it attempts to:
Create adjacencies with neighbors
Exchange routing information
Calculate the best routes
Reach convergence
OSPF progresses through different states while attempting to reach convergence:
Down State
Init State
Two-Way State
ExStart State
Exchange State
Loading state
Full state
Establish Neighbor Adjacencies
When OSPF is enabled on an interface, the router sends a Hello packet containing its router ID out of all OSPF-enabled interfaces. The Hello packet is sent to the reserved All OSPF Routers IPv4 multicast address . Only OSPFv2 routers will process these packets.
When a neighboring OSPF-enabled router receives a Hello packet with a router ID that is not within its neighbor list, the receiving router attempts to establish an adjacency with the initiating router. This transition involves the Init and Two-Way states.
Synchronizing OSPF Databases
After the Two-Way state, routers transition to database synchronization states:
Decide First Router
Exchange DBDs
Send an LSR
In the ExStart state, the two routers decide which router will send the DBD packets first. The router with the higher router ID will be the first router to send DBD packets during the Exchange state.
In the Exchange state, the two routers exchange one or more DBD packets. A DBD packet includes information about the LSA entry header that appears in the LSDB of the router.
If the DBD packet has a more current link-state entry, the router transitions to the Loading state and sends an LSR.
The Need for a DR
Multiaccess networks can create two challenges for OSPF regarding the flooding of LSAs, as follows:
Creation of multiple adjacencies: Ethernet networks could potentially interconnect many OSPF routers over a common link. Creating adjacencies with every router is unnecessary and undesirable. It would lead to an excessive number of LSAs exchanged between routers on the same network.
adjacencies, where is the number of routers. For example, a multiaccess network with 20 routers would create 190 adjacencies.
Extensive flooding of LSAs: Link-state routers flood their LSAs any time OSPF is initialized, or when there is a change in the topology. This flooding can become excessive.
A Designated Router (DR) and Backup Designated Router (BDR) are elected to mitigate the flooding issue.
Reference Bandwidth and OSPF Cost
Cost Calculation: The OSPF cost is calculated using the formula: .
The default reference bandwidth is (100,000,000).
Routers in other areas receive updates regarding topology changes, but these routers only update the routing table, not rerun the SPF algorithm.
Link State Advertisements
Type 1: Router LSA – Generated by each Router for each area. Includes the Router ID, Link State info.
Type 2 Network LSA – Generated by the DR in broadcast multiaccess topologies. Lists the routers connected to the DR
Type 3 – Summary LSAs – Used by ABRs to describe networks from areas outside the local area to routers in the current area.
Type 4 – ASBR Summary LSAs – Used by ABRs to advertise ASBRs.
Type 5 – AS External LSA – Used to advertise routes external to the AS. (ASBR generates these)
Type 7 – NSSA External LSAs – Used within an NSSA to advertise routes external to the AS. Converted to type 5 at the ABR
OSPFv3 Renamed some of these LSAs and also contains two additional LSAs.
OSPF priority.
The routers in the network elect the router with the highest interface priority as the DR. The router with the second highest interface priority is elected as the BDR. The priority can be configured to be any number between 0 - 255.
If the interface priority value is set to 0, that interface cannot be elected as DR nor BDR. The default priority of multiaccess broadcast interfaces is 1.
If the current DR (R3) fails, the pre-elected BDR (R2) assumes the role of DR. Subsequently, an election is held to choose a new BDR. Because R1 is the only DROTHER, it is elected as the BDR.
The network command is used to determine which interfaces participate in the routing process for an OSPFv2 area. The basic syntax for the network command is network network-address wildcard-mask area area-id. Any interfaces on a router that match the network address in the network command can send and receive OSPF packets.
OSPF reference bandwidth
Cost = 100,000,000 bps / interface bandwidth in bps.
To assist OSPF in making the correct path determination, the reference bandwidth must be changed to a higher value to accommodate networks with links faster than 100 Mbps.
To adjust the reference bandwidth, use the auto-cost reference-bandwidth Mbps router configuration command.
show ip interface brief - This verifies that the desired interfaces are active with correct IP addressing.
show ip route- This verifies that the routing table contains all the expected routes.