OSPF Area Types

What is OSPF Area?
OSPF allows collections of contiguous networks and hosts to be grouped together.  Such a group, together with the routers having interfaces to any one of the included networks, is called an area. (RFC 2823)
OSPF areas are logical groupings of routers and networks devices. Each area contains separate LSD (link state database) whose information may be summarized towards the rest of the network by the connecting router. In OSPF area is represented by 32 bit area identifiers. The topology of an area is unknown outside of the area. The advantages of an area is include
·         Less routing Traffic in an area
·         Less Router’s memory consumption
·         Less CPU utilization
·         Smaller routing tables

OSPF area Types
*      Standard Area
*      Backbone Area
*      OSPF Stub area
*      OSPF Totally stubby Area
*      OSPF Not So stubby area

Standard Area
Normal area is known as Standard areas. This is basic types of area in OSPF. When you define an OSPF area with default setting e.g. which have no stub, backbone etc. is simply referred as standard area.
A standard area can contain LSAs of type 1,2,3,4, and 5.

Backbone Area
In OSPF area 0 is backbone area. A backbone area contains all the information of its connected areas. Backbone area is also responsible for distributing routing information to other area and to other automatous system connected to OSPF. All OSPF areas are must be connected to backbone area. This is basic requirement in OSPF, If this is not implemented then you need Virtual Links.

OSPF Stub area:
Stub area are good feature of OSPF, by using this you can minimize routing updates for a specific area and can make routing table smaller. OSPF stub Area block the external area route, block type-5 LSA for some area.
OSPF Stub area configuration:
For example in figure we want to make area-2 as stub so that R1 don’t receive any update of other areas but just a default route to R2. Following commands accomplish this goal. 
R1(config)#router ospf 1
R1(config-rtr)#area 2 stub

R2(config)#router ospf 1
R2(config-rtr)#area 2 stub

Totally stubby Area:
Totally stubby area is cisco proprietary and it blocks type 3, 4 and 5 LSA from entering into an area. Configurations are simple, you can see below.

R4(config-rtr)#area 1 stub no summary
R5(config-rtr)#area 1 stub

OSPF Not So stubby area:
NSSA is define in RFC 1587. A not-so-stubby area (NSSA) is a type of stub area that can import autonomous system external routes and send them to other areas. Since Type 5 LSAs are not allowed in NSSA areas, so the ASBR in NSSA generates a type 7 LSA instead, this type-7 LSA passes to backbone area and then converted back to types-5 LSA.
For more detail you can visit OSPF NSSA configuration.

Shortest Path First SPF algorithm (Dijkstra algorithm)

OSPF use SPF algorithm to calculate the shortest path between points in the network using Dijkstra algorithm. The Dijkstra SPF routing algorithm is the basis for OSPF operations.

How SPF works?
When a router is booted, it’s assured that its interfaces are up and working, then use the OSPF Hello packets to find neighbors. The router sends hello packets to its neighbors and receives their hello packets back. All routers exchange link-states by means of flooding. Each router that receives a link-state update using this router build its link state database and then propagate the update to other routers.
On multi-access environment, DR router is selected which is responsible for generating LSAs for the entire multi-access network.

When the link-state databases of two neighboring routers are synchronized, the routers are said to be adjacent. Then router uses the Dijkstra algorithm in order to calculate the shortest path tree. The destinations, the associated cost and the next hop to reach those destinations form the IP routing table.

The algorithm places each router at the root of a tree and calculates the shortest path to each destination based on cost required to reach that destination. Each router will have its own view of the topology even though all the routers will build a shortest path tree using the same link-state database.

Whenever there is a change in OSPF network, it is communicated through link-state updates, and the Dijkstra algorithm is recalculated in order to find the shortest path.

Consider the following network diagram with the indicated interface costs. Now suppose that router0 want to calculate the shortest path to router4, for this we make Router0 the root of the tree and calculate the smallest cost for its destination router4.

In network diagram you can see that Router0 have two paths to router4. One has total cost of 12(1+10+1) to reach router4 and second have a cost of 6(5+1). Router0 chose the second path as a shortest path using SPF because this path has less cost to reach. Similarly all routers in network set himself as root and calculate the shortest to destination.

OSPF Lab Examples:
OSPF DR/BDR selection By Loopback Configuration

OSPF Neighbor Relationship Process

OSPF neighbor relationship

Routers on the same network segment are called neighbors. Two routers connected with each other become neighbors if they have the same area-id, subnet, authentication and hello/dead intervals.
Neighbor process starts with hello packets. Hello packets are sent periodically out of each interface using IP multicast. Routers become neighbors as soon as they see themselves listed in the neighbor's Hello packet. This way, a two way communication is guaranteed. This process involves the following steps and states:

1.       First router determined OSPF RID
2.       Network command add OSPF interfaces into OSPF process and router run link-state   
3.       Hello packets are send out on OSPF running interfaces.

When OSPF router sends a hello message it is in down-state.
When router sends a hello packet it is down-state, hello message is send in 10s in broadcast / point to point network and after every 30s in NBMA (non broadcast multi-access)
Received Hello from other routers, in this state router check hello timer, check network ID, area ID and authentication.
Two-way State:
If already neighbor then update dead timer, if no then add as a new neighbor and move to next step.
Exstart State:
Master slave are selected in this state. A router having high priority will become Master if they have same then higher RID break the tie. Master sends the information first to slave.
Exchange State:
Routers will describe their entire link-state database by sending database description packets. At this state, packets could be flooded to other interfaces on the router.
Loading State:
In loading state router start save the information in memory. Slave send LSR (link state request), master reply with LSU (link state update), similarly master request for missing info by LSR and slave rely with LSU. By this process neighbors get synchronize.
Full State:
In full state neighbors are synchronized, SPF algorithm is run for calculation shortest path.

OSPF Lab Examples: