OSPF Design Guide | Open shortest path first CCNP Concepts

What is OSPF (open shortest path first)?

OSPF is define in RFC 2328 according to this Open Shortest Path First (OSPF) is internet routing protocol.  OSPF is classified as an Interior Gateway Protocol (IGP).  This means that it distributes routing information between routers belonging to a single Autonomous System.
OSPF is stands for Open shortest Path first. In Routing world by path selection there are two types of protocols.

OSPF is a link state routing protocol, OSPF use SPF algorithm to find the best path. There are two versions for OSPF one is version 2 and other is version 3 which supports IPV6. OSPF is the most widely-used interior gateway protocol (IGP) in large enterprise networks. OSPF use the trigger update, mean whenever any change in network occur it converges on a new loop-free routing structure within seconds. OSPF use Dijkstra's algorithm to calculate shortest path.

.. There are three tables in OSPF.
1.       Neighbor table
2.       Topology table
3.       OSPF Routing table

What is OSPF cost?
OSPF metric is known as cost and OSPF Cost is the overhead required to send packets across a certain interface.
OSPF use the following formula for calculating cost for a link.
OSPF Cost=100 / (bandwidth in MB)
For more detail visit OSPF Cost.

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. Read more OSPFneighbor relationship

OSPF Network Types:

OSPF networks types is a big topic. There are following OSPF network Types.
1.       Broadcast/Multi-access Network
2.       OSPF Point to point
3.       OSPF Non-broadcast Multiaccess (NBMA)     
NBMA have five mode of working.
                                i.            Non-Broadcast (RFC Standard)
                              ii.            Point to Multipoint (RFC Standard)
                            iii.            Broadcast (Cisco Proprietary)
                             iv.            Point to point
                               v.            Point to point, Non Broadcast

Summarization in OSPF:
Summarization in OSPF is implemented on main routers like ABR & ASBR and also summary configuration is different for ABR and ASBR in OSPF.
On ABR you can use command
ABR#area 1 range
And on ASBR you need to use
ASBR# summary address  

LSAs are building block of OSPF. There are total 11 types of LSA.
1.       LSA Type-1| Router LSA from one network
2.       LSA Type-2| Network LSA from more network (DR Generated)
3.       LSA Type-3| Summary LSA (ABR summary Route)
4.       LSA Type-4| Summary LSA (just IP address of ASBR)
5.       LSA Type-5| External LSA (ASBR summary Route)
6.       LSA type-6 (not supported by Cisco)
7.       LSA type-7
Read more OSPF LSA Types

In OSPF there is a basic requirement while designing a network with multiple areas that every area is directly connected to backbone area 0. Virtual link comes when some area e.g. area-2 in figure is not directly connected to area 0. There is area-1 in between area-2 and backbone area-0, so in this case communication between area-0 and area-2 is not possible. To make communication between these areas you need to create virtual-links.

OSPF support different type of areas.
OSPF area Types
*      Standard Area
*      Backbone Area
*      OSPF Stub area
*      OSPF Totally stubby Area
*      OSPF Not So stubby area

OSPF DR\BDR election:
To avoid the broadcast in network, in shared Ethernet segment DR are elected. DR send multicast to
By default DR election base on router priority, router with high priority become DR  

How to configure OSPF on router
You can enable/configure OSPF on a router by following two methods.
·         Enable OSPF using network command in router process mode
·         Enable OSPF using IP OSPF command in interface mode
For more detail configure OSPF on router

OSPF Lab Examples:
Learn about Cloud Computing and Active Directory

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