OSPF
Introduction
Introduction
-
OSPF stands for Open shortest Path First
OSPF是开放最短路径优先的意思。
-
Open standard protocol
开放标准协议
-
It is a link State protocol
它是链路状态协议
-
It uses a Shortest Path First (SPF) algorithm (Dijkistra algorithm)
它使用最短路径优先(SPF)算法(Dijkistra算法)。
-
Metric is cost (reference BW [100Mb/s] / interface BW)
指标是成本(参考BW[100Mb/s]/接口BW)。
-
Administrative distance is 110
管理距离为110
-
It is a classless routing algorithm
它是一种无类别的路由算法
-
It supports equal cost load balancing
它支持同等成本的负载平衡
-
Introduces the concept of Area’s (reduce the amount of Link State Advertisements [LSA’s]
引入区域的概念(减少链接状态广告[LSA]的数量
-
All routers have the same information
所以路由都有相同的信息
-
Updates are sent using 224.0.0.5
使用224.0.0.5发送更新。

-
IGP(Interior Gateway Protocols)
专有名词
Process ID

router ospf process-id命令是任何Cisco IOS OSPF配置的开始(16位值1-65,535)。它用于创建或修改一个现有的OSPF路由进程,并使用户进入OSPF路由器配置模式。进程ID - 允许一个路由器运行OSPF的多个实例。(例如,连接到3个不同客户的路由器)这些OSPF进程ID只在本地有意义,不必从一个OSPF设备到另一个匹配.
Router ID(RID)

router-id命令用来静态配置OSPF的路由器id;这个路由器id(RID)用来向OSPF网络中的其他设备识别OSPF设备。对于每个OSPF设备来说,这个路由器ID必须是唯一的;如果没有配置路由器ID,它将根据以下顺序被选择:最高的环回接口,最高的活动(向上/向上)物理接口。配置环回接口或使用router-id命令在OSPF实施中非常普遍,因为它使特定的OSPF设备的识别更容易。
Router Priority

在多接入网络中,具有最高优先级值的路由器被选为DR,作为LSA交换的中心点。优先级命令被分配到一个接口上。OSPF接口的默认优先级是1,其范围是0到255。0意味着该接口不参与DR的选举。
具有最高OSPF优先级的路由器将成为DR。默认情况下,所有路由器的优先级都是1。 如果出现平局,具有最高路由器ID的路由器赢得选举。具有第二高OSPF优先级或路由器ID的路由器将成为一个BDR。
AREA ID

在OSPF中,一个单一的自治系统(AS)可以被划分为较小的组,称为区域。这减少了网络上发送的链路状态广告(LSA)和其他OSPF开销流量的数量,并减少了每个路由器必须维护的拓扑数据库的大小。
Processing
三个大流程(宏观)
-
Become Neighbours – Routers running OSPF on the same segment form neighbour relationships.
成为邻居 - 同一网段上运行OSPF的路由器形成邻居关系。
[PtP segment – Master/Slave, Broadcast segment - DR/BDR/Drother.]
有Master/Slave - PPP
-
Exchange database information – the neighbour routers exchange their LSDB data with each other using LSA’s.
**交换数据库信息-**邻居路由器和其他路由器使用LSA‘s(link-state advertisements)交换他们的LSDB(Link states databse)数据
-
Choose the best routes – each router adds the best routes to its routing table based on the results of running the SPF algorithm on the LSDB
选择最好的路由-每个路由器根据在LSDB上运行SPF算法的结果,向其路由表添加最佳路由。
7大步骤(微观)
-
Down (No info has been exchanged or retained)
Down (没有交换或保留信息)
-
Init (A hello packet has been received, but hasn’t gone to two way yet) )
init (已收到一个hello数据包,但还没有进入双路) )
-
Two way (establishment of a bidirectional conversation between two routers)
双向(在两个路由器之间建立双向对话)。
-
Exstart (first step of adjacency, decide on Master Slave)
Exstart(邻接的第一步,决定主从)。
-
Exchange (exchange LSDB’s )
Exchange(交换LSDB的)。
-
Loading (requests the most recent link-state advertisements (LSA’s) from its neighbour)
Loading(请求其邻居提供最新的链接状态广告(LSA))。
-
Full (when the routers are fully adjacent, and the state appears in all router- and network-LSA’s)
Full(当路由器完全相邻,并且该状态出现在所有路由器和网络LSA中时)
Proceesing detail
Become neighbour
- R1发送Hello message 给R2

- 建立邻居关系要满足的要求

- Area ID
- Subnet
- Hello and Dead interval
- Authentication
- Stub area flag
- Unique router ID(RID)
Hellow message Content

Hellow timer 默认10s
Dead interval默认40s
- R2 发送Hello包含neighbor ID给R1,并R2进入初始化状态

- R1直接从Down转变成2-way,因为R1已经知道了R2的RID和neighbourID

R1将R2列为邻居
- R2收到R1的hello message后也知道R1的情况,将R1列为R2的邻居,从init变成2-way

DR’s and BDR’s 不再PtP中选出。
- 选择DR和BDR
选择基于最高的OSPF priority, priority默认为1.
如果优先级相等,则通过RID来进行选择DR/BDR,RID越高则是DR。
路由器只会与DR或BDR成为邻居
2-way的邻居状态意味着他们都发送和接受彼此的hello,但之间并不交换路由信息。
- 进入2-way之后就要交换路由器的LSDB了。

PtP link
进入2-way状态,准备交换LSDB,必须选择一个路由器将启动交换,这个是在Exstart state下完成的
Exstart state
根据RID选择Master或Slave,高RID的将会成为Master并启动进程并控制序列号。
Exchange Database Information
- 选完Master和slave后进入Exchange状态

路由器开始相互发送LSA列表,这个过程叫做DBD(Database description)
- 交换完LSA后进入loading


每个路由器将检查DBD,并请求任何如果它没有的信息(相当于updata)
通过路由器请求信息不仅仅是发送更新来防止循环。
- 假如R2 有R1没有的信息,如有一个192.168.3.0,R1没有

在LSR(Link State Request)中R1请求LSA(Link State Advertisement )
- R2回复并发送更新LSU

LSU- link State Update, R2向R1发送更新。
- R1向R2 发送一个ACK

LSAck- link state Ack
- R2也想要R1的DBD,重复以上过程

当然R2也会想要R1的192.168.1.0,所以重复以上过程。
Full
- 当信息全部交换完成便变成full 状态

-
In the full state, the routers have full OSPF adjacency and identical LSDB’s.
在完全状态下,路由器具有完整的OSPF邻接性和相同的LSDB。
-
They will continue to send and listen for Hello packets (every 10 seconds by default on an Ethernet interface, 30 sec on serial links) to maintain the neighbour adjacency
他们将继续发送和收听Hello数据包(默认情况下在以太网接口上每10秒,在串行链路上每30秒),以保持邻居邻接
-
Every time a hello packet is received the dead timer (40 seconds by default) is reset back to 40 sec.
每次收到hello数据包时,死计时器(默认情况下为40秒)都会重置为40秒。
-
If the Dead timer counts down to 0 and NO Hello message is received, the neighbour is removed.
如果死计时器倒计时到0,并且没有收到Hello消息,则邻居将被删除。
-
The routers will continue to send LSA’s as the network changes to ensure each router has a complete and accurate map of the network (LSDB)
随着网络的变化,路由器将继续发送LSA,以确保每个路由器都有完整准确的网络地图(LSDB)
Cisco command
Change reference Bandwidth

auto-cost reference-bandwidth 1000

Neighbour relationship
- Command of ospf
sh ip ospf int brief告诉我自己的信息
sh ip ospf neighbors告诉我邻居的信息



死亡计时器从40s开始倒计时,收到hello message则重置。
Full state

Example of cisco





OSPF Area






