首页 > 代码库 > OSPF补全计划-1
OSPF补全计划-1
OSPF全称是啥我就不絮叨了,什么迪杰斯特拉,什么开放最短路径优先算法都是人尽皆知的事儿,尤其是一提算法还会被学数据结构的童鞋鄙视,干脆就不提了,直接开整怎么用吧。(不过好像真有人不知道OSPF里的F代表了什么...)
一个大概的profile:
89号协议,链路状态协议Link State之一,组播地址会用到224.0.0.5(DR other 用来收听DBD LSR LSU LSA的,也就是下面5种包中的4种) 224.0.0.6(DR BDR用来收听。。。的)
跟大多数dynamic routing protocol一样,它也是Hello包建邻居,生产邻居表;接下来开始传信息,这些信息被OSPF称为LSA,这个LSA不是上面提到的那个LSA,这个是Link State Advertisement, 这些信息被交互过之后就存入Link State Database, 即LSDB,即topology表。这个拓扑表,我个人认为就是被SPF这个算法所直接读取的,然后去给你计算出最短路径,这个拓扑表不光包含了路由,应该算作是路由表的一个母体,它里面会有我的哪个端口接了谁的哪个端口。
Link State Routing Protocol 这是从思科的PPT上抄的,什么EIGRP是道听途说OSPF才是有组织的居委会之类的陈词滥调我就不说了,我今天是以一个长者的身份对你们说,唉?好像哪里不对
- Link State routers recognize more information about the network than their distance vector counterparts
- Each router has a full picture of the topology
- Consequently, link state routers tend to make more accurate decision
Link State Data Structure:
Network Hierarchy 是一个backbone区域周围连几个area 1 2 3 4这样的结构
- Router A and B are backbone routers
- Backbone routers make up area 0
- Routers C, D and E are known as area border routers (ABRs)
- ABRs attach all other areas to area 0
它的目的是:
- Minimize routing table entries
- Localizes impact of a topology change within an area
- Detailed LSA flooding stops at the area boundary
- Requres a hierarchical network design
但是说实话,我们公司就没这么做,因为犯不着,具体原因后面再说。
Forming OSPF Adjacencies
- Point-to-point WAN links:
- Both neighbors becomes fully adjacent
- LAN links (MA) including BMA(such as Ethernet) and NBMA(such as FR)
- Neighbors form a full adjacency with DR and BDR
- Router s maintain two-way state with the other rotuers(DR other)
- Routing updates and topology information are passed only between adjacent routers
- Once an adjacency is formed, LSDBs are synchronized by exchanging LSAs
- LSAs are flooded reliably throughout the area (or network)
整个topology是触发更新的,但是你要是迟迟不触发它,它自己30min会refresh一次,老化时间是60min.
OSPF有5种包
- Hello
- Database Description
- Link-State Request
- Link-State Update
- Link-State Acknowledgment
每个OSPF的speaker都有一个router-id,确定router-id的方法如下,按照先后顺序依次是:
- 手工指定(任意,唯一)
- loopback口(if any)最大的地址
- 物理口最大地址
(要是以上三个都没有,那你还跑个毛的OSPF,不许抬杠哦!)
建立Neighborhood的条件,也就是说这俩speaker得一致的条件 PS. speaker counterpart peer都是常用的这种邻居的英文表达,尤其counterpart 和 peer的意思更是接近,都有对等体的意思,speaker没有对等体的意思
- Hello and Dead intervals Hello interval 有两种,一种是10s的默认用在以太网Ethernet link上的,另一种是30s的默认用在non-broadcast link上的,如serial link,如NMBA
- Area ID
- Authentiation passwd (if any)
- Stub area flag
OSPF建立邻居需要经过的几个状态
Initial 正在交换Hello包
Two way Hello包交换完毕,Hello包里有自己的router-id,反正是用于比较router-id的,MA网络在没有改端口优先级的情况下用来选出谁是DR BDR & other,完了 整个地方还牵扯网络类型..整个dr other 之间是没有未来的,他们就停留在two way 状态,所以他们也不算邻居neighbor而是邻接adjacent
Exstart 选主从,router-id大的是Master,小的是slave,整个可以通过 debug ip os adj debug ip ospf packet 在slave上可以看到"NBR Negotiation Done. We are the SLAVE."这样一条忧伤的信息
Exchange 交换 LSDB
Loading 交换LSR LSU
Full
PS. 感觉能把每个包头部都画出来的绝对是大神...困死了,睡觉去。
OSPF补全计划-1