OSPF is classless routing protocol that interfaces directly to IP as protocol 89. OSPF uses the concept of multicast hellos and dead timers to discover and maintain neighbors. Routing updates for OSPF are called link-state advertisements (LSAs). The topology table for OSPF commonly is referred to as the link-state database. OSPF floods areas with LSAs until every router in the domain has a consistent image of the network, called the link-state database. When every router has the same image of the network, the SPF algorithm, or the Dijkstra algorithm, is run on the database, and a loop-free graph describing the shortest-cost path to each destination in the network is created. This is called the Spf tree. The OSPF routes in the route table or forwarding table are derived from the SPF tree. Because each router has an identical copy of the entire SPF tree, rapid convergence is possible. OSPF uses an arbitrary metric of cost when determining the shortest path to a destination.
Let's take a look at the major steps that OSPF goes through in building a route table, followed by a detailed examination of those steps. It is important to understand how OSPF operates over the different types of links and what type of LSAs propagates from one area to another. These details can be important when configuring OSPF over different media types.
1. When OSPF initializes, it sends hello packets out all OSPF interfaces on the multicast address of 18.104.22.168, called the AllSPFRouter address, on broadcast and point-to-point networks. The hello is unicast to specific neighbors on NBMA and multipoint networks. A router that receives the hello then verifies it against its own information about the network. The OSPF hello packet is a lot more complicated than that of EIGRP. As you will see, OSPF actually exchanges data within the hello packet.
2. When the packet has been verified, a neighbor is formed between the two routers. Neighbors, in turn, might or might not form adjacencies. An adjacency can be thought of as a virtual link between to routes used to send routing information on.
3. Each router sends its link-state information to the new neighbor.
4. Each neighbor records the new information and floods it to all its existing neighbors.
5. All routers receive the link-state information and build identical link-state databases. When the databases are complete, each router runs the SPF algorithm. The algorithm generates a loop-free path to every known route, with the local router as root. This is called the SPF tree.
6. Routes fitting the proper criteria from the SPF database then are inserted into the route table or forwarding database on the router.
Now, let's examine some of the more significant elements in greater detail. OSPF Hello Protocol
As mentioned previously, the hello protocol in OSPF actually carries important information and forms the adjacency. By default, the hello packet is sent out every 10 seconds on all OSPF interfaces. On NBMA networks, the default hello is 30 seconds. The hello packet accomplishes these tasks:
• Neighbor discovery— When a router receives a hello, the packet contains the following information:
- The router ID of the originating router
- The area ID of the originating router interface
- The address mask of the originating interface
- Authentication type and authentication information for the originating interface
- The HelloInterval of the originating interface
- The RouterDeadInterval of the originating interface
- The router priority
- The designated router (DR) and backup designated router (BDR)
- Five flags for options
- The router IDs of the originating router's neighbors
• Adjacency criteria— For OSPF to form an adjacency between two neighbors, the HelloInterval, RouterDeadInterval, area IDs, and authentication type and password must match.
• Keepalive mechanism between neighbors— The RouterDeadInterval is set to four times the hello timer. In most cases, this is 40 seconds or 120 seconds, depending on the link type. If a hello is not received by the time the RouterDeadInterval expires, the neighbor is declared down.
• Election of DRs and BDRs on broadcast and NBMA networks— The router ID, DR, and
BDR fields, along with the router priority, help determine the state of DRs and BDRs. More information on DR and BDRs is offered in upcoming sections.
Sometimes, the terms neighbors and adjacencies are used synonymously. In OSPF, the terms are related but mean different things. RFC 2328 defines neighboring routers as routers that have interfaces to a common network. Neighbors are maintained by and usually are dynamically discovered by OSPF's Hello Protocol. Adjacency is defined as a relationship formed between selected neighboring routers for the purpose of exchanging routing information. Not every pair of neighboring routers becomes adjacent.
The old Frost poem about neighbors reads as true for OSPF as it did for EIGRP: "Good neighbors make good networks." As in EIGRP, link states can be exchanged only after the neighbors build adjacencies. Stable OSPF neighbors are important in OSPF networks. How OSPF treats the neighbor and propagates link states depends on the network type that the router and its neighbor(s) exist on. There are five types of OSPF networks:
• Point-to-point networks— Examples of point-to-point networks are HDLC networks, PPP, and Frame Relay networks with point-to-point subinterfaces. Link states and hellos use the multicast address of 22.214.171.124. There is no designated router or BDR election. This is a Cisco-specific network type and is not defined by an RFC.
• Broadcast networks— Examples include Ethernet, Token Ring, and FDDI networks. Hellos use the address 126.96.36.199 and elect a DR and a BDR. The other routers on this network send link states on the multicast address of 188.8.131.52. Only the DR and the BDR listen to these updates on this address. They, in turn, flood the link states out address 184.108.40.206 for the other routers. The election and the role of the DR and BDR are discussed more in the next section.
• NBMA networks— NBMA network types include Frame Relay natural or multipoint interfaces and X.25 networks. On networks such as these, multicast packets are not forwarded properly to all neighbors because there exists no broadcast capability. Therefore, OSPF neighbors must be statically defined. A DR and a BDR are elected, and all OSPF packets are unicast. On NBMA networks, the DR/BDR should be the router(s) that have a PVC, SVC, or circuit to all the other routers, or what is called the hub router(s).
• Point-to-multipoint— Point-to-multipoint network types must be statically defined. The router treats a Frame Relay multipoint network like many point-to-point links. A DR and BDR are not elected, and OSPF packets are multicast.
• Virtual links— Virtual links are a special type of network that is used to extend Area 0. Virtual links are discussed more in the section "OSPF Virtual Links."
On multiaccess networks, such as Ethernet, Token Ring, or FDDI, it quickly becomes inefficient for every adjacent router to advertise link states to all its neighbors. It also becomes inefficient for every router to become adjacent. Instead, OSPF elects one router and calls it the designated router. The designated router listens to link states on 220.127.116.11 and floods them on address 18.104.22.168. This is the only router besides the backup designated router that will listen for link-state updates on 22.214.171.124. The BDR will shadow the DR and take over only when the DR fails. Essentially, the DR/ BDR scheme offers the following advantages:
• It streamlines routing updates through managing the flooding link states.
• DR and BDR represent the multiaccess network to the rest of the OSPF domain. By acting as a single point of control, the DR also ensures that routers on the multiaccess network have consistent link-state information.
• The concept of a BDR also speeds network synchronization. Because all routers are also adjacent to the BDR, if the DR fails, the BDR takes its place with minimum unavailability.
When the DR and the BDR are elected, new routers will establish adjacencies only with the DR and the BDR. The DR and the BDR also become adjacent with each other.
To elect the DR and BDR, the router will adhere to the following process:
1. Neighbors participating in the election must be in at least the 2-way state. That is, each neighbor has sent and received a hello from the other neighbors participating. See the section entitled "The Basic OSPF Adjacency."
2. Priority values will be examined. Neighbors with the priority value of 0 are excluded from the process. The neighbor with the highest priority becomes the BDR. In case of a tie, the router with the highest RID wins. The default OSPF priority is 1, which can be modified with the ip ospf priority [0-255] interface command.
3. If no DRs are reported on the link, the BDR is promoted to DR, and the process begins again to select a new BDR. If there is a tie in the network, the tie is resolved by the router ID. The router with the highest router ID becomes the BDR.
4. If a router with a higher priority is added to the network, a new DR or BDR will not be selected. The DR/BDR election process happens again only if the DR or BDR fails.
5. The routers continue to exchange hellos every 10 seconds (the default on broadcast networks). If a router does not receive a hello from a neighbor within the amount of time specified by the dead timer interval, which is four times the hello interval, the neighbor is declared down.
Essentially, the election of a DR and a BDR allows OSPF to streamline routing updates through the network. In the Ethernet example in Figure 12-1, you can see how inefficient the routing process would quickly become in a large network. Without the DR/BDR, every router would need to exchange LS information with every other router on the network.
Figure 12-1. OSPF Ethernet Network LS Propagation Without a DR and BDR
Figure 12-1. OSPF Ethernet Network LS Propagation Without a DR and BDR
With a DR and BDR in place (see Figure 12-2), LS information, or route information, is controlled by the DR.
Figure 12-2. LS Propagation with a DR and BDR
OSPF Router IDs (RIDs)
The OSPF router ID (RID) is 32-bit unique number assigned to each router running OSPF. This number uniquely identifies the router within the autonomous system. By having a unique router ID for every router within the AS, OSPF can accomplish the following:
• OSPF easily can identify duplicate LSAs.
• OSPF is used to identify the unique end points of virtual links.
• OSPF is used to determine the tie-breaker for DR and BDR negotiations, as mentioned previously.
The router ID is chosen among the interfaces configured for IP on the Cisco router. The router chooses the highest IP address from any operational IP interface. That is, the line is up and the line protocol is up for that interface. If a loopback address is configured on the router, the router chooses that address. If multiple loopback interfaces are configured, it chooses the loopback interface with the highest IP address.
To force a router ID, use a loopback interface with a high IP address, such as 192.168.200.X. It is not necessary to propagate this network in a routing protocol. The networks—or, more specifically, the IP host addresses used for router IDs—do not need to be reachable or "ping-able" addresses. In Cisco IOS Software Version 12.0 and above, the OSPF router ID can be hard-coded with the OSPF router command:
Router(config-router)#router-id ip address
It is highly recommended to set the router ID with router-id command or by using loopback interfaces. This can greatly increase OSPF network stability. For example, OSPF virtual links rely on the router ID. If the router ID is not fixed and a new network or loopback interface is added to that router, the router ID would be recalculated upon a failure of that router. This could then lead to a change in routers IDs, making the virtual link fail.
OSPF neighbors go through states before they can begin exchanging LSAs, as illustrated in Figure 12-3. These states are referred to as the neighbor state machine. You can examine the state of an OSPF neighbor with the show ip ospf neighbor command.
Figure 12-3. A Basic OSPF Adjacency
Figure 12-3. A Basic OSPF Adjacency
The following list briefly describes the OSPF neighbor states and how they operate:
• Down— This is the initial state of the neighbor, which also indicates that no hellos were heard from this neighbor within the last dead time interval.
• Attempt— This state applies only to neighbors on NBMA networks, where the neighbors statically are configured with the neighbor command. When the interface becomes active, it goes to the ATTEMPT state, or when the router is DR or BDR.
• Init— A hello packet has been received from the neighbor, but two-way communication hasn't taken place yet.
• 2-way— This state indicates that a router has seen its own router ID in the Neighbor field of the Hello packet that it received from the neighbor. It also means that bidirectional conversation was established and that DR and BDR election can occur.
When an OSPF interface first becomes active, it begins to send hello packets. When two routers receive each other's hello, they place the neighbor in init status. When a neighbor is in init status, it places its own router ID into the hello packet. When a router receives one of the new hellos with the router ID of its neighbor, it places the neighbor in a new state of 2-way. The 2-way state ensures that there is two-way communication between the routers. The routers must be in this state before they can negotiate a DR/BDR and exchange LSAs.
After the routers have achieved the 2-way state, OSPF enters its final states:
• ExStart— The router enters a master/slave relationship and prepares for the exchange of database description packets. The neighbor with the highest interface address becomes the master.
• Exchange— The router sends its database description packets to neighbors in the exchange state. The database description packets describe the entire link-state database. The linkstate database is synchronized after this phase. After synchronization, the router enters one of two final states:
- Loading— The router also sends link-state request packets to all neighbors that are in the loading state. The loading phase requests that more recent LSAs be sent.
- Full— Neighbors in this state are fully adjacent. In summary, the OSPF adjacency is built in four phases:
1. Neighbors are discovered.
2. Bidirectional communication is established between neighbors.
3. The SPF database is synchronized.
You can view the status of an OSPF adjacency with the show ip ospf neighbor command, and you can observe the actual building of the adjacency with the debug ip ospf adj command. These and other OSPF status commands are discussed more in upcoming sections.
In Figure 12-4, the charlie router is added to an existing OSPF network. By enabling the debug command, you can observe the adjacency being built, as demonstrated in Example 12-1.
Figure 12-4. A Basic OSPF Adjacency Demonstration
Was this article helpful?