RFC 2178
OSPF Version 2
OSPF Version 2 ๐ฆ
Okay bestie, let's start with the ID card ๐ชช This is RFC 2178, titled OSPF Version 2. It was written by J. Moy of Cascade Communications Corp. and dated July 1997. It came out of the Network Working Group and is on the Standards Track ๐ It obsoletes RFC 1583, so 1583 is officially out and this one is in ๐
Status of this Memo
Okay so this one is an Internet standards track protocol for the whole Internet community ๐ It's also asking everyone to chat about it and send suggestions for improvements ๐ฌ If you want the official standardization state and status of this protocol, check the current edition of the "Internet Official Protocol Standards" (STD 1) ๐ And distribution of this memo is unlimited, so share it with everyone ๐ธ
Abstract
Okay, the main character here is OSPF version 2 ๐ OSPF is a link-state routing protocol ๐ง It's designed to run internal to a single Autonomous System, so it's a within-the-network kind of routing, not a between-networks one ๐ Every OSPF router keeps an identical database that describes the Autonomous System's topology, and the routing table gets calculated from that database by building a shortest-path tree ๐ณ It's giving consistency, bestie ๐
OSPF recalculates routes really fast when the topology changes, and it uses a minimum of routing protocol traffic while doing it โก It also supports equal-cost multipath ๐ค๏ธ There's an area routing capability too, which gives an additional level of routing protection and cuts down on routing protocol traffic ๐ซถ And the big one: all OSPF routing protocol exchanges are authenticated ๐ Iconic, no notes ๐ญ
Now the tea โ The differences between this memo and RFC 1583 are explained in Appendix G. All of those differences are backward-compatible in nature ๐ Implementations of this memo and of RFC 1583 will interoperate, so old and new can totally hang out together ๐ฅน
For comments, the address is ospf@gated.cornell.edu ๐
Part 1 of 47 is done! ๐ More parts coming, so stay tuned, bestie ๐
Table of Contents ๐
okay bestie, this is the whole roadmap for the doc โจ every section, subsection and appendix, with the page where it starts so you can jump straight to the good stuff ๐
1 Introduction ........................................... 5
1.1 Protocol Overview ...................................... 5
1.2 Definitions of commonly used terms ..................... 6
1.3 Brief history of link-state routing technology ........ 9
1.4 Organization of this document ......................... 10
1.5 Acknowledgments ....................................... 11
2 The link-state database: organization and calculations 11
2.1 Representation of routers and networks ................ 11
2.1.1 Representation of non-broadcast networks .............. 13
2.1.2 An example link-state database ........................ 14
2.2 The shortest-path tree ................................ 18
2.3 Use of external routing information ................... 20
2.4 Equal-cost multipath .................................. 22
3 Splitting the AS into Areas ........................... 22
3.1 The backbone of the Autonomous System ................. 23
3.2 Inter-area routing .................................... 23
3.3 Classification of routers ............................. 24
3.4 A sample area configuration ........................... 25
3.5 IP subnetting support ................................. 31
3.6 Supporting stub areas ................................. 32
3.7 Partitions of areas ................................... 33
4 Functional Summary .................................... 34
4.1 Inter-area routing .................................... 35
4.2 AS external routes .................................... 35
4.3 Routing protocol packets .............................. 35
4.4 Basic implementation requirements ..................... 38
4.5 Optional OSPF capabilities ............................ 39
5 Protocol data structures .............................. 40
6 The Area Data Structure ............................... 42
7 Bringing Up Adjacencies ............................... 44
7.1 The Hello Protocol .................................... 44
7.2 The Synchronization of Databases ...................... 45
7.3 The Designated Router ................................. 46
7.4 The Backup Designated Router .......................... 47
7.5 The graph of adjacencies .............................. 48
8 Protocol Packet Processing ............................ 49
8.1 Sending protocol packets .............................. 49
8.2 Receiving protocol packets ............................ 51
9 The Interface Data Structure .......................... 54
9.1 Interface states ...................................... 57
9.2 Events causing interface state changes ................ 59
9.3 The Interface state machine ........................... 61
9.4 Electing the Designated Router ........................ 64
9.5 Sending Hello packets ................................. 66
9.5.1 Sending Hello packets on NBMA networks ................ 67
10 The Neighbor Data Structure ........................... 68
10.1 Neighbor states ....................................... 70
10.2 Events causing neighbor state changes ................. 75
10.3 The Neighbor state machine ............................ 76
10.4 Whether tocome adjacent ............................ 82
10.5 Receiving Hello Packets ............................... 83
10.6 Receiving Database Description Packets ................ 85
10.7 Receiving Link State Request Packets .................. 88
10.8 Sending Database Description Packets .................. 89
10.9 Sending Link State Request Packets .................... 90
10.10 An Example ............................................ 91
11 The Routing Table Structure ........................... 93
11.1 Routing table lookup .................................. 96
11.2 Sample routing table, without areas ................... 97
11.3 Sample routing table, with areas ...................... 97
12 Link State Advertisements (LSAs) ......................100
12.1 The LSA Header ........................................100
12.1.1 LS age ............................................... 101
12.1.2 Options .............................................. 101
12.1.3 LS type .............................................. 102
12.1.4 Link State ID ........................................ 102
12.1.5 Advertising Router ................................... 104
12.1.6 LS sequence number ................................... 104
12.1.7 LS checksum .......................................... 105
12.2 The link state database .............................. 105
12.3 Representation of TOS ................................ 106
12.4 Originating LSAs ..................................... 107
12.4.1 Router-LSAs .......................................... 110
12.4.1.1 Describing point-to-point interfaces ................. 112
12.4.1.2 Describing broadcast and NBMA interfaces ............. 113
12.4.1.3 Describing virtual links ............................. 113
12.4.1.4 Describing Point-to-MultiPoint interfaces ............ 114
12.4.1.5 Examples of router-LSAs .............................. 114
12.4.2 Network-LSAs ......................................... 116
12.4.2.1 Examples of network-LSAs ............................. 116
12.4.3 Summary-LSAs ......................................... 117
12.4.3.1 Originating summary-LSAs into stub areas ............. 119
12.4.3.2 Examples of summary-LSAs ............................. 119
12.4.4 AS-external-LSAs ..................................... 120
12.4.4.1 Examples of AS-external-LSAs ......................... 121
13 The Flooding Procedure ............................... 122
13.1 Determining which LSA is newer ....................... 126
13.2 Installing LSAs in the database ...................... 127
13.3 Next step in the flooding procedure .................. 128
13.4 Receiving self-originated LSAs ....................... 130
13.5 Sending Link State Acknowledgment packets ............ 131
13.6 Retransmitting LSAs .................................. 133
13.7 Receiving link state acknowledgments ................. 134
14 Aging The Link State Database ........................ 134
14.1 Premature aging of LSAs .............................. 135
15 Virtual Links ........................................ 135
16 Calculation of the routing table ..................... 137
16.1 Calculating the shortest-path tree for an area ....... 138
16.1.1 The next hop calculation ............................. 144
16.2 Calculating the inter-area routes .................... 145
16.3 Examining transit areas' summary-LSAs ................ 146
16.4 Calculating AS external routes ....................... 149
16.4.1 External path preferences ............................ 151
16.5 Incremental updates -- summary-LSAs .................. 151
16.6 Incremental updates -- AS-external-LSAs .............. 152
16.7 Events generated as a result of routing table changes 153
16.8 Equal-cost multipath ................................. 154
Footnotes ............................................ 155
References ........................................... 158
A OSPF data formats .................................... 160
A.1 Encapsulation of OSPF packets ........................ 160
A.2 The Options field .................................... 162
A.3 OSPF Packet Formats .................................. 163
A.3.1 The OSPF packet header ............................... 164
A.3.2 The Hello packet ..................................... 166
A.3.3 The Database Description packet ...................... 168
A.3.4 The Link State Request packet ........................ 170
A.3.5 The Link State Update packet ......................... 171
A.3.6 The Link State Acknowledgment packet ................. 172
A.4 LSA formats .......................................... 173
A.4.1 The LSA header ....................................... 174
A.4.2 Router-LSAs .......................................... 176
A.4.3 Network-LSAs ......................................... 179
A.4.4 Summary-LSAs ......................................... 180
A.4.5 AS-external-LSAs ..................................... 182
B Architectural Constants .............................. 184
C Configurable Constants ............................... 186
C.1 Global parameters .................................... 186
C.2 Area parameters ...................................... 187
C.3 Router interface parameters .......................... 188
C.4 Virtual link parameters .............................. 190
C.5 NBMA network parameters .............................. 191
C.6 Point-to-MultiPoint network parameters ............... 191
C.7 Host route parameters ................................ 192
D Authentication ....................................... 193
D.1 Null authentication .................................. 193
D.2 Simple password authentication ....................... 193
D.3 Cryptographic authentication ......................... 194
D.4 Message generation ................................... 196
D.4.1 Generating Null authentication ....................... 196
D.4.2 Generating Simple password authentication ............ 197
D.4.3 Generating Cryptographic authentication .............. 197
D.5 Message verification ................................. 198
D.5.1 Verifying Null authentication ........................ 199
D.5.2 Verifying Simple password authentication ............. 199
D.5.3 Verifying Cryptographic authentication ............... 199
E An algorithm for assigning Link State IDs ............ 201
F Multiple interfaces to the same network/subnet ....... 203
G Differences from RFC 1583 ............................ 204
G.1 Enhancements to OSPF authentication .................. 204
G.2 Addition of Point-to-MultiPoint interface ............ 204
G.3 Support for overlapping area ranges .................. 205
G.4 A modification to the flooding algorithm ............. 206
G.5 Introduction of the MinLSArrival constant ............ 206
G.6 Optionally advertising point-to-point links as subnets 207
G.7 Advertising same external route from multiple areas .. 207
G.8 Retransmission of initial Database Description packets 209
G.9 Detecting interface MTU mismatches ................... 209
G.10 Deleting the TOS routing option ...................... 209
Security Considerations .............................. 210
Author's Address ..................................... 211
1. Introduction ๐
okay bestie, this doc is the spec for OSPF (Open Shortest Path First), a TCP/IP internet routing protocol ๐. OSPF is an Interior Gateway Protocol (IGP), which means it shares routing info between routers that all belong to one single Autonomous System (AS) ๐ธ. It's link-state (SPF) based, and that's a total glow-up from the Bellman-Ford stuff that traditional TCP/IP routing protocols run on ๐ง.
The OSPF protocol was developed by the OSPF working group of the Internet Engineering Task Force. It was designed expressly for the TCP/IP internet environment, so it's got explicit support for CIDR and for tagging externally-derived routing info ๐ท๏ธ. It also authenticates routing updates, and it uses IP multicast when sending and receiving updates ๐ก. On top of all that, a lot of work went into making it respond fast to topology changes while only sending small amounts of routing protocol traffic. iconic, honestly โจ.
1.1. Protocol overview
OSPF routes IP packets based solely on the destination IP address in the IP packet header ๐ฏ. The packets get routed "as is" -- they aren't encapsulated in any extra protocol headers as they transit the Autonomous System, so no extra wrapping ๐. OSPF is a dynamic routing protocol, which means it quickly detects topology changes in the AS (like a router interface failing) and then calculates new loop-free routes after a period of convergence ๐. That convergence period is short and only involves a minimum of routing traffic. the way that's so efficient ๐ญ.
In a link-state routing protocol, every router keeps a database describing the Autonomous System's topology. This is called the link-state database ๐๏ธ. Every participating router has an identical database, and each individual piece of it is a particular router's local state (for example, the router's usable interfaces and reachable neighbors). Routers spread their local state through the whole AS by flooding ๐.
All routers run the exact same algorithm, in parallel ๐ฏ. From the link-state database, each router builds a tree of shortest paths with itself as the root. That shortest-path tree gives the route to every destination in the AS, and externally derived routing info shows up on the tree as leaves ๐ณ.
When several equal-cost routes to a destination exist, traffic gets split equally among them โ๏ธ. The cost of a route is described by a single dimensionless metric ๐ .
OSPF lets sets of networks get grouped together, and each grouping is called an area ๐งฉ. The topology of an area is hidden from the rest of the AS, and this information hiding gives a big drop in routing traffic ๐. Routing inside the area is determined only by that area's own topology, so the area is protected from bad routing data ๐ก๏ธ. An area is basically a generalization of an IP subnetted network.
OSPF also lets you configure IP subnets in a flexible way ๐. Each route distributed by OSPF has a destination and a mask. Two different subnets of the same IP network number can have different sizes (different masks), and that's known as variable length subnetting ๐ฆ. A packet gets routed to the best match, meaning the longest or most specific one. Host routes count as subnets whose masks are "all ones" (0xffffffff) ๐.
Every OSPF protocol exchange is authenticated, so only trusted routers can take part in the AS's routing ๐. You can use a variety of authentication schemes, and in fact you can configure separate schemes for each IP subnet ๐.
Externally derived routing data (for example, routes learned from an Exterior Gateway Protocol such as BGP; see [Ref23]) gets advertised throughout the AS ๐. That external data is kept separate from OSPF's link-state data. Each external route can also be tagged by the router advertising it, which lets routers on the AS boundary pass extra info between each other ๐ท๏ธโจ.
1.2. Definitions of commonly used terms
This section gives definitions for terms that have a specific meaning to OSPF and get used all through the text ๐. If you're new to the Internet Protocol Suite, check out [Ref13] for an intro to IP ๐ค.
- Router: A level three Internet Protocol packet switch. It used to be called a gateway in a lot of the IP literature ๐.
- Autonomous System: A group of routers exchanging routing information via a common routing protocol. Abbreviated as AS ๐๏ธ.
- Interior Gateway Protocol: The routing protocol spoken by the routers belonging to an Autonomous system. Abbreviated as IGP. Each Autonomous System has a single IGP, but separate Autonomous Systems may be running different IGPs ๐.
- Router ID: A 32-bit number assigned to each router running OSPF. This number uniquely identifies the router within an Autonomous System ๐ชช.
- Network: In this memo, an IP network/subnet/supernet. It's possible for one physical network to be assigned multiple IP network/subnet numbers, and we consider those to be separate networks. Point-to-point physical networks are the exception: they count as a single network no matter how many (if any at all) IP network/subnet numbers get assigned to them ๐ธ๏ธ.
- Network mask: A 32-bit number showing the range of IP addresses on a single IP network/subnet/supernet. This spec displays network masks as hexadecimal numbers, so the mask for a class C IP network shows up as
0xffffff00. Elsewhere in the literature you'll often see that same mask written as255.255.255.0๐ญ. - Point-to-point networks: A network that joins a single pair of routers. A 56Kb serial line is an example ๐.
- Broadcast networks: Networks that support many (more than two) attached routers, and that can address a single physical message to all of the attached routers (broadcast). Neighboring routers get discovered dynamically on these nets using OSPF's Hello Protocol, which itself takes advantage of the broadcast capability. OSPF also makes further use of multicast capabilities, if they exist. Each pair of routers on a broadcast network is assumed to be able to communicate directly. An ethernet is an example ๐ข.
- Non-broadcast networks: Networks that support many (more than two) routers but have no broadcast capability. Neighboring routers are maintained on these nets using OSPF's Hello Protocol. Because there's no broadcast capability, some configuration info may be needed to help discover neighbors. On non-broadcast networks, OSPF protocol packets that are normally multicast need to be sent to each neighboring router, one at a time. An X.25 Public Data Network (PDN) is an example ๐ญ.
OSPF runs in one of two modes over non-broadcast networks ๐๏ธ. The first mode, called non-broadcast multi-access or NBMA, simulates the operation of OSPF on a broadcast network. The second mode, called Point-to-MultiPoint, treats the non-broadcast network as a collection of point-to-point links. Non-broadcast networks are called NBMA networks or Point-to-MultiPoint networks, depending on which mode OSPF is using over them ๐ค.
- Interface: The connection between a router and one of its attached networks. An interface has state info associated with it, which comes from the underlying lower level protocols and the routing protocol itself. An interface to a network has a single IP address and mask associated with it (unless the network is an unnumbered point-to-point network). An interface is sometimes also called a link ๐.
- Neighboring routers: Two routers that have interfaces to a common network. Neighbor relationships are maintained by OSPF's Hello Protocol, which usually discovers them dynamically ๐.
- Adjacency: A relationship formed between selected neighboring routers so they can exchange routing info. Not every pair of neighboring routers becomes adjacent ๐.
- Link state advertisement: A unit of data describing the local state of a router or network. For a router, this includes the state of its interfaces and adjacencies. Each link state advertisement gets flooded throughout the routing domain, and the collected link state advertisements of all routers and networks form the protocol's link state database. Throughout this memo, link state advertisement is abbreviated as LSA ๐ฆ.
- Hello Protocol: The part of OSPF used to establish and maintain neighbor relationships. On broadcast networks, the Hello Protocol can also dynamically discover neighboring routers ๐.
- Flooding: The part of OSPF that distributes and synchronizes the link-state database between OSPF routers ๐.
- Designated Router: Each broadcast and NBMA network that has at least two attached routers has a Designated Router. The Designated Router generates an LSA for the network and has other special responsibilities in running the protocol ๐. The Designated Router is elected by the Hello Protocol.
The Designated Router concept cuts down on the number of adjacencies required on a broadcast or NBMA network. That in turn reduces the amount of routing protocol traffic and the size of the link-state database ๐โจ.
- Lower-level protocols: The underlying network access protocols that provide services to the Internet Protocol and, in turn, to OSPF. Examples are the X.25 packet and frame levels for X.25 PDNs, and the ethernet data link layer for ethernets ๐งฑ.
1.3. Brief history of link-state routing technology ๐ฐ๏ธ
okay so OSPF is a link state routing protocol ๐ฆ (people also call these SPF-based or distributed-database protocols, iykyk). This section is a quick tour of the link-state glow-up that shaped OSPF. literally the whole family tree ๐ณ
The first link-state routing protocol was built for the ARPANET packet switching network ๐ง It's described in [Ref3], and it's the OG that every other link-state protocol kind of started from. The ARPANET was super homogeneous: single-vendor packet switches connected by synchronous serial lines. That made the original protocol way easier to design and implement, no cap.
Then [Ref4] came through with upgrades ๐ These mods made the routing protocol more fault tolerant, and one of the big moves was adding a checksum to the LSAs so database corruption can get caught. The paper also had ways to cut down routing traffic overhead. They did it by letting the interval between LSA originations grow by an order of magnitude. iconic behavior ๐
A link-state algorithm was also proposed for the ISO IS-IS routing protocol ๐ธ It's described in [Ref2]. This one has methods for reducing data and routing traffic over broadcast networks. The trick is electing a Designated Router for each broadcast network, and that Designated Router then originates an LSA for the network.
Then the OSPF Working Group of the IETF took all of this and ran with it ๐โโ๏ธโจ The Designated Router concept got a major glow-up to cut routing traffic even more. Multicast capabilities are used for extra routing bandwidth savings. An area routing scheme was developed so information can be hidden, protected, or reduced ๐. And the algorithms were tailored to run efficiently in TCP/IP internets. main character energy ๐
1.4. Organization of this document ๐๏ธ
okay so the first three sections give you the big-picture overview of what the protocol can do and what it's for ๐ Sections 4-16 get into the nitty-gritty of how each mechanism works. The packet formats, protocol constants and configuration items all live in the appendices ๐
Labels like HelloInterval that show up in the text are protocol constants ๐ง They may or may not be configurable. The architectural constants are summed up in Appendix B, and the configurable constants are summed up in Appendix C.
The detailed spec is written in terms of data structures, because that makes the explanation way more precise ๐ฏ Implementations of the protocol are required to support the functionality described here, but they need not use the exact data structures that appear in this memo. the vibe is "match the behavior, not the furniture" ๐ชโจ
1.5. Acknowledgments ๐ซถ
The author wants to give a huge thank-you to Ran Atkinson, Fred Baker, Jeffrey Burgan, Rob Coltun, Dino Farinacci, Vince Fuller, Phanindra Jujjavarapu, Milo Medin, Tom Pusateri, Kannan Varadhan, Zhaohui Zhang, and the rest of the OSPF Working Group ๐ for the ideas and support they gave to this project. bestie squad goals ๐ฏโโ๏ธ
The OSPF Point-to-MultiPoint interface is based on work done by Fred Baker ๐ฆ
The OSPF Cryptographic Authentication option was developed by Fred Baker and Ran Atkinson ๐ iconic duo behavior ๐ฅ
2. The Link-state Database: organization and calculations ๐ง
The following subsections describe how OSPF's link-state database is organized, and the routing calculations that run on the database to produce a router's routing table ๐
2.1. Representation of routers and networks ๐ธ๏ธ
The Autonomous System's link-state database describes a directed graph ๐ The vertices of the graph are routers and networks. A graph edge connects two routers when they're attached via a physical point-to-point network. An edge connecting a router to a network means the router has an interface on that network. Networks can be either transit or stub networks. Transit networks are the ones that can carry data traffic that is neither locally originated nor locally destined. A transit network is a graph vertex with both incoming and outgoing edges, while a stub network's vertex only has incoming edges ๐ง
The neighborhood of each network node in the graph depends on the network's type (point-to-point, broadcast, NBMA or Point-to-MultiPoint) and on how many routers have an interface to it ๐ Three cases are shown in Figure 1a. Rectangles are routers. Circles and oblongs are networks. Router names start with RT and network names start with N. Router interface names start with I. Lines between routers mean point-to-point networks. The left side of the figure shows the networks with their connected routers, and the resulting graphs are on the right ๐
**FROM**
* |RT1|RT2|
+---+Ia +---+ * ------------
|RT1|------|RT2| T RT1| | X |
+---+ Ib+---+ O RT2| X | |
* Ia| | X |
* Ib| X | |
Physical point-to-point networks
**FROM**
+---+ *
|RT7| * |RT7| N3|
+---+ T ------------
| O RT7| | |
+----------------------+ * N3| X | |
N3 *
Stub networks
+---+ +---+
|RT3| |RT4| |RT3|RT4|RT5|RT6|N2 |
+---+ +---+ * ------------------------
| N2 | * RT3| | | | | X |
+----------------------+ T RT4| | | | | X |
| | O RT5| | | | | X |
+---+ +---+ * RT6| | | | | X |
|RT5| |RT6| * N2| X | X | X | X | |
+---+ +---+
Broadcast or NBMA networks
Figure 1a: Network map components
Networks and routers are both represented by vertices ๐ฆ An edge connects Vertex A to Vertex B iff the intersection of Column A and Row B is marked with an X. ngl that's the cleanest little rule ever ๐
The top of Figure 1a shows two routers joined by a point-to-point link. In the resulting link-state database graph, the two router vertices are directly connected by a pair of edges, one in each direction โ๏ธ Interfaces on point-to-point networks don't need IP addresses. When interface addresses are assigned, they get modelled as stub links, with each router advertising a stub connection to the other router's interface address. You can also optionally assign an IP subnet to the point-to-point network. In that case, both routers advertise a stub link to the IP subnet, instead of advertising each other's IP interface addresses ๐ง
The middle of Figure 1a shows a network with only one attached router, which is a stub network. Here the network sits at the end of a stub connection in the link-state database's graph ๐
When multiple routers are attached to a broadcast network, the link-state database graph shows all of them bidirectionally connected to the network vertex. That's the picture at the bottom of Figure 1a ๐
Each network (stub or transit) in the graph has an IP address and an associated network mask ๐ฏ The mask tells you how many nodes are on the network. Hosts attached directly to routers (called host routes) show up in the graph as stub networks. The network mask for a host route is always 0xffffffff, which means there's a single node ๐โจ
2.1.1. Representation of non-broadcast networks ๐
As mentioned previously, OSPF can run over non-broadcast networks in one of two modes: NBMA or Point-to-MultiPoint ๐ The mode you pick decides how the Hello protocol and flooding work over the non-broadcast network, and also how that network shows up in the link-state database ๐ง
In NBMA mode, OSPF emulates operation over a broadcast network ๐ช A Designated Router is elected for the NBMA network, and that Designated Router originates an LSA for the network. The graph representation for broadcast and NBMA networks is identical, and it's the one pictured in the middle of Figure 1a ๐
NBMA mode is the most efficient way to run OSPF over non-broadcast networks, both for link-state database size and for the amount of routing protocol traffic ๐ฅ The catch is that it has one big restriction: it requires all routers attached to the NBMA network to be able to communicate directly ๐ฌ That restriction can be met on some non-broadcast networks, like an ATM subnet using SVCs. But it often isn't met on others, like PVC-only Frame Relay networks. On non-broadcast networks where not every router can talk directly, you can split the network into logical subnets. Routers on each subnet can communicate directly, and then each subnet runs as its own NBMA network (see [Ref15]). Heads up though, this takes quite a bit of administrative overhead and it's prone to misconfiguration ๐ It's probably better to run that kind of network in Point-to-MultiPoint mode ๐
In Point-to-MultiPoint mode, OSPF treats all router-to-router connections over the non-broadcast network as if they were point-to-point links ๐ฆ No Designated Router is elected for the network, and no LSA is generated for it. In fact, a vertex for the Point-to-MultiPoint network doesn't even show up in the link-state database graph ๐ป
Figure 1b illustrates how a Point-to-MultiPoint network is represented in the link-state database ๐จ On the left side of the figure, a Point-to-MultiPoint network is pictured. It's assumed that all routers can communicate directly, except for routers RT4 and RT5. I3 though I6 indicate the routers' IP interface addresses on the Point-to-MultiPoint network. In the graphical representation of the link-state database, routers that can communicate directly over the Point-to-MultiPoint network are joined by bidirectional edges. Each router also has a stub connection to its own IP interface address, which is different from how real point-to-point links are represented (see Figure 1a) โจ
On some non-broadcast networks, using Point-to-MultiPoint mode together with data-link protocols like Inverse ARP (see [Ref14]) will allow autodiscovery of OSPF neighbors even when broadcast support isn't available ๐ง๐
2.1.2. An example link-state database ๐บ๏ธโจ
Okay so picture this ๐. Figure 2 is a sample map of an Autonomous System, and it's giving full network drama. The rectangle labelled H1 is a host with a SLIP connection to Router RT12, which means RT12 is advertising a host route ๐ง. Lines between routers are physical point-to-point networks. The only point-to-point network with interface addresses assigned is the one joining Routers RT6 and RT10 ๐ฆ. Routers RT5 and RT7 have BGP connections to other Autonomous Systems, and both of them display a set of BGP-learned routes ๐.
A cost is attached to the output side of each router interface, and the system administrator can configure it ๐. The lower the cost, the more likely that interface is to get used to forward data traffic ๐ฅ. Costs also apply to the externally derived routing data, like those BGP-learned routes ๐ .
Next up, the directed graph from Figure 2 is shown in Figure 3 ๐ง . Arcs are labelled with the cost of the matching router output interface. Arcs with no label have a cost of 0. Arcs leading from networks to routers always have cost 0, but they still matter, no cap ๐. Also, the externally derived routing data shows up on the graph as stubs ๐ธ.
**FROM**
+---+ +---+
|RT3| |RT4| |RT3|RT4|RT5|RT6|
+---+ +---+ * --------------------
I3| N2 |I4 * RT3| | X | X | X |
+----------------------+ T RT4| X | | | X |
I5| |I6 O RT5| X | | | X |
+---+ +---+ * RT6| X | X | X | |
|RT5| |RT6| * I3| X | | | |
+---+ +---+ I4| | X | | |
I5| | | X | |
I6| | | | X |
Figure 1b: Network map components
Point-to-MultiPoint networks
All routers can communicate directly over N2, except
routers RT4 and RT5. I3 through I6 indicate IP
interface addresses
+
| 3+---+ N12 N14
N1|--|RT1|\ 1 \ N13 /
| +---+ \ 8\ |8/8
+ \ ____ \|/
/ \ 1+---+8 8+---+6
* N3 *---|RT4|------|RT5|--------+
\____/ +---+ +---+ |
+ / | |7 |
| 3+---+ / | | |
N2|--|RT2|/1 |1 |6 |
| +---+ +---+8 6+---+ |
+ |RT3|--------------|RT6| |
+---+ +---+ |
|2 Ia|7 |
| | |
+---------+ | |
N4 | |
| |
| |
N11 | |
+---------+ | |
| | | N12
|3 | |6 2/
+---+ | +---+/
|RT9| | |RT7|---N15
+---+ | +---+ 9
|1 + | |1
_|__ | Ib|5 __|_
/ \ 1+----+2 | 3+----+1 / \
* N9 *------|RT11|----|---|RT10|---* N6 *
\____/ +----+ | +----+ \____/
| | |
|1 + |1
+--+ 10+----+ N8 +---+
|H1|-----|RT12| |RT8|
+--+SLIP +----+ +---+
|2 |4
| |
+---------+ +--------+
N10 N7
Figure 2: A sample Autonomous System
**FROM**
|RT|RT|RT|RT|RT|RT|RT|RT|RT|RT|RT|RT|N3|N6|N8|N9|
|1 |2 |3 |4 |5 |6 |7 |8 |9 |10|11|12| | | | |
----- ---------------------------------------------
RT1| | | | | | | | | | | | |0 | | | |
RT2| | | | | | | | | | | | |0 | | | |
RT3| | | | | |6 | | | | | | |0 | | | |
RT4| | | | |8 | | | | | | | |0 | | | |
RT5| | | |8 | |6 |6 | | | | | | | | | |
RT6| | |8 | |7 | | | | |5 | | | | | | |
RT7| | | | |6 | | | | | | | | |0 | | |
* RT8| | | | | | | | | | | | | |0 | | |
* RT9| | | | | | | | | | | | | | | |0 |
T RT10| | | | | |7 | | | | | | | |0 |0 | |
O RT11| | | | | | | | | | | | | | |0 |0 |
* RT12| | | | | | | | | | | | | | | |0 |
* N1|3 | | | | | | | | | | | | | | | |
N2| |3 | | | | | | | | | | | | | | |
N3|1 |1 |1 |1 | | | | | | | | | | | | |
N4| | |2 | | | | | | | | | | | | | |
N6| | | | | | |1 |1 | |1 | | | | | | |
N7| | | | | | | |4 | | | | | | | | |
N8| | | | | | | | | |3 |2 | | | | | |
N9| | | | | | | | |1 | |1 |1 | | | | |
N10| | | | | | | | | | | |2 | | | | |
N11| | | | | | | | |3 | | | | | | | |
N12| | | | |8 | |2 | | | | | | | | | |
N13| | | | |8 | | | | | | | | | | | |
N14| | | | |8 | | | | | | | | | | | |
N15| | | | | | |9 | | | | | | | | | |
H1| | | | | | | | | | | |10| | | | |
Figure 3: The resulting directed graph
Here's the vibe for the graph itself ๐: networks and routers are both vertices. An edge of cost X connects Vertex A to Vertex B iff the intersection of Column A and Row B is marked with an X. Super neat, right? ๐ญ
The link-state database gets pieced together from the LSAs that routers generate ๐งฉ. On the graph, the neighborhood of each router or transit network lives in its own separate LSA. Figure 4 shows these LSAs graphically ๐. RT12 has an interface to two broadcast networks plus that SLIP line to the host ๐. Network N6 is a broadcast network with three attached routers, and every link from N6 to those routers costs 0 ๐.
Quick heads up ๐: the LSA for Network N6 isn't generated by the network itself. It's generated by one of the attached routers, specifically the router that was elected Designated Router for that network. Iykyk ๐ซถ.
2.2. The shortest-path tree ๐ณโจ
okay so when there are no OSPF areas configured, every router in the Autonomous System has the exact same link-state database, which means they all see the same graph ๐ each router then builds its routing table by calculating a tree of shortest paths with itself as the root. main character energy fr ๐ the tree is different for every router because it depends on who's doing the math. for RT6 in our example, the shortest-path tree is in Figure 5 ๐ซถ
the tree gives the entire path to any destination network or host, but only the next hop actually gets used when forwarding ๐ฆ also, the best route to every router gets calculated too. for external data, RT6 notes the next hop and distance to any router advertising external routes. RT6's routing table is pictured in Table 2 ๐ there's a separate route for each end of a numbered point-to-point network (in this case, the serial line between RT6 and RT10) ๐
Here's the link-state stuff that feeds all of this (Figure 4):
**FROM** **FROM**
|RT12|N9|N10|H1| |RT9|RT11|RT12|N9|
* -------------------- * ----------------------
* RT12| | | | | * RT9| | | |0 |
T N9|1 | | | | T RT11| | | |0 |
O N10|2 | | | | O RT12| | | |0 |
* H1|10 | | | | * N9| | | | |
* *
RT12's router-LSA N9's network-LSA
Figure 4: Individual link state components
networks and routers are both represented by vertices ๐ฎ an edge of cost X connects Vertex A to Vertex B if and only if the intersection of Column A and Row B is marked with an X. that's the whole rule, bestie ๐ง
now here's the full SPF tree for RT6 (Figure 5) ๐ธ
RT6(origin)
RT5 o------------o-----------o Ib
/|\ 6 |\ 7
8/8|8\ | \
/ | \ 6| \
o | o | \7
N12 o N14 | \
N13 2 | \
N4 o-----o RT3 \
/ \ 5
1/ RT10 o-------o Ia
/ |\
RT4 o-----o N3 3| \1
/| | \ N6 RT7
/ | N8 o o---------o
/ | | | /|
RT2 o o RT1 | | 2/ |9
/ | | |RT8 / |
/3 |3 RT11 o o o o
/ | | | N12 N15
N2 o o N1 1| |4
| |
N9 o o N7
/|
/ |
N11 RT9 / |RT12
o--------o-------o o--------o H1
3 | 10
|2
|
o N10
Figure 5: The SPF tree for Router RT6
okay so edges that don't have a cost marked on them have a cost of zero ๐ those are the network-to-router links. the routes to networks N12-N15 are external info, and we'll cover that in Section 2.3 ๐ routes to networks in other AS'es (like N12) show up as dashed lines on the tree in Figure 5. we'll get into how that external stuff gets used in the next section โจ
here's the local part of RT6's routing table (Table 2) ๐
Destination Next Hop Distance
__________________________________
N1 RT3 10
N2 RT3 10
N3 RT3 7
N4 RT3 8
Ib * 7
Ia RT10 12
N6 RT10 8
N7 RT10 12
N8 RT10 10
N9 RT10 11
N10 RT10 13
N11 RT10 14
H1 RT10 21
__________________________________
RT5 RT5 6
RT7 RT10 8
Table 2: The portion of Router RT6's routing table listing local
destinations.
2.3. Use of external routing information ๐
after the tree is built, the external routing information gets checked ๐ this info can come from another routing protocol like BGP, or be statically configured (static routes). default routes can be part of the AS's external routing info too ๐
external routing info is flooded unaltered throughout the AS ๐ in our example, every router in the AS knows that RT7 has two external routes, with metrics 2 and 9 โจ
OSPF supports two types of external metrics ๐ Type 1 external metrics are expressed in the same units as OSPF interface cost (so, in terms of the link-state metric). Type 2 external metrics are an order of magnitude larger, and any Type 2 metric counts as greater than the cost of any path inside the AS ๐ญ using Type 2 metrics assumes that routing between AS'es is the major cost of routing a packet, and it means you don't need to convert external costs into internal link-state metrics ๐ฆ
let's do Type 1 processing ๐ง say RT7 and RT5 in Figure 2 are both advertising Type 1 external metrics. for each advertised external route, the total cost from RT6 is the sum of the external route's advertised cost plus the distance from RT6 to the advertising router. when two routers advertise the same external destination, RT6 picks the one with the minimum total cost ๐ then RT6 sets the next hop to that external destination equal to the next hop it would use to route packets to the chosen advertising router ๐ซถ
in Figure 2, both RT5 and RT7 advertise an external route to destination N12. RT7 wins because it's advertising N12 at a distance of 10 (8+2) to RT6, which beats RT5's 14 (6+8) ๐ค Table 3 shows the entries added to the routing table when external routes get examined ๐
Destination Next Hop Distance
__________________________________
N12 RT10 10
N13 RT5 14
N14 RT5 14
N15 RT10 17
Table 3: The portion of Router RT6's routing table
listing external destinations.
Type 2 processing is simpler ๐ง the AS boundary router advertising the smallest external metric gets chosen, no matter what the internal distance to that router is. so if RT5 and RT7 were both advertising Type 2 external routes, all traffic for N12 would go to RT7, since 2 < 8 ๐ฅ when several equal-cost Type 2 routes exist, the internal distance to the advertising routers breaks the tie ๐
Type 1 and Type 2 external metrics can both be in the AS at the same time ๐ when that happens, Type 1 external metrics always take precedence ๐
this section has assumed that packets for external destinations always get routed through the advertising AS boundary router. that's not always ideal ๐ for example, imagine RTX is attached to Network N6 in Figure 2. RTX doesn't participate in OSPF routing, but it does swap BGP info with the AS boundary router RT7. then RT7 would end up advertising OSPF external routes for every destination that should go to RTX ๐ an extra hop gets introduced whenever packets for those destinations have to go to RT7 first (the advertising router) ๐ญ
to fix that, OSPF lets an AS boundary router specify a "forwarding address" in its AS-external-LSAs ๐ in the example above, RT7 would put RTX's IP address as the "forwarding address" for all the destinations whose packets should go straight to RTX โจ
the "forwarding address" has one other trick too ๐ง it lets routers inside the AS work as "route servers". for example, in Figure 2, RT6 could become a route server by gaining external routing info through a mix of static configuration and external routing protocols ๐ฆ RT6 would then start advertising itself as an AS boundary router and originate a set of OSPF AS-external-LSAs. in each AS-external-LSA, RT6 would specify the correct Autonomous System exit point to use for the destination by setting the LSA's "forwarding address" field appropriately ๐
2.4. Equal-cost multipath ๐ค๏ธ
everything above has been simplified by looking at only one route to any destination ๐ in reality, if multiple equal-cost routes to a destination exist, they're all discovered and used ๐ this doesn't need any conceptual changes to the algorithm, and we'll talk about it more when we get into the tree-building process in detail ๐ซถ
with equal-cost multipath, a router can potentially have several next hops available toward any given destination ๐ธ
3. Splitting the AS into Areas โจ
okay so OSPF lets you bundle up a group of contiguous networks and hosts into one big cozy bundle called an area ๐ซถ The group plus any routers with an interface to one of those networks is the area. Every area runs its own copy of the basic link-state routing algorithm, so each area gets its own link-state database and its own graph, just like we talked about in the last section ๐ง
the area's topology is invisible from outside the area ๐ฆ and routers inside an area know nothing about the detailed topology outside of it. this isolation of knowledge is what lets the protocol seriously cut down on routing traffic, compared to treating the whole Autonomous System as one single link-state domain. iconic ๐
now the database situation changes: routers in the AS no longer all have an identical link-state database ๐ a router actually keeps a separate database for each area it's connected to. (routers connected to multiple areas are called area border routers ๐ธ) two routers in the same area have identical area link-state databases for that area, though ๐
routing in the AS happens on two levels ๐ depending on whether the source and destination of a packet live in the same area (intra-area routing) or in different areas (inter-area routing). with intra-area routing, the packet gets routed only on info from inside the area. no routing info from outside the area can be used, and that protects intra-area routing from bad routing info getting injected ๐ก๏ธ we'll get into inter-area routing in Section 3.2.
3.1. The backbone of the Autonomous System
the OSPF backbone is the special OSPF Area 0 ๐ (you'll also see it written as Area 0.0.0.0, since OSPF Area IDs are usually formatted like IP addresses). the backbone always contains all the area border routers โจ its job is distributing routing info between the non-backbone areas. the backbone has to be contiguous. it doesn't have to be physically contiguous though! backbone connectivity can be set up and kept going by configuring virtual links ๐
virtual links can be configured between any two backbone routers that have an interface to a common non-backbone area ๐ virtual links belong to the backbone. the protocol treats two routers joined by a virtual link as if they were connected by an unnumbered point-to-point backbone network. on the backbone's graph, those two routers are joined by arcs whose costs are the intra-area distances between them ๐ and the routing protocol traffic flowing along the virtual link uses intra-area routing only, periodt.
3.2. Inter-area routing
when a packet is routed between two non-backbone areas, the backbone gets used ๐ฆ the packet's path can be broken into three contiguous pieces: an intra-area path from the source to an area border router, a backbone path between the source and destination areas, and then another intra-area path to the destination. the algorithm finds the set of these paths with the smallest cost ๐
another way to picture it: inter-area routing is like forcing a star configuration on the Autonomous System, with the backbone as the hub and each non-backbone area as a spoke ๐
the topology of the backbone decides which backbone paths get used between areas. you can enhance the backbone's topology by adding virtual links, and that gives the system administrator some control over the routes inter-area traffic takes ๐ง
the right area border router to use as the packet leaves the source area is picked in exactly the same way routers advertising external routes are picked ๐ each area border router in an area summarizes its cost to all networks external to the area for that area. after the SPF tree is calculated for the area, routes to all inter-area destinations are calculated by checking those area border router summaries ๐
3.3. Classification of routers
before areas existed, the only OSPF routers with a specialized function were the ones advertising external routing info, like Router RT5 in Figure 2 ๐ once the AS gets split into OSPF areas, routers are further sorted by function into the following four overlapping categories:
- Internal routers: A router with all directly connected networks belonging to the same area. These routers run a single copy of the basic routing algorithm. โจ
- Area border routers: A router that attaches to multiple areas. Area border routers run multiple copies of the basic algorithm, one copy for each attached area. They condense the topological info of their attached areas for distribution to the backbone, and the backbone in turn distributes that info to the other areas ๐ธ
- Backbone routers: A router that has an interface to the backbone area. This includes all routers that interface to more than one area (i.e., area border routers). However, backbone routers don't have to be area border routers. Routers with all interfaces connecting to the backbone area are supported too ๐
- AS boundary routers: A router that exchanges routing info with routers belonging to other Autonomous Systems. These routers advertise AS external routing info throughout the Autonomous System. The paths to each AS boundary router are known by every router in the AS. This classification is completely independent of the previous ones: AS boundary routers may be internal or area border routers, and may or may not participate in the backbone ๐
3.4. A sample area configuration
Figure 6 shows a sample area configuration ๐ฆ the first area is made of networks N1-N4, along with their attached routers RT1-RT4. the second area is networks N6-N8, plus their attached routers RT7, RT8, RT10 and RT11. the third area is networks N9-N11 and Host H1, plus their attached routers RT9, RT11 and RT12. the third area is configured so that networks N9-N11 and Host H1 all get grouped into a single route when advertised external to the area (see Section 3.5 for more details) ๐
in Figure 6, routers RT1, RT2, RT5, RT6, RT8, RT9 and RT12 are internal routers. routers RT3, RT4, RT7, RT10 and RT11 are area border routers. and, as before, routers RT5 and RT7 are AS boundary routers โญ
...........................
. + .
. | 3+---+ . N12 N14
. N1|--|RT1|\ 1 . \ N13 /
. | +---+ \ . 8\ |8/8
. + \ ____ . \|/
. / \ 1+---+8 8+---+6
. * N3 *---|RT4|------|RT5|--------+
. \____/ +---+ +---+ |
. + / \ . |7 |
. | 3+---+ / \ . | |
. N2|--|RT2|/1 1\ . |6 |
. | +---+ +---+8 6+---+ |
. + |RT3|------|RT6| |
. +---+ +---+ |
. 2/ . Ia|7 |
. / . | |
. +---------+ . | |
.Area 1 N4 . | |
........................... | |
.......................... | |
. N11 . | |
. +---------+ . | |
. | . | | N12
. |3 . Ib|5 |6 2/
. +---+ . +----+ +---+/
. |RT9| . .........|RT10|.....|RT7|---N15.
. +---+ . . +----+ +---+ 9 .
. |1 . . + /3 1\ |1 .
. _|__ . . | / \ __|_ .
. / \ 1+----+2 |/ \ / \ .
. * N9 *------|RT11|----| * N6 * .
. \____/ +----+ | \____/ .
. | . . | | .
. |1 . . + |1 .
. +--+ 10+----+ . . N8 +---+ .
. |H1|-----|RT12| . . |RT8| .
. +--+SLIP +----+ . . +---+ .
. |2 . . |4 .
. | . . | .
. +---------+ . . +--------+ .
. N10 . . N7 .
. . .Area 2 .
.Area 3 . ................................
..........................
Figure 6: A sample OSPF area configuration
it also shows the complete view of the internet for the two internal routers RT1 and RT2 ๐ง the area border routers RT3 and RT4 have the job of advertising into Area 1 the distances to all destinations external to the area. these show up in Figure 7 as the dashed stub routes ๐ฆ RT3 and RT4 also have to advertise into Area 1 where the AS boundary routers RT5 and RT7 are. and finally, AS-external-LSAs from RT5 and RT7 are flooded throughout the entire AS, including Area 1 โจ those LSAs get included in Area 1's database and yield routes to Networks N12-N15 ๐
routers RT3 and RT4 also have to summarize Area 1's topology for distribution to the backbone ๐ธ their backbone LSAs are shown in Table 4. these summaries show which networks are contained in Area 1 (i.e., Networks N1-N4), and the distance to those networks from RT3 and RT4 respectively ๐
the link-state database for the backbone is shown in Figure 8 ๐ the routers pictured there are the backbone routers. Router RT11 is a backbone router because it belongs to two areas. to make the backbone connected, a virtual link has been configured between Routers R10 and R11 ๐
the area border routers RT3, RT4, RT7, RT10 and RT11 condense the routing info of their attached non-backbone areas for distribution via the backbone. those are the dashed stubs in Figure 8 ๐ remember that the third area is configured to condense Networks N9-N11 and Host H1 into a single route, which gives one dashed line for N9-N11 and Host H1 in Figure 8 โจ and routers RT5 and RT7 are AS boundary routers, so their externally derived info also shows up on the Figure 8 graph as stubs ๐
Network RT3 adv. RT4 adv.
_____________________________
N1 4 4
N2 4 4
N3 1 1
N4 2 3
The backbone is where the area border routers swap their summaries, and it's giving main character energy ๐โจ
Table 4: Networks advertised to the backbone
by Routers RT3 and RT4.
|RT|RT|RT|RT|RT|RT|
|1 |2 |3 |4 |5 |7 |N3|
----- -------------------
RT1| | | | | | |0 |
RT2| | | | | | |0 |
RT3| | | | | | |0 |
* RT4| | | | | | |0 |
* RT5| | |14|8 | | | |
T RT7| | |20|14| | | |
O N1|3 | | | | | | |
* N2| |3 | | | | | |
* N3|1 |1 |1 |1 | | | |
N4| | |2 | | | | |
Ia,Ib| | |20|27| | | |
N6| | |16|15| | | |
N7| | |20|19| | | |
N8| | |18|18| | | |
N9-N11,H1| | |29|36| | | |
N12| | | | |8 |2 | |
N13| | | | |8 | | |
N14| | | | |8 | | |
N15| | | | | |9 | |
Figure 7: Area 1's Database.
Networks and routers are represented by vertices.
An edge of cost X connects Vertex A to Vertex B iff
the intersection of Column A and Row B is marked
with an X.
**FROM**
|RT|RT|RT|RT|RT|RT|RT
|3 |4 |5 |6 |7 |10|11|
------------------------
RT3| | | |6 | | | |
RT4| | |8 | | | | |
RT5| |8 | |6 |6 | | |
RT6|8 | |7 | | |5 | |
RT7| | |6 | | | | |
* RT10| | | |7 | | |2 |
* RT11| | | | | |3 | |
T N1|4 |4 | | | | | |
O N2|4 |4 | | | | | |
* N3|1 |1 | | | | | |
* N4|2 |3 | | | | | |
Ia| | | | | |5 | |
Ib| | | |7 | | | |
N6| | | | |1 |1 |3 |
N7| | | | |5 |5 |7 |
N8| | | | |4 |3 |2 |
N9-N11,H1| | | | | | |11|
N12| | |8 | |2 | | |
N13| | |8 | | | | |
N14| | |8 | | | | |
N15| | | | |9 | | |
Figure 8: The backbone's database.
Networks and routers are represented by vertices.
An edge of cost X connects Vertex A to Vertex B iff
the intersection of Column A and Row B is marked
with an X.
Okay so the backbone is basically the group chat where every area border router shares its area summaries with every other area border router ๐ซถ. Each one then works out the distance to every network outside its own area by looking at all those collected LSAs and adding in the backbone distance to whichever router advertised them. Iconic teamwork, honestly ๐
Let's run it again with RT3 and RT4 as our examples ๐ฆ. First they calculate the SPF tree for the backbone, which tells them the distances to all the other area border routers. They also note the distances to the networks Ia and Ib, plus the AS boundary routers RT5 and RT7, since those all belong to the backbone. That calculation is in Table 5 ๐
dist from dist from
RT3 RT4
__________________________________
to RT3 * 21
to RT4 22 *
to RT7 20 14
to RT10 15 22
to RT11 18 25
__________________________________
to Ia 20 27
to Ib 15 22
__________________________________
to RT5 14 8
to RT7 20 14
Table 5: Backbone distances calculated
by Routers RT3 and RT4.
Next up, RT3 and RT4 read the area summaries from those area border routers, and that tells them how far away every network outside their area is ๐ธ. Then they pass those distances along inside Area 1. Table 6 shows exactly what RT3 and RT4 will advertise into Area 1. Quick note: Table 6 assumes an area range has been configured for the backbone that groups Ia and Ib into one single LSA ๐
Destination RT3 adv. RT4 adv.
_________________________________
Ia,Ib 20 27
N6 16 15
N7 20 19
N8 18 18
N9-N11,H1 29 36
_________________________________
RT5 14 8
RT7 20 14
Table 6: Destinations advertised into Area 1
by Routers RT3 and RT4.
Because of all that info, an internal router like RT1 can pick an area border router with a clear head ๐ง โจ. RT1 would send traffic for Network N6 through RT4, traffic for Network N10 through RT3, and split its traffic between the two for Network N8 ๐
RT1 can also work out the shortest path to the AS boundary routers RT5 and RT7 in this same way ๐. Then it checks the AS-external-LSAs from RT5 and RT7, so it can choose between RT5 and RT7 when it's sending to a destination in another Autonomous System (one of the networks N12-N15) ๐ง
Heads up: if the line between Routers RT6 and RT10 goes down, the backbone gets disconnected ๐ญ. Setting up a virtual link between Routers RT7 and RT10 gives the backbone more connectivity and makes it way more resistant to failures like that ๐ก๏ธ๐
3.5. IP subnetting support ๐
OSPF attaches an IP address mask to every route it advertises ๐ฆ. The mask shows the range of addresses that route covers. For example, a summary-LSA for the destination 128.185.0.0 with a mask of 0xffff0000 is actually describing one single route to the whole group of destinations from 128.185.0.0 to 128.185.255.255 ๐. Host routes work a little differently: they're always advertised with a mask of 0xffffffff, which means there's only one destination in there ๐
Putting the mask on each advertised destination is what makes variable-length subnetting possible, and that's literally so iconic ๐ฅ. It means one IP class A, B, or C network number can be chopped up into lots of subnets of different sizes. For example, the network 128.185.0.0 could be split into 62 variable-sized subnets: 15 subnets of size 4K, 15 subnets of size 256, and 32 subnets of size 8 ๐. Table 7 shows a few of the resulting network addresses along with their masks.
Network address IP address mask Subnet size
_______________________________________________
128.185.16.0 0xfffff000 4K
128.185.1.0 0xffffff00 256
128.185.0.8 0xfffffff8 8
Table 7: Some sample subnet sizes.
There are tons of ways to divide a class A, B, or C network into variable-sized subnets ๐ง. The exact procedure for doing that is outside the scope of this specification, but this spec does set one guideline: when an IP packet is forwarded, it always goes to the network that is the best match for the packet's destination ๐. "Best match" just means the longest or most specific match. For example, the default route with destination 0.0.0.0 and mask 0x00000000 always matches every IP destination, but it's always less specific than any other match ๐. So subnet masks have to be assigned in a way that makes the best match for any IP destination unambiguous โจ
Attaching an address mask to each route also makes IP supernetting possible ๐งโโ๏ธ. For example, one physical network segment could be given the [address,mask] pair [192.9.4.0,0xfffffc00]. That segment would then be a single IP network covering addresses from the four consecutive class C network numbers 192.9.4.0 through 192.9.7.0 ๐ธ. This kind of addressing is becoming super common now that CIDR is here (see [Ref10]) ๐
To get better aggregation at area boundaries, area address ranges can be used (see Section C.2 for more details) ๐ซถ. Each address range is defined as an [address,mask] pair. Lots of separate networks can sit inside one address range, the same way a subnetted network is made up of many separate subnets ๐. Area border routers then summarize what's inside the area, for distribution to the backbone, by advertising one single route per address range. The cost of that route is the maximum cost to any of the networks in that range ๐ฅ
Here's an example: an IP subnetted network might be set up as a single OSPF area ๐ฆ. In that case, you can configure one address range, which is a class A, B, or C network number along with its natural IP mask. Inside the area, you can define any number of variable-sized subnets ๐. Outside the area, though, only a single route for the entire subnetted network gets distributed, so the fact that it's subnetted at all stays hidden ๐. The cost of that route is the maximum of the costs to the component subnets ๐
3.6. Supporting stub areas ๐ง
okay so in some Autonomous Systems, the majority of the link-state database is basically just AS-external-LSAs ๐. An OSPF AS-external-LSA usually gets flooded throughout the entire AS, which is a LOT. BUT OSPF lets you configure certain areas as "stub areas" ๐ฆ. AS-external-LSAs are not flooded into or throughout stub areas, so routing to AS external destinations in these areas is based on a (per-area) default only. This shrinks the link-state database, and therefore the memory requirements, for a stub area's internal routers. iconic for the little routers ๐ซถ
To take advantage of the OSPF stub area support, default routing must be used in the stub area โจ. Here's how it works: one or more of the stub area's area border routers advertise a default route into the stub area via summary-LSAs. These summary defaults get flooded throughout the stub area, but no further ๐. (So these defaults only pertain to that particular stub area, nothing leaks out.) These summary default routes get used for any destination that isn't explicitly reachable by an intra-area or inter-area path, aka AS external destinations.
An area can be configured as a stub when there's a single exit point from the area, or when the choice of exit point doesn't need to be made on a per-external-destination basis. For example, Area 3 in Figure 6 could be configured as a stub area, because all external traffic has to travel through its single area border router RT11. If Area 3 were configured as a stub, RT11 would advertise a default route for distribution inside Area 3 (in a summary-LSA), instead of flooding the AS-external-LSAs for Networks N12-N15 into or throughout the area. main character energy ๐
OSPF makes sure all routers belonging to an area agree on whether the area has been configured as a stub. This guarantees no confusion in the flooding of AS-external-LSAs ๐ .
There are a couple of restrictions though ๐ญ. Virtual links cannot be configured through stub areas. And AS boundary routers cannot be placed internal to stub areas. literally no exceptions ๐ซ
3.7. Partitions of areas ๐ง
OSPF doesn't actively try to repair area partitions. When an area becomes partitioned, each component simply becomes a separate area, and the backbone does the routing between the new areas. Some destinations that were reachable via intra-area routing before the partition will now need inter-area routing.
However, to keep full routing after the partition, an address range must not be split across multiple components of the area partition. Also, the backbone itself must not partition. If it does, parts of the Autonomous System become unreachable ๐ฑ. Backbone partitions can be repaired by configuring virtual links (see Section 15) ๐ฉน.
Another way to think about area partitions is to look at the Autonomous System graph from Section 2. Area IDs can be viewed as colors for the graph's edges.[1] Each edge of the graph connects to a network, or is itself a point-to-point network. Either way, the edge is colored with the network's Area ID ๐.
A group of edges, all the same color and interconnected by vertices, represents an area. If the topology of the Autonomous System is intact, the graph will have several regions of color, each color being a distinct Area ID.
When the AS topology changes, one of the areas may become partitioned. The graph of the AS will then have multiple regions of the same color (Area ID). Routing in the Autonomous System keeps on working as long as these regions of same color are connected by the single backbone region ๐.
4. Functional Summary โจ
A separate copy of OSPF's basic routing algorithm runs in each area. Routers having interfaces to multiple areas run multiple copies of the algorithm. Here's a quick summary of how the routing algorithm goes ๐
When a router starts, it first initializes the routing protocol data structures. Then it waits for indications from the lower-level protocols that its interfaces are functional.
Next, the router uses OSPF's Hello Protocol to acquire neighbors. It sends Hello packets to its neighbors and, in turn, receives their Hello packets. On broadcast and point-to-point networks, the router dynamically detects its neighboring routers by sending its Hello packets to the multicast address AllSPFRouters. On non-broadcast networks, some configuration information may be necessary to discover neighbors. On broadcast and NBMA networks, the Hello Protocol also elects a Designated router for the network ๐
The router will try to form adjacencies with some of its newly acquired neighbors. Link-state databases get synchronized between pairs of adjacent routers. On broadcast and NBMA networks, the Designated Router decides which routers should become adjacent.
Adjacencies control the distribution of routing information. Routing updates are only sent and received on adjacencies ๐ซถ
A router periodically advertises its state, which is also called link state. Link state is also advertised when a router's state changes. A router's adjacencies are reflected in the contents of its LSAs. This relationship between adjacencies and link state lets the protocol detect dead routers in a timely fashion โฐ
LSAs are flooded throughout the area. The flooding algorithm is reliable, ensuring that all routers in an area have exactly the same link-state database. This database is the collection of LSAs originated by each router belonging to the area. From this database, each router calculates a shortest-path tree, with itself as root. That shortest-path tree in turn yields a routing table for the protocol ๐ธ
4.1. Inter-area routing ๐
The previous section described the operation of the protocol within a single area. For intra-area routing, no other routing information is pertinent. To route to destinations outside of the area, the area border routers inject additional routing information into the area. This additional information is a distillation of the rest of the Autonomous System's topology.
Here's how the distillation works: each area border router is by definition connected to the backbone. Each area border router summarizes the topology of its attached non-backbone areas for transmission on the backbone, and hence to all other area border routers. An area border router then has complete topological information concerning the backbone, plus the area summaries from each of the other area border routers. From this information, the router calculates paths to all inter-area destinations. The router then advertises these paths into its attached areas. This enables the area's internal routers to pick the best exit router when forwarding traffic to inter-area destinations ๐ง
4.2. AS external routes ๐
Routers that have information regarding other Autonomous Systems can flood this information throughout the AS. This external routing information is distributed verbatim to every participating router ๐ฃ. There is one exception: external routing information is not flooded into "stub" areas (see Section 3.6).
To utilize external routing information, the path to all routers advertising external information must be known throughout the AS (excepting the stub areas). For that reason, the locations of these AS boundary routers are summarized by the (non-stub) area border routers ๐
4.3. Routing protocol packets โจ
okay so OSPF just runs straight on top of IP, using IP protocol 89 ๐ง. It doesn't have its own fragmentation or reassembly, so when a packet is too big, plain IP fragmentation/reassembly steps in. BUT the OSPF packets are designed so big ones can usually get chopped into several smaller ones, and that is RECOMMENDED bestie ๐
. IP fragmentation SHOULD be avoided whenever possible ๐.
Routing protocol packets SHOULD always be sent with the IP TOS field set to 0. If at all possible, they SHOULD get priority over regular IP data traffic, both when they're being sent and when they're being received ๐. To help make that happen, OSPF protocol packets SHOULD have their IP precedence field set to the value Internetwork Control (see [Ref5]) ๐ฅ.
Every OSPF packet shares a common protocol header, and it's described in Appendix A ๐. The packet types are listed in Table 8 ๐ฆ, and their formats are also in Appendix A.
Type Packet name
Protocol function
__________________________________________________________
1 Hello Discover/maintain neighbors
2 Database Description Summarize database contents
3 Link State Request Database download
4 Link State Update Database update
5 Link State Ack Flooding acknowledgment
Table 8: OSPF packet types.
OSPF's Hello protocol uses Hello packets to discover and maintain neighbor relationships ๐ธ. The Database Description and Link State Request packets are used when forming adjacencies. OSPF's reliable update mechanism is built from the Link State Update and Link State Acknowledgment packets, so they're literally the dream team ๐ซถ.
Each Link State Update packet carries a set of new link state advertisements (LSAs) one hop further away from their point of origination โจ. A single Link State Update packet MAY contain the LSAs of several routers. Each LSA is tagged with the ID of the originating router and a checksum of its link state contents. Each LSA also has a type field, and the different OSPF LSA types are listed in Table 9 ๐.
OSPF routing packets (except Hellos) are sent ONLY over adjacencies. Okay so that means all OSPF protocol packets travel a single IP hop, except the ones sent over virtual adjacencies ๐ง. The IP source address of an OSPF protocol packet is one end of a router adjacency, and the IP destination address is either the other end of the adjacency or an IP multicast address ๐.
LS LSA LSA description
type name
________________________________________________________
1 Router-LSAs Originated by all routers.
This LSA describes
the collected states of the
router's interfaces to an
area. Flooded throughout a
single area only.
________________________________________________________
2 Network-LSAs Originated for broadcast
and NBMA networks by
the Designated Router. This
LSA contains the
list of routers connected
to the network. Flooded
throughout a single area only.
________________________________________________________
3,4 Summary-LSAs Originated by area border
routers, and flooded through-
out the LSA's associated
area. Each summary-LSA
describes a route to a
destination outside the area,
yet still inside the AS
(i.e., an inter-area route).
Type 3 summary-LSAs describe
routes to networks. Type 4
summary-LSAs describe
routes to AS boundary routers.
________________________________________________________
5 AS-external-LSAs Originated by AS boundary
routers, and flooded through-
out the AS. Each
AS-external-LSA describes
a route to a destination in
another Autonomous System.
Default routes for the AS can
also be described by
AS-external-LSAs.
Table 9: OSPF link state advertisements (LSAs).
4.4. Basic implementation requirements ๐
An implementation of OSPF requires the following pieces of system support:
Timers โฐ
Two different kinds of timers are REQUIRED ๐ . The first kind, called "single shot timers", fires once and causes a protocol event to be processed. The second kind, called "interval timers", fires at continuous intervals. These are used for sending packets at regular intervals, and a good example is the regular broadcast of Hello packets. The granularity of both kinds of timers is one second.
Interval timers SHOULD be implemented to avoid drift. In some router implementations, packet processing can affect timer execution. When multiple routers are attached to a single network, all doing broadcasts, this can lead to synchronization of routing packets (which SHOULD be avoided) ๐ญ. If timers cannot be implemented to avoid drift, small random amounts SHOULD be added to or subtracted from the interval timer at each firing ๐ฒ.
IP multicast ๐ก
Certain OSPF packets take the form of IP multicast datagrams. Support for receiving and sending IP multicast datagrams, along with the appropriate lower-level protocol support, is REQUIRED ๐ฅ. The IP multicast datagrams used by OSPF never travel more than one hop. For this reason, the ability to forward IP multicast datagrams is not REQUIRED. For information on IP multicast, see [Ref7] ๐ฆ.
Variable-length subnet support ๐
The router's IP protocol support MUST include the ability to divide a single IP class A, B, or C network number into many subnets of various sizes. This is commonly called variable-length subnetting, so see Section 3.5 for details ๐.
IP supernetting support ๐งฉ
The router's IP protocol support MUST include the ability to aggregate contiguous collections of IP class A, B, and C networks into larger quantities called supernets. Supernetting has been proposed as one way to improve the scaling of IP routing in the worldwide Internet. For more information on IP supernetting, see [Ref10] โจ.
Lower-level protocol support ๐
The lower-level protocols referred to here are the network access protocols, such as the Ethernet data link layer. Indications MUST be passed from these protocols to OSPF as the network interface goes up and down. For example, on an ethernet it would be valuable to know when the ethernet transceiver cable becomes unplugged ๐.
Non-broadcast lower-level protocol support ๐ฎ
On non-broadcast networks, the OSPF Hello Protocol can be aided by providing an indication when an attempt is made to send a packet to a dead or non-existent router. For example, on an X.25 PDN, a dead neighboring router MAY be indicated by the reception of an X.25 clear with an appropriate cause and diagnostic, and this information would be passed to OSPF ๐ง.
List manipulation primitives ๐
Much of the OSPF functionality is described in terms of its operation on lists of LSAs. For example, the collection of LSAs that will be retransmitted to an adjacent router until acknowledged is described as a list. Any particular LSA MAY be on many such lists. An OSPF implementation needs to be able to manipulate these lists, adding and deleting constituent LSAs as necessary ๐.
Tasking support ๐
Certain procedures described in this specification invoke other procedures. At times, these other procedures SHOULD be executed in-line, that is, before the current procedure is finished. This is indicated in the text by instructions to execute a procedure. At other times, the other procedures are to be executed only when the current procedure has finished. This is indicated by instructions to schedule a task ๐ซถ.
4.5. Optional OSPF capabilities ๐
The OSPF protocol defines several optional capabilities. A router indicates the optional capabilities that it supports in its OSPF Hello packets, Database Description packets, and in its LSAs. This enables routers supporting a mix of optional capabilities to coexist in a single Autonomous System ๐.
Some capabilities MUST be supported by all routers attached to a specific area. In this case, a router will not accept a neighbor's Hello Packet unless there is a match in reported capabilities (i.e., a capability mismatch prevents a neighbor relationship from forming). An example of this is the ExternalRoutingCapability (see below) ๐ .
Other capabilities can be negotiated during the Database Exchange process. This is accomplished by specifying the optional capabilities in Database Description packets. A capability mismatch with a neighbor in this case will result in only a subset of the link state database being exchanged between the two neighbors ๐ฆ.
The routing table build process can also be affected by the presence or absence of optional capabilities. For example, since the optional capabilities are reported in LSAs, routers incapable of certain functions can be avoided when building the shortest path tree ๐ง.
The OSPF optional capabilities defined in this memo are listed below. See Section A.2 for more information ๐ธ.
ExternalRoutingCapability ๐ช
Entire OSPF areas can be configured as "stubs" (see Section 3.6). AS-external-LSAs will NOT be flooded into stub areas. This capability is represented by the E-bit in the OSPF Options field (see Section A.2). In order to ensure consistent configuration of stub areas, all routers interfacing to such an area MUST have the E-bit clear in their Hello packets (see Sections 9.5 and 10.5) ๐ฅโจ
5. Protocol Data Structures โจ
okay so this section is the tour of OSPF's brain ๐ง ๐ it's all the top-level data structures the protocol runs on, plus any setup they need. (areas, interfaces, and neighbors get their own structs later, so don't worry about those yet ๐ซถ)
Router ID ๐ A 32-bit number that uniquely identifies this router in the AS. one possible move is to use the smallest IP interface address on the router. if the Router ID ever changes, the OSPF software should be restarted before the new one takes effect. and bestie, before that restart, the router should flush its self-originated LSAs from the routing domain (see Section 14.1), or they'll hang around for up to MaxAge minutes ๐
Area structures ๐บ๏ธ every area the router is connected to gets its own data structure. this one describes how the basic OSPF algorithm works in that area. remember: each area runs its own separate copy of the algorithm ๐ธ
Backbone (area) structure ๐ฆด the OSPF backbone area is responsible for spreading inter-area routing info. it's the main character of the whole network ๐
Virtual links configured ๐ these are the virtual links with this router as one endpoint. to have any configured virtual links at all, the router itself must be an area border router. virtual links are identified by the Router ID of the other endpoint, which is another area border router. both endpoint routers must be attached to a common area, called the virtual link's Transit area. virtual links are part of the backbone and act like unnumbered point-to-point networks between the two routers ๐ฆ they use the intra-area routing of their Transit area to forward packets, and they come up and down as the shortest-path trees for the Transit area get built โจ
List of external routes ๐ these are routes to destinations outside the Autonomous System. the router learned them through direct experience with another routing protocol (like BGP), through configuration, or through a mix of both (for example, dynamic external info that OSPF advertises with a configured metric). any router holding these external routes is called an AS boundary router, and it advertises them into the OSPF routing domain using AS-external-LSAs ๐ซ ๐ฅ
List of AS-external-LSAs ๐ part of the link-state database. they originate from the AS boundary routers and describe routes to destinations outside the Autonomous System. if the router is itself an AS boundary router, some of these AS-external-LSAs were self-originated ๐
The routing table ๐งญ derived from the link-state database. every entry is indexed by a destination and holds that destination's cost plus a set of paths to use when forwarding packets to it. a path is described by its type and next hop. for more detail, see Section 11 ๐
Figure 9 shows all the data structures living in a typical router. the router pictured is RT10, from the map in Figure 6. RT10 has a virtual link configured to Router RT11, with Area 2 as the link's Transit area. that's the dashed line in the figure. once the virtual link is active (through building the shortest path tree for Area 2), it becomes an interface to the backbone. check out the two backbone interfaces in Figure 9 ๐ฅน
+----+
|RT10|------+
+----+ \+-------------+
/ \ |Routing Table|
/ \ +-------------+
/ \
+------+ / \ +--------+
|Area 2|---+ +---|Backbone|
+------+***********+ +--------+
/ \ * / \
/ \ * / \
+---------+ +---------+ +------------+ +------------+
|Interface| |Interface| |Virtual Link| |Interface Ib|
| to N6 | | to N8 | | to RT11 | +------------+
+---------+ +---------+ +------------+ |
/ \ | | |
/ \ | | |
+--------+ +--------+ | +-------------+ +------------+
|Neighbor| |Neighbor| | |Neighbor RT11| |Neighbor RT6|
| RT8 | | RT7 | | +-------------+ +------------+
+--------+ +--------+ |
|
+-------------+
|Neighbor RT11|
+-------------+
Figure 9: Router RT10's Data structures
6. The Area Data Structure ๐ก
this is the area data structure, and it holds everything the basic OSPF routing algorithm needs to run. every area keeps its own link-state database ๐ a network belongs to one area, a router interface connects to one area, and each router adjacency belongs to one area too. no sharing, no drama ๐ โโ๏ธ
the OSPF backbone is the special area in charge of spreading inter-area routing info. it's the bestie everyone relies on ๐
the area's link-state database is the collection of router-LSAs, network-LSAs and summary-LSAs that the area's routers originated. this info only gets flooded throughout that single area ๐ธ the list of AS-external-LSAs (see Section 5) also counts as part of each area's link-state database.
Area ID ๐ชช a 32-bit number identifying the area. the Area ID 0.0.0.0 is reserved for the backbone ๐ฆด
List of area address ranges ๐ฆ to aggregate routing info at area boundaries, area address ranges can be used. each range is an [address,mask] pair with a status of either Advertise or DoNotAdvertise (see Section 12.4.3) โจ
Associated router interfaces ๐ this router's interfaces that connect to the area. a router interface belongs to one and only one area (or the backbone). for the backbone, this list includes all the virtual links. a virtual link is identified by the Router ID of its other endpoint, and its cost is the cost of the shortest intra-area path through the Transit area between the two routers ๐ซถ
List of router-LSAs ๐ each router in the area generates one of these. it describes the state of that router's interfaces to the area ๐
List of network-LSAs ๐ธ๏ธ one network-LSA is generated for each transit broadcast and NBMA network in the area. it describes the set of routers currently connected to that network ๐
List of summary-LSAs ๐จ these come from the area's area border routers. they describe routes to destinations inside the Autonomous System but outside the area (aka inter-area destinations) ๐ฆ
Shortest-path tree ๐ณ the shortest-path tree for the area, with this router as the root. it's derived from the collected router-LSAs and network-LSAs using the Dijkstra algorithm (see Section 16.1) ๐ง
TransitCapability ๐ฆ this parameter says whether the area can carry data traffic that neither starts nor ends in the area itself. it gets calculated when the area's shortest-path tree is built (see Section 16.1). TransitCapability is set to TRUE if and only if there are one or more fully adjacent virtual links using the area as Transit area. it's then used as an input to a later step of the routing table build (see Section 16.3). when an area's TransitCapability is TRUE, the area is called a "transit area" ๐ฅ
ExternalRoutingCapability ๐ this says whether AS-external-LSAs will be flooded into and throughout the area. it's a configurable parameter. if AS-external-LSAs are excluded from the area, the area is called a "stub". inside stub areas, routing to AS external destinations is based solely on a default summary route. the backbone cannot be configured as a stub area. and virtual links can't be configured through stub areas either. for more info, see Section 3.6 ๐
StubDefaultCost ๐ธ if the area is configured as a stub area and the router itself is an area border router, the StubDefaultCost is the cost of the default summary-LSA the router should advertise into the area. see Section 12.4.3 for more ๐
unless otherwise specified, the rest of this document is about how OSPF works within a single area ๐
7. Bringing Up Adjacencies ๐ค
OSPF creates adjacencies between neighboring routers so they can swap routing info. not every pair of neighbors will become adjacent ๐ this section covers the general stuff involved in making adjacencies. for the nitty-gritty, see Section 10 โจ
7.1. The Hello Protocol ๐
the Hello Protocol is the one in charge of establishing and maintaining neighbor relationships ๐ it also makes sure communication between neighbors is bidirectional. Hello packets get sent periodically out of every router interface. bidirectional communication is indicated when the router sees itself listed in the neighbor's Hello Packet, which is honestly so iconic ๐ฅน on broadcast and NBMA networks, the Hello Protocol also elects a Designated Router for the network ๐
the Hello Protocol works differently on broadcast networks, NBMA networks and Point-to-MultiPoint networks ๐ฆ
on broadcast networks, each router advertises itself by periodically multicasting Hello Packets. that's how neighbors get discovered dynamically ๐ these Hello Packets carry the router's view of the Designated Router's identity, plus the list of routers whose Hello Packets it has seen recently ๐ซถ
on NBMA networks, some configuration info might be needed for the Hello Protocol to work. each router that could potentially become Designated Router keeps a list of all the other routers attached to the network ๐ a router with Designated Router potential sends Hello Packets to all the other potential Designated Routers as soon as its NBMA interface first becomes operational. this is an attempt to find the Designated Router for the network ๐ต๏ธโโ๏ธ if the router itself gets elected Designated Router, it starts sending Hello Packets to all the other routers attached to the network ๐
on Point-to-MultiPoint networks, a router sends Hello Packets to all the neighbors it can communicate with directly ๐ those neighbors might be discovered dynamically through a protocol like Inverse ARP (see [Ref14]), or they might be configured ๐ง
once a neighbor has been discovered, bidirectional communication is ensured, and (if it's on a broadcast or NBMA network) a Designated Router has been elected, a decision gets made about whether an adjacency should form with that neighbor (see Section 10.4) ๐ if it should, the first step is synchronizing the neighbors' link-state databases. that's covered in the next section ๐
7.2. The Synchronization of Databases โจ
okay so, in a link-state routing algorithm it is SO important that every router's link-state database stays in sync ๐ฅ OSPF makes this way easier by only requiring adjacent routers to stay synchronized ๐ซถ The sync process kicks off the moment two routers try to bring up the adjacency. Each router describes its database by sending a sequence of Database Description packets to its neighbor. Each Database Description Packet describes a set of LSAs that belong to the router's database. When the neighbor sees an LSA that's more recent than its own copy, it makes a little note that this newer LSA should be requested ๐
This back-and-forth of Database Description packets is called the "Database Exchange Process" ๐ During it, the two routers form a master/slave relationship (very dramatic, very iconic). Each Database Description Packet has a sequence number. The master's packets (the polls) get acknowledged by the slave echoing back that sequence number. Both the polls and the responses carry summaries of link state data. The master is the only one allowed to retransmit Database Description Packets, and it only does that at fixed intervals, whose length is the configured per-interface constant RxmtInterval โฐ
Each Database Description has an indication that there are more packets to follow, which is the M-bit ๐ The Database Exchange Process is over when a router has both received and sent Database Description Packets with the M-bit off. Done and dusted โจ
During and after that exchange, each router has a list of LSAs where the neighbor has a more up-to-date instance. Those get requested in Link State Request Packets. Any Link State Requests that don't get satisfied are retransmitted at fixed intervals of time, again RxmtInterval ๐ Once the Database Description Process has wrapped up and every Link State Request has been satisfied, the databases are deemed synchronized and the routers are marked fully adjacent ๐ฅณ At that point the adjacency is fully functional and gets advertised in both routers' router-LSAs. Main character energy for real ๐
The flooding procedure starts using the adjacency as soon as the Database Exchange Process begins. This simplifies database synchronization and guarantees that it finishes in a predictable period of time ๐ฆ
7.3. The Designated Router
every broadcast and NBMA network has a Designated Router ๐ธ The Designated Router has two main jobs for the routing protocol:
- The Designated Router originates a network-LSA on behalf of the network. This LSA lists the set of routers (including the Designated Router itself) currently attached to the network. The Link State ID for this LSA (see Section 12.1.4) is the IP interface address of the Designated Router. The IP network number can then be worked out using the network's subnet/network mask ๐งฎ
- The Designated Router becomes adjacent to all other routers on the network. Since the link state databases are synchronized across adjacencies (through adjacency bring-up and then the flooding procedure), the Designated Router plays a central part in the synchronization process ๐
The Designated Router is elected by the Hello Protocol. A router's Hello Packet contains its Router Priority, which can be configured on a per-interface basis ๐ Generally speaking, when a router's interface to a network first becomes functional, it checks whether there's already a Designated Router for that network. If there is, it accepts that Designated Router, regardless of its Router Priority. (This makes it harder to predict who the Designated Router will be, but it means the Designated Router changes less often. More on that below ๐) Otherwise, the router itself becomes Designated Router if it has the highest Router Priority on the network. A more detailed (and more accurate) description of Designated Router election is in Section 9.4 ๐
The Designated Router is the endpoint of a lot of adjacencies. To optimize flooding on broadcast networks, the Designated Router multicasts its Link State Update Packets to the address AllSPFRouters, instead of sending separate packets over each adjacency. Efficient queen behavior ๐ธ
Section 2 of this document talks about the directed graph representation of an area. Router nodes are labelled with their Router ID. Transit network nodes are actually labelled with the IP address of their Designated Router. So when the Designated Router changes, it looks like the network node on the graph gets replaced by a totally new node ๐ญ That causes the network and all its attached routers to originate new LSAs. Until the link-state databases converge again, some temporary loss of connectivity may happen, and this may result in ICMP unreachable messages being sent in response to data traffic. Which is exactly why the Designated Router should change only infrequently. Router Priorities should be configured so that the most dependable router on a network eventually becomes Designated Router ๐ง
7.4. The Backup Designated Router
To make switching to a new Designated Router smoother, there's a Backup Designated Router for each broadcast and NBMA network ๐ The Backup Designated Router is also adjacent to all routers on the network, and it becomes Designated Router when the previous Designated Router fails. Without a Backup Designated Router, when a new Designated Router became necessary, new adjacencies would have to be formed between the new Designated Router and all the other routers on the network. Part of forming an adjacency is synchronizing link-state databases, which can potentially take quite a long time โณ During that time the network wouldn't be available for transit data traffic. The Backup Designated obviates the need to form these adjacencies, since they already exist. So the disruption to transit traffic only lasts as long as it takes to flood the new LSAs (the ones announcing the new Designated Router) ๐
The Backup Designated Router does not generate a network-LSA for the network. (If it did, the transition to a new Designated Router would be even faster. But that's a tradeoff between database size and speed of convergence when the Designated Router disappears ๐คทโโ๏ธ)
The Backup Designated Router is also elected by the Hello Protocol. Each Hello Packet has a field that specifies the Backup Designated Router for the network ๐
During some steps of the flooding procedure, the Backup Designated Router plays a passive role and lets the Designated Router do more of the work. This cuts down on the amount of local routing traffic. See Section 13.3 for more info ๐ฆ
7.5. The graph of adjacencies
An adjacency is bound to the network that the two routers have in common. If two routers have multiple networks in common, they can have multiple adjacencies between them ๐ซง
Picture the collection of adjacencies on a network as an undirected graph. The vertices are routers, with an edge joining two routers if they're adjacent. This graph shows how routing protocol packets flow through the Autonomous System, especially Link State Update Packets ๐
There are two possible graphs, depending on whether a Designated Router is elected for the network. On physical point-to-point networks, Point-to-MultiPoint networks and virtual links, neighboring routers become adjacent whenever they can communicate directly. On broadcast and NBMA networks, though, only the Designated Router and the Backup Designated Router become adjacent to all other routers attached to the network ๐ฅน
Both graphs are shown in Figure 10. It's assumed that Router RT7 has become the Designated Router, and Router RT3 the Backup Designated Router, for the Network N2. The Backup Designated Router performs a lesser function during flooding than the Designated Router (see Section 13.3). That's why the lines connecting Backup Designated Router RT3 are dashed ๐ซ
+---+ +---+
|RT1|------------|RT2| o---------------o
+---+ N1 +---+ RT1 RT2
RT7
o---------+
+---+ +---+ +---+ /|\ |
|RT7| |RT3| |RT4| / | \ |
+---+ +---+ +---+ / | \ |
| | | / | \ |
+-----------------------+ RT5o RT6o oRT4 |
| | N2 * * * |
+---+ +---+ * * * |
|RT5| |RT6| * * * |
+---+ +---+ *** |
o---------+
RT3
Figure 10: The graph of adjacencies ๐จ
8. Protocol Packet Processing
this section covers the general processing of OSPF routing protocol packets ๐ง It's super important that the router link-state databases stay synchronized, so routing protocol packets should get preferential treatment over ordinary data packets, both when sending and when receiving ๐
Routing protocol packets are sent along adjacencies only (with the exception of Hello packets, which are used to discover the adjacencies). That means all routing protocol packets travel a single IP hop, except those sent over virtual links ๐ฃ๏ธ
All routing protocol packets begin with a standard header. The sections below explain how to fill in and verify this standard header. Then, for each packet type, there's a section giving more details on how that particular packet type gets processed ๐
Part 12 done, bestie ๐๐
8.1. Sending protocol packets โจ
okay so when a router sends a routing protocol packet, it fills in the fields of the standard OSPF packet header ๐ (the full breakdown is in Section A.3.1 if you wanna peek ๐):
Version #: set to2, the version of the protocol documented in this spec ๐Packet type: the kind of OSPF packet, like a Link state Update or a Hello Packet ๐ฆPacket length: the length of the whole OSPF packet in bytes, header included ๐Router ID: the router's own identity, aka who's originating the packet ๐Area ID: the OSPF area the packet is being sent into ๐ธChecksum: the standard IP 16-bit one's complement checksum of the entire OSPF packet, excluding the 64-bit authentication field. This gets calculated as part of the right authentication procedure, and for some OSPF authentication types the checksum calculation is skipped entirely. See Section D.4 ๐AuTypeandAuthentication: every OSPF packet exchange gets authenticated ๐. Authentication types are assigned by the protocol and documented in Appendix D. Each IP network/subnet can use a different procedure.AuTypetells you which procedure is in use, and the 64-bit authentication field is for that procedure to use. This procedure SHOULD be the last one called when forming the packet to be sent. See Section D.4 for the deets.
So the IP destination address gets picked like this, and it's kinda giving main character energy ๐ฌ. On physical point-to-point networks, the IP destination is always set to the address AllSPFRouters. On all other network types (including virtual links), most OSPF packets go out as unicasts, meaning they're sent directly to the other end of the adjacency. In that case the IP destination is just the Neighbor IP address for the other end of the adjacency (see Section 10). The only packets that aren't sent as unicasts are on broadcast networks ๐ก. There, Hello packets go to the multicast destination AllSPFRouters. The Designated Router and its Backup send both Link State Update Packets and Link State Acknowledgment Packets to the multicast address AllSPFRouters, while all the other routers send both their Link State Update and Link State Acknowledgment Packets to the multicast address AllDRouters. ๐ซถ
Retransmissions of Link State Update packets are ALWAYS sent as unicasts. no exceptions, bestie ๐ โโ๏ธ
The IP source address SHOULD be set to the IP address of the sending interface. Interfaces to unnumbered point-to-point networks don't have an associated IP address, so on those, the IP source SHOULD be set to any of the other IP addresses belonging to the router. For this reason, there MUST be at least one IP address assigned to the router.[2] ngl this is a lot of rules, but it all makes sense ๐ง . Note that, for most purposes, virtual links act precisely the same as unnumbered point-to-point networks. However, each virtual link does have an IP interface address (discovered during the routing table build process), and that's what gets used as the IP source when sending packets over the virtual link ๐.
For more info on the format of specific OSPF packet types, check the sections listed in Table 10 ๐.
Type Packet name detailed section (transmit)
_________________________________________________________
1 Hello Section 9.5
2 Database description Section 10.8
3 Link state request Section 10.9
4 Link state update Section 13.3
5 Link state ack Section 13.5
Table 10: Sections describing OSPF protocol packet transmission. ๐
8.2. Receiving protocol packets โจ
okay, receiving is where things get spicy ๐ถ๏ธ. Whenever a protocol packet hits the router, it gets marked with the interface it arrived on. For routers with virtual links configured, it might not be obvious which interface a packet belongs to ๐ค. Like, take Router RT11 in Figure 6. If RT11 gets an OSPF protocol packet on its interface to Network N8, it might want to associate the packet with the interface to Area 2, or with the virtual link to Router RT10 (which is part of the backbone). In the following, we assume the packet is initially associated with the non-virtual link.[3] ๐ฆ
Before the packet even gets passed up to OSPF, it has to get through a bunch of IP-level checks. In order for the packet to be accepted at the IP level, it MUST pass a number of tests:
- The IP checksum MUST be correct. โ
- The packet's IP destination address MUST be the IP address of the receiving interface, or one of the IP multicast addresses
AllSPFRoutersorAllDRouters. - The IP protocol specified MUST be OSPF (89).
- Locally originated packets SHOULD NOT be passed on to OSPF. That is, the source IP address SHOULD be examined to make sure this isn't a multicast packet the router itself generated. no self-replies, periodt ๐
Next, the OSPF packet header gets verified. The fields specified in the header MUST match the ones configured for the receiving interface. If they don't, the packet SHOULD be discarded ๐๏ธ:
- The version number field MUST specify protocol version 2.
- The Area ID found in the OSPF header MUST be verified. If both of the following cases fail, the packet SHOULD be discarded. The Area ID specified in the header MUST either:
- (1) Match the Area ID of the receiving interface. In this case, the packet was sent over a single hop, so the packet's IP source address is REQUIRED to be on the same network as the receiving interface. You can check this by comparing the packet's IP source address to the interface's IP address, after masking both addresses with the interface mask. This comparison SHOULD NOT be performed on point-to-point networks. On point-to-point networks, the interface addresses of each end of the link are assigned independently, if they're assigned at all ๐.
- (2) Indicate the backbone. In this case, the packet was sent over a virtual link. The receiving router MUST be an area border router, and the Router ID specified in the packet (the source router) MUST be the other end of a configured virtual link. The receiving interface MUST also attach to the virtual link's configured Transit area. If all of these checks succeed, the packet is accepted and is from now on associated with the virtual link (and the backbone area) ๐.
- Packets whose IP destination is AllDRouters SHOULD only be accepted if the state of the receiving interface is DR or Backup (see Section 9.1) ๐ฏ.
- The AuType specified in the packet MUST match the AuType specified for the associated area.
- The packet MUST be authenticated ๐. The authentication procedure is indicated by the setting of AuType (see Appendix D). The authentication procedure MAY use one or more Authentication keys, which can be configured on a per-interface basis. The authentication procedure MAY also verify the checksum field in the OSPF packet header (which, when used, is set to the standard IP 16-bit one's complement checksum of the OSPF packet's contents after excluding the 64-bit authentication field). If the authentication procedure fails, the packet SHOULD be discarded ๐.
If the packet type is Hello, it SHOULD then be further processed by the Hello Protocol (see Section 10.5) ๐. All other packet types are sent and received only on adjacencies, which means the packet MUST have been sent by one of the router's active neighbors. If the receiving interface connects to a broadcast network, Point-to-MultiPoint network or NBMA network, the sender is identified by the IP source address found in the packet's IP header. If the receiving interface connects to a point-to-point network or a virtual link, the sender is identified by the Router ID (source router) found in the packet's OSPF header. The data structure associated with the receiving interface contains the list of active neighbors. Packets not matching any active neighbor are discarded ๐ซ .
At this point, every received protocol packet is associated with an active neighbor โจ. For further input processing of specific packet types, check the sections listed in Table 11 ๐.
Type Packet name detailed section (receive)
________________________________________________________
1 Hello Section 10.5
2 Database description Section 10.6
3 Link state request Section 10.7
4 Link state update Section 13
5 Link state ack Section 13.7
Table 11: Sections describing OSPF protocol packet reception. ๐
9. The Interface Data Structure โจ
okay so an OSPF interface is basically the connection between a router and a network ๐ we're assuming there's just one OSPF interface to each attached network/subnet, bestie. supporting multiple interfaces on a single network is a whole other vibe that gets covered in Appendix F ๐ and each interface structure has at most one IP interface address ๐
an OSPF interface can be considered to belong to the area that contains the attached network ๐ธ every routing protocol packet the router sends out over this interface gets labelled with the interface's Area ID ๐ท๏ธ you can have one or more router adjacencies developing over an interface, and a router's LSAs reflect the state of its interfaces and their associated adjacencies. it's giving full transparency โจ
here's the list of data items attached to an interface. heads up, a bunch of these are actually configuration for the attached network, so they must be the same for all routers connected to the network ๐ซถ (okay not the bold, the original says must in lowercase, but you get the vibe ๐ญ)
- Type: the OSPF interface type is either point-to-point, broadcast, NBMA, Point-to-MultiPoint or virtual link ๐ฆ
- State: the functional level of an interface ๐ state decides whether or not full adjacencies are allowed to form over the interface, and state also shows up in the router's LSAs
- IP interface address: the IP address tied to the interface. it shows up as the IP source address in every routing protocol packet sent over this interface ๐ interfaces to unnumbered point-to-point networks don't have an associated IP address, so no drama there
- IP interface mask: also called the subnet mask ๐ it marks the portion of the IP interface address that identifies the attached network. masking the IP interface address with the IP interface mask gives you the IP network number of the attached network. on point-to-point networks and virtual links the IP interface mask is not defined ๐ the link itself isn't assigned an IP network number, so the addresses on each side get assigned independently, if they get assigned at all
- Area ID: the Area ID of the area the attached network belongs to ๐ท every routing protocol packet originating from the interface gets labelled with this Area ID
- HelloInterval: the length of time, in seconds, between the Hello packets the router sends on the interface โฑ๏ธ it's advertised in Hello packets sent out this interface
- RouterDeadInterval: the number of seconds before the router's neighbors declare it down when they stop hearing its Hello Packets ๐ also advertised in Hello packets sent out this interface
- InfTransDelay: the estimated number of seconds it takes to transmit a Link State Update Packet over this interface ๐ LSAs in that packet get their age incremented by this amount before transmission. this value should take transmission and propagation delays into account, and it must be greater than zero ๐ฅ
- Router Priority: an 8-bit unsigned integer ๐ when two routers on a network both try to become Designated Router, the one with the highest Router Priority wins. a router with Router Priority set to 0 is ineligible to become Designated Router on the attached network ๐ญ it's advertised in Hello packets sent out this interface
- Hello Timer: an interval timer that makes the interface send a Hello packet โฐ it fires every HelloInterval seconds. note that on non-broadcast networks, a separate Hello packet goes to each qualified neighbor ๐ง
- Wait Timer: a single shot timer that makes the interface exit the Waiting state and, as a result, select a Designated Router on the network ๐ฌ the timer length is RouterDeadInterval seconds
- List of neighboring routers: the other routers attached to this network ๐ซง the Hello Protocol forms this list. adjacencies will form to some of these neighbors, and you can figure out the set of adjacent neighbors by checking all of the neighbors' states ๐
- Designated Router: the Designated Router selected for the attached network ๐ it's chosen on all broadcast and NBMA networks by the Hello Protocol. two pieces of identification are kept for it: its Router ID and its IP interface address on the network. the Designated Router advertises link state for the network, and that network-LSA is labelled with the Designated Router's IP address. it's initialized to 0.0.0.0, which means there's no Designated Router yet ๐ธ
- Backup Designated Router: also selected on all broadcast and NBMA networks by the Hello Protocol ๐ฆ all routers on the attached network become adjacent to both the Designated Router and the Backup Designated Router. the Backup Designated Router becomes Designated Router when the current one fails ๐ it's initialized to 0.0.0.0, meaning there's no Backup Designated Router yet
- Interface output cost(s): the cost of sending a data packet on the interface, expressed in the link state metric ๐ฐ it's advertised as the link cost for this interface in the router-LSA. the cost of an interface must be greater than zero ๐ญ
- RxmtInterval: the number of seconds between LSA retransmissions for adjacencies belonging to this interface ๐ it's also used when retransmitting Database Description and Link State Request Packets
- AuType: the type of authentication used on the attached network/subnet ๐ authentication types are defined in Appendix D. all OSPF packet exchanges are authenticated, and different authentication schemes can be used on different networks/subnets ๐
- Authentication key: configured data that lets the authentication procedure generate and/or verify OSPF protocol packets ๐๏ธ it can be configured on a per-interface basis. for example, if the AuType indicates simple password, the Authentication key is a 64-bit clear password inserted into the OSPF packet header. if AuType indicates Cryptographic authentication instead, the Authentication key is a shared secret that enables generating and/or verifying the message digests appended to the OSPF protocol packets. with Cryptographic authentication, multiple simultaneous keys are supported so you get a smooth key transition (see Section D.3) โจ
9.1. Interface states โจ
okay so here's the lineup of states a router interface can be in ๐ฆ they're listed in order of progressing functionality, so the inoperative one comes first, then a few intermediate ones, and then the final fully functional one ๐ the spec actually uses that ordering too, which is why you'll see stuff like "those interfaces in state greater than X" ๐ Figure 11 shows the graph of state changes, with each arc labelled by the event that causes it ๐ those events live in Section 9.2, and the detailed state machine is in Section 9.3 ๐ง
+----+ UnloopInd +--------+
|Down|<--------------|Loopback|
+----+ +--------+
|
|InterfaceUp
+-------+ | +--------------+
|Waiting|<-+-------------->|Point-to-point|
+-------+ +--------------+
|
WaitTimer|BackupSeen
|
|
| NeighborChange
+------+ +-+<---------------- +-------+
|Backup|<----------|?|----------------->|DROther|
+------+---------->+-+<-----+ +-------+
Neighbor | |
Change | |Neighbor
| |Change
| +--+
+---->|DR|
+--+
Figure 11: Interface State changes
In addition to the state transitions pictured,
Event InterfaceDown always forces Down State, and
Event LoopInd always forces Loopback State
Down ๐ this is the initial interface state ๐ซถ the lower-level protocols have indicated that the interface is unusable, so no protocol traffic at all will be sent or received on it. in this state, interface parameters should be set to their initial values ๐
All interface timers should be disabled, and there should be no adjacencies associated with the interface. ๐
Loopback ๐ in this state, the router's interface to the network is looped back. the interface may be looped back in hardware or software ๐ it will be unavailable for regular data traffic, but it may still be desirable to get info on the quality of the interface, either by sending ICMP pings to it or with something like a bit error test ๐ so IP packets may still be addressed to an interface in Loopback state โจ to make that work, these interfaces are advertised in router-LSAs as single host routes, whose destination is the IP interface address.[4] ๐ฆ
Waiting โณ in this state, the router is trying to figure out the identity of the (Backup) Designated Router for the network. to do that, it monitors the Hello Packets it receives. the router is not allowed to elect a Backup Designated Router or a Designated Router until it transitions out of Waiting state ๐ โโ๏ธ this prevents unnecessary changes of (Backup) Designated Router, which is honestly such a relief ๐
Point-to-point ๐ธ in this state, the interface is operational and connects either to a physical point-to-point network or to a virtual link. the moment it enters this state, the router attempts to form an adjacency with the neighboring router ๐ค Hello Packets are sent to the neighbor every HelloInterval seconds ๐จ
DR Other ๐ the interface connects to a broadcast or NBMA network where another router has been selected to be the Designated Router. in this state, the router itself has not been selected as Backup Designated Router either ๐ it forms adjacencies to both the Designated Router and the Backup Designated Router (if they exist) ๐
Backup ๐ in this state, the router itself is the Backup Designated Router on the attached network. it will be promoted to Designated Router when the current Designated Router fails ๐ญ the router establishes adjacencies to all other routers attached to the network. the Backup Designated Router does slightly different things during the Flooding Procedure compared to the Designated Router (see Section 13.3) ๐ see Section 7.4 for more on what the Backup Designated Router does ๐ซถ
DR ๐ in this state, this router itself is the Designated Router on the attached network. adjacencies are established to all other routers attached to the network ๐ค the router must also originate a network-LSA for the network node ๐ฃ that network-LSA will contain links to all routers (including the Designated Router itself) attached to the network ๐ธ๏ธ see Section 7.3 for more on the functions the Designated Router performs โจ
9.2. Events causing interface state changes ๐ฅ
state changes can be triggered by a bunch of different events ๐ they show up as the labelled arcs in Figure 11, and the label definitions are below ๐ for a detailed explanation of how these events affect OSPF protocol operation, check out Section 9.3 ๐ง
InterfaceUp ๐ lower-level protocols have indicated that the network interface is operational ๐ข this lets the interface transition out of Down state. on virtual links, the interface operational indication is actually a result of the shortest path calculation (see Section 16.7) ๐งฎ
WaitTimer โฐ the Wait Timer has fired, which marks the end of the waiting period required before electing a (Backup) Designated Router ๐
BackupSeen ๐ the router has detected the existence or non-existence of a Backup Designated Router for the network. this happens in one of two ways ๐ first, a Hello Packet may be received from a neighbor claiming to be the Backup Designated Router itself. alternatively, a Hello Packet may be received from a neighbor claiming to be the Designated Router itself, and indicating that there is no Backup Designated Router. in either case there must be bidirectional communication with the neighbor, i.e., the router must also appear in the neighbor's Hello Packet ๐คณ this event signals the end of the Waiting state ๐
NeighborChange ๐ there has been a change in the set of bidirectional neighbors associated with the interface, so the (Backup) Designated Router needs to be recalculated ๐ง the following neighbor changes lead to the NeighborChange event. for an explanation of neighbor states, see Section 10.1 ๐
- Bidirectional communication has been established to a neighbor. in other words, the state of the neighbor has transitioned to 2-Way or higher ๐ค
- There is no longer bidirectional communication with a neighbor. in other words, the state of the neighbor has transitioned to Init or lower ๐
- One of the bidirectional neighbors is newly declaring itself as either Designated Router or Backup Designated Router. this is detected through examination of that neighbor's Hello Packets ๐
- One of the bidirectional neighbors is no longer declaring itself as Designated Router, or is no longer declaring itself as Backup Designated Router. this is again detected through examination of that neighbor's Hello Packets ๐ โโ๏ธ
- The advertised Router Priority for a bidirectional neighbor has changed. this is again detected through examination of that neighbor's Hello Packets ๐
LoopInd ๐ an indication has been received that the interface is now looped back to itself ๐ช this indication can come either from network management or from the lower level protocols ๐ก
UnloopInd โก๏ธ an indication has been received that the interface is no longer looped back ๐ as with LoopInd, this indication can come either from network management or from the lower level protocols ๐ก
InterfaceDown ๐ซ lower-level protocols indicate that this interface is no longer functional ๐ต no matter what the current interface state is, the new interface state will be Down ๐
9.3. The Interface state machine ๐ฆ
okay so this is the interface state machine, and it's giving main character energy โจ Every state change is kicked off by an event (see Section 9.2) ๐ but the same event can do totally different things depending on what state the interface is already in. That's why the machine is organized by current interface state and then received event ๐ซถ Each entry tells you the new interface state and the actions you need to take.
When an interface changes state, you might need to originate a new router-LSA. See Section 12.4 for more details ๐ธ
Some of the actions below generate events for the neighbor state machine. Like, when an interface becomes inoperative, every neighbor connection tied to it has to be destroyed ๐ For more on the neighbor state machine, check Section 10.3 ๐ง
State(s): Down
Event: InterfaceUp
New state: Depends upon action routine
Okay so when InterfaceUp hits while the interface is Down, you start the interval Hello Timer, which keeps Hello packets flowing out the interface on a regular schedule ๐ Then it depends on the network. If the attached network is a physical point-to-point network, a Point-to-MultiPoint network, or a virtual link, the interface moves to Point-to-Point ๐ If that's not the case and the router isn't eligible to become Designated Router, the interface moves to DR Other ๐
Otherwise, the attached network is a broadcast or NBMA network and the router is eligible to become Designated Router. In this case, the interface goes to Waiting so it can try to discover the attached network's Designated Router, and the single shot Wait Timer starts โณ Also, if the network is NBMA, you look at the configured list of neighbors for this interface and generate the neighbor event Start for each neighbor that is also eligible to become Designated Router ๐ฅ
State(s): Waiting
Event: BackupSeen
New state: Depends upon action routine.
When BackupSeen happens in Waiting, calculate the attached network's Backup Designated Router and Designated Router, following Section 9.4 ๐ That calculation decides the new state, which will be DR Other, Backup or DR. No other options, bestie ๐
State(s): Waiting
Event: WaitTimer
New state: Depends upon action routine.
Same energy for WaitTimer in Waiting. You run the exact same calculation from Section 9.4 for the attached network's Backup Designated Router and Designated Router, and the result is still DR Other, Backup or DR โจ
State(s): DR Other, Backup or DR
Event: NeighborChange
New state: Depends upon action routine.
If NeighborChange shows up while you're in DR Other, Backup or DR, you recalculate the attached network's Backup Designated Router and Designated Router as shown in Section 9.4 ๐ฆ The result, once again, will be DR Other, Backup or DR. It's giving consistency, honestly ๐ซถ
State(s): Any State
Event: InterfaceDown
New state: Down
InterfaceDown is the drama queen of this whole table, and it works from any state ๐ The new state is Down. All interface variables get reset, and the interface timers get disabled. Every neighbor connection tied to the interface also gets destroyed, which happens by generating the event KillNbr on all of the associated neighbors (see Section 10.2) ๐ญ
State(s): Any State
Event: LoopInd
New state: Loopback
LoopInd also works from any state, and it sends the interface into Loopback ๐ The reason is that the interface isn't connected to the attached network anymore, so you run all the actions that go with the InterfaceDown event above โจ
State(s): Loopback
Event: UnloopInd
New state: Down
Last but not least, UnloopInd in Loopback takes the interface back to Down ๐ธ No actions are necessary here. For example, the interface variables were already reset when the interface entered Loopback, so there's nothing left to clean up ๐งน Just remember that the interface needs to receive an InterfaceUp event before it becomes fully functional again ๐
9.4. Electing the Designated Router ๐
okay so this section is all about the algorithm for calculating a network's Designated Router and Backup Designated Router ๐ง The Interface state machine is the one that invokes it. The very first time a router runs the election for a network, the network's Designated Router and Backup Designated Router both get set to 0.0.0.0. That value means there's no Designated Router and no Backup Designated Router yet ๐ซง
Here's how the election goes. Call the router doing the calculation Router X. You look at the list of neighbors attached to the network that have established bidirectional communication with Router X. This list is precisely the collection of Router X's neighbors on this network whose state is greater than or equal to 2-Way (see Section 10.1). Router X itself is also on the list ๐ Next, you throw out every router on the list that is ineligible to become Designated Router. Routers with a Router Priority of 0 are ineligible ๐ Then the following steps run, but only on the routers that are still on the list:
(1) Note the current values for the network's Designated Router and Backup Designated Router. You'll compare against these later ๐
(2) Calculate the new Backup Designated Router for the network. Only the routers on the list that haven't declared themselves Designated Router are eligible here ๐ If one or more of them have declared themselves Backup Designated Router (meaning they list themselves as Backup Designated Router, but not as Designated Router, in their Hello Packets), the one with the highest Router Priority gets declared Backup Designated Router ๐ฅ If there's a tie, the one with the highest Router ID wins. If no routers have declared themselves Backup Designated Router, pick the router with the highest Router Priority (again excluding routers that have declared themselves Designated Router), and use the Router ID to break ties ๐
(3) Calculate the new Designated Router for the network. If one or more routers have declared themselves Designated Router (meaning they list themselves as Designated Router in their Hello Packets), the one with the highest Router Priority is declared Designated Router ๐ If there's a tie, the one with the highest Router ID is chosen. If no routers have declared themselves Designated Router, the Designated Router is set to the same router as the newly elected Backup Designated Router ๐ซถ
(4) If Router X is now newly the Designated Router or newly the Backup Designated Router, or if it's now no longer the Designated Router or no longer the Backup Designated Router, repeat steps 2 and 3, and then move on to step 5 ๐ For example, if Router X is now the Designated Router, then when step 2 is repeated, X won't be eligible for Backup Designated Router election anymore. Among other things, this makes sure that no router ends up declaring itself both Backup Designated Router and Designated Router.[5] ๐
(5) Because of these calculations, the router itself might now be the Designated Router or the Backup Designated Router. See Sections 7.3 and 7.4 for the extra duties that come with that ๐ง The router's interface state should be set to match. If the router itself is now Designated Router, the new interface state is DR. If the router itself is now Backup Designated Router, the new interface state is Backup. Otherwise, the new interface state is DR Other ๐ธ
(6) If the attached network is an NBMA network, and the router itself has just become either Designated Router or Backup Designated Router, it must start sending Hello Packets to the neighbors that aren't eligible to become Designated Router (see Section 9.5.1) ๐จ To do that, invoke the neighbor event Start for each neighbor with a Router Priority of 0 ๐
(7) If these calculations have changed the identity of either the Designated Router or the Backup Designated Router, the set of adjacencies tied to this interface will need to be modified. Some adjacencies may need to be formed, and others may need to be broken ๐
To make that happen, invoke the event AdjOK? on all neighbors whose state is at least 2-Way. This reexamines their eligibility for adjacency (see Sections 10.3 and 10.4) โจ
The reason the election algorithm is so complicated is that it wants an orderly handover from Backup Designated Router to Designated Router when the current Designated Router fails ๐ฆ That orderly handover comes from hysteresis: no new Backup Designated Router can be chosen until the old Backup accepts its new Designated Router responsibilities ๐ซถ
The procedure above may elect the same router to be both Designated Router and Backup Designated Router, although that router will never be the calculating router (Router X) itself ๐ The elected Designated Router might not be the router with the highest Router Priority, and the Backup Designated Router won't necessarily have the second highest Router Priority either ๐ If Router X isn't eligible to become Designated Router itself, it's possible that the procedure won't select a Backup Designated Router or a Designated Router at all ๐ And if Router X is the only attached router that's eligible to become Designated Router, it will select itself as Designated Router, and there won't be any Backup Designated Router for the network ๐
9.5. Sending Hello packets โจ
Okay bestie, Hello packets go out of each functioning router interface ๐ก๐. They're how routers discover and maintain their neighbor relationships.[6] On broadcast and NBMA networks, Hello Packets also help elect the Designated Router and Backup Designated Router ๐.
The format of an Hello packet is in Section A.3.2 ๐. The Hello Packet carries the router's Router Priority (used when choosing the Designated Router) and the interval between Hello Packets sent out the interface (HelloInterval). It also says how often a neighbor has to be heard from to stay active (RouterDeadInterval). HelloInterval and RouterDeadInterval MUST be the same for all routers attached to a common network ๐ซถ. The packet also has the IP address mask of the attached network (Network Mask). On unnumbered point-to-point networks and on virtual links, this field SHOULD be set to 0.0.0.0 ๐ธ.
The Hello packet's Options field describes the router's optional OSPF capabilities. One optional capability is defined in this specification (see Sections 4.5 and A.2) ๐ง. The E-bit of the Options field SHOULD be set if and only if the attached area is capable of processing AS-external-LSAs (i.e., it is not a stub area). If the E-bit is set incorrectly, the neighboring routers will refuse to accept the Hello Packet (see Section 10.5) ๐. Unrecognized bits in the Hello Packet's Options field SHOULD be set to zero ๐.
To make sure two adjacent routers can talk both ways, the Hello packet lists every router on the network that has sent a Hello Packet recently ๐ฆ. It also carries the router's current pick for Designated Router and Backup Designated Router. A value of 0.0.0.0 in these fields means nobody has been selected yet ๐.
On broadcast networks and physical point-to-point networks, Hello packets go out every HelloInterval seconds to the IP multicast address AllSPFRouters ๐ฃ. On virtual links, Hello packets are sent as unicasts (addressed directly to the other end of the virtual link) every HelloInterval seconds. On Point-to-MultiPoint networks, separate Hello packets go to each attached neighbor every HelloInterval seconds. Sending Hello packets on NBMA networks is covered in the next section ๐ซง.
9.5.1. Sending Hello packets on NBMA networks
Static configuration may be needed for the Hello Protocol to work on non-broadcast networks (see Sections C.5 and C.6) โ๏ธ. On NBMA networks, every attached router that is eligible to become Designated Router becomes aware of all of its neighbors on the network (either through configuration or by some unspecified mechanism). Each neighbor is labelled with that neighbor's Designated Router eligibility ๐ท๏ธ.
The interface state MUST be at least Waiting before any Hello Packets are sent out the NBMA interface ๐ฆ. Hello Packets are then sent directly (as unicasts) to some subset of a router's neighbors. Sometimes a Hello Packet goes out on a timer, and other times it's sent as a reply to a received Hello Packet. How often a router sends hellos depends on whether the router itself is eligible to become Designated Router ๐
.
If the router is eligible to become Designated Router, it MUST periodically send Hello Packets to all neighbors that are also eligible ๐. If the router is itself the Designated Router or Backup Designated Router, it MUST also send periodic Hello Packets to all other neighbors. That means any two eligible routers are always exchanging Hello Packets, which is necessary for the correct operation of the Designated Router election algorithm ๐ฅ. To keep the number of Hello Packets down, the number of eligible routers on an NBMA network SHOULD be kept small ๐ค.
If the router is not eligible to become Designated Router, it MUST periodically send Hello Packets to both the Designated Router and the Backup Designated Router (if they exist) ๐. It MUST also send a Hello Packet in reply to a Hello Packet received from any eligible neighbor (other than the current Designated Router and Backup Designated Router). This is needed to set up an initial bidirectional relationship with any potential Designated Router ๐ค.
When sending Hello packets periodically to any neighbor, the interval depends on that neighbor's state. If the neighbor is in state Down, Hello Packets go out every PollInterval seconds. Otherwise, they go out every HelloInterval seconds โฑ๏ธโจ.
10. The Neighbor Data Structure ๐
An OSPF router chats with its neighboring routers all the time ๐ฌ. Each separate conversation is described by a "neighbor data structure". Each conversation is bound to a particular OSPF router interface, and is identified either by the neighboring router's OSPF Router ID or by its Neighbor IP address (see below). So if the OSPF router and another router share multiple attached networks, multiple conversations happen, each described by its own unique neighbor data structure ๐ฏ. Each separate conversation is loosely called a separate "neighbor" in the text.
The neighbor data structure holds everything about the forming or formed adjacency between two neighbors. (Remember, though, that not all neighbors become adjacent ๐.) An adjacency is basically a highly developed conversation between two routers ๐.
State The functional level of the neighbor conversation. This is described in more detail in Section 10.1 ๐ฆ.
Inactivity Timer A single shot timer whose firing means no Hello Packet has been seen from this neighbor recently. The length of the timer is RouterDeadInterval seconds โฐ.
Master/Slave When two neighbors are exchanging databases, they form a master/slave relationship ๐. The master sends the first Database Description Packet, and is the only one allowed to retransmit. The slave can only respond to the master's Database Description Packets. The master/slave relationship is negotiated in state ExStart ๐ค.
DD Sequence Number The DD Sequence number of the Database Description packet currently being sent to the neighbor ๐ข.
Last received Database Description packet The initialize(I), more (M) and master(MS) bits, Options field, and DD sequence number contained in the last Database Description packet received from the neighbor. It's used to figure out whether the next Database Description packet from the neighbor is a duplicate ๐.
Neighbor ID The OSPF Router ID of the neighboring router. The Neighbor ID is learned when Hello packets are received from the neighbor, or it's configured if this is a virtual adjacency (see Section C.4) ๐ชช.
Neighbor Priority The Router Priority of the neighboring router. It's contained in the neighbor's Hello packets, and it's used when selecting the Designated Router for the attached network ๐.
Neighbor IP address The IP address of the neighboring router's interface to the attached network ๐. It's used as the Destination IP address when protocol packets are sent as unicasts along this adjacency. It's also used in router-LSAs as the Link ID for the attached network if the neighboring router is selected to be Designated Router (see Section 12.4.1). The Neighbor IP address is learned when Hello packets are received from the neighbor. For virtual links, the Neighbor IP address is learned during the routing table build process (see Section 15) ๐บ๏ธ.
Neighbor Options The optional OSPF capabilities supported by the neighbor ๐งฉ. These are learned during the Database Exchange process (see Section 10.6). The neighbor's optional OSPF capabilities are also listed in its Hello packets. This lets received Hello Packets be rejected (i.e., neighbor relationships won't even start to form) if there's a mismatch in certain crucial OSPF capabilities (see Section 10.5) ๐ซ. The optional OSPF capabilities are documented in Section 4.5.
Neighbor's Designated Router The neighbor's idea of the Designated Router. If this is the neighbor itself, it matters for the local calculation of the Designated Router. Only defined on broadcast and NBMA networks ๐ป.
Neighbor's Backup Designated Router The neighbor's idea of the Backup Designated Router. If this is the neighbor itself, it matters for the local calculation of the Backup Designated Router. Only defined on broadcast and NBMA networks ๐.
The next set of variables are lists of LSAs ๐. These lists describe subsets of the area link-state database. This memo defines five distinct types of LSAs, all of which may be present in an area link-state database: router-LSAs, network-LSAs, and Type 3 and 4 summary-LSAs (all stored in the area data structure), and AS-external-LSAs (stored in the global data structure) ๐๏ธ.
Link state retransmission list The list of LSAs that have been flooded but not acknowledged on this adjacency. They'll be retransmitted at intervals until they're acknowledged, or until the adjacency is destroyed ๐.
Database summary list The complete list of LSAs that make up the area link-state database, at the moment the neighbor goes into Database Exchange state. This list is sent to the neighbor in Database Description packets ๐.
Link state request list The list of LSAs that need to be received from this neighbor in order to synchronize the two neighbors' link-state databases. It's created as Database Description packets are received, then sent to the neighbor in Link State Request packets. The list gets depleted as the appropriate Link State Update packets are received ๐ฅนโจ.
10.1. Neighbor states โจ
okay bestie, neighbor states time ๐ฆ A neighbor's state is really the state of a conversation the router is having with a neighboring router, so it's not about the neighbor itself ๐ The states are listed in order of how functional they get. The inoperative one comes first, then a bunch of intermediate states, then the fully functional one ๐ The spec leans on that ordering too, with stuff like "those neighbors/adjacencies in state greater than X" ๐ Figures 12 and 13 are the state change graphs, with each arc labelled by the event that causes the change. The neighbor events live in Section 10.2 ๐ธ
Figure 12 is all about the Hello Protocol ๐ That's the thing in charge of neighbor acquisition and maintenance, and of making sure two-way communication is actually happening between neighbors ๐ซถ
Figure 13 shows how an adjacency forms ๐ฅ Not every pair of neighboring routers ends up adjacent (see Section 10.4), so don't assume it'll happen ๐ The adjacency starts forming when the neighbor reaches ExStart. Once the two routers work out their master/slave status, it moves to Exchange. Now the neighbor gets used in the flooding procedure, and the two routers start syncing their databases โจ When that sync is finished, the neighbor is Full and we say the two routers are fully adjacent. At that point the adjacency gets listed in LSAs ๐
For the detailed version of each state change, plus the extra actions that go with them, check out Section 10.3 ๐ง
Down ๐
This is the starting point of a neighbor conversation. It means no recent information has come in from the neighbor ๐ฅบ On NBMA networks, Hello packets may still be sent to "Down" neighbors, just at a reduced frequency (see Section 9.5.1).
+----+
|Down|
+----+
|\
| \Start
| \ +-------+
Hello | +---->|Attempt|
Received | +-------+
| |
+----+<-+ |HelloReceived
|Init|<---------------+
+----+<--------+
| |
|2-Way |1-Way
|Received |Received
| |
+-------+ | +-----+
|ExStart|<--------+------->|2-Way|
+-------+ +-----+
Figure 12: Neighbor state changes (Hello Protocol)
In addition to the state transitions pictured,
Event KillNbr always forces Down State,
Event Inactivity Timer always forces Down State,
Event LLDown always forces Down State
+-------+
|ExStart|
+-------+
|
NegotiationDone|
+->+--------+
|Exchange|
+--+--------+
|
Exchange|
Done |
+----+ | +-------+
|Full|<---------+----->|Loading|
+----+<-+ +-------+
| LoadingDone |
+------------------+
Figure 13: Neighbor state changes (Database Exchange)
In addition to the state transitions pictured,
Event SeqNumberMismatch forces ExStart state,
Event BadLSReq forces ExStart state,
Event 1-Way forces Init state,
Event KillNbr always forces Down State,
Event InactivityTimer always forces Down State,
Event LLDown always forces Down State,
Event AdjOK? leads to adjacency forming/breaking
Attempt ๐ฎ
This state only applies to neighbors attached to NBMA networks ๐ It means no recent info has come from the neighbor, but we should make a more serious effort to reach them. So we send the neighbor Hello packets at intervals of HelloInterval (see Section 9.5.1).
Init ๐
In this state, a Hello packet has recently been seen from the neighbor ๐จ But bidirectional communication isn't set up yet, because the router itself didn't show up in the neighbor's Hello packet ๐ All neighbors in this state or higher get listed in the Hello packets sent out from the associated interface ๐
2-Way ๐ค
In this state, the two routers can talk both ways, and the Hello Protocol is what makes that sure ๐ This is the most advanced state before adjacency establishment starts. The (Backup) Designated Router gets picked from the set of neighbors in 2-Way or greater ๐
ExStart ๐
This is the very first step in creating an adjacency between the two neighboring routers โจ The goal here is to decide which router is the master, and to pick the initial DD sequence number. Neighbor conversations in this state or greater are called adjacencies ๐
Exchange ๐
In this state, the router is describing its whole link state database by sending Database Description packets to the neighbor ๐ซถ Each Database Description packet has a DD sequence number and gets explicitly acknowledged. Only one Database Description packet is allowed to be outstanding at any one time ๐ Link State Request packets may also go out in this state, asking the neighbor for its more recent LSAs. All adjacencies in Exchange state or greater are used by the flooding procedure ๐ฅ Honestly these adjacencies can transmit and receive all types of OSPF routing protocol packets, so they're fully capable ๐ช
Loading ๐ฆ
In this state, Link State Request packets get sent to the neighbor, asking for the more recent LSAs that were discovered (but not yet received) during Exchange ๐ต๏ธโโ๏ธ
Full ๐ฏ
Here the neighboring routers are fully adjacent, period ๐ These adjacencies will now show up in router-LSAs and network-LSAs ๐
10.2. Events causing neighbor state changes ๐
State changes can happen because of a bunch of different events ๐ธ They're the stuff shown in the labels on the arcs of Figures 12 and 13. Here's what each label means:
HelloReceived ๐จ
A Hello packet has been received from the neighbor.
Start ๐
This is basically a signal that Hello packets should now be sent to the neighbor every HelloInterval seconds ๐ This event only gets generated for neighbors associated with NBMA networks ๐
2-WayReceived ๐ค
Bidirectional communication has been realized between the two neighboring routers ๐ You can tell because the router sees itself in the neighbor's Hello packet ๐
NegotiationDone ๐งโ๐คโ๐ง
The Master/Slave relationship has been negotiated, and DD sequence numbers have been exchanged ๐ This signals the start of sending and receiving Database Description packets. For more on how this event gets generated, consult Section 10.8 โจ
ExchangeDone ๐
Both routers have successfully transmitted a full sequence of Database Description packets ๐ Each router now knows which parts of its link state database are out of date. For more on how this event gets generated, consult Section 10.8 ๐ง
BadLSReq ๐
A Link State Request has been received for an LSA that isn't in the database. This means something went wrong in the Database Exchange process ๐ญ
Loading Done ๐
Link State Updates have been received for all out-of-date portions of the database โ You can tell because the link state request list goes empty after the Database Exchange process has completed ๐ฅณ
AdjOK? ๐ค
A decision has to be made about whether an adjacency should be established or maintained with the neighbor ๐ญ This event will kick off some adjacencies forming, and destroy others ๐ฅ
The following events cause well developed neighbors to revert to lesser states ๐ Unlike the events above, these can happen when the neighbor conversation is in any of a bunch of different states ๐
SeqNumberMismatch ๐ โโ๏ธ
A Database Description packet has been received that either a) has an unexpected DD sequence number, b) unexpectedly has the Init bit set, or c) has an Options field that differs from the last Options field received in a Database Description packet ๐ฌ Any of these means some error happened during adjacency establishment.
1-Way ๐
A Hello packet has been received from the neighbor, and the router isn't mentioned in it ๐ซ That means communication with the neighbor isn't bidirectional.
KillNbr โ ๏ธ
This is an indication that all communication with the neighbor is now impossible, so the neighbor is forced back to Down state ๐
InactivityTimer โฐ
The Inactivity Timer has fired ๐ต That means no Hello packets have been seen from the neighbor recently, so it reverts to Down state.
LLDown ๐
This is an indication from the lower level protocols that the neighbor is now unreachable ๐ก For example, on an X.25 network this could be signaled by an X.25 clear indication with appropriate cause and diagnostic fields. This event forces the neighbor into Down state ๐
10.3. The Neighbor state machine
okay so this is the neighbor state machine and it is giving drama ๐ โจ Every state change gets kicked off by an event (see Section 10.2), but the same event can do totally different things depending on what state the neighbor is already in ๐ So the machine is organized by current neighbor state and received event, and each entry tells you the new state plus the extra actions you need to take ๐
When a neighbor's state changes, you might need to rerun the Designated Router election algorithm ๐ณ๏ธ Whether you do depends on if the interface NeighborChange event gets generated (see Section 9.2). And if the Interface is in DR state (meaning the router is itself the Designated Router), neighbor state changes can cause a new network-LSA to be originated (see Section 12.4) ๐ธ
When the neighbor state machine needs to invoke the interface state machine, it should do that as a scheduled task (see Section 4.4) ๐ง This keeps things clean because neither state machine ends up running recursively inside the other. no spaghetti, bestie ๐๐ซ
Here are the entries, verbatim so you can see every detail ๐
State(s): Down
Event: Start
New state: Attempt
Action: Send an Hello Packet to the neighbor (this neighbor
is always associated with an NBMA network) and start
the Inactivity Timer for the neighbor. The timer's
later firing would indicate that communication with
the neighbor was not attained.
Starting from Down with the Start event moves you to Attempt. You send a Hello and start the Inactivity Timer, and if that timer fires it means the neighbor never answered ๐
State(s): Attempt
Event: HelloReceived
New state: Init
Action: Restart the Inactivity Timer for the neighbor, since
the neighbor has now been heard from.
Attempt plus HelloReceived gets you to Init. The neighbor finally talked back, so the Inactivity Timer gets restarted ๐ฆ
State(s): Down
Event: HelloReceived
New state: Init
Action: Start the Inactivity Timer for the neighbor. The
timer's later firing would indicate that the neighbor
is dead.
From Down, a HelloReceived also takes you to Init, but this time you start the Inactivity Timer. If it fires later, that means the neighbor is dead โ ๏ธ rip bozo
State(s): Init or greater
Event: HelloReceived
New state: No state change.
Action: Restart the Inactivity Timer for the neighbor, since
the neighbor has again been heard from.
If you're already at Init or greater and another HelloReceived comes in, the state stays exactly where it is. You just restart the Inactivity Timer because the neighbor is still around ๐ซถ
State(s): Init
Event: 2-WayReceived
New state: Depends upon action routine.
Action: Determine whether an adjacency should be established
with the neighbor (see Section 10.4). If not, the
new neighbor state is 2-Way.
Otherwise (an adjacency should be established) the
neighbor state transitions to ExStart. Upon
entering this state, the router increments the DD
sequence number in the neighbor data structure. If
this is the first time that an adjacency has been
attempted, the DD sequence number should be assigned
some unique value (like the time of day clock). It
then declares itself master (sets the master/slave
bit to master), and starts sending Database
Description Packets, with the initialize (I), more
(M) and master (MS) bits set. This Database
Description Packet should be otherwise empty. This
Database Description Packet should be retransmitted
at intervals of RxmtInterval until the next state is
entered (see Section 10.8).
This is the big moment where Init meets 2-WayReceived ๐ First the router figures out whether an adjacency should happen (see Section 10.4). If not, the neighbor lands in 2-Way. If so, it goes to ExStart, bumps the DD sequence number, and declares itself master by setting the master/slave bit to master. Then it starts sending Database Description Packets with the I, M and MS bits set. That packet should be otherwise empty and gets retransmitted every RxmtInterval until the next state is entered (see Section 10.8) ๐
State(s): ExStart
Event: NegotiationDone
New state: Exchange
Action: The router must list the contents of its entire area
link state database in the neighbor Database summary
list. The area link state database consists of the
router-LSAs, network-LSAs and summary-LSAs contained
in the area structure, along with the AS-external-
LSAs contained in the global structure. AS-
external-LSAs are omitted from a virtual neighbor's
Database summary list. AS-external-LSAs are omitted
from the Database summary list if the area has been
configured as a stub (see Section 3.6). LSAs whose
age is equal to MaxAge are instead added to the
neighbor's Link state retransmission list. A
summary of the Database summary list will be sent to
the neighbor in Database Description packets. Each
Database Description Packet has a DD sequence
number, and is explicitly acknowledged. Only one
Database Description Packet is allowed outstanding
at any one time. For more detail on the sending and
receiving of Database Description packets, see
Sections 10.8 and 10.6.
Once ExStart sees NegotiationDone, the router moves to Exchange and has to list its whole area link state database in the neighbor Database summary list ๐ That means the router-LSAs, network-LSAs and summary-LSAs in the area structure, plus the AS-external-LSAs in the global structure. But AS-external-LSAs get left out for a virtual neighbor, and also left out if the area is configured as a stub (see Section 3.6). LSAs sitting at MaxAge go onto the neighbor's Link state retransmission list instead. The summary gets sent in Database Description packets, each with a DD sequence number and an explicit acknowledgement, and only one of those packets can be outstanding at a time. More details live in Sections 10.8 and 10.6 ๐ซ
State(s): Exchange
Event: ExchangeDone
New state: Depends upon action routine.
Action: If the neighbor Link state request list is empty,
the new neighbor state is Full. No other action is
required. This is an adjacency's final state.
Otherwise, the new neighbor state is Loading. Start
(or continue) sending Link State Request packets to
the neighbor (see Section 10.9). These are requests
for the neighbor's more recent LSAs (which were
discovered but not yet received in the Exchange
state). These LSAs are listed in the Link state
request list associated with the neighbor.
When Exchange sees ExchangeDone, it depends on whether the Link state request list is empty. If it is, you're at Full, which is the adjacency's final state, and nothing else is needed โจ If it isn't, you go to Loading and start (or keep) sending Link State Request packets to ask for the neighbor's newer LSAs, the ones you discovered but haven't received yet (see Section 10.9) ๐ฌ
State(s): Loading
Event: Loading Done
New state: Full
Action: No action required. This is an adjacency's final
state.
Loading plus Loading Done lands you at Full. Nothing to do, you made it ๐
State(s): 2-Way
Event: AdjOK?
New state: Depends upon action routine.
Action: Determine whether an adjacency should be formed with
the neighboring router (see Section 10.4). If not,
the neighbor state remains at 2-Way. Otherwise,
transition the neighbor state to ExStart and perform
the actions associated with the above state machine
entry for state Init and event 2-WayReceived.
From 2-Way, an AdjOK? check decides things. If no adjacency should form (see Section 10.4), you stay at 2-Way. If one should, you move to ExStart and run the same actions as the Init plus 2-WayReceived entry above ๐
State(s): ExStart or greater
Event: AdjOK?
New state: Depends upon action routine.
Action: Determine whether the neighboring router should
still be adjacent. If yes, there is no state change
and no further action is necessary.
Otherwise, the (possibly partially formed) adjacency
must be destroyed. The neighbor state transitions
to 2-Way. The Link state retransmission list,
Database summary list and Link state request list
are cleared of LSAs.
For ExStart or greater, AdjOK? asks whether the neighbor should still be adjacent. If yes, nothing changes. If no, the possibly half-built adjacency has to be destroyed ๐ The neighbor drops to 2-Way, and the Link state retransmission list, Database summary list and Link state request list all get cleared of LSAs.
State(s): Exchange or greater
Event: SeqNumberMismatch
New state: ExStart
Action: The (possibly partially formed) adjacency is torn
down, and then an attempt is made at
reestablishment. The neighbor state first
transitions to ExStart. The Link state
retransmission list, Database summary list and Link
state request list are cleared of LSAs. Then the
router increments the DD sequence number in the
neighbor data structure, declares itself master
(sets the master/slave bit to master), and starts
sending Database Description Packets, with the
initialize (I), more (M) and master (MS) bits set.
This Database Description Packet should be otherwise
empty (see Section 10.8).
Uh oh, SeqNumberMismatch in Exchange or greater means the adjacency gets torn down and then rebuilt from scratch ๐ญ The neighbor goes back to ExStart, the three lists get cleared, the DD sequence number goes up, and the router declares itself master again and starts sending Database Description Packets with I, M and MS set. Same empty packet as before (see Section 10.8). fresh start, no drama ๐
State(s): Exchange or greater
Event: BadLSReq
New state: ExStart
Action: The action for event BadLSReq is exactly the same as
for the neighbor event SeqNumberMismatch. The
(possibly partially formed) adjacency is torn down,
and then an attempt is made at reestablishment. For
more information, see the neighbor state machine
entry that is invoked when event SeqNumberMismatch
is generated in state Exchange or greater.
BadLSReq is basically SeqNumberMismatch's twin ๐ฏ Same exact action: tear it down, try again, and go look at the SeqNumberMismatch entry above if you want the full details.
State(s): Any state
Event: KillNbr
New state: Down
Action: The Link state retransmission list, Database summary
list and Link state request list are cleared of
LSAs. Also, the Inactivity Timer is disabled.
KillNbr works from any state and sends the neighbor to Down. All three lists get cleared, and the Inactivity Timer gets disabled โ ๏ธ
State(s): Any state
Event: LLDown
New state: Down
Action: The Link state retransmission list, Database summary
list and Link state request list are cleared of
LSAs. Also, the Inactivity Timer is disabled.
LLDown does the exact same cleanup from any state and drops you to Down ๐
State(s): Any state
Event: InactivityTimer
New state: Down
Action: The Link state retransmission list, Database summary
list and Link state request list are cleared of
LSAs.
InactivityTimer also sends you to Down from any state. This time the lists get cleared, but the timer is already doing its thing, so there's no mention of disabling it ๐
State(s): 2-Way or greater
Event: 1-WayReceived
New state: Init
Action: The Link state retransmission list, Database summary
list and Link state request list are cleared of
LSAs.
If you're at 2-Way or greater and a 1-WayReceived shows up, you fall back to Init and clear those three lists ๐
State(s): 2-Way or greater
Event: 2-WayReceived
New state: No state change.
Action: No action required.
2-Way or greater getting another 2-WayReceived means no state change and no action required. Chill ๐งโโ๏ธ
State(s): Init
Event: 1-WayReceived
New state: No state change.
Action: No action required.
Last one! At Init, a 1-WayReceived just leaves you right where you are with nothing to do ๐ธ
10.4. Whether to become adjacent
okay so not every neighbor gets an adjacency, and that's a whole decision ๐ค Some subset of the router's neighbors get adjacent, and the rules are pretty clear. Routers on point-to-point networks, Point-to-MultiPoint networks and virtual links always become adjacent ๐ On broadcast and NBMA networks, though, every router becomes adjacent to both the Designated Router and the Backup Designated Router ๐
The adjacency-forming decision happens in two places in the neighbor state machine. The first is when bidirectional communication is first set up with the neighbor, and the second is when the identity of the attached network's (Backup) Designated Router changes โจ If the router decides not to try for an adjacency, the neighbor communication just stops at 2-Way.
An adjacency should be established with a bidirectional neighbor when at least one of these conditions holds:
- The underlying network type is point-to-point
- The underlying network type is Point-to-MultiPoint
- The underlying network type is virtual link
- The router itself is the Designated Router
- The router itself is the Backup Designated Router
- The neighboring router is the Designated Router
- The neighboring router is the Backup Designated Router
10.5. Receiving Hello Packets ๐จ
Okay bestie, this part is the deep dive on how a received Hello Packet gets processed ๐
(peep Section A.3.2 for the format of Hello packets ๐). By now the generic input processing has already checked the IP header and the OSPF packet header, so we're past that. Next, the Network Mask, HelloInterval, and RouterDeadInterval fields in the Hello MUST be checked against what's configured on the receiving interface. Any mismatch means processing stops and the packet gets dropped ๐
โโ๏ธ. These fields are really describing the attached network's config, so they have to line up. BUT there's one lowkey exception ๐: on point-to-point networks and on virtual links, the Network Mask in the received Hello Packet SHOULD be ignored.
The receiving interface attaches to a single OSPF area (yes, that could be the backbone ๐). The E-bit in the Hello's Options field has to match that area's ExternalRoutingCapability. If AS-external-LSAs aren't flooded into or throughout the area (aka the area is a "stub" ๐งธ), the E-bit MUST be clear in received Hello Packets. Otherwise the E-bit MUST be set. A mismatch means processing stops and the packet is dropped. The rest of the bits in the Options field SHOULD be ignored ๐คทโโ๏ธ.
Now we try to match the source of the Hello to one of the receiving interface's neighbors ๐. If the interface connects to a broadcast, Point-to-MultiPoint or NBMA network, the source is identified by the IP source address in the Hello's IP header. If the interface connects to a point-to-point link or a virtual link, the source is identified by the Router ID in the Hello's OSPF packet header. The interface's current neighbor list lives in the interface's data structure. If no matching neighbor structure exists (aka this is the first time we've spotted this neighbor ๐), one gets created, and its initial state is set to Down ๐ธ.
When a Hello comes in from a neighbor on a broadcast, Point-to-MultiPoint or NBMA network, set the neighbor structure's Neighbor ID to the Router ID from the packet's OSPF header. On a point-to-point network (but not on a virtual link), set the neighbor structure's Neighbor IP address to the packet's IP source address ๐.
Now the rest of the Hello gets examined, generating events for the neighbor and interface state machines ๐ฆ. These state machines are either executed or scheduled (see Section 4.4 ๐). For example, if the neighbor state machine is executed in line, a single received Hello can trigger several neighbor state transitions at once โจ:
- Each Hello Packet causes the neighbor state machine to be executed with the event
HelloReceived. ๐ซ - Then the list of neighbors contained in the Hello Packet is examined. If the router itself appears in this list, the neighbor state machine SHOULD be executed with the event
2-WayReceived. Otherwise, the neighbor state machine SHOULD be executed with the event1-WayReceived, and the processing of the packet stops ๐. - Next, the Hello Packet's
Router Priorityfield is examined. If this field is different than the one previously received from the neighbor, the receiving interface's state machine is scheduled with the eventNeighborChange. In any case, theRouter Priorityfield in the neighbor data structure SHOULD be updated accordingly ๐. - Next the
Designated Routerfield in the Hello Packet is examined. If the neighbor is both declaring itself to be Designated Router (Designated Routerfield = Neighbor IP address) and theBackup Designated Routerfield in the packet is equal to0.0.0.0and the receiving interface is in stateWaiting, the receiving interface's state machine is scheduled with the eventBackupSeen๐. Otherwise, if the neighbor is declaring itself to be Designated Router and it had not previously, or the neighbor is not declaring itself Designated Router where it had previously, the receiving interface's state machine is scheduled with the eventNeighborChange๐ฅ. In any case, the Neighbors' Designated Router item in the neighbor structure is updated accordingly. - Finally, the
Backup Designated Routerfield in the Hello Packet is examined. If the neighbor is declaring itself to be Backup Designated Router (Backup Designated Routerfield = Neighbor IP address) and the receiving interface is in stateWaiting, the receiving interface's state machine is scheduled with the eventBackupSeen๐. Otherwise, if the neighbor is declaring itself to be Backup Designated Router and it had not previously, or the neighbor is not declaring itself Backup Designated Router where it had previously, the receiving interface's state machine is scheduled with the eventNeighborChange๐. In any case, the Neighbor's Backup Designated Router item in the neighbor structure is updated accordingly.
On NBMA networks, receipt of a Hello Packet MAY also cause a Hello Packet to be sent back to the neighbor in response. See Section 9.5.1 for more details ๐ฆ.
10.6. Receiving Database Description Packets โจ
okay so this section is the deep dive on how a received Database Description Packet gets processed ๐ง. by the time it gets here, the generic input packet processing (Section 8.2) has already matched it up with a neighbor and a receiving interface ๐ . whether it gets accepted, and what happens next, totally depends on the neighbor state ๐ซถ
if a Database Description packet is accepted, save these fields in the corresponding neighbor data structure under "last received Database Description packet": the packet's initialize(I), more (M) and master(MS) bits, the Options field, and the DD sequence number ๐. if those fields are set identically in two consecutive Database Description packets from the neighbor, the second one counts as a "duplicate" in everything below ๐ฏ
if the Interface MTU field shows an IP datagram size that's bigger than what the router can accept on the receiving interface without fragmentation, the packet gets rejected ๐
. otherwise, here's what happens based on the neighbor state ๐
Down
The packet SHOULD be rejected. ๐ฅ
Attempt
The packet SHOULD be rejected. ๐ฅ
Init
The neighbor state machine SHOULD be executed with the event 2-WayReceived. this causes an immediate state change to either state 2-Way or state ExStart โก. if the new state is ExStart, the processing of the current packet SHOULD then continue in that new state by falling through to case ExStart below ๐ฆ
2-Way
The packet SHOULD be ignored. Database Description Packets are only used for bringing up adjacencies, so that's all they're for ๐[7]
ExStart
if the received packet matches one of the following cases, then the neighbor state machine SHOULD be executed with the event NegotiationDone (which moves the state to Exchange) โจ. the packet's Options field SHOULD be recorded in the neighbor structure's Neighbor Options field, and the packet SHOULD be accepted as next in sequence and processed further (see below). otherwise, the packet SHOULD be ignored ๐
- The
initialize(I),more (M)andmaster(MS)bits are set, the contents of the packet are empty, and the neighbor's Router ID is larger than the router's own. in this case the router is now Slave ๐. set the master/slave bit to slave, and set the neighbor data structure's DD sequence number to the one specified by the master. - The
initialize(I)andmaster(MS)bits are off, the packet's DD sequence number equals the neighbor data structure's DD sequence number (that's the acknowledgment ๐ค), and the neighbor's Router ID is smaller than the router's own. in this case the router is Master ๐.
Exchange
duplicate Database Description packets get discarded by the master, and they make the slave retransmit the last Database Description packet it sent ๐. otherwise (the packet is not a duplicate):
- if the state of the MS-bit doesn't match the master/slave state of the connection, generate the neighbor event
SeqNumberMismatchand stop processing the packet ๐. - if the
initialize(I)bit is set, generate the neighbor eventSeqNumberMismatchand stop processing the packet. - if the packet's
Optionsfield shows a different set of optional OSPF capabilities than were previously received from the neighbor (recorded in the Neighbor Options field of the neighbor structure), generate the neighbor eventSeqNumberMismatchand stop processing the packet. - Database Description packets MUST be processed in sequence, as shown by their DD sequence numbers ๐ข. if the router is master, the next packet received SHOULD have a DD sequence number equal to the one in the neighbor data structure. if the router is slave, the next packet received SHOULD have a DD sequence number equal to one more than the one stored in the neighbor data structure. either way, if the packet is next in sequence, it SHOULD be accepted and its contents processed as described below โ .
- anything else: generate the neighbor event
SeqNumberMismatchand stop processing the packet ๐ซ.
Loading or Full
in this state the router has sent and received an entire sequence of Database Description Packets, so it's basically done with the chat ๐. the only packets that should show up are duplicates (see above). in particular, the packet's Options field SHOULD match the set of optional OSPF capabilities the neighbor already indicated (stored in the neighbor structure's Neighbor Options field) ๐ง. any other packets received, including one with the Initialize(I) bit set, SHOULD generate the neighbor event SeqNumberMismatch.[8] duplicates SHOULD be discarded by the master, and the slave MUST respond to duplicates by repeating the last Database Description packet it sent ๐ซ .
when the router accepts a received Database Description Packet as the next in sequence, the packet contents get processed like this ๐. for each LSA listed, the LSA's LS type gets checked for validity. if the LS type is unknown (for example, not one of the LS types 1-5 defined by this specification), or if this is an AS-external-LSA (LS type = 5) and the neighbor is associated with a stub area, generate the neighbor event SeqNumberMismatch and stop processing the packet โ. otherwise, the router looks the LSA up in its database to see whether it also has an instance of that LSA ๐. if it doesn't, or if its database copy is less recent (see Section 13.1), the LSA goes on the Link state request list, so it can be requested (right away or later) in Link State Request Packets ๐.
when the router accepts a received Database Description Packet as the next in sequence, it also does the following, depending on whether it's master or slave ๐ซ:
Master
increments the DD sequence number in the neighbor data structure. if the router has already sent its entire sequence of Database Description Packets, and the packet that was just accepted has the more bit (M) set to 0, the neighbor event ExchangeDone gets generated ๐. otherwise, it SHOULD send a new Database Description to the slave.
Slave
sets the DD sequence number in the neighbor data structure to the DD sequence number in the received packet ๐. the slave MUST send a Database Description Packet in reply. if the received packet has the more bit (M) set to 0, and the packet the slave is about to send will also have the M-bit set to 0, the neighbor event ExchangeDone gets generated ๐. note that the slave always generates this event before the master ๐ฅ.
10.7. Receiving Link State Request Packets ๐
this section explains the detailed processing of received Link State Request packets ๐ฆ. these are basically the neighbor asking for a list of LSAs they want to receive ๐. Link State Request Packets SHOULD be accepted when the neighbor is in states Exchange, Loading, or Full. in all other states, Link State Request Packets SHOULD be ignored ๐.
each LSA named in the Link State Request packet SHOULD be found in the router's database and copied into Link State Update packets to send to the neighbor ๐ฌ. these LSAs SHOULD NOT be placed on the Link state retransmission list for the neighbor ๐ท. if an LSA can't be found in the database, something went wrong with the Database Exchange process, and the neighbor event BadLSReq SHOULD be generated ๐ฌ.
10.8. Sending Database Description Packets ๐ฐ
this section walks through how Database Description Packets get sent to a neighbor ๐ค. the Interface MTU field in the Database Description packet SHOULD be set to the size of the largest IP datagram that can go out the sending interface without fragmentation ๐. common MTUs in use across the Internet can be found in Table 7-1 of [Ref22]. Interface MTU SHOULD be set to 0 in Database Description packets sent over virtual links ๐.
the router's optional OSPF capabilities (see Section 4.5) get sent to the neighbor in the Options field of the Database Description packet ๐งฉ. the router SHOULD keep the same set of optional capabilities throughout the Database Exchange and flooding procedures ๐. if the router's optional capabilities somehow change, the Database Exchange procedure SHOULD be restarted by going back to neighbor state ExStart ๐. one optional capability is defined in this specification (see Sections 4.5 and A.2). the E-bit SHOULD be set if and only if the attached network belongs to a non-stub area ๐ฟ. unrecognized bits in the Options field SHOULD be set to zero 0๏ธโฃ.
how Database Description packets get sent depends on the neighbor's state ๐ซง. in state ExStart, the router sends empty Database Description packets with the initialize (I), more (M) and master (MS) bits set ๐ฑ. these packets get retransmitted every RxmtInterval seconds โฐ.
in state Exchange, the Database Description Packets actually contain summaries of the link state information in the router's database ๐. each LSA in the area's link-state database (at the moment the neighbor moves into Exchange state) gets listed in the neighbor Database summary list ๐๏ธ. each new Database Description Packet copies its DD sequence number from the neighbor data structure, then describes the current top of the Database summary list ๐. items get removed from the Database summary list once the previous packet is acknowledged โ๏ธ.
in state Exchange, when a Database Description packet gets sent depends on whether the router is master or slave ๐ญ:
Master
Database Description packets are sent when either a) the slave acknowledges the previous one by echoing the DD sequence number, or b) RxmtInterval seconds pass without an acknowledgment, in which case the previous Database Description packet gets retransmitted ๐.
Slave
Database Description packets are sent only in response to Database Description packets received from the master ๐ฃ๏ธ. if the Database Description packet from the master is new, a new Database Description packet gets sent. otherwise, the previous Database Description packet gets resent ๐.
in states Loading and Full, the slave MUST resend its last Database Description packet in response to duplicate Database Description packets received from the master ๐ฅน. for this reason the slave MUST wait RouterDeadInterval seconds before freeing the last Database Description packet โ. if a Database Description packet arrives from the master after this interval, it will generate a SeqNumberMismatch neighbor event ๐ฅ.
10.9. Sending Link State Request Packets โจ
okay so, in neighbor states Exchange or Loading, the Link state request list ๐ holds all the LSAs that a router still needs to grab from its neighbor. ๐ฆ To ask for them, the router sends the neighbor the beginning of that list, packed up in a Link State Request packet ๐
when the neighbor answers with the right Link State Update packet(s), the router chops off the part of the list that got answered and sends a fresh Link State Request packet โ๏ธ this keeps going until the Link state request list is totally empty ๐ and any Link State Request packets that haven't been answered get resent every RxmtInterval โฐ also, there should be at most one Link State Request packet outstanding at any one time, so no spamming your bestie with requests ๐
once the Link state request list is empty AND the neighbor state is Loading (aka a complete run of Database Description packets has been sent to and received from the neighbor), the router generates the Loading Done neighbor event ๐ฅณ that's the signal that the adjacency is basically caught up ๐
10.10. An Example ๐ธ
okay this is my favorite part, we're going to watch an adjacency form in real time ๐ง Figure 14 shows it happening. so we've got RT1 and RT2, both hanging out on the same broadcast network ๐ RT2 is the Designated Router for that network, and RT2 has a higher Router ID than RT1 ๐
the neighbor state changes each router goes through are listed on the sides of the figure, so keep your eyes peeled ๐
at the very start, RT1's interface to the network comes up โจ it starts blasting Hello Packets, even though it has no clue who the Designated Router is or who any of its other neighbors are ๐ RT2 hears that hello (so RT1 moves to Init state on RT2's side ๐ซถ), and then RT2's next Hello Packet says "hey, I'm the Designated Router, and I've heard your hellos" ๐ that pushes RT1 into ExStart as it starts bringing up the adjacency ๐ฅ
RT1 starts out by claiming it's the master ๐ค but when it sees that RT2 is actually the master (because RT2 has the higher Router ID), RT1 flips to slave state and adopts its neighbor's DD sequence number ๐ now Database Description packets get swapped, with the polls coming from the master (RT2) and the responses coming from the slave (RT1) ๐ this whole sequence wraps up when both the poll and its response have the M-bit off ๐
in this example, RT2 already has a completely up to date database ๐ so RT2 goes straight to Full state ๐ RT1 gets to Full too, once it updates the parts of its database it's missing ๐ฆ it does that by sending Link State Request Packets and getting Link State Update Packets back ๐ฌ
one tea โ RT1 waited until it had received a full set of Database Description Packets from RT2 before sending any Link State Request Packets, but that isn't required. RT1 could have mixed sending Link State Request Packets in with receiving Database Description Packets too ๐
+---+ +---+
|RT1| |RT2|
+---+ +---+
Down Down
Hello(DR=0,seen=0)
------------------------------>
Hello (DR=RT2,seen=RT1,...) Init
<------------------------------
ExStart D-D (Seq=x,I,M,Master)
------------------------------>
D-D (Seq=y,I,M,Master) ExStart
<------------------------------
Exchange D-D (Seq=y,M,Slave)
------------------------------>
D-D (Seq=y+1,M,Master) Exchange
<------------------------------
D-D (Seq=y+1,M,Slave)
------------------------------>
...
...
...
D-D (Seq=y+n, Master)
<------------------------------
D-D (Seq=y+n, Slave)
Loading ------------------------------>
LS Request Full
------------------------------>
LS Update
<------------------------------
LS Request
------------------------------>
LS Update
<------------------------------
Full
Figure 14: An adjacency bring-up example
11. The Routing Table Structure โจ
okay so the routing table is literally the brain of the router ๐ง โจ it holds everything needed to forward an IP data packet toward its destination ๐ฆ Each routing table entry describes the collection of best paths to one particular destination. When a packet shows up, the router hunts for the entry that gives the best match for the packet's IP destination, and that entry tells it the next hop toward the destination ๐
OSPF also has a default route (Destination ID = DefaultDestination, Address Mask = 0x00000000). When it exists, it matches every single IP destination (though any other matching entry is a better match, ngl ๐). Finding the entry that best matches an IP destination is explained more in Section 11.1 ๐
There is exactly one routing table in each router ๐ Two sample routing tables are described in Sections 11.2 and 11.3 ๐ and the building of the routing table is discussed in Section 16 ๐ง
The rest of this section defines the fields found in a routing table entry. The first set of fields describes the entry's destination ๐ธ
Destination Type
Destination type is either "network" or "router". Only network entries are actually used when forwarding IP data traffic. Router routing table entries are used solely as intermediate steps in the routing table build process ๐
A network is a range of IP addresses that IP data traffic may be forwarded to. This includes IP networks (class A, B, or C), IP subnets, IP supernets and single IP hosts. The default route also falls into this category โจ
Router entries are kept for area border routers and AS boundary routers. Routing table entries for area border routers are used when calculating the inter-area routes (see Section 16.2), and when maintaining configured virtual links (see Section 15). Routing table entries for AS boundary routers are used when calculating the AS external routes (see Section 16.4) ๐ฆ
Destination ID
The destination's identifier or name. This depends on the Destination Type. For networks, the identifier is their associated IP address. For routers, the identifier is the OSPF Router ID.[9] ๐
Address Mask
Only defined for networks. The network's IP address together with its address mask defines a range of IP addresses. For IP subnets, the address mask is referred to as the subnet mask. For host routes, the mask is "all ones" (0xffffffff) ๐
Optional Capabilities
When the destination is a router, this field indicates the optional OSPF capabilities supported by the destination router. The only optional capability defined by this specification is the ability to process AS-external-LSAs. For a further discussion of OSPF's optional capabilities, see Section 4.5 ๐ง
The set of paths to use for a destination may vary based on the OSPF area the paths belong to. This means there may be multiple routing table entries for the same destination, depending on the values of the next field ๐ธ
Area
This field indicates the area whose link state information has led to the routing table entry's collection of paths. This is called the entry's associated area. For sets of AS external paths, this field is not defined. For destinations of type "router", there may be separate sets of paths (and therefore separate routing table entries) associated with each of several areas. For example, this will happen when two area border routers share multiple areas in common. For destinations of type "network", only the set of paths associated with the best area (the one providing the preferred route) is kept ๐
The rest of the routing table entry describes the set of paths to the destination. The following fields pertain to the set of paths as a whole. In other words, each one of the paths contained in a routing table entry is of the same path-type and cost (see below) โจ
Path-type
There are four possible types of paths used to route traffic to the destination, listed here in order of preference: intra-area, inter-area, type 1 external or type 2 external. Intra-area paths indicate destinations belonging to one of the router's attached areas. Inter-area paths are paths to destinations in other OSPF areas. These are discovered through the examination of received summary-LSAs. AS external paths are paths to destinations external to the AS. These are detected through the examination of received AS-external-LSAs ๐
Cost
The link state cost of the path to the destination. For all paths except type 2 external paths, this describes the entire path's cost. For type 2 external paths, this field describes the cost of the portion of the path internal to the AS. This cost is calculated as the sum of the costs of the path's constituent links ๐ซถ
Type 2 cost
Only valid for type 2 external paths. For these paths, this field indicates the cost of the path's external portion. This cost has been advertised by an AS boundary router, and is the most significant part of the total path cost. For example, a type 2 external path with type 2 cost of 5 is always preferred over a path with type 2 cost of 10, regardless of the cost of the two paths' internal components ๐ญ๐ฅ
Link State Origin
Valid only for intra-area paths, this field indicates the LSA (router-LSA or network-LSA) that directly references the destination. For example, if the destination is a transit network, this is the transit network's network-LSA. If the destination is a stub network, this is the router-LSA for the attached router. The LSA is discovered during the shortest-path tree calculation (see Section 16.1). Multiple LSAs may reference the destination, however a tie-breaking scheme always reduces the choice to a single LSA. The Link State Origin field is not used by the OSPF protocol, but it is used by the routing table calculation in OSPF's Multicast routing extensions (MOSPF) ๐
When multiple paths of equal path-type and cost exist to a destination (called elsewhere "equal-cost" paths), they are stored in a single routing table entry. Each one of the "equal-cost" paths is distinguished by the following fields ๐
Next hop
The outgoing router interface to use when forwarding traffic to the destination. On broadcast, Point-to-MultiPoint and NBMA networks, the next hop also includes the IP address of the next router (if any) in the path towards the destination ๐ฆ
Advertising router
Valid only for inter-area and AS external paths. This field indicates the Router ID of the router advertising the summary-LSA or AS-external-LSA that led to this path ๐
11.1. Routing table lookup
When an IP data packet is received, an OSPF router finds the routing table entry that best matches the packet's destination. This routing table entry then provides the outgoing interface and next hop router to use in forwarding the packet. This section describes the process of finding the best matching routing table entry. The process consists of a number of steps, wherein the collection of routing table entries is progressively pruned. In the end, the single routing table entry remaining is called the "best match" ๐ฅ
Before the lookup begins, "discard" routing table entries should be inserted into the routing table for each of the router's active area address ranges (see Section 3.5). (An area range is considered "active" if the range contains one or more networks reachable by intra-area paths.) The destination of a "discard" entry is the set of addresses described by its associated active area address range, and the path type of each "discard" entry is set to "inter-area".[10] ๐
Note that the steps described below may fail to produce a best match routing table entry (i.e., all existing routing table entries are pruned for some reason or another), or the best match routing table entry may be one of the above "discard" routing table entries. In these cases, the packet's IP destination is considered unreachable. Instead of being forwarded, the packet should be discarded and an ICMP destination unreachable message should be returned to the packet's source ๐ญ
(1) Select the complete set of "matching" routing table entries from the routing table. Each routing table entry describes a (set of) path(s) to a range of IP addresses. If the data packet's IP destination falls into an entry's range of IP addresses, the routing table entry is called a match. (It is quite likely that multiple entries will match the data packet. For example, a default route will match all packets.) ๐ง
(2) Reduce the set of matching entries to those having the most preferential path-type (see Section 11). OSPF has a four level hierarchy of paths. Intra-area paths are the most preferred, followed in order by inter-area, type 1 external and type 2 external paths ๐
(3) Select the remaining routing table entry that provides the most specific (longest) match. Another way of saying this is to choose the remaining entry that specifies the narrowest range of IP addresses.[11] For example, the entry for the address/mask pair of (128.185.1.0, 0xffffff00) is more specific than an entry for the pair (128.185.0.0, 0xffff0000). The default route is the least specific match, since it matches all destinations ๐ธ
11.2. Sample routing table, without areas
Consider the Autonomous System pictured in Figure 2. No OSPF areas have been configured. A single metric is shown per outbound interface. The calculation of Router RT6's routing table proceeds as described in Section 2.2. The resulting routing table is shown in Table 12. Destination types are abbreviated: Network as "N", Router as "R" โจ
There are no instances of multiple equal-cost shortest paths in this example. Also, since there are no areas, there are no inter-area paths ๐ซถ
Routers RT5 and RT7 are AS boundary routers. Intra-area routes have been calculated to Routers RT5 and RT7. This allows external routes to be calculated to the destinations advertised by RT5 and RT7 (i.e., Networks N12, N13, N14 and N15). It is assumed all AS-external-LSAs originated by RT5 and RT7 are advertising type 1 external metrics. This results in type 1 external paths being calculated to destinations N12-N15 ๐ฆ
11.3. Sample routing table, with areas ๐บ๏ธ
okay so bestie, let's take that last example and split it up into OSPF areas ๐ An OSPF area configuration is pictured in Figure 6. We're gonna look at Router RT4's routing table for this setup. RT4 is connected to Area 1 and the backbone, so it sees the AS as the combo of the two graphs in Figures 7 and 8. The result is in Table 13 โจ
Type Dest Area Path Type Cost Next Adv.
Hop(s) Router(s)
____________________________________________________________
N N1 0 intra-area 10 RT3 *
N N2 0 intra-area 10 RT3 *
N N3 0 intra-area 7 RT3 *
N N4 0 intra-area 8 RT3 *
N Ib 0 intra-area 7 * *
N Ia 0 intra-area 12 RT10 *
N N6 0 intra-area 8 RT10 *
N N7 0 intra-area 12 RT10 *
N N8 0 intra-area 10 RT10 *
N N9 0 intra-area 11 RT10 *
N N10 0 intra-area 13 RT10 *
N N11 0 intra-area 14 RT10 *
N H1 0 intra-area 21 RT10 *
R RT5 0 intra-area 6 RT5 *
R RT7 0 intra-area 8 RT10 *
____________________________________________________________
N N12 * type 1 ext. 10 RT10 RT7
N N13 * type 1 ext. 14 RT5 RT5
N N14 * type 1 ext. 14 RT5 RT5
N N15 * type 1 ext. 17 RT10 RT7
Table 12: The routing table for Router RT6
(no configured areas).
Okay, so RT5 and RT7 are both AS boundary routers ๐ซถ RT3, RT4, RT7, RT10 and RT11 are area border routers ๐ฆ RT3 gets two routing entries because it shares two areas with RT4 (Area 1 and the backbone). Iconic, honestly.
Backbone paths are calculated to every area border router, and those paths get used when figuring out the inter-area routes. All the inter-area routes are tied to the backbone. That's always the case when the calculating router is itself an area border router, so no surprises there ๐ธ Routing info also gets condensed at area boundaries. In this example, Area 3 is set up so that N9-N11 and the host route to H1 all get squished into one route when RT11 advertises them into the backbone. The cost of that condensed route is the maximum of the costs of its individual components. Main character cost calculation, ngl ๐
There's a virtual link between RT10 and RT11 ๐ง Without that configured virtual link, RT11 couldn't advertise a route for N9-N11 and Host H1 into the backbone, and RT4's routing table would have no entry for those networks at all ๐
There are two equal-cost paths to Network N12, but they both go through the same next hop, which is RT5. Simple and clean ๐
Type Dest Area Path Type Cost Next Adv.
Hops(s) Router(s)
__________________________________________________________________
N N1 1 intra-area 4 RT1 *
N N2 1 intra-area 4 RT2 *
N N3 1 intra-area 1 * *
N N4 1 intra-area 3 RT3 *
R RT3 1 intra-area 1 * *
__________________________________________________________________
N Ib 0 intra-area 22 RT5 *
N Ia 0 intra-area 27 RT5 *
R RT3 0 intra-area 21 RT5 *
R RT5 0 intra-area 8 * *
R RT7 0 intra-area 14 RT5 *
R RT10 0 intra-area 22 RT5 *
R RT11 0 intra-area 25 RT5 *
__________________________________________________________________
N N6 0 inter-area 15 RT5 RT7
N N7 0 inter-area 19 RT5 RT7
N N8 0 inter-area 18 RT5 RT7
N N9-N11,H1 0 inter-area 36 RT5 RT11
__________________________________________________________________
N N12 * type 1 ext. 16 RT5 RT5,RT7
N N13 * type 1 ext. 16 RT5 RT5
N N14 * type 1 ext. 16 RT5 RT5
N N15 * type 1 ext. 23 RT5 RT7
Table 13: Router RT4's routing table
in the presence of areas.
Now here's the glow-up ๐ RT4's routing table would get better (some paths would get shorter) if you added another virtual link between RT4 and RT3. That new virtual link would be tied to the first RT3 entry in Table 13, which is the intra-area path through Area 1. That gives the virtual link a cost of 1 โจ The changes to the routing table from adding this link are in Table 14.
Type Dest Area Path Type Cost Next Adv.
Hop(s) Router(s)
________________________________________________________________
N Ib 0 intra-area 16 RT3 *
N Ia 0 intra-area 21 RT3 *
R RT3 0 intra-area 1 * *
R RT10 0 intra-area 16 RT3 *
R RT11 0 intra-area 19 RT3 *
________________________________________________________________
N N9-N11,H1 0 inter-area 30 RT3 RT11
Table 14: Changes resulting from an
additional virtual link.
12. Link State Advertisements (LSAs) ๐
Every router in the Autonomous System originates one or more link state advertisements (LSAs) ๐ซถ This memo defines five distinct types of LSAs, which we'll get into in Section 4.3. All of them together form the link-state database. Each type has its own job, though ๐ Router-LSAs and network-LSAs describe how an area's routers and networks are connected. Summary-LSAs are the way to condense an area's routing info. AS-external-LSAs are how you transparently advertise externally-derived routing info across the whole Autonomous System. Serving organization, honestly ๐
Each LSA starts with a standard 20-byte header. We'll break that header down below ๐
12.1. The LSA Header ๐ธ
The LSA header has the LS type, Link State ID and Advertising Router fields. Put those three together and you get a unique ID for the LSA ๐ฆ
There can be several instances of the same LSA in the Autonomous System all at once. When that happens, somebody has to figure out which instance is more recent. That's decided by checking the LS sequence, LS checksum and LS age fields, which also live in that 20-byte header ๐ฅ
Lots of OSPF packet types list LSAs. When which instance it is doesn't matter, you just refer to the LSA by its LS type, Link State ID and Advertising Router (check out Link State Request Packets). Otherwise, you also need the LS sequence number, LS age and LS checksum fields ๐ง
Here's a detailed rundown of the fields in the LSA header, coming right up ๐
12.1.1. LS age โณ
This field is the age of the LSA in seconds. It should be processed as an unsigned 16-bit integer. It's set to 0 when the LSA is originated. It must be incremented by InfTransDelay on every hop of the flooding procedure. LSAs also age while they're sitting in each router's database ๐
The age of an LSA never goes past MaxAge. LSAs with age MaxAge are not used in the routing table calculation. When an LSA's age first hits MaxAge, it gets reflooded. An LSA at MaxAge is finally flushed from the database once it's no longer needed to keep databases in sync. For more on how LSAs age, go check Section 14 ๐
The LS age field gets checked when a router receives two instances of an LSA that have identical LS sequence numbers and LS checksums. An instance with age MaxAge is always accepted as the most recent, which lets old LSAs get flushed out of the routing domain quickly ๐งน Otherwise, if the ages differ by more than MaxAgeDiff, the instance with the smaller age is accepted as most recent.[12] See Section 13.1 for the full details ๐
12.1.2. Options ๐๏ธ
The Options field in the LSA header shows which optional capabilities are associated with the LSA. OSPF's optional capabilities are described in Section 4.5. This specification defines one optional capability, represented by the E-bit in the Options field. Any unrecognized bits in the Options field should be set to zero. The E-bit represents OSPF's ExternalRoutingCapability. This bit should be set in all LSAs associated with the backbone, and in all LSAs associated with non-stub areas (see Section 3.6). It should also be set in all AS-external-LSAs. It should be reset in all router-LSAs, network-LSAs and summary-LSAs associated with a stub area. For all LSAs, the E-bit is for informational purposes only; it doesn't affect the routing table calculation ๐ซง
12.1.3. LS type ๐ท๏ธ
The LS type field decides the format and function of the LSA. LSAs of different types have different names, like router-LSAs or network-LSAs ๐ Every LSA type defined by this memo gets flooded throughout a single area only, except for AS-external-LSAs (LS type = 5). Those get flooded throughout the entire Autonomous System, excluding stub areas (see Section 3.6) ๐ Each separate LSA type is briefly described below in Table 15 โจ
12.1.4. Link State ID ๐
okay so this field tells you which piece of the routing domain the LSA is describing ๐ what goes in it depends on the LSA's LS type, and Table 16 has the full tea ๐ซ
ok wait, plot twist ๐ for Type 3 summary-LSAs (LS type = 3) and AS-external-LSAs (LS type = 5), the Link State ID can also have one or more of the destination network's "host" bits set. for example, if you're originating an AS-external-LSA for the network 10.0.0.0 with mask 255.0.0.0, the Link State ID can be anything from 10.0.0.0 through 10.255.255.255 inclusive (but 10.0.0.0 should be used whenever possible ๐ ). this freedom is what lets a router originate separate LSAs for two networks that have the same address but different masks ๐ฆ see Appendix E for the details.
LS Type LSA description
________________________________________________
1 These are the router-LSAs.
They describe the collected
states of the router's
interfaces. For more information,
consult Section 12.4.1.
________________________________________________
2 These are the network-LSAs.
They describe the set of routers
attached to the network. For
more information, consult
Section 12.4.2.
________________________________________________
3 or 4 These are the summary-LSAs.
They describe inter-area routes,
and enable the condensation of
routing information at area
borders. Originated by area border
routers, the Type 3 summary-LSAs
describe routes to networks while the
Type 4 summary-LSAs describe routes to
AS boundary routers.
________________________________________________
5 These are the AS-external-LSAs.
Originated by AS boundary routers,
they describe routes
to destinations external to the
Autonomous System. A default route for
the Autonomous System can also be
described by an AS-external-LSA.
Table 15: OSPF link state advertisements (LSAs).
LS Type Link State ID
_______________________________________________
1 The originating router's Router ID.
2 The IP interface address of the
network's Designated Router.
3 The destination network's IP address.
4 The Router ID of the described AS
boundary router.
5 The destination network's IP address.
Table 16: The LSA's Link State ID.
when the LSA is describing a network (LS type = 2, 3 or 5), you can easily get the network's IP address by masking the Link State ID with the network/subnet mask in the body of the LSA ๐ง when the LSA is describing a router (LS type = 1 or 4), the Link State ID is always the described router's OSPF Router ID ๐ค
when an AS-external-LSA (LS Type = 5) is describing a default route, its Link State ID is set to DefaultDestination (0.0.0.0) ๐
12.1.5. Advertising Router ๐ฎ
this field has the OSPF Router ID of whoever originated the LSA ๐ for router-LSAs, it's identical to the Link State ID field. network-LSAs get originated by the network's Designated Router, summary-LSAs get originated by area border routers, and AS-external-LSAs get originated by AS boundary routers ๐ซถ
12.1.6. LS sequence number ๐ข
ok this one is so good ๐ญ the sequence number field is a signed 32-bit integer, and it's how routers figure out which LSAs are old and which are duplicates ๐ต๏ธโโ๏ธ the space of sequence numbers is linearly ordered, so the bigger the number (compared as signed 32-bit integers), the more recent the LSA. to get precise, in the discussion below let N stand for the constant 2**31 ๐งฎ
the sequence number -N (0x80000000) is reserved and unused ๐ซ that leaves -N + 1 (0x80000001) as the smallest, and therefore oldest, sequence number. this one is called the constant InitialSequenceNumber ๐ผ a router uses InitialSequenceNumber the first time it originates any LSA. after that, the LSA's sequence number goes up by one each time the router originates a new instance of it โจ
now the spicy part ๐ถ๏ธ when someone tries to increment the sequence number past the maximum value of N - 1 (0x7fffffff, also called MaxSequenceNumber), the current instance of the LSA has to be flushed from the routing domain first ๐ this happens by prematurely aging the LSA (see Section 14.1) and reflooding it. once every adjacent neighbor has acknowledged that flood, a new instance can be originated with the sequence number InitialSequenceNumber ๐
a router may be forced to bump the sequence number of one of its LSAs when a more recent instance of that LSA shows up unexpectedly during flooding. this should be a rare event ๐ it may mean that an out-of-date LSA, originated by the router itself before its last restart/reload, is still floating around the Autonomous System ๐ป for more info, see Section 13.4.
12.1.7. LS checksum ๐งฎ
this field is the checksum of the complete contents of the LSA, except the LS age field ๐ the LS age is left out so an LSA's age can keep ticking up without the checksum needing an update. the checksum is the same one used for ISO connectionless datagrams, commonly called the Fletcher checksum, and it's documented in Annex B of [Ref6] ๐ the LSA header also has the LSA's length in bytes. subtract the size of the LS age field (two bytes) and you get the amount of data to checksum ๐
the checksum is there to catch data corruption in an LSA, which can happen while the LSA is being flooded or while it's sitting in a router's memory ๐ก๏ธ the LS checksum field can't be zero, and a zero value should be considered a checksum failure. basically, calculating the checksum is not optional ๐ซก
an LSA's checksum gets verified in two situations: a) when it's received in a Link State Update Packet, and b) at times during the aging of the link state database. a checksum failure leads to different actions in each case, so check out Sections 13 and 14 for the details ๐
whenever the LS sequence number field says two instances of an LSA are the same, the LS checksum field gets examined. if they differ, the instance with the larger LS checksum is considered the most recent ๐[13] see Section 13.1 for more details.
12.2. The link state database ๐๏ธ
a router has a separate link state database for every area it belongs to, and all routers in the same area have identical link state databases for that area ๐ฏ
each area's database is always dealt with separately โ๏ธ the shortest path calculation is run separately for each area (see Section 16), components of an area's link-state database only get flooded throughout that area, and when an adjacency (belonging to Area A) is being brought up, only the Area A database gets synchronized between the two routers ๐
the area database is made up of router-LSAs, network-LSAs and summary-LSAs (all listed in the area data structure). external routes (AS-external-LSAs) are also included in all non-stub area databases (see Section 3.6) ๐
an OSPF implementation must be able to access individual pieces of an area database ๐ this lookup function is based on an LSA's LS type, Link State ID and Advertising Router.[14] there's only a single instance of each LSA in the database (the most up-to-date one) โจ the lookup function gets invoked during the LSA flooding procedure (Section 13) and the routing table calculation (Section 16). using this lookup function, a router can also figure out whether it has ever originated a particular LSA and, if so, what LS sequence number it used ๐ต๏ธโโ๏ธ
an LSA gets added to a router's database when either a) it's received during flooding (Section 13) or b) the router originates it itself (Section 12.4). an LSA gets deleted from a router's database when either a) it's been overwritten by a newer instance during flooding (Section 13), b) the router originates a newer instance of one of its self-originated LSAs (Section 12.4), or c) the LSA ages out and gets flushed from the routing domain (Section 14) ๐๏ธ
whenever an LSA is deleted from the database, it must also be removed from all neighbors' Link state retransmission lists (see Section 10) ๐งน
12.3. Representation of TOS ๐
for backward compatibility with older versions of the OSPF specification ([Ref9]), TOS-specific info can be included in router-LSAs, summary-LSAs and AS-external-LSAs ๐งธ the way TOS gets encoded in OSPF LSAs is laid out in Table 17. that table connects the OSPF encoding to the TOS field in the IP packet header (defined in [Ref12]) ๐ธ the OSPF encoding is written as a decimal integer, while the IP packet header's TOS field uses the binary TOS values from [Ref12] ๐ข
OSPF encoding RFC 1349 TOS values
___________________________________________
0 0000 normal service
2 0001 minimize monetary cost
4 0010 maximize reliability
6 0011
8 0100 maximize throughput
10 0101
12 0110
14 0111
16 1000 minimize delay
18 1001
20 1010
22 1011
24 1100
26 1101
28 1110
30 1111
Table 17: Representing TOS in OSPF.
12.4. Originating LSAs โจ
okay so bestie, every OSPF area is gonna have a bunch of LSAs getting originated ๐ Each router originates a router-LSA. And if the router is the Designated Router for any of the area's networks, it also originates network-LSAs for those networks ๐ฆ
Area border routers originate a single summary-LSA for each known inter-area destination. AS boundary routers originate a single AS-external-LSA for each known AS external destination. Destinations get advertised one at a time, so when one route changes, only that route gets flooded and not the whole collection of routes ๐ซถ During flooding, lots of LSAs can ride along in a single Link State Update packet ๐ฆ
Okay, example time! Look at Router RT4 in Figure 6. It's an area border router with a connection to Area 1 and the backbone ๐ RT4 originates 5 distinct LSAs into the backbone (one router-LSA, plus one summary-LSA for each of the networks N1-N4). RT4 also originates 8 distinct LSAs into Area 1 (one router-LSA and seven summary-LSAs, as pictured in Figure 7). And if RT4 has been selected as Designated Router for Network N3, it will also originate a network-LSA for N3 into Area 1 ๐
Now, Router RT5 in that same figure is originating 3 distinct AS-external-LSAs (one for each of the networks N12-N14) ๐ง These get flooded through the entire AS, assuming none of the areas have been configured as stubs. But if area 3 has been configured as a stub area, the AS-external-LSAs for N12-N14 will not be flooded into area 3 (see Section 3.6). Instead, Router RT11 would originate a default summary-LSA that gets flooded throughout area 3 (see Section 12.4.3). This basically tells all of area 3's internal routers to send their AS external traffic to RT11 ๐
Whenever a new instance of an LSA gets originated, itsLS sequence numberis incremented, itsLS ageis set to 0, itsLS checksumis calculated, and the LSA is added to the link state database and flooded out the appropriate interfaces. See Section 13.2 for the details on installing the LSA into the link state database, and Section 13.3 for the details on flooding newly originated LSAs ๐ฅ
Okay, now the ten events that can cause a new instance of an LSA to be originated ๐
(1) The LS age field of one of the router's self-originated LSAs reaches the value LSRefreshTime. In this case, a new instance of the LSA is originated, even though the contents of the LSA (apart from the LSA header) will be the same. This guarantees periodic originations of all LSAs, and this periodic updating adds robustness to the link state algorithm ๐ LSAs that solely describe unreachable destinations should not be refreshed. They should instead be flushed from the routing domain (see Section 14.1) ๐
When whatever is being described by an LSA changes, a new LSA gets originated. However, two instances of the same LSA may not be originated within the time period MinLSInterval, so the generation of the next instance may get delayed by up to MinLSInterval ๐ The following events may cause the contents of an LSA to change. These events should cause new originations if and only if the contents of the new LSA would be different โจ
(2) An interface's state changes (see Section 9.1). This may mean it's necessary to produce a new instance of the router-LSA ๐
(3) An attached network's Designated Router changes. A new router-LSA should be originated. Also, if the router itself is now the Designated Router, a new network-LSA should be produced. If the router itself is no longer the Designated Router, any network-LSA it might have originated for the network should be flushed from the routing domain (see Section 14.1) ๐ธ
(4) One of the neighboring routers changes to or from the FULL state. This may mean it's necessary to produce a new instance of the router-LSA. Also, if the router is itself the Designated Router for the attached network, a new network-LSA should be produced ๐ฆ
The next four events concern area border routers only ๐ซถ
(5) An intra-area route has been added, deleted, or modified in the routing table. This may cause a new instance of a summary-LSA (for this route) to be originated in each attached area (possibly including the backbone) ๐
(6) An inter-area route has been added, deleted, or modified in the routing table. This may cause a new instance of a summary-LSA (for this route) to be originated in each attached area (but NEVER for the backbone) ๐ซ
(7) The router becomes newly attached to an area. The router must then originate summary-LSAs into the newly attached area for all pertinent intra-area and inter-area routes in the router's routing table. See Section 12.4.3 for more details ๐ง
(8) When the state of one of the router's configured virtual links changes, it may be necessary to originate a new router-LSA into the virtual link's Transit area (see the discussion of the router-LSA's bit V in Section 12.4.1), as well as originating a new router-LSA into the backbone ๐
The last two events concern AS boundary routers (and former AS boundary routers) only ๐
(9) An external route gained through direct experience with an external routing protocol (like BGP) changes. This will cause an AS boundary router to originate a new instance of an AS-external-LSA ๐ฅ
(10) A router ceases to be an AS boundary router, perhaps after restarting. In this situation, the router should flush all AS-external-LSAs that it had previously originated. These LSAs can be flushed via the premature aging procedure specified in Section 14.1 ๐ฅฒ
The construction of each type of LSA is explained in detail below. In general, these sections describe the contents of the LSA body (i.e., the part coming after the 20-byte LSA header). For info on building the LSA header, see Section 12.1 ๐
12.4.1. Router-LSAs โจ
okay so a router makes a router-LSA for every area it belongs to ๐ Each one describes the router's collected states of its links to that area. It gets flooded throughout that particular area, and no further ๐ The format lives in Appendix A (Section A.4.2), and the first 20 bytes are the generic LSA header we covered in Section 12.1. Router-LSAs have LS type = 1 ๐ฆ
A router also flags whether it's an area border router or an AS boundary router by setting the right bits ๐
....................................
. 192.1.2 Area 1 .
. + .
. | .
. | 3+---+1 .
. N1 |--|RT1|-----+ .
. | +---+ \ .
. | \ _______N3 .
. + \/ \ . 1+---+
. * 192.1.1 *------|RT4|
. + /\_______/ . +---+
. | / | .
. | 3+---+1 / | .
. N2 |--|RT2|-----+ 1| .
. | +---+ +---+8 . 6+---+
. | |RT3|----------------|RT6|
. + +---+ . +---+
. 192.1.3 |2 . 18.10.0.6|7
. | . |
. +------------+ .
. 192.1.4 (N4) .
....................................
Figure 15: Area 1 with IP addresses shown
(bit B and bit E, respectively) in its router-LSAs. This lets paths to those types of routers get saved in the routing table, for later processing of summary-LSAs and AS-external-LSAs ๐ธ Bit B should be set whenever the router is actively attached to two or more areas, even if the router isn't currently attached to the OSPF backbone area. Bit E should never be set in a router-LSA for a stub area, because stub areas can't contain AS boundary routers ๐ โโ๏ธ
Also, the router sets bit V in its router-LSA for Area A if and only if it's the endpoint of one or more fully adjacent virtual links that have Area A as their Transit area. Bit V is how other routers in Area A figure out whether the area supports transit traffic (see TransitCapability in Section 6) ๐ง
The router-LSA then describes the router's working connections (interfaces or links) to the area. Each link is typed by the kind of attached network, and each one gets a Link ID that names the entity on the other end ๐ Table 18 has the rundown of Type and Link ID values:
Link type Description Link ID
__________________________________________________
1 Point-to-point Neighbor Router ID
link
2 Link to transit Interface address of
network Designated Router
3 Link to stub IP network number
network
4 Virtual link Neighbor Router ID
Table 18: Link descriptions in the
router-LSA.
Every link also gets a Link Data field, which holds 32 bits of extra info ๐ For links to transit networks, numbered point-to-point links, and virtual links, it holds the IP interface address of the associated router interface (the routing table calculation needs this, see Section 16.1.1). For links to stub networks, it holds the stub network's IP address mask. For unnumbered point-to-point links, the Link Data field should be set to the unnumbered interface's MIB-II [Ref8] ifIndex value.
Last but not least, the cost of using the link for output gets specified ๐ The output cost of a link is configurable. Except for links to stub networks, the output cost must always be non-zero.
Okay, so how do you actually build the list of link descriptions? Say a router wants to build a router-LSA for Area A ๐ฅ It checks its collection of interface data structures, and for each interface:
- If the attached network doesn't belong to Area A, no links get added to the LSA, and you move on to the next interface.
- If the state of the interface is Down, no links are added.
- If the state of the interface is Loopback, add a Type 3 link (stub network) as long as it isn't an interface to an unnumbered point-to-point network. The Link ID should be set to the IP interface address, the Link Data set to the mask 0xffffffff (indicating a host route), and the cost set to 0.
- Otherwise, the link descriptions added to the router-LSA depend on the OSPF interface type. Link descriptions for point-to-point interfaces are in Section 12.4.1.1, for virtual links in Section 12.4.1.2, for broadcast and NBMA interfaces in 12.4.1.3, and for Point-to-MultiPoint interfaces in 12.4.1.4.
After all the router interfaces are considered, host links get added to the router-LSA by looking through the list of attached hosts that belong to Area A ๐ A host route is represented as a Type 3 link (stub network) whose Link ID is the host's IP address, whose Link Data is the all-ones mask (0xffffffff), and whose cost is the host's configured cost (see Section C.7).
12.4.1.1. Describing point-to-point interfaces
For point-to-point interfaces, one or more link descriptions get added to the router-LSA like this ๐
- If the neighboring router is fully adjacent, add a Type 1 link (point-to-point). The Link ID should be set to the Router ID of the neighboring router. For numbered point-to-point networks, the Link Data should specify the IP interface address. For unnumbered point-to-point networks, the Link Data field should specify the interface's MIB-II [Ref8] ifIndex value. The cost should be set to the output cost of the point-to-point interface.
- In addition, as long as the state of the interface is "Point-to-Point" (and regardless of the neighboring router state), a Type 3 link (stub network) should be added. This stub link can take one of two forms ๐ฆ
Option 1 Assuming the neighboring router's IP address is known, set the Link ID of the Type 3 link to the neighbor's IP address, the Link Data to the mask 0xffffffff (indicating a host route), and the cost to the interface's configured output cost.[15]
Option 2 If a subnet has been assigned to the point-to-point link, set the Link ID of the Type 3 link to the subnet's IP address, the Link Data to the subnet's mask, and the cost to the interface's configured output cost.[16]
12.4.1.2. Describing broadcast and NBMA interfaces
For operational broadcast and NBMA interfaces, a single link description gets added to the router-LSA like so ๐ซถ
- If the state of the interface is Waiting, add a Type 3 link (stub network) with Link ID set to the IP network number of the attached network, Link Data set to the attached network's address mask, and cost equal to the interface's configured output cost.
- Otherwise, there's a Designated Router elected for the attached network. If the router is fully adjacent to the Designated Router, or if the router itself is the Designated Router and is fully adjacent to at least one other router, add a single Type 2 link (transit network) with Link ID set to the IP interface address of the attached network's Designated Router (which may be the router itself), Link Data set to the router's own IP interface address, and cost equal to the interface's configured output cost. Otherwise, add a link as if the interface state were Waiting (see above) ๐ญ
12.4.1.3. Describing virtual links
For virtual links, a link description only gets added to the router-LSA when the virtual neighbor is fully adjacent โจ In that case, add a Type 4 link (virtual link) with Link ID set to the Router ID of the virtual neighbor, Link Data set to the IP interface address associated with the virtual link, and cost set to the cost calculated for the virtual link during the routing table calculation (see Section 15) ๐
12.4.1.4. Describing Point-to-MultiPoint interfaces
For operational Point-to-MultiPoint interfaces, one or more link descriptions get added to the router-LSA as follows ๐ธ
- A single Type 3 link (stub network) is added with Link ID set to the router's own IP interface address, Link Data set to the mask 0xffffffff (indicating a host route), and cost set to 0.
- For each fully adjacent neighbor associated with the interface, add an additional Type 1 link (point-to-point) with Link ID set to the Router ID of the neighboring router, Link Data set to the IP interface address, and cost equal to the interface's configured output cost. ๐
12.4.1.5. Examples of router-LSAs โจ
Okay bestie, let's look at the router-LSAs that RT3 makes ๐ Check out Figure 6 first, then peek at Area 1 with real network addresses in Figure 15. Pretend the last byte of every RT3 interface is 3, so it has 192.1.1.3 and 192.1.4.3, and the other routers have similar addressing vibes ๐ We're also assuming every link works, and Router IDs are the smallest IP interface address.
RT3 makes two router-LSAs, one for Area 1 and one for the backbone. Let's say Router RT4 got picked as the Designated Router for network 192.1.1.0. RT3's Area 1 router-LSA says RT3 has two connections into Area 1: a link to the transit network 192.1.1.0, and a link to the stub network 192.1.4.0. The transit network is named by its Designated Router's IP interface, so the Link ID = 192.1.1.4 is RT4's interface to 192.1.1.0 ๐ฆ RT3 also flags itself as an area border router, which is so iconic of it ๐
; RT3's router-LSA for Area 1
LS age = 0 ;always true on origination
Options = (E-bit) ;
LS type = 1 ;indicates router-LSA
Link State ID = 192.1.1.3 ;RT3's Router ID
Advertising Router = 192.1.1.3 ;RT3's Router ID
bit E = 0 ;not an AS boundary router
bit B = 1 ;area border router
#links = 2
Link ID = 192.1.1.4 ;IP address of Desig. Rtr.
Link Data = 192.1.1.3 ;RT3's IP interface to net
Type = 2 ;connects to transit network
# TOS metrics = 0
metric = 1
Link ID = 192.1.4.0 ;IP Network number
Link Data = 0xffffff00 ;Network mask
Type = 3 ;connects to stub network
# TOS metrics = 0
metric = 2
Next up is RT3's backbone router-LSA ๐ RT3 only has one attachment to the backbone, and that's an unnumbered point-to-point link to Router RT6. Once again, RT3 marks itself as an area border router ๐ธ
; RT3's router-LSA for the backbone
LS age = 0 ;always true on origination
Options = (E-bit) ;
LS type = 1 ;indicates router-LSA
Link State ID = 192.1.1.3 ;RT3's router ID
Advertising Router = 192.1.1.3 ;RT3's router ID
bit E = 0 ;not an AS boundary router
bit B = 1 ;area border router
#links = 1
Link ID = 18.10.0.6 ;Neighbor's Router ID
Link Data = 0.0.0.3 ;MIB-II ifIndex of P-P link
Type = 1 ;connects to router
# TOS metrics = 0
metric = 8
12.4.2. Network-LSAs ๐ง
A network-LSA gets generated for every transit broadcast or NBMA network. (Quick reminder: a transit network is one with two or more attached routers.) The network-LSA describes every router attached to that network, so it's basically the guest list ๐
The Designated Router for the network is the one that originates the LSA. It only does that if it's fully adjacent to at least one other router on the network. The network-LSA gets flooded throughout the area containing the transit network, and not any further ๐ It lists the routers that are fully adjacent to the Designated Router, with each one identified by its OSPF Router ID. The Designated Router puts itself on that list too ๐
The Link State ID for a network-LSA is the IP interface address of the Designated Router. Mask that value with the network's address mask (which also lives in the network-LSA) and you get the network's IP address ๐ฅ
Now here's some drama ๐ A router that used to be the Designated Router for a network, but isn't anymore, should flush the network-LSA it originated before. That LSA doesn't get used in the routing table calculation anymore. To flush it, you prematurely bump the LSA's age to MaxAge and reflood (see Section 14.1). There's another case too: if a router's Router ID has changed, any network-LSAs that were originated with the old Router ID must be flushed. The router might have no idea what its previous Router ID was, so these network-LSAs are spotted by having their Link State ID equal one of the router's IP interface addresses, and their Advertising Router equal some value other than the router's current Router ID (see Section 13.4 for more details) ๐ฆ
12.4.2.1. Examples of network-LSAs โญ
Let's look at the Figure 6 area setup again ๐ Network-LSAs are originated for Network N3 in Area 1, Networks N6 and N8 in Area 2, and Network N9 in Area 3. Say Router RT4 was picked as the Designated Router for Network N3. Then RT4 generates this network-LSA on behalf of Network N3 (check Figure 15 for the address assignments):
; Network-LSA for Network N3
LS age = 0 ;always true on origination
Options = (E-bit) ;
LS type = 2 ;indicates network-LSA
Link State ID = 192.1.1.4 ;IP address of Desig. Rtr.
Advertising Router = 192.1.1.4 ;RT4's Router ID
Network Mask = 0xffffff00
Attached Router = 192.1.1.4 ;Router ID
Attached Router = 192.1.1.1 ;Router ID
Attached Router = 192.1.1.2 ;Router ID
Attached Router = 192.1.1.3 ;Router ID
12.4.3. Summary-LSAs ๐
A summary-LSA describes one of three things: an IP network, an AS boundary router, or a range of IP addresses. These get flooded throughout a single area only. The destination it describes sits outside that area but still belongs to the Autonomous System ๐
Area border routers are the ones that originate summary-LSAs. Which summary routes get advertised into an area comes from looking at the routing table structure (see Section 11), following the algorithm below. Heads up: only intra-area routes get advertised into the backbone, while both intra-area and inter-area routes get advertised into the other areas ๐ซถ
To decide which routes go out to an attached Area A, process each routing table entry like this. Remember that each routing table entry describes a set of equal-cost best paths to one particular destination:
- Only Destination Types of network and AS boundary router are advertised in summary-LSAs. If the routing table entry's Destination Type is area border router, skip to the next routing table entry ๐ โโ๏ธ
- AS external routes are never advertised in summary-LSAs. If the routing table entry has Path-type of type 1 external or type 2 external, skip to the next routing table entry.
- Else, if the area associated with this set of paths is Area A itself, don't generate a summary-LSA for the route.[17]
- Else, if the next hops associated with this set of paths belong to Area A itself, don't generate a summary-LSA for the route.[18] This is the logical equivalent of a Distance Vector protocol's split horizon logic ๐
- Else, if the routing table cost equals or exceeds the value LSInfinity, a summary-LSA cannot be generated for this route.
- Else, if the destination of this route is an AS boundary router, a summary-LSA should be originated if and only if the routing table entry describes the preferred path to the AS boundary router (see Step 3 of Section 16.4). If so, a Type 4 summary-LSA is originated for the destination, with Link State ID equal to the AS boundary router's Router ID and metric equal to the routing table entry's cost. Note: these LSAs should not be generated if Area A has been configured as a stub area ๐
- Else, the Destination type is network. If this is an inter-area route, generate a Type 3 summary-LSA for the destination, with Link State ID equal to the network's address (if necessary, the Link State ID can also have one or more of the network's host bits set; see Appendix E for details) and metric equal to the routing table cost ๐ฏ
- The one remaining case is an intra-area route to a network. That means the network sits inside one of the router's directly attached areas. Generally, this info has to be condensed before it shows up in summary-LSAs. Remember that an area has a configured list of address ranges, where each range is an [address,mask] pair with a status of either Advertise or DoNotAdvertise. At most a single Type 3 summary-LSA is originated for each range. When the range's status is Advertise, a Type 3 summary-LSA is generated with Link State ID equal to the range's address (if necessary, the Link State ID can also have one or more of the range's "host" bits set; see Appendix E for details) and cost equal to the largest cost of any of the component networks. When the range's status is DoNotAdvertise, the Type 3 summary-LSA gets suppressed and the component networks stay hidden from other areas ๐
By default, if a network isn't inside any explicitly configured address range, a Type 3 summary-LSA is generated with Link State ID equal to the network's address (if necessary, the Link State ID can also have one or more of the network's "host" bits set; see Appendix E for details) and metric equal to the network's routing table cost ๐
If an area can carry transit traffic (meaning its TransitCapability is set to TRUE), routing info about backbone networks should not be condensed before being summarized into the area. The advertisement of backbone networks into transit areas shouldn't get suppressed either. Put simply, the backbone's configured ranges should be ignored when originating summary-LSAs into transit areas ๐
If a router advertised a summary-LSA for a destination that then becomes unreachable, the router must flush that LSA from the routing domain by setting its age to MaxAge and reflooding (see Section 14.1). Also, if the destination is still reachable but can no longer be advertised under the procedure above (for example, it's now an inter-area route when it used to be an intra-area route tied to some non-backbone area, so it would no longer be advertisable to the backbone), the LSA should also be flushed from the routing domain ๐งน
12.4.3.1. Originating summary-LSAs into stub areas โจ
okay so the algorithm in Section 12.4.3 is optional ๐ when Area A is an OSPF stub area. Area border routers hooked up to a stub area can originate summary-LSAs into it using the Section 12.4.3 algorithm, OR they can choose to originate only a subset of them, maybe because of configuration control ๐. Fewer LSAs means a smaller link state database for the stub area, which takes some pressure off its routers' resources โจ. BUT omitting LSAs might lead to sub-optimal inter-area routing, although routing will still work ๐.
As specified in Section 12.4.3, Type 4 summary-LSAs (ASBR-summary-LSAs) are never originated into stub areas ๐ซ. That's a hard no, bestie ๐.
In a stub area, the area border routers don't import external routes. Instead, each one originates a "default summary-LSA" into the area ๐ง. The Link State ID for that default summary-LSA is set to DefaultDestination, and its metric is set to the per-area configurable parameter StubDefaultCost ๐. Also, StubDefaultCost doesn't have to be configured the same way on every area border router in the stub area, so don't panic if they differ ๐.
12.4.3.2. Examples of summary-LSAs ๐ฆ
Consider again the area configuration in Figure 6 ๐บ๏ธ. Routers RT3, RT4, RT7, RT10 and RT11 are all area border routers, so they're originating summary-LSAs. Let's focus on Router RT4 ๐ฅ. Its routing table was calculated in the example in Section 11.3. RT4 originates summary-LSAs into both the backbone and Area 1 โจ.
Into the backbone, Router RT4 originates separate LSAs for each of the networks N1-N4 ๐. Into Area 1, Router RT4 originates separate LSAs for networks N6-N8 and the AS boundary routers RT5,RT7 ๐ซถ. It also condenses host routes Ia and Ib into a single summary-LSA ๐ฆ. Finally, the routes to networks N9,N10,N11 and Host H1 are advertised by a single summary-LSA ๐. That condensation was originally done by Router RT11, so credit where it's due ๐.
These LSAs are illustrated graphically in Figures 7 and 8 ๐ฆ. Two of the summary-LSAs originated by Router RT4 are shown below. The actual IP addresses for the networks and routers in question were assigned in Figure 15 ๐.
; Summary-LSA for Network N1,
; originated by Router RT4 into the backbone
LS age = 0 ;always true on origination
Options = (E-bit) ;
LS type = 3 ;Type 3 summary-LSA
Link State ID = 192.1.2.0 ;N1's IP network number
Advertising Router = 192.1.1.4 ;RT4's ID
metric = 4
; Summary-LSA for AS boundary router RT7
; originated by Router RT4 into Area 1
LS age = 0 ;always true on origination
Options = (E-bit) ;
LS type = 4 ;Type 4 summary-LSA
Link State ID = Router RT7's ID
Advertising Router = 192.1.1.4 ;RT4's ID
metric = 14
12.4.4. AS-external-LSAs ๐
AS-external-LSAs describe routes to destinations outside the Autonomous System ๐. Most of them describe routes to specific external destinations. In those cases, the LSA's Link State ID is set to the destination network's IP address ๐ฌ. If needed, the Link State ID can also have one or more of the network's "host" bits set, and Appendix E has the details ๐ง. A default route for the whole Autonomous System can be described in an AS-external-LSA too, by setting the Link State ID to DefaultDestination (0.0.0.0) ๐ธ. AS-external-LSAs get originated by AS boundary routers ๐ช. An AS boundary router originates a single AS-external-LSA for each external route it has learned, whether that came from another routing protocol (like BGP) or from configuration information โ๏ธ.
AS-external-LSAs are the only type of LSA that gets flooded throughout the entire Autonomous System ๐. Every other type of LSA is specific to a single area. AS-external-LSAs are not flooded into or throughout stub areas (see Section 3.6) ๐ โโ๏ธ. That's what keeps the link state database smaller for routers inside stub areas ๐.
The metric advertised for an external route can be one of two types ๐. Type 1 metrics are comparable to the link state metric. Type 2 metrics are assumed to be larger than the cost of any intra-AS path ๐ .
If a router advertises an AS-external-LSA for a destination that then becomes unreachable, the router must then flush that LSA from the routing domain. It does this by setting the LSA's age to MaxAge and reflooding it (see Section 14.1) ๐งน.
12.4.4.1. Examples of AS-external-LSAs ๐
Consider once again the AS pictured in Figure 6 ๐ผ๏ธ. There are two AS boundary routers: RT5 and RT7. Router RT5 originates three AS-external-LSAs, for networks N12-N14. Router RT7 originates two AS-external-LSAs, for networks N12 and N15. Let's say RT7 learned its route to N12 via BGP, and it wants to advertise a Type 2 metric to the AS ๐ฃ. RT7 would then originate the following LSA for N12 ๐:
; AS-external-LSA for Network N12,
; originated by Router RT7
LS age = 0 ;always true on origination
Options = (E-bit) ;
LS type = 5 ;AS-external-LSA
Link State ID = N12's IP network number
Advertising Router = Router RT7's ID
bit E = 1 ;Type 2 metric
metric = 2
Forwarding address = 0.0.0.0
In that example, the forwarding address field is set to 0.0.0.0. That tells everyone to forward packets for the external destination to the advertising OSPF router (RT7) ๐ฎ. But that's not always the move ๐. Check out the example pictured in Figure 16 ๐. There are three OSPF routers (RTA, RTB and RTC) connected to a common network. Only one of them, RTA, is exchanging BGP information with the non-OSPF router RTX ๐ค. So RTA must then originate AS-external-LSAs for the destinations it learned from RTX. By using the AS-external-LSA's forwarding address field, RTA can say that packets for those destinations should be forwarded directly to RTX ๐ฏ. Without this feature, Routers RTB and RTC would take an extra hop to reach those destinations ๐ฉ.
When the forwarding address field is non-zero, it should point to a router that belongs to another Autonomous System ๐.
A forwarding address can also be set for the default route ๐ฃ๏ธ. For example, in Figure 16, RTA may want to say that all externally-destined packets should, by default, be forwarded to its BGP peer RTX ๐ซก. The resulting AS-external-LSA is shown below. Notice that the Link State ID is set to DefaultDestination โจ.
; Default route, originated by Router RTA
; Packets forwarded through RTX
LS age = 0 ;always true on origination
Options = (E-bit) ;
LS type = 5 ;AS-external-LSA
Link State ID = DefaultDestination ; default route
Advertising Router = Router RTA's ID
bit E = 1 ;Type 2 metric
metric = 1
Forwarding address = RTX's IP address
Now, in Figure 16, suppose both RTA and RTB exchange BGP information with RTX instead ๐ฏ. In that case, RTA and RTB would originate the same set of AS-external-LSAs. If those LSAs specify the same metric, they're functionally equivalent, since they name the same destination and forwarding address (RTX) ๐. That's a clear duplication of effort ๐ญ. If only one of RTA or RTB originated the set, the routing would stay the same and the link state database would shrink ๐. BUT it has to be unambiguously defined which router originates the LSAs. Otherwise neither might, or the identity of the originator could oscillate ๐. So here's the rule ๐: if two routers, both reachable from one another, originate functionally equivalent AS-external-LSAs (i.e., same destination, cost and non-zero forwarding address), then the LSA originated by the router with the highest OSPF Router ID is used โ . The router with the lower OSPF Router ID can then flush its LSA. Flushing an LSA is discussed in Section 14.1 ๐งน๐.
13. The Flooding Procedure โจ
Okay bestie, flooding is where LSAs actually get passed around ๐ Link State Update packets do the delivering ๐. One packet can carry several distinct LSAs, and each one gets pushed one hop further from where it started. Iconic. To make this reliable, each LSA must be acknowledged separately ๐ซถ Those acks ride in Link State Acknowledgment packets, and a bunch of separate acks can get bundled into one packet. Efficient, no cap.
The whole flooding procedure kicks off once a Link State Update packet has been received ๐ Before it gets handed over, it has already gone through a ton of consistency checks (see Section 8.2). Most importantly, the packet has been tied to a particular neighbor and a particular area. Also, if the neighbor is in a lesser state than Exchange, the packet should be dropped without further processing. Bye bye ๐
Here's a little picture of a forwarding address situation, because it's giving diagram energy ๐ฆ
+
|
+---+.....|.BGP
|RTA|-----|.....+---+
+---+ |-----|RTX|
| +---+
+---+ |
|RTB|-----|
+---+ |
|
+---+ |
|RTC|-----|
+---+ |
|
+
Figure 16: Forwarding address example ๐ธ
Now the tea. All types of LSAs, except AS-external-LSAs, are tied to a specific area. BUT LSAs don't have an area field ๐ So the area has to be figured out from the Link State Update packet header instead. Detective vibes ๐ต๏ธโโ๏ธ
For each LSA inside a Link State Update packet, these steps happen, in this order:
(1) Validate the LSA's LS checksum. If the checksum turns out to be invalid, discard the LSA and get the next one from the Link State Update packet. Bad checksum? Not today, sis ๐
(2) Examine the LSA's LS type. If the LS type is unknown, discard the LSA and get the next one from the Link State Update Packet. This specification defines LS types 1-5 (see Section 4.3). So anything outside 1 through 5 is a no-go ๐ โโ๏ธ
(3) Else if this is an AS-external-LSA (LS type = 5), and the area has been configured as a stub area, discard the LSA and get the next one from the Link State Update Packet. AS-external-LSAs are not flooded into/throughout stub areas (see Section 3.6). Stub areas are not for these, periodt ๐
(4) Else if the LSA's LS age is equal to MaxAge, and there is currently no instance of the LSA in the router's link state database, then take the following actions:
- (a) Acknowledge the receipt of the LSA by sending a Link State Acknowledgment packet back to the sending neighbor (see Section 13.5).
- (b) Purge all outstanding requests for equal or previous instances of the LSA from the sending neighbor's Link State Request list (see Section 10).
- (c) If the sending neighbor is in state Exchange or in state Loading, then install the MaxAge LSA in the link state database. Otherwise, simply discard the LSA. In either case, examine the next LSA (if any) listed in the Link State Update packet. Dramatic exit, but make it make sense ๐ญ
(5) Otherwise, find the instance of this LSA that is currently contained in the router's link state database. If there is no database copy, or the received LSA is more recent than the database copy (see Section 13.1 below for the determination of which LSA is more recent) the following steps must be performed:
- (a) If there is already a database copy, and if the database copy was installed less than MinLSArrival seconds ago, discard the new LSA (without acknowledging it) and examine the next LSA (if any) listed in the Link State Update packet.
- (b) Otherwise immediately flood the new LSA out some subset of the router's interfaces (see Section 13.3). In some cases (e.g., the state of the receiving interface is DR and the LSA was received from a router other than the Backup DR) the LSA will be flooded back out the receiving interface. This occurrence should be noted for later use by the acknowledgment process (Section 13.5). Boomerang energy ๐ช
- (c) Remove the current database copy from all neighbors' Link state retransmission lists.
- (d) Install the new LSA in the link state database (replacing the current database copy). This may cause the routing table calculation to be scheduled. In addition, timestamp the new LSA with the current time (i.e., the time it was received). The flooding procedure cannot overwrite the newly installed LSA until MinLSArrival seconds have elapsed. The LSA installation process is discussed further in Section 13.2. Timestamps, obsessed ๐ง
- (e) Possibly acknowledge the receipt of the LSA by sending a Link State Acknowledgment packet back out the receiving interface. This is explained below in Section 13.5.
- (f) If this new LSA indicates that it was originated by the receiving router itself (i.e., is considered a self-originated LSA), the router must take special action, either updating the LSA or in some cases flushing it from the routing domain. For a description of how self-originated LSAs are detected and subsequently handled, see Section 13.4. Main character energy, the router literally has to deal with its own stuff ๐
(6) Else, if there is an instance of the LSA on the sending neighbor's Link state request list, an error has occurred in the Database Exchange process. In this case, restart the Database Exchange process by generating the neighbor event BadLSReq for the sending neighbor and stop processing the Link State Update packet. Oops, we gotta restart the whole Database Exchange ๐ฌ
(7) Else, if the received LSA is the same instance as the database copy (i.e., neither one is more recent) the following two steps should be performed:
- (a) If the LSA is listed in the Link state retransmission list for the receiving adjacency, the router itself is expecting an acknowledgment for this LSA. The router should treat the received LSA as an acknowledgment by removing the LSA from the Link state retransmission list. This is termed an "implied acknowledgment". Its occurrence should be noted for later use by the acknowledgment process (Section 13.5). Ngl, this is so clever ๐ง โจ
- (b) Possibly acknowledge the receipt of the LSA by sending a Link State Acknowledgment packet back out the receiving interface. This is explained below in Section 13.5.
(8) Else, the database copy is more recent. If the database copy has LS age equal to MaxAge and LS sequence number equal to MaxSequenceNumber, simply discard the received LSA without acknowledging it. (In this case, the LSA's LS sequence number is wrapping, and the MaxSequenceNumber LSA must be completely flushed before any new LSA instance can be introduced). Otherwise, send the database copy back to the sending neighbor, encapsulated within a Link State Update Packet. The Link State Update Packet should be unicast to the neighbor. In so doing, do not put the database copy of the LSA on the neighbor's link state retransmission list, and do not acknowledge the received (less recent) LSA instance. Sequence number wrap-around is a whole mood ๐
13.1. Determining which LSA is newer
When a router encounters two instances of an LSA, it must determine which is more recent. This occurred above when comparing a received LSA to its database copy. This comparison must also be done during the Database Exchange procedure which occurs during adjacency bring-up.
An LSA is identified by its LS type, Link State ID and Advertising Router. For two instances of the same LSA, the LS sequence number, LS age, and LS checksum fields are used to determine which instance is more recent:
- The LSA having the newer LS sequence number is more recent. See Section 12.1.6 for an explanation of the LS sequence number space. If both instances have the same LS sequence number, then:
- If the two instances have different LS checksums, then the instance having the larger LS checksum (when considered as a 16-bit unsigned integer) is considered more recent.
- Else, if only one of the instances has its LS age field set to MaxAge, the instance of age MaxAge is considered to be more recent.
- Else, if the LS age fields of the two instances differ by more than MaxAgeDiff, the instance having the smaller (younger) LS age is considered to be more recent.
- Else, the two instances are considered to be identical.
Basically, sequence number first, then checksum, then age. It's a whole ladder ๐ช๐
13.2. Installing LSAs in the database
Installing a new LSA in the database, either as the result of flooding or a newly self-originated LSA, may cause the OSPF routing table structure to be recalculated. The contents of the new LSA should be compared to the old instance, if present. If there is no difference, there is no need to recalculate the routing table. When comparing an LSA to its previous instance, the following are all considered to be differences in contents:
- The LSA's Options field has changed.
- One of the LSA instances has LS age set to MaxAge, and the other does not.
- The length field in the LSA header has changed.
- The body of the LSA (i.e., anything outside the 20-byte LSA header) has changed. Note that this excludes changes in LS Sequence Number and LS Checksum.
If the contents are different, the following pieces of the routing table must be recalculated, depending on the new LSA's LS type field:
Router-LSAs and network-LSAs The entire routing table must be recalculated, starting with the shortest path calculations for each area (not just the area whose link-state database has changed). The reason that the shortest path calculation cannot be restricted to the single changed area has to do with the fact that AS boundary routers may belong to multiple areas. A change in the area currently providing the best route may force the router to use an intra-area route provided by a different area.[19] Whole routing table, full reset ๐
Summary-LSAs The best route to the destination described by the summary-LSA must be recalculated (see Section 16.5). If this destination is an AS boundary router, it may also be necessary to re-examine all the AS-external-LSAs.
AS-external-LSAs The best route to the destination described by the AS-external-LSA must be recalculated (see Section 16.6).
Also, any old instance of the LSA must be removed from the database when the new LSA is installed. This old instance must also be removed from all neighbors' Link state retransmission lists (see Section 10). Clean up crew, every time ๐งนโจ
13.3. Next step in the flooding procedure โจ
okay bestie, when a new (and more recent) LSA has been received, it must be flooded out some set of the router's interfaces ๐ฆ. This is the second half of the flooding procedure (the first half is what happened in Section 13 ๐ ), and it's all about picking the outgoing interfaces and adding the LSA to the neighbors' Link state retransmission lists. Maintaining the neighbors' Link state request lists is also part of this step ๐ซถ.
This section is equally applicable to the flooding of an LSA that the router itself has just originated (see Section 12.4) ๐.
For these LSAs, this section gives you the entire flooding procedure. The processing of Section 13 is not performed ๐, since the LSA hasn't been received from a neighbor and therefore doesn't need to be acknowledged.
Depending on the LSA's LS type, the LSA can only be flooded out certain interfaces. These are called the eligible interfaces ๐:
AS-external-LSAs (LS Type = 5): AS-external-LSAs are flooded throughout the entire AS, with the exception of stub areas (see Section 3.6) ๐ธ. The eligible interfaces are all the router's interfaces, excluding virtual links and those interfaces attaching to stub areas.
All other LS types: All other types are specific to a single area (Area A) ๐. The eligible interfaces are all those interfaces attaching to the Area A. If Area A is the backbone, this includes all the virtual links.
Link state databases must remain synchronized over all adjacencies associated with the above eligible interfaces ๐. This is accomplished by executing the following steps on each eligible interface. It should be noted that this procedure may decide not to flood an LSA out a particular interface, if there is a high probability that the attached neighbors have already received the LSA. However, in these cases the flooding procedure must be absolutely sure that the neighbors eventually do receive the LSA, so the LSA is still added to each adjacency's Link state retransmission list. For each eligible interface:
(1) Each of the neighbors attached to this interface are examined, to determine whether they must receive the new LSA. The following steps are executed for each neighbor:
- (a) If the neighbor is in a lesser state than
Exchange, it does not participate in flooding, and the next neighbor should be examined. - (b) Else, if the adjacency is not yet full (neighbor state is
ExchangeorLoading), examine the Link state request list associated with this adjacency. If there is an instance of the new LSA on the list, it indicates that the neighboring router has an instance of the LSA already. Compare the new LSA to the neighbor's copy:- If the new LSA is less recent, then examine the next neighbor.
- If the two copies are the same instance, then delete the LSA from the Link state request list, and examine the next neighbor.[20]
- Else, the new LSA is more recent. Delete the LSA from the Link state request list.
- (c) If the new LSA was received from this neighbor, examine the next neighbor.
- (d) At this point we are not positive that the neighbor has an up-to-date instance of this new LSA. Add the new LSA to the Link state retransmission list for the adjacency. This ensures that the flooding procedure is reliable; the LSA will be retransmitted at intervals until an acknowledgment is seen from the neighbor.
(2) The router must now decide whether to flood the new LSA out this interface. If in the previous step, the LSA was NOT added to any of the Link state retransmission lists, there is no need to flood the LSA out the interface and the next interface should be examined. ๐ โโ๏ธ
(3) If the new LSA was received on this interface, and it was received from either the Designated Router or the Backup Designated Router, chances are that all the neighbors have received the LSA already. Therefore, examine the next interface.
(4) If the new LSA was received on this interface, and the interface state is Backup (i.e., the router itself is the Backup Designated Router), examine the next interface. The Designated Router will do the flooding on this interface. However, if the Designated Router fails the router (i.e., the Backup Designated Router) will end up retransmitting the updates.
(5) If this step is reached, the LSA must be flooded out the interface. Send a Link State Update packet (including the new LSA as contents) out the interface. The LSA's LS age must be incremented by InfTransDelay (which must be > 0) when it is copied into the outgoing Link State Update packet (until the LS age field reaches the maximum value of MaxAge).
On broadcast networks, the Link State Update packets are multicast. The destination IP address specified for the Link State Update Packet depends on the state of the interface. If the interface state is DR or Backup, the address AllSPFRouters should be used. Otherwise, the address AllDRouters should be used.
On non-broadcast networks, separate Link State Update packets must be sent, as unicasts, to each adjacent neighbor (i.e., those in state Exchange or greater). The destination IP addresses for these packets are the neighbors' IP addresses.
13.4. Receiving self-originated LSAs
It is a common occurrence for a router to receive self-originated LSAs via the flooding procedure. A self-originated LSA is detected when either 1) the LSA's Advertising Router is equal to the router's own Router ID or 2) the LSA is a network-LSA and its Link State ID is equal to one of the router's own IP interface addresses. ๐ช
However, if the received self-originated LSA is newer than the last instance that the router actually originated, the router must take special action. โ ๏ธ The reception of such an LSA indicates that there are LSAs in the routing domain that were originated by the router before the last time it was restarted. In most cases, the router must then advance the LSA's LS sequence number one past the received LS sequence number, and originate a new instance of the LSA.
It may be the case the router no longer wishes to originate the received LSA. Possible examples include: 1) the LSA is a summary-LSA or AS-external-LSA and the router no longer has an (advertisable) route to the destination, 2) the LSA is a network-LSA but the router is no longer Designated Router for the network or 3) the LSA is a network-LSA whose Link State ID is one of the router's own IP interface addresses but whose Advertising Router is not equal to the router's own Router ID (this latter case should be rare, and it indicates that the router's Router ID has changed since originating the LSA). In all these cases, instead of updating the LSA, the LSA should be flushed from the routing domain by incrementing the received LSA's LS age to MaxAge and reflooding (see Section 14.1) ๐.
13.5. Sending Link State Acknowledgment packets โจ
Okay bestie, every newly received LSA must be acknowledged ๐ Usually that happens by sending Link State Acknowledgment packets. But acks can also happen implicitly by sending Link State Update packets (see step 7a of Section 13) ๐ฆ so no extra packet is needed, iconic!
Lots of acknowledgments can get bundled into one Link State Acknowledgment packet ๐ฆ That packet goes back out the same interface the LSAs came in on. There are two ways to send it: delayed, on an interval timer, or direct, as a unicast straight to one neighbor. Which one you use depends on the situation around receiving the LSA ๐ธ
Delayed acks are giving three main vibes ๐ 1) they let you pack multiple acks into one Link State Acknowledgment packet, 2) one packet can ack several neighbors at once (by multicasting), and 3) they randomize when the various routers on a shared network send their Link State Acknowledgment packets ๐ The fixed gap between a router's delayed transmissions must be short (less than RxmtInterval) or you'll get needless retransmissions, and nobody wants that ๐
Direct acks go to one particular neighbor when they send you duplicate LSAs ๐ They're unicast, and they go out right away when the duplicate shows up โก
Here's the exact procedure, Table 19 ๐ The circumstances for receiving the LSA are in the left column, and the ack action goes in one of the two right columns. The action depends on the state of the interface, and interfaces in state Backup act differently from interfaces in every other state ๐ Delayed acks must reach all adjacent routers linked to the interface. On broadcast networks, that means sending the delayed Link State Acknowledgment packets as multicasts ๐ฃ The destination IP address depends on the interface state: if it's DR or Backup, the destination is AllSPFRouters. In all other states, the destination is AllDRouters. On non-broadcast networks, delayed Link State Acknowledgment packets must be unicast separately over each adjacency (i.e., each neighbor whose state is >= Exchange) ๐ซถ
Action taken in state
Circumstances Backup All other states
_______________________________________________________________
LSA has No acknowledgment No acknowledgment
been flooded back sent. sent.
out receiving in-
terface (see Sec-
tion 13, step 5b).
_______________________________________________________________
LSA is Delayed acknowledg- Delayed ack-
more recent than ment sent if adver- nowledgment sent.
database copy, but tisement received
was not flooded from Designated
back out receiving Router, otherwise
interface do nothing
_______________________________________________________________
LSA is a Delayed acknowledg- No acknowledgment
duplicate, and was ment sent if adver- sent.
treated as an im- tisement received
plied acknowledg- from Designated
ment (see Section Router, otherwise
13, step 7a). do nothing
_______________________________________________________________
LSA is a Direct acknowledg- Direct acknowledg-
duplicate, and was ment sent. ment sent.
not treated as an
implied ack-
nowledgment.
_______________________________________________________________
LSA's LS Direct acknowledg- Direct acknowledg-
age is equal to ment sent. ment sent.
MaxAge, and there is
no current instance
of the LSA
in the link state
database (see
Section 13, step 4).
Table 19: Sending link state acknowledgments.
Why are these multicasts? Let's check the example ๐ง Look at the network in Figure 15. Say RT4 got elected as Designated Router and RT3 as Backup Designated Router for network N3. When RT4 floods a new LSA onto N3, RT1, RT2, and RT3 all receive it ๐ These routers won't flood the LSA back onto net N3, but they still need their link-state databases to stay synced with their adjacent neighbors ๐ค So RT1, RT2, and RT4 are all waiting to see an ack from RT3. And RT4 and RT3 are both waiting to see acks from RT1 and RT2. The way to handle that is to send the acks as multicasts ๐
Backup DRs get slightly different ack logic, and the reason is that they behave differently while LSAs are flooding (see Section 13.3, step 4) ๐
13.6. Retransmitting LSAs ๐
LSAs flooded out an adjacency go onto that adjacency's Link state retransmission list โจ To make flooding reliable, those LSAs keep getting retransmitted until they're acknowledged ๐ช The time between retransmissions is a configurable per-interface value called RxmtInterval. If it's set too low for an interface, you'll get needless retransmissions ๐ฉ If it's set too high, flooding speed can suffer when packets get lost ๐ข
Several retransmitted LSAs can fit in one Link State Update packet ๐ฆ When LSAs need retransmitting, only the number that fits in a single Link State Update packet should be sent. Another packet of retransmissions can go out whenever some of the LSAs get acknowledged, or on the next firing of the retransmission timer โฐ
Link State Update packets carrying retransmissions are always sent as unicasts (directly to the neighbor's physical address) ๐ They are never sent as multicasts ๐ โโ๏ธ Each LSA's LS age must be incremented by InfTransDelay (which must be > 0) when it's copied into the outgoing Link State Update packet, until the LS age field hits the maximum value of MaxAge โณ
If an adjacent router goes down, retransmissions might keep happening until OSPF's Hello Protocol destroys the adjacency ๐ Once the adjacency is destroyed, the Link state retransmission list gets cleared ๐งน
13.7. Receiving link state acknowledgments ๐ฌ
Before a received Link State Acknowledgment packet even reaches the flooding procedure, it gets a bunch of consistency checks ๐ต๏ธโโ๏ธ Most importantly, it's been tied to a particular neighbor. If that neighbor is in a state lower than Exchange, the Link State Acknowledgment packet gets tossed ๐๏ธ
Otherwise, for each acknowledgment in the packet, these steps happen:
- Does the LSA acknowledged have an instance on the Link state retransmission list for the neighbor? If not, examine the next acknowledgment. Otherwise:
- If the acknowledgment is for the same instance that is contained on the list, remove the item from the list and examine the next acknowledgment. Otherwise:
- Log the questionable acknowledgment, and examine the next one.
14. Aging The Link State Database ๐ฐ๏ธ
Every LSA has an LS age field, measured in seconds โฑ๏ธ An LSA's LS age field goes up while the LSA sits in a router's database. And when it's copied into a Link State Update Packet for flooding out a particular interface, its LS age goes up by InfTransDelay too ๐
An LSA's LS age never goes past MaxAge ๐ LSAs with age MaxAge don't get used in the routing table calculation ๐ โโ๏ธ As a router ages its link state database, an LSA's LS age might reach MaxAge.[21] At that point, the router must try to flush the LSA from the routing domain ๐งน It does this by reflooding the MaxAge LSA just like it would a newly originated LSA (see Section 13.3) ๐ฅ
When a newly forming adjacency builds its Database summary list, any MaxAge LSAs in the link state database get added to the neighbor's Link state retransmission list instead of its Database summary list ๐ See Section 10.3 for more details.
A MaxAge LSA must be removed from the router's link state database immediately once both a) it's no longer on any neighbor Link state retransmission list and b) none of the router's neighbors are in states Exchange or Loading โจ
When the router is aging its link state database and an LSA's LS age hits a multiple of CheckAge, its LS checksum should be verified ๐ If the LS checksum is wrong, a program or memory error has been detected, and at the very least the router itself should be restarted ๐ฑ
Yikes, a bad checksum is a big deal. Restart the router, bestie ๐จ
14.1. Premature aging of LSAs ๐
An LSA can get flushed from the routing domain by setting its LS age to MaxAge and reflooding it ๐ This follows the same course as flushing an LSA whose LS age naturally reached MaxAge (see Section 14). Specifically, the MaxAge LSA is removed from the router's link state database as soon as a) it's no longer on any neighbor Link state retransmission list and b) none of the router's neighbors are in states Exchange or Loading ๐ซ We call setting an LSA's LS age to MaxAge "premature aging" ๐ฆ
Premature aging is used when a self-originated LSA's sequence number field is about to wrap ๐ At that point, the current LSA instance (with LS sequence number MaxSequenceNumber) must be prematurely aged and flushed from the routing domain before a new instance with sequence number equal to InitialSequenceNumber can be originated. See Section 12.1.6 for more info ๐
Premature aging can also be used when, say, one of the router's previously advertised external routes is no longer reachable ๐ฃ๏ธ In that case, the router can flush its AS-external-LSA from the routing domain via premature aging. This is preferable to the alternative, which is originating a new LSA for the destination with a metric of LSInfinity ๐ Premature aging is also be used when unexpectedly receiving self-originated LSAs during the flooding procedure (see Section 13.4) ๐ณ
A router may only prematurely age its own self-originated LSAs ๐ The router may not prematurely age LSAs originated by other routers ๐ซ An LSA counts as self-originated when either 1) the LSA's Advertising Router equals the router's own Router ID or 2) the LSA is a network-LSA and its Link State ID equals one of the router's own IP interface addresses ๐ซถ
15. Virtual Links โจ
okay so the single backbone area (0.0.0.0, the Area ID) can NEVER get disconnected ๐ญ bc then some areas of the whole Autonomous System would become unreachable and that's a total disaster ๐. to keep the backbone connected, you can set up virtual links through non-backbone areas ๐ฆ. they basically stitch together backbone pieces that are physically separated, and the two endpoints are both area border routers. the virtual link has to be configured on both routers. each router needs to know two things: the other virtual endpoint (the other area border router), and the non-backbone area the two routers share, which is called the Transit area ๐ง. and virtual links can't be configured through stub areas (see Section 3.6), so don't even try ๐
โโ๏ธ
the virtual link gets treated as if it were an unnumbered point-to-point network that belongs to the backbone and connects the two area border routers ๐. the router tries to bring up an adjacency over it. once that adjacency is up, the virtual link shows up in the backbone router-LSAs, and OSPF packets for the backbone area flow over the adjacency ๐. this kind of adjacency is what this document calls a "virtual adjacency" โจ
in each endpoint router, the cost and viability of the virtual link come from looking at the routing table entry for the other endpoint router ๐. (that entry's associated area has to be the configured Transit area.) this is called the virtual link's corresponding routing table entry ๐ธ. the InterfaceUp event fires for a virtual link when its corresponding routing table entry becomes reachable, and the InterfaceDown event fires when that entry becomes unreachable ๐ฅ. so basically, the virtual link is only viable if there's an intra-area path between the two endpoints, going through the Transit area ๐. also, a virtual link whose underlying path has a cost greater than 0xffff (the maximum size of an interface cost in a router-LSA) should be considered inoperational, which means it gets treated the same as if the path didn't exist at all ๐
here's the rest of the virtual link tea:
- AS-external-LSAs are NEVER flooded over virtual adjacencies ๐. that would just be duplicated work, since the same AS-external-LSAs are already flooded all over the virtual link's Transit area. for the same reason, AS-external-LSAs don't get summarized over virtual adjacencies during the Database Exchange process ๐ซถ
- the cost of a virtual link is NOT configured ๐ โโ๏ธ. it's defined to be the cost of the intra-area path between the two defining area border routers, and that cost shows up in the virtual link's corresponding routing table entry ๐ . when the virtual link's cost changes, a new router-LSA should be originated for the backbone area ๐
- the IP interface address for the virtual interface and the virtual neighbor's IP address are also figured out through the routing table build process, the same way the cost and viability are ๐ง . they're used when sending OSPF protocol packets over the virtual link ๐ฆ. heads up though: if one (or both) of the endpoints connects to the Transit area through an unnumbered point-to-point link, it might be impossible to calculate either the virtual interface's IP address or the virtual neighbor's IP address, and then the virtual link fails ๐ญ
- in each endpoint's backbone router-LSA, the virtual link is represented as a Type 4 link. the Link ID is set to the virtual neighbor's OSPF Router ID, and the Link Data is set to the virtual interface's IP address ๐. see Section 12.4.1 for more info โจ
- a non-backbone area can carry transit data traffic (in other words, it counts as a "transit area") if and only if it serves as the Transit area for one or more fully adjacent virtual links ๐ฆ. see TransitCapability in Sections 6 and 16.1 for that. a transit area needs special treatment when backbone networks get summarized into it (see Section 12.4.3), and also during the routing calculation (see Section 16.3) ๐
- the time between link state retransmissions,
RxmtInterval, is configured for a virtual link ๐ฐ๏ธ. it should be well over the expected round-trip delay between the two routers. this can be hard to estimate for a virtual link, so it's better to err on the side of making it too large ๐
16. Calculation of the routing table ๐งฎ
this section breaks down the OSPF routing table calculation ๐
. the router takes its attached areas' link state databases as input and runs the following algorithm, building its routing table step by step ๐ช. at each step, the router has to access individual pieces of the link state databases (for example, a router-LSA originated by a certain router) ๐. that access is done with the lookup function discussed in Section 12.2. heads up: the lookup process might return an LSA whose LS age is equal to MaxAge ๐. that LSA should NOT be used in the routing table calculation, and it gets treated just like the lookup process failed ๐
the OSPF routing table's organization is explained in Section 11, and there are two examples of the routing table build process in Sections 11.2 and 11.3 ๐ฆ. this process can be broken into these steps:
(1) the present routing table gets invalidated ๐๏ธ. the routing table is built again from scratch, but the old one is saved so you can figure out which routing table entries changed โจ
(2) the intra-area routes are calculated by building the shortest-path tree for each attached area ๐ณ. specifically, all routing table entries whose Destination Type is "area border router" get calculated in this step ๐. this step happens in two parts. first, the tree is built using only the links between routers and transit networks. then the stub networks get added to the tree ๐ง. during the area's shortest-path tree calculation, the area's TransitCapability also gets calculated so it's ready for Step 4 ๐
(3) the inter-area routes are calculated by looking at summary-LSAs ๐. if the router is attached to multiple areas (in other words, it's an area border router), only backbone summary-LSAs get examined ๐ธ
(4) in area border routers connecting to one or more transit areas (that is, non-backbone areas whose TransitCapability is found to be TRUE) ๐ฆ, the transit areas' summary-LSAs get examined to see if there are better paths through the transit areas than the ones found in Steps 2-3 above ๐
(5) routes to external destinations get calculated by looking at AS-external-LSAs ๐. the locations of the AS boundary routers (the ones that originate the AS-external-LSAs) were already figured out in steps 2-4 ๐
Steps 2-5 get explained in more detail below ๐ซถ
changes made to routing table entries from these calculations can make the OSPF protocol take further actions ๐ฅ. for example, a change to an intra-area route makes an area border router originate new summary-LSAs (see Section 12.4). see Section 16.7 for the full list of OSPF protocol actions that result from routing table changes ๐
16.1. Calculating the shortest-path tree for an area ๐ณ
this calculation gives you the set of intra-area routes associated with an area (called Area A from here on) โจ. a router calculates the shortest-path tree using itself as the root.[22] the shortest path tree gets formed in two stages ๐ช. in the first stage, only the links between routers and transit networks are considered, and a tree gets built from this subset of the link state database using the Dijkstra algorithm ๐ง . in the second stage, leaves get added to the tree by looking at the links to stub networks ๐
the procedure is explained using the graph terminology from Section 2 ๐. Area A's link state database is represented as a directed graph ๐ธ๏ธ. the graph's vertices are routers, transit networks, and stub networks. the first stage only deals with the transit vertices (routers and transit networks) and their connecting links ๐ซง. throughout the shortest path calculation, each transit vertex also has the following data associated with it:
Vertex (node) ID ๐ A 32-bit number that uniquely identifies the vertex. for router vertices, this is the router's OSPF Router ID. for network vertices, this is the IP address of the network's Designated Router.
An LSA ๐ each transit vertex has an associated LSA. for router vertices, that's a router-LSA. for transit networks, it's a network-LSA (which is actually originated by the network's Designated Router). either way, the LSA's Link State ID is always equal to the Vertex ID above ๐ .
List of next hops ๐ฆ the list of next hops for the current set of shortest paths from the root to this vertex. there can be multiple shortest paths thanks to the equal-cost multipath capability ๐. each next hop tells you the outgoing router interface to use when forwarding traffic to the destination. on broadcast, Point-to-MultiPoint and NBMA networks, the next hop also includes the IP address of the next router (if there is one) in the path toward the destination ๐งญ.
Distance from root ๐ the link state cost of the current set of shortest paths from the root to the vertex. the link state cost of a path is the sum of the costs of the path's constituent links (as advertised in router-LSAs and network-LSAs) โ. one path is "shorter" than another if it has a smaller link state cost ๐โโ๏ธ
the first stage of the procedure (the Dijkstra algorithm) can be summed up like this ๐ซ. at each iteration, there's a list of candidate vertices. paths from the root to these vertices have been found, but they're not necessarily the shortest ones yet. however, the path to the candidate vertex closest to the root is guaranteed to be shortest. so that vertex gets added to the shortest-path tree and removed from the candidate list, and its adjacent vertices get examined for possible addition to or modification of the candidate list ๐. then the algorithm iterates again. it stops when the candidate list is empty ๐
here are the detailed steps. remember, we're computing the shortest path tree for Area A, so every link state database lookup below is from Area A's database ๐
(1) initialize the algorithm's data structures ๐งน. clear the list of candidate vertices. set the shortest-path tree to just the root (which is the router doing the calculation) ๐ฑ. set Area A's TransitCapability to FALSE ๐ โโ๏ธ
(2) call the vertex just added to the tree vertex V ๐ฏ. examine the LSA associated with vertex V. this is a lookup in Area A's link state database based on the Vertex ID. if this is a router-LSA, and bit V of the router-LSA (see Section A.4.2) is set, set Area A's TransitCapability to TRUE โ . in any case, each link described by the LSA gives the cost to an adjacent vertex. for each described link (say it joins vertex V to vertex W) ๐:
(a) if this is a link to a stub network, examine the next link in V's LSA ๐โโ๏ธ. links to stub networks get considered in the second stage of the shortest path calculation ๐ธ
(b) Okay so, if W is not a router, it's a transit vertex (router or transit network) ๐. Look up W's LSA (router-LSA or network-LSA) in Area A's link state database ๐. If the LSA doesn't exist, or its LS age is equal to MaxAge, or it doesn't have a link back to vertex V, just move on and check the next link in V's LSA.[23]
(c) If vertex W is already on the shortest-path tree, examine the next link in the LSA ๐ซถ.
(d) Now we calculate the link state cost D of the resulting path from the root to vertex W ๐งฎ. D is equal to the sum of the link state cost of the (already calculated) shortest path to vertex V and the advertised cost of the link between vertices V and W. Then we compare D:
- If D is greater than the value that already appears for vertex W on the candidate list, examine the next link. Bye bye ๐
- If D is equal to the value that appears for vertex W on the candidate list, calculate the set of next hops that result from using the advertised link. Input to this calculation is the destination (W), and its parent (V). This calculation is shown in Section 16.1.1. This set of hops should be added to the next hop values that appear for W on the candidate list. โจ
- If D is less than the value that appears for vertex W on the candidate list, or if W does not yet appear on the candidate list, then set the entry for W on the candidate list to indicate a distance of D from the root. Also calculate the list of next hops that result from using the advertised link, setting the next hop values for W accordingly. The next hop calculation is described in Section 16.1.1; it takes as input the destination (W) and its parent (V). ๐
(3) If at this step the candidate list is empty, the shortest-path tree (of transit vertices) has been completely built and this stage of the procedure terminates. ๐ Otherwise, choose the vertex belonging to the candidate list that is closest to the root, and add it to the shortest-path tree (removing it from the candidate list in the process). Note that when there is a choice of vertices closest to the root, network vertices must be chosen before router vertices in order to necessarily find all equal-cost paths. This is consistent with the tie-breakers that were introduced in the modified Dijkstra algorithm used by OSPF's Multicast routing extensions (MOSPF). It's giving organized ๐ธ.
(4) Possibly modify the routing table. For those routing table entries modified, the associated area will be set to Area A, the path type will be set to intra-area, and the cost will be set to the newly discovered shortest path's calculated distance. ๐
If the newly added vertex is an area border router or AS boundary router, a routing table entry is added whose destination type is "router". The Options field found in the associated router-LSA is copied into the routing table entry's Optional capabilities field. Call the newly added vertex Router X. If Router X is the endpoint of one of the calculating router's virtual links, and the virtual link uses Area A as Transit area: the virtual link is declared up, the IP address of the virtual interface is set to the IP address of the outgoing interface calculated above for Router X, and the virtual neighbor's IP address is set to Router X's interface address (contained in Router X's router-LSA) that points back to the root of the shortest-path tree. Equivalently, this is the interface that points back to Router X's parent vertex on the shortest-path tree (similar to the calculation in Section 16.1.1). ๐ฆ
If the newly added vertex is a transit network, the routing table entry for the network is located. The entry's Destination ID is the IP network number, which can be obtained by masking the Vertex ID (Link State ID) with its associated subnet mask (found in the body of the associated network-LSA). If the routing table entry already exists (i.e., there is already an intra-area route to the destination installed in the routing table), multiple vertices have mapped to the same IP network. For example, this can occur when a new Designated Router is being established. In this case, the current routing table entry should be overwritten if and only if the newly found path is just as short and the current routing table entry's Link State Origin has a smaller Link State ID than the newly added vertex' LSA. ๐
If there is no routing table entry for the network (the usual case), a routing table entry for the IP network should be added. The routing table entry's Link State Origin should be set to the newly added vertex' LSA. ๐
(5) Iterate the algorithm by returning to Step 2. ๐
The stub networks are added to the tree in the procedure's second stage. In this stage, all router vertices are again examined. Those that have been determined to be unreachable in the above first phase are discarded. For each reachable router vertex (call it V), the associated router-LSA is found in the link state database. Each stub network link appearing in the LSA is then examined, and the following steps are executed:
(1) Calculate the distance D of stub network from the root. D is equal to the distance from the root to the router vertex (calculated in stage 1), plus the stub network link's advertised cost. Compare this distance to the current best cost to the stub network. This is done by looking up the stub network's current routing table entry. If the calculated distance D is larger, go on to examine the next stub network link in the LSA. ๐ โโ๏ธ
(2) If this step is reached, the stub network's routing table entry must be updated. Calculate the set of next hops that would result from using the stub network link. This calculation is shown in Section 16.1.1; input to this calculation is the destination (the stub network) and the parent vertex (the router vertex). If the distance D is the same as the current routing table cost, simply add this set of next hops to the routing table entry's list of next hops. In this case, the routing table already has a Link State Origin. If this Link State Origin is a router-LSA whose Link State ID is smaller than V's Router ID, reset the Link State Origin to V's router-LSA. ๐
Otherwise D is smaller than the routing table cost. Overwrite the current routing table entry by setting the routing table entry's cost to D, and by setting the entry's list of next hops to the newly calculated set. Set the routing table entry's Link State Origin to V's router-LSA. Then go on to examine the next stub network link. ๐
For all routing table entries added/modified in the second stage, the associated area will be set to Area A and the path type will be set to intra-area. When the list of reachable router-LSAs is exhausted, the second stage is completed. At this time, all intra-area routes associated with Area A have been determined. ๐ฅณ
The specification does not require that the above two stage method be used to calculate the shortest path tree. However, if another algorithm is used, an identical tree must be produced. For this reason, it is important to note that links between transit vertices must be bidirectional in order to be included in the above tree. It should also be mentioned that more efficient algorithms exist for calculating the tree; for example, the incremental SPF algorithm described in [Ref1]. ๐ง
16.1.1. The next hop calculation ๐ง
This section explains how to calculate the current set of next hops to use for a destination. Each next hop consists of the outgoing interface to use in forwarding packets to the destination together with the IP address of the next hop router (if any). The next hop calculation is invoked each time a shorter path to the destination is discovered. This can happen in either stage of the shortest-path tree calculation (see Section 16.1). In stage 1 of the shortest-path tree calculation a shorter path is found as the destination is added to the candidate list, or when the destination's entry on the candidate list is modified (Step 2d of Stage 1). In stage 2 a shorter path is discovered each time the destination's routing table entry is modified (Step 2 of Stage 2).
The set of next hops to use for the destination may be recalculated several times during the shortest-path tree calculation, as shorter and shorter paths are discovered. In the end, the destination's routing table entry will always reflect the next hops resulting from the absolute shortest path(s). โจ
Input to the next hop calculation is a) the destination and b) its parent in the current shortest path between the root (the calculating router) and the destination. The parent is always a transit vertex (i.e., always a router or a transit network).
If there is at least one intervening router in the current shortest path between the destination and the root, the destination simply inherits the set of next hops from the parent. Otherwise, there are two cases. In the first case, the parent vertex is the root (the calculating router itself). This means that the destination is either a directly connected network or directly connected router. The outgoing interface in this case is simply the OSPF interface connecting to the destination network/router. If the destination is a router which connects to the calculating router via a Point-to-MultiPoint network, the destination's next hop IP address(es) can be determined by examining the destination's router-LSA: each link pointing back to the calculating router and having a Link Data field belonging to the Point-to-MultiPoint network provides an IP address of the next hop router. If the destination is a directly connected network, or a router which connects to the calculating router via a point-to-point interface, no next hop IP address is required. If the destination is a router connected to the calculating router via a virtual link, the setting of the next hop should be deferred until the calculation in Section 16.3. ๐ธ
In the second case, the parent vertex is a network that directly connects the calculating router to the destination router. The list of next hops is then determined by examining the destination's router-LSA. For each link in the router-LSA that points back to the parent network, the link's Link Data field provides the IP address of a next hop router. The outgoing interface to use can then be derived from the next hop IP address (or it can be inherited from the parent network). ๐
16.2. Calculating the inter-area routes ๐
okay so inter-area routes get calculated by looking at summary-LSAs ๐ซถ If the router is attached to multiple areas, it only checks the backbone's summary-LSAs. Routers attached to a single area check that area's summary-LSAs instead. Either way, all the summary-LSAs we look at come from one area's link state database (let's call it Area A) โจ
Summary-LSAs get originated by the area border routers. We check each summary-LSA in Area A one at a time ๐ Remember, the destination in a summary-LSA is either a network (Type 3 summary-LSAs) or an AS boundary router (Type 4 summary-LSAs). For each summary-LSA:
- If the cost specified by the LSA is LSInfinity, or if the LSA's LS age is equal to MaxAge, then examine the the next LSA. ๐
- If the LSA was originated by the calculating router itself, examine the next LSA. ๐
- If it is a Type 3 summary-LSA, and the collection of destinations described by the summary-LSA equals one of the router's configured area address ranges (see Section 3.5), and the particular area address range is active, then the summary-LSA should be ignored. "Active" means that there are one or more reachable (by intra-area paths) networks contained in the area range. ๐ธ
- Else, call the destination described by the LSA N (for Type 3 summary-LSAs, N's address is obtained by masking the LSA's Link State ID with the network/subnet mask contained in the body of the LSA), and the area border originating the LSA BR. Look up the routing table entry for BR having Area A as its associated area. If no such entry exists for router BR (i.e., BR is unreachable in Area A), do nothing with this LSA and consider the next in the list. Else, this LSA describes an inter-area path to destination N, whose cost is the distance to BR plus the cost specified in the LSA. Call the cost of this inter-area path IAC. ๐ง
- Next, look up the routing table entry for the destination N. (If N is an AS boundary router, look up the "router" routing table entry associated with Area A). If no entry exists for N or if the entry's path type is "type 1 external" or "type 2 external", then install the inter-area path to N, with associated area Area A, cost IAC, next hop equal to the list of next hops to router BR, and Advertising router equal to BR. ๐
- Else, if the paths present in the table are intra-area paths, do nothing with the LSA (intra-area paths are always preferred). ๐
- Else, the paths present in the routing table are also inter-area paths. Install the new path through BR if it is cheaper, overriding the paths in the routing table. Otherwise, if the new path is the same cost, add it to the list of paths that appear in the routing table entry. ๐ฆ
16.3. Examining transit areas' summary-LSAs ๐
okay this step is only performed by area border routers attached to one or more non-backbone areas that are capable of carrying transit traffic (i.e., "transit areas", or those areas whose TransitCapability parameter has been set to TRUE in Step 2 of the Dijkstra algorithm (see Section 16.1). โจ
The whole point of this calculation is to check the transit areas and see whether they offer any better (shorter) paths than the ones we already worked out in Sections 16.1 and 16.2. Any paths that are better than or equal to what we've already found get installed in the routing table ๐ฅ
Here's how it goes. All the transit areas' summary-LSAs get examined in turn. Each one describes a route through a transit area Area A to a Network N (N's address is obtained by masking the LSA's Link State ID with the network/subnet mask contained in the body of the LSA), or, in the case of a Type 4 summary-LSA, to an AS boundary router N. Suppose also that the summary-LSA was originated by an area border router BR.
- If the cost advertised by the summary-LSA is LSInfinity, or if the LSA's LS age is equal to MaxAge, then examine the next LSA. ๐
- If the summary-LSA was originated by the calculating router itself, examine the next LSA. ๐
- Look up the routing table entry for N. (If N is an AS boundary router, look up the "router" routing table entry associated with the backbone area). If it does not exist, or if the route type is other than intra-area or inter-area, or if the area associated with the routing table entry is not the backbone area, then examine the next LSA. In other words, this calculation only updates backbone intra-area routes found in Section 16.1 and inter-area routes found in Section 16.2. ๐ธ
- Look up the routing table entry for the advertising router BR associated with the Area A. If it is unreachable, examine the next LSA. Otherwise, the cost to destination N is the sum of the cost in BR's Area A routing table entry and the cost advertised in the LSA. Call this cost IAC. ๐งฎ
- If this cost is less than the cost occurring in N's routing table entry, overwrite N's list of next hops with those used for BR, and set N's routing table cost to IAC. Else, if IAC is the same as N's current cost, add BR's list of next hops to N's list of next hops. In any case, the area associated with N's routing table entry must remain the backbone area, and the path type (either intra-area or inter-area) must also remain the same. ๐
. Area 1 (transit) . +
. . |
. +---+1 1+---+100 |
. |RT2|----------|RT4|=========|
. 1/+---+********* +---+ |
. /******* . |
. 1/*Virtual . |
1+---+/* Link . Net|work
=======|RT1|* . | N1
+---+\ . |
. \ . |
. \ . |
. 1\+---+1 1+---+20 |
. |RT3|----------|RT5|=========|
. +---+ +---+ |
. . |
........................ +
Figure 17: Routing through transit areas ๐ฆ
It's really important to know that this calculation never makes unreachable destinations reachable ๐ โโ๏ธ It just potentially finds better paths to destinations that were already reachable. Any better cost it finds gets installed into the routing table entry, and from there it may be readvertised in summary-LSAs to other areas โจ
Let's walk through an example using the Autonomous System pictured in Figure 17. There's a single non-backbone area (Area 1) that physically splits the backbone into two separate pieces ๐ญ To keep the backbone connected, a virtual link has been configured between routers RT1 and RT4. On the right side of the figure, Network N1 belongs to the backbone. The dotted lines show that there's a much shorter intra-area backbone path between router RT5 and Network N1 (cost 20) than there is between Router RT4 and Network N1 (cost 100). Both Router RT4 and Router RT5 will inject summary-LSAs for Network N1 into Area 1. ๐
After the shortest-path tree has been calculated for the backbone in Section 16.1, Router RT1 (left end of the virtual link) will have calculated a path through Router RT4 for all data traffic destined for Network N1. However, since Router RT5 is so much closer to Network N1, all routers internal to Area 1 (e.g., Routers RT2 and RT3) will forward their Network N1 traffic towards Router RT5, instead of RT4. And indeed, after examining Area 1's summary-LSAs by the above calculation, Router RT1 will also forward Network N1 traffic towards RT5. Note that in this example the virtual link enables transit data traffic to be forwarded through Area 1, but the actual path the transit data traffic takes does not follow the virtual link. In other words, virtual links allow transit traffic to be forwarded through an area, but do not dictate the precise path that the traffic will take. ๐ โจ
16.4. Calculating AS external routes โจ
okay bestie, AS external routes get figured out by digging through the AS-external-LSAs ๐. we go through each one in turn ๐
. most of them describe routes to specific IP destinations, but an AS-external-LSA can also describe a default route for the whole Autonomous System (Destination ID = DefaultDestination, network/subnet mask = 0x00000000) ๐. here's the drill for each AS-external-LSA:
(1) if the cost in the LSA is LSInfinity, or the LSA's LS age is equal to MaxAge, then skip to the next LSA ๐.
(2) if the LSA was originated by the router doing the calculating, skip to the next LSA. no self-drama here ๐.
(3) call the destination described by the LSA N ๐ฏ. N's address comes from masking the LSA's Link State ID with the network/subnet mask in the body of the LSA. then look up the routing table entries (potentially one per attached area) for the AS boundary router (ASBR) that originated the LSA. if there are no entries for the router ASBR (aka ASBR is unreachable), do nothing with this LSA and consider the next one in the list.
otherwise, this LSA describes an AS external path to destination N โจ. check the forwarding address in the AS-external-LSA. that's the IP address packets for the destination should be forwarded to.
if the forwarding address is 0.0.0.0, packets should be sent to the ASBR itself. out of the multiple routing table entries for the ASBR, pick the preferred one like this. if RFC1583Compatibility is set to "disabled", prune the set of routing table entries for the ASBR as described in Section 16.4.1 (the prune step is giving main character ๐). either way, among the remaining entries, pick the one with the least cost. when there's a tie for least cost, the entry whose associated area has the largest OSPF Area ID (read as an unsigned 32-bit integer) wins ๐.
if the forwarding address is non-zero, look it up in the routing table.[24] the matching routing table entry must specify an intra-area or inter-area path. if no such path exists, do nothing with the LSA and consider the next one in the list ๐ซถ.
(4) let X be the cost specified by the preferred routing table entry for the ASBR/forwarding address, and Y the cost specified in the LSA. X is in terms of the link state metric, and Y is a type 1 or 2 external metric ๐งฎ.
(5) look up the routing table entry for destination N. if no entry exists for N, install the AS external path to N, with next hop equal to the list of next hops to the forwarding address, and advertising router equal to ASBR. if the external metric type is 1, the path-type is set to type 1 external and the cost is equal to X+Y. if the external metric type is 2, the path-type is set to type 2 external, the link state component of the route's cost is X, and the type 2 cost is Y.
(6) compare the AS external path described by the LSA with the existing paths in N's routing table entry ๐ช, as follows. if the new path is preferred, it replaces the present paths in N's routing table entry. if the new path is of equal preference, it's added to N's routing table entry's list of paths.
- (a) intra-area and inter-area paths are always preferred over AS external paths ๐.
- (b) type 1 external paths are always preferred over type 2 external paths. when all paths are type 2 external paths, the paths with the smallest advertised type 2 metric are always preferred.
- (c) if the new AS external path is still indistinguishable from the current paths in N's routing table entry, and
RFC1583Compatibilityis set to "disabled", select the preferred paths based on the intra-AS paths to the ASBR/forwarding addresses, as specified in Section 16.4.1. - (d) if the new AS external path is still indistinguishable from the current paths in N's routing table entry, select the preferred path based on a least cost comparison. type 1 external paths are compared by looking at the sum of the distance to the forwarding address and the advertised type 1 metric (X+Y). type 2 external paths advertising equal type 2 metrics are compared by looking at the distance to the forwarding addresses.
16.4.1. External path preferences
when multiple intra-AS paths are available to ASBRs/forwarding addresses, these rules tell you which paths are preferred ๐บ๏ธ. they apply when the same ASBR is reachable through multiple areas, or when you're deciding which of several AS-external-LSAs should be preferred. in the first case, the paths all terminate at the same ASBR. in the second, the paths terminate at separate ASBRs/forwarding addresses. either way, each path is represented by a separate routing table entry, as defined in Section 11.
this section only applies when RFC1583Compatibility is set to "disabled" โ ๏ธ so don't skip it, bestie.
the path preference rules, from highest to lowest preference, are below. note that because of these rules there may still be multiple paths at the highest preference. in that case, the path to use must be determined based on cost, as described in Section 16.4.
- Intra-area paths using non-backbone areas are always the most preferred ๐ธ.
- Otherwise, intra-area backbone paths are preferred.
- Inter-area paths are the least preferred.
16.5. Incremental updates -- summary-LSAs
when a new summary-LSA comes in, you don't have to recalculate the entire routing table ๐. call the destination described by the summary-LSA N (N's address is obtained by masking the LSA's Link State ID with the network/subnet mask in the body of the LSA), and let Area A be the area the LSA belongs to. there are then two separate cases:
Case 1: Area A is the backbone and/or the router is not an area border router. ๐ In this case, the following calculations must be performed. First, if there is presently an inter-area route to destination N, N's routing table entry is invalidated, saving the entry's values for later comparisons. then the calculation in Section 16.2 is run again for the single destination N. in this calculation, all of Area A's summary-LSAs that describe a route to N are examined. in addition, if the router is an area border router attached to one or more transit areas, the calculation in Section 16.3 must be run again for the single destination. if the results of these calculations have changed the cost/path to an AS boundary router (as would be the case for a Type 4 summary-LSA) or to any forwarding addresses, all AS-external-LSAs will have to be reexamined by rerunning the calculation in Section 16.4. otherwise, if N is now newly unreachable, the calculation in Section 16.4 must be rerun for the single destination N, in case an alternate external route to N exists.
Case 2: Area A is a transit area and the router is an area border router. ๐ In this case, the following calculations must be performed. First, if N's routing table entry presently contains one or more inter-area paths that utilize the transit area Area A, these paths should be removed. if this removes all paths from the routing table entry, the entry should be invalidated. the entry's old values should be saved for later comparisons. next, the calculation in Section 16.3 must be run again for the single destination N. if the results of this calculation have caused the cost to N to increase, the complete routing table calculation must be rerun, starting with the Dijkstra algorithm specified in Section 16.1. otherwise, if the cost/path to an AS boundary router (as would be the case for a Type 4 summary-LSA) or to any forwarding addresses has changed, all AS-external-LSAs will have to be reexamined by rerunning the calculation in Section 16.4. otherwise, if N is now newly unreachable, the calculation in Section 16.4 must be rerun for the single destination N, in case an alternate external route to N exists.
16.6. Incremental updates -- AS-external-LSAs
when a new AS-external-LSA is received, you don't need to recalculate the entire routing table ๐ฆ. call the destination described by the AS-external-LSA N. N's address is obtained by masking the LSA's Link State ID with the network/subnet mask in the body of the LSA. if there's already an intra-area or inter-area route to the destination, no recalculation is necessary, because internal routes take precedence ๐ .
otherwise, the procedure in Section 16.4 will have to be performed, but only for those AS-external-LSAs whose destination is N. before this procedure is performed, the present routing table entry for N should be invalidated.
16.7. Events generated as a result of routing table changes
changes to routing table entries sometimes make the OSPF area border routers take extra actions ๐ฌ. these routers need to act on the following routing table changes:
- The cost or path type of a routing table entry has changed. if the destination described by this entry is a Network or AS boundary router, and this is not simply a change of AS external routes, new summary-LSAs may have to be generated (potentially one for each attached area, including the backbone). see Section 12.4.3 for more information. if a previously advertised entry has been deleted, or is no longer advertisable to a particular area, the LSA must be flushed from the routing domain by setting its LS age to MaxAge and reflooding (see Section 14.1).
- A routing table entry associated with a configured virtual link has changed. the destination of such a routing table entry is an area border router. the change indicates a modification to the virtual link's cost or viability.
if the entry indicates that the area border router is newly reachable, the corresponding virtual link is now operational. an InterfaceUp event should be generated for the virtual link, which will cause a virtual adjacency to begin to form (see Section 10.3). at this time, the virtual link's IP interface address and the virtual neighbor's Neighbor IP address are also calculated.
if the entry indicates that the area border router is no longer reachable, the virtual link and its associated adjacency should be destroyed. this means an InterfaceDown event should be generated for the associated virtual link.
if the cost of the entry has changed, and there is a fully established virtual adjacency, a new router-LSA for the backbone must be originated. this in turn may cause further routing table changes ๐.
16.8. Equal-cost multipath โจ
OSPF keeps track of multiple equal-cost routes to every destination ๐ฃ๏ธโจ You can see this in the steps we used above to calculate the routing table, and in how the routing table structure is defined ๐
Each of those routes has the same type (intra-area, inter-area, type 1 external, or type 2 external) ๐ and the same cost ๐ and the same associated area ๐ธ The difference is that every route has its own next hop and its own Advertising router ๐ฆ
Okay, but here's the lowkey chill part ๐ซถ A router running OSPF has no requirement to track every possible equal-cost route to a destination ๐ An implementation can keep only a fixed number of routes to any one destination, and that doesn't change any of the algorithms in this spec ๐
Footnotes ๐
[1] The graph's vertices stand for routers, transit networks, or stub networks ๐ธ๏ธ Routers can belong to more than one area, so it's not possible to color the graph's vertices ๐
[2] It's possible for all of a router's interfaces to be unnumbered point-to-point links ๐ค When that happens, an IP address has to be assigned to the router ๐ท๏ธ That address then gets advertised in the router's router-LSA as a host route โจ
[3] Heads up: in these cases, the non-virtual interface and the virtual interface would both have the same IP address ๐ฏ
[4] No host route is generated for interfaces to unnumbered point-to-point networks, and no IP packets can be addressed to them ๐ โโ๏ธ This is true no matter what state the interface is in ๐
[5] Let's think about what happens when the Designated Router for a network crashes ๐ญ Call the Designated Router for the network RT1, and the Backup Designated Router RT2 ๐ If Router RT1 crashes (or maybe its interface to the network dies), the other routers on the network will notice RT1 is gone within RouterDeadInterval seconds ๐ They won't all notice at the exact same moment ๐ฐ๏ธ The routers that notice RT1's absence before RT2 does will, for a little while, pick RT2 to be both Designated Router and Backup Designated Router ๐ค Once RT2 realizes RT1 is gone, it moves itself up to Designated Router ๐ฆธโโ๏ธ Then the remaining router with the highest Router Priority gets picked as Backup Designated Router ๐
[6] On point-to-point networks, the lower-level protocols tell you whether the neighbor is up and running ๐ก Existence of the neighbor on virtual links is shown by the routing table calculation ๐งฎ But in both of these cases, the Hello Protocol is still used ๐ That makes sure communication between the neighbors goes both ways, and that each neighbor has a working routing protocol layer ๐ซถ
[7] When the identity of the Designated Router is changing, a neighbor in this state might often send the router a Database Description packet ๐ฌ That just means there's some momentary disagreement about who the Designated Router is ๐
[8] A router can resynchronize any of its fully established adjacencies by setting the adjacency's state back to ExStart ๐ That makes the other end of the adjacency process a SeqNumberMismatch event, so it also goes back to ExStart state ๐
[9] The address space of IP networks and the address space of OSPF Router IDs can overlap ๐ So a network might have an IP address that's identical (when you treat it as a 32-bit number) to some router's Router ID ๐คฏ
[10] "Discard" entries are necessary to make sure route summarization at area boundaries won't cause packet looping ๐ Not optional, babe ๐
[11] It's assumed that, for two different address ranges matching the destination, one range is more specific than the other โจ Non-contiguous subnet masks can be configured to break this assumption ๐ Those subnet mask configurations can't be handled by the OSPF protocol ๐ โโ๏ธ
[12] MaxAgeDiff is an architectural constant ๐ It shows the maximum dispersion of ages, in seconds, that can happen for a single LSA instance while it's being flooded through the routing domain ๐ If two LSAs differ by more than this, they're assumed to be different instances of the same LSA ๐ฆ This can happen when a router restarts and loses track of the LSA's previous LS sequence number ๐ญ See Section 13.4 for more details ๐
[13] When two LSAs have different LS checksums, they're assumed to be separate instances ๐งฉ This can happen when a router restarts and loses track of the LSA's previous LS sequence number ๐ If the two LSAs have the same LS sequence number, there's no way to tell which one is actually newer ๐คทโโ๏ธ But if the wrong LSA gets accepted as newer, the originating router will just originate another instance ๐ See Section 13.4 for further details ๐
[14] There's one place where a lookup has to be done based on partial information ๐ That's during the routing table calculation, when a network-LSA has to be found using only its Link State ID ๐ The lookup is still well defined, though, since no two network-LSAs can have the same Link State ID ๐
[15] This is the way RFC 1583 specified point-to-point representation ๐ It has three perks: a) it doesn't require allocating a subnet to the point-to-point link, b) it tends to bias the routing so that packets destined for the point-to-point interface will actually be received over that interface (which is handy for diagnostics), and c) it allows network bootstrapping of a neighbor without requiring that the bootstrap program contain an OSPF implementation ๐ง
[16] This is the more traditional point-to-point representation, the one protocols like RIP use ๐ฐ๏ธ
[17] This clause covers the case where inter-area routes are not summarized to the backbone ๐ฆด That's because inter-area routes are always associated with the backbone area ๐
[18] This clause only gets invoked when a non-backbone Area A supports transit data traffic (in other words, has TransitCapability set to TRUE) ๐ฆ For example, in the area configuration of Figure 6, Area 2 can support transit traffic because of the configured virtual link between Routers RT10 and RT11 ๐ So Router RT11 only needs to originate a single summary-LSA into Area 2 (having the collapsed destination N9-N11,H1) ๐ That's because all of Router RT11's other eligible routes have next hops inside Area 2 itself ๐ Those only need to be advertised by other area border routers, which in this case are Routers RT10 and RT7 ๐ซถ
[19] By keeping more information in the routing table, an implementation can recalculate the shortest path tree for just a single area ๐ณ There are actually incremental algorithms that let an implementation recalculate only a portion of a single area's shortest path tree [Ref1] โจ These algorithms are beyond the scope of this specification ๐
[20] This is how the Link state request list gets emptied, which eventually makes the neighbor state move to Full ๐ See Section 10.9 for more details ๐
[21] It should be pretty rare for an LSA's LS age to reach MaxAge this way ๐ Usually the LSA gets replaced by a more recent instance before it ages out โณ
[22] Strictly speaking, because of equal-cost multipath, the algorithm doesn't actually create a tree ๐ฒ We keep using the "tree" terminology anyway, because that's what shows up most in the existing literature ๐
[23] Note that the presence of any link back to V is enough, and it doesn't need to be the matching half of the link under consideration from V to W ๐ That's enough to make sure that, before data traffic flows between a pair of neighboring routers, their link state databases will be synchronized ๐ซถ
[24] When the forwarding address is non-zero, it should point to a router that belongs to another Autonomous System ๐ See Section 12.4.4 for more details ๐
References ๐
- [Ref1] McQuillan, J., I. Richer and E. Rosen, "ARPANET Routing Algorithm Improvements", BBN Technical Report 3803, April 1978.
- [Ref2] Digital Equipment Corporation, "Information processing systems -- Data communications -- Intermediate System to Intermediate System Intra-Domain Routing Protocol", October 1987.
- [Ref3] McQuillan, J. et.al., "The New Routing Algorithm for the ARPANET", IEEE Transactions on Communications, May 1980.
- [Ref4] Perlman, R., "Fault-Tolerant Broadcast of Routing Information", Computer Networks, December 1983.
- [Ref5] Postel, J., "Internet Protocol", STD 5, RFC 791, USC/Information Sciences Institute, September 1981.
- [Ref6] McKenzie, A., "ISO Transport Protocol specification ISO DP 8073", RFC 905, ISO, April 1984.
- [Ref7] Deering, S., "Host extensions for IP multicasting", STD 5, RFC 1112, Stanford University, May 1988.
- [Ref8] McCloghrie, K., and M. Rose, "Management Information Base for network management of TCP/IP-based internets: MIB-II", STD 17, RFC 1213, Hughes LAN Systems, Performance Systems International, March 1991.
- [Ref9] Moy, J., "OSPF Version 2", RFC 1583, Proteon, Inc., March 1994.
- [Ref10] Fuller, V., T. Li, J. Yu, and K. Varadhan, "Classless Inter-Domain Routing (CIDR): an Address Assignment and Aggregation Strategy", RFC1519, BARRNet, cisco, MERIT, OARnet, September 1993.
- [Ref11] Reynolds, J., and J. Postel, "Assigned Numbers", STD 2, RFC 1700, USC/Information Sciences Institute, October 1994.
- [Ref12] Almquist, P., "Type of Service in the Internet Protocol Suite", RFC 1349, July 1992.
- [Ref13] Leiner, B., et.al., "The DARPA Internet Protocol Suite", DDN Protocol Handbook, April 1985.
- [Ref14] Bradley, T., and C. Brown, "Inverse Address Resolution Protocol", RFC 1293, January 1992.
- [Ref15] deSouza, O., and M. Rodrigues, "Guidelines for Running OSPF Over Frame Relay Networks", RFC 1586, March 1994.
- [Ref16] Bellovin, S., "Security Problems in the TCP/IP Protocol Suite", ACM Computer Communications Review, Volume 19, Number 2, pp. 32-38, April 1989.
- [Ref17] Rivest, R., "The MD5 Message-Digest Algorithm", RFC 1321, April 1992.
- [Ref18] Moy, J., "Multicast Extensions to OSPF", RFC 1584, Proteon, Inc., March 1994.
- [Ref19] Coltun, R. and V. Fuller, "The OSPF NSSA Option", RFC 1587, RainbowBridge Communications, Stanford University, March 1994.
- [Ref20] Ferguson, D., "The OSPF External Attributes LSA", work in progress.
- [Ref21] Moy, J., "Extending OSPF to Support Demand Circuits", RFC 1793, Cascade, April 1995.
- [Ref22] Mogul, J. and S. Deering, "Path MTU Discovery", RFC 1191, DECWRL, Stanford University, November 1990.
- [Ref23] Rekhter, Y. and T. Li, "A Border Gateway Protocol 4 (BGP-4)", RFC 1771, T.J. Watson Research Center, IBM Corp., cisco Systems, March 1995.
- [Ref24] Hinden, R., "Internet Routing Protocol Standardization Criteria", BBN, October 1991.
A. OSPF data formats โจ
okay bestie, this appendix is where we get into the actual packet formats ๐ OSPF runs directly over the IP network layer, so before we look at any data formats we need to talk about how OSPF gets encapsulated ๐
Then we're gonna check out the OSPF Options field, which is how routers flag the capabilities they do or don't support. It shows up in OSPF Hello packets, Database Description packets, and OSPF LSAs ๐ฆ
The packet formats are in Section A.3, and the LSA formats are in Section A.4 ๐ธ
A.1 Encapsulation of OSPF packets
OSPF runs directly on top of the Internet Protocol's network layer ๐ So OSPF packets get wrapped in nothing but IP and local data-link headers. Simple and iconic ๐
OSPF doesn't have its own way to fragment packets. It relies on IP fragmentation when a packet is bigger than the network MTU ๐ The packet can be up to 65,535 bytes long, IP header included, if it needs to be. The OSPF packet types that tend to get big (Database Description, Link State Request, Link State Update, and Link State Acknowledgment packets) can usually be split into several smaller protocol packets without losing any functionality ๐งฉ That's the move. IP fragmentation should be avoided whenever possible โจ
So the rule of thumb here is to keep OSPF packets sent over virtual links to 576 bytes, unless Path MTU Discovery is being performed (see [Ref22]) ๐ซถ
Here are the other key features of OSPF's IP encapsulation:
- Use of IP multicast. Some OSPF messages get multicast when they're sent over broadcast networks ๐ฃ Two distinct IP multicast addresses are used. Packets sent to these addresses should never be forwarded, because they're only meant to travel a single hop ๐ฆ To make sure they don't travel multiple hops, their IP TTL must be set to 1 ๐
- AllSPFRouters. This multicast address has been assigned the value 224.0.0.5 ๐ All routers running OSPF should be prepared to receive packets sent to this address. Hello packets are always sent to this destination. Certain OSPF protocol packets are also sent here during the flooding procedure ๐
- AllDRouters. This multicast address has been assigned the value 224.0.0.6 ๐ Both the Designated Router and the Backup Designated Router must be prepared to receive packets destined for this address. Certain OSPF protocol packets are sent here during the flooding procedure โญ
- OSPF is IP protocol number 89 ๐ข This number was registered with the Network Information Center. IP protocol number assignments are documented in [Ref11] ๐
- All OSPF routing protocol packets are sent using the normal service TOS value of binary 0000, which is defined in [Ref12] ๐
- Routing protocol packets are sent with IP precedence set to Internetwork Control ๐ OSPF protocol packets should be given precedence over regular IP data traffic, both when they're sent and when they're received. Setting the IP precedence field in the IP header to Internetwork Control [Ref5] may help make this happen ๐
A.2 The Options field
The OSPF Options field shows up in OSPF Hello packets, Database Description packets, and all LSAs ๐ It's how OSPF routers say whether they support (or don't support) optional capabilities, and how they tell other OSPF routers what their capability level is. That's the magic that lets routers with different capabilities hang out in the same OSPF routing domain ๐ง
In Hello packets, the Options field lets a router reject a neighbor because of a capability mismatch ๐ โโ๏ธ When capabilities are exchanged in Database Description packets, a router can choose not to forward certain LSAs to a neighbor because that neighbor has reduced functionality ๐ซฃ And when capabilities are listed in LSAs, routers can route traffic around the reduced-functionality routers by leaving them out of parts of the routing table calculation ๐ฃ๏ธ Lowkey genius.
Five bits of the OSPF Options field have been assigned ๐ฅ Only one of them, the E-bit, is fully described by this memo, but I'll give you a quick rundown of each one below ๐ Routers should reset (i.e. clear) unrecognized bits in the Options field when they send Hello packets or Database Description packets and when they originate LSAs. On the flip side, when routers run into unrecognized Option bits in received Hello packets, Database Description packets, or LSAs, they should ignore that capability and process the packet or LSA normally ๐
+------------------------------------+
| * | * | DC | EA | N/P | MC | E | * |
+------------------------------------+
The Options field
E-bit. This bit describes the way AS-external-LSAs are flooded, as described in Sections 3.6, 9.5, 10.8 and 12.1.2 of this memo ๐ธ
MC-bit. This bit describes whether IP multicast datagrams are forwarded according to the specifications in [Ref18] ๐
N/P-bit. This bit describes how Type-7 LSAs are handled, as specified in [Ref19] ๐ฆ
EA-bit. This bit describes the router's willingness to receive and forward External-Attributes-LSAs, as specified in [Ref20] โจ
DC-bit. This bit describes how the router handles demand circuits, as specified in [Ref21] ๐
A.3 OSPF Packet Formats
There are five distinct OSPF packet types ๐ Every single one of them starts with a standard 24 byte header. We'll go through that header first, and then each packet type gets its own section after it. In those sections, you'll see how each packet is divided into fields, followed by the field definitions ๐ฆ
All OSPF packet types except the OSPF Hello packets deal with lists of LSAs ๐ซถ For example, Link State Update packets are what handle flooding LSAs throughout the OSPF routing domain. Because of that, you can't parse OSPF protocol packets unless you also understand the format of LSAs ๐คฏ The LSA format is covered in Section A.4, so go check it out ๐
The receive processing of OSPF packets is detailed in Section 8.2 ๐ The sending of OSPF packets is explained in Section 8.1 โญ
A.3.1 The OSPF packet header
Every OSPF packet starts with a standard 24 byte header ๐ง This header has all the info needed to decide whether a packet should be accepted for further processing. That decision is described in Section 8.2 of the specification ๐
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Version # | Type | Packet length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Router ID |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Area ID |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Checksum | AuType |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Authentication |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Authentication |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Version #. This is the OSPF version number. This specification documents version 2 of the protocol ๐ข
Type. This is the OSPF packet type. The types are listed below, and you can find the details in Sections A.3.2 through A.3.6 ๐๏ธ
Type Description
________________________________
1 Hello
2 Database Description
3 Link State Request
4 Link State Update
5 Link State Acknowledgment
Packet length. This is the length of the OSPF protocol packet in bytes. The length includes the standard OSPF header ๐
Router ID. This is the Router ID of the packet's source ๐
Area ID. This is a 32 bit number that identifies the area the packet belongs to. Every OSPF packet is associated with a single area. Most travel a single hop only. Packets traveling over a virtual link are labelled with the backbone Area ID of 0.0.0.0 ๐บ๏ธ
Checksum. This is the standard IP checksum of the entire contents of the packet, starting with the OSPF packet header but leaving out the 64-bit authentication field ๐งฎ It's calculated as the 16-bit one's complement of the one's complement sum of all the 16-bit words in the packet, excluding the authentication field. If the packet's length isn't an integral number of 16-bit words, the packet is padded with a byte of zero before checksumming. The checksum is considered part of the packet authentication procedure, and for some authentication types the checksum calculation is omitted ๐
AuType. This identifies the authentication procedure to be used for the packet. Authentication is discussed in Appendix D of the specification. Check Appendix D for a list of the currently defined authentication types ๐ก๏ธ
Authentication. This is a 64-bit field for use by the authentication scheme. See Appendix D for details ๐
A.3.2 The Hello packet โจ
okay so Hello packets are OSPF packet type 1 ๐. They get sent periodically on all interfaces (including virtual links) to establish and maintain neighbor relationships ๐. On physical networks with multicast or broadcast capability, Hello packets are also multicast, which is how routers dynamically discover their neighbors ๐ฆ
all routers on a common network have to agree on certain parameters (Network mask, HelloInterval and RouterDeadInterval) ๐ . These parameters ride along in Hello packets, so any differences can block neighbor relationships from forming ๐. the detailed receive processing for Hello packets is in Section 10.5, and the sending side is covered in Section 9.5 ๐ธ
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Version # | 1 | Packet length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Router ID |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Area ID |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Checksum | AuType |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Authentication |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Authentication |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Network Mask |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| HelloInterval | Options | Rtr Pri |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| RouterDeadInterval |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Designated Router |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Backup Designated Router |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Neighbor |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| ... |
Network mask ๐ the network mask linked to this interface. for example, if the interface goes to a class B network whose third byte is used for subnetting, the network mask is 0xffffff00 โจ
Options ๐ the optional capabilities this router supports, as documented in Section A.2 ๐
HelloInterval โฑ๏ธ the number of seconds between this router's Hello packets ๐ธ
Rtr Pri ๐ this router's Router Priority. it's used in (Backup) Designated Router election ๐ฆ. if it's set to 0, the router is ineligible to become (Backup) Designated Router ๐
RouterDeadInterval ๐ the number of seconds before a silent router gets declared down ๐ญ
Designated Router ๐ง the identity of the Designated Router for this network, from the sending router's point of view. it's identified here by its IP interface address on the network. set to 0.0.0.0 if there is no Designated Router ๐ซถ
Backup Designated Router ๐ง the identity of the Backup Designated Router for this network, from the sending router's point of view. it's identified here by its IP interface address on the network. set to 0.0.0.0 if there is no Backup Designated Router ๐ซถ
Neighbor ๐ the Router IDs of each router whose valid Hello packets have been seen recently on the network. "recently" means in the last RouterDeadInterval seconds ๐
A.3.3 The Database Description packet
okay bestie, Database Description packets are OSPF packet type 2 ๐ธ. they get exchanged when an adjacency is being initialized ๐ฆ, and they describe the contents of the link-state database ๐. it can take more than one packet to describe the whole database, so there's a poll-response procedure for that ๐ . one router is designated the master and the other is the slave ๐. the master sends Database Description packets (polls), and the slave acknowledges them with its own Database Description packets (responses) โจ. the responses get linked back to the polls through the packets' DD sequence numbers ๐
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Version # | 2 | Packet length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Router ID |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Area ID |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Checksum | AuType |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Authentication |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Authentication |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Interface MTU | Options |0|0|0|0|0|I|M|MS
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| DD sequence number |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
+- -+
| |
+- An LSA Header -+
| |
+- -+
| |
+- -+
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| ... |
the layout of the Database Description packet is super similar to the Link State Request and Link State Acknowledgment packets ๐ฏ. the main bit of all three is a list of items, and each item describes a piece of the link-state database ๐ . the sending side is documented in Section 10.8, and the reception side is in Section 10.6 ๐ธ
Interface MTU ๐ the size in bytes of the largest IP datagram that can be sent out the associated interface without fragmentation ๐ฆ. the MTUs of common Internet link types can be found in Table 7-1 of [Ref22] โจ. Interface MTU should be set to 0 in Database Description packets sent over virtual links ๐
Options ๐ the optional capabilities this router supports, as documented in Section A.2 ๐
I-bit ๐ the Init bit. when it's set to 1, this packet is the first in the sequence of Database Description Packets ๐
M-bit ๐ง the More bit. when it's set to 1, it means more Database Description Packets are to follow ๐ธ
MS-bit ๐ the Master/Slave bit. when it's set to 1, the router is the master during the Database Exchange process. otherwise, the router is the slave ๐ซถ
DD sequence number ๐ข used to sequence the collection of Database Description Packets. the initial value (indicated by the Init bit being set) should be unique. then the DD sequence number increments until the complete database description has been sent ๐
the rest of the packet is a (possibly partial) list of the link-state database's pieces ๐. each LSA in the database is described by its LSA header, which is documented in Section A.4.1 โจ. the header has all the info needed to uniquely identify both the LSA and the LSA's current instance ๐ญ
A.3.4 The Link State Request packet
Link State Request packets are OSPF packet type 3 ๐ฆ. after a router swaps Database Description packets with a neighbor, it might notice that parts of its link-state database are out-of-date ๐. that's where the Link State Request packet comes in, to ask for the pieces of the neighbor's database that are more up-to-date ๐ . it may take more than one Link State Request packet to do the job ๐ธ
a router that sends a Link State Request packet has a precise instance of the database pieces in mind ๐ฏ. each instance is defined by its LS sequence number, LS checksum, and LS age, even though those fields aren't actually specified in the Link State Request Packet itself ๐ซถ. the router may even receive more recent instances in response ๐
the sending side of Link State Request packets is documented in Section 10.9, and the reception side is documented in Section 10.7 ๐ง
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Version # | 3 | Packet length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Router ID |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Area ID |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Checksum | AuType |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Authentication |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Authentication |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| LS type |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Link State ID |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Advertising Router |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| ... |
each requested LSA is specified by its LS type, Link State ID, and Advertising Router ๐. that combo uniquely identifies the LSA, but not its instance ๐. Link State Request packets are understood to be requests for the most recent instance (whatever that might be) โจ
A.3.5 The Link State Update packet ๐ฆโจ
Link State Update packets are OSPF packet type 4 ๐. These are the packets that actually handle the flooding of LSAs. Each one carries a collection of LSAs one hop further from their origin, and you can fit several LSAs into a single packet ๐ .
Link State Update packets are multicast on those physical networks that support multicast/broadcast. To make flooding reliable, flooded LSAs get acknowledged in Link State Acknowledgment packets ๐ซถ. If retransmission of certain LSAs is necessary, the retransmitted LSAs are always carried by unicast Link State Update packets. For more on reliable flooding of LSAs, check out Section 13 ๐ธ.
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Version # | 4 | Packet length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Router ID |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Area ID |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Checksum | AuType |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Authentication |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Authentication |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| # LSAs |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
+- +-+
| LSAs |
+- +-+
| ... |
# LSAs
The number of LSAs included in this update.
The body of the Link State Update packet is a list of LSAs. Each LSA begins with a common 20 byte header, described in Section A.4.1. Detailed formats of the different types of LSAs are described in Section A.4 ๐ง.
A.3.6 The Link State Acknowledgment packet ๐ฆ
Link State Acknowledgment packets are OSPF packet type 5 ๐. To make flooding of LSAs reliable, flooded LSAs are explicitly acknowledged. This acknowledgment happens through sending and receiving Link State Acknowledgment packets, and multiple LSAs can be acknowledged in a single one ๐.
Depending on the state of the sending interface and the sender of the corresponding Link State Update packet, a Link State Acknowledgment packet is sent either to the multicast address AllSPFRouters, to the multicast address AllDRouters, or as a unicast. The sending of these packets is documented in Section 13.5, and the reception is documented in Section 13.7 โจ.
The format of this packet is similar to that of the Data Description packet. The body of both packets is simply a list of LSA headers ๐.
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Version # | 5 | Packet length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Router ID |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Area ID |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Checksum | AuType |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Authentication |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Authentication |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
+- -+
| |
+- An LSA Header -+
| |
+- -+
| |
+- -+
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| ... |
Each acknowledged LSA is described by its LSA header. The LSA header is documented in Section A.4.1 ๐. It contains all the information required to uniquely identify both the LSA and the LSA's current instance, so it's basically the LSA's ID card ๐ชช.
A.4 LSA formats ๐ธ
This memo defines five distinct types of LSAs ๐. Each LSA begins with a standard 20 byte LSA header, which is explained in Section A.4.1. Succeeding sections then diagram the separate LSA types ๐.
Each LSA describes a piece of the OSPF routing domain. Every router originates a router-LSA. On top of that, whenever a router is elected Designated Router, it originates a network-LSA. Other types of LSAs may also be originated (see Section 12.4). All LSAs are then flooded throughout the OSPF routing domain. The flooding algorithm is reliable, ensuring that all routers have the same collection of LSAs (see Section 13 for more information concerning the flooding algorithm). This collection of LSAs is called the link-state database ๐๏ธ.
From the link state database, each router constructs a shortest path tree with itself as root. This yields a routing table (see Section 11). For the details of the routing table build process, see Section 16 ๐ง .
A.4.1 The LSA header ๐ฅ
All LSAs begin with a common 20 byte header. This header contains enough information to uniquely identify the LSA (LS type, Link State ID, and Advertising Router) ๐. Multiple instances of the LSA may exist in the routing domain at the same time, so it's necessary to figure out which instance is more recent. This is done by examining the LS age, LS sequence number and LS checksum fields, which are also contained in the LSA header โญ.
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| LS age | Options | LS type |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Link State ID |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Advertising Router |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| LS sequence number |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| LS checksum | length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
LS age
The time in seconds since the LSA was originated โฐ.
Options
The optional capabilities supported by the described portion of the routing domain. OSPF's optional capabilities are documented in Section A.2.
LS type
The type of the LSA. Each LSA type has a separate advertisement format. The LSA types defined in this memo are as follows (see Section 12.1.3 for further explanation):
LS Type Description
___________________________________
1 Router-LSAs
2 Network-LSAs
3 Summary-LSAs (IP network)
4 Summary-LSAs (ASBR)
5 AS-external-LSAs
Link State ID
This field identifies the portion of the internet environment that is being described by the LSA. Its contents depend on the LSA's LS type. For example, in network-LSAs the Link State ID is set to the IP interface address of the network's Designated Router (from which the network's IP address can be derived). The Link State ID is further discussed in Section 12.1.4 ๐ท.
Advertising Router
The Router ID of the router that originated the LSA. For example, in network-LSAs this field is equal to the Router ID of the network's Designated Router ๐ก.
LS sequence number
Detects old or duplicate LSAs. Successive instances of an LSA are given successive LS sequence numbers. See Section 12.1.6 for more details ๐ข.
LS checksum
The Fletcher checksum of the complete contents of the LSA, including the LSA header but excluding the LS age field. See Section 12.1.7 for more details ๐งฎ.
length
The length in bytes of the LSA. This includes the 20 byte LSA header ๐.
A.4.2 Router-LSAs โจ
okay bestie, router-LSAs are the Type 1 LSAs ๐ each router in an area originates one. It describes the state and cost of the router's links (aka interfaces) to the area. all of the router's links to the area must be described in a single router-LSA, no splitting it up ๐ซถ for the deets on building these, see Section 12.4.1.
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| LS age | Options | 1 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Link State ID |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Advertising Router |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| LS sequence number |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| LS checksum | length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| 0 |V|E|B| 0 | # links |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Link ID |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Link Data |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type | # TOS | metric |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| ... |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| TOS | 0 | TOS metric |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Link ID |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Link Data |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| ... |
in router-LSAs, the Link State ID field is set to the router's OSPF Router ID. router-LSAs are flooded throughout a single area only ๐ธ
bit V when set, the router is an endpoint of one or more fully adjacent virtual links having the described area as Transit area (V is for virtual link endpoint) ๐ฆ
bit E when set, the router is an AS boundary router (E is for external) ๐
bit B when set, the router is an area border router (B is for border) ๐ง
# links the number of router links described in this LSA. this must be the total collection of router links (i.e., interfaces) to the area ๐
the following fields describe each router link (i.e., interface). each router link is typed (see the below Type field). the Type field tells you the kind of link being described: it may be a link to a transit network, to another router, or to a stub network. the values of all the other fields describing a router link depend on the link's Type. for example, each link has an associated 32-bit Link Data field. for links to stub networks this field specifies the network's IP address mask. for other link types, the Link Data field specifies the router interface's IP address. that's the vibe check for the Type field ๐
Type a quick description of the router link. one of the following. note that host routes are classified as links to stub networks with network mask of 0xffffffff ๐
Type Description
__________________________________________________
1 Point-to-point connection to another router
2 Connection to a transit network
3 Connection to a stub network
4 Virtual link
Link ID identifies the object that this router link connects to. the value depends on the link's Type. when connecting to an object that also originates an LSA (i.e., another router or a transit network), the Link ID is equal to the neighboring LSA's Link State ID. this is the key for looking up the neighboring LSA in the link state database during the routing table calculation. see Section 12.2 for more details โจ
Type Link ID
______________________________________
1 Neighboring router's Router ID
2 IP address of Designated Router
3 IP network/subnet number
4 Neighboring router's Router ID
Link Data the value again depends on the link's Type field. for connections to stub networks, Link Data specifies the network's IP address mask. for unnumbered point-to-point connections, it specifies the interface's MIB-II [Ref8] ifIndex value. for the other link types it specifies the router interface's IP address. this latter piece of information is needed during the routing table build process, when calculating the IP address of the next hop. see Section 16.1.1 for more details ๐ฅ
# TOS the number of different TOS metrics given for this link, not counting the required link metric (referred to as the TOS 0 metric in [Ref9]). for example, if no additional TOS metrics are given, this field is set to 0 ๐
metric the cost of using this router link ๐
additional TOS-specific information may also be included, for backward compatibility with previous versions of the OSPF specification ([Ref9]). within each link, and for each desired TOS, TOS TOS-specific link information may be encoded as follows:
TOS IP the Type of Service that this metric refers to. the encoding of TOS in OSPF LSAs is described in Section 12.3 ๐
TOS metric TOS-specific metric information ๐ซถ
A.4.3 Network-LSAs ๐ฆ
okay, network-LSAs are the Type 2 LSAs ๐ธ a network-LSA gets originated for each broadcast and NBMA network in the area that supports two or more routers. it's originated by the network's Designated Router. the LSA describes all routers attached to the network, including the Designated Router itself. the LSA's Link State ID field lists the IP interface address of the Designated Router ๐
the distance from the network to all attached routers is zero, which is why metric fields don't need to be specified in the network-LSA ๐ง for details on building network-LSAs, see Section 12.4.2.
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| LS age | Options | 2 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Link State ID |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Advertising Router |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| LS sequence number |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| LS checksum | length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Network Mask |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Attached Router |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| ... |
Network Mask the IP address mask for the network. for example, a class A network would have the mask 0xff000000 ๐
Attached Router the Router IDs of each of the routers attached to the network. actually, only those routers that are fully adjacent to the Designated Router are listed. the Designated Router includes itself in this list. the number of routers included can be deduced from the LSA header's length field ๐
A.4.4 Summary-LSAs ๐ง
okay so summary-LSAs are the Type 3 and 4 LSAs ๐ area border routers are the ones who originate them, and they describe inter-area destinations ๐ฆ if you want the full breakdown of how they get built, check out Section 12.4.3 โจ
Type 3 summary-LSAs are used when the destination is an IP network ๐ธ in that case the LSA's Link State ID field is an IP network number (if necessary, the Link State ID can also have one or more of the network's "host" bits set; see Appendix E for details). when the destination is an AS boundary router, a Type 4 summary-LSA is used and the Link State ID field is the AS boundary router's OSPF Router ID. (to see why it's necessary to advertise the location of each ASBR, consult Section 16.4 ๐) other than the difference in the Link State ID field, the format of Type 3 and 4 summary-LSAs is identical ๐
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| LS age | Options | 3 or 4 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Link State ID |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Advertising Router |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| LS sequence number |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| LS checksum | length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Network Mask |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| 0 | metric |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| TOS | TOS metric |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| ... |
for stub areas, Type 3 summary-LSAs can also be used to describe a (per-area) default route ๐ default summary routes are used in stub areas instead of flooding a complete set of external routes, which is so smart ngl. when describing a default summary route, the summary-LSA's Link State ID is always set to DefaultDestination (0.0.0.0) and the Network Mask is set to 0.0.0.0 โจ
- Network Mask: for Type 3 summary-LSAs, this indicates the destination network's IP address mask. for example, when advertising the location of a class A network, the value
0xff000000would be used. this field is not meaningful and must be zero for Type 4 summary-LSAs ๐ - metric: the cost of this route, expressed in the same units as the interface costs in the router-LSAs ๐
additional TOS-specific information may also be included, for backward compatibility with previous versions of the OSPF specification ([Ref9]). for each desired TOS, the TOS-specific information is encoded as follows ๐
- TOS: the IP Type of Service that this metric refers to. the encoding of TOS in OSPF LSAs is described in Section 12.3 ๐ซถ
- TOS metric: TOS-specific metric information ๐
A.4.5 AS-external-LSAs ๐ฅ
AS-external-LSAs are the Type 5 LSAs ๐ these get originated by AS boundary routers, and they describe destinations external to the AS ๐ฆ for the details on how they're constructed, see Section 12.4.3 โจ
AS-external-LSAs usually describe a particular external destination. for these LSAs the Link State ID field specifies an IP network number (if necessary, the Link State ID can also have one or more of the network's "host" bits set; see Appendix E for details). AS-external-LSAs are also used to describe a default route ๐ธ default routes are used when no specific route exists to the destination. when describing a default route, the Link State ID is always set to DefaultDestination (0.0.0.0) and the Network Mask is set to 0.0.0.0 ๐
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| LS age | Options | 5 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Link State ID |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Advertising Router |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| LS sequence number |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| LS checksum | length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Network Mask |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|E| 0 | metric |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Forwarding address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| External Route Tag |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|E| TOS | TOS metric |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Forwarding address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| External Route Tag |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| ... |
- Network Mask: the IP address mask for the advertised destination. for example, when advertising a class A network, the mask
0xff000000would be used ๐ - bit E: the type of external metric. if bit E is set, the metric specified is a Type 2 external metric, which means the metric is considered larger than any link state path. if bit E is zero, the specified metric is a Type 1 external metric, which means it is expressed in the same units as the link state metric (i.e., the same units as interface cost) โจ
- metric: the cost of this route. the interpretation depends on the external type indication (bit E above) ๐ฆ
- Forwarding address: data traffic for the advertised destination will be forwarded to this address. if the Forwarding address is set to
0.0.0.0, data traffic will be forwarded instead to the LSA's originator (i.e., the responsible AS boundary router) ๐ซถ - External Route Tag: a 32-bit field attached to each external route. this is not used by the OSPF protocol itself. it may be used to communicate information between AS boundary routers; the precise nature of such information is outside the scope of this specification ๐ธ
additional TOS-specific information may also be included, for backward compatibility with previous versions of the OSPF specification ([Ref9]). for each desired TOS, the TOS-specific information is encoded as follows ๐
- TOS: the Type of Service that the following fields concern. the encoding of TOS in OSPF LSAs is described in Section 12.3 ๐
- bit E: for backward-compatibility with [Ref9] ๐
- TOS metric: TOS-specific metric information ๐
- Forwarding address: for backward-compatibility with [Ref9] ๐ง
- External Route Tag: for backward-compatibility with [Ref9] ๐
B. Architectural Constants โจ
okay so a bunch of OSPF protocol parameters have fixed architectural values ๐ธ they get referred to in the text by names like LSRefreshTime, and the same naming convention is used for the configurable protocol parameters (those are defined in Appendix C) ๐ below, you'll find each architectural constant with its value and a short description of what it does ๐
LSRefreshTime: the maximum time between distinct originations of any particular LSA. if the LS age field of one of the router's self-originated LSAs reaches the valueLSRefreshTime, a new instance of the LSA is originated, even though the contents of the LSA (apart from the LSA header) will be the same. the value ofLSRefreshTimeis set to 30 minutes โฐMinLSInterval: the minimum time between distinct originations of any particular LSA. the value ofMinLSIntervalis set to 5 seconds ๐ฆMinLSArrival: for any particular LSA, the minimum time that must elapse between reception of new LSA instances during flooding. LSA instances received at higher frequencies are discarded. the value ofMinLSArrivalis set to 1 second ๐MaxAge: the maximum age that an LSA can attain. when an LSA's LS age field reachesMaxAge, it is reflooded in an attempt to flush the LSA from the routing domain (see Section 14). LSAs of ageMaxAgeare not used in the routing table calculation. the value ofMaxAgeis set to 1 hour ๐ฅCheckAge: when the age of an LSA in the link state database hits a multiple ofCheckAge, the LSA's checksum is verified. an incorrect checksum at this time indicates a serious error. the value ofCheckAgeis set to 5 minutes ๐MaxAgeDiff: the maximum time dispersion that can occur as an LSA is flooded throughout the AS. most of this time is accounted for by the LSAs sitting on router output queues (and therefore not aging) during the flooding process. the value ofMaxAgeDiffis set to 15 minutes ๐LSInfinity: the metric value indicating that the destination described by an LSA is unreachable. used in summary-LSAs and AS-external-LSAs as an alternative to premature aging (see Section 14.1). it is defined to be the 24-bit binary value of all ones:0xffffff๐DefaultDestination: the Destination ID that indicates the default route. this route is used when no other matching routing table entry can be found. the default destination can only be advertised in AS-external-LSAs and in stub areas' type 3 summary-LSAs. its value is the IP address0.0.0.0. its associated Network Mask is also always0.0.0.0๐งInitialSequenceNumber: the value used for LS Sequence Number when originating the first instance of any LSA. its value is the signed 32-bit integer0x80000001๐MaxSequenceNumber: the maximum value that LS Sequence Number can attain. its value is the signed 32-bit integer0x7fffffff๐ซถ
C. Configurable Constants โจ
okay so OSPF has quite a few configurable parameters ๐ They're grouped into general buckets (area parameters, interface parameters, and so on), and some of them come with sample values so you have a starting point ๐
some settings have to match across groups of routers. like, all the routers in an area need to agree on that area's parameters, and all the routers on a network need to agree on that network's IP network number and mask ๐ซถ
some parameters can be figured out by router algorithms that live outside this spec, like the address of a host hooked up to the router over a SLIP line. from OSPF's point of view those are still configurable, so it's not a free pass ๐
C.1 Global parameters
in general, OSPF runs a separate copy for each area ๐ธ which means most config params are defined per area. the few global ones are below ๐
Router ID This is a 32-bit number that uniquely identifies the router in the Autonomous System. one way to pick it is to use the largest or smallest IP address assigned to the router ๐ฆ If a router's OSPF Router ID changes, the router's OSPF software should be restarted before the new Router ID takes effect. Before restarting to change its Router ID, the router should flush its self-originated LSAs from the routing domain (see Section 14.1). if it doesn't, they'll stick around for up to MaxAge minutes ๐
RFC1583Compatibility this one controls the preference rules used in Section 16.4 when the router is choosing between multiple AS-external-LSAs that advertise the same destination ๐ง When set to "enabled", the preference rules stay the ones from RFC 1583 ([Ref9]). When set to "disabled", the preference rules are the ones in Section 16.4.1, which stop routing loops when AS-external-LSAs for the same destination came from different areas (see Section G.7). it's "enabled" by default ๐
to keep the chance of routing loops low, every OSPF router in a routing domain should have RFC1583Compatibility set the same way. if there are routers around that haven't been updated with the functionality in Section 16.4.1 of this memo, then everyone should be "enabled". otherwise, everyone should be "disabled", and that blocks all the routing loops ๐ฅ
C.2 Area parameters
all the routers in an area have to agree on that area's config ๐ if two routers disagree, adjacencies can't form between them, and the flow of routing protocol and data traffic gets hindered. these are the items you have to configure for an area:
Area ID This is a 32-bit number that identifies the area. The Area ID of 0.0.0.0 is reserved for the backbone ๐ If the area represents a subnetted network, the IP network number of that subnetted network may be used as the Area ID โจ
List of address ranges an OSPF area is defined as a list of address ranges ๐ Each address range has these items:
[IP address, mask]: this describes the collection of IP addresses in the address range. Networks and hosts get assigned to an area depending on whether their addresses fall into one of the area's defining address ranges ๐ฆ Routers are seen as belonging to multiple areas, depending on the area membership of their attached networks.- Status: set to either Advertise or DoNotAdvertise. Routing information gets condensed at area boundaries ๐ Outside the area, at most a single route gets advertised (via a summary-LSA) for each address range. The route is advertised if and only if the address range's Status is set to Advertise. Unadvertised ranges let the existence of certain networks get intentionally hidden from other areas, which is lowkey iconic ๐ Status is set to Advertise by default.
as an example, say an IP subnetted network is going to be its own OSPF area ๐ The area would be configured as a single address range, where the IP address is the address of the subnetted network and the mask is the natural class A, B, or C address mask. A single route would be advertised outside the area, describing the entire subnetted network ๐ธ
ExternalRoutingCapability this is about whether AS-external-LSAs get flooded into and throughout the area ๐ง If AS-external-LSAs are excluded from the area, the area is called a "stub". Inside stub areas, routing to external destinations is based only on a default summary route. The backbone cannot be configured as a stub area, and virtual links can't be configured through stub areas either ๐ญ For more information, see Section 3.6.
StubDefaultCost if the area has been configured as a stub area, and the router itself is an area border router, then StubDefaultCost is the cost of the default summary-LSA that the router should advertise into the area ๐
C.3 Router interface parameters
some of the configurable router interface parameters (like the IP interface address and subnet mask) actually imply properties of the attached networks ๐ซถ so they have to be consistent across all the routers attached to that network. these are the parameters that must be configured for a router interface:
IP interface address the IP protocol address for this interface. It uniquely identifies the router across the entire internet ๐ An IP address isn't required on point-to-point networks. A point-to-point network like that is called "unnumbered" ๐ฆ
IP interface mask also called the subnet/network mask ๐ It indicates the portion of the IP interface address that identifies the attached network. Masking the IP interface address with the IP interface mask gives you the IP network number of the attached network โจ On point-to-point networks and virtual links, the IP interface mask isn't defined. On those networks the link itself isn't assigned an IP network number, so the address on each side of the link is assigned independently, if it's assigned at all ๐ง
Area ID the OSPF area that the attached network belongs to ๐
Interface output cost the cost of sending a packet on the interface, expressed in the link state metric ๐ฅ This is advertised as the link cost for this interface in the router's router-LSA. The interface output cost must always be greater than 0 ๐
RxmtInterval the number of seconds between LSA retransmissions, for adjacencies that belong to this interface ๐ It's also used when retransmitting Database Description and Link State Request Packets. It should be well over the expected round-trip delay between any two routers on the attached network ๐ธ Keep this setting conservative, or you'll get needless retransmissions ๐ Sample value for a local area network: 5 seconds.
InfTransDelay the estimated number of seconds it takes to transmit a Link State Update Packet over this interface โญ LSAs in the update packet must have their age incremented by this amount before transmission. This value should take the transmission and propagation delays of the interface into account. It must be greater than 0 ๐ซถ Sample value for a local area network: 1 second.
Router Priority an 8-bit unsigned integer ๐ When two routers attached to a network both try to become Designated Router, the one with the highest Router Priority takes precedence. If there's still a tie, the router with the highest Router ID wins ๐ A router whose Router Priority is set to 0 is ineligible to become Designated Router on the attached network ๐ญ Router Priority is only configured for interfaces to broadcast and NBMA networks.
HelloInterval the length of time, in seconds, between the Hello Packets the router sends on the interface ๐ฆ This value is advertised in the router's Hello Packets. It must be the same for all routers attached to a common network. The smaller the HelloInterval, the faster topological changes get detected, but more OSPF routing protocol traffic follows ๐ Sample value for an X.25 PDN network: 30 seconds. Sample value for a local area network: 10 seconds.
RouterDeadInterval after a router stops hearing another router's Hello Packets, this is how many seconds pass before its neighbors declare that router down ๐ It's also advertised in the router's Hello Packets, in their RouterDeadInterval field. It should be some multiple of the HelloInterval (say 4) ๐ This value again must be the same for all routers attached to a common network.
AuType identifies the authentication procedure to be used on the attached network ๐ง This value must be the same for all routers attached to the network. See Appendix D for a discussion of the defined authentication types ๐ฅ
Authentication key this configured data lets the authentication procedure verify OSPF protocol packets received over the interface ๐ For example, if the AuType indicates simple password, the Authentication key would be a clear 64-bit password ๐ Authentication keys for the other OSPF authentication types are discussed in Appendix D.
C.4 Virtual link parameters
virtual links are used to restore or increase connectivity of the backbone ๐ธ They can be configured between any pair of area border routers that have interfaces to a common (non-backbone) area ๐ซถ The virtual link shows up in the graph for the backbone as an unnumbered point-to-point link โจ The virtual link must be configured in both of the area border routers ๐
a virtual link shows up in router-LSAs (for the backbone) as if it were a separate router interface to the backbone ๐ So it has all the parameters a router interface has (see Section C.3) ๐ฆ Even though it acts like an unnumbered point-to-point link, it does have an associated IP interface address ๐ That address is used as the IP source in OSPF protocol packets sent along the virtual link, and it's set dynamically during the routing table build process ๐ง Interface output cost is also set dynamically on virtual links, to be the cost of the intra-area path between the two routers ๐ The parameter RxmtInterval must be configured, and should be well over the expected round-trip delay between the two routers ๐ฅ This can be hard to estimate for a virtual link, so it's better to err on the side of making it too large ๐ Router Priority isn't used on virtual links ๐
a virtual link is defined by two configurable parameters: the Router ID of the virtual link's other endpoint, and the (non-backbone) area the virtual link runs through, which is called the virtual link's Transit area ๐ Virtual links cannot be configured through stub areas ๐ญ
C.5 NBMA network parameters โจ
okay so OSPF treats an NBMA network pretty much like a broadcast network ๐ฆ Since there can be lots of routers plugged into it, a Designated Router gets picked for the network. That Designated Router then makes a network-LSA listing every router attached to the NBMA network ๐
BUT ๐ญ NBMA networks don't have broadcast, so sometimes you need to configure stuff for the Designated Router election. These parameters only need to be set on routers that can actually become Designated Router (aka their Router Priority on the network is non-zero), and only if there's no automatic way to discover neighbors ๐ซถ
List of all other attached routers : The list of all other routers attached to the NBMA network. Each router is listed by its IP interface address on the network. For each router listed, you also have to define whether that router is eligible to become Designated Router. When an interface to an NBMA network comes up, the router sends Hello Packets only to neighbors that are eligible to become Designated Router, until it finds out who the Designated Router is ๐ธ
PollInterval : If a neighboring router has gone inactive (no Hello Packets seen for RouterDeadInterval seconds), you may still need to keep sending Hello Packets to that dead neighbor ๐ Those get sent at the reduced rate PollInterval, which should be much larger than HelloInterval. Sample value for a PDN X.25 network: 2 minutes โญ
C.6 Point-to-MultiPoint network parameters ๐ง
on Point-to-MultiPoint networks, you might need to configure the set of neighbors that are directly reachable over the network. Each neighbor is identified by its IP address on the Point-to-MultiPoint network. Designated Routers aren't elected on Point-to-MultiPoint networks, so the Designated Router eligibility of configured neighbors is undefined ๐
Or, if you'd rather not, neighbors on Point-to-MultiPoint networks can be dynamically discovered by lower-level protocols such as Inverse ARP ([Ref14]) ๐
C.7 Host route parameters ๐
Host routes get advertised in router-LSAs as stub networks with mask 0xffffffff. They show up for router interfaces to point-to-point networks, looped router interfaces, or IP hosts directly connected to the router (for example, over a SLIP line) ๐ For each host directly connected to the router, the following items must be configured:
Host IP address : The IP address of the host.
Cost of link to host : The cost of sending a packet to the host, in terms of the link state metric. Since the host probably has only one connection to the internet, though, the configured cost is often unimportant, meaning it won't affect routing at all ๐ฅน
Area ID : The OSPF area the host belongs to.
D. Authentication ๐
All OSPF protocol exchanges are authenticated, no cap ๐ The OSPF packet header (see Section A.3.1) has an authentication type field, plus 64-bits of data for whatever authentication scheme the type field picks ๐
The authentication type is configurable per interface (or equivalently, per network/subnet). Extra authentication data is also configurable per interface ๐
Authentication types 0, 1 and 2 are defined by this specification. Every other authentication type is reserved for definition by the IANA (iana@ISI.EDU). The current list of authentication types is in Table 20 below โจ
AuType Description
___________________________________________
0 Null authentication
1 Simple password
2 Cryptographic authentication
All others Reserved for assignment by the
IANA (iana@ISI.EDU)
Table 20: OSPF authentication types.
D.1 Null authentication ๐
Using this type means routing exchanges over the network/subnet aren't authenticated at all ๐ The 64-bit authentication field in the OSPF header can hold anything, and it isn't checked on reception. With Null authentication, the whole OSPF packet (except the 64-bit authentication field) still gets checksummed to catch data corruption ๐ซถ
D.2 Simple password authentication ๐
With this type, a 64-bit field is configured per network. Every packet sent on that network has to carry this value in its OSPF header 64-bit authentication field. It's basically a "clear" 64-bit password ๐ธ The whole OSPF packet (except the 64-bit authentication field) is checksummed too, to catch data corruption.
Simple password authentication keeps routers from accidentally joining the routing domain. Each router has to get its attached networks' passwords configured before it can take part in routing ๐ง BUT, and this is a big but, simple password authentication is vulnerable to passive attacks that are super widespread on the Internet (see [Ref16]). Anyone with physical access to the network can learn the password and compromise the security of the OSPF routing domain ๐ญ๐ฅ
D.3 Cryptographic authentication ๐ก๏ธ
With this type, a shared secret key is configured on all routers attached to a common network/subnet. For each OSPF protocol packet, the key is used to generate or verify a "message digest" that gets appended to the end of the OSPF packet. The message digest is a one-way function of the OSPF protocol packet and the secret key ๐ The secret key is never sent over the network in the clear, so you get protection against passive attacks. iconic ๐ฆ
The algorithms used to generate and verify the message digest are specified implicitly by the secret key. This specification completely defines the use of OSPF Cryptographic authentication when the MD5 algorithm is used ๐
A non-decreasing sequence number is also included in each OSPF protocol packet to protect against replay attacks. That's long-term protection, but it's still possible to replay an OSPF packet until the sequence number changes ๐ฅบ To pull this off, each neighbor data structure contains a new field called the "cryptographic sequence number". This field is initialized to zero, and it's also set back to zero whenever the neighbor's state transitions to "Down". Whenever an OSPF packet is accepted as authentic, the cryptographic sequence number gets set to the received packet's sequence number โจ
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| 0 | Key ID | Auth Data Len |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Cryptographic sequence number |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Figure 18: Usage of the Authentication field
in the OSPF packet header when Cryptographic
Authentication is employed
This specification does NOT provide a rollover procedure for the cryptographic sequence number ๐ฌ When the sequence number a router is sending hits the maximum value, the router should reset the number it's sending back to 0. After that happens, the router's neighbors will reject its OSPF packets for a period of RouterDeadInterval, and then the router will be forced to re-establish all adjacencies over the interface. HOWEVER, many implementations are expected to use "seconds since reboot" (or "seconds since 1960", etc.) as the cryptographic sequence number ๐ That choice essentially prevents rollover, since the cryptographic sequence number field is 32 bits long โญ
The OSPF Cryptographic authentication option does not provide confidentiality ๐
When cryptographic authentication is used, the 64-bit Authentication field in the standard OSPF packet header gets redefined as shown in Figure 18. The new field definitions are:
Key ID : This field identifies the algorithm and secret key used to create the message digest appended to the OSPF packet. Key Identifiers are unique per interface (or equivalently, per subnet) ๐
Auth Data Len : The length in bytes of the message digest appended to the OSPF packet.
Cryptographic sequence number : An unsigned 32-bit non-decreasing sequence number. Used to guard against replay attacks ๐
The message digest appended to the OSPF packet isn't actually considered part of the OSPF protocol packet. It isn't included in the OSPF header's packet length, although it is included in the packet's IP header length field ๐ง
Each key is identified by the combination of interface and Key ID. An interface may have multiple keys active at any one time, which enables a smooth transition from one key to another ๐ฆ Each key has four time constants associated with it. These can be expressed in terms of a time-of-day clock, or in terms of a router's local clock (for example, number of seconds since last reboot) โฐ
KeyStartAccept : The time the router will start accepting packets that have been created with the given key.
KeyStartGenerate : The time the router will start using the key for packet generation.
KeyStopGenerate : The time the router will stop using the key for packet generation.
KeyStopAccept : The time the router will stop accepting packets that have been created with the given key.
For smooth key transition, KeyStartAccept should be less than KeyStartGenerate, and KeyStopGenerate should be less than KeyStopAccept ๐ธ If KeyStopGenerate and KeyStopAccept are left unspecified, the key's lifetime is infinite. When a new key replaces an old one, the KeyStartGenerate time for the new key must be less than or equal to the KeyStopGenerate time of the old key ๐
Key storage should persist across a system restart, warm or cold, to avoid operational issues. If the last key associated with an interface expires, it's unacceptable to revert to an unauthenticated condition, and it's not advisable to disrupt routing either ๐ญ So the router should send a "last authentication key expiration" notification to the network manager, and treat the key as having an infinite lifetime until the lifetime is extended, the key is deleted by network management, or a new key is configured ๐ซถ
D.4 Message generation โ๏ธ
After building the contents of an OSPF packet, the authentication procedure indicated by the sending interface's Autype value is called before the packet is sent. The authentication procedure modifies the OSPF packet as follows.
D.4.1 Generating Null authentication โจ
okay so when you're using Null authentication, the packet gets modified like this ๐
- The Autype field in the standard OSPF header is set to
0. - The checksum field in the standard OSPF header is set to the standard IP checksum of the entire contents of the packet, starting with the OSPF packet header but excluding the 64-bit authentication field. This checksum is calculated as the 16-bit one's complement of the one's complement sum of all the 16-bit words in the packet, excepting the authentication field. If the packet's length is not an integral number of 16-bit words, the packet is padded with a byte of zero before checksumming. ๐ซถ
D.4.2 Generating Simple password authentication ๐
bestie, Simple password authentication is giving the same vibe, just with a password glow-up ๐
- The Autype field in the standard OSPF header is set to
1. - The checksum field in the standard OSPF header is set to the standard IP checksum of the entire contents of the packet, starting with the OSPF packet header but excluding the 64-bit authentication field. This checksum is calculated as the 16-bit one's complement of the one's complement sum of all the 16-bit words in the packet, excepting the authentication field. If the packet's length is not an integral number of 16-bit words, the packet is padded with a byte of zero before checksumming.
- The 64-bit authentication field in the OSPF packet header is set to the 64-bit password (i.e., authentication key) that has been configured for the interface. ๐
D.4.3 Generating Cryptographic authentication ๐ฅ
okay this one is the main character ๐ When you're using Cryptographic authentication, there may be multiple keys configured for the interface. In that case, among the keys that are valid for message generation (i.e, that have KeyStartGenerate <= current time < KeyStopGenerate), you choose the one with the most recent KeyStartGenerate time. Using that key, you modify the packet like so:
- The Autype field in the standard OSPF header is set to
2. - The checksum field in the standard OSPF header is not calculated, but is instead set to
0. ๐ - The Key ID (see Figure 18) is set to the chosen key's Key ID.
- The Auth Data Len field is set to the length in bytes of the message digest that will be appended to the OSPF packet. When using MD5 as the authentication algorithm, Auth Data Len will be
16. - The 32-bit Cryptographic sequence number (see Figure 18) is set to a non-decreasing value (i.e., a value at least as large as the last value sent out the interface). The precise values to use in the cryptographic sequence number field are implementation-specific. For example, it may be based on a simple counter, or be based on the system's clock. โฐ
- The message digest is then calculated and appended to the OSPF packet. The authentication algorithm to be used in calculating the digest is indicated by the key itself. Input to the authentication algorithm consists of the OSPF packet and the secret key. When using MD5 as the authentication algorithm, the message digest calculation proceeds as follows:
- (a) The 16 byte MD5 key is appended to the OSPF packet.
- (b) Trailing pad and length fields are added, as specified in [Ref17].
- (c) The MD5 authentication algorithm is run over the concatenation of the OSPF packet, secret key, pad and length fields, producing a 16 byte message digest (see [Ref17]).
- (d) The MD5 digest is written over the OSPF key (i.e., appended to the original OSPF packet). The digest is not counted in the OSPF packet's length field, but is included in the packet's IP length field. Any trailing pad or length fields beyond the digest are not counted or transmitted. ๐ง
D.5 Message verification ๐
okay the receiving side has to be just as iconic When an OSPF packet has been received on an interface, it must be authenticated. The authentication procedure is indicated by the setting of Autype in the standard OSPF packet header, which matches the setting of Autype for the receiving OSPF interface.
If an OSPF protocol packet is accepted as authentic, processing of the packet continues as specified in Section 8.2. Packets which fail authentication are discarded. ๐ซ
D.5.1 Verifying Null authentication ๐ธ
When using Null authentication, the checksum field in the OSPF header must be verified. It must be set to the 16-bit one's complement of the one's complement sum of all the 16-bit words in the packet, excepting the authentication field. (If the packet's length is not an integral number of 16-bit words, the packet is padded with a byte of zero before checksumming.)
D.5.2 Verifying Simple password authentication ๐ฆ
When using Simple password authentication, the received OSPF packet is authenticated as follows:
- The checksum field in the OSPF header must be verified. It must be set to the 16-bit one's complement of the one's complement sum of all the 16-bit words in the packet, excepting the authentication field. (If the packet's length is not an integral number of 16-bit words, the packet is padded with a byte of zero before checksumming.)
- The 64-bit authentication field in the OSPF packet header must be equal to the 64-bit password (i.e., authentication key) that has been configured for the interface. ๐
D.5.3 Verifying Cryptographic authentication ๐
When using Cryptographic authentication, the received OSPF packet is authenticated as follows:
- Locate the receiving interface's configured key having Key ID equal to that specified in the received OSPF packet (see Figure 18). If the key is not found, or if the key is not valid for reception (i.e.,
current time < KeyStartAcceptorcurrent time >= KeyStopAccept), the OSPF packet is discarded. ๐๏ธ - If the cryptographic sequence number found in the OSPF header (see Figure 18) is less than the cryptographic sequence number recorded in the sending neighbor's data structure, the OSPF packet is discarded.
- Verify the appended message digest in the following steps:
- (a) The received digest is set aside.
- (b) A new digest is calculated, as specified in Step 6 of Section D.4.3.
- (c) The calculated and received digests are compared. If they do not match, the OSPF packet is discarded. If they do match, the OSPF protocol packet is accepted as authentic, and the "cryptographic sequence number" in the neighbor's data structure is set to the sequence number found in the packet's OSPF header. ๐
E. An algorithm for assigning Link State IDs ๐ง
okay so the Link State ID in AS-external-LSAs and summary-LSAs is usually set to the described network's IP address. However, if necessary, one or more of the network's host bits may be set in the Link State ID. This lets the router originate separate LSAs for networks having the same address, yet different masks. Such networks can occur in the presence of supernetting and subnet 0s (see [Ref10]). ๐
This appendix gives one possible algorithm for setting the host bits in Link State IDs. Choosing such an algorithm is a local decision. Separate routers are free to use different algorithms, since the only LSAs affected are the ones that the router itself originates. The only requirement on the algorithms used is that the network's IP address should be used as the Link State ID whenever possible. This maximizes interoperability with OSPF implementations predating RFC 1583. โจ
The algorithm below is stated for AS-external-LSAs. This is only for clarity; the exact same algorithm can be used for summary-LSAs. Suppose that the router wishes to originate an AS-external-LSA for a network having address NA and mask NM1. The following steps are then used to determine the LSA's Link State ID:
- Determine whether the router is already originating an AS-external-LSA with Link State ID equal to
NA(in such an LSA the router itself will be listed as the LSA's Advertising Router). If not, the Link State ID is set equal toNAand the algorithm terminates. Otherwise, - Obtain the network mask from the body of the already existing AS-external-LSA. Call this mask
NM2. There are then two cases:NM1is longer (i.e., more specific) thanNM2. In this case, set the Link State ID in the new LSA to be the network[NA,NM1]with all the host bits set (i.e.,NAor'ed together with all the bits that are not set inNM1, which is network[NA,NM1]'s broadcast address).NM2is longer thanNM1. In this case, change the existing LSA (having Link State ID ofNA) to reference the new network[NA,NM1]by incrementing the sequence number, changing the mask in the body toNM1and inserting the cost of the new network. Then originate a new LSA for the old network[NA,NM2], with Link State ID equal toNAor'ed together with the bits that are not set inNM2(i.e., network[NA,NM2]'s broadcast address).
The above algorithm assumes that all masks are contiguous. This ensures that when two networks have the same address, one mask is more specific than the other. The algorithm also assumes that no network exists having an address equal to another network's broadcast address. Given these two assumptions, the above algorithm always produces unique Link State IDs. The above algorithm can also be reworded as follows: When originating an AS-external-LSA, try to use the network number as the Link State ID. If that produces a conflict, examine the two networks in conflict. One will be a subset of the other. For the less specific network, use the network number as the Link State ID, and for the more specific use the network's broadcast address instead (i.e., flip all the "host" bits to 1). If the most specific network was originated first, this will cause you to originate two LSAs at once. ๐
As an example of the algorithm, consider its operation when the following sequence of events occurs in a single router (Router A).
- Router A wants to originate an AS-external-LSA for
[10.0.0.0,255.255.255.0]:- (a) A Link State ID of
10.0.0.0is used.
- (a) A Link State ID of
- Router A then wants to originate an AS-external-LSA for
[10.0.0.0,255.255.0.0]:- (a) The LSA for
[10.0.0,0,255.255.255.0]is reoriginated using a new Link State ID of10.0.0.255. - (b) A Link State ID of
10.0.0.0is used for[10.0.0.0,255.255.0.0].
- (a) The LSA for
- Router A then wants to originate an AS-external-LSA for
[10.0.0.0,255.0.0.0]:- (a) The LSA for
[10.0.0.0,255.255.0.0]is reoriginated using a new Link State ID of10.0.255.255. - (b) A Link State ID of
10.0.0.0is used for[10.0.0.0,255.0.0.0]. - (c) The network
[10.0.0.0,255.255.255.0]keeps its Link State ID of10.0.0.255. ๐
- (a) The LSA for
F. Multiple interfaces to the same network/subnet โจ
okay so bestie, there are at least two ways to support multiple physical interfaces on the same IP subnet ๐ฆ Both methods will interoperate with implementations of RFC 1583 (and of course this memo) ๐ The two methods are sketched briefly below. We're assuming each interface has been given its own separate IP address. (Otherwise supporting multiple interfaces is more of a link-level or ARP issue than an OSPF issue, and that's a different vibe entirely ๐)
Method 1:
Run the entire OSPF functionality over both interfaces. That means sending and receiving hellos, flooding, and supporting separate interface and neighbor FSMs for each interface, etc. ๐ When you do this, all the other routers on the subnet will treat the two interfaces as separate neighbors, because on broadcast and NBMA networks, neighbors are identified by their IP address.
Method 1 has the following disadvantages:
- You increase the total number of neighbors and adjacencies.
- You lose the bidirectionality test on both interfaces, since bidirectionality is based on Router ID. ๐ญ
- You have to consider both interfaces together during the Designated Router election. If you declare both to be DR at the same time, you can confuse the tie-breaker, which is Router ID ๐
Method 2:
Run OSPF over only one interface (call it the primary interface), but include both the primary and secondary interfaces in your Router-LSA. โจ Simple, clean, iconic.
Method 2 has the following disadvantages:
- You lose the bidirectionality test on the secondary interface.
- When the primary interface fails, you need to promote the secondary interface to primary status. ๐ฅบ
G. Differences from RFC 1583 ๐
this section is where we spill all the tea on how this memo differs from RFC 1583 ๐ซถ The good news is that every single difference is backward-compatible, so implementations of this memo and of RFC 1583 will interoperate. no drama ๐
G.1 Enhancements to OSPF authentication
an extra OSPF authentication type got added: the Cryptographic authentication type ๐ It's defined so that any arbitrary "Keyed Message Digest" algorithm can be used for packet authentication. The MD5 algorithm is fully specified (see Appendix D), so that one is the main character ๐
A bunch of other changes were also made to OSPF packet authentication, affecting the following Sections:
- The authentication type is now specified per-interface, rather than per-area (Sections 6, 9, C.2 and C.3). ๐ธ
- The OSPF packet header checksum is now considered part of the authentication procedure. So it has been moved out of the packet send and receive logic (Sections 8.1 and 8.2) and into the description of authentication types (Appendix D). It's giving organization ๐ง
- In Appendix D, sections detailing message generation and message verification have been added. โจ
- For the OSPF Cryptographic authentication type, there's now a discussion of key management added to Appendix D. This includes the requirement for simultaneous support of multiple keys, key lifetimes and smooth key transition. obsessed ๐ญ
G.2 Addition of Point-to-MultiPoint interface
this memo adds another way to run OSPF over non-broadcast networks: the Point-to-Multipoint network ๐ฆ To make that work, the language of RFC 1583 got tweaked a little. References to "multi-access" networks have been deleted. Now "non-broadcast networks" is the term used for networks that can connect many routers but don't natively support broadcast/multicast (like a public Frame relay network) ๐
Over non-broadcast networks, you've got two options for running OSPF: modelling them as "NBMA networks" or as "Point-to-MultiPoint networks". NBMA networks require full mesh connectivity between routers. If you're using NBMA networks with partial mesh connectivity, you have to configure multiple NBMA networks, as described in [Ref15]. Point-to-Multipoint networks, on the other hand, were designed to work simply and naturally when there's partial mesh connectivity. ๐
The addition of Point-to-MultiPoint networks impacted the text in a lot of places. Here's the quick summary:
- Section 2, which describes the OSPF link-state database, got split into additional subsections. One of them (Section 2.1.1) describes the differing map representations of the two non-broadcast network options. It also contrasts NBMA and Point-to-MultiPoint networks and describes when one is preferable to the other. ๐
- Compared to NBMA networks, Point-to-MultiPoint networks have these properties:
- Adjacencies are established between all neighboring routers (Sections 4, 7.1, 7.5, 9.5 and 10.4).
- There is no Designated Router or Backup Designated Router for a Point-to-MultiPoint network (Sections 7.3 and 7.4). ๐
- No network-LSA is originated for Point-to-MultiPoint networks (Sections 12.4.2 and A.4.3).
- Router Priority is not configured for Point-to-MultiPoint interfaces, nor for neighbors on Point-to-MultiPoint networks (Sections C.3 and C.6).
- The Interface FSM for a Point-to-MultiPoint interface is identical to the one used for point-to-point interfaces. Two states are possible: "Down" and "Point-to-Point" (Section 9.3). so simple, I'm obsessed ๐ซถ
- When originating a router-LSA, a Point-to-MultiPoint interface is reported as a collection of "point-to-point links" to all of the interface's adjacent neighbors. It also comes with a single stub link advertising the interface's IP address with a cost of 0 (Section 12.4.1.4). โจ
- When flooding out a non-broadcast interface (whether it's in NBMA or Point-to-MultiPoint mode), the Link State Update or Link State Acknowledgment packet must be replicated so it gets sent to each of the interface's neighbors (see Sections 13.3 and 13.5). This one is a must-do, bestie ๐ฅ
G.3 Support for overlapping area ranges
RFC 1583 requires that all networks falling into a given area range actually belong to a single area. This memo relaxes that restriction ๐ธ Here's a good example of why that's useful. Suppose [10.0.0.0, 255.0.0.0] is carved up into subnets. Most of those subnets are assigned to a single OSPF area (call it Area X), and a few are assigned to other areas.
To get this setup working with RFC 1583, you can't summarize the Area X subnets with the single range [10.0.0.0, 255.0.0.0]. If you did, the subnets of 10.0.0.0 that belong to other areas would become unreachable ๐ญ But with this memo, you can summarize the subnets in Area X, as long as the subnets belonging to other areas are not summarized. the way that makes sense ๐ง
Implementation details for this change can be found in Sections 11.1 and 16.2.
G.4 A modification to the flooding algorithm
the OSPF flooding algorithm got a glow-up ๐ When a Link State Update Packet arrives containing an LSA instance that's actually less recent than the router's current database copy, the router will now, in most cases, respond by flooding back its database copy. In RFC 1583, the router just threw the received LSA away. Hard pass, now ๐ โโ๏ธ
The detailed description of the change is in Step 8 of Section 13.
This change improves MaxAge processing, and honestly it was needed ๐ญ Sometimes MaxAge LSAs hang around in a router's database for ages. This happens 1) when they're stuck in a retransmission queue on a slow link, or 2) when a router isn't properly flushing them from its database because of software bugs. Those lingering MaxAge LSAs can block the flooding of new instances of the LSA. New instances usually start with an LS sequence number equal to InitialSequenceNumber. Routers still holding MaxAge instances treat them as less recent, so under RFC 1583 they were discarded. ๐
With the flooding change above, a router holding a MaxAge instance floods the MaxAge instance back. When that flood reaches the LSA's originator, the originator picks the next highest LS sequence number and reflloods, overwriting the MaxAge instance. Main character energy from the originator, no cap ๐
G.5 Introduction of the MinLSArrival constant
OSPF limits how often new instances of any particular LSA can be accepted during flooding ๐ซถ This is extra protection, just in case a neighboring router is violating the mandated limit on LSA (re)originations. That limit is one per LSA in any MinLSInterval.
In RFC 1583, the frequency at which new LSA instances were accepted was also set equal to once every MinLSInterval seconds. But in some circumstances, this led to unwanted link state retransmissions, even when the LSA originator was obeying the MinLSInterval limit on originations. The cause was either 1) the choice of clock granularity in some OSPF implementations, or 2) differing clock speeds in neighboring routers. ๐
To fix this, the frequency at which new LSA instances are accepted during flooding has been increased to once every MinLSArrival seconds, and MinLSArrival is set to 1 ๐ This change is reflected in Steps 5a and 5d of Section 13, and in Appendix B. โจ
G.6 Optionally advertising point-to-point links as subnets
When describing a point-to-point interface in its router-LSA, a router may now advertise a stub link to the point-to-point network's subnet ๐ฆ This is an alternative to the RFC 1583 behavior, which was to advertise a stub link to the neighbor's IP address. See Sections 12.4.1 and 12.4.1.1 for details. It's your call, bestie ๐
G.7 Advertising same external route from multiple areas
Okay bestie, this one is a fix for routing loops ๐ that could happen in RFC 1583 when the same external destination gets advertised by AS boundary routers sitting in separate areas. There are two different ways this went wrong ๐ญ
The first one was spotted by Dennis Ferguson ๐. It happens when an aggregated forwarding address is in use. The desirability of that forwarding address can get worse as a packet crosses an area aggregation boundary on its way there. That can change the preference of the AS-external-LSAs, and boom, routing loop ๐
The second one was found by Richard Woundy ๐ง . It comes from OSPF only applying its preference for intra-area routes over inter-area routes halfway. Paths to one specific ASBR/forwarding address get picked by intra-area preference first, but when you compare different ASBRs/forwarding addresses, only cost matters and the intra-area preference gets ignored. Richard's example is shown in Figure 19 ๐ฆ. Router A3 and router B3 are both originating an AS-external-LSA for 10.0.0.0/8, with the same type 2 metric. Router A1 picks B1 as its next hop toward 10.0.0.0/8 because the route to ASBR B3 through B1->B2->B3 is cheaper. But B1 can't actually use that shorter route, since it prefers its (more expensive) intra-area route to B3 through Area A. So B1 turns around and picks A1 as its next hop to 10.0.0.0/8, and now you have a routing loop ๐๐ฑ
To stop these loops, two changes were made ๐:
- When originating a type 3 summary-LSA for a configured area address range, the cost of the summary-LSA is now set to the maximum cost of the range's component networks. Before, the algorithm used the minimum component cost instead. This change affects Sections 3.5 and 12.4.3, Figures 7 and 8, and Tables 6 and 13.
- The preference rules for choosing among multiple AS-external-LSAs got a glow-up โจ. Before, cost was the only thing that mattered. Now the preference is driven first by the type of path to the ASBR/forwarding address (intra-area or inter-area, and through a non-backbone area or through the backbone), and cost is only used to break ties. This change affects Sections 16.4 and 16.4.1.
Once this change is in, the Figure 19 example works out differently. Router A1 now chooses A3 as its next hop to 10.0.0.0/8, and B1 chooses B3 ๐. The reason is that ASBRs/forwarding addresses are chosen based on intra-area preference first, and then by cost.
10.0.0.0/8
----------
|
+----+
| XX |
+----+
RIP / \ RIP
--------------------- --------------------
! !
! !
+----+ +----+ 1 +----+......+----+....
| A3 |------| A1 |---------------| B1 |------| B3 | .
+----+ 6 +----+ +----+ 8 +----+ .
1| . / .
OSPF backbone | . / .
+----+ 2 / .
| B2 |------- Area A.
+----+................
Figure 19: Example routing loop when the
same external route is advertised from multiple
areas
Now here's the tea โ. This change is not backward compatible ๐ฌ. It stops the loops when every router runs the new preference rules, but if some routers use the new rules and others still run RFC 1583, it can actually create routing loops ๐. Because of that, there's a new configuration parameter called RFC1583Compatibility. The new preference rules only kick in when RFC1583Compatibility is set to "disabled" ๐ซถ. See Appendix C for more details.
G.8 Retransmission of initial Database Description packets
This memo lets you retransmit initial Database Description packets without resetting the state of the adjacency ๐ธ. Honestly, in some environments retransmitting the initial Database Description packet is just unavoidable ๐ฉ. For example, the link delay on a satellite link might be longer than the RxmtInterval you configured for an interface ๐ฐ๏ธ. In RFC 1583, that kind of environment means a full adjacency can never form at all, which is so sad ๐.
To fix this, changes were made to how Database Description packets get received, so retransmitted initial ones are treated exactly the same as any other retransmitted Database Description packets โจ. See Section 10.6 for details.
G.9 Detecting interface MTU mismatches
When two neighboring routers have different interface MTUs on their shared network segment, things get messy fast ๐. Big packets can't make it from one router to the other, which hurts OSPF's flooding algorithm and can create "black holes" ๐ณ๏ธ where user data traffic just disappears.
This memo fixes the MTU mismatch problem by advertising the interface MTU inside Database Description packets ๐ฆ. When a router gets a Database Description packet advertising an MTU bigger than the router can receive, it drops that packet. That stops the adjacency from forming, which tells OSPF flooding and user data traffic to steer clear of that connection between the two routers ๐ โโ๏ธ. For more information, see Sections 10.6, 10.8, and A.3.3.
G.10 Deleting the TOS routing option
The TOS routing option is gone from OSPF ๐. The Internet standards process ([Ref24]) required this, because there just wasn't enough implementation experience with OSPF's TOS routing ๐. But for backward compatibility, the formats of OSPF's various LSAs stayed the same ๐. So you can still specify TOS metrics in router-LSAs, summary-LSAs, ASBR-summary-LSAs, and AS-external-LSAs (see Sections 12.3, A.4.2, A.4.4, and A.4.5).
If you want to nerd out on OSPF's original TOS routing design, check out [Ref9] ๐ค๐.
Security Considerations
Okay, this part is SERIOUS ๐จ, so read it carefully bestie ๐ซถ. All OSPF protocol exchanges are authenticated ๐. OSPF supports multiple types of authentication, and you can configure which type is in use on a per network segment basis. One of them, the Cryptographic authentication option, is believed to be secure against passive attacks and to give significant protection against active attacks ๐ก๏ธ. When you use the Cryptographic authentication option, each router appends a "message digest" to its transmitted OSPF packets. Receivers then use the shared secret key and the received digest to verify that each OSPF packet is authentic โ .
The quality of the security from the Cryptographic authentication option depends completely on three things ๐ค: the strength of the message digest algorithm (MD5 is currently the only message digest algorithm specified), the strength of the key being used, and whether the security mechanism is implemented correctly in all communicating OSPF implementations. It also requires that every party keeps the shared secret key secret ๐คซ.
None of the OSPF authentication types provide confidentiality ๐ โโ๏ธ. They also don't protect against traffic analysis. Key management is not addressed by this memo either ๐.
For more information, see Sections 8.1, 8.2, and Appendix D ๐.
Author's Address
John Moy ๐ฆ Cascade Communications Corp. 5 Carlisle Road Westford, MA 01886
Phone: 508-952-1367 Fax: 508-692-9214 Email: jmoy@casc.com
๐ฆ where this page comes from
- ietf: rfc2178 1997-07
- ๐ girlified by claude-haiku-5-5 on : a language model's rewrite of the original, under its terms