OSPF
OSPF
Introduction
The history of OSPF can be traced back to the early 1980s, when the internet was still in its early stages of development. At the time, the
most common routing protocol was RIP (Routing Information Protocol), but RIP had a number of limitations, such as its inability to support
large networks or to distribute external routes.
In response to the limitations of RIP and to develop a new routing protocol, the IETF (Internet Engineering Task Force) -
• Formed a working group in 1998.
• In 1991, published RFC 1247, which defined the first version of OSPF.
• In 1998, published RFC 2328, which defines the current version of OSPF (OSPFv2).
• In 1999, published RFC 2740, which defines OSPFv3 for IPv6 networks.
OSPF is now one of the most widely used routing protocols worldwide. In fact, it the most used IGP (Interior Gateway Protocol). OSPF
has continued to evolve over the years, and the IETF continues to publish new RFCs that define new features and enhancements for OSPF.
OSPF is an IGP (Interior Gateway Protocol) but it can also Redistribute External Routes from different Autonomous System into its routing
table. This routing protocol is known for its scalability, reliability and support for advanced features such as authentication and traffic
engineering.
Key Features
• OSPF stands for Open Shortest Path First. It uses Dijkstra’s Algorithm (SPF).
• IGP (Interior Gateway Protocol) - route traffic within a single AS (Autonomous System).
• Standard Protocol – Cisco/Non-Cisco devices.
• Link-State Protocol – sent LSAs (Link-State Advertisement) periodically.
• Thus, convergence is Fast (40 seconds).
• Protocol number 89.
• AD (Administrative Distance) value 110.
• Multicast address 224.0.0.5 for normal communication and 224.0.0.6 for update to DR/BDR (Designated Router/Backup
Designated Router).
• Supports equal Load balancing.
• No automatic summarization.
• Multiple Areas.
• Different OSPF Processes in a single autonomous system.
• Supports CIDR (Classless Inter-Domain Routing).
• No limit for number of Hops (routers) connected.
24 bytes
Area ID Checksum: To perform error checking.
Checksum Authentication Type Authentication Type: Authentication type ranging
Authentication from 0 to 2 respectively non-authentication, simple
Authentication (plaintext) authentication, and MD5 authentication.
Authentication: Data used for authentication.
How it works!
OSPF works in three steps mainly:
1. Becoming Neighbors: OSPF routers discover and establish neighbor relationships with other OSPF routers on the same network
segment by sending Hello packets.
To see the neighbor table, type this command in privileged EXEC mode:
‘show ip ospf neighbor’
2. Exchanging Database: OSPF routers exchange Link-State Advertisements (LSAs) to create and maintain a synchronized link-state
database. LSAs contain information about the routers, links, and subnets within the OSPF area.
To see the database table, type this command in privileged EXEC mode:
‘show ip ospf database’
3. Calculating Best Route: OSPF use Dijkstra's algorithm to calculate the shortest path tree (SPF tree). The SPF tree represents the
best paths to reach all destinations within the OSPF area.
To see the routing table, type this command in privileged EXEC mode:
‘show ip route’
Becoming Neighbors
OSPF process stars with a Hello message. There are 3 states in becoming neighbors:
2-Way 2-Way
Router ID: 1.1.1.1 Router ID: 2.2.2.2
Becoming Neighbors
Router ID: A 32 bit unique number. OSPF router is identified using same ID in all directions. It is selected in following cascading
selection:
1. Manually assigned. To reset the Router ID, use following
‘Router(config)# router ospf 1’ command in privileged EXEC mode:
‘Router(config-router)# router-id 1.1.1.1’ ‘Router# clear ip ospf process’
2. Highest ‘up’ status loopback interface IP address.
3. Highest ‘up’ status physical interface IP address.
Dead Interval the designated router. If the Priority is set to 0, the router
does not participate in the DR/BDR selection.
Designated Router (DR)
Dead Interval: Time before declaring a silent router down. It
Backup Designated Router
is four times hello interval.
Neighbor
DR: IP address of the Designated Router.
…
BDR: IP address of the Backup Designated Router.
***Initial DR, BDR & Neighbors are “0.0.0.0” Neighbors: Router ID of the neighbor routers.
Exchanging Database
After becoming neighbors, routers starts to flood the summary information of LSAs. There are some states to become adjacent router:
Exchange Exchange
Router ID: 1.1.1.1 Router ID: 2.2.2.2
Here is the summary
DD Packets of my DB!
My RID: 2.2.2.2
Exchange Exchange
Router ID: 1.1.1.1 Router ID: 2.2.2.2
Full Full
Router ID: 1.1.1.1 Router ID: 2.2.2.2
There is another state named “Attempt” state. It is only seen in NBMA (Non-Broadcast Multi Access) links. In NMBA, we have to manually
configure the neighbor’s IP because it doesn’t support multicast. Then, hello packets are sent unicast to manually configured neighbor IP.
IP Header OSPF Header OSPF LSU Packet IP Header OSPF Header OSPF LSAck Packet
0 7 15 31 0 7 15 31
Number of LSAs LSA Header
LSAs …
… LSA Header
Number of LSAs: the number of LSAs contained in the LSU LSA Header: A list of received LSA headers; a single LSAck
packet. packet can contain multiple LSA headers.
LSAs: LSAs to be advertised in LSU packets; multiple LSAs
can be included and advertised in a single LSU packet. The
LSA consists of LSA header and LSA data.
LSA Flooding
R3
R5 LSA R5 LSA
R5 LSA R5 LSA
R1 R2 R5
R5 LSA R5 LSA
R4
Maintaining Updates
Maintaining Neighbors and the LSDB-
• Incremental updates (whenever there is a change).
• Hello packets are sent periodically every 10 seconds and Dead time is 40 seconds.
• Convergence rate is fast (40 seconds).
Periodic Updates-
• Each router re-flood the LSA every 30 minutes by default even if no changes occur.
• But the network is not overloaded with flooding LSAs. Why?
Because, each LSA has e separate timer, based on when the LSA was created.
Basic Configurations
Process ID: 32 bit Process ID is a number used
to identify an OSPF routing process on the
router. Multiple OSPF processes can be started
on the same router. This process ID is locally
significant. Its range is 0 to 65535.
‘R1(config)# router ospf <process ID>’
Network ID: Advertising network’s IP address.
‘R1(config-router)# network <network ID> <wildcard mask> area <area ID>’
Wildcard Mask: Tell the IOS which portion of
the bits to match or ignore.
• Decimal 0 (Min): The router must compare
this octet as normal .
• Decimal 255 (Max): The router ignores this
octet, considering it to already match.
Area ID: OSPF area number in which this
interface/network will exist.
Neighbor Table
Neighbor ID: The router ID of the neighbor.
Pri: The priority value is used in the OSPF
neighbor election process. It determines the
likelihood of a router becoming the Designated
Router (DR) or Backup Designated Router (BDR)
on a multi-access network segment.
State: The current status of neighborship.
Dead Time: time interval within which OSPF
routers expect to receive Hello packets from their
neighbors, if not received it will go to down state.
Address: IP address of the neighbor.
Interface: the specific interface through which the
OSPF neighbor is reachable.
Database Table
• OSPF Database Table is called LSDB.
• Each Entry in LSDB is known as LSA.
Link ID: What the Link State ID contains depends on the type of LSA. Checksum: A checksum value calculated for
ADV Router: IP address of the OSPF router that originated or advertised the LSA. the LSA's contents. Routers use this value to
Age: indicates how long (in seconds) ago the LSA was originally generated by the verify the integrity of the LSA during
advertising router. It helps routers determine the freshness of the routing transmission.
Route Table
• Destination Network IP address with its
Subnet Mask (CIDR) value.
• Administrative Distance and Cost
(Metric) value (lowest).
• Next Hop ID Address
• Existing Route duration time.
• Interface through which traffic should be
sent to reach the destination network.
Protocols Table
In Route Table, we only get the best route to
get to the destination network. But in OSPF
Route Table, we get every possible route
found to get to the destination network by
OSPF routing protocol with their Destination IP
Address (with CIDR value), Administrative
Distance, Cost (Metric), Next Hop IP Address,
Existing Route Duration Time and Source
Interface IP Address.
Interfaces
This command provides details about
OSPF-enabled interfaces, including their
state, IP addresses, area assignments,
hello time, dead time, waiting time,
process ID and many more.
Cost Metric
• OSPF uses SPF (Shortest Path First) algorithm to calculate the best route.
• The sum of the OSPF interface costs for all outgoing interfaces in the route.
• Router then adds each route to its routing table. 𝑹𝒆𝒇𝒆𝒓𝒆𝒏𝒄𝒆 𝑩𝒂𝒏𝒅𝒘𝒊𝒅𝒕𝒉
• The Formula used to calculate the OSPF cost is: Cost = 𝑰𝒏𝒕𝒆𝒓𝒇𝒂𝒄𝒆 𝑩𝒂𝒏𝒅𝒘𝒊𝒅𝒕𝒉
• By default, Reference Bandwidth is 𝟏𝟎𝟖 in bps (bit per second)
• Default Cost Metric value is given below:
Interface Default
Interface Bandwidth (Kbps) Formula (Kbps) OSPF Cost
Serial 1544 100,000/1544 64
Ethernet 10,000 100,000/10,000 10
Fast Ethernet 100,000 100,000/100,000 1
Gigabit Ethernet 1,000,000 100,000/1,000,000 1
10 Gigabit Ethernet 10,000,000 100,000/10,000,000 1
100 Gigabit Ethernet 100,000,000 100,000/100,000,000 1
Cost Metric
There are three ways to change interface cost in cisco routers:
1. Changing Interface Bandwidth: It will change the total cost metric of
interface by using the interface subcommand- ‘bandwidth <value>’
2. Changing Default Reference Bandwidth: Any interface with an interface
bandwidth of 100 Mbps or
faster ties with a calculated
OSPF cost of 1 which is a
limitation. It is probably not
the right basis for choosing
routes. It can be changed by using this command-
‘auto-cost reference-bandwidth <value>’
3. Changing Cost Manually: Manually setting the cost will replace the
calculated cost metric. Thus the calculated best route might also change.
We can change the cost manually using the interface subcommand- ***Ci sco recommends making the OS PF reference bandwidth
settings the same on all OSPF routers in an Enterprise Network.
‘ip ospf cost <value>’
OSPF Area
Single Area Limitations: OSPF Multiple Area:
• Larger topology requires more memory on router. • Multiple area allows to logically group set of routers in one area.
• Too many LSAs may cause network overload. • It will break one large LSDB into several smaller LSDBs.
• Take more CPU time & resources to run SPF algorithm. • Minimizes the CPU & memory resources.
• A single interface status change anywhere forces every router • Convergence becomes fast.
to run SPF again. • Any changes are restricted, LSA advertised in the particular
• Convergence time becomes very slow. area only.
• OSPF area range 0 to 4294967295.
OSPF Multiple Area Design Rules:
• In each area, recommended number of router is less than 30 to 50.
• Two or more area must have at least one area named ‘area 0’ which is called the backbone area.
• All the non-backbone areas must connect to area 0. Else it cannot advertise its networks in other areas by default.
• There must be at least one ABR (Area Border Router) connecting two or more areas.
• Interfaces of both routers facing must be in the same area.
ABR ABR
3 4
Types of Routers
• IR (Internal Router): IRs are routers that have all their interfaces in the same OSPF area. They don’t have interfaces in multiple
OSPF areas. They maintain the OSPF Database for their area and participate in the calculation of the best routes within the area.
• ABR (Area Border Router): An ABR is a router that is connected to two or more OSPF areas. They maintain an LSDB for each
area and serve as a gateway, thus summarize routes from one area to another, reducing the size of the OSPF database in each area.
• ASBR (Autonomous System Border Router): Connect the OSPF routing domain to external networks or other routing domains,
such as those using different routing protocols. ASBRs redistribute external routes into the OSPF routing domain and vice versa.
• BR (Backbone Router): Backbone Routers are routers that have at least one interface in the OSPF backbone area (Area 0).
Backbone Routers are crucial for interconnecting OSPF areas.
• DR (Designated Router): Elected on multi-access network segments (Ethernet) to reduce OSPF traffic and adjacencies. The DR
is responsible for generating network-specific LSAs (Type 2 LSAs) & forwarding OSPF updates to other routers on the same segment.
• BDR (Backup Designated Router): The BDR monitors the DR and quickly assumes the DR role if the DR becomes unavailable.
This ensures redundancy and stability on multi-access segments.
• VLR (Virtual Link Router): Virtual Routers are routers that establish virtual links to connect OSPF areas when physical connectivity
to the backbone area (Area 0) is not possible. They allow routers in non-backbone areas to reach the backbone area indirectly.
• SR (Stub Router): A stub router is a router that is connected to only one OSPF area and does not exchange routing information
with other areas. Stub routers are typically used in small networks.
Network Types
Primarily, there are three types of OSPF network-
OSPF
Point-to-Point Network
➢ A single point-to-point link is a single pair of router.
➢ Does not support the ability to add a third router to the link.
➢ Usually a serial interface running either PPP or HDLC.
➢ May also be a point-to-point sub-interface running Frame
Relay or ATM.
➢ No election of DR or BDR is required.
➢ OSPF packets are sent using multicast 224.0.0.5.
➢ OSPF auto-detects this interface type.
Point-to-Point over Ethernet Links:
Most of the WAN Ethernet connections can be P2P. Like-
Ethernet Private Wire Service, Ethernet Line, etc. In this
scenario, Ethernet DR/BDR adds a extra convergence time.
P2P over ethernet links can be done using the commands-
‘R1(config)# interface se0/1/0’
‘R1(config-if)# ip ospf network point-to-point’
Broadcast Network
DROTHER DROTHER
➢ OSPF by default uses Broadcast network type on all types
of Ethernet interfaces.
➢ In broadcast multi-access networks there is two challenges-
• Multiple adjacencies. DR BDR
• Flooding of LSAs.
➢ These challenges are solved by electing DR and BDR.
➢ All neighbor routers form full adjacencies with the DR and
BDR only.
➢ The DROTHER routers will never update other routers in
the network.
➢ DROTHER DR, use multicast 224.0.0.6
DR DROTHER, use multicast 224.0.0.5.
PDU: A protocol data unit is a single unit of information transmitted among peer entities of a computer network.