RFC 2178

OSPF Version 2

๐Ÿ“… published July 1997, from ietf

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 as 255.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 ๐Ÿงฑ.

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 ๐Ÿ”ฅ

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 ๐Ÿงš๐Ÿ’œ

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 to 2, 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 ๐Ÿ’œ
  • AuType and Authentication: 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. AuType tells 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 AllSPFRouters or AllDRouters.
  • 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 event 1-WayReceived, and the processing of the packet stops ๐Ÿ›‘.
  • Next, the Hello Packet's Router Priority field 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 event NeighborChange. In any case, the Router Priority field in the neighbor data structure SHOULD be updated accordingly ๐Ÿ“.
  • Next the Designated Router field in the Hello Packet is examined. If the neighbor is both declaring itself to be Designated Router (Designated Router field = Neighbor IP address) and the Backup Designated Router field in the packet is equal to 0.0.0.0 and the receiving interface is in state Waiting, the receiving interface's state machine is scheduled with the event BackupSeen ๐Ÿ™Œ. 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 event NeighborChange ๐Ÿ”ฅ. In any case, the Neighbors' Designated Router item in the neighbor structure is updated accordingly.
  • Finally, the Backup Designated Router field in the Hello Packet is examined. If the neighbor is declaring itself to be Backup Designated Router (Backup Designated Router field = Neighbor IP address) and the receiving interface is in state Waiting, the receiving interface's state machine is scheduled with the event BackupSeen ๐ŸŽ€. 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 event NeighborChange ๐ŸŒˆ. 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) and master(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) and master(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 SeqNumberMismatch and stop processing the packet ๐Ÿ’€.
  • if the initialize(I) bit is set, generate the neighbor event SeqNumberMismatch and stop processing the packet.
  • if the packet's Options field 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 event SeqNumberMismatch and 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 SeqNumberMismatch and 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 ๐Ÿฅ‡.


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 ๐Ÿ’ฅ.

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.

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 โœจ

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.


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, its LS sequence number is incremented, its LS age is set to 0, its LS checksum is 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) ๐Ÿ˜ญ

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 Exchange or Loading), 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) ๐Ÿ’€.

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 ๐Ÿงน


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.

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 ๐Ÿซถ

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:

  1. 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. ๐Ÿ™ˆ
  2. If the LSA was originated by the calculating router itself, examine the next LSA. ๐Ÿ’€
  3. 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. ๐ŸŒธ
  4. 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. ๐Ÿงš
  5. 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. ๐Ÿ‘‘
  6. Else, if the paths present in the table are intra-area paths, do nothing with the LSA (intra-area paths are always preferred). ๐Ÿ’œ
  7. 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.

  1. 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. ๐Ÿ“
  2. If the summary-LSA was originated by the calculating router itself, examine the next LSA. ๐ŸŽ€
  3. 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. ๐ŸŒธ
  4. 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. ๐Ÿงฎ
  5. 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 RFC1583Compatibility is 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 ๐Ÿ˜ญ

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) โœจ

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 ๐Ÿงš.

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 0xff000000 would 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 0xff000000 would 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 value LSRefreshTime, 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 of LSRefreshTime is set to 30 minutes โฐ
  • MinLSInterval: the minimum time between distinct originations of any particular LSA. the value of MinLSInterval is 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 of MinLSArrival is set to 1 second ๐Ÿ™ˆ
  • MaxAge: the maximum age that an LSA can attain. when an LSA's LS age field reaches MaxAge, it is reflooded in an attempt to flush the LSA from the routing domain (see Section 14). LSAs of age MaxAge are not used in the routing table calculation. the value of MaxAge is set to 1 hour ๐Ÿ”ฅ
  • CheckAge: when the age of an LSA in the link state database hits a multiple of CheckAge, the LSA's checksum is verified. an incorrect checksum at this time indicates a serious error. the value of CheckAge is 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 of MaxAgeDiff is 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 address 0.0.0.0. its associated Network Mask is also always 0.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 integer 0x80000001 ๐Ÿ’œ
  • MaxSequenceNumber: the maximum value that LS Sequence Number can attain. its value is the signed 32-bit integer 0x7fffffff ๐Ÿซถ

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.


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 ๐Ÿ’…

  1. The Autype field in the standard OSPF header is set to 0.
  2. 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 ๐Ÿ”

  1. The Autype field in the standard OSPF header is set to 1.
  2. 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.
  3. 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:

  1. The Autype field in the standard OSPF header is set to 2.
  2. The checksum field in the standard OSPF header is not calculated, but is instead set to 0. ๐Ÿ™ˆ
  3. The Key ID (see Figure 18) is set to the chosen key's Key ID.
  4. 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.
  5. 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. โฐ
  6. 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:

  1. 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.)
  2. 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:

  1. 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 < KeyStartAccept or current time >= KeyStopAccept), the OSPF packet is discarded. ๐Ÿ—‘๏ธ
  2. 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.
  3. 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. ๐ŸŽ‰

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:

  1. 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 to NA and the algorithm terminates. Otherwise,
  2. Obtain the network mask from the body of the already existing AS-external-LSA. Call this mask NM2. There are then two cases:
    • NM1 is longer (i.e., more specific) than NM2. 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., NA or'ed together with all the bits that are not set in NM1, which is network [NA,NM1]'s broadcast address).
    • NM2 is longer than NM1. In this case, change the existing LSA (having Link State ID of NA) to reference the new network [NA,NM1] by incrementing the sequence number, changing the mask in the body to NM1 and inserting the cost of the new network. Then originate a new LSA for the old network [NA,NM2], with Link State ID equal to NA or'ed together with the bits that are not set in NM2 (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).

  1. 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.0 is used.
  2. 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 of 10.0.0.255.
    • (b) A Link State ID of 10.0.0.0 is used for [10.0.0.0,255.255.0.0].
  3. 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 of 10.0.255.255.
    • (b) A Link State ID of 10.0.0.0 is 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 of 10.0.0.255. ๐Ÿ’…

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:

  1. You increase the total number of neighbors and adjacencies.
  2. You lose the bidirectionality test on both interfaces, since bidirectionality is based on Router ID. ๐Ÿ˜ญ
  3. 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:

  1. You lose the bidirectionality test on the secondary interface.
  2. 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. โœจ

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