OSPF (a) OSPF Protocol Overview

OSPF Thematic Introduction

OSPF protocol more content, so I'll make a topic to explain. This article is the topic of the first article of OSPF, mainly the overall brief OSPF protocol, then later in the article which, one by one go-depth description of the more important concepts of OSPF protocol

Foreword

An article on common routing protocol in my main lists some common protocols and classification. Also simple to explain the static routing, then we know that static routing configuration requires the administrator to manually configure, equivalent to the administrator of the pen strokes to draw a map . But in the face of relatively large network topology, static routing becomes more stretched. At this time, dynamic routing became apparent to his advantage.

Dynamic routing comparative advantages and disadvantages of static routing

Advantage

  1. No administrator manual maintenance, reducing administrator workload.
  2. The router routing protocol running on the router can route entries automatically adjusted according to the change of the network topology;
  3. Net network is suitable for large-scale, complex network topology

Disadvantaged

  1. Take up network bandwidth
  2. Take up computing resources

OSPF

In the previous article: RIP protocol , I have a very simple introduction about the RIP protocol, the reason is not described in detail RIP protocol has now been phased out, whichever is the OSPF protocol and instead of it.

Open Shortest Path First protocol ---- OSPF (Open Shortest Path First)

RIP problems caused by:

RIP features. Problems caused by
Hop-convergence Convergence slow, long recovery time
Rumor routing update mechanism Lack of understanding of the global network topology
The most effective hop count of 15 Ring network in the remote routing unreachable
The "hops" to measure There is a risk of selecting suboptimal paths

solution:

RIP issues Optimization or resolved manner (OSPF characteristics)
Convergence slow, long recovery time "Receive updates -> calculate routes -> Send Update" to "receive updates -> Send Update -> calculate routes."
Lack of understanding of the global network topology Router based on topology information, the route calculated independently
The most effective hop count of 15 Is not limited to the number of hops
There is a risk of selecting suboptimal paths The routing link bandwidth as a reference value

OSPF is a routing protocol (the LS) (for reference according to the link state) based on the link state, from which the design ensures that no routing loops. OSPF supports the divided areas, the area inside the router uses the SPF shortest path algorithm guarantees loop-free within the region. OSPF also use connection rules between areas ensures no routing loop between the regions.
OSPF support triggered updates, can quickly detect and notify topology changes within the autonomous system.
OSPF can solve the problem caused by network expansion. When the router on the network more and more, the rapid growth of traffic routing information when, OSPF can each autonomous system into multiple areas, and to limit the scope of each region. OSPF feature of this sub-region, so particularly suitable for medium-sized networks OSPF. OSPF can provide authentication. Messages between the OSPF router can be configured to be certified in order to be exchanged.

advantage:

No loop 1. 2. SPF algorithm to calculate their own informed (each OSPF routers know the topology of the entire region) (RIP rumors updating)
Fast convergence 1. Using the SPF algorithm 2.OSPF receive link state information is sent immediately to other people, and then unified processing (RIP after receiving the routing information, deal with their own complete cycle to the other person to send) (example: 5 barrels of water boil for 5 people .RIP: a get 5 buckets of water, boil that their barrels, then other water to B ... OSPF:.. the water to give to everyone, and then boil together)
Good scalability OSPF supports multiple routing protocols work together to distinguish between internal routes and external routes (divided into different areas) (RIP uniform, I do not know who is outside internal)
Support Certification (good security) Two authentication: area authentication, authentication interfaces (for example: an area, the three areas do router authentication, authentication does not do a router, the router is a router exclude other out its routing Yigaibuli.) (Interface authentication priority level is greater than area authentication: example: two routers without opening area authentication, but the open interface authentication, they may also communicate)

OSPF packets

OSPF packets are encapsulated in IP packet header, protocol number is 89.
Here Insert Picture Description

Field effect
Version For OSPFv2 currently used, the value of this field is 2. v3 release supports IPv6
Type OSPF packet type. There HELLO, DD, etc.
Packet length It represents the entire length of the OSPF packet, in bytes.
Router ID This represents a generation Router ID packet router.
Area ID It indicates that this message needs to be advertised to the area.
Checksum Check field, check the entire range of OSPF packet, including header OSPF packets.
Auth Type Is 0 means no authentication; represents a simple plain text password authentication is 1; represents an encryption (MD5) authentication is 2.
Authentication Authentication information required. Contents of the field with the value AuType differ.

Update mode

单播:单播更新为特殊情况,要手工配置
组播:默认更新方式

Packet type

OSPF packet types There are five, each message uses the same OSPF packet header. They are:

Type Message name Messages sent
1 Hello Discover and maintain neighbor relationships
2 Database Description Interactive link state database summary
3 Link State Request Requests a particular link state information
4 Link State Update Detailed transmission link status information
5 Link State Ack(LSAck Send confirmation message (LSA attention and make a difference)

Note: DD, LSU, LSR, LSACK. For more information on LSA only carry LSU, others are just header information.

OSPF simple works

Here Insert Picture Description

  1. Neighbor established

     路由器之间发现并建立邻居关系。
    
  2. Synchronize the link state database

     每台路由器产生并向邻居泛洪链路状态信息,同时收集来自其他路由器链路状态信息,完成LSDB(Link State Database)的同步。
    
  3. Calculate the optimal route

     每台路由器基于LSDB通过SPF算法,计算得到一棵以自己为根的				SPT(Shortest Path Tree),再以SPT为基础计算去往各目的网络的最优路由,并形成路由表。
    

Neighbor state machine

Here Insert Picture Description

status effect
down OSPF opened but did not receive any of the OSPF packet, only send Hello packets (periodic 10s)
Attempt 此状态只在NBMA网络上存在**(NBMA后面会提一下)**,表示没有收到邻居的任何信息,但是已经周期性的向邻居发送报文,发送间隔为(30s)HelloInterval。如果RouterDeadInterval(死亡)间隔(120s)内未收到邻居的Hello报文,则转为Down状态(相当于死亡,转为死亡状态,初始状态就是死亡状态(没有使用就是死亡)) (简单理解:手工配置了邻居,去找这个邻居,但是邻居还没有恢复你报文) 这种状态很难遇到,作为了解即可。
Init 接受到了邻居发送的HELLO报文,但是报文中的邻居信息没有存在我。 (最开始A喊:有人吗。B听到了知道A的存在,但是A不知道B的存在。)
2-Way 邻居状态的最高状态 接受到了邻居的HELLO报文,同时邻居的HELLO报文中存在我。 在DROther(代表了既不是DR、也不是ODR)之间最高只能是2-Way状态 (DR:指定路由器,负责收集分发LSA信息。虚拟出来的路由器,依附在实体路由器的接口上) (BDR:备份路由器,作为DR的备份,虚拟)(DR与ODR都是IP的时候讲的)
ExStart 形成邻接状态的第一步 开始交互DD报文,选举主从关系(就是选举DR,BDR) 报文不携带LSA头部
Exchange 主从关系选举完成 还是一样交互DD报文,此时DD报文携带LSA信息。交互完后根据情况进入Loading状态或Full状态。 (此时已经交换目录,然后要不要交换书籍看自己)
Loading 发现自己的LSDB不存在对方的部分LSA信息,所以发送LSR报文进行请求,接收到LSR的路由器,将回复LSU报文,当发出LSAck报文后进入Full状态
Full 邻接状态 作为OSPF路由器之间关系的最高状态,代表了LSDB已经同步。

总结:八种状态,除了Attempt有点特殊,我们作为了解。其他的我们来看一下。首先路由器开启了OSPF之后,最开始处于down状态,然后到2-Way状态这段过程种,路由器都处于邻居的关系中,这个阶段只发送Hello报文。之后三个状态,路由器都处于形成邻接状态的路上。然后到最后Full状态的时候,完成邻接状态。(具体邻居、邻接关系后面还会详细讲到)

Router ID、邻居与邻接

Router ID

概念:OSPF路由器在本AS(自治系统)内的唯一标识(不能重复,重复则一直报错,不能建立邻居关系)。

组成:32个比特,写法与IP地址相同(点分十进制),但是Router ID可以是路由器没有的ID

配置:可手动配置;若不手动配置则自动配置。(通常建议手动配置,以防因为地址改变发生的id改变)

自动配置规则:

  1. Router id会自动获取你配置的第一个IP地址
  2. 如果设备存在多个逻辑接口地址,则路由器使用逻辑接口中最大的IP地址作为Router ID;
  3. 如果没有配置逻辑接口,则路由器使用物理接口的最大IP地址作为Router ID
  4. 在为一台运行OSPF的路由器配置新的Router ID后,可以在路由器上通过重置OSPF进程来更新Router ID

在实际情况中,Router ID的变化采取稳定大于一些的原则:在设置好了Router ID之后,再去修改,不生效。

邻居与邻接

邻居(Neighbor)

概念:

相连的路由器,互相知道对方的存在

状态2-Way的时候建立成邻居关系

邻接(Adjacency)

概念:

相连的路由器,LSDB进行了同步

只有当双方成功交换DD报文,并同步LSDB后,才形成真正意义上的邻接关系。

邻居关系和邻接关系演变

邻居发现

Here Insert Picture Description
OSPF的邻居发现过程是基于Hello报文来实现的,我们说首先刚开启OSPF的时候,路由器处于down的状态啊,然后路由器通过Hello报文来发现邻居。

Hello报文
组成 作用
Network Mask 网络掩码 发送Hello报文的接口的网络掩码。 网络掩码不一致会影响建立邻居
Hello Interval 发送Hello报文的时间间隔,单位为秒。间隔默认为10s,NBMA网络为30s ( 广播型网络上缺省值为10s,非广播型网络如上为30s。) 接收的Hello Interval必须和接受端口的配置一致,不然接受到的Hello报文不合法。
Options 选项 标识发送此报文的OSPF路由器所支持的可选功能。 具体的可选功能已超出这里的讨论范围。
Router Priority 接口优先级 发送Hello报文的接口的Router Priority,用于选举DR和BDR。 默认是1,最大值是255
Router Dead Interval 失效时间 如果在此时间内未收到邻居发来的Hello报文,则认为邻居失效; 单位为秒,通常为四倍Hello Interval。普通40s 、特殊(NBMA)120s 所接收的Hello报文中Router Dead Interval字段必须和接收端口的配置一致。
Designated Router 指定路由器 发送Hello报文的路由器所选举出的DR的IP地址。 如果设置为0.0.0.0,表示未选举DR路由器。
Backup Designated Router 备份路由器 发送Hello报文的路由器所选举出的BDR的IP地址。 如果设置为0.0.0.0,表示未选举BDR。
Neighbor 邻居 邻居的Router ID列表,表示本路由器已经从这些邻居收到了合法的Hello报文。 如果路由器发现所接受的报文邻居列表里面有自己的router i那么就认为已经建立了邻居关系。(路由器到2-way状态)
  • 如果路由器发现所接收的合法Hello报文的邻居列表中有自己的Router ID,则认为已经和邻居建立了双向连接,表示邻居关系已经建立。(可重提)

验证一个接收到的Hello报文是否合法包括:

  • 如果接收端口的网络类型是广播型,点到多点或者NBMA,所接收的Hello报文中Network Mask字段必须和接收端口的网络掩码一致,如果接收端口的网络类型为点到点类型或者是虚连接,则不检查Network Mask字段;
  • 所接收的Hello报文中Hello Interval字段必须和接收端口的配置一致;
  • 所接收的Hello报文中Router Dead Interval字段必须和接收端口的配置一致;
  • 所接收的Hello报文中Options字段中的E-bit(表示是否接收外部路由信息)必须和相关区域的配置一致。

数据库同步

Here Insert Picture Description

路由器在建立完成邻居关系之后,路由器下一个状态就到ExStart。这时候便开始进行数据库同步。

路由器使用DD报文来进行主从路由器的选举和数据库摘要信息的交互。(DD报文的作用:选举主从关系、DD报文包含LSA的头部信息,用来描述LSDB的摘要信(告诉别人我有什么))

数据库同步详细步骤

  • 邻居状态变为ExStart以后,RTA向RTB发送第一个DD报文,在这个报文中,DD序列号被设置为X(假设),RTA宣告自己为主路由器。

  • RTB也向RTA发送第一个DD报文,在这个报文中,DD序列号被设置为Y(假设)。RTB也宣告自己为主路由器。由于RTB的Router ID比RTA的大,所以RTB应当为真正的主路由器。

  • 主从关系选举完成

    • 选举条件:

        1. 接口优先级(接口优先级一样则看Router ID)
        2. Router ID:越大越优先
      
  • (开始信息的交互)

  • RTA发送一个新的DD报文 (从),在这个新的报文中包含LSDB的摘要信息,序列号设置为RTB在步骤2里使用的序列号,因此RTB将邻居状态改变为Exchange。

  • 邻居状态变为Exchange以后,RTB发送一个新的DD报文 (主) ,该报文中包含LSDB的描述信息,DD序列号设为Y+1(上次使用的序列号加1)。

  • 即使RTA不需要新的DD报文描述自己的LSDB,但是作为从路由器,RTA需要对主路由器RTB发送的每一个DD报文进行确认。所以,RTA向RTB发送一个内容为空的DD报文,序列号为Y+1。

  • 发送完最后一个DD报文之后,RTA将邻居状态改变为Loading;RTB收到最后一个DD报文之后,改变状态为Full(假设RTB的LSDB是最新最全的,不需要向RTA请求更新)。

建立完全邻接关系

Here Insert Picture Description
步骤

  • 假设RTB的LSDB是最新最全的,不需要向RTA请求更新,那么RTB直接进入Full状态。

  • RTA邻居状态变为Loading之后,RTA开始向RTB发送LSR报文,请求那些在Exchange状态下通过DD报文发现的,而且在本地LSDB中没有的链路状态信息。

  • RTB收到LSR报文之后,向RTA发送LSU报文,在LSU报文中,包含了那些被请求的链路状态的详细信息。RTA收到LSU报文之后,将邻居状态从Loading改变成Full。

  • RTA向RTB发送LSAck报文,用于对已接收LSA的确认。

    • 若此时RTA一直不发送LSAck报文,则RTB会一直向RTA发送LSU报文
  • 此时,RTA和RTB之间的邻居状态变成Full,表示达到完全邻接状态。

以上就是OSPF一个完整的发现、建立邻居和邻接关系的工作工程。

LSA

LSA(Link State Advertisement)是路由器之间链路状态信息的载体。LSA是LSDB的最小组成单位,也就是说LSDB由一条条LSA构成的。
Here Insert Picture Description

所有的LSA都有相同的头部,关键字段的含义如下:

字段 作用
LS age 此字段表示LSA已经生存的时间,单位是秒。相当于年龄
LS type 此字段标识了LSA的格式和功能。常用的LSA类型有五种。1、2、3、5、7(后面文章会详细具体讲到)
Link State ID 此字段是该LSA所描述的那部分链路的标识,例如Router ID等。(Type不同,描述的信息不同)
Advertising Router 此字段是产生此LSA的路由器的Router ID。
LS sequence number 此字段用于检测旧的和重复的LSA。

OSPF支持的网络类型

Here Insert Picture Description
Here Insert Picture Description

网络类型 解释 举例
广播型网络 支持两台以上路由器,并且具有广播能力的网络 多个用户共享同一通信信道。在网络中只有一个通信信道,由这个网络中所有的主机所共享的 一个含有三台路由器的以太网就是一个广播型网络的例子
点到点网络(P2P) 两台路由器直接相连的网络(用光纤和双绞线的是广播网络) 串行链路(s口) 一个运行PPP的64K串行线路就是一个点到点网络的例子
NBMA网络 非广播-多路访问网络(Non-Broadcast Multiple Access) NBMA用来描述如X.25和帧中继这类本身并不具有支持广播和多播能力的多路访问网络
点到多点网络 (P2MP) (Point To Multi-Points) 将整个网络看成是一组点到点网络 对于不能组成全连接的网络应当使用点到多点方式,例如只使用PVC的不完全连接的帧中继网络。
  • 缺省情况下,OSPF认为以太网的网络类型是广播类型,PPP、HDLC的网络类型是点到点类型。
  • 缺省情况下,OSPF认为帧中继、 ATM的网络类型是NBMA。
  • OSPF可以在不支持广播的多路访问网络上运行,此类网络包括在hub-spoke拓扑上运行的帧中继(FR)和异步传输模式(ATM)网络,这些网络的通信依赖于虚电路。OSPF定义了两种支持多路访问的网络类型:非广播多路访问网络(NBMA)和点到多点网络(Point To Multi-Points)。
  • NBMA:在NBMA网络上,OSPF模拟在广播型网络上的操作,但是每个路由器的邻居需要手动配置。NBMA方式要求网络中的路由器组成全连接。
  • P2MP:将整个网络看成是一组点到点网络。对于不能组成全连接的网络应当使用点到多点方式,例如只使用PVC的不完全连接的帧中继网络。

扩展

  • MA网络是指multiple access多路访问网络。(MA=NBMA+广播式网络),多路访问是指在一条链路上有多个访问点,区别于点到点(P2P)或点到多点(P2MP)的网络。

OSPF single region with a simple configuration

Here Insert Picture Description
Configuring Content:

[RTA]ospf [process id] [router-id 1.1.1.1]   //使能OSPF,在该命令中可以配置进程ID,若不配置则进程ID缺省为1;配置Router ID,若不配置则使用全局Router ID,中括号中可写可不写。
[RTA-ospf-1]area 0 //进入骨干区域 ,(0为0.0.0.0,0为简写。Area 1为0.0.0.1与ip写法一样)
[RTA-ospf-1-area-0.0.0.0]network [相邻网段] [反子网掩码] //宣告网络,并开启接口OSPF功能。

verification:

display ospf peerSee for neighbor related properties, including the status area, a neighbor's, the major abutment negotiation state, and from the DR and BDR situation.

[RTA]display ospf peer 

​     OSPF Process 1 with Router ID 1.1.1.1 //ospf进程号1,Router ID为1

​         Neighbors                   //邻居

Area 0.0.0.0 interface 192.168.1.2(GigabitEthernet0/0/0)'s     //在Area 0的区域这个接口下邻居有谁

 neighbors                                          //邻居有谁

  Router ID: 2.2.2.2     Address: 192.168.1.1              //有一个Router ID2的路由器,IP地址是192.168.1.1                  

  State: Full Mode:Nbr is Slave Priority: 1             //邻接状态:full、模式:邻居是从(主从关系),优先级:1

​        邻居是主:MASTER

  DR: 192.168.1.2 BDR: 192.168.1.1 MTU: 0     // DR(从IP地址看是自己)、BDR(从IP地址看是Router 2的路由器)

​       与上面主从关系对标

  Dead timer due in 40 sec                  //死亡时间40s

  Retrans timer interval: 5                   //倒计时,会一直变

  Neighbor is up for 00:00:31                //邻居起来多久了,计时。

  Authentication Sequence: [ 0 ]              //认证号,没有认证是0
Published 20 original articles · won praise 27 · views 3194

Guess you like

Origin blog.csdn.net/qq_46254436/article/details/104839585