Basic Concepts of OSPF
OSPF has the following functions:
Divides an Autonomous System (AS) into one or more logical areas.
Advertises routes by sending Link State Advertisements (LSAs).
Exchanges OSPF packets between devices in an OSPF area to synchronize routing information.
Encapsulates OSPF packets into IP packets and sends the packets in unicast or multicast mode.
Router ID
A router ID is a 32-bit unsigned integer, which identifies a router in an autonomous system (AS). A router ID must exist before the router runs OSPF.
A router ID can be manually configured or automatically obtained.
If no router ID has been configured, the router automatically obtains a router ID using the following methods in descending order of priority.
The router preferentially selects the largest IP address from its loopback interface addresses as the router ID.
If no loopback interface has been configured, the router selects the largest IP address from its interface IP addresses as the router ID.
A router can obtain a router ID again only after a router ID is reconfigured for the router or an OSPF router ID is reconfigured and the OSPF process restarts.
Area
When a large number of routers run OSPF, link state databases (LSDBs) become very large and require a large amount of storage space. Large LSDBs also complicate shortest path first (SPF) computation and overload the routers. As the network grows, the network topology changes, which results in route flapping and frequent OSPF packet transmission. When a large number of OSPF packets are transmitted, bandwidth usage efficiency decreases, and each router on a network has to recalculate routes in case of any topology change.
OSPF resolves this problem by partitioning an AS into different areas. An area is regarded as a logical group, and each group is identified by an area ID. A router, not a link, resides at the border of an area. A network segment or link can belong only to one area. An area must be specified for each OSPF interface.
OSPF areas include common areas, stub areas, and not-so-stubby areas (NSSAs). Table 5-1 describes these OSPF areas.
Common area |
Function |
Notes |
---|---|---|
Common area |
By default, OSPF areas are defined as common areas. Common areas include:
|
|
Stub area |
A stub area is a non-backbone area with only one area border router (ABR) and generally resides at the border of an AS. The ABR in a stub area does not transmit received AS external routes, which significantly decreases the number of entries in the routing table on the ABR and the amount of routing information to be transmitted. To ensure the reachability of AS external routes, the ABR generates a default route and advertises the route to non-ABRs in the stub area. A totally stub area allows only intra-area routes and ABR-advertised Type 3 link state advertisements (LSAs) carrying a default route to be advertised within the area. |
|
NSSA |
An NSSA is similar to a stub area. An NSSA does not advertise Type 5 LSAs but can import AS external routes. ASBRs in an NSSA generate Type7 LSAs to carry the information about the AS external routes. The Type 7 LSAs are advertised only within the NSSA. When the Type 7 LSAs reach an ABR in the NSSA, the ABR translates the Type 7 LSAs into Type 5 LSAs and floods them to the entire AS. A totally NSSA allows only intra-area routes to be advertised within the area. |
|
Router Types
Routers are classified as internal routers, ABRs, backbone routers, or ASBRs by location in an AS. Figure 5-1 shows the four router types.
Table 5-2 describes the four router types.
Router Type |
Description |
---|---|
Internal router |
All interfaces on an internal router belong to the same OSPF area. |
Area Border Router (ABR) |
An ABR connects the backbone area and non-backbone areas, and it can connect to the backbone area either physically or logically. An ABR can belong to two or more areas, one of which must be a backbone area. |
Backbone router |
At least one interface on a backbone router needs to belong to the backbone area. Internal routers in Area 0 and all ABRs are backbone routers. |
ASBR (AS Boundary Router) |
An ASBR exchanges routing information with other ASs. An ASBR does not necessarily reside on the border of an AS. It can be an internal router or an ABR. An OSPF device importing external routing information will become an ASBR. |
LSA Types
OSPF encapsulates routing information into LSAs for transmission. Table 5-3 describes LSAs and their functions.
LSA Type |
Function |
---|---|
Router-LSA (Type 1) |
Describes the link status and cost of a router. Router-LSAs are generated by a router and advertised within the area to which the router belongs. |
Network-LSA (Type 2) |
Describes the link status of all routers on the local network segment. Network-LSAs are generated by a designated router (DR) and advertised in the area where the DR resides. |
Network-summary-LSA (Type 3) |
Describes routes on a network segment of an area. Network-summary-LSAs are generated by an ABR and advertised to other areas, excluding the totally stub area and totally NSSA. For example, an ABR belongs to both area 0 and area 1, area 0 has a network segment 10.1.1.0, and area 1 has a network segment 11.1.1.0. In this case, for area 0, the ABR generates Type 3 LSAs destined for the network segment 11.1.1.0; for area 1, the ABR generates Type 3 LSAs destined for the network segment 10.1.1.0. |
ASBR-summary-LSA (Type 4) |
Describes routes of an area to the ASBRs of other areas. ASBR-summary-LSAs are generated by an ABR and advertised to other areas, excluding the stub area, totally stub area, NSSA, totally NSSA, and area to which the ASBR of the route generation ABR belongs. |
AS-external-LSA (Type 5) |
Describes routes to a destination outside an AS. AS-external-LSAs are generated by an ASBR and advertised to all areas except stub areas and NSSAs. |
NSSA-LSA (Type 7) |
Describes routes to a destination outside an AS. NSSA-LSAs are generated by an ASBR and advertised in NSSAs only. |
Opaque-LSA (Type 9/Type 10/Type 11) |
Provides a universal mechanism for OSPF extension.
|
Table 5-4 describes whether a type of LSA is supported in an area.
Area Type |
Router-LSA (Type 1) |
Network-LSA (Type 2) |
Network-summary-LSA (Type 3) |
ASBR-summary-LSA (Type 4) |
AS-external-LSA (Type 5) |
NSSA-LSA (Type 7) |
---|---|---|---|---|---|---|
Common area (including standard and backbone areas) |
Supported |
Supported |
Supported |
Supported |
Supported |
Not supported |
Stub area |
Supported |
Supported |
Supported |
Not supported |
Not supported |
Not supported |
Totally stub area |
Supported |
Supported |
Not supported |
Not supported |
Not supported |
Not supported |
NSSA |
Supported |
Supported |
Supported |
Not supported |
Not supported |
Supported |
Totally NSSA |
Supported |
Supported |
Not supported |
Not supported |
Not supported |
Supported |
Packet Types
OSPF encapsulates protocol packets directly with IP packets. The protocol number is 89. OSPF packets are classified as Hello, Database Description (DD), Link State Request (LSR), Link State Update (LSU), or Link State Acknowledgment (LSAck) packets. Table 5-5 describes OSPF packets and their functions.
Packet Type |
Function |
---|---|
Hello packet |
Hello packets are periodically sent to discover and maintain OSPF neighbor relationships. |
Database Description (DD) packet |
DD packets contain the summaries of LSAs in the local LSDB. DD packets are used for LSDB synchronization between two routers. |
Link State Request (LSR) packet |
LSR packets are sent to OSPF neighbors to request required LSAs. A router sends LSR packets to its OSPF neighbor only after DD packets have been successfully exchanged. |
Link State Update (LSU) packet |
LSU packets are used to transmit required LSAs to OSPF neighbors. |
Link State Acknowledgement (LSAck) packet |
LSAck packets are sent to acknowledge LSA receipts. |
Route Types
Route types are classified as intra-area, inter-area, Type 1 external, or Type 2 external routes. Intra-area and inter-area routes describe the network structure of an AS. Type 1 or Type 2 AS external routes describe how to select routes to destinations outside an AS.
Table 5-6 describes OSPF routes in descending order of priority.
Route Type |
Description |
---|---|
Intra-area route |
Indicates routes within an area. |
Inter-area route |
Indicates routes between areas. |
Type 1 external route |
Type 1 external routes have high reliability. Cost of a Type 1 external route = Cost of the route from a router to an ASBR + Cost of the route from the ASBR to the destination When multiple ASBRs exist, the cost of each Type 1 external route equals the cost of the route from the local device to an ASBR plus the cost of the route from the ASBR to the destination. The cost is used for route selection. |
Type 2 external route |
Because a Type 2 external route has low reliability, its cost is considered to be much greater than the cost of any internal route to an ASBR. Cost of a Type 2 external route = Cost of the route from an ASBR to the destination If routes are imported by multiple ASBRs, the route with the smallest cost from the corresponding ASBR to its destination is selected. If the routes have the same cost from the corresponding ASBR to each route destination, the route with the smallest cost from the local router to the corresponding ASBR is selected. The cost of each Type 2 external route equals the cost of the route from the corresponding ASBR to the destination. |
Network Types
Networks are classified as broadcast, non-broadcast multiple access (NBMA), point-to-multipoint (P2MP), or point-to-point (P2P) networks by link layer protocol. Table 5-7 describes the network types.
Network Type |
Description |
---|---|
Broadcast |
If a network uses Ethernet or Fiber Distributed Data Interface (FDDI) as the link layer protocol, OSPF defaults it to a broadcast network. On a broadcast network:
|
Non-Broadcast Multi-Access (NBMA) |
If a network uses frame relay (FR) or X.25 as the link layer protocol, OSPF defaults it to an NBMA network. On an NBMA network, protocol packets such as Hello packets, DD packets, LSR packets, LSU packets, and LSAck packets are sent in unicast mode. |
Point-to-Multipoint (P2MP) |
OSPF does not default any network to a P2MP network regardless of its link layer protocol. Therefore, a P2MP network must be forcibly changed from another network type. It is a common practice to change a non-fully meshed NBMA network to a P2MP network. On a P2MP network:
|
Point-to-point (P2P) |
If a network uses PPP, HDLC, or LAPB as the link layer protocol, OSPF defaults it to a P2P network. On a P2P network, protocol packets, such as Hello packets, DD packets, LSR packets, LSU packets, and LSAck packets, are sent in multicast mode using the multicast address 224.0.0.5. |
OSPF Packet Authentication
OSPF supports packet authentication. Only the OSPF packets that have been authenticated can be received. If OSPF packets are not authenticated, a neighbor relationship cannot be established.
A router supports two authentication methods:
Area-based authentication
Interface-based authentication
When both area-based and interface-based authentication methods are configured, interface-based authentication takes effect.
DR and BDR
On broadcast or NBMA networks, any two routers need to exchange routing information. As shown in Figure 5-2, n routers are deployed on the network. n x (n - 1)/2 adjacencies must be established. Any route change on a router is transmitted to other routers, which wastes bandwidth resources. OSPF resolves this problem by defining a DR and a backup designated router (BDR). After a DR is elected, all routers send routing information only to the DR. Then the DR broadcasts LSAs. routers other than the DR and BDR are called DR others. The DR others establish only adjacencies with the DR and BDR and not with each other. This process reduces the number of adjacencies established between routers on broadcast or NBMA networks.
If the original DR fails, routers must reelect a DR and the routers except the new DR must synchronize routing information to the new DR. This process is lengthy, which may cause incorrect route calculations. A BDR is used to shorten the process. The BDR is a backup for a DR. A BDR is elected together with a DR. The BDR establishes adjacencies with all routers on the network segment and exchanges routing information with them. When the DR fails, the BDR immediately becomes a new DR. The routers need to reelect a new BDR, but this process does not affect route calculations.
The DR priority of a router interface determines its qualification for DR and BDR elections. The router interfaces with their DR priorities greater than 0 are eligible. Each router adds the elected DR to a Hello packet and sends it to other routers on the network segment. When both router interfaces on the same network segment declare that they are DRs, the router interface with a higher DR priority is elected as a DR. If the two router interfaces have the same DR priority, the router interface with a larger router ID is elected as a DR.
OSPF Multi-Process
OSPF supports multi-process. Multiple OSPF processes can run on the same router, and they are independent from each other. Route exchanges between different OSPF processes are similar to route exchanges between different routing protocols.
Each interface on a router can belong to only one OSPF process.
A typical application of OSPF multi-process is that OSPF runs between PEs and CEs in a VPN, whereas OSPF is used as an IGP on the backbone of the VPN. Two OSPF processes on the same PE are independent from each other.
OSPF Default Route
A default route is the route whose destination address and mask are both all 0s. When no matching route is discovered, a router uses a default route to forward packets.
A default route generally applies to the following scenarios:
An ABR in an area advertises Type 3 LSAs carrying a default route within the area. The routers in the area use the received default route to forward inter-area packets.
An ASBR in an AS advertises Type 5 or Type 7 LSAs carrying a default route within the AS. The routers in the AS use the received default route to forward AS external packets.
OSPF routes are hierarchically managed. The priority of the default route carried in Type 3 LSAs is higher than the priority of the default route carried in Type 5 or Type 7 LSAs.
A router advertises LSAs carrying a default route by adhering to the following principles:
A router in an area can advertise LSAs carrying a default route only when the router has an interface connected to a device outside the area.
If a router has advertised LSAs carrying a default route, the router no longer learns the same type of LSA advertised by other routers, which carry a default route. That is, the router uses only the LSAs advertised by itself to calculate routes. The LSAs advertised by other routers are still saved in the LSDB.
If a router must use a route to advertise LSAs carrying an external default route, the route cannot be a route learned by the local OSPF process. A router in an area uses an external default route to forward packets outside the area. If the next hops of routes in the area are routers in the area, packets cannot be forwarded outside the area.
Before a router advertises a default route, it checks whether a neighbor in the full state is present in area 0. The router advertises a default route only when a neighbor in the full state is present in area 0. If no such a neighbor exists, the backbone area cannot forward packets and advertising a default route is meaningless.
Table 5-8 describes the principles for advertising default routes in different areas.
Area Type |
Function |
---|---|
Common area |
By default, a router in a common area does not generate a default route. When a default route on the network is generated by another non-OSPF routing process, the device that generates the default route must advertise it within the entire OSPF AS. You can use commands to configure an ASBR to generate a default route. After configuration, the ASBR generates a Type 5 LSA carrying the default route and then advertises the LSA within the entire OSPF AS. If no default route is generated on the ASBR, the router does not advertise a default route. |
Stub area |
Type 5 LSAs cannot be advertised within a stub area. A router in the stub area must learn AS external routes from an ABR. The ABR automatically generates a Type 3 LSA carrying a default route and advertises it within the entire stub area. Then the router can learn AS external routes from the ABR. |
Totally stub area |
Neither Type 3 (except default Type 3 LSAs) nor Type 5 LSAs can be advertised within a totally stub area. A router in the totally stub area must learn AS external and inter-area routes from an ABR. After you configure a totally stub area, an ABR automatically generates a Type 3 LSA carrying a default route and advertises it within the entire totally stub area. Then the router can learn AS external and inter-area routes from the ABR. |
NSSA |
A small number of AS external routes learned from the ASBR in an NSSA can be imported to the NSSA. Type 5 LSAs cannot be advertised within the NSSA. When at least a neighbor in Full status and an interface that is Up exist in the backbone area, the ABR automatically generates a Type 7 LSA carrying a default route and advertises it within the entire NSSA. A small number of AS external routes can be learned from the ASBR in the NSSA, and other inter-area routes can be learned from the ABR in the NSSA. Manual configurations must be performed on the ASBR to enable the ASBR to generate a Type 7 LSA carrying a default route and advertise the LSA within the entire NSSA. An ABR does not translate Type 7 LSAs carrying a default route into Type 5 LSAs carrying a default route or flood them to the entire AS. |
Totally NSSA |
Neither Type 3 (except default Type 3 LSAs) nor Type 5 LSAs can be advertised within a totally NSSA. A router in the totally NSSA must learn AS external routes from an ABR. The ABR automatically generates Type 3 and Type7 LSAs carrying a default route and advertises them to the entire totally NSSA. Then AS external and inter-area routes can be advertised within the totally NSSA. |
OSPF Route Summarization
Route summarization means that an ABR in an area summarizes the routes with the same prefix into one route and advertises the summarized route to other areas.
Route summarization between areas reduces the amount of routing information to be transmitted, reducing the size of routing tables and improving device performance.
Route summarization can be carried out by an ABR or an ASBR:
Route summarization on an ABR:
When an ABR in an area advertises routing information to other areas, it generates Type 3 LSAs by network segment. If this area contains consecutive network segments, you can run a command to summarize these network segments into one network segment. The ABR only sends one summarized LSA, and will not send the LSAs that belong to the summarized network segment specified in the command.
Route summarization on an ASBR:
If the local device is an ASBR and route summarization is configured, the ASBR will summarize the imported Type 5 LSAs within the aggregated address range. After an NSSA is configured, the ASBR also summarizes the imported Type 7 LSAs within the aggregated address range.
If the local device functions both as an ASBR and an ABR, the device summarizes the Type 5 LSAs that are translated from Type 7 LSAs.
OSPF Route Filtering
OSPF supports route filtering using routing policies. By default, OSPF does not filter routes.
Routing policies used by OSPF include route-policy, access-list, and prefix-list.
OSPF route filtering can be used for:
Importing routes
OSPF can import routes learned by other routing protocols. You can configure routing policies to filter the imported routes so that OSPF can import only the routes that match specific conditions.
Advertising imported routes
OSPF advertises the imported routes to its neighbors.
You can configure filtering rules to filter the routes to be advertised. The filtering rules can be configured only on ASBRs.
If OSPF imports a large number of external routes and advertises them to a device with a smaller routing table capacity, the device may restart unexpectedly. To address this problem, you can configure a limit on the number of LSAs that can be generated for imported external routes in an OSPF process.
Learning routes
Filtering rules can be configured to allow OSPF to filter the received intra-area, inter-area, and AS external routes.
After receiving routes, an OSPF device adds only the routes that match the filtering rules to the local routing table, but can still advertise all routes from the OSPF routing table.
Learning inter-area LSAs
You can run a command to configure an ABR to filter the Summary LSAs entering the local area. This configuration takes effect only on ABRs because only ABRs can advertise Summary LSAs.
Table 5-9 Differences between filtering for inter-area LSA learning and filtering for route learningFiltering for Inter-area LSA Learning
Filtering for Route Learning
Directly filters the LSAs entering the local area.
Filters the routes that are calculated based on LSAs, but does not filter LSAs. This means that all incoming LSAs are learned, but only routes matching filtering conditions are added to the local routing table.
Advertising inter-area LSAs
You can run commands to configure an ABR to filter outgoing Summary LSAs. This configuration takes effect only on ABRs.
OSPF RFC 1583 Compatibility
RFC 1583 is an earlier version of OSPFv2.
When OSPF calculates external routes, routing loops may occur due to differences of route selection rules between RFC 2328 and RFC 1583. To prevent routing loops, both communication ends must use the same route selection rules.
- If RFC 1583 compatibility is enabled, OSPF uses the route selection rules defined in RFC 1583.
- If RFC 1583 compatibility is disabled, OSPF uses the route selection rules defined in RFC 2328.
- The router selects a route to the ASBR that originates the LSA or a route to the forwarding address (FA) described in the LSA.
- The router selects external routes to the same destination.
By default, OSPF uses the route selection rules defined in RFC 1583.