Each router uses the SPF algorithm against the LSDB to build the SPF tree. The SPF tree is used to determine the best paths.
As shown in the figure, the order in which the best paths are calculated is as follows:
1. All routers calculate the best paths to destinations within their area (intra-area) and add these entries to the routing table. These are the type 1 and type 2 LSAs, which are noted in the routing table with a routing designator of O. (1)
2. All routers calculate the best paths to the other areas within the internetwork. These best paths are the interarea route entries, or type 3 and type 4 LSAs, and are noted with a routing designator of O IA. (2)
3. All routers (except those that are in a form of stub area) calculate the best paths to the external autonomous system (type 5) destinations. These are noted with either an O E1 or an O E2 route designator, depending on the configuration. (3)
When converged, a router can communicate with any network within or outside the OSPF autonomous system.