Monday, February 9, 2015

CCIE OCG: OSPF (Chapter 9), Part II

OSPF Design and LSAs

  • Most OSPF design choices directly impact the LSA types in a network and impose restrictions on which neighbors can exchange those LSAs.

OSPF Design Terms

  • Area Border Routers (ABRs) = Routers that connect to different areas.
  • ABRs must connect to area 0, the backbone area, and to one or more other areas.
  • Only a router that is actively attached to multiple areas, including the backbone area, considers itself an ABR and performs the appropriate functions.
  • A router actively attached to multiple areas but not to the backbone area does not consider itself an ABR and does not act like one.
  • Autonomous System Boundary Routers (ASBRs) inject external routes into the OSPF domain.
  • OSPF keeps an independent and separate LSDB for each area to which it is connected.
  • By default, the contents of per-area LSDBs are completely isolated. One LSDB does not leak into another.
  • Only the ABR can translate and carry information between the areas in a controlled way.
  • The SPF is run in each LSDB separately, and the results are combined into the routing table subject to the OSPF path preference rules.
  • Using OSPF areas provides the following benefits:
  1. Generally smaller per-area LSDBs, requiring less memory.
  2. Faster SPF computation.
  3. A link failure in one area only requires a partial SPF computation in other areas.
  4. Routes can be summarized and filtered only at ABRs.
  • The number of routers and subnet does not shrink in multiarea OSPF design, but the LSDB does.
  • An ABR does not pass denser and more detailed Type 1 and 2 LSAs between areas - instead, Type 3 LSAs are passed.

OSPF Path Selection Process

  • OSPF always chooses an intra-area route over an inter-area route for the same prefix, regardless of metric.
  • ABRs ignore Type 3 LSAs learned in a non-backbone area during SPF calculation.


LSA Types

  • Only a router that has originated a particular LSA is allowed to modify or withdraw it.
  • Other routers must process and flood this LSA, but they must never change its contents, block it, or drop it before its maximum lifetime has expired.
  • This makes sure that all routers in an area have the same LSDB contents and the same view of the network.
  • Summarization and route filtering can be done in very limited fashion vs. distance vector protocols where these functions can be performed at any point in the network.

Type 1 LSA - Router

  • One per router per area, listing the router's RID and all interface IP addresses in that area.
  • Represents stub networks as well.
  • Flooded only within its area of origin.

Type 2 LSA - Network

  • One per transit network.
  • Created by the DR on the subnet, and represents the subnet and the router interfaces connected to the subnet.
  • Flooded only within its area of origin.

Type 3 LSA - Net Summary

  • Created by ABRs to represent networks in one area when advertised into another area.
  • Defines the subnets in the origin area, and cost, but no topology data.
  • Flooded only within its area of origin; reoriginated on ABRs.

Type 4 LSA - ASBR Summary

  • Like Type 3 LSA, except it advertises a host route used to reach an ASBR.
  • Flooded only within its area of origin; reoriginated on ABRs.

Type 5 LSA - External

  • Created by ASBRs for external routes injected into OSPF.
  • Flooded to all regular areas.

Type 6 LSA - Group Membership

  • Defined for MOSPF.
  • Not supported by Cisco IOS.

Type 7 LSA - NSSA External

  • Created by ASBRs inside an NSSA, instead of a Type 5 LSA.
  • Flooded only within its area of origin; converted to Type 5 LSA on an ABR toward other areas.

Type 8 - External Attributes

  • Created by ASBRs during BGP-to-OSPF redistribution to preserve BGP attributes of redistributed networks.
  • Not implemented in Cisco routers.

Type 9-11 LSAs - Opaque

  • Used as generic LSAs to allow for easy future extension of OSPF. For example, Type 10 LSA has been adapted for MPLS traffic engineering.
  • These LSAs have different flooding scope: Type 9 has link-local flooding scope, Type 10 has area-local flooding scope, and Type 11 has autonomous system flooding scope equivalent to the flooding scope of Type 5 LSAs (not flooded into stubby areas or NSSAs).

  • Transit network: A network over which two or more OSPF routers have become
    neighbors and elected a DR so that traffic can transit from one to the other.
  • Stub network: A subnet on which a router has not formed any neighbor relationships.


LSA Types 1 and 2

  • Each router creates and floods a Type 1 LSA for itself.
  • These LSAs describe the router, its interfaces (in that area), and a list of neighboring routers (in that area) on each interface.
  • Identified by a link-state ID (LSID) equal to that router's RID
  • Type 2 LSA represents a transit subnet for which a DR has been elected.
  • The LSID is the interface IP address on that subnet.
  • Type 2 LSAs are not created for subnets on which no DR has been elected.
  • Armed with an LSDB with all the Type 1 and 2 LSAs inside an area, the SPF algorithm is able to create a topological graph of the network, calculate the possible routes, and finally choose the best routes.
  • The Type 2 LSA includes references to the RIDs of all routers that are currently neighbors of the DR on that subnet. That information, combined with the Type 1 LSAs for each router connected to the subnet represented by the Type 2 LSA, allows SPF to construct an accurate picture of the network.
  • Be aware of a long-term glitch in the show ip ospf database output: the Link ID column should say Link State ID.
  • While Link State ID is a unique identifier for an entire LSA, a Link ID is a particular entry specifically in a Type 1 LSA body that describes an adjacency to a neighboring object of a router.
  • A single Type 1 LSA identified by a single Link State ID can describe several adjacencies represented by several Link ID entries.
  • These two terms are not interchangeable.
  • The show ip ospf database command lists the LSAs in that router's LSDB in sequential order.
  • To signify a network that is down, the appropriate Type 1 or 2 LSA is either reoriginated and the disconnected network is removed from that LSA, or the entire LSA is prematurely aged by setting its age to 3600 seconds and flooding it, causing it to immediately expire from all LSDBs.


LSA Type 3 and Inter-Area Costs

  • ABRs do not forward Type 1 and 2 LSAs from one area to another.
  • ABRs advertise Type 3 LSAs, which represent subnets described in both Type 1 and 2 LSAs in another area.
  • Describe a simple inter-area destination: the subnet, the mask, and the ABR's cost to reach that subnet.

S2# show ip ospf database
! Lines omitted for brevity
Summary Net Link States (Area 0)
Link ID    ADV Router  Age   Seq#        Checksum
10.3.0.0   1.1.1.1     257   0x80000001  0x00A63C
10.3.2.0   1.1.1.1     257   0x80000001  0x009A45
10.3.13.0  1.1.1.1     261   0x80000021  0x007747

S2# show ip ospf database summary 10.3.0.0
OSPF Router with ID (8.8.8.8) (Process ID 1)
Summary Net Link States (Area 0)
Routing Bit Set on this LSA
LS age: 341
Options: (No TOS-capability, DC, Upward)
LS Type: Summary Links(Network)
Link State ID: 10.3.0.0 (summary Network Number)
Advertising Router: 1.1.1.1
LS Seq Number: 80000001
Checksum: 0xA63C
Length: 28
Network Mask: /23
        TOS: 0 Metric: 74


  • Next, S2's routes to all three subnets are listed. S2 calculates its cost based on its cost to reach R1, plus the cost listed in the type 3 LSA.

S2# show ip route ospf
O IA 10.3.0.0/23 [110/75] via 10.1.1.1, 00:05:08, Vlan1

S2# show ip ospf border-routers
OSPF Process 1 internal Routing Table
Codes: i – Intra-area route, I – Inter-area route


i 1.1.1.1 [1] via 10.1.1.1, Vlan1, ABR, Area 0, SPF 18


  • Routers calculate the cost for a Typer 3 LSA route by adding the following:
  1. The calculated cost to reach the ABR that created and advertised the Type 3 LSA. (show ip ospf database summary <link-id>).
  2. The cost as listed in the Type 3 LSA. (show ip ospf border-routers)
  • When a Type 1 or 2 LSA changes in some way, each router in the area runs SPF, but routers inside other areas do not. They only run minor modications - a process called a partial run, partial SPF, or partial route calculation.
  • Type 3 summary LSAs are flooded only within the are into which they were originated by ABRs.
  • An ABR uses only Type 3 LSAs received over a backbone area in its calculation. Type 3 LSAs received over non-backbone areas will be skipped during the ABR's SPF computation, though they are stored in the ABR's LSDB and flooded within that non-backbone area as usual.
  • Only intra-area routes from non-backbone areas are advertised into the backbone; both intra-area and inter-area routes are advertised from the backbone into non-backbone areas.

LSA Types 4 and 5, and External Route Types 1 and 2

  • OSPF allows for two types of external routes, aptly named types 1 and 2.
  • The type determines whether only the external metric is considered by SPF when picking the best routes (external type 2, or E2), or whether both the external and internal metrics are added together to compute the metric (external type 1, or E1).
  • By default, Cisco routers use the E2 metric type in redistribution.
  • When an ASBR injects an external route, it creates a Type 5 LSA for the subnet.
  • The LSA lists the metric and the metric type.
  • The ASBR then floods the Type 5 LSA throughout all regular areas.
  • If the LSA contains the E1 metric, the total cost of the external network is the cost of reaching the ASBR + the E1 cost carried in the LSA.
  • If the LSA contains the E2 metric, this metric is used exactly as it is indicated in the LSA.
  • If there are multiple paths, the path with the least total cost is used. Otherwise, all of them will be used.
  • No additional costs are ever summed with the E2 metric.
  • If there are multiple paths, the path with the lowest E2 metric is used.
  • If there are still multiple paths, the path through the closest ASBR is used.
  • If there ara still multiple paths, all of them will be used.
  • If there are both E1 and E2 routes to the same network, the E1 is always preferred to E2.
  • With both E1 and E2 metric types, it is necessary to compute the metric to the ASBR.
  • Within the area where the ASBR resides, this is simply the least-cost path from the computing router to the ASBR as computed using Type 1 and 2 LSAs.
  • When an ABR floods the Type 5 LSA into another area, it creates a Type 4 LSA, containing the ASBR's RID and the ABR's metric to reach the ASBR.
  • Routers in other areas use the Type 4 LSA to know what ASBRs in other areas exist, what ABRs can be used to reach them, and what is the distance of each ABR to a particular ASBR.
  • For a router in a different area, the total cost of reaching the ASBR = the cost to the ABR + the cost between the ABR and ASBR (as indicated in the Type 4 LSA).
  • Type 4 LSA is not required in the area where the ASBR resides.

R3# show ip ospf database | begin Type-5
Type-5 AS External Link States
Link ID       ADV Router  Age    Seq#          Checksum    Tag 

192.168.1.0   7.7.7.7     1916   0x8000002B    0x0080EF    0
192.168.2.0   7.7.7.7     1916   0x80000028    0x00FEF2    0


R3# show ip ospf database external 192.168.2.0
OSPF Router with ID (3.3.3.3) (Process ID 1)
Type-5 AS External Link States
Routing Bit Set on this LSA
LS age: 1969
Options: (No TOS-capability, DC)
LS Type: AS External Link
Link State ID: 192.168.2.0 (External Network Number)
Advertising Router: 7.7.7.7
LS Seq Number: 80000028
Checksum: 0xFEF2
Length: 36

Network Mask: /24
      Metric Type: 2 (Larger than any link state path)
      TOS: 0
      Metric: 20
      Forward Address: 0.0.0.0
      External Route Tag: 0


  • Note about the usage of summary in OSPF:
  1. Type 3 and 4 LSAs are called summary LSAs.
  2. The term LSA summary refers to the LSA headers that identify LSAs and are sent inside DD packets.
  3. The term summary can also be used to refer to summary routes created with the area range and summary-address commands.


Stubby Areas

  • Areas that do not perform any automatic filtering on the type of accepted information are called regular areas.
  • Stubby areas take advantage of the fact that not all areas need to have knowledge about individual external networks.
  • The advantage of knowing the external networks is only visible if there were multiple ABRs in the current area and multiple ASBRs in other areas, so the least-cost paths could be chosen individually.
  • The connectivity to external networks can be equivalently provided to a stubby area by replacing the list of external networks with a simple default route injected by the area's ABRs.
  • If an area is configured as a stubby area, ABRs will stop advertising Type 4 and 5 LSAs into this area.
  • In addition, the ABRs will automatically inject a default route into the area as Type 3 LSA.
  • The connectivity to external networks is still guaranteed but the LSDBs will be sparser.
  • The visibility of intra-area and inter-area networks is not affected in any way.
  • OSPF defines several different types of stubby areas.
  • By definition, all stubby areas stop Type 4 (ASBR summary) and Type 5 (external) LSAs.
  • However, a stubby area might also prevent Type 3 LSAs from being injected, causing the area to stop seeing individual inter-area routes as well.
  • Another variation includes whether a router inside the stubby area can redistribute routes into OSPF, thereby injected an external route.
  • When the name includes "totally", Type 3 LSAs are not passed into the area, except the Type 3 LSA carrying the default route.
  • If the name includes "NSSA", it means that external routes can be redistributed into OSPF by routers inside the stubby area (in Type 7 LSAs, because Type 5 LSAs are prohibited).
  • To configure stubby areas, all routers attached to the area must be configured with the exact same command for each stubby area type.
  • However, in totally stubby areas, non-ABRs should omit the no-summary keyword because the additional Type 3 LSA filtering is performed only by the ABR.
  • An NSSA is still a stubby area in the sense that external routes from other areas are not advertised to it.
  • However, an NSSA can hold an ASBR and perform external route injection.
  • This external information is carried in Type 7 LSAs to distinguish it from normal external routes in Type 5 LSAs, which are still prohibited even in NSSAs.
  • A default route is not advertised into the NSSA automatically.
  • ABRs must be configured with the area <area-id> nssa default-information-originate command.
  • All other non-regular area types will inject a default route automatically, including totally NSSA (NSSA-TS).
  • ABRs convert Type 7 LSAs to Type 5 LSAs before forwarding them into another area.
  • If using NSSAs, N1 refers to NSSA-external Type 1 routes and N2 to NSSA-external Type 2. The differences are equivalent to differences between E1 and E2 routes.


OSPF Path Choices That Do Not Use Cost

  • Under most circumstances, when an OSPF router runs the SPF algorithm and finds more than one possible route to reach a particular subnet, the router chooses the route with the least cost.
  • However, OSPF does considers a few conditions other than cost when making this best-path decision.
  • It is possible for a router to find multiple routes to reach a given subnet where the type of route (intra-area, inter-area, E1/N1, or E2/N2) is different.
  • In these cases, the router should ignore the costs and instead choose the best route based on the following order of preference:
    1. Intra-area routes.
    2. Inter-area routes.
    3. E1/N1 routes (equivalent).
    4. E2/N2 routes (equivalent).
  • When an ABR originates type 3 LSAs on behalf of known routes, it translates only intra-area routes from a nonbackbone area into type 3 LSAs and floods them into the backbone, and it translates both intra-area and inter-area routes from the backbone area into type 3 LSAs and floods them into nonbackbone areas.
  • When an ABR runs the SPF algorithm, it ignores all type 3 LSAs received over nonbackbone areas.
  • The first rule essentially makes sure that the only valid way of one area learning about
    routes in another area is through the backbone, and that the backbone is never fed a
    route that must have already traversed the backbone.
  • The second rule makes sure that an ABR does not traverse a nonbackbone area to reach
    a network that is located in the backbone or in some other nonbackbone area.

Tuesday, February 3, 2015

CCIE OCG: OSPF (Chapter 9), Part I

  • OSPF is a link-state routing protocol.
  • "Link state" refers to the fact that the topology includes information about each data link and their current operational state.
  • All topological data comprises the link-state database (LSDB).
  • Each router applies the Dijkstra algorithm to the database to calculate the current best routes to each subnet.

OSPF Database Exchange

  • Five different messages to establish adjacencies and exchange routing information.
  • The LSA exchange process is the same in single and multi-area designs.

OSPF Router IDs

  • A unique 32-bit identifier.
  • Chosen in the following sequence:
  1. Use the configured router ID (router-id <rid>).
  2. Use the highest non-shutdown loopback interface IP address that is not reserved by another OSPF process.
  3. Use any other highest non-shutdown interface IP address that is not allocated by another OSPF process.
  • Valid interfaces do not have to be matched by a network statement.
  • The down/down state is sufficient.
  • OSPF does not have to advertise to reach the RID subnet.
  • The RID does not have to be reachable per the IP routing table.
  • The RID can change if the OSPF process is restarted or the RID is manually configured.
  • If the RID changes, the routers in the same area will have to perform a new SPF calculation.

Becoming Neighbors, Exchanging Databases, and Becoming Adjacent

  • Five different message types are encapsulated inside IP packets, using IP protocol 89.
  • Hello: Used to discover neighbors, bring a neighbor relationship to a 2-Way state, and monitor a neighbor's continuous liveliness.
  • Database Description (DD or DBD): Used to exchange LSA headers during the initial topology change.
  • Link-State Request (LSR): A packet that identifies one or more LSAs about which the sending router would like the neighbor to supply full details about.
  • Link-State Update (LSU): A packet that contains fully detailed LSAs, sent in response to an LSR message or in the event of a topological change.
  • Link-State Acknowledgement (LSAck): Sent to confirm the receipt of an LSU message.
  • The LSAs themselves are not OSPF messages.
  • An LSA is a data structure, held inside a router's LSDB and exchanged inside LSU messages.
  • An OSPF router keeps a state machine for each neighbor (show ip ospf neighbor).
  • These neighbor states change as the neighbors progress through their messaging.



OSPF Neighbor States

  • OSPF routers go through a series of adjacency states.
  • Some of these states are transitory, and some are stable states.
  • Neighbor states, not adjacency states.
  • Routers can temporarily consider each other in different states, but ultimately both routers must arrive at the same state.
  • Down: The initial state for a neighbor. Implies that the router already knows about its neighbor's IP address.
  • Attempt: Valid only in NBMA networks. A neighbor is immediately placed into the this state and contacted by Hello packets. If no reply within the Dead interval, go back to Down state.
  • Init: If a valid Hello packet has been received but the list of seen routers in this Hello packet does not contain the receiving router's RID.
  • 2-Way: If a valid Hello packet has been received and the list of seen routers in this Hello packet includes the receiving router's RID. Confirms bidirectional visibility, and is a stable state between routers that do not intend to become fully adjacent.
  • ExStart: The purpose is to establish the Master/Slave relationship. The routers exchange empty DBD packets to compare their RIDs, determine the Master/Slave roles, and agree on a common starting sequence number used to acknowledge subsequent DBD packets.
  • Exchange: DBD packets are exchanged. Each router builds a list of LSAs to be subsequently downloaded from the other router.
  • Loading: After the neighbor has advertised the complete list of LSAs and downloads the LSAs.
  • Full: All required LSAs have been downloaded, so all missing or outdated LSAs have been acquired. The state is stable and neighbors are fully adjacent.

Becoming Neighbors: The Hello Process

  • Hello messages perform four major functions:
  1. Discover other OSPF routers on common subnets.
  2. Check for agreement on selected configuration parameters.
  3. Verify bidirectional visibility between routers.
  4. Monitor the health of the neighbors to react if the neighbor fails.
  • Listen for multicast Hellos messages sent to 224.0.0.5 (All OSPF Routers).
  • Hellos are sourced from the router's primary IP address on the interface.
  • Routers will advertise secondary IP addresses but never send Hellos or form neighborships using secondary IP addresses.
  • OSPF neighbors will become fully adjacent if one or both of the neighbors are using unnumbered interfaces for the connection between them.
  • Perform the following parameter check based on the received Hellos:
  1. Must pass the authentication process (if configured).
  2. Must be in the same primary subnet, including the same subnet mask.
  3. Must be in the same OSPF area.
  4. Must be of the same area type.
  5. Must not have duplicate RIDs.
  6. OSPF Hello and Dead timers must match.
  • If any of these items do not match, the routers do not form a neighborship.
  • The OSPF process ID does not have to match.
  • The MTU must be equal for the DBD packets to be successfully processed.
  • The MTU mismatch would negatively affect the database synchronization process in the ExStart and Exchange process.
  • Each Hello contains a list of neighbors from whom the sending router received valid and acceptable Hellos.
  • The Hello contains RIDs of routers whose Hellos were seen and accepted by the router originating this Hello.
  • If a router finds its own RID in the list of seen routers in a Hello received from a neighbor, it can be sure that they can hear each other.
  • Heartbeat: The neighbors send Hellos every hello interval. If a Hello is not received within the dead interval, the router has failed.
  • Hello interval: 10 seconds for broadcast and point-to-point, 30 seconds for nonbroadcast and point-to-multipoint.
  • Dead interval: 4 x Hello interval.

R1# debug ip ospf hello
OSPF hello events debugging is on
Jan 12 06:41:20.940: OSPF: Mismatched hello parameters from 10.1.111.4
Jan 12 06:41:20.940: OSPF: Dead R 40 C 120, Hello R 10 C 30 Mask R 255.255.255.0 C
255.255.255.0


C = Configured, R = Received

Transmitting LSA Headers to Neighbors

  • After Hellos and parameter checks, neighbors do not immediately send LSAs.
  • First, each router creates and sends Database Description (DD or DBD) packets, which contain the headers of each LSA.
  • Essentially, the DBD is an index list of all the LSAs each router knows about (including revisions).
  • Next, a router requests a new copy of only those LSAs it does not have or which are less recent.
  • DD messages have an OSPF-defined simple error recovery process: each DD packet has a sequence number assigned, the receiver acknowledges a received DD packet by sending a DD packet with the identical sequence number to the sender.

Database Description Exchange: Master/Slave Relationship

  • In ExStart, the routers determine the master and slave roles.
  • Only the master is allowed to send DD packets on its own accord and to set and increase their sequence numbers.
  • A slave is allowed to send a DD packet only as a response to a master's DD, and must use the same sequence number.
  • In effect, a slave is polled by the master and only responds to it.
  • DD packet contains three flags:
  1. Master (MS) flag: Set in all DD packets sent by the master, and cleared in all packets sent by the slave.
  2. More (M) flag: Set when a router intends to send an additional DD packet after this one.
  3. Init (I) flag: Indicates the initial DD packet that starts the exchange. Subsequent DD packets, either from master or slave, have the I flag cleared.

  • During the DD packet exchange, one router might need to send many DD packets while the other might only require a single DD packet.
  • Two rules to sending DD packets:
  1. Each DD packet sent from the master must be replied to by the slave (i.e. the number of DD packets sent from master to slave must match the number of DD packets sent from slave to master).
  2. A slave can send a DD packet only as a response to receiving a master's DD packet.

  • If a router has no more LSA headers to advertise but its peer requires it to send more DD packets, the router will simply send empty DD packets.
  • If the slave has more DD packets to send, the master must continue polling the slave, even if it has no more LSAs to advertise itself.
  • The slave sets the M flag in its DD packet sent in response to the master's DD packet.
  • A master will stop sending DD packets to a slave when it has no more LSA headers to advertise, and the slave's last received DD packet has the M flag cleared.
  • In the beginning of ExStart, both routers consider themselves to be the master, and send an empty DD packet, containing a randomly chosen sequence number, and MS (Master), M (More), and I (Init) flags set to 1.
  • After receiving the neighbor's DD packet, the router with the lower RID will change its role to slave, and it will respond with a DD packet with the MS and I flags cleared and the sequence number set to the sequence number of the master's DD packet.
  • The routers move into the Exchange state.
  • The master will then a DD packet with the sequence incremented by 1, and the slave will respond with the same sequence number, optinally advertising its own LSA headers.
  • The exchange continues in the same fashion, until both routers have advertised all known LSA headers.
  • The master will stop sending DD packets when it has advertised all LSA headers itself and the last DD response from the slave has the M flag cleared.

Requesting, Getting, and Acknowledging LSAs

  • After the DD packets, the router needs to request a full copy of each LSA that is missing from its own LSDB.
  • To know whether a neighbor has a more recent copy of a particular LSA, a router looks at the sequence number of the LSA in its LSDB and compares it to the sequence number of that same LSA learned from the DD packet.
  • Each LSA's sequence number is incremented every time the LSA changes or is reoriginated.
  • For example, R1 sent R2 an LSA header for the type 1 LSA that describes R1 itself, with sequence number 0x80000004. If R2’s database already held that LSA, but with a sequence number of 0x80000003, R2 would know that it needs to ask R1 to send the latest copy (sequence number 0x80000004) of that LSA.
  • LSA sequence numbers start with 0x80000001; increase through 0xFFFFFFFF, 0x00000000, and 0x00000001, and finish at 0x7FFFFFFF.
  • Routers use Link-State Request (LSR) packets to request one or more LSAs from a neighbor.
  • The neighboring router replies with Link-State Update (LSU) packets, which hold one or more full LSAs.
  • The LSR/LSA process uses a reliable protocol with two acknowledgement options: 1) send back the same LSU to the sender, and 2) send back an LSAck, which contains a list of acknowledged LSA headers.
  • At the end of the process, the neighbors have exchanged their LSDBs, and the LSDBs are identical.

Designated Routers on LANs

  • OSPF uses a DR (and a backup DR, or BDR) on a multiaccess network. 
  • The LSA flooding occurs through the DR, reducing the unncessary exchange of redundant LSAs.
  • The presence of a DR/BDR allows the routers to synchronize only to a DR and BDR, alleviating the need of synchronizing to each other, possibly flooding the same set of LSAs multiple times.
  • In reality, DRs have a different crucial and the only truly irreplaceable function: They create a Type 2 LSA that represents the multiaccess network segment.
  • Only routers in the Full state are allowed to exchange LSAs.
  • On a multiaccess network, every router is in the Full state only with the DR and BDR.
  • The DR and BDR are also in the Full state with each other.
  • The DR and BDR send LSUs to the multicast IP address 224.0.0.5, All OSPF Routers group.
  • Other OSPF routers will acknowledge the receipt of the LSU by sending an unicast LSAck back to the originating router.
  • All other non-DR/BDR send updates to the multicast IP address 224.0.0.6, the All OSPF DR Routers group that contains only the DR and BDR.
  • Both the DR and BDR will store the updated LSA from the LSU in their LSDB.
  • The DR then floods the new LSU to all OSPF routers (224.0.0.5).
  • Other routers on the segment including the BDR, except the original router, will acknowledge the DR's LSU with a unicast LSAck sent to the DR.
  • A router that is neither a DR or BDR is called a DROther.
  • Routers that are DROthers do not become fully adjacent; they stop at the 2-WAY state.
  • The 2-WAY simply means that the Hello parameters match and bidirectional visibility check worked, but the neighbors do not synchronize their LSDBs directly with each other.
  • Neighbors: Two routers that share a common data link and that exchange Hello messages, and the Hellos must match for certain parameters.
  • Adjacent (fully adjacent): Two neighbors that have completed the process of fully exchanging DD and LSU packets directly between each other.
  • DROthers still end up with an identical copy of the LSDB by exchanging them with the DR.

DR Election on LANs

  • The election occurs after the routers have become neighbors, but before they send DD packets and reach the ExStart neighbor state.
  • If the DR has not been elected (a DR of 0.0.0.0 in the Hello message), the router waits before attempting to elect a DR.
  • The wait period is called the OSPF wait time, which is set to the same value as the Dead timer.
  • If the received Hellos already list the DR's RID, the router does not have to wait before beginning the election process.
  • A router with its OSPF priority set to 1-255 inclusive is eligible to become a DR or BDR. 
  • If the priority is set to 0, the router is ignored in DR/BDR elections.
  • Each router performs the elections locally, but the algorithm makes sure that all routers ultimately arrive at the same conclusion.
  • During the wait interval, each router collects the priorities and RIDs of other neighbors on the segment. The routers do not assert themselves as the DR or BDR during this phase.
  • If, during the wait interval, a Hello packet arrives from a neighbor that claims itself as the DR or BDR, the router immediately proceeds to the DR/BDR election process. Otherwise, the full wait time on the interface needs to expire.
  • The election is performed only for those roles that are not yet claimed in neighbor Hellos.
  • The router with the highest priority becomes the DR, and the router with the second-highest priority becomes the BDR.
  • If there are routers with the same priority, the higher RID is used to break the tie.
  • After the election has completed, if a new router arrives on an existing router improves its priority, it cannot preempt and take over the existing DR (or BDR).
  • When a DR is elected and the DR fails, the BDR becomes the DR, and a new election is held for a new BDR.
  • If two routers arrive at different DR/BDR elections (perhaps due to STP convergence), they enter the election phase again.

Designated Routers on WANs and OSPF Network Types

  • Routers can be configured to use, or not to use, a DR and a couple of other key behaviors, based on the OSPF network type.
  • The OSPF network type determines the following:
  1. Whether the router tries to elect a DR.
  2. Whether the router uses unicast (the neighbor command) or multicast to find neighbors.
  3. Whether two or more neighbors should be allowed on the same subnet.
  • The OSPF network type is set with the ip ospf network <type> under the interface.
  • The table lists the network types and their exact keywords for the command.

Caveats Regarding OSPF Network Type over NBMA Networks

  • Make sure that the default Hello/Dead timers do not cause the Hello parameter check to fail.
  • Ensure that all routers in the same NBMA network use an OSPF network type that either uses a DR or does not.
  • If a DR is used, the DR and BDR must have a PVC to every other router in the subnet. Routers that do not have a PVC to every other router must not be permitted to become a DR/BDR.
  • The neighbor command on a single router is sufficient to bring up the OSPF adjacency with the configured neighbor. For clarity and stability, it is better to configure the neighbor command on both routers.

Example of OSPF Network Types and NBMA

  • With partial meshes, the DR/BDR election should be influenced by configuring the routers' priorities and RIDs so that the hub of a hub-and-spoke design becomes the DR.
  • The priority specified in the neighbor command is never used in DR/BDR elections.
  • If there are multiple neighbor statemets and at least one of them has a non-zero value, the router will first send Hello packets only to those neighbors.
  • Only after the DR/BDR elections have completed between these routers, the router will start sending Hello packets to all remaining neighbors.
  • This optimization increases the chances that the DR and BDR roles will be taken up by appropriate routers, and prevents routers from competing in DR/BDR elections with neighbors that are not entitled to these roles.
  • The priorities specified in the neighbor commands do not need to match the real priorities of these neighbors, but if they differ, the router can engage in DR/BDR elections with neighbors not entitled to become a DR/BDR.
  • In any case, the real priorities, as seen in the Hello packes, will be used to complete the DR/BDR elections.
  • If all neighbor statements omit the priority setting, this optimization is not used, and all neighbors are contacted immediately.

SPF Calculation

  • After a router has new or different information in its LSDB, it uses the Dijkstra SPF algorithm to examine the LSAs in the LSDB and derive the new tree of shortest paths to available networks.
  • SPF on a router constructs least-cost paths from this router to all possible destinations, summing the costs for each outgoing interface along the path and picking the path with the lowest total cost.
  • Found destinations and their least-cost paths are placed into the routing table.


Steady-State Operation

  • Even after the network has stabilized and the LSDBs are synchronized, the routers perform the following operations:
  1. Send Hellos, based on per-interface Hello intervals.
  2. Expect to receive Hellos from neighbors within the Dead interval on each interface; if not, the neighbor is considered to have failed.
  3. Reflood self-originated LSAs (incrementing the Sequence Number by 1) based on the LSRefresh interval (default 30 minutes) even if no change has occurred.
  4. Expect to have its LSAs refreshed within each LSA's MaxAge timer (default 60 minutes).