Introduction to OSPF
If you are preparing for Cisco CCNA or Cisco CCNP or higher exams you will need to learn OSPF routing protocol. OSPF (Open Shortest Path First) is link-state routing protocol which we shall learn in this post. Before understanding OSPF, lets talk about navigation system like google maps which you use on your smart phones to get to your destination. Google maps has complete knowledge of the city or territories which provides us loop free navigation services. OSPF works like google maps as it build the complete network map called LSDB (Link State Database) and then runs its Dijkstra algorithm to calculate the best path to your destination subnet / network.
Link-state routing protocols operate by sending link-state advertisements (LSA) to all other link-state routers. The link-state advertisement (LSA) is a basic communication means of the OSPF routing protocol for the Internet Protocol (IP).
All the routers need to have these link-state advertisements so they can build their link-state database or LSDB. Basically all the link-state advertisements are a piece of the puzzle which builds the LSDB.
So if there is a network of OSPF speaking routers connected with switch, so each router will advertise its LSA to form neighborship with other routers. This will create a full mesh of OSPF neighbors. This will cause huge LSAs traffic over the network.
OSPF Designated Router DR
What if all our OSPF routers would just send their LSAs to a single OSPF router who will then forward it to all the other OSPF routers? All our OSPF routers will know about all the routing information out there but we will have far less OSPF traffic. OSPF uses something called a DR (Designated Router). All our OSPF routers will only form a “full” neighbor adjacency with the DR and not with all the other routers. this will significantly reduce LSA advertisements into our network.
OSPF Backup Designated Router
Since bad stuff can happen to our networks we want to have backup for our Designated Router. If it
crashes the BDR (Backup Designated Router) will take over. All our OSPF routers will only form full neighbor adjacencies with the DR and BDR and not with all other routers.
OSPF Designated Router and backup designated router are used in multiaccess network. There is no need to use designated routers and backup designated router in point-to-point networks.
What is an OSPF Area?
OSPF works with the concepts of areas and by default you will always have a single area, normally this is area zero (area 0) or also called the backbone area. The main benefit of creating areas is a reduction in the number of routes to propagate – by the filtering and the summarization of routes. as per Cisco:
An OSPF network can be divided into sub-domains called areas. An area is a logical collection of OSPF networks, routers, and links that have the same area identification.
What are OSPF Area types?
- Backbone area, also called the backbone area, is actually area 0. According to the OSPF design principle, area 0 plays the role of the central node in the OSPF network. The link information of other areas is transmitted through area 0. This also means that all other areas must be connected to area 0. This area supports 1, 2, 3, 4, and 5 LSAs.
- Standard area, also called the standard area, means that in this area, OSPF packets can be normally transmitted. This area supports Link state Advertisements from1, 2, 3, 4, and 5 LSAs.
- Stub area, also called stub area, the so-called stub area, means that the area does not accept any external routes of non-OSPF network, if it wants to reach those external routes, only Need to send it through the default route. This area supports 1, 2, and 3 LSAs.
- Totally stubby area, also called completely stub area, it means that the area does not accept external routes and does not accept the link information of other areas outside of their own area. If it wants to reach the target network outside the area, it will send out the message through the default route just like the stub area. It should be noted here that since the default route is sent using Type 3 LSAs, the completely stub area does not allow ordinary Type 3 LSA packets, but it supports this type of LSA with default routes. This area supports Type 1, Type 2 LSAs, and Type 3 LSAs with default routes.
- No so stubby area, is usually referred to as the NSSA, this NSSA is actually derived from the stub area, it means that in the case of a stub area, it also has to send external routes to other areas ability. This area supports 1, 2, 3, and 7 LSAs. Note here that there is another mode in the Totally stubby area zone, which is the NSSA of the completely stub area mode. In fact, this mode allows the introduction of external routes in a completely stub area environment. This area mode supports Class 1, Type 2 LSAs, and Class 3 LSAs with default routes.
You can have multiple areas and All of these areas must connect to the backbone area. If you want to go from area 1 to area 2 you must go through the backbone area to get there. It’s impossible to go from area 1 directly to area 2; you always have to pass the backbone area! Same thing if you want to go from area 3 to area 2…you must cross the backbone area. This rule ensures that network remained loop free.
OSPF Routing Protocol Related Articles
OSPF Router Types
- Routers in the backbone area (area 0) are called backbone routers.
- Routers between 2 areas (like the one between area 0 and area 1) are called area border routers or ABR.
- Routers that run OSPF and are connected to another network that runs another routing protocol (for example EIGRP) are called autonomous system border routers or ASBR.
OSPF Hello Packet
Once you configure OSPF your router will start sending hello packets. If the router also receive hello packets from the other router they will become neighbors. Once OSPF routers have become neighbors they are going to exchange link-state advertisements. There are a couple of fields in the hello packet and many of them have to match otherwise you won’t become neighbors.
- Router ID: Each OSPF router needs to have an unique ID which is the highest IP address on any active interface. More about this later.
- Hello / Dead Interval: Every X seconds we are going to send a hello packet, if we don’t hear any hello packets from our network for X seconds we declare you “dead” and we are no longer neighbors. These values have to match on both sides in order to become neighbors.
- Neighbors: All other routers who are your neighbors are specified in the hello packet.
- Area ID: This is the area you are in. This value has to match on both sides in orderto become neighbors.
- Router Priority: This value is used to determine who will become designated or backup designated router.
- DR and BDR IP address: Designated and Backup Designated router.
- Authentication password: You can use clear text and MD5 authentication for OSPF which means every packet will be authenticated. Obviously you need the same password on both routers in order to make things work.
- Stub area flag: Besides area numbers OSPF has different area types. Both routers have to agree on the area type in order to become neighbors.
Each OSPF router needs to have an unique router ID which is based on the highest IP address on any active interface, there is a catch here however. On any Cisco router you can create loopback interfaces which is like a virtual interface. You can configure an IP address on it and when you try to ping it you will always get a response.
If you have a loopback interface on your OSPF router then this IP address will be used as the router ID even when it’s not the highest active IP address. Why does OSPF do this? Well it makes sense…your loopback interface will never go down unless your router crashes.
Best practice: Configure router id statically by using router-id command in cisco.
How does OSPF calculates path?
If we recall from distant vector protocols, they used metric to calculate the path. The metric is what the routing protocol uses in order to determine the best path. OSPF uses a metric called cost which is based on the bandwidth of an interface, it works like this:
Cost = Reference Bandwidth / Interface Bandwidth
The reference bandwidth is a default value on Cisco routers which is a 100Mbit interface. You divide the reference bandwidth by the bandwidth of the interface and you’ll get the cost.
OSPF Cost = Reference bandwidth / Interface bandwidth.
OSPF Cost = 100 Mbit / 100 Mbit = 1
OSPF Cost = 100 Mbit / 10 Mbit = 10
Ospf Cost = 100 Mbit / 1 Mbit = 100
The lower the cost the better the path is.
What if multiple OSPF paths have equal cost?
The answer is load balancing. We are going to use both paths and OSPF will load balance among them 50/50. Some things worth knowing about OSPF load balancing:
- Paths must have an equal cost.
- 4 equal cost paths will be placed in routing table.
- Maximum of 32 paths.
- To make paths equal cost, change the “cost” of a link
If a path is not equal we can make it so by manually changing the cost or bandwidth of an interface.
Well, that’s enough of the introduction to OSPF, in this post we have covered a lot of the basic terminologies of OSPF which included OSPF DR, OSPF BDR, OSPF Areas, OSPF Area Types, OSPF Router Types, OSPF LSA Types, OSPF Hello Packet, OSPF Router ID, OSPF Path Calculation & OSPF Equal Cost Load-balancing. I hope this has been informative for you, i next lesson we shall configure OSPF and verify the neighborship using show commands.