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.
To configure an area as totally stubby, use the command "area <area-id> no-summary"
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".
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.
The Hello and Dead timers must match for forming neighbour relationship.
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
The routers should be in the same Area to form neighbour relationship.
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
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).
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.
OSPF is a link state technology that uses Dijkstra algorithm to compute routing information.
It has the following advantages 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.
Default cost of essential interfaces.
Interface Type bandwidth Metric Calculation Cost
Ethernet Link 10Mbps 100Mbps/10Mbps 10
FastEthernet Link 100Mbps 100Mbps/100Mbps 1
Serial Link 1544Kbps(default) 100Mbps/1.544Mbps= 64.76 64
OSPF uses SPT tree to calculate the best route for routing table. A SPT tree cannot grow beyond the area. So if a router has interfaces in multiple areas, it needs to build separate tree for each area. SPF algorithm calculates all possible routes from source router to destination network.
In short:Cumulative cost = Sum of all outgoing interfaces cost in route
Best route for routing table = Route which has the lowest cumulative cost
1. LSA (Link State Advertisement): LSAs are included in the database description packets (DDPs or DBDs). LSA entries include link-state type, the address of the advertising router, the cost of the link, and the sequence number.
2. LSR ( Link State Request): When a slave router receives an DDP (Database Description Packet), it sends and LSAck packet. Then it compares the received information with the information it has. If the DDP has more recent information, the slave router sends a link-state request (LSR) to the master router.
3. LSU ( Link State Update): LSU packet is sent in response to LSR (Link-State Request) packet sent from a slave router to a master router. LSU contains complete information about the requested entry.
The major advantages of hierarchical nature of OSPF are:
1. Reduced frequency of SPF calculations: This is because the packets are flooded only within an area, and not to the other areas.
2. Smaller routing tables: Routes can be summarized when being advertised out side an area, thus reducing the routing table entries.
3. Reduced LSU overhead: Fewer number of LSUs can be sent with a single or fewer summarized routes between areas to reduce the overhead associated with link-state updates when they are crossing areas.
Important features of stub area are:
Virtual-link in OSPF: Theoretically, all areas in an OSPF autonomous system must be physically connected to the backbone area (area 0). In some cases where this physical connection is not possible, you can use a virtual link to connect to the backbone through a non-backbone area. You can also use virtual links to connect two parts of a partitioned backbone through a non-backbone area. The area through which you configure the virtual link is known as a transit area.
Use the "area area-id virtual-link router-id" command in order to configure a virtual link, where the area-id is the area ID assigned to the transit area (this can be either a valid IP address or a decimal value), and where router-id is the router ID associated with the virtual link neighbor.
The command "show ip ospf virtual-links" will show up the status of virtual links of a router.
Sometimes when you issue a "show ip ospf virtual-link" the output shows that the Virtual-Link is UP, but you see no communication going on, neither a OSPF Relationship established. To make sure that the Virtual-Link is "really" working, issue a show ip ospf virtual-link command and see if the adcency state id FULL, and communication is there as given in the example below (typical output):
R(config-router)#do sh ip ospf virtual-link
Virtual Link OSPF_VL0 to router 18.104.22.168 is up
Run as demand circuit
DoNotAge LSA allowed.
Transit area 1, via interface Serial1/0, Cost of using 64
Transmit Delay is 1 sec, State POINT_TO_POINT,
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
Hello due in 00:00:08
Adjacency State FULL (Hello suppressed)
Index 2/3, retransmission queue length 1, number of retransmission 1
First 0x65593B80(11)/0x0(0) Next 0x65593B80(11)/0x0(0)
Last retransmission scan length is 1, maximum is 1
Last retransmission scan time is 0 msec, maximum is 0 msec
Link State retransmission due in 2986 msec
Yes, external and summary routes are not injected into a totally stubby area in an OSPF network. The advantages of totally stubby areas are reduced routing tables, faster convergence, and stability.
22.214.171.124 and 126.96.36.199 are the multicast addresses used by OSPFv2.
The command that is used for configuring OSPF in NBMA mode is : "ip ospf network non-broadcast". However, note that NBMA mode is used by default.
The statements identify that the process-id of the OSPF is 100, and the statement "area 1 stub no-summary" signifies totally stubby area. The router is connecting two area, and hence not a backbone router.
The following is true about OSPF area
The following are the types of OSPF routers:
1. Internal router: An internal router has all the interfaces in the same area. All internal routers have same link state databases.
2. Backbone router: Backbone routers sit on the perimeter of Area 0, with at least one interface connected to backbone (Area 0).
3. Area Border Router (ABR): ABRs are routers that have interfaces attached to multiple areas. It may be noted that these routers maintain separate link-state databases for each area that they are connected. They are capable of routing traffic destined for or arriving from other areas.
4. Autonomous System Boundary Router (ASBR): These are the routers that have at least one interface to the external network (another autonomous system). This autonomous network can be non-OSPF. ASBRs are capable of route redistribution, a term used to imply that the concerned router can import routing information from non-OSPF networks and distribute the same in OSPF network for which it is responsible and visa versa.
OSPF LSA Types
Different LSA types are described below:
a. LSA 1 (Router LSA): Generated by all routers in an area to describe their directly attached links (Intra-area routes). These do not leave the area.
b. LSA 2 (Network LSA): Generated by the DR of a broadcast or Nonbroadcast segment to describe the neighbors connected to the segment. These do not leave the area.
c. LSA 3 (Summary LSA): Generated by the ABR to describe a route to neighbors outside the area. (Inter-area routes)
d. LSA 4 (Summary LSA): Generated by the ABR to describe a route to an ASBR to neighbors outside the area.
e. LSA 5 (External LSA): Generated by ASBR to describe routes redistributed into the area. These routes appear as E1 or E2 in the routing table. E2 (default) uses a static cost throughout the OSPF domain as it only takes the cost into account that is reported at redistribution. E1 uses a cumulative cost of the cost reported into the OSPF domain at redistribution plus the local cost to the ASBR.
f. LSA 6 (Multicast LSA): Not supported on Cisco routers.
g. LSA 7 (NSSA External LSA): Generated by an ASBR inside a NSSA to describe routes redistributed into the NSSA. LSA 7 is translated into LSA 5 as it leaves the NSSA. These routes appear as N1 or N2 in the ip routing table inside the NSSA. Much like LSA 5, N2 is a static cost while N1 is a cumulative cost that includes the cost upto the ASBR.
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) - This type of packet will only have the external cost assigned, irrespective of where in the area it crosses. Type 2 packets are preferred over Type 1 packets unless there are two same cost routes existing to the destination.
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 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.
In an OSPF environment
1. A DDP (Data Description Packet) is used during the exchange protocol and includes summary information about link-state entries.
2. A hello packet is used during the hello process and includes information that enables routers to establish neighbor relationship.
3. An internal router is a router that resides within an area.