OSPF 原理

关于OSPF的数据结构
Link-State Protocol Data Structures
链路状态路由器与距离矢量路由器,可以知道关于整个网络的更多信息
Neighbor table:also known as the adjacency database
邻居表:也正如我们知道的 邻接关系数据库
Topology table:referred as the LSDB
拓扑表:指的就是 链路状态数据库
Routing table:also knowns as the forwarding database
路由表:也正如我们知道的转发数据库。
Each router has a full picture of the topology.
每一个路由器都有完整的拓扑信息。
Link-state routers tend to make more accurate decisions.
运行链路状态路由选择协议的路由器可以做出更加准确的决策。

OSPF Areas
Link-state routing requires a hierarchical network structure.
链路状态的路由协议 需要一个层次化的网络结构
This two-level hierarchy consists of the following:
这种两层的层次架构包括下面的:
Transit area (backbone or area 0)
穿越区域,或者说传输区域, 又称为:骨干区域。 在多区域的ospf中,必须有0区域,其他的区域连接

到ospf的骨干区域上。当然对于网络规模不是太大的,也可以只有0区域。
对于单区域 来说, 区域号 可以用1 ,也可以用 10 etc。 当然 区域号必须一致。
区域号:为32位的二进制数。
Normal areas(non-backbone areas)
普通区域 (非骨干区域)

 

区域边界在路由器上。

ABR:Area border Router :区域边界路由器,用来连接不同区域的路由器。

ASBR:Autonomous System Boundary Router 自治系统边界路由器。:用来连接不同的自治系统,比如在

rip和ospf相连的网络,必须进行重分布。

Internal routers:所有的接口都在同一个区域之中。

Backbone routers:只要有一个接口在骨干区域之内即可。 例如:ABR ASBR 都算是骨干区域路由器。


Routing updates and topology information are passed only between adjacent routers.
路由更新和拓扑信息只在建立邻接关系的路由器之间传递。
Forming OSPF adjacencies on point-to-point WAN links.
在点到点的WAN链路上,形成ospf 邻接关系。
Forming OSPF adjacencies on LAN links is different than forming them on point-to-point links
在LAN链路上建立邻接关系是不同于WAN链路的。

Routers find the best paths to destinations by applying Dijkstra's SPF algorithm to the LSDB
根据链路状态数据库运用dijkstra's SPF 算法,路由器可以发现到达目的地的最佳路径。
The best path is calculated based on the lowest total cost and sent to the routing table.
最佳路径是基于最小的总的cost值计算出来的,然后被送往路由表中。

OSPF 的度量值是 cost
cost=10的8次方 除以带宽。 即cost=100,000,000 / bandwidth [b/s]

Defined per interface,but may be altered.
确定每一个接口的配置,但是可以改变。
Inversely proportional to the bandwidth of that interface.
度量值和 接口的带宽成反比。

Buliding the LSDB
The Hello protocol is used to define neighbors
Hello包用来确定邻居。
Adjacency is established
邻接关系建立
Adjacent routers exchanges LSAs
建立邻接关系的路由器交换LSAs
Each router build an LSDB using LSAs.
每一个路由器都是用LSAs,建立 LSDB,链路状态数据库。
也就是 构筑 自己的 关于整个网络的拓扑。

如何来查看LSA是否是最新的。
An LSA is more rencent if it has:
A higher sequence number 序列号
A higher checksum number 校验和
An age equal to the maximum age(poisoning)寿命时间
A  significantly smaller link-state age (the LSA is significantly younger)

Each LSA in the LSDB maintains a sequence number
4-byte number
begins with 0x80000001;ends with 0x7FFFFFFF

OSPF floods each LSA every 30 minutes.
OSPF每隔30分钟泛洪LSA
Each time,the sequence number is incermented by one.
每一次,序列号会增加一。
The LSA with the higher(newer)sequence number is more recent.
拥有最高序列号的LSA是最新的。

Ultimately,a sequence number will wrap around to 0x80000001
The exsting LSA was prematurely aged to the maximum age (one hour)and fulshed.
现存的LSA过早的达到最大的值之后,一个小时,把它刷新掉,然后,重置为0x80000001,这样子,

0x80000001 就成为最新的了。
Every OSPF router announces a router LSA for those interfaces that is owns in that area.

 

命令:show run |sec router ospf
显示 ospf的相关配置。
包括 重新发布的路由。

命令:show run |sec router rip
显示rip 的相关配置。
包括重新发布进入rip的路由。

High-level functions of OSPF include the following:

Discover neighbors and form adjacencies
Flood link-state database(LSDB)information
Compute the shortest path
Install routers in the route-forwarding table

Additional functions of OSPF include the following:
Detect changes in the link state 自动检测链路状态
Propagate changes to maintain link-state database synchronization

Several OSPF packet types are involved

 

OSPF uses five types of routing protocol packets.
1.Hello包
2.Database Description  数据库描述包即DBD包
3.Link-State Request    链路状态请求包
4.Link-state Update     链路状态更新包
5.Link-state Acknowledment 链路状态确认包

使用 debug ip ospf packet 命令,查看 运行ospf 的路由器,收发的ospf数据包。
This debug output shows the fields in the OSPF header.
这个debug命令输出显示了在ospf报头中的字段。

Neighbor Relationship : The Hello Packet
邻居关系在two-way状态形成,邻居之间互相发送hello包。
*Entries must match on neighboring routers.
要形成邻接关系必须匹配的条目
Hello包的内容如下:
Router ID
Hello and dead intervals*
Neighbors
Area ID*
Router priority
DR IP address*
BDR IP address
Authentication password*
Stub area flag*
其中 要形成邻居 关系, Hello and dead intervals  Area ID*  DR IP address*  Authentication

password*   Stub area flag*  这些必须匹配。

Use of Multicast and unicast IP address
point-to-point:224.0.0.5     组播地址224.0.0.5 代表所有ospf路由器。
broadcast:DRother 监听:224.0.0.5     DR/BDR 监听:224.0.0.6
Four types of update packets

LSDB synchronization process
Discover neighbor 发现ospf 邻居。
Establish bidriectional communication 建立双向的联系。
Elect a designated router,if desired 如果需要协商,选举DR
Form an adjacency  形成邻接关系。
Discover the network routers 发现 网络上的其他路由器。
Update and synchronize link-state databases.  更新和同步链路状态数据库。


OSPF  Establishing Bidirectional communication
 建立双向通信状态。

1.Down state  Down 状态。路由器之间没有进行任何的数据交换与传输。
发送 hello 包,携带必要的信息,去建立邻居关系。
2.Init state  初始化状态。
3.Two-way state Two-way 状态。
如果 network-type:broadcast ,那么需要在two-way状态 进行DR与BDR 的选举。
4.Exstar State :信息交换初始状态——确定“主路由器”与“从路由器”。谁的路由器ID越高,谁将

成为“主路由器”。信息交换,由 “主路由器” 首先 发送 给 “从路由器”。
5.Exchange State 交换信息 状态
发送 汇总的LSDB信息。 summary of my LSDB.收到之后,要发送相应的ACK包确认。
6.Loading State 载入状态。
发送LSR,即链路状态请求包。请求邻居有,而自己没有的相关的路由条目。
7.Full State 状态。
完全邻接状态。

OSPF Neighbor States  OSPF邻居的状态
OSPF routers progress through seven states:OSPF完成整个收敛所要经历的七个状态。
1.Down:no active neighbor detected
2.INIt:hello packet received
3.Two-way:own router ID in received hello
4.Exstart:master and slave roles determined
5.Exchange:database description packets sent
6.Loading:exchange of LSRs and LSUs
7.Full:neighbors fully adjacent


OSPF Network Types
OSPF 网络类型:
Point-to-point:A network taht joins a single pair of routers.
Broadcast:A multiaccess broadcast network, such as Ethernet.
Nonbroadcast multiaccess(NBMA):A network that interconnects more than two routers but that
has no broadcast capability.
-Examples:Frame Relay, ATM,and X.25
-Five modes of OSPF operation are available for NBMA networks.


Point-to-Point Links
Usually a serial interfce running either PPP or HDLC
通常 是 串口 封装ppp 或者 HDLC 协议。
May also be a point-to-point subinterface running Frame Relay or ATM
也可能是点到点的子接口欲行 帧中继或者ATM
Does not require DR or BDR election
不需要DR和BDR 的选举。
Is automatically detected by OSPF
可以被OSPF自动识别。
Sends OSPF packets using multicast 224.0.0.5
发送OSPF包使用多播地址:224.0.0.5


Multiaccess Broadcast Network
This generally applies to LAN technologies like Ethernet.
DR and BDR selection are required.
All neighbor routers form full adjacencies with the DR and BDR only.
Packets to the DR and the BDR use 224.0.0.6
Packets from DR to all other routers use 224.0.0.5

DR的选举:
Hello packets are exchanged via IP multicast
DR: The router with the highest OSPF priority
BDR:The router with the second-highest priority value
The OSPF router ID is used as the tiebreaker  OSPF 的RID用来 决胜DR 和BDR
The DR election is nonpreemptive

 

1.只要配置的换回口的IP被通告进入了ospf网络,那么它的掩码就是32位的。不管你配置的掩码是多少。
这是ospf 的默认配置。

2.如何还原ospf中loopback接口的默认掩码呢?

ip ospf network point-to-point
如果使用了这一条命令,那么相当于还原了ospf的loopback接口的真实掩码,而并不是ospf默认的32位。


DR 的第一个特点:

1.不抢占。
clear ip ospf process *

清除之后,然后再看。


ip ospf priority

数值越大,优先级越高。比如 2 的优先级就 比 1 要高。

2.当DR down掉以后,BDR直接升为DR,而在整个区域中,重新选举BDR。

3.DR BDR DRother 是 接口概念 。

4.不同网段,分别选DR ,BDR。

 

1.在广播和NBMA网络中需要选举
2.优先级最高,优先级取值0-255
3.默认优先级1,如果是0表示无资格选举
4.如果优先级相同,选择路由器ID值最大的
5.如果网络中已存在DR,后加入的路由器即使优先级更高也不会改变现有DR,因为DR是非抢占的。
6.如果DR出现故障,BDR直接接替DR角色,再从网络中选出新的BDR
7.DR/BDR 从接口级别选举。

命令 ip ospf priority “value”
可以修改优先级。
1.This interface configuration command assigns the OSPF priority to an interface
2.Different interfaces on a router may be assigned different values.
3.The default priority is 1. The range is from  0 to 255.
4.“0” means the router cannot be the DR and BDR
5.A rotuer that is not the DR or  BDR is DROTHER。

NBMA Topology
A single interface interconnects multiple sites
NBMA topologies support multiple routers,but without broadcasting capabilities.
Five modes of OSPF operation are available.

DR Election in NBMA Topology
1.OSPF considers NBMA to be like other broadcast media.
2.The DR and BDR need to have fully meshed connectivity with all other routers,but NBMA

networks are not always fully meshed.
—The DR and BDR each need a list of neighbors.
OSPF neighbors are not automatically discovered by the router.

There are five modes of OSPF operation.
RFC 2328-compliant modes are as follows:
-Nonbroadcast (NBMA)
-Point-to-multipoint
Additional modes from Cisco are as follows:
-Point-to-multipoint nonbroadcast
-Broadcast
-Point-to-point

posted @ 2015-04-14 10:18  Fatt  阅读(1212)  评论(0编辑  收藏  举报