< Free Open Study > |
Technical Overview of OSPFOSPF 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.
Now, let's examine some of the more significant elements in greater detail. OSPF Hello ProtocolAs 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 :
NOTE 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. OSPF Neighbors and Network TypesThe 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:
Designated Routers and Backup Designated RoutersOn 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 224.0.0.6 and floods them on address 224.0.0.5. This is the only router besides the backup designated router that will listen for link-state updates on 224.0.0.6. The BDR will shadow the DR and take over only when the DR fails. Essentially, the DR/BDR scheme offers the following advantages:
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:
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 (Hypothetical)
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:
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 TIP It is highly recommended to set the router ID with r outer-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. The Basic OSPF AdjacencyOSPF 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
The following list briefly describes the OSPF neighbor states and how they operate :
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:
In summary, the OSPF adjacency is built in four phases:
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
Example 12-1 debug ip ospf adj Command Followed by a show ip ospf neighbor Command Demonstrating an Adjacency Formingcharlie# debug ip ospf adj OSPF adjacency events debugging is on OSPF: Interface Ethernet0 going Up OSPF: Build router LSA for area 0, router ID 172.16.1.1 OSPF: Build router LSA for area 0, router ID 172.16.1.1 OSPF: Build router LSA for area 0, router ID 172.16.1.1 %SYS-5-CONFIG_I: Configured from console by console OSPF: 2 Way Communication to 172.16.1.10 on Ethernet0, state 2WAY Router enters two-way state OSPF: Build router LSA for area 0, router ID 172.16.1.1 OSPF: 2 Way Communication to 172.16.1.5 on Ethernet0, state 2WAY OSPF: Backup seen Event before WAIT timer on Ethernet0 OSPF: DR/BDR election on Ethernet0 DR/BDR election begins OSPF: Elect BDR 172.16.1.5 OSPF: Elect DR 172.16.1.10 DR: 172.16.1.10 (Id) BDR: 172.16.1.5 (Id) OSPF: Send DBD to 172.16.1.5 on Ethernet0 seq 0x1370 opt 0x2 flag 0x7 len 32 OSPF: Send DBD to 172.16.1.10 on Ethernet0 seq 0x218C opt 0x2 flag 0x7 len 32 OSPF: Build router LSA for area 0, router ID 172.16.1.1 OSPF: Rcv DBD from 172.16.1.10 on Ethernet0 seq 0x1137 opt 0x2 flag 0x7 len 32 state EXSTART EXSTART state begins slave/master will be selected OSPF: NBR Negotiation Done. We are the SLAVE OSPF: Send DBD to 172.16.1.10 on Ethernet0 seq 0x1137 opt 0x2 flag 0x2 len 52 OSPF: Rcv DBD from 172.16.1.5 on Ethernet0 seq 0x16D9 opt 0x42 flag 0x7 len 32 state EXSTART EXSTART state begins for the other neighbor OSPF: NBR Negotiation Done. We are the SLAVE OSPF: Send DBD to 172.16.1.5 on Ethernet0 seq 0x16D9 opt 0x2 flag 0x2 len 52 OSPF: Rcv DBD from 172.16.1.10 on Ethernet0 seq 0x1138 opt 0x2 flag 0x3 len 92 state EXCHANGE Exchange state begins for one neighbor OSPF: Send DBD to 172.16.1.10 on Ethernet0 seq 0x1138 opt 0x2 flag 0x0 len 32 OSPF: Database request to 172.16.1.10 OSPF: sent LS REQ packet to 172.16.1.10, length 36 OSPF: Rcv DBD from 172.16.1.5 on Ethernet0 seq 0x16DA opt 0x42 flag 0x3 len 92 state EXCHANGE Exchange state begins for the other neighbor OSPF: Send DBD to 172.16.1.5 on Ethernet0 seq 0x16DA opt 0x2 flag 0x0 len 32 OSPF: Database request to 172.16.1.5 OSPF: sent LS REQ packet to 172.16.1.5, length 36 OSPF: Rcv DBD from 172.16.1.10 on Ethernet0 seq 0x1139 opt 0x2 flag 0x1 len 32 s tate EXCHANGE OSPF: Exchange Done with 172.16.1.10 on Ethernet0 OSPF: Send DBD to 172.16.1.10 on Ethernet0 seq 0x1139 opt 0x2 flag 0x0 len 32 OSPF: Synchronized with 172.16.1.10 on Ethernet0, state FULL LS database is synced and the adjacency is in FULL status for this neighbor OSPF: Build router LSA for area 0, router ID 172.16.1.1 OSPF: Rcv DBD from 172.16.1.5 on Ethernet0 seq 0x16DB opt 0x42 flag 0x1 len 32 s tate EXCHANGE OSPF: Exchange Done with 172.16.1.5 on Ethernet0 OSPF: Synchronized with 172.16.1.5 on Ethernet0, state FULL The same "FULL" state is achieved with this neighbor OSPF: Build router LSA for area 0, router ID 172.16.1.1 OSPF: Send DBD to 172.16.1.5 on Ethernet0 seq 0x16DB opt 0x2 flag 0x0 len 32 OSPF: Build router LSA for area 0, router ID 172.16.1.1 charlie# charlie# show ip ospf neighbor Neighbor ID Pri State Dead Time Address Interface 172.16.1.5 1 FULL/BDR 00:00:35 172.16.1.5 Ethernet0 172.16.1.10 1 FULL/DR 00:00:30 172.16.1.10 Ethernet0 charlie# In this example, 172.16.1.10, or the alpha router, became the DR because its IP address is the highest one on the link. The next highest IP address was 172.16.1.5, or the bravo router, so it was elected as the BDR. Shortest-Path Tree (SPF) and the OSPF Metric CostWhen the LS database is synchronized within an area, the Dijkstra algorithm is run against it in two passes to form the shortest-path (SPF) tree. The first pass against the SPF database forms the branches, or router adjacencies within the area. The second pass adds all leaves or stub networks to the tree. When OSPF builds the tree, it determines the shortest path to each destination based on the sum cost to the destination. The lower the cost is, the more preferred the route is. The cost of a route is the sum of all costs of outgoing interfaces to that destination. Oddly enough, RFC 2328 offers no specific values for cost. Nortel Networks, for example, implements OSPF under RFC 2328 and uses the same formula to generate cost as Cisco Systems. In multivendor environments, take the extra time to see how cost is calculated because it will help OSPF have a consistent view of the entire internetwork. Cisco routers calculate OSPF cost as (10 8 /BW) rounded down, where BW is the configured or default bandwidth of the interface. Table 12-1 lists the common default OSPF cost settings. Table 12-1. Default OSPF Interface Cost
The default cost values can be overridden with the ip ospf cost 1-65535 interface command. The cost for a route can be viewed with the show ip route command. Recall that the variable behind the administrative distance is the metric cost for the router. Figure 12-5 shows a quick example of how cost is calculated. The route table of the echo router lists the cost for network 172.16.2.0 to be 70. The bandwidth of the T1 plus the 16-MB Token Ring equals 70; 64 + 6 = 70. The route to the Ethernet network has a cost of 80; 64 + 6 + 10. Figure 12-5. OSPF Cost Calculation
OSPF Router Types, Areas, and LSAsAt the onset, we mentioned that OSPF could be considered to be CPU- intensive and difficult to configure. By now, it becomes evident that multiple SPF databases, complex algorithms, and constant CPU interrupts caused by link-state flooding can cause an increase in the router's processor utilization. To control the flooding of link states and database synchronization, OSPF deploys the use of areas. An OSPF area can be defined as a group of routers and links that divide an OSPF domain into subdomains. Areas are identified by a 32-bit area ID, which then also can be expressed in dotted -decimal notation or as a decimal number. There are five types of areas in OSPF:
OSPF requires a hierarchical network design through the use of areas controlled by specific router types. A router might be multiple router types; for example, ABRs are also backbone routers. The OSPF router types are as follows :
The word LSA has been mentioned quite a bit. LSAs are what OSPF uses to build the OSPF database. OSPF floods specific LSA types to specific portions of the OSPF domain as dictated by the area and router type mentioned previously. LSA are classified by type, and each type serves a specific purpose, as described in the following list:
Table 12-2 summarizes the LSAs that are allowed in each area. Table 12-2. LSA Types Allowed in Each Area
NOTE RFC 2370 defines opaque link states. Opaque LSAs are Type 9, 10, and 11 link-state advertisements. These advertisements might be used directly by OSPF or indirectly by some application wanting to distribute information throughout the OSPF domain, such as RSVP. The function of the opaque LSA option is to provide for future extensibility of OSPF. The following section is taken directly from RFC 2370: 3.0 The Opaque LSA Opaque LSAs are types 9, 10 and 11 link-state advertisements. Opaque LSAs consist of a standard LSA header followed by a 32-bit aligned application-specific information field. Standard link-state database flooding mechanisms are used for distribution of Opaque LSAs. The range of topological distribution (i.e., the flooding scope) of an Opaque LSA is identified by its link-state type. This section documents the flooding of Opaque LSAs. The flooding scope associated with each Opaque link-state type is defined as follows. Link-state type 9 denotes a link-local scope. Type-9 Opaque LSAs are not flooded beyond the local (sub)network. Link-state type 10 denotes an area-local scope. Type-10 Opaque LSAs are not flooded beyond the borders of their associated area. Link-state type 11 denotes that the LSA is flooded throughout the Autonomous System (AS). The flooding scope of type-11 LSAs are equivalent to the flooding scope of AS-external (type-5) LSAs. Specifically type-11 Opaque LSAs are 1) flooded throughout all transit areas, 2) not flooded into stub areas from the backbone and 3) not originated by routers into their connected stub areas. As with type-5 LSAs, if a type-11 Opaque LSA is received in a stub area from a neighboring router within the stub area the LSA is rejected. Figure 12-6 illustrates a modern OSPF network, highlighting the different router types. Figure 12-6. OSPF Network Router types
OSPF AcknowledgmentsTo ensure that LSAs are transmitted successfully, OSPF requires each LSA to be acknowledged. LSAs are acknowledged by one of the following acknowledgment types:
To ensure that LSAs are current and valid, each LSA has a sequence number, a checksum, and a MaxAge value. The sequence number and checksum verify that the LSA is valid, whereas the age parameter ensures that the LSA is the most current LSA. MaxAge is used to verify how old the LSA was. MaxAge is set for 3600 seconds, or 1 hour . When a router originates an LSA, it sets the MaxAge at 0. Each time the LSA is flooded by another router, its MaxAge is incremented by another timer called InfTransDelay, which has a default value of 1. When the LSA reaches the MaxAge value, the LSA is reflooded throughout the network. Routers also use the MaxAge parameter when comparing two LSAs to determine which one is more current. This type of flooding can be excessive on large stable networks. In Cisco IOS 12.1, Cisco introduced a concept called LSA flooding reduction. LSA flooding control is discussed more in upcoming sections. OSPF Path TypesWhen you perform the show ip route command on OSPF, each route is classified in OSPF as one of six path types. The path is preceded by a tag representing the route's type. The path types and tags used are as follows:
Example 12-2 lists a complex route table with four types of OSPF routes. Example 12-2 Complex OSPF Route Table skynet# show ip route Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, * - candidate default U - per-user static route, o - ODR Gateway of last resort is 172.16.128.1 to network 0.0.0.0 10.0.0.0/24 is subnetted, 1 subnets O 10.10.10.0 is a summary, 03:05:49, Null0 129.201.0.0/24 is subnetted, 1 subnets O E1 129.201.1.0 [110/90] via 172.16.2.66, 03:05:45, TokenRing1 128.200.0.0/24 is subnetted, 1 subnets D EX 128.200.1.0 [170/679936] via 172.16.192.3, 05:42:57, Serial1 129.200.0.0/24 is subnetted, 1 subnets O E1 129.200.1.0 [110/90] via 172.16.2.66, 03:05:45, TokenRing1 128.201.0.0/24 is subnetted, 1 subnets D EX 128.201.1.0 [170/679936] via 172.16.192.3, 05:42:57, Serial1 C 201.201.101.0/24 is directly connected, Loopback0 O E2 132.31.0.0/16 [110/2] via 172.16.2.66, 00:58:04, TokenRing1 O E2 131.31.0.0/16 [110/2] via 172.16.2.66, 00:58:04, TokenRing1 172.16.0.0/16 is variably subnetted, 27 subnets, 4 masks O IA 172.16.152.0/24 [110/71] via 172.16.2.66, 03:05:45, TokenRing1 O IA 172.16.150.0/24 [110/80] via 172.16.2.66, 03:05:45, TokenRing1 O IA 172.16.151.0/24 [110/71] via 172.16.2.66, 03:05:45, TokenRing1 C 172.16.144.0/21 is directly connected, Loopback20 C 172.16.136.0/21 is directly connected, Ethernet1 C 172.16.128.0/21 is directly connected, Ethernet0 C 172.16.220.0/24 is directly connected, Loopback69 C 172.16.192.0/24 is directly connected, Serial1 C 172.16.192.3/32 is directly connected, Serial1 O IA 172.16.42.2/32 [110/70] via 172.16.2.66, 03:05:46, TokenRing1 O IA 172.16.42.3/32 [110/70] via 172.16.2.66, 03:05:46, TokenRing1 O E2 172.16.42.0/24 [110/2] via 172.16.2.66, 03:05:46, TokenRing1 O IA 172.16.42.1/32 [110/6] via 172.16.2.66, 03:05:46, TokenRing1 O IA 172.16.21.0/24 [110/76] via 172.16.2.66, 03:05:46, TokenRing1 O IA 172.16.22.0/24 [110/71] via 172.16.2.66, 03:05:46, TokenRing1 O E2 172.16.1.0/24 [110/2] via 172.16.2.66, 03:05:46, TokenRing1 O E2 172.16.2.0/24 [110/2] via 172.16.2.66, 03:05:46, TokenRing1 D 172.16.102.0/24 [90/679936] via 172.16.192.3, 05:42:59, Serial1 D 172.16.103.0/24 [90/409600] via 172.16.128.1, 05:42:59, Ethernet0 O E2 172.16.84.0/24 [110/2] via 172.16.2.66, 03:05:47, TokenRing1 O E2 172.16.85.0/24 [110/2] via 172.16.2.66, 03:05:47, TokenRing1 O E2 172.16.81.0/24 [110/2] via 172.16.2.66, 03:05:47, TokenRing1 O E2 172.16.82.0/24 [110/2] via 172.16.2.66, 03:05:47, TokenRing1 O E2 172.16.83.0/24 [110/2] via 172.16.2.66, 03:05:47, TokenRing1 O E2 172.16.64.0/24 [110/2] via 172.16.2.66, 03:05:47, TokenRing1 <<<text omitted>>> This section on the technical aspects of OSPF is meant to give you a solid background on OSPF fundamentals so that the configuration commands will have a firmer meaning when used. Several books have been written on OSPF describing in further detail OSPF packet structure, as well as other OSPF intricacies. For further reading, we suggest Jeff Doyles's Routing TCP/IP , Volume I; Tom Thomas's OSPF Network Design Solutions ; and John Moy's OSPF, Anatomy of an Internet Routing Protocol . The Cisco OSPF design guide on www.cisco.com and RFC 2328 also make good references. |
< Free Open Study > |