OSPF (Open Shortest Path First) is an advanced routing protocol used to determine where to route packets in a IGP (Interior Gateway Protocol) network. This type of routing protocol is considered to be a link-state protocol. Link-state routing differs from distance vector routing (such as RIP) in many ways but there are some similarities. Besides routing data throughout networks, these two type of protocols send their routing updates to their neighboring routers and in turn their neighboring router forwards these updates to their neighbors and so on.
There are many more differences than similarities between link-state and distance vector protocols however. Routers using link-state advertises every detail about the internetwork to all other routers. After all routers complete this process, every router will have the same exact information about the internetwork. This information is saved in a database on each router in whats called a link-state database or (LSDB). Similar to the way every car traveling to a destination on the same interstate highway may have the exact same United States map. However each car may be traveling to a different destination and each car will be traveling in a certain direction depending on where they are located in the US so they will use the map to determine the best way to get to a specific destination from their location. OSPF works the same way, the LSDB is the map and depending on where the router is located and where it's trying to send data too, it will use the LSDB to determine the best route to get to its destination.
In order for each router to learn about what IP address and networks are located in the internetwork, OSPF uses what's called Link-state Advertisements (LSA's). The two main types of LSA's is the Router LSA and the Link LSA. The Router LSA includes router ID info, interface IP addresses, the state of each interface, and the cost or metric that's associated with each interface. The Link LSA identifies each link (subnet) and the routers that are attached to that link. The link state (up or down) isw also included in the LSA. By default OSPF refloods LSA's every 30 minutes unless network changes such as down interfaces occur.