OSPF, or Open Shortest Path First is a link state routing protocol. It is a non proprietary Interior Gateway Protocol.
OSPF version 2 is defined in RFC 2328 and supports IPv4.
OSPF version 3 is defined in RFC 5340 and supports IPv6
OSPF works by sending neighbouring routers link state advertisements (LSAs) that contain the link state and link metric of a route. The LSAs that a router receives are stored in a local database called the LSDB, or link state database.
These LSAs are flooded throughout a OSPF routing domain in the same format as the original advertising router. This means that each OSPF router in the domain contains a synchronised copy of the LSDB for the OSPF area.
The link state database provides the topology of the network, giving a router a complete view of the surrounding network.
All OSPF routers run the Dijkstra shorted path first (SPF) algorithm to construct loop free topology of shortest paths around the network. OSPF can dynamically detect topology changes from within the network and calculate loop-free paths in a short time with minimal overhead protocol traffic.
At the top of the shortest path tree is where each router participating in OSPF will see itself. The SPT (shortest path tree) will show all the network destinations that can be reached within the OSPF domain.
The SPT will not show any redundant links, only the shortest path to any network it knows the route too from the link state database (LSDB). The SPT is rebuilt whenever a topology change is detected.
OSPF can be adjusted to scale easily by defining OSPF areas. Each OSPF area contains a collection of connected networks grouped together into an area.
There are two types of areas in OSPF, backbone and non-backbone. All non-backbone areas must connect to the backbone. The backbone area is known as Area 0, or the transit area. Networks are advertised from other networks into Area 0, and Area 0 advertises those networks into other areas directly connected to it.
From the outside of a non-backbone area, it’s topology is not fully visible. Routers do not have a complete topology map of that area, which helps save bandwidth and processing overheads. This means that all routers in a OSPF domain will no longer have identical link databases, but all routers within an area will be synchronised instead.
OSPF can run in multiple processes on one router, and the process number does not need to match with its neighbours. Routes learned in one OSPF process will not automatically be learned in another OSPF process on the same router.