<p>
</p><blockquote><p><span style="font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";"><b>一、OSPF路由協(xié)議</b></span></p></blockquote><p>
</p><p>
</p><div class="image-package"><img src="https://upload-images.jianshu.io/upload_images/2084007-f82130c9d9ce5a90.jpeg" img-data="{"format":"jpeg","size":40673,"height":437,"width":1080}" class="uploaded-img" style="min-height:200px;min-width:200px;" width="auto" height="auto"/>
</div><p><span>
</span></p><p>
</p><p><b>開放式最短路徑優(yōu)先OSPF(Open Shortest Path First)是IETF組織開發(fā)的一個基于鏈路狀態(tài)的內(nèi)部網(wǎng)關(guān)協(xié)議(Interior Gateway Protocol)。</b>
</p><p><b>
</b></p><p><span><strong><span style="font-size:14px">兩個版本:</span></strong>
</span></p><p><b>IPv4協(xié)議使用的是OSPF Version 2(RFC2328);針對IPv6協(xié)議使用OSPF Version 3(RFC2740)</b></p><p><b>
</b></p><p><b>在這里估計你要打三個問號了???什么是基于鏈路狀態(tài)的內(nèi)部網(wǎng)關(guān)協(xié)議,什么又是開放式最短路徑樹,為什么會出現(xiàn)OSPF呢?接下來就讓我娓娓道來!</b></p><p><b>
</b></p><p><b>首先來展開第一個疑問:為什么會出現(xiàn)OSPF呢?</b></p><p><b>肯定就有人說,出現(xiàn)任何??技術(shù)都是為了解決某個領(lǐng)域的難題,不錯,OSPF的出現(xiàn)正是解決日益龐大的網(wǎng)絡(luò)如何選路并到達目的地的難題,因特網(wǎng)最開始出現(xiàn)的時候是局限在某個區(qū)域中,而隨著因特網(wǎng)的普及,越來越多的地區(qū)和區(qū)域都加入進來,到如今更是與我們生活融為一體,不可分割。早期的時候可能就是幾個人互聯(lián)的網(wǎng)絡(luò),或者是一個小型的區(qū)域網(wǎng)絡(luò),而隨著組織和企業(yè)的加入,一個組織越來越多的人機開始交互,日益龐大,導(dǎo)致網(wǎng)絡(luò)互聯(lián)的成本和難度日益提高,一個數(shù)據(jù)包的選路越來越復(fù)雜,靠人手工維護陷入困境(靜態(tài)路由),相應(yīng)的出現(xiàn)了自動學(xué)習(xí)的方法(動態(tài)路由)。
</b></p><p><b>
</b></p><p><b>最開始的RIP協(xié)議,在早期解決了部分問題,但隨著時間的推移,RIP的短板也越來凸顯:
</b></p><p><b>RIP:</b><b><strong><span style="font-weight:bold">RIP是一種基于距離矢量算法的路由協(xié)議</span></strong></b></p><p><b><strong><span style="font-weight:bold">
</span></strong></b></p><ol><li><p><b><strong><span style="font-weight:bold">收斂慢;</span></strong></b></p></li><li><p><b><strong><span style="font-weight:bold">易產(chǎn)生路由環(huán)路;</span></strong></b></p></li><li><p><b><strong><span style="font-weight:bold">可擴展性差,只支持最大16跳,大規(guī)模網(wǎng)絡(luò)不合適;</span></strong></b></p></li><li><p><b><strong><span style="font-weight:bold">不支持VLSM</span></strong></b></p></li></ol><p>
</p><p><span style="font-size:14px"><strong><span>OSPF能更好的解決RIP無法解決的問題
</span></strong></span></p><p><span style="font-size:14px">歷史就是如此相似,混亂的時代總能產(chǎn)生英雄;而在網(wǎng)絡(luò)江湖中,OSPF也應(yīng)運而生。</span>
</p><p><strong><span style="font-size:14px">OSPF就是為RIP的短板而生,集大成者得天下,而現(xiàn)在網(wǎng)絡(luò)江湖中,OSPF已霸占主流;RIP也就退出歷史潮流,OSPF在IGP中如魚得水,那到底是如何做到的呢?請繼續(xù)動動手指</span></strong>
</p><p>
</p><blockquote><p><b>二、OSPF關(guān)鍵要素</b>
</p></blockquote><p>
</p><p><b>OSPF是基于鏈路狀態(tài)的路由協(xié)議,那什么是鏈路狀態(tài)呢?
</b></p><p><b>RIP是距離矢量路由協(xié)議,是跳躍點來作為路由選路,并不構(gòu)建全局的面,簡單理解可以說RIP是點,OSPF是以點構(gòu)建成面,也就是每個OSPF上都有一套全局的地圖可供選路。</b></p><p><span style="font-size:14px"><strong>每個運行OSPF的路由器都有一張全局的地圖庫進行查詢,RIP沒法做到,那具體都有哪些因素影響呢?</strong></span></p><p><span style="font-size:14px"><strong>
</strong></span></p><p><strong><b>OSPF關(guān)鍵要素--五種報文</b></strong></p><p><b>
</b></p><p><b>OSPF是運行在網(wǎng)絡(luò)層協(xié)議,IP協(xié)議號 89,其實在我理解OSPF是跨層封裝,OSPF將協(xié)議包封裝在IP包中,可以看如下圖所示:</b></p><p><b>
</b></p><p><b><div class="image-package"><img src="https://upload-images.jianshu.io/upload_images/2084007-b0848517cc7abefa.jpeg" img-data="{"format":"jpeg","size":8360,"height":241,"width":321}" class="uploaded-img" style="min-height:200px;min-width:200px;" width="auto" height="auto"/>
</div></b></p><p/><p><b>
</b></p><div class="image-package"><img src="https://upload-images.jianshu.io/upload_images/2084007-fc9bde66816a7b11.jpeg" contenteditable="false" img-data="{"format":"jpeg","size":33994,"height":422,"width":1392}" class="uploaded-img" style="min-height:200px;min-width:200px;" width="auto" height="auto"/>
</div><p>
</p><p><strong><span style="font-size:14px">如下圖所示:</span></strong>
</p><p>
</p><div class="image-package"><img src="https://upload-images.jianshu.io/upload_images/2084007-676222a0b5b47eba.jpeg" img-data="{"format":"jpeg","size":17959,"height":342,"width":543}" class="uploaded-img" style="min-height:200px;min-width:200px;" width="auto" height="auto"/>
</div><p><span style="font-size:14px"><strong>OSPF報文類型說明:</strong></span>
</p><div class="image-package"><img src="https://upload-images.jianshu.io/upload_images/2084007-e8d0f323c7d1ce4b.jpeg" contenteditable="false" img-data="{"format":"jpeg","size":74776,"height":498,"width":1378}" class="uploaded-img" style="min-height:200px;min-width:200px;" width="auto" height="auto"/>
</div><p><strong><span style="font-size:14px">故OSPF是劃分在IP層中,但是在整個TCP/IP協(xié)議簇中,很多協(xié)議其實并不能確定是屬于</span></strong><span><strong><span style="font-size:14px">那</span></strong></span><strong><span style="font-size:14px">個協(xié)議,有些是跨協(xié)議,有些協(xié)議在灰色地帶,最主要的還是看具體解決什么問題,我可以說OSPF是在傳輸層,BGP屬于應(yīng)用層,所以不能很粗略的定義在哪一層,OSPF是基于IP的,BGP基于TCP的,報文封裝在下層,而解決的問題是網(wǎng)絡(luò)層問題,看計算機網(wǎng)絡(luò)自頂向下方法一書可以看出,故不要太局限嚴(yán)格定義在哪一層的協(xié)議。</span></strong></p><p>
</p><p><span style="font-size:14px"><strong><b>OSPF數(shù)據(jù)包首部邏輯結(jié)構(gòu):</b>
</strong></span></p><p><span style="font-size:14px"><strong>
</strong></span></p><div class="image-package"><img src="https://upload-images.jianshu.io/upload_images/2084007-521c58eaa8eb34f0.jpeg" img-data="{"format":"jpeg","size":74547,"height":645,"width":1077}" class="uploaded-img" style="min-height:200px;min-width:200px;" width="auto" height="auto"/>
</div><p><strong><span style="font-size:14px">抓包結(jié)構(gòu):</span></strong></p><div class="image-package"><img src="https://upload-images.jianshu.io/upload_images/2084007-7db40962cba751d3.jpeg" img-data="{"format":"jpeg","size":34909,"height":511,"width":1080}" class="uploaded-img" style="min-height:200px;min-width:200px;" width="auto" height="auto"/>
</div><p>
</p><div class="image-package"><img src="https://upload-images.jianshu.io/upload_images/2084007-13645ee22a836eb3.jpeg" contenteditable="false" img-data="{"format":"jpeg","size":108761,"height":796,"width":1382}" class="uploaded-img" style="min-height:200px;min-width:200px;" width="auto" height="auto"/>
</div><p>
</p><p><strong/><strong><b>OSPF關(guān)鍵要素--三張表</b></strong></p><p>
</p><p><span style="font-size:14px"><strong>OSPF協(xié)議的運行需要三張表,鄰居表、鏈路狀態(tài)數(shù)據(jù)庫、OSPF路由表。如下以華為示例:</strong></span></p><p><b>鄰居表:display ospf peer</b></p><ol><li><p><span style="font-size:12px">通過Hello報文形成鄰居</span></p></li><li><p><span style="font-size:12px">用鄰居機制來維持路由</span></p></li><li><p><span style="font-size:12px">鄰居表存儲雙向通信的OSPF路由器列表信息</span></p></li></ol><p>
</p><p><b>鏈路狀態(tài)數(shù)據(jù)庫(LSDB):display ospf peer</b></p><ol><li><p><span style="font-size:12px">通過LSU報文更新LSDB</span></p></li><li><p><span style="font-size:12px">描述拓撲信息的LSA存儲在LSDB中</span></p></li></ol><p>
</p><p><b>路由表:display ospf routing</b></p><ol><li><p><span style="font-size:12px">OSPF計算出來的路由將會加載到路由表</span></p></li><li><p><b>路由優(yōu)先級 域內(nèi)>域間>域外 1/2 >NSS區(qū)域 1/2</b></p></li></ol><p>
</p><blockquote><p><b>三、OSPF協(xié)議原理</b>
</p></blockquote><p>
</p><p>
</p><p><span style="font-size:15px"><strong>啟動OSPF,發(fā)送hello包,建立鄰居關(guān)系,泛洪LSA,每臺路由器匯總LSA,形成LSDB,鏈路狀態(tài)數(shù)據(jù)庫生成帶權(quán)有向圖,每臺運行OSPF路由器以自己為根節(jié)點計算最小路徑樹,最終形成每臺路由器的路由表加載到路由器內(nèi)存中。</strong></span></p><p>
</p><div class="image-package"><img src="https://upload-images.jianshu.io/upload_images/2084007-f9969e717adadfcf.jpeg" img-data="{"format":"jpeg","size":36645,"height":361,"width":755}" class="uploaded-img" style="min-height:200px;min-width:200px;" width="auto" height="auto"/>
</div><p>
</p><p><span style="font-size:14px"><strong><span>LSA泛洪:</span></strong></span></p><p><span style="font-size:14px"><strong>運行鏈路狀態(tài)路由協(xié)議的路由器都會進行鏈路狀態(tài)公告LSA (Link State Advertisement)泛洪,</strong>LSA中包含了路由器已知的接口狀態(tài)、接口IP地址、掩碼、開銷、網(wǎng)絡(luò)類型、宣告路由ID和等信息。</span></p><p><span style="font-size:14px">
</span></p><p><span style="font-size:14px"><strong>通俗點講就是LSA把路由器鄰居相互之間的路由信息和拓撲信息進行握手交換。</strong></span></p><p>
</p><p><span style="font-size:14px"><strong><span>建立LSDB:</span></strong></span></p><p><span style="font-size:14px">收到LSA的路由器都可以根據(jù)LSA提供的信息建立自己的鏈路狀態(tài)數(shù)據(jù)庫LSDB(Link State Database)。</span></p><p>
</p><p><span style="font-size:14px">通俗點講就是每臺路由器都會收到網(wǎng)絡(luò)中其他的路由器發(fā)送過來的LSA信息,這些所有的LSA信息構(gòu)成了LSDB。這里需要注意的是當(dāng)網(wǎng)絡(luò)穩(wěn)定后,網(wǎng)絡(luò)中的所有設(shè)備應(yīng)該是有相同的LSDB的。</span></p><p>
</p><p><strong><span style="font-size:14px">建立最短路徑樹:</span></strong></p><p><span style="font-size:14px"><span><span>運行OSPF協(xié)議的路由器在LSDB的基礎(chǔ)上使用</span>SPF算法<span>進行運算,建立起到達每個網(wǎng)絡(luò)的</span>最短路徑樹<span>。</span></span></span></p><p><span style="font-size:14px"><span><span>
</span></span></span></p><p><span style="font-size:14px"><strong><span style="font-size:14px">路由計算:</span></strong></span></p><p><span style="font-size:14px">通過最短路徑樹得出到達目的網(wǎng)絡(luò)的最優(yōu)路由,并將其加入到IP路由表中。</span></p><p>
</p><p><span style="font-size:14px"><strong>OSPF從最開始的鄰居建立到最終路由表的加載是有一個過程的,整個過程分7個狀態(tài),分別都是不同的OSPF數(shù)據(jù)報文交互的結(jié)果。如下圖:</strong></span></p><p><span style="font-size:14px"><strong>
</strong></span></p><div class="image-package"><img src="https://upload-images.jianshu.io/upload_images/2084007-e5f5f9e14083dee5.jpeg" img-data="{"format":"jpeg","size":47488,"height":651,"width":779}" class="uploaded-img" style="min-height:200px;min-width:200px;" width="auto" height="auto"/>
</div><p>
</p><p><span style="font-size:15px"><strong>關(guān)于OSPF協(xié)議狀態(tài)機下文講結(jié)合實際抓包和圖文著重分解。</strong></span></p><p><span style="font-size:15px"><strong>更多文章請關(guān)注微信公眾號:網(wǎng)絡(luò)小斐</strong></span></p><p><span style="font-size:15px"/>
</p>
一劍開天門系列-OSPF路由協(xié)議基礎(chǔ)
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。
相關(guān)閱讀更多精彩內(nèi)容
- 概要信息: 1、ospf的LSA類型1/2/3/4/5/7類LSA 2、ospf的特殊區(qū)域 stub、tot...
- 每個 OSPF 報文都由 OSPF header 加上 OSPF payload 組成,OSPF 支持組播發(fā)送報文...
- OSPF協(xié)議簡介 開放式最短路徑優(yōu)先OSPF(Open Shortest Path First)是IETF組織開發(fā)...
- 版權(quán)聲明:原創(chuàng)作品,謝絕轉(zhuǎn)載!否則將追究法律責(zé)任。 OSPF路由協(xié)議 楔子 為了加強自己我打算好好玩玩網(wǎng)絡(luò)。 OS...
- 上帝視角 OSPF出現(xiàn)背景 如上圖就是一張簡單的OSPF協(xié)議網(wǎng)絡(luò),那么為什么會出現(xiàn)OSPF協(xié)議呢? 開放式最短路徑...