Lets jump into OSPF today and get to know few basics. OSPF stands for Open Shortest Path First. It is classified under IGP group of protocols. It is an example of a link-state routing protocol. Specifically the name of the algorithm used in OSPF is Dijkstra’s Algorithm. We will talk about it in a later post. The major way of functioning of a Link State Protocol (and hence OSPF), is exchanging the topology information using the “link states”. The link state implies that we include information about the link as well as the current state of the link. All the link states together form the Link State Database (LSDB).
Let me point out the steps into enabling and running OSPF in a network:
- Identify the OSPF routers by marking each of them with a unique router id.
- Establish adjacency and neighbor relations between the router in the network.
- Exchange the link state database so that each router can calculate the shortest path to each link using the SPF algorithm.
- Whenever a new link is added or there is a change in topology, then an update is triggered to the entire network. If no changes occur then the link information are refreshed after 30 mins to ensure that the database state is accurate and current.
Assigning the Router ID
Router ID is used to simply identify the router. It is of the 4 byte IP address format A.B.C.D. It is not an address that need to be reachable using the routing table. The ID can be explicitly mentioned or can be derived from the existing IP addresses on the router. The sequence to be used is -
- If an explicit router id is mentioned, then this id is preferred. Usually the command is router-id <A.B.C.D>.
- If no router id is mentioned explicitly, then use the highest IP address from the available up and running loopback interfaces.
- If no loopback interfaces are present, then use the highest IP address from the available up and running physical interfaces.
A router ID once configured (or derived), doesnt change till the OSPF process is refreshed in the router. If a router ID changes, then all routers in the network need to rerun their SPF calculations.
Router IDs are used to identify the routers and they are also used in many other steps during the setting up of OSPF adjacency as will be described later.
OSPF is a pure Layer 3 routing protocol and the messages are encapsulated directly into IP packets. The IP protocol number for OSPF is 89.
Each and every step in OSPF be it the establishment of neighbor relationships, exchanging of the link state database and establishing the complete adjacency, is done with the help of OSPF messages (or packets). We will establish here a term that is used to describe all link state packets – Link State Advertisements (LSA). There are 5 different types of OSPF messages -
- Hello Packets – This is used for finding neighbors, establishing neighbor relationships and checking the liveliness and availability of the neighbor.
- Database Description (DBD) Packets – These are used to exchange the LSA headers, so that a router create a list of LSAs that it will need from a neighbor.
- Link-State Request (LSR) Packets – These packets contains a list of one or more LSAs which the router wants its neighbor to send complete details about.
- Link-State Update (LSU) – These packets the complete LSAs. These are sent usually in response to an LSR message.
- Link-State Acknowledgement (LSAck) – These packets are sent to confirm receipt of an LSU message.
States of an OSPF Router
Lets briefly list here the various OSPF states. I will talk about them in greater detail in a future post.
- Init – As soon as OSPF is enabled in a router, the Init state is achieved.
- 2-Way – An OSPF router transitions to 2-Way state once bi-directional hello exchange has been done per router. As we will see later, DR and BDR election is done during this state if required.
- ExStart – During this state, a Master-Slave relationship is achieved between each neighbor. This is based on the Router IDs of the neighbors.
- Exchange – During this state, DBD packets are exchanged between the neighbors and the routers create LSRs.
- Loading – The actual exchange of the LSAs occur during this state using LSRs, LSUs and LSAcks.
- Full – Once all LSAs have been exchanged, the router transitions to Full State.
This was a brief introduction to OSPF. I will keep discussing all the above concepts and many more in detail in later posts.