前文我們瞭解了OSPF建立鄰居關係的條件,回顧請參考https://www.cnblogs.com/qiuhom-1874/p/15032907.html;今天我們來聊一聊OSPF中的DR和BDR;
在說DR和BDR之前我們先來了解下OSPF的網路型別;
首先OSPF的網路型別是基於介面來劃分,其次OSPF的網路型別是通過介面的二層封裝報文的方式進行了劃分,預設情況下OSPF把介面二層是乙太網封裝的網路稱為廣播型別,把介面二層是PPP或者HDLC封裝的網路稱為點到點型別;
在生活中,廣播就是一個人說話,在同一個房間裡的其他人都可以聽到;在網路裡,廣播和這個類似;一個網路裝置在一個廣播域傳送一條廣播報文,在同一個廣播域的所有裝置都能收到該裝置的廣播;這樣一來我們要想和其中的一臺裝置通訊怎麼通訊呢?在二層為乙太網封裝的廣播型別網路裡,它是通過二層乙太網封裝目標MAC和源MAC;其原因是ip地址是變化的,如果單純的使用ip地址不能夠準確的標識某一臺裝置(因為ip地址是變化的),而MAC地址是裝置的硬體地址,這個地址是裝置出廠時就固定了,況且不會發生變化;所以確定一臺裝置的唯一性,我們可以通過MAC地址;有了通訊雙方的mac地址再結合三層的ip地址,我們就可以準確的將對應資料包傳送給對方;
對於點到點型別的網路,其二層就不需要封裝MAC地址,一條鏈路上就只有兩個端點,在A端點傳送資料B端點就一定能收到;
提示:廣播型別的介面是乙太網型別介面(就是我們常常看到的網口),而點到點型別的介面是串列埠;
在點對點型別的網路中,基於介面封裝的不同又可以分非廣播多路訪問和點到多點,如下圖
提示:預設情況下,OSPF認為幀中繼(FR)、非同步傳輸(ATM)的網路型別為NBMA;在幀中繼網路裡非廣播多路訪問和乙太網中的廣播型別,兩者有一個相同的特點,就是都可以接多個裝置;不同點是乙太網二層封裝需要封裝mac地址,支援廣播傳送,而幀中繼網路二層不需要封裝mac地址,其原因是它不支援廣播;不支援廣播就意味著在ospf裡不支援組播;不支援組播也就是說幀中繼網路裡,ospf只能通過單播的方式建立鄰居;
實驗:如下圖兩個拓撲,R1和R2為乙太網型別介面,R3和R4為串列埠介面,在兩個實驗環境中配置ospf,抓包看看兩者傳送到hello包有什麼不同
配置R1
sys sys R1 int g0/0/0 ip add 12.0.0.1 24 ospf 1 router-id 1.1.1.1 area 0 net 12.0.0.1 0.0.0.0 dis ip int b
配置R2
sys sys R2 int g0/0/0 ip add 12.0.0.2 24 ospf 1 router-id 2.2.2.2 area 0 net 12.0.0.2 0.0.0.0 dis ip int b
配置R3
sys sys R3 int s4/0/0 ip add 34.0.0.3 24 ospf 1 router-id 3.3.3.3 area 0 net 34.0.0.3 0.0.0.0 dis ip int b
配置R4
sys sys R4 int s4/0/0 ip add 34.0.0.4 24 ospf 1 router-id 4.4.4.4 area 0 net 34.0.0.4 0.0.0.0 dis ip int b
在R1或R2上抓包
在R3或R4上抓包
提示:預設情況串列埠鏈路的二層封裝為ppp型別,這裡抓包就選擇ppp鏈路型別即可;
提示:從上面的抓包情況可以看到,在乙太網封型別的網路環境下抓包,其二層封裝了目標mac和源mac,而在點到點型別的網路環境下抓包,其二層就不是使用乙太網協議而是用ppp協議,並且資料包裡面也沒有封裝mac地址;
驗證:檢視對應ospf網路型別
在R1或R2上驗證相關介面的網路型別
在R3或R4上驗證相關介面的網路型別
更改R3的s4/0/0的鏈路封裝為FR,看看對應的介面型別是什麼
提示:可以看到修改了R3的s4/0/0介面的封裝為FR以後,對應ospf就down掉了;並且對應介面的型別就變為了NBMA(非廣播多路訪問);
OSPF DR和BDR
DR和BDR的作用
在上述的網路型別中,在多路訪問網路型別中跑OSPF,每個路由器都會和其他路由器建立鄰居,一個路由器傳送一條鏈路更新,其他路由器都會跟著確認,這樣一來,每個路由器都要經過兩兩的互動和確認,在一定程度上會帶來路由器的效能的開銷(hello包,DD,LSR,LSU,LSACK這些包過多,增加路由器的處理壓力,從而導致路由器的效能降低);為了降低資料包的交換,在OSPF中會選舉DR和BDR;如下圖
提示:廣播型網路MA和NBMA網路中,為了減少鄰接關係的數量,從而減少資料包交換,次數,最終節省頻寬,降低對路由器處理能力的壓力,選舉DR和BDR。
相關術語概述
DR:Designed Router,指定路由器,類似班長、總經理;
BDR:Backup DR,備用DR,類似副班長、副總經理;
DRouthers:類似普通學生、普通員工;
三者的關係:DR、BDR、DRothers之間都保持鄰接關係(Full),DRothers之間保持鄰居關係(Two-Way);
通訊地址:224.0.0.6向DR和BDR傳送鏈路狀態更新,224.0.0.5向所有OSPF路由器傳送;
DR選舉規則
1、首先比較Hello報文中攜帶的優先順序,優先順序範圍是0-255,預設情況下都是1;優先順序最高的被選舉為DR,優先順序次高的被選舉為BDR;優先順序為0的不參與選舉;
2、如果優先順序相同的情況下,比較Router id,router id 越大越優先;
3、選舉不具有搶佔性,除非當DR和BDR都失效或重啟OSPF程式;
提示:DRothers的LSU向DR或BDR通過224.0.0.6傳送,然後DR收到DRothers傳送到LSU以後,會將對應的LSU通過224.0.0.5向其他路由器傳送,其他路由器收到DR傳送LSU以後,BDR向224.0.0.5直接確認,而DBothers則通過224.0.0.6向DR確認;總結一句話就是從DR或BDR發出的資料包都是發往224.0.0.5,DR和BDR都會監聽224.0.0.6這個地址;DRothers發出的資料會通過224.0.0.6向DR或BDR傳送;
實驗:如下圖,全網執行ospf,看看對應的資料包會這麼傳送,對應路由器之間是什麼關係
配置R1
sys sys R1 int g0/0/0 ip add 1.0.0.1 24 ospf 1 router-id 1.1.1.1 a 0 net 1.0.0.0 0.0.0.255 dis ip int b dis ospf peer brief
在R1上檢視g0/0/0的介面資訊,看看誰是DR和BDR
提示:可以看到只配置了R1上的OSPF以後,對應DR就是它自己,因為此時沒有其他裝置和它競選DR,所以只有它是DR;對於BDR來說,它不知道,因為目前就只有它自己在ospf裡面,沒有看到其他裝置;
配置R2
sys sys R2 int g0/0/0 ip add 1.0.0.2 24 ospf 1 router-id 2.2.2.2 a 0 net 1.0.0.0 0.0.0.255 dis ip int b dis ospf peer brief
<Huawei>sys Enter system view, return user view with Ctrl+Z. [Huawei]sys R2 [R2]int g0/0/0 [R2-GigabitEthernet0/0/0]ip add 1.0.0.2 24 [R2-GigabitEthernet0/0/0]ospf 1 rout Jul 24 2021 12:08:39-08:00 R2 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP on the interface GigabitEthernet0/0/0 has entered the UP state. [R2-GigabitEthernet0/0/0]ospf 1 router-id 2.2.2.2 [R2-ospf-1]a 0 [R2-ospf-1-area-0.0.0.0]net 1.0.0.0 0.0.0.255 [R2-ospf-1-area-0.0.0.0]dis ip int b *down: administratively down ^down: standby (l): loopback (s): spoofing The number of interface that is UP in Physical is 2 The number of interface that is DOWN in Physical is 2 The number of interface that is UP in Protocol is 2 The number of interface that is DOWN in Protocol is 2 Interface IP Address/Mask Physical Protocol GigabitEthernet0/0/0 1.0.0.2/24 up up GigabitEthernet0/0/1 unassigned down down GigabitEthernet0/0/2 unassigned down down NULL0 unassigned up up(s) [R2-ospf-1-area-0.0.0.0]dis ospf peer brief Jul 24 2021 12:08:44-08:00 R2 %%01OSPF/4/NBR_CHANGE_E(l)[1]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=1.0.0.1, NeighborEvent=HelloReceived, NeighborPreviousState=Down, NeighborCurrentState=Init) [R2-ospf-1-area-0.0.0.0]dis ospf peer brief Jul 24 2021 12:08:44-08:00 R2 %%01OSPF/4/NBR_CHANGE_E(l)[2]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=1.0.0.1, NeighborEvent=2WayReceived, NeighborPreviousState=Init, NeighborCurrentState=2Way) [R2-ospf-1-area-0.0.0.0]dis ospf peer brief Jul 24 2021 12:08:44-08:00 R2 %%01OSPF/4/NBR_CHANGE_E(l)[3]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=1.0.0.1, NeighborEvent=AdjOk?, NeighborPreviousState=2Way, NeighborCurrentState=ExStart) [R2-ospf-1-area-0.0.0.0]dis ospf peer brief Jul 24 2021 12:08:44-08:00 R2 %%01OSPF/4/NBR_CHANGE_E(l)[4]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=1.0.0.1, NeighborEvent=NegotiationDone, NeighborPreviousState=ExStart, NeighborCurrentState=Exchange) [R2-ospf-1-area-0.0.0.0]dis ospf peer brief Jul 24 2021 12:08:44-08:00 R2 %%01OSPF/4/NBR_CHANGE_E(l)[5]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=1.0.0.1, NeighborEvent=ExchangeDone, NeighborPreviousState=Exchange, NeighborCurrentState=Loading) [R2-ospf-1-area-0.0.0.0]dis ospf peer brief Jul 24 2021 12:08:44-08:00 R2 %%01OSPF/4/NBR_CHANGE_E(l)[6]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=1.0.0.1, NeighborEvent=LoadingDone, NeighborPreviousState=Loading, NeighborCurrentState=Full) [R2-ospf-1-area-0.0.0.0]dis ospf peer brief OSPF Process 1 with Router ID 2.2.2.2 Peer Statistic Information ---------------------------------------------------------------------------- Area Id Interface Neighbor id State 0.0.0.0 GigabitEthernet0/0/0 1.1.1.1 Full ---------------------------------------------------------------------------- [R2-ospf-1-area-0.0.0.0]
提示:可以看到當R2配置好ospf以後,它會和R1先建立其鄰接關係;
再次在R1上檢視g0/0/0的介面資訊,看看此時誰是DR和BDR
提示:此時可以看到DR是R1的介面ip地址,BDR是R2的介面地址;
配置R3
sys sys R3 int g0/0/0 ip add 1.0.0.3 24 ospf 1 router-id 3.3.3.3 a 0 net 1.0.0.0 0.0.0.255 dis ip int b dis ospf peer brief
<Huawei>sys Enter system view, return user view with Ctrl+Z. [Huawei]sys R3 [R3]int g0/0/0 [R3-GigabitEthernet0/0/0]ip add 1.0.0.3 24 Jul 24 2021 12:14:41-08:00 R3 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP on the interface GigabitEthernet0/0/0 has entered the UP state. [R3-GigabitEthernet0/0/0]ospf 1 router-id 3.3.3.3 [R3-ospf-1]a 0 [R3-ospf-1-area-0.0.0.0]net 1.0.0.0 0.0.0.255 [R3-ospf-1-area-0.0.0.0]dis ip int b *down: administratively down ^down: standby (l): loopback (s): spoofing The number of interface that is UP in Physical is 2 The number of interface that is DOWN in Physical is 2 The number of interface that is UP in Protocol is 2 The number of interface that is DOWN in Protocol is 2 Interface IP Address/Mask Physical Protocol GigabitEthernet0/0/0 1.0.0.3/24 up up GigabitEthernet0/0/1 unassigned down down GigabitEthernet0/0/2 unassigned down down NULL0 unassigned up up(s) [R3-ospf-1-area-0.0.0.0]dis ospf peer brief Jul 24 2021 12:14:45-08:00 R3 %%01OSPF/4/NBR_CHANGE_E(l)[1]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=1.0.0.1, NeighborEvent=HelloReceived, NeighborPreviousState=Down, NeighborCurrentState=Init) [R3-ospf-1-area-0.0.0.0]dis ospf peer brief Jul 24 2021 12:14:45-08:00 R3 %%01OSPF/4/NBR_CHANGE_E(l)[2]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=1.0.0.1, NeighborEvent=2WayReceived, NeighborPreviousState=Init, NeighborCurrentState=2Way) [R3-ospf-1-area-0.0.0.0]dis ospf peer brief Jul 24 2021 12:14:46-08:00 R3 %%01OSPF/4/NBR_CHANGE_E(l)[3]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=2.0.0.1, NeighborEvent=HelloReceived, NeighborPreviousState=Down, NeighborCurrentState=Init) [R3-ospf-1-area-0.0.0.0]dis ospf peer brief Jul 24 2021 12:14:46-08:00 R3 %%01OSPF/4/NBR_CHANGE_E(l)[4]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=2.0.0.1, NeighborEvent=2WayReceived, NeighborPreviousState=Init, NeighborCurrentState=2Way) [R3-ospf-1-area-0.0.0.0]dis ospf peer brief Jul 24 2021 12:14:46-08:00 R3 %%01OSPF/4/NBR_CHANGE_E(l)[5]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=1.0.0.1, NeighborEvent=AdjOk?, NeighborPreviousState=2Way, NeighborCurrentState=ExStart) [R3-ospf-1-area-0.0.0.0]dis ospf peer brief Jul 24 2021 12:14:46-08:00 R3 %%01OSPF/4/NBR_CHANGE_E(l)[6]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=2.0.0.1, NeighborEvent=AdjOk?, NeighborPreviousState=2Way, NeighborCurrentState=ExStart) [R3-ospf-1-area-0.0.0.0]dis ospf peer brief Jul 24 2021 12:14:46-08:00 R3 %%01OSPF/4/NBR_CHANGE_E(l)[7]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=1.0.0.1, NeighborEvent=NegotiationDone, NeighborPreviousState=ExStart, NeighborCurrentState=Exchange) [R3-ospf-1-area-0.0.0.0]dis ospf peer brief Jul 24 2021 12:14:46-08:00 R3 %%01OSPF/4/NBR_CHANGE_E(l)[8]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=2.0.0.1, NeighborEvent=NegotiationDone, NeighborPreviousState=ExStart, NeighborCurrentState=Exchange) [R3-ospf-1-area-0.0.0.0]dis ospf peer brief Jul 24 2021 12:14:46-08:00 R3 %%01OSPF/4/NBR_CHANGE_E(l)[9]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=1.0.0.1, NeighborEvent=ExchangeDone, NeighborPreviousState=Exchange, NeighborCurrentState=Loading) [R3-ospf-1-area-0.0.0.0]dis ospf peer brief Jul 24 2021 12:14:46-08:00 R3 %%01OSPF/4/NBR_CHANGE_E(l)[10]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=1.0.0.1, NeighborEvent=LoadingDone, NeighborPreviousState=Loading, NeighborCurrentState=Full) [R3-ospf-1-area-0.0.0.0]dis ospf peer brief Jul 24 2021 12:14:46-08:00 R3 %%01OSPF/4/NBR_CHANGE_E(l)[11]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=2.0.0.1, NeighborEvent=ExchangeDone, NeighborPreviousState=Exchange, NeighborCurrentState=Loading) [R3-ospf-1-area-0.0.0.0]dis ospf peer brief Jul 24 2021 12:14:46-08:00 R3 %%01OSPF/4/NBR_CHANGE_E(l)[12]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=2.0.0.1, NeighborEvent=LoadingDone, NeighborPreviousState=Loading, NeighborCurrentState=Full) [R3-ospf-1-area-0.0.0.0]dis ospf peer brief OSPF Process 1 with Router ID 3.3.3.3 Peer Statistic Information ---------------------------------------------------------------------------- Area Id Interface Neighbor id State 0.0.0.0 GigabitEthernet0/0/0 1.1.1.1 Full 0.0.0.0 GigabitEthernet0/0/0 2.2.2.2 Full ---------------------------------------------------------------------------- [R3-ospf-1-area-0.0.0.0]
提示:可以看到當R3配置好以後,對應R3和R1和R2都建立起鄰接關係;
檢視R3g0/0/0介面資訊,看看DR和BDR變化沒有?
提示:之所以DR和BDR沒有發生變化,其原因是ospf已經選好了DR和BDR,而DR和BDR的選舉是非搶佔性,一旦選好,就不變了,除非重啟ospf程式(所有路由器)來觸發DR和BDR的重新選舉;
配置R4
sys sys R4 int g0/0/0 ip add 1.0.0.4 24 ospf 1 router-id 4.4.4.4 a 0 net 1.0.0.0 0.0.0.255 dis ip int b dis ospf peer brief
<Huawei>sys Enter system view, return user view with Ctrl+Z. [Huawei]sys R4 [R4]int g0/0/0 [R4-GigabitEthernet0/0/0]ip add 1.0.0.4 24 Jul 24 2021 12:20:57-08:00 R4 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP on the interface GigabitEthernet0/0/0 has entered the UP state. [R4-GigabitEthernet0/0/0]ospf 1 router-id 4.4.4.4 [R4-ospf-1]a 0 [R4-ospf-1-area-0.0.0.0]net 1.0.0.0 0.0.0.255 [R4-ospf-1-area-0.0.0.0]dis ip int b *down: administratively down ^down: standby (l): loopback (s): spoofing The number of interface that is UP in Physical is 2 The number of interface that is DOWN in Physical is 2 The number of interface that is UP in Protocol is 2 The number of interface that is DOWN in Protocol is 2 Interface IP Address/Mask Physical Protocol GigabitEthernet0/0/0 1.0.0.4/24 up up GigabitEthernet0/0/1 unassigned down down GigabitEthernet0/0/2 unassigned down down NULL0 unassigned up up(s) [R4-ospf-1-area-0.0.0.0]dis ospf peer brief Jul 24 2021 12:21:02-08:00 R4 %%01OSPF/4/NBR_CHANGE_E(l)[1]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=2.0.0.1, NeighborEvent=HelloReceived, NeighborPreviousState=Down, NeighborCurrentState=Init) [R4-ospf-1-area-0.0.0.0]dis ospf peer brief Jul 24 2021 12:21:02-08:00 R4 %%01OSPF/4/NBR_CHANGE_E(l)[2]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=2.0.0.1, NeighborEvent=2WayReceived, NeighborPreviousState=Init, NeighborCurrentState=2Way) [R4-ospf-1-area-0.0.0.0]dis ospf peer brief Jul 24 2021 12:21:02-08:00 R4 %%01OSPF/4/NBR_CHANGE_E(l)[3]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=2.0.0.1, NeighborEvent=AdjOk?, NeighborPreviousState=2Way, NeighborCurrentState=ExStart) [R4-ospf-1-area-0.0.0.0]dis ospf peer brief Jul 24 2021 12:21:02-08:00 R4 %%01OSPF/4/NBR_CHANGE_E(l)[4]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=2.0.0.1, NeighborEvent=NegotiationDone, NeighborPreviousState=ExStart, NeighborCurrentState=Exchange) [R4-ospf-1-area-0.0.0.0]dis ospf peer brief Jul 24 2021 12:21:02-08:00 R4 %%01OSPF/4/NBR_CHANGE_E(l)[5]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=2.0.0.1, NeighborEvent=ExchangeDone, NeighborPreviousState=Exchange, NeighborCurrentState=Loading) [R4-ospf-1-area-0.0.0.0]dis ospf peer brief Jul 24 2021 12:21:02-08:00 R4 %%01OSPF/4/NBR_CHANGE_E(l)[6]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=2.0.0.1, NeighborEvent=LoadingDone, NeighborPreviousState=Loading, NeighborCurrentState=Full) [R4-ospf-1-area-0.0.0.0]dis ospf peer brief Jul 24 2021 12:21:04-08:00 R4 %%01OSPF/4/NBR_CHANGE_E(l)[7]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=1.0.0.1, NeighborEvent=HelloReceived, NeighborPreviousState=Down, NeighborCurrentState=Init) [R4-ospf-1-area-0.0.0.0]dis ospf peer brief Jul 24 2021 12:21:04-08:00 R4 %%01OSPF/4/NBR_CHANGE_E(l)[8]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=1.0.0.1, NeighborEvent=2WayReceived, NeighborPreviousState=Init, NeighborCurrentState=2Way) [R4-ospf-1-area-0.0.0.0]dis ospf peer brief Jul 24 2021 12:21:04-08:00 R4 %%01OSPF/4/NBR_CHANGE_E(l)[9]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=1.0.0.1, NeighborEvent=AdjOk?, NeighborPreviousState=2Way, NeighborCurrentState=ExStart) [R4-ospf-1-area-0.0.0.0]dis ospf peer brief Jul 24 2021 12:21:05-08:00 R4 %%01OSPF/4/NBR_CHANGE_E(l)[10]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=1.0.0.1, NeighborEvent=NegotiationDone, NeighborPreviousState=ExStart, NeighborCurrentState=Exchange) [R4-ospf-1-area-0.0.0.0]dis ospf peer brief Jul 24 2021 12:21:05-08:00 R4 %%01OSPF/4/NBR_CHANGE_E(l)[11]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=1.0.0.1, NeighborEvent=ExchangeDone, NeighborPreviousState=Exchange, NeighborCurrentState=Loading) [R4-ospf-1-area-0.0.0.0]dis ospf peer brief Jul 24 2021 12:21:05-08:00 R4 %%01OSPF/4/NBR_CHANGE_E(l)[12]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=1.0.0.1, NeighborEvent=LoadingDone, NeighborPreviousState=Loading, NeighborCurrentState=Full) [R4-ospf-1-area-0.0.0.0]dis ospf peer brief Jul 24 2021 12:21:06-08:00 R4 %%01OSPF/4/NBR_CHANGE_E(l)[13]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=3.0.0.1, NeighborEvent=HelloReceived, NeighborPreviousState=Down, NeighborCurrentState=Init) [R4-ospf-1-area-0.0.0.0]dis ospf peer brief Jul 24 2021 12:21:06-08:00 R4 %%01OSPF/4/NBR_CHANGE_E(l)[14]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=3.0.0.1, NeighborEvent=2WayReceived, NeighborPreviousState=Init, NeighborCurrentState=2Way) [R4-ospf-1-area-0.0.0.0]dis ospf peer brief Jul 24 2021 12:21:06-08:00 R4 %%01OSPF/4/NBR_CHANGE_E(l)[15]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=3.0.0.1, NeighborEvent=AdjOk?, NeighborPreviousState=2Way, NeighborCurrentState=2Way) [R4-ospf-1-area-0.0.0.0]dis ospf peer brief OSPF Process 1 with Router ID 4.4.4.4 Peer Statistic Information ---------------------------------------------------------------------------- Area Id Interface Neighbor id State 0.0.0.0 GigabitEthernet0/0/0 1.1.1.1 Full 0.0.0.0 GigabitEthernet0/0/0 2.2.2.2 Full 0.0.0.0 GigabitEthernet0/0/0 3.3.3.3 2-Way ---------------------------------------------------------------------------- [R4-ospf-1-area-0.0.0.0]
提示:可以看到當R4配置好以後,對應R4和R1(DR),R2(BDR)是鄰接關係;而和R3(DRothers)建立的鄰居關係;
驗證:在R1上釋出更新,抓包看看對應的資料包會怎麼傳送和確認?
提示:可以看到當R1(DR)傳送LSU時,它會直接向224.0.0.5傳送;其中R2(BDR)向224.0.0.5確認;R3(DRothers)和R4(DRothers)向224.0.0.6確認;
驗證:在R2上傳送LSU,看看對應資料包會這麼傳送和確認的呢?
提示:可以看到當R2(BDR)傳送LSU時,它和R1傳送LSU一樣直接向224.0.0.5傳送LSU,對應R1(DR)直接向224.0.0.5確認;R3、R4(DRother)向224.0.0.6確認;
驗證:當R3傳送LSU,看看對應資料包會這麼傳送和確認呢?
提示:可以看到當R3(DRother)傳送LSU時,它首先會把LSU通過224.0.0.6向R1(DR)傳送,當R1(DR)收到R3傳送的LSU,它會通過224.0.0.5向其他路由器傳送LSU(不會再傳送給R3);R2(BDR)收到LSU向224.0.0.5確認,R4(DRother)向224.0.0.6確認;
驗證:當R4 傳送LSU時,看看對應資料包會怎麼傳送和確認呢?
提示:可以看到R4(DRother)傳送LSU和R3(DRother)傳送LSU一樣;首先它會把LSU傳送給R1(DR),然後由R1(DR)再向其他路由器傳送LSU;BDR(R2)直接向224.0.0.5確認;DRother(R3)向224.0.0.6確認;
驗證:全網重啟ospf程式,看看對應的DR和BDR是否會重新選舉?
提示:可以看到4個路由器分別重新啟動了ospf以後,重置ospf 程式以後,R4當選為DR,R3當選為BDR;因為重啟ospf程式對應的鄰居和鄰接關係又重新建立,此時4個路由器首先會比較對應的hello包裡的優先順序,預設情況下優先順序都是1 ,此時優先順序一樣,會比較router id,router id誰大誰就是DR,次大者就為BDR,剩下沒有被選舉成DR或BDR的就淪為DRother;R4的router id為4.4.4.4 是4個路由器中最大的,所以R4當選DR,R3的router id為3.3.3.3 ,第二大,所以當選BDR;