When routers that run OSPF are initialized, an exchange process occurs, with the Hello protocol as the first procedure.
當執行 OSPF 的路由器初始化時,會發生一個交換程序,第一個步驟就是 Hello 協定。
When the point-to-point links are used or configured, the figure illustrates the exchange process that happens after routers appear on the network:
當使用或設定點對點鏈路時,下圖說明了路由器出現在網路上之後所發生的交換程序:
- A router interface is enabled on the network. The OSPF process is in a down state because the router has not yet exchanged information with any other router. The router begins by sending a hello packet out of the OSPF-enabled interface, although it does not know the identity of any other routers.某路由器介面在網路上啟用。由於該路由器尚未與任何其他路由器交換過資訊,因此 OSPF 處理程序處於 down 狀態。路由器會開始從啟用 OSPF 的介面傳送 hello 封包,即使它並不知道任何其他路由器的身分。
- All directly connected routers that are running OSPF receive the hello packet from the first router and add the router to their lists of neighbors. After adding the router to the list, other routers are in the initial state (INIT state).所有正在執行 OSPF 且直接連接的路由器都會收到第一台路由器傳來的 hello 封包,並將該路由器加入它們的鄰居清單。加入後,其他路由器便處於初始狀態(INIT state)。
- Each router that received the hello packet sends a unicast reply hello packet to the first router with its corresponding information. The Neighbors field in the hello packet lists all neighboring routers, including the first router.每台收到 hello 封包的路由器,都會以單播方式回傳一個包含自身相關資訊的 hello 回覆封包給第一台路由器。hello 封包中的「鄰居」欄位會列出所有相鄰路由器,包括第一台路由器。
- When the first router receives the hello packets from the neighboring routers containing its own router ID inside the list of neighbors, it adds the neighboring routers to its own neighbor relationship database. After recognizing itself in the neighbor list, the first router goes into two-way state with those neighbors. At this point, all routers that have each other in their lists of neighbors have established a bidirectional (two way) communication. When routers are in two-way state, they must decide whether to proceed in building an adjacency or staying in the current state.當第一台路由器從鄰居路由器收到的 hello 封包中,發現鄰居清單內含有自己的路由器 ID 時,就會將這些鄰居路由器加入自己的鄰居關係資料庫。在鄰居清單中辨識出自己後,第一台路由器便與這些鄰居進入雙向(two-way)狀態。此時,所有互相列在彼此鄰居清單中的路由器,都已建立雙向通訊。當路由器處於雙向狀態時,必須決定要繼續建立鄰接關係,還是維持目前狀態。
If the link type is a multiaccess broadcast network (for example, an Ethernet LAN), a DR and BDR must first be selected. The DR acts as a central exchange point for routing information to reduce the amount of routing information that the routers have to exchange. The DR and BDR are selected after routers are in the two-way state. Note that the DR and BDR are per LAN, not per area. The router with the highest priority becomes the DR and the router with the second highest priority becomes the BDR. If there is a tie, the router with the highest router ID becomes the DR and the router with the second highest router ID becomes the BDR. Among the routers on a LAN that are not elected as the DR or BDR, the exchange process stops at this point and the routers remain in the two-way state. Routers then communicate only with the DR (or BDR) by using the OSPF DR multicast IPv4 address 224.0.0.6. The DR uses the 224.0.0.5 multicast IPv4 address to communicate with all other non-DR routers. On point-to-point links, there is no DR/BDR election, because only two routers can be connected on a single point-to-point segment and there is no need for using DR or BDR.
如果鏈路類型是多重存取廣播網路(例如乙太網路 LAN),則必須先選出 DR 與 BDR。DR 作為路由資訊的中央交換點,以減少路由器之間需要交換的路由資訊量。DR 與 BDR 是在路由器進入雙向狀態之後才選出的。請注意,DR 與 BDR 是以每個 LAN 為單位選出,而非以每個區域為單位。優先權最高的路由器成為 DR,優先權次高的路由器成為 BDR。如果優先權相同,則路由器 ID 最高者成為 DR,次高者成為 BDR。在 LAN 上未當選為 DR 或 BDR 的路由器中,交換程序到此為止,這些路由器仍維持在雙向狀態。之後路由器只會使用 OSPF DR 群播 IPv4 位址 224.0.0.6 與 DR(或 BDR)通訊。DR 則使用群播 IPv4 位址 224.0.0.5 與所有非 DR 路由器通訊。在點對點鏈路上,不會進行 DR/BDR 選舉,因為單一點對點區段上只能連接兩台路由器,因此不需要使用 DR 或 BDR。
The figure shows the exchange process in case the multiaccess broadcast network is used:
下圖顯示使用多重存取廣播網路時的交換程序:
After the DR and BDR are selected, the routers are considered to be in the exstart state. The routers are then ready to discover the link-state information about the internetwork and create their LSDBs. The exchange protocol is used to discover the network routes, and it brings all the routers from the exchange state to a full state of communication with the DR and BDR.
選出 DR 與 BDR 之後,路由器就進入 exstart 狀態。此時路由器已準備好探索有關網際網路的鏈路狀態資訊,並建立各自的 LSDB。交換協定會用來探索網路路由,並使所有路由器從交換狀態進入與 DR、BDR 完全通訊的 full 狀態。
As shown in the figure, the exchange protocol continues as follows:
如圖所示,交換協定接著會依以下方式進行:
- In the exstart state, a primary/secondary relationship is created between each router and its adjacent DR and BDR. The router with the higher router ID acts as the primary router during the exchange process. The primary/secondary election dictates which router will start the exchange of routing information. This step is not shown in the figure.在 exstart 狀態中,每台路由器與其相鄰的 DR、BDR 之間會建立主/從(primary/secondary)關係。路由器 ID 較高的路由器在交換程序中扮演主要(primary)路由器的角色。主/從選舉決定哪一台路由器將開始交換路由資訊。此步驟未顯示於圖中。
- The primary/secondary routers exchange one or more database description (DBD) packets, containing a summary of their LSDB. The routers are in the exchange state.主/從路由器會交換一個或多個資料庫描述(DBD)封包,其中包含各自 LSDB 的摘要。此時路由器處於交換(exchange)狀態。
- A router compares the DBD that it received with the LSAs that it has. If the DBD has a more up-to-date link-state entry, the router sends a link-state request (LSR) to the other router. When routers start sending LSRs, they are in the loading state.路由器會將收到的 DBD 與自己所擁有的 LSA 進行比較。如果 DBD 中的鏈路狀態項目較新,該路由器就會向另一台路由器傳送鏈路狀態要求(LSR)。當路由器開始傳送 LSR 時,即處於載入(loading)狀態。
- The router sends a link state update (LSU), containing the entries requested in the LSR. This is acknowledged with a link state acknowledgment (LSAck). When all LSRs have been satisfied for a given router, the adjacent routers are considered synchronized and are in the full state.路由器會傳送鏈路狀態更新(LSU),其中包含 LSR 所要求的項目,並以鏈路狀態確認(LSAck)予以確認。當某路由器的所有 LSR 都已滿足時,相鄰的路由器即視為已同步,進入 full 狀態。
All states except two-way and full are transitory, and routers should not remain in these states for extended periods of time.
除了雙向(two-way)狀態與 full 狀態之外,所有其他狀態都是暫時性的,路由器不應長時間停留在這些狀態中。

