Open Shortest Path First (OSPF) is a widely used link-state routing protocol that enables routers to determine the best path for data packets within an IP network. OSPF operates as an Interior Gateway Protocol (IGP) and utilizes the Shortest Path First (SPF) algorithm, also known as Dijkstra's algorithm, to calculate optimal routes.
To master OSPF and enhance your skills, consider enrolling in Cisco enterprise training, which provides comprehensive knowledge and hands-on experience with this essential networking protocol.
There are two types of OSPF states:
1. OSPF Interface States: These states determine how an interface interacts with the OSPF process and include parameters such as the Hello interval, Dead interval, and network type.
2. OSPF Neighbor States: It describes the various stages a router goes through to establish and maintain relationships with neighboring routers. These states are crucial for forming adjacencies and exchanging routing information. Neighbor states include transitions such as Down, Init, 2-Way, Exstart, Exchange, Loading, and Full.
This article covers the two types of OSPF states in networking. After reading this article, you will have a complete understanding of the OSPF interface states and OSPF Neighbor states in order.
In OSPF, interfaces represent the connections between routers, configured with parameters like the Hello interval and Dead interval, which are vital for maintaining neighbor relationships.
OSPF uses Hello packets to discover and maintain these relationships, allowing routers to share routing information effectively. Notably, OSPF routers establish their link states even before sending Hello packets or forming adjacencies.
After initial communication, OSPF routers exchange Link State Advertisements (LSAs) to build a Link State Database (LSDB). This database is used to calculate the best paths through the network using the Shortest Path First (SPF) algorithm.
If you seek to achieve the certification and live CCNP training online then feel free to contact our learning advisors.
The command "show ip ospf interface" depicts various components of the Interface data structure
The components of the interface data structure are:
1. IP Address and Mask: Configured on the interface, this address serves as the source for OSPF packets originating from it.
2. Area ID: Identifies the OSPF area assigned to the interface or process. OSPF packets from this interface will carry this Area ID.
3. Process ID: Unique to each router, this ID indicates the OSPF process to which the interface belongs. Cisco routers can support multiple OSPF processes.
4. Router ID: This unique identifier for the router is typically the highest IP address of any loopback interface or the highest IP address of an active interface.
5. Network Type: The various OSPF network types configured on an interface include:
● Broadcast
● Point-to-Point
● Non-Broadcast Multi-Access (NBMA)
● Point-to-Multipoint
● Virtual Link
6. Cost: This metric, ranging from 1 to 65535, represents the overhead for using this interface in OSPF routing decisions. The default cost is 1 but can be modified using the "ip ospf cost" command.
7. Link State Database (LSDB): This database contains all the Link State Advertisements (LSAs) received from neighboring routers. Each router maintains its own LSDB, which is synchronized with its neighbors.
8. Routing Table: Derived from the LSDB, this table contains the best paths to reach various destinations within the network.
9. Neighbor Table: This table keeps track of adjacent routers and their states, helping OSPF manage communication efficiently.
Interface states represent the operational status of OSPF-enabled interfaces on a router. These states are crucial for determining how interfaces interact with the OSPF protocol and facilitate the establishment of neighbor relationships
In this type of state, an interface enabled with OSPF transitions into 5 interface OSPF states before stating functioning. These states are as follows
It's an initial interface state in which no protocol traffic is passing through and the interface is not functional
This state comes into the picture only when interfaces are connected to OSPF network-type point-to-point, point-to-multipoint, and virtual links.
In this state, an interface is functional and starts sending Hello packets in every HellowInterval to form an adjacency with the neighbor
It is applicable only to broadcast and NBMA OSPF network types. When the OSPF interface is in this state, it starts sending and receiving Hello packets and sets the wait timer.
In this state, the router also attempts to identify DR and BDR.
When an OSPF router is a BDR on a network and establishes adjacencies with other routers on a multi-access network
In this state, the interface is loopback. The OSPF interface address still advertises in router LSA
Now similarly to understand OSPF neighbor states, we need to know OSPF neighbor and its data structure
OSPF (Open Shortest Path First) neighbor states represent the stages a router goes through to establish and maintain relationships with other OSPF routers. Initially, routers send Hello packets to discover neighbors. When they recognize each other's router IDs in these packets, they confirm bidirectional communication.
Following this, they synchronize their Link State Databases (LSDBs) through various exchanges to ensure consistent routing information. Achieving full adjacency allows OSPF routers to share and update routing information effectively.
OSPF router adjacency forms in the following four phases:
When Hello packets are received from the neighbor routers
When both neighbor routers have each other's router ID in their Hello packets
When both neighbor routers have the same information in their link state database after exchanging the following with each other
● Database Description
● Link State Request
● Link State Update Packets
In this case, one router becomes the master who controls the exchange of data description packets and the other becomes a slave.
An OSPF router sends Hello packets containing the information stored in the interface data structure to its neighbor to inform about itself. Similarly, neighbor routers maintain a neighbor data structure learned from other routers' Hello packets. This is 2-way communication with each other.
The command "show ip ospf neighbor" gives more insight into understanding the OSPF neighbor data structure.
The components of the OSPF neighbor data structure are as follows
1. Neighbor ID: This is the router ID of the neighbor.
2. Neighbor IP Address: This is the IP address of the neighbor's interface attached to the network
3. Area ID: This ID has to be the same for two OSPF routers to become neighbors. The area ID is present in the Hello packets received on an interface.
4. Interface: The interface attached to the network on which the neighbor is located.
5. Neighbor Priority: This is the router priority of the neighbor which is advertised in Hello packets. The DR/BDR election uses the router priority.
6. State: This is the state of the neighbor
7. PollInterval: This value is used only in NBMA networks
8. Neighbor Options: This is an optional value for OSPF capabilities supported by the neighbor.
9. Inactivity Timer: It is RouterDeadInterval. This timer is reset whenever the router receives a Hello packet from the neighbor.
10. Designated Router (DR): The Address is present in the DR field of the neighbor's Hello packets.
11. Backup Designated Router (BDR): The Address is present in the BDR field of the neighbor's Hello packets.
12. Master and Slave: It defines which router will control the database synchronization. This relationship is exchanged in the ExStart state.
13. Database Description (DD) Sequence Number: The Sequence Number of the DD packet currently sent to the neighbor.
14. Last Received DD Packet: This information is used to determine whether the next DD packet is a duplicate.
15. Link State Retransmission List: This component is a list of flooded LSAs on the adjacency, but not yet acknowledged.
16. Database Summary List: These are LSAs sent to the neighbor in Database Description packets during database synchronization. These LSAs make up the link state database when the router goes into an exchange state.
17. Link State Request List: Link State Request packets are sent to the neighbor for copies of these LSAs; as the requested LSAs are received in Link State Update packets, the Request List is depleted.
An OSPF neighbor router goes through 8 OSPF neighbor states before the neighbor becomes fully adjacent
These are the initial OSPF states of a neighbor. No Hellos were received from the neighbor in the last RouterDeadInterval, Hellos are sent every PollInterval.
If a neighbor transitions to a Down state from some higher state then the following are cleared
● Link State retransmission List
● Database Summary List
● Link State Request List
The attempt state is only valid to neighbors on NBMA networks where neighbors are manually configured. A router sends Hello packets in the Attempt state. A
DR-eligible router transitions a neighbor to the Attempt state when the interface to the neighbor first becomes Active or when the router is the DR or BDR.
An OSPF router includes its own and neighbor's router ID in Hello packets. In the Init state, a Hello packet is received from a neighbor but can not see its own router ID in the packet. 2-way communication is not completed yet.
In this state, the router sees his router ID in the Hello packets received from the neighbor. On multi-access networks, neighbors must be in this state to be eligible to be elected as the DR or BDR.
In the Cisco OSPF ExStart state, the router and its neighbor form a master and slave relationship with each other to determine the initial DD sequence number for exchanging Database Description packets. The neighbor with the highest interface address becomes the master.
The router sends database description (DBD) packets summarizing its link state database to neighbors. It may also send Link State Request (LSR) packets and request the most updated LSA to neighbors.
The router sends Link State Request packets to neighbors in the Loading state, requesting more recent LSAs that have been discovered in the Exchange state but have not yet been received.
Neighbors in this state are fully adjacent, and the adjacencies will appear in Router LSAs and Network LSAs.
Now let's look at the OSPF neighbor states in the process of database synchronization
Step 1: OSPF is enabled on R1 and becomes active on the multi-access network. It starts sending Hello packets. The Neighbor field of the packet is empty because not yet received Hello packet from any neighbor. The DR and BDR fields are set to 0.0.0.0.
Step 2: When R2 receives Hello from R1, it creates a neighbor data structure for R1 and set R1's state to Init. Now R2 sends a Hello packet to R1 with R1's router ID in the neighbor field and its own interface IP address in the DR field.
Step 3: When R1 receives a Hello from R2, it sees its own router ID in the packet. R1 creates a neighbor data structure for R2 and sets R2's state to ExStart for the master/slave negotiation.
R1 sends the packet to R2 contains the following
1. It generates an empty Database Description (DD) packet with a random sequence number x
2. It sets I-bit to indicate that this is R1's initial DD packet for this exchange 3. It sets M-bit to indicate that this is not the last DD packet
4. It also sets MS-bit to indicate that R1 is claiming itself as the master
Step 4: When R2 received the DD packet, it transitions R1's state to ExStart.
Now R2 sends the packet to R1 contains the following
1. DD packet with a DD sequence number of y
2. R2 sets MS-bit because it has the higher router ID than R1
3. Empty DD packet because this one is used for the master/slave negotiation
Step 5: R1 Upon receiving the packet from R2, it accepts R2 as the master and transitions R2's state to Exchange.
R1 sends the packet to R2 containing the following
1. It generates a DD packet with R2's DD sequence number of y
2. It sets MS = 0, indicating that R1 is the slave
3. R1's LSA headers from its Link State Summary list to populate
Step 6: When R2 receives a DD packet from R1, it changes its neighbor state to Exchange. Now It sends a DD packet to R1, containing LSA headers from its Link State Summary list. It also increments the DD sequence number to y+1.
Step 7: When R1 receives the packet, it sends an acknowledging packet containing the same sequence number as in the DD packet it just received from R2.
The process of R2 sending a single DD packet and wait for an acknowledgement with same sequence number before sending the next packet continues. It keeps happening until when R2 sends the DD packet with the last of its LSA summaries and sets M = 0,
Step 8: When R1 receives this packet for sending the last of its own LSA summaries. R1 comes to know that the Exchange process is done. However, if it has entries in its Link State Request list then it transitions its state to Loading.
Step 9: When R2 receives R1's last DD packet, it transitions R1's state to full because it has no entries in its Link State Request list.
Step 10: R1 sends Link State Request packets, and R2 sends the requested LSAs in Link State Update packets until R1's Link State Request list is empty. RT1 will then transition R2's state to Full.
OSPF (Open Shortest Path First) operates through a series of states to establish and maintain neighbor relationships among routers. These states include Down, Attempt, Init, 2-Way, ExStart, Exchange, Loading, and Full. The process begins with routers in the Down state, where no Hello packets have been exchanged.
As they progress, they establish bidirectional communication and exchange routing information until they reach the Full state, indicating complete adjacency and synchronized databases. Understanding these states is crucial for effective OSPF troubleshooting and optimization in network environments.
Engaging in IT infrastructure training can further enhance your skills in managing OSPF effectively.
He is a senior solution network architect and currently working with one of the largest financial company. He has an impressive academic and training background. He has completed his B.Tech and MBA, which makes him both technically and managerial proficient. He has also completed more than 450 online and offline training courses, both in India and ...
More... | Author`s Bog | Book a Meeting