OSPF uses Dijkstra algorithm to calculate lowest cost route. The algorithm adds up the total costs between the local router and each destination network. The lowest cost route is always preferred when there are multiple paths to a given destination.
Note: By default, OSPF keeps 4 routes in routing table if there are 4 or more equal cost routes exist for the same subnet. However, OSPF can include up to 16 equal cost routes in the routing table and perform load balancing amongst them. In order to configure this feature, you need to use the OSPF sub command maximum-paths, i.e. maximum-paths 16.
Important characteristics of OSPF:
1. Route updates are only sent when routes change. Each router sends a link-state advertisement (LSA) whenever a change occurs in one of the routes known to the router.
2. LSAs contain information about the route that changed only.
3. Routers exchange "Hello" messages during the convergence process to build their neighbor tables.
4. OSPF, like RIP, is supported on non-Cisco routers.
5. OSPF, like RIPv2 supports variable-length subnet masking (VLSM).
6. OSPF supports an unlimited number of network hops. Compare it with only 15 hops supported by RIP.
7. OSPF scales out very well because
8. OSPF process identifier is locally significant. Two neighboring router interfaces can have same or different process ids. It is required to identify a unique instance of OSPF database
9. The Hello and Dead timers must match for forming neighbor relationship. Otherwise, adjacencies will not take place
10. The routers should be in the same Area to form neighbor relationship. By default Dead timer is configured as 4 times the Hello timer.
11. If no OSPF router ID is explicitly configured, OSPF computes the router-ID based on the items 2, 3, and 4 and restarts OSPF (if the process is enabled and router-ID has changed).
12. A router with highest priority becomes the designated router and a router with priority 0 can never become designated router. If the priorities are the same, then the router with the highest router ID becomes the DR.
13. An OSPF area is a collection of networks and routers that has the same area identification.
14. In an OSPF network, when a packet need to traverse from one area to another area to reach its destination, it is routed as below:
Source Area -> Source ABR -> Backbone Area -> Destination ABR -> Destination Area Routers
15. OSPF process identifier is locally significant. Two neighboring router interfaces can have same or different process ids. It is required to identify a unique instance of OSPF database.
16. OSPF determines the route by taking only bandwidth into account. Since AD, DC are configured with T3 links, it has the lowest path cost. In OSPF, the route entry used will always be the lowest cost path.
The sequence of steps followed in OSPF operation are as below:
1. Establish router adjacencies
2. Elect DR and BDR
3. Discover Routes
4. Choose appropriate routes for use
5. Maintain routing information.
OSPF must be configured with areas. The backbone area 0, or 0.0.0.0, must be configured if you use more than one area assignment. If you are configuring OSPF in a single area; you can choose any area number.
To enable OSPF on a Cisco router and advertise interfaces, the following tasks are required:
Step 1: Use the command "router ospf process ID" to start OSPF. Process ID is any number
Step 2: Use the network <ip-address> <wildcard-mask> area <area-id> command to enable
OSPF on specified networks
Step 3: Repeat for each area id.
Holddown timers prevent regular update messages from reinstating a route that has gone bad. Here, if a route fails, the router waits a certain amount of time before accepting any other routing information about that route. Holddowns tell routers to hold any changes that might affect routes for some period of time. The holddown period is usually calculated to be just greater than the period of time necessary to update the entire network with a routing change.
OSPF determines the router ID using the following criteria:
1. Use the address configured by the ospf router-id command
2. Use the highest numbered IP address of a loopback interface
3. Use the highest IP address of any physical interface
4. If no interface exists, set the router-ID to 0.0.0.0
OSPF Path cost: The path cost in OSPF network is calculated using bandwidth only. The formula used is [10 ^8 divided by Bandwidth]. For example, the cost of a 56kbps serial link is 1785. The default cost of a 10mbps Ethernet is 10.
The "hello" packets are sent periodically out of each interface using IP multicast addresses. The hello interval specifies the frequency in seconds that a router sends hello's. This is 10 seconds on multi access networks.
OSPF is a link state technology that uses Dijkstra algorithm to compute routing information.
Advantages of OSPF over Distance Vector protocols such as RIP:
1. Faster convergence: OSPF network converges faster because routing changes are flooded immediately and computer in parallel.
2. Support for VLSM: OSPF supports VLSM. However, please note that RIP version2 also supports VLSM.
3. Network Reachability: RIP networks are limited to 15 hops. Therefore, networks with more than 15 hops can not be reached by RIP by normal means. On the other hand, OSPF has practically no reachability limitation.
4. Metric: RIP uses only hop count for making routing decisions. This may lead to severe problems in some cases, for example, that a route is nearer but is very slow compared to another route with plenty of bandwidth available. OSPF uses "cost" metric to choose best path. Cisco uses "bandwidth" as metric to choose best route.
5. Efficiency: RIP uses routing updates every 30 seconds. OSPF multicasts link-state updates and sends the updates only when there is a change in the network.
OSPF Configuration Example:
Enter into global configuration mode
Router(config)#router ospf 1
router ospf 1 specified process id of 1 (process ids need not be unique between routers)
Router(config-router)#network 192.168.2.0 0.0.0.255 area 200
In the above command:
Network IP address: 126.96.36.199
Wild card mask: 0.0.0.255
Area ID: 200
A default route can be advertised into OSPF domain by an ASBR router in one of two ways:
By using "default-information originate" command: This command can be used when there is a default route (0.0.0.0/0) already existing. This command will advertise a default route into the OSPF domain.
By using "default-information originate always" command: This command can be used when there is a default route (0.0.0.0/0) is present or not. This command is particularly useful when the default route is not consistent. An inconsistent default route may result in flipping of the route advertised into the OSPF domain, resulting in instability of the OSPF domain routing information. Therefore, it is recommended to use "always" keyword.
The cost of external route depends on the configuration of ASBR. There are two external packet types possible.
1.Type 1 (E1) : Here the metric is calculated by adding the external cost to the internal cost of each link that the packet crosses.
2.Type 2 (E2) : E2 is the default route type for routes learned via redistribution.
To modify router priority in an OSPF ip network, issue the command :
ip ospf priority <number>
where <number> is any number between 0 and 255. The default is 1.
OSPF show commands :
The command "show ip ospf database" displays the contents of the topological database maintained by the router. This command also displays router id and the ospf process id.
The following is sample output of the "show ip ospf database" command
The Link ID is actually the link-state ID. It is the ID of the router in the area. The ADV Router is the ID of the router that sent the LSA. As you can see, the router with the ID 192.168.3.1 is advertising 5 links into the area. Router LSA are flooded to every other router in the area. So neighboring routers will send LSA about other routes they know about to their neighbors so everyone is "on the same page". so to speak.
A more specific command for showing the interfaces running OSPF is "show ip ospf interfaces". The command "show ip ospf interfaces" shows the summary information for OSPF interfaces. The information provided include autonomous system number, router id, designated router id, backup designated router id, hello time, and adjacent neighbors.
The following is sample output of the "show ip ospf interfaces" command
The following describes filelds in the display
The command "show ip ospf virtual-links" will show up the status of virtual links of a router.
In an OSPF network, Type 2 LSAs are generated by a Designated Router (DR). Type 2 LSAs describe the set of routers attached to a particular network and are flooded within the area that contain the network only.
The following is sample output of the show ip ospf virtual-links command:
The following describes the fields in the display:
The major advantages of hierarchical nature of OSPF are:
Important features of stub area are:
The router is an ABR (Area Border Router) since it connects two OSPF areas. Area 2 is configured as stubby and not totally stubby. To configure an area as totally stubby, use the command "area
The cost of the default route that is injected into the stub area is equal to 1 by default. To change this value, use the command "area <area-id> default-cost <cost>" command. For example, if you want to set a value of 5 for the default route, use the command "area 2 default-cost 5".