Working with Open Shortest Path First (OSPF) Routing Protocol
Because Open Shortest Path First (OSPF) is an open standard protocol, many people have contributed to its design and thousands upon thousands of people have reviewed it. In this section,some functional components of this interior gateway protocol (IGP) and its use in your networks will be highlighted.
Because every IGP behaves slightly differently from other IGPs, you should be familiar with a few OSPF terms that are used with the protocol before jumping into the configuration commands. This section attempts to clarify the major terms and concepts you should be familiar with.
OSPF as a link-state protocol
In link-state protocols, the link part of the protocol is the interface on the router, while the state is how it relates to its neighbors, which would include its address and network information. Before you get started, check out this short list of terms used in this section:
Link State Advertisement (LSA): A simple update on a router’s link status, so one will be sent when a link is connected, disconnected, or otherwise changed
Topological database: A table in the router’s memory that contains link information about all known routers (see Chapter 6 of this minibook)
SPF algorithm: A mathematical calculation that uses the Dijkstra algorithm (named after a Dutch mathematician) to determine the shortest path to destinations and that has been heavily applied to computer networks
SPF tree: A listing all of the routes to any destination with an order of preference
Each router that has been configured for an OSPF area sends out a Link State Advertisement (LSA) at regular intervals. All of this link-state information is stored in a topological database, after which an SPF algorithm is applied to the data in the database.
This process generates an SPF tree listing all of the routes to any destination with an order of preference. The preferred order is then stored in the routing table, giving the router the best routing choices to those destinations. Figure 8-1 illustrates this process:
Routers in exchange link-state data start the process.
Each router stores the link-state information in memory using a structure named the topology table or topology database.
The router processes all data in the topology table and makes use of the Dijkstra algorithm to determine all routes to all networks, as well as the least-cost routes.
All this information is stored in the SFP tree, identifying preferred and secondary routes.
The routing information is propagated to the routing table.
OSPF packet types
OSPF works with a few different types of packets to convey information to surrounding routers.
Hello packet: Exchanges information about neighbors with each other.
Database Description packet: Elects a version of the database to be used.
Link-state request packet: Requests a specific LSA from a neighbor.
Link-state update packet: Sends an entire LSA to a neighbor who has requested an update.
Link-state acknowledge packet: Acknowledges the receipt of a link-state update packet.
The default interval for sending LSA updates is 30 minutes, with a 4-minute random offset to prevent all routers from sending at the same time. This interval does not mean that when a change occurs on an interface, it takes up to 30 minutes to start the replication process. Rather, changes in interface status or configuration are sent out immediately. The 30-minute interval is used to refresh data that already exists on other routers.
Because a router expects to receive updates every 30 minutes, you may be wondering what happens if an update does not show up on schedule. If an update is not received within four intervals (120 minutes), the router is aged out of the topology database. This might happen if something unexpected happens to the router, such as a power supply failure or becoming unplugged.
All routers that share a common area identifier (or area ID) receive the LSA data, not just routers on the same data link.
Knowing areas and Autonomous Systems
When designing your OSPF network, the two main factors you work with are areas and how they fit within an AS. Areas are functional areas of your network, perhaps a building or the floor of a building, and Autonomous Systems are collections of areas, which typically are your entire network.
The overall OSPF network is divided into groups called areas, whereas all routers in an organization are probably part of a single AS. The area is defined as a logical division of the AS, broken up into contiguous sections of the IP network.
In other words, you break the area along groups of subnets that can be grouped together with a single routing entry. In a typical large network, an area may consist of 30 to 40 routers.
The Hello packet
The faster, more regular packet of OSPF management packets, is the multicast OSPF Hello packet, which goes to the address 184.108.40.206. The Hello packet is the mechanism that creates the neighbor relationships between routers. By default, these packets go out every ten seconds on broadcast media, alerting surrounding neighbors that the router is still up and running.
The dead interval (the time when a neighbor is possibly down) for Hello information is four times the Hello interval, so if a router fails to send four sets of Hello packets, it will be flagged as unavailable and its routes will be suspect. It will later be removed when four update intervals have passed.
When OSPF Hello packets are sent out, they contain several pieces of information. Here is a list of the key items:
Router ID: Found in the OSPF header, the Router ID is a 32-bit numeric identifier that, by default, is the highest IP address among all the available interfaces. By implementing a loopback interface, you can exercise some control over the Router ID. You can also use the router-id configuration parameter to set the Router ID to a preferred value.
Neighbors: At the end of the Hello packet is a list of all known neighbor routers, which allows each neighbor to know about all other neighbors.
Area ID: Neighbors must share a common segment, and their interfaces must belong to the same OSPF area on that segment. They must also share the same subnet and mask.
Router priority: An 8-bit number for priority, used to select Designated Router (DR) and Backup Designated Router (BDR).
DR and BDR IP addresses: The addresses of both the DR and BDR.
Authentication password: The authentication password. Performing authentication is an optional security feature with the OSPF protocol.
Stub area flag: Reduces updates by individually routing them with a default route.
Checking out the base cost
After the router gathers all the information, it calculates a base cost for each route. The cost is calculated with this formula:
Cost = reference bandwidth / interface bandwidth in bps
The reference bandwidth is the same as Fast Ethernet, which is 100,000,000. Fast Ethernet links always have a cost of 1. If you are calculating the cost of a Gigabit Ethernet link, you use 100,000,000/1,000,000,000, which gives you 0.1.
The cost of an Ethernet link is 100,000,000/10,000,000, which gives you 10; the cost of a T1 link is 100,000,000/1,544,000, which gives you a cost of 64. The slower the link, the higher the cost, and the less it is preferred. The lowest cost link will always be preferred.