Sorry for newbie question for OSPF. I am in the process of learning the protocol, and there is some very basic thing I do not understand. In OSPF the routing is based on router id - which usually is one of its IP addresses. However what actually interests us, is the prefixes of the all the networks that router is directly attached to (that's the key to RIP routing tables if I am not mistake - and it really makes sense). So I am completely confused how given the destination packet IP we deduce the destination router (even before calculating the shortest path to it) without knowing network prefixes of all the networks that all routers in table are being attached to?
This link was very helpful:- https://supportforums.cisco.com/document/133976/reading-and-understanding-ospf-database
What makes you think, there is not a table of all the networks? OSPF is Link State routing protocol. So it has to know. (At least for networks inside an area. There are differences routing across areas.)
And by the way, usually (I am sure this is true for Linux/Unix based implementations, but there may be some other proprietary ways to implement it) the shortest path is not calculated when the packet is to be routed, but rather when the topology changes and is propagated to the routing table.
The difference between RIP and OSPF from this point of view is, that RIP sends the whole routing table periodically to all neighbours (which, when large, is quite a waste). OSPF only communicates the changes in topology.
There is a pretty good description of contents of OSPF packets.
LSA is a data structure that describe the network - it gets transferred in packet types 2 and 4(DBD and LSU). Packet type 3 (LSR) is used to request LSU from a router.
That contains enough information to reconstruct the topology of whole network.