Open Shortest Path First | |
Purpose: | Routing protocol |
Rfcs: | ... |
OSPF for IPv6 | |
Rfcs: | ... |
Open Shortest Path First (OSPF) is a routing protocol for Internet Protocol (IP) networks. It uses a link state routing (LSR) algorithm and falls into the group of interior gateway protocols (IGPs), operating within a single autonomous system (AS).
OSPF gathers link state information from available routers and constructs a topology map of the network. The topology is presented as a routing table to the internet layer for routing packets by their destination IP address. OSPF supports Internet Protocol version 4 (IPv4) and Internet Protocol version 6 (IPv6) networks and is widely used in large enterprise networks. IS-IS, another LSR-based protocol, is more common in large service provider networks.
Originally designed in the 1980s, OSPF version 2 is defined in RFC 2328 (1998). The updates for IPv6 are specified as OSPF version 3 in RFC 5340 (2008). OSPF supports the Classless Inter-Domain Routing (CIDR) addressing model.
OSPF is an interior gateway protocol (IGP) for routing Internet Protocol (IP) packets within a single routing domain, such as an autonomous system. It gathers link state information from available routers and constructs a topology map of the network. The topology is presented as a routing table to the internet layer which routes packets based solely on their destination IP address.
OSPF detects changes in the topology, such as link failures, and converges on a new loop-free routing structure within seconds. It computes the shortest-path tree for each route using a method based on Dijkstra's algorithm. The OSPF routing policies for constructing a route table are governed by link metrics associated with each routing interface. Cost factors may be the distance of a router (round-trip time), data throughput of a link, or link availability and reliability, expressed as simple unitless numbers. This provides a dynamic process of traffic load balancing between routes of equal cost.
OSPF divides the network into routing areas to simplify administration and optimize traffic and resource utilization. Areas are identified by 32-bit numbers, expressed either simply in decimal, or often in the same octet-based dot-decimal notation used for IPv4 addresses. By convention, area 0 (zero), or 0.0.0.0, represents the core or backbone area of an OSPF network. While the identifications of other areas may be chosen at will, administrators often select the IP address of a main router in an area as the area identifier. Each additional area must have a connection to the OSPF backbone area. Such connections are maintained by an interconnecting router, known as an area border router (ABR). An ABR maintains separate link-state databases for each area it serves and maintains summarized routes for all areas in the network.
OSPF runs over IPv4 and IPv6, but does not use a transport protocol such as UDP or TCP. It encapsulates its data directly in IP packets with protocol number 89. This is in contrast to other routing protocols, such as the Routing Information Protocol (RIP) and the Border Gateway Protocol (BGP). OSPF implements its own transport error detection and correction functions. OSPF also uses multicast addressing for distributing route information within a broadcast domain. It reserves the multicast addresses (IPv4) and (IPv6) for all SPF/link state routers (AllSPFRouters) and (IPv4) and (IPv6) for all Designated Routers (AllDRouters). For non-broadcast networks, special provisions for configuration facilitate neighbor discovery. OSPF multicast IP packets never traverse IP routers, they never travel more than one hop. The protocol may therefore be considered a link layer protocol, but is often also attributed to the application layer in the TCP/IP model. It has a virtual link feature that can be used to create an adjacency tunnel across multiple hops. OSPF over IPv4 can operate securely between routers, optionally using a variety of authentication methods to allow only trusted routers to participate in routing. OSPFv3 (IPv6) relies on standard IPv6 protocol security (IPsec), and has no internal authentication methods.
For routing IP multicast traffic, OSPF supports the Multicast Open Shortest Path First (MOSPF) protocol. Cisco does not include MOSPF in their OSPF implementations. Protocol Independent Multicast (PIM) in conjunction with OSPF or other IGPs, is widely deployed.
OSPF version 3 introduces modifications to the IPv4 implementation of the protocol. Except for virtual links, all neighbor exchanges use IPv6 link-local addressing exclusively. The IPv6 protocol runs per link, rather than based on the subnet. All IP prefix information has been removed from the link-state advertisements and from the hello discovery packet making OSPFv3 essentially protocol-independent. Despite the expanded IP addressing to 128 bits in IPv6, area and router Identifications are still based on 32-bit numbers.
Network type | Point to point (P2P) | Broadcast (default) | Non-broadcast multi-access (NBMA) | Point to multipoint | Point to multipoint non broadcast (P2MP-NB) | Passive | |
---|---|---|---|---|---|---|---|
Max routers per network | 2 | Unlimited | Unlimited | Unlimited | Unlimited | ||
Full mesh assumed | |||||||
Hello (default Cisco) | 10 | 10 | 30 | 30 | 30 | ||
Dead timers (default Cisco) | 40 | 40 | 120 | 120 | 120 | ||
Wait timer: | 0 | equal to dead timer | equal to dead timer | 0 | 0 | ||
Automatic neighbour discovery | |||||||
Discovery and hellos are sent to | 224.0.0.5 | 224.0.0.5 | Neighbour IP | 224.0.0.5 | Neighbour IP | ||
Neighbour communication is sent to | 224.0.0.5 | Unicast | Unicast | Unicast | Unicast | ||
LSAs are sent to: | 224.0.0.5 | DR/BDR: 224.0.0.6 All: 224.0.0.5 | DR/BDR: 224.0.0.6 All: 224.0.0.5 | Unicast | Unicast | ||
Next-hop IP: | Peer | Original router | Original router | Hub | Hub | ||
Imported in to OSPF as: | Stub and P2P | Transit | Transit | Stub and P2P | Stub and P2P | Stub |
As a link-state routing protocol, OSPF establishes and maintains neighbor relationships for exchanging routing updates with other routers. The neighbor relationship table is called an adjacency database. Two OSPF routers are neighbors if they are members of the same subnet and share the same area ID, subnet mask, timers and authentication. In essence, OSPF neighborship is a relationship between two routers that allow them to see and understand each other but nothing more. OSPF neighbors do not exchange any routing information the only packets they exchange are hello packets. OSPF adjacencies are formed between selected neighbors and allow them to exchange routing information. Two routers must first be neighbors and only then, can they become adjacent. Two routers become adjacent if at least one of them is designated router or backup designated router (on multiaccess-type networks), or they are interconnected by a point-to-point or point-to-multipoint network type. For forming a neighbor relationship between, the interfaces used to form the relationship must be in the same OSPF area. While an interface may be configured to belong to multiple areas, this is generally not practiced. When configured in a second area, an interface must be configured as a secondary interface.
The OSPF can have different operation modes on the following setups on an interface or network:
Virtual link over Virtual links, tunneling and sham links, are a form of connections that goes over the routing engine, and is not a direct connection to the remote host.
Each OSPF router within a network communicates with other neighboring routers on each connecting interface to establish the states of all adjacencies. Every such communication sequence is a separate conversation identified by the pair of router IDs of the communicating neighbors. RFC 2328 specifies the protocol for initiating these conversations (Hello Protocol) and for establishing full adjacencies (database description packets, link-state request packets). During its course, each router conversation transitions through a maximum of eight conditions defined by a state machine:[5]
In broadcast multiple-access networks, neighbor adjacency is formed dynamically using multicast hello packets to .
IP 192.0.2.1 > 224.0.0.5: OSPFv2, hello IP 192.0.2.2 > 224.0.0.5: OSPFv2, hello IP 192.0.2.1 > 192.0.2.2: OSPFv2, database description IP 192.0.2.2 > 192.0.2.1: OSPFv2, database description
A network where OSPF adverts the network, but the OSPF will not start neighbour adjacency.
In a non-broadcast multiple-access (NBMA) network, a neighbor adjacency is formed by sending unicast packets to another router. A non-broadcast network can have more than two routers, but broadcast is not supported.
IP 192.0.2.1 > 192.0.2.2: OSPFv2, hello IP 192.0.2.2 > 192.0.2.1: OSPFv2, hello IP 192.0.2.1 > 192.0.2.2: OSPFv2, database description IP 192.0.2.2 > 192.0.2.1: OSPFv2, database description
Examples of non-broadcast networks:
A network is divided into OSPF areas that are logical groupings of hosts and networks. An area includes its connecting router having an interface for each connected network link. Each router maintains a separate link-state database for the area whose information may be summarized towards the rest of the network by the connecting router. Thus, the topology of an area is unknown outside the area. This reduces the routing traffic between parts of an autonomous system.
OSPF can handle thousands of routers with more a concern of reaching capacity of the forwarding information base (FIB) table when the network contains lots of routes and lower-end devices.[6] Modern low-end routers have a full gigabyte of RAM,[7] which allows them to handle many routers in an area 0. Many resources[8] refer to OSPF guides from over 20 years ago where it was impressive to have 64 MB of RAM.
Areas are uniquely identified with 32-bit numbers. The area identifiers are commonly written in the dot-decimal notation, familiar from IPv4 addressing. However, they are not IP addresses and may duplicate, without conflict, any IPv4 address. The area identifiers for IPv6 implementations (OSPFv3) also use 32-bit identifiers written in the same notation. When dotted formatting is omitted, most implementations expand area 1 to the area identifier 0.0.0.1, but some have been known to expand it as 1.0.0.0.
Several vendors (Cisco, Allied Telesis, Juniper, Alcatel-Lucent, Huawei, Quagga), implement totally stubby and NSSA totally stubby area for stub and not-so-stubby areas. Although not covered by RFC standards, they are considered by many to be standard features in OSPF implementations.
OSPF defines several area types:
The backbone area (also known as area 0 or area 0.0.0.0) forms the core of an OSPF network. All other areas are connected to it, either directly or through other routers. OSPF requires this to prevent routing loops.[9] Inter-area routing happens via routers connected to the backbone area and to their own associated areas. It is the logical and physical structure for the 'OSPF domain' and is attached to all nonzero areas in the OSPF domain. In OSPF the term autonomous system boundary router (ASBR) is historic, in the sense that many OSPF domains can coexist in the same Internet-visible autonomous system, RFC 1996.
All OSPF areas must connect to the backbone area. This connection, however, can be through a virtual link. For example, assume area 0.0.0.1 has a physical connection to area 0.0.0.0. Further assume that area 0.0.0.2 has no direct connection to the backbone, but this area does have a connection to area 0.0.0.1. Area 0.0.0.2 can use a virtual link through the transit area 0.0.0.1 to reach the backbone. To be a transit area, an area has to have the transit attribute, so it cannot be stubby in any way.
A regular area is just a non-backbone (nonzero) area without specific feature, generating and receiving summary and external LSAs. The backbone area is a special type of such area.
In hello packets the E-flag is not high, indicating "External routing: not capable"A stub area is an area that does not receive route advertisements external to the AS and routing from within the area is based entirely on a default route. An ABR deletes type 4 and 5 LSAs from internal routers, sends them a default route of 0.0.0.0 and turns itself into a default gateway. This reduces LSDB and routing table size for internal routers.
Modifications to the basic concept of stub area have been implemented by systems vendors, such as the totally stubby area (TSA) and the not-so-stubby area (NSSA), both an extension in Cisco Systems routing equipment.
A totally stubby area is similar to a stub area. However, this area does not allow summary routes in addition to not having external routes, that is, inter-area (IA) routes are not summarized into totally stubby areas. The only way for traffic to get routed outside the area is a default route which is the only Type-3 LSA advertised into the area. When there is only one route out of the area, fewer routing decisions have to be made by the route processor, which lowers system resource utilization.
Occasionally, it is said that a TSA can have only one ABR.[10]
In hello packets the N-flag is set high, indicating "NSSA: supported"A not-so-stubby area (NSSA) is a type of stub area that can import autonomous system external routes and send them to other areas, but still cannot receive AS-external routes from other areas.
NSSA is an extension of the stub area feature that allows the injection of external routes in a limited fashion into the stub area. A case study simulates an NSSA getting around the stub-area problem of not being able to import external addresses. It visualizes the following activities: the ASBR imports external addresses with a type 7 LSA, the ABR converts a type 7 LSA to type 5 and floods it to other areas, the ABR acts as an ASBR for other areas.The ASBRs do not take type 5 LSAs and then convert to type 7 LSAs for the area.
An addition to the standard functionality of an NSSA, the totally stubby NSSA is an NSSA that takes on the attributes of a TSA, meaning that type 3 and 4 summary routes are not flooded into this type of area. It is also possible to declare an area both totally stubby and not-so-stubby, which means that the area will receive only the default route from area 0.0.0.0, but can also contain an autonomous system boundary router (ASBR) that accepts external routing information and injects it into the local area, and from the local area into area 0.0.0.0.
Redistribution into an NSSA area creates a special type of LSA known as type 7, which can exist only in an NSSA area. An NSSA ASBR generates this LSA, and an NSSA ABR router translates it into a type 5 LSA, which gets propagated into the OSPF domain.
A newly acquired subsidiary is one example of where it might be suitable for an area to be simultaneously not-so-stubby and totally stubby if the practical place to put an ASBR is on the edge of a totally stubby area. In such a case, the ASBR does send externals into the totally stubby area, and they are available to OSPF speakers within that area. In Cisco's implementation, the external routes can be summarized before injecting them into the totally stubby area. In general, the ASBR should not advertise default into the TSA-NSSA, although this can work with extremely careful design and operation, for the limited special cases in which such an advertisement makes sense.
By declaring the totally stubby area as NSSA, no external routes from the backbone, except the default route, enter the area being discussed. The externals do reach area 0.0.0.0 via the TSA-NSSA, but no routes other than the default route enter the TSA-NSSA. Routers in the TSA-NSSA send all traffic to the ABR, except to routes advertised by the ASBR.
OSPF defines the following overlapping categories of routers:
The router type is an attribute of an OSPF process. A given physical router may have one or more OSPF processes. For example, a router that is connected to more than one area, and which receives routes from a BGP process connected to another AS, is both an area border router and an autonomous system boundary router.
Each router has an identifier, customarily written in the dotted-decimal format (e.g., 1.2.3.4) of an IP address. This identifier must be established in every OSPF instance. If not explicitly configured, the highest logical IP address will be duplicated as the router identifier. However, since the router identifier is not an IP address, it does not have to be a part of any routable subnet in the network, and often isn't to avoid confusion.
On networks (same subnet) with networks type of:
A system of designated router (DR) and backup designated router (BDR), is used to reducing network traffic by providing a source for routing updates.This is done using multicast addresses:
The DR and BDR maintains a complete topology table of the network and sends the updates to the other routers via multicast. All routers in a multi-access network segment will form a leader/follower relationship with the DR and BDR. They will form adjacencies with the DR and BDR only. Every time a router sends an update, it sends it to the DR and BDR on the multicast address . The DR will then send the update out to all other routers in the area, to the multicast address . This way all the routers do not have to constantly update each other, and can rather get all their updates from a single source. The use of multicasting further reduces the network load. DRs and BDRs are always setup/elected on OSPF broadcast networks. DR's can also be elected on NBMA (Non-Broadcast Multi-Access) networks such as Frame Relay or ATM. DRs or BDRs are not elected on point-to-point links (such as a point-to-point WAN connection) because the two routers on either side of the link must become fully adjacent and the bandwidth between them cannot be further optimized. DR and non-DR routers evolve from 2-way to full adjacency relationships by exchanging DD, Request, and Update.
A designated router (DR) is the router interface elected among all routers on a particular multiaccess network segment, generally assumed to be broadcast multiaccess. Special techniques, often vendor-dependent, may be needed to support the DR function on non-broadcast multiaccess (NBMA) media. It is usually wise to configure the individual virtual circuits of an NBMA subnet as individual point-to-point lines; the techniques used are implementation-dependent.
A backup designated router (BDR) is a router that becomes the designated router if the current designated router has a problem or fails. The BDR is the OSPF router with the second-highest priority at the time of the last election.
A given router can have some interfaces that are designated (DR) and others that are backup designated (BDR), and others that are non-designated. If no router is a DR or a BDR on a given subnet, the BDR is first elected, and then a second election is held for the DR.
A router that has not been selected to be designated router (DR) or backup designated router (BDR). The router forms an adjacency to both the designated router (DR) and the backup designated router (BDR).
For other non (B)DR, the adjacency stops at 2-ways State.
The DR is elected based on the following default criteria:
Unlike other routing protocols, OSPF does not carry data via a transport protocol, such as the User Datagram Protocol (UDP) or the Transmission Control Protocol (TCP). Instead, OSPF forms IP datagrams directly, packaging them using protocol number 89 for the IP Protocol field. OSPF defines five different message types, for various types of communication. Multiple packets can be sent per frame.
OSPF uses 5 packet types:
24 | 4 | 2 | 1 | 1 | 4 | 4 | 4 | 4 |
---|---|---|---|---|---|---|---|---|
Header | ||||||||
Network Mask | Hello Interval | Options | Router Priority | Router Dead Interval | Designated Router ID | Backup Designated Router ID | Neighbor ID |
16 | 4 | 1 | 3 | 2 | 2 | 4 | 4 | 4 |
---|---|---|---|---|---|---|---|---|
Header | ||||||||
Interface ID | Router Priority | Options | Hello Interval | Router Dead Interval | Designated Router ID | Backup Designated Router ID | Neighbor ID |
16 or 24 | 2 | 1 | 1 | 1 | 4 | Variable |
---|---|---|---|---|---|---|
Header | ||||||
Interface MTU | Hello Interval | Options | Flags | DD sequence number | LSA Headers |
Database description messages contain descriptions of the topology of the autonomous system or area. They convey the contents of the link-state database (LSDB) for the area from one router to another. Communicating a large LSDB may require several messages to be sent by having the sending device designated as a leader device and sending messages in sequence, with the follower (recipient of the LSDB information) responding with acknowledgments.
See main article: Link-state advertisement.
24 | 4 | 4 | 4 |
---|---|---|---|
Header | |||
LS Type | Link State ID | Advertising Router |
16 | 2 | 2 | 4 | 4 |
---|---|---|---|---|
Header | ||||
Reserved | LS Type | Link State ID | Advertising Router |
24 or 16 | 4 | Variable |
---|---|---|
Header | ||
| List of LSAs |
24 or 16 | Variable |
---|---|
Header | |
List of LSAs |
LS type | LS name | Generated by | Description | |
---|---|---|---|---|
1 | Router-LSAs | Each internal router within an area | The link-state ID of the type 1 LSA is the originating router ID.Router-LSAs, describe the following types of interfaces:
| |
2 | Network-LSAs | The DR | Originated for broadcasts and NBMA networks by the designated router. This LSA contains the list of routers connected to the network. The link-state ID of the type 2 LSA is the IP interface address of the DR. | |
3 | Summary-LSAs | The ABR | Type 3 summary-LSAs describe routes to networks. To inform other areas about inter-area routers. These routes can also be summarised. | |
4 | ASBR-summary | The ABR | Type 4 describe routes to AS boundary routers beyond its area.The area border router (ABR) generates this LSA to inform other routers in the OSPF domain, that the matching router is an autonomous system boundary router (ASBR), so that the external LSAs (Type 5 / Type 7) it sent may be properly resolved outside its own area. | |
5 | AS-external-LSAs | The ASBR | Type 5 These describe routes advertised by the ASBR.LSAs contain information imported into OSPF from other routing processes. Together with Type 4 they describe the way to an external route. | |
7 | NSSA external link-state advertisements | The ASBR, within a not-so-stubby area | Type 7-LSAs are identical to type-5 LSAs. Type-7 LSAs are only flooded within the NSSA. At the area border router, selected type-7 LSAs are translated into type 5-LSAs and flooded into the backbone. | |
8 | Link-LSA (v3) | Each internal router within a link | Provide it local router's link-local address to all other routers on the local network. | |
9 | Intra-Area-Prefix-LSAs (v3) | Each internal router within an area | Replaces some of the functionality of Router-LSAs; stub network segment, or an attached transit network segment. |
Not all area types use all LSA. Below is a matrix of accepted LSAs.
Within a single area | Inter area | ||||||
---|---|---|---|---|---|---|---|
Area type | LSA 1 - router | LSA 2 - network | LSA 7 - NSSA external | LSA 3 - network summary | LSA 4 - ASBR Summary | LSA 5 - AS external | |
Backbone | |||||||
Non-backbone | |||||||
Stub | |||||||
Totally stubby | |||||||
Not-so-stubby | |||||||
Totally not-so-stubby |
OSPF uses path cost as its basic routing metric, which was defined by the standard not to equate to any standard value such as speed, so the network designer could pick a metric important to the design. In practice, it is determined by comparing the speed of the interface to a reference-bandwidth for the OSPF process. The cost is determined by dividing the reference bandwidth by the interface speed (although the cost for any interface can be manually overridden). If a reference bandwidth is set to '10000', then a 10 Gbit/s link will have a cost of 1. Any speeds less than 1 are rounded up to 1.[14] Here is an example table that shows the routing metric or 'cost calculation' on an interface.
Interface speed | Link cost | Uses | ||
---|---|---|---|---|
Default (100 Mbit/s) | 200 Gbit/s | |||
800 Gbit/s | 1 | 1 | QSFP-DD112 | |
200 Gbit/s | 1 | 1 | SFP-DD | |
40 Gbit/s | 1 | 5 | QSFP+ | |
25 Gbit/s | 1 | 8 | SFP28 | |
10 Gbit/s | 1 | 20 | 10 GigE, common in data centers | |
5 Gbit/s | 1 | 40 | NBase-T, Wi-Fi routers | |
1 Gbit/s | 1 | 200 | common gigabit port | |
100 Mbit/s | 1 | 2000 | low-end port | |
10 Mbit/s | 10 | 20000 | 1990's speed. |
OSPF is a layer 3 protocol. If a layer 2 switch is between the two devices running OSPF, one side may negotiate a speed different from the other side. This can create an asymmetric routing on the link (Router 1 to Router 2 could cost '1' and the return path could cost '10'), which may lead to unintended consequences.
Metrics, however, are only directly comparable when of the same type. Four types of metrics are recognized. In decreasing preference (for example, an intra-area route is always preferred to an external route regardless of metric), these types are:
OSPF version 3 introduces modifications to the IPv4 implementation of the protocol. Despite the expansion of addresses to 128 bits in IPv6, area and router identifications are still 32-bit numbers.
Type | Type field | sub value | name | |
---|---|---|---|---|
Two-octet AS | 0x00 | 0x05 | OSPF domain identifier | |
Four-octet AS | 0x02 | 0x05 | OSPF domain identifier | |
IPv4 address | 0x01 | 0x05 | OSPF domain identifier | |
IPv4 address | 0x01 | 0x07 | OSPF route ID | |
Opaque | 0x03 | 0x06 | OSPF route type |
4 byte | 1 byte | 1 byte | |
---|---|---|---|
Area number | Route type | Options |
A customer can use OSPF over a MPLS VPN, where the service provider uses BGP or RIP as their interior gateway protocol.When using OSPF over MPLS VPN, the VPN backbone becomes part of the OSPF backbone area 0. In all areas, isolated copies of the IGP are run.
Advantages:
To achieve this, a modified OSPF-BGP redistribution is used. All OSPF routes retain the source LSA type and metric.[19] [20] To prevent loops, an optional DN bit is set by the service provider in LSAs from the provider equipment to indicate that a route has already been sent to the customer's equipment.
OSPF-TE is an extension to OSPF extending the expressivity to allow for traffic engineering and use on non-IP networks.[21] Using OSPF-TE, more information about the topology can be exchanged using opaque LSA carrying type–length–value elements. These extensions allow OSPF-TE to run completely out of band of the data plane network. This means that it can also be used on non-IP networks, such as optical networks.
OSPF-TE is used in GMPLS networks as a means to describe the topology over which GMPLS paths can be established. GMPLS uses its own path setup and forwarding protocols, once it has the full network map.
In the Resource Reservation Protocol (RSVP), OSPF-TE is used for recording and flooding RSVP signaled bandwidth reservations for label-switched paths within the link-state database.
documents work in optical routing for IP based on extensions to OSPF and IS-IS.[22]
The Multicast Open Shortest Path First (MOSPF) protocol is an extension to OSPF to support multicast routing. MOSPF allows routers to share information about group memberships.
OSPF is a widely deployed routing protocol that can converge a network in a few seconds and guarantee loop-free paths. It has many features that allow the imposition of policies about the propagation of routes that it may be appropriate to keep local, for load sharing, and for selective route importing. IS-IS, in contrast, can be tuned for lower overhead in a stable network, the sort more common in ISP than enterprise networks. There are some historical accidents that made IS-IS the preferred IGP for ISPs, but ISPs today may well choose to use the features of the now-efficient implementations of OSPF,[23] after first considering the pros and cons of IS-IS in service provider environments.[24]
When the default route to an ISP is injected into OSPF from multiple ASBRs as a Type I external route and the same external cost specified, other routers will go to the ASBR with the least path cost from its location. This can be tuned further by adjusting the external cost. If the default route from different ISPs is injected with different external costs, as a Type II external route, the lower-cost default becomes the primary exit and the higher-cost becomes the backup only.