Let’s say the link speed between two routers is 1544 Kbps (1544000 bps) then the link cost would somewhere be around 64 by using the above formula. In this case, 64 becomes the link cost between two routers.
The OSPF uses different kinds of tables to keep track of the routers and maintain a set of the databases.
Neighbor tables contain the routers directly connected to different interfaces of a router. It is also known as the adjacency table. Neighbor table is often used in troubleshooting if there is no communication between two routers. Neighbor table of a router is checked at first hand to see if two routers make neighbors at all.
Database table also refers to LSDB (Link State Database). It contains all the possible routes to different routers in the network.
The routing table is used to find the best possible path to any router in the network.
There are seven stages in which OSPF works. Here are they:
Initially, all the routers will be in the down state. That means all the routers are oblivious to all the routers in an autonomous system.
B. Initialization State
Once a router is powered up, it begins advertising by sending hello packets to the adjacent routers. In the hello packet, it also sends the IP address of the interface through which it sends the hello packet. The hello packet is sent to a multicast address at 220.127.116.11 and is delivered to all the routers.
C. Two Way State
Once all the routers receive the hello packet. The routers open the hello packet and look at the IP address. After processing the hello packet, routers conclude that if the received packet is from the same network or not. If the received packet is from the same network, then they look at the interface from where the packet was received.
Once the interface has been identified, the other router receiving the packet replies to the first router by unicasting its own hello packet along with its IP address. This way, both the routers can know they’re neighbors. This is called two-way state because Router A becomes the neighbor of Router B and vice versa.
D. ExStart State
ExStart state is dependent on another concept used in the OSPF called Router ID. The Router ID is the name of the router.
Router ID is the highest physical interface of the router. Sometimes, a router might have a logical interface configured as well, in that case, the router Id will be the highest IP address of the logical interface.
Coming back to the ExStart State, it is not about exchanging the information between two routers, but it’s more about deciding which router shares the information first.
So, both the routers compare their router IDs. The router with the higher router ID will get the privilege to start sharing information first.
E. Exchange State
After the ExStart state, the real exchange happens in the exchange state only. The routers share summaries of the database that they have. The database is called LSDB (Link State Database).
F. Loading State
In the loading state, the router compares its database against the database it receives from the neighbors. That’s because OSPF relies on the fact that all the routers in the network should have the same network database and topology.
LSR (Link State Request)
In case there is a discrepancy in the link state database, the router sends the link state request, also known as LSR, to its neighbor requesting for more information about a particular network which is mismatched.
Link State Update (LSU)
Once a router receives the LSR, it replies with LSU which contains the updated information.
LSAck (Link State Acknowledgement)
Once the router receives the LSU, it sends the LSAck.
G. Full State
When all the routers have the same database, the network is in the final stage of the OSPF we call Full State. Now when a router receives a packet, based on the maintained databases, it calculates the best path and sends the packet.