OSFP Notes/Advance OSPF
OSPF sends link-state advertisements (LSAs) to neighbouring routers.
An LSA contains information on the link state and link metric
OSPF advertises this information to neighbouring routers exactly as the original advertising router advertised it.
Received LSAs are stored in a local database of Routers called the link-state database (LSDB).
All OSPF routers maintain a synchronized identical copy of the LSDB within an area.
The LSDB provides the topology of the network, in essence providing the router a complete map of the network.
All OSPF routers run Dijkstra’s shortest path first (SPF) algorithm to construct a loop-free topology of shortest paths.
OSPF dynamically detects topology changes within the network and calculates loop-free paths in a short amount of
time with minimal routing protocol traffic.
Each router sees itself as the root or top of the SPF tree (SPT)
SPT contains all network destinations within the OSPF domain.
The SPT differs for each OSPF router, but the LSDB used to calculate the SPT is
identical for all OSPF routers.
A router can run multiple OSPF processes.
Each process maintains its own unique database
routes learned in one OSPF process are not available to a different OSPF process.
The OSPF process numbers are locally significant and do not have to match among
routers.
If OSPF process number 1 is running on one router and OSPF process number
1234 is running on another, the two routers can become neighbours.
OSPF provides scalability for the routing table by splitting segments of the topology into multiple OSPF areas within
the routing domain.
An OSPF area is a logical grouping of routers or, more specifically, a logical grouping of router interfaces.
Area membership is set at the interface level, an interface can belong to only one area.
Area ID is included in the OSPF hello packet.
All routers within the same OSPF area maintain an identical copy of the LSDB.
An OSPF area grows in size as the number of network links and number of routers increase in the area.
While using a single area topology-
A full Unnecessary SPT calculation runs when a link flaps within the area.
With a single area, the LSDB increases in size and becomes unmanageable.
The LSDB for the single area grows, consumes more memory, and takes longer during
the SPF computation process.
With a single area, no summarization of route information occurs.
these issues resolve by proper segmenting the OSPF routing domain into multiple OSPF areas, keeping the LSDB a
manageable size.
If a router has interfaces in multiple areas, the router has multiple LSDBs (one for each area).
The internal topology of one area is invisible from outside that area.
If a topology change occurs (such as a link flap or an additional network added) within an area, all routers in the
same OSPF area calculate the SPT again.
Routers outside that area do not calculate the full SPT again but do perform a partial SPF calculation.
OSPF area hides the topology from another area but allows the networks to be visible in other areas within the OSPF
domain. Segmenting the OSPF domain into multiple areas reduces the size of the LSDB for each area, making SPT
calculations faster and decreasing LSDB flooding between routers when a link flaps.
Area 0 is a special area called the backbone or backbone area
all areas must connect to the upper tier Area 0 because OSPF expects all areas to inject routing information into Area0
Area 0 advertises the routes into other non-backbone areas. The backbone design is crucial to preventing routing
loops.
The area identifier (also known as the area ID) is a 32-bit field and can be formatted in simple decimal (0 through
4294967295) or dotted decimal (0.0.0.0 through 255.255.255.255).
When configuring routers in an area, even if you use decimal format on one router and dot- ted-decimal format on a
different router, the routers will be able to form an adjacency.
OSPF advertises the area ID in the OSPF packets.
Area border routers (ABRs) are OSPF routers connected to Area 0 and another OSPF area ABRs are responsible for
advertising routes from one area and injecting them into a different OSPF area.
Every ABR needs to participate in Area 0 to allow for the advertisement of routes into another area.
Inter-Router Communication
OSPF runs directly over IPv4, using protocol 89 in the IP header, which the Internet Assigned Numbers Authority
(IANA) reserves for OSPF.
OSPF uses multicast where possible to reduce unnecessary traffic. There are two OSPF multicast addresses:
AllSPFRouters: IPv4 address 224.0.0.5 or MAC address 01:00:5E:00:00:05. All routers running OSPF should be able to
receive packets with this address.
AllDRouters: IPv4 address 224.0.0.6 or MAC address 01:00:5E:00:00:06. Communication with designated routers (DRs)
uses this address.
Within the OSPF protocol, five types of packets are communicated.
Hello Packets- are sent out periodically on all OSPF interfaces to discover new neighbors while ensuring that other
neighbors are still online.
Database description (DBD or DDP)-Packets are exchanged when an OSPF adjacency is first being formed. These
packets are used to describe the contents of the LSDB.
Link-state request (LSR)-When a router thinks that part of its LSDB is stale, it may request a portion of a neighbor’s
database by using this packet type.
Link-state update (LSU)-This is an explicit LSA for a specific network link, and normally it is sent in direct response
to an LSR.
Link-state acknowledgment-These packets are sent in response to the flooding of LSAs, thus making the flooding a
reliable transport feature.
Router ID/ neighbor ID
The OSPF router ID (RID) is a 32-bit number that uniquely identifies an OSPF router.
The RID must be unique for each OSPF process in an OSPF domain and must be unique between OSPF processes on
a router.
The RID is dynamically allocated by default, using the highest IP address of any up loopback interfaces. If there are no
up-loopback interfaces, the highest IP address of any active up physical interfaces becomes the RID when the OSPF
process starts.
The OSPF process selects the RID when the OSPF process starts, and it does not change until the process restarts.
This means that the RID can change if a higher loopback address has been added and the process (or router) is
restarted.
The RID is four octets in length and is configured with the command router-id router-id under the OSPF process.
process ID
The process ID is a local, unique identifier for a specific OSPF instance running on a router.
It allows multiple OSPF processes to be configured and managed on the same router.
The process ID is not shared between neighboring routers and can be different or same for each OSPF instance on a
router. process ID does not need to match on all OSPF routers within a network
OSPF neighbor states.
Down - The initial state of a neighbor relationship. It indicates that the router has not received any OSPF hello packets.
Attempt - A state that is relevant to non-broadcast multi-access (NBMA) networks that do not support broadcast and
that require explicit neighbor configuration. This state indicates that no recent information has been received, but the
router is still attempting communication.
Init - A state in which a hello packet has been received from another router, but bidirectional communication has not
been established.
2-Way - A state in which bidirectional communication has been established. If a DR or BDR is needed, the election
occurs during this state.
ExStart- The first state in forming an adjacency. Routers identify which router will be the primary or secondary for the
LSDB synchronization.
Exchange - A state during which routers are exchanging link states by using DBD packets.
Loading- A state in which LSR packets are sent to the neighbor, asking for the more recent LSAs that have been
discovered (but not received) in the Exchange State.
Full- A state in which neighboring routers are fully adjacent.
In OSPF, intra-area routing describes routing within the same area, while inter-area routing involves routing between
different areas. Intra-area routes are preferred by OSPF because they represent the most direct path within a single
area.
Intra-area routing:
• Routing within the same area:
Packets are routed using information gathered within the specific OSPF area.
LSA Type 1 and 2:
Intra-area routes are advertised using LSA Type 1 and 2, which contain information about the network topology within
the area.
Priority:
Intra-area routes are always preferred over inter-area routes to the same destination within the same OSPF process.
Routing table:
Intra-area routes are identified as "O" in the routing table.
Redistribution:
Intra-area routes can be redistributed to other OSPF processes or external routing protocols.
Inter-area routing:
• Routing between different areas:
Packets are routed between areas, typically involving Area Border Routers (ABRs).
LSA Type 3:
Inter-area routes are advertised using LSA Type 3, which summarizes network information from other areas.
Routing table:
Inter-area routes are identified as "O IA" in the routing table.
Virtual Links:
In OSPF, virtual links are used to connect areas that are not directly physically connected to the backbone.
Backbone Area:
All areas must be connected to the backbone area (area 0) for inter-area routing.
Priority:
Inter-area routes are preferred over external routes (learned from external protocols), but intra-area routes are always
preferred over inter-area route
OSPF Configuration
The configuration process for OSPF occurs mostly under the OSPF process, but some OSPF
options go directly on the interface configuration submode. The OSPF process ID is locally
significant but is generally kept the same for operational consistency. OSPF can be enabled
on an interface using two methods:
■ OSPF network statement
■ Interface-specific configuration
Sample Topology and Configuration
Figure 6-5 displays a reference topology for a basic multi-area OSPF configuration and will
be referenced frequently in other sections of this chapter. In the topology:
■ R1, R2, R3, and R4 belong to Area 1234.
■ R4 and R5 belong to Area 0.
■ R5 and R6 belong to Area 56.
■ R1, R2, and R3 are member (internal) routers.
■ R4 and R5 are ABRs.
■ Area 1234 connects to Area 0, and Area 56 connects to Area 0.
■ Routers in Area 1234 can see routes from routers in Area 0 (R4 and R5) and Area 56
(R5 and R6) and vice versa.
To demonstrate the different methods of OSPF configuration, the routers are configured as
follows:
■ R1 is configured to enable OSPF on all interfaces with one network statement.
■ R2 is configured to enable OSPF on both interfaces with two explicit network
statements.
■ R3 is configured to enable OSPF on all interfaces with one network statement but sets
the 10.3.3.0/24 LAN interface as passive to prevent forming an OSPF adjacency on it.
■ R4 is configured to enable OSPF using an interface-specific OSPF configuration.
■ R5 is configured to place all interfaces in the 10.45.1.0/24 network segment into Area 0
and all other network interfaces into Area 56.
■ R6 is configured to place all interfaces into Area 56 with one network statement.
■ On R1 and R2, OSPF is enabled on all interfaces with one command, R3 uses specific
network-based statements, and R4 uses interface-specific commands
R1
router ospf 1
router-id 192.168.1.1
network 0.0.0.0 255.255.255.255 area 1234
R2
router ospf 1
router-id 192.168.2.2
network 10.123.1.2 0.0.0.0 area 1234
network 10.24.1.2 0.0.0.0 area 1234
R3
router ospf 1
router-id 192.168.3.3
network 0.0.0.0 255.255.255.255 area 1234
passive-interface GigabitEthernet0/1
R4
router ospf 1
router-id 192.168.4.4
!
interface GigabitEthernet0/0
ip ospf 1 area 0
interface Serial1/0
ip ospf 1 area 1234
R5
router ospf 1
router-id 192.168.5.5
network 10.45.1.0 0.0.0.255 area 0
network 0.0.0.0 255.255.255.255 area 56
R6
router ospf 1
router-id 192.168.6.6
network 0.0.0.0 255.255.255.255 area 56
Output
OSPF NBR Output
The state for R2’s S1/0 interface does not reflect a DR status with its peering with R4 (192.168.4.4) because a DR does
not exist on a point-to-point link.
OSPF routes to networks learned from outside the OSPF domain that are injected into an OSPF domain through
redistribution are known as external OSPF routes.
When a router redistributes prefixes into an OSPF domain, the router is called an autonomous system boundary
router (ASBR). An ASBR can be any OSPF router, and the ASBR function is independent of the ABR function. An
OSPF domain can have an ASBR without having an ABR. An OSPF router can be an ASBR and an ABR at the same
time.
In this topology:
■ R1, R2, and R3 are member (internal) routers.
■ R4 and R5 are ABRs.
■ R6 is the ASBR.
■ 172.16.6.0/24 is being redistributed as an OSPF external Type 1 route.
External OSPF network routes are marked as O E1 and O E2 in the routing table
The Designated Router and Backup Designated Router
Multi-access networks such as Ethernet (LANs) and Frame Relay networks allow more than
two routers to exist on a network segment.
This could cause scalability problems with OSPF as the number of routers on a segment increases. Additional routers
flood more LSAs on the segment, and OSPF traffic becomes excessive as OSPF neighbor adjacencies increase.
n (n – 1) / 2, where n represents the number of routers
OSPF overcomes this inefficiency by creating a pseudocode (that is, a virtual router) to manage the adjacency state
with all the other routers on that broadcast network segment. A router on the broadcast segment, known as the
designated router (DR), assumes the role of the pseudo node.
The DR reduces the number of OSPF adjacencies on a multi-access network segment because routers form full OSPF
adjacencies only with the DR and not with each other.
The DR is then responsible for flooding the update to all OSPF routers on that segment as updates occur
The DR/BDR process distributes LSAs in the following manner assuming that all OSPF
routers (DR, BDR, and DROTHER) on a segment form a full OSPF adjacency with the DR
and BDR:
Step 1. As an OSPF router learns of a new route, it sends the updated LSA to the All- DRouters (224.0.0.6) address,
which only the DR and BDR accept and process
Step 2. The DR sends a unicast acknowledgment to the router that sent the initial LSA update
Step 3. The DR floods the LSA to all the routers on the segment via the AllSPFRouters (224.0.0.5) address
Designated Router Elections
The DR/BDR election occurs with OSPF neighborship—specifically, during the last phase of the 2-Way neighbor state
and just before the ExStart state.
When a router enters the 2-Way state, it has already received a hello from the neighbor. If the hello packet includes an
RID other than 0.0.0.0 for the DR or BDR, the new router assumes that the current routers are the actual DR and BDR.
Any router with the OSPF priority of 1 to 255 on its OSPF interface attempts to become the DR. By default, all OSPF
interfaces use a priority of 1.
The routers place their RID and OSPF priority in their OSPF hellos for that segment. Routers then receive and
examine OSPF hellos from neighboring routers.
If a router identifies itself as a more favorable router than the OSPF hellos it receives, it continues to send out hellos
with its RID and priority listed.
If the hello received is more favorable, the router updates its OSPF hello packet to use the more preferable RID in the
DR field. OSPF deems a router more preferable if the priority for the interface is the highest for that segment. If the
OSPF priority is the same, the higher RID is more favorable.
When all the routers have agreed on the same DR, all routers for that segment become adjacent with the DR.
Then the election for the BDR takes place. The election follows the same logic as the DR election, except that the DR
does not add its RID to the BDR field of the hello packet.
The OSPF DR and BDR roles cannot be preempted after the DR/BDR election. Only upon the failure (or process
restart) of the DR or BDR does the election start to replace the role that is missing.
DR and BDR Placement
Modifying a router’s RID for DR placement is a bad design strategy. A better technique involves modifying the
interface priority/Router priority to a higher value than that of the existing DR.
Changing the priority to a value higher than that of the other routers (which
have a default value of 1) increases the chance of that router becoming the DR
for that segment on that Node
restart the OSPF process on the current DR/BDR for the changes to take effect
The priority can be set manually under the interface configuration with the command ip ospf priority 0-255 for IOS
nodes. Setting an interface priority to 0 removes that interface from the DR/BDR election immediately. Raising the
priority above the default value (1) makes that interface more favorable than interfaces with the default value
Basics
OSPF areas
OSPF backbone
Area border routers
OSPF packet types
OSPF neighbor states
Requirements of neighbor adjacency
OSPF network statement
Interface-specific configuration
External OSPF routes
The designated router
Designated router elections
DR and BDR placement
OSPF network types
Authentication
OSPF Network Types
OSPF uses six LSA types for IPv4 routing:
■ Type 1, router: LSAs that advertise prefixes within an area
■ Type 2, network: LSAs that indicate the routers attached to broadcast segment within
an area
■ Type 3, summary: LSAs that advertise prefixes that originate from a different area
■ Type 4, ASBR summary: LSA used to locate the ASBR from a different area
■ Type 5, AS external: LSA that advertises prefixes that were redistributed in to OSPF
■ Type 7, NSSA external: LSA for external prefixes that were redistributed in a local
NSSA area
LSA Types 1, 2, and 3 are used for building the SPF tree for intra-area and inter-area route
routes.
LSA Types 4, 5, and 7 are related to external OSPF routes (that is, routes that were
redistributed into the OSPF routing domain).
R1, R2, and R3 are member (internal) routers.
R4 and R5 are area border routers (ABRs).
R6 is the ASBR, which is redistributing the 172.16.6.0/24 network into OSPF.
LSA sequence number
OSPF uses the sequence number to overcome problems caused by delays in LSA propagation in a network.
The LSA sequence number is a 32-bit number used to control versioning.
When the originating router sends out LSAs, the LSA sequence number is incremented.
If a router receives an LSA sequence that is greater than the one in the LSDB, it processes the LSA.
If the LSA sequence number is lower than the one in the LSDB, the router deems the LSA old and discards it.
LSA Age and Flooding
Every OSPF LSA includes an age that is entered into the local LSDB that increases by 1 every second.
When a router’s OSPF LSA age exceeds 1800 seconds (that is, 30 minutes)
When originating router advertises a new LSA with the LSA age set to 0.
If the LSA age reaches 3600, the LSA is deemed invalid and is purged from the LSDB. The repetitive flooding of LSAs
is a secondary safety mechanism to ensure that all routers maintain a consistent LSDB within an area.
The age of the LSA on the router on which the command is being run. Values over 1800 are expected to refresh soon.
Network link type
Transit: A transit network indicates that an adjacency was formed and that a DR was elected on that link.
Point-to-point: A point-to-point link indicates that an adjacency was formed on a network type that does not use a
DR. Interfaces using the OSPF point-to-point network type advertise two links. One link is the point-to-point link type
that identifies the OSPF neighbor RID for that segment, and the other link is a stub network link
that provides the subnet mask for that network.
Stub-A stub network indicates that no neighbor adjacencies were established on that link. Point-to-point and transit
link types that did not become adjacent with another OSPF router are classified as a stub network link type. When an
OSPF adjacency forms, the link type changes to the appropriate type: point-to-point or transit.
LSA Types
show ip ospf database.
LSA Type 1: Router Link
Every OSPF router advertises a Type 1 LSA (router LSA).
Type 1 LSAs are the essential building blocks in the LSDB.
A Type 1 LSA entry exists for each OSPF-enabled link (that is, an interface and its attached networks only)
LSA Type 2: Network Link
A Type 2 LSA (network LSA) represents a multi-access network segment that uses a DR.
The DR always advertises the Type 2 LSA and identifies all the routers attached to that network segment.
If a DR has not been elected, a Type 2 LSA is not present in the LSDB because the corresponding Type 1 transit link
type LSA is a stub.
Type 2 LSAs are not flooded outside the originating OSPF area in an identical fashion to Type 1 LSAs.
LSA Type 3: Summary Link
Type 3 LSAs (summary LSAs) represent networks from other areas.
The role of the ABRs is to participate in multiple OSPF areas and ensure that the networks are associated with Type 1
LSAs are reachable in the non-originating OSPF areas.
ABRs do not forward Type 1 or Type 2 LSAs into other areas.
When an ABR receives a Type 1 LSA, it creates a Type 3 LSA referencing the network in the original Type 1 LSA. (The
Type 2 LSA is used to determine the network mask of the multi-access network.) The ABR then advertises the Type 3
LSA into other areas.
If an ABR receives a Type 3 LSA from Area 0 (backbone area), it regenerates a new Type 3 LSA for the non-backbone
area and lists itself as the advertising router with the additional cost metric.
LSA Type 5: External Routes
When a route is redistributed into OSPF, the router is known as an autonomous system boundary router (ASBR).
The external route is flooded throughout the entire OSPF domain as a Type 5 LSA (external LSAs).
Type 5 LSAs are not associated with a specific area and are flooded throughout the OSPF domain. Only the LSA age is
modified during flooding for Type 2 external OSPF routes.
Type 5 LSA exists in all OSPF areas of the routing domain.
LSA Type 4: ASBR Summary
A Type 4 LSA (ASBR summary LSA) locates the ASBR for a Type 5 LSA.
A Type 5 LSA is flooded through the OSPF domain, and the only mechanism to identify the ASBR is the RID.
Routers examine the Type 5 LSA, check to see whether the RID is in the local area, and if the ASBR is not local, they
require a mechanism to locate the ASBR.
Remember that the RID does not have to match an IP address on any OSPF router (including ASBRs).
Only Type 1 or Type 2 LSAs provide a method to locate the RID within an area
Type 4 LSAs provide a way for routers to locate the ASBR when the router is in a different area from the ASBR. A Type
4 LSA is created by the first ABR, and it provides a summary route strictly for the ASBR of a Type 5 LSA. The metric
for a Type 4 LSA uses the following logic:
■ When the Type 5 LSA crosses the first ABR, the ABR creates a Type 4 LSA with a metric set to the total path metric
to the ASBR.
■ When an ABR receives a Type 4 LSA from Area 0, the ABR creates a new Type 4 LSA with a metric set to the total
path metric of the first ABR plus the metric in the original Type 4 LSA
LSA Type 7: NSSA External Summary
A Type 7 LSA (NSSA external LSA) exists only in NSSAs where route redistribution is occurring. An ASBR
injects external routes as Type 7 LSAs in an NSSA.
The ABR does not advertise Type 7 LSAs outside the originating NSSA, but it converts the Type 7 LSA into a
Type 5 LSA for the other OSPF areas.
If the Type 5 LSA crosses Area 0, the second ABR creates a Type 4 LSA for the Type 5 LSA.
LSA Description
1 Router link
2 Network link
3 Summary link
4 ASBR summary
5 AS external
7 NSSA external
The previous section focuses on summarizing routes as they leave an area
OSPF Stubby Areas
OSPF stubby areas provide a method to filter out external routes and the option to block inter-area routes.
OSPF stubby areas are identified by the area flag in the OSPF hello packet.
Every router within an OSPF stubby area needs to be configured as a stub so that the routers can establish/maintain
OSPF adjacencies.
four types of OSPF stubby areas
■ Stub areas
■ Totally stubby areas
■ Not-so-stubby areas (NSSAs)
■ Totally Not-so-stubby areas (NSSAs)
Stub Areas
OSPF stub areas prohibit Type 5 LSAs (external routes) and Type 4 LSAs (ASBR summary LSAs) from
entering the area at the ABR.
The ABR of a stub area, the ABR generates a default route for the stub via a Type 3 LSA.
A Cisco ABR generates a default route when the area is configured as a stub and has an OSPF-enabled interface
configured for Area 0.
All routers in the stub area must be configured as stubs, or an adjacency cannot form because the area type flags in the
hello packets do not match. An area is configured as a stub with the OSPF process command area area-id stub
Totally Stubby Areas
An OSPF totally stubby area prohibits Type 3 LSAs (inter-area), Type 4 LSAs (ASBR summary LSAs), and
Type 5 LSAs (external routes) from entering the area at the ABR.
When an ABR of a totally stubby area receives a Type 3 or Type 5 LSA, the ABR generates a default route for the
totally stubby area.
Not-So-Stubby Areas
An OSPF not-so-stubby-area (NSSA) prohibits Type 5 LSAs from entering at the ABR but allows for
redistribution of external routes into the NSSA.
As the ASBR redistributes the route into OSPF in the NSSA, the ASBR advertises the route with a Type 7 LSA instead
of a Type 5 LSA.
When the Type 7 LSA reaches the ABR, the ABR converts the Type 7 LSA to a Type 5 LSA.
The ABR does not automatically advertise a default route when a Type 5 or Type 7 LSA is blocked. During
configuration, an option exists to advertise a default route to provide connectivity to the blocked LSAs; in addition,
other techniques can be used to ensure bidirectional connectivity.
Totally NSSAs
OSPF areas that need to block Type 3 and Type 5 LSAs and still provide the capability of redistributing external
networks into OSPF should use the OSPF totally NSSA.
When the ASBR redistributes the route into OSPF, the ASBR advertises the route with a Type 7 LSA.
As the Type 7 LSA reaches the ABR, the ABR converts the Type 7 LSA to a Type 5 LSA. When an ABR for a totally
NSSA receives a Type 3 LSA from the backbone,
ABR generates a default route for the totally NSSA. When an interface on the ABR is assigned to Area 0, it acts as the
trigger for the Type 3 LSA that leads to the default route generation within the totally NSSA.
OSPF Path Selection
OSPF executes Dijkstra’s shortest path first (SPF) algorithm to create a loop-free topology of
shortest paths.
All routers use the same logic to calculate the shortest path for each network.
Path selection prioritizes paths in the following order:
1. Intra-area
2. Inter-area
3. External Type 1
4. External Type 2