OSPF Protocol Overview: (Open Shortest Path first-shortest path priority)
OSPF在不同的路由器之间,通过互相传递各自的路由条目,以 保证全网的所有的设备,具备相同的路由信息。 运行 OSPF 的路由器,会以组播的方式周期性的发送 OSPF Hello 报文, 用于 OSPF 邻居关系的建立。 -周期时间 : 10s -组播地址 : 224.0.0.5 ->表示的是所有的 OSPF 路由器。 - OSPF 属于 OSI 模型第 3 层 ; - 在 IP 头部中使用的协议号 是: 89
Network type
1.broadcast
2.NBMA
3.p2p
4.p2mp
OSPF working process:
1、建立邻居表 :考虑邻居的建立过程以及影响因素2、同步数据库 :考虑数据库同步的过程以及稳定性3、计算路由表 :每一个路由器都会基于“自己的”数据库信息,
Type of message for OSPF:
1. Hello--for the establishment, maintenance and demolition of OSPF neighbors
2, DBD (DD)--Database description, Data description message
3, LSR-link state request, link status requests message--database entry
4, LSU-link State Update, link status updates message-database entry
5, Lsack-link State ack, link status confirmation message
DBD key Field Description:
I-init, if the token is 1, indicates that the DBD message is "first DBD".
By comparison of the first DBD message, the master-slave relationship is determined;
M-more, if the mark is 1, indicates that there are more DBD messages in the back, i.e.
The DBD message is not the last dbd, so this should not be done at this time
Following the Loading, this is the exchange phase.
Ms-master/slve, if the token is 1, indicates that the router is the primary route, and if it is 0
Indicates that the router is from a route.
Once the master-slave relationship is determined, the DBD message sent from the router
The serial number should be changed with the DBD serial number of the main router to achieve
"Implicit acknowledgment" of the DBD message.
DBD Sequence , DBD报文序列号。每个路由器发送的第一个 DBD 的序列号 是随机的。一旦确定主从关系,那么从路由器的 DBD 的序列号 要随着主路由器的变化。从而实现 DBD 报文的“可靠”传输。
OSPF Database:
Content contained in the OSPF database, called LSA (link-state advertisement)
That is, link-state advertisements.
OSPF computes the router through various types of LSA.
Different types of LSA are used, and the types of routes that are computed are different.
LSA Entry Structure:
Type: Indicates the kind of LSA (1/2/3/4/5/7)
Link-id: Represents the name of the LSA, and the representation of the names of the different types of LSA is different.
Advrouter: Represents the advertise router, which is the notification router, which is the LSA
The name of the router
Age: Indicates the time of the LSA's survival, in seconds, and is being timed. The maximum value is 3600s.
If the time-to-live becomes 3600s, it means that the LSA is not available and must be deleted in the database.
To ensure that the LSA does not cause accidental deletion due to the normal timing of the time,
Therefore, we need to send a "new" LSA before the LSA reaches the maximum age.
The new LSA is generated and sent every 1800s at once;
The new LSA can only be generated by the LSA's advrouter.
When the other router receives this "new LSA", it will clear its age timer by 0.
Re-timer.
"OSPF database refresh mechanism: 1800s"
Lenght: Represents the message length of the LSA.
Sequence: serial number. Represents the new and old extent of the LSA. Each time the LSA changes, the serial number will
Add 1, which means the larger the serial number, the more new.
Watch Compare the serial numbers of all LSA in the same region, different serial numbers
The difference between, should be the smaller the better.
Metric: The measure value that represents the network segment that the LSA's generation router arrives at that LSA
The distance.
Class 1 Lsa-router LSA,
Any OSPF router will be in any of its own connected areas,
产生一个 router lsa 。相当于每一个路由器在每一个区域 自我介绍
Class 2 Lsa-network LSA
Can only be produced by DR
# 用来对同一个“网段”中的路由器,宣告 DR 的管理范围的。
Class 3 Lsa-summary ABR
Can only be generated by ABR
# 用来表示不同区域之间的路由信息的。
Class 4 Lsa-summary ASBR
Produced by an ABR with ASBR in the same area.
#用来在不同的区域之间传输“ASBR的router-id”。
Class 5 Lsa-exteral LSA
Can only be produced by ASBR.
# 用来表示 OSPF 的外部路由;
OSPF Neighbor Establishment Impact factor: (essentially in parsing the parameters in Hello)
1.router-id cannot be the same.
2.area-id must be the same.
3. Authentication must be the same (type and password are the same)
4. Subnet masks must be the same (special case)
5.hello-timer must be the same
6.dead-timer must be the same
7. Special marker bits must be the same (option-represents the ability of the OSPF router)
8. Port priority cannot be all 0 (special case)
---special circumstances----
In the case of an OSPF network that requires an election dr/bdr, this is what is called a "special case" here.
DR: Specify the router
BDR: Designated Router for backup
The process of establishing an OSPF adjacency relationship:
0、down - 该状态下,down 没有启用 OSPF 协议。1、init - 初始化状态。表示的是本地路由器接收到了对方发送 过来的 hello报文;2、two-way - 双向通信状态。表示的是本地路由器接收到了对方发送 过来的 hello 报文,并且在该报文中发现了自己的RID; 如果该网络类型中需要选举DR/BDR,则在该阶段进行。3、exstart - 交换初始化状态。在该状态下,双方路由器都会发送第一个 DBD报文,为的就是选举一个主/从关系,主要目的就是为了 实现 “数据库同步”的可靠性和高效性。 [DBD报文中包含的是数据库中的条目的基本信息]4、exchange - 交换状态。在该阶段,主从路由器会进行 DBD 报文的 互相传输,最终实现两边数据库的比对工作。5、loading - 加载状态。在该状态下,主从路由器就会通过 LSR和LSU 进行 “数据库条目”的请求和发送,并通过 LSAck 报文 对该过程进行确认。6、full - 完全邻接。即此时邻居路由器之间的数据库完全一致。
Basic configuration commands for OSFP:
[R1]OSPF 1 Router-id 1.1.1.1
"ID of the router"
[R1-ospf-1]area 0
"Area 0--Backbone Area"
[R1-ospf-1-0.0.0.0]network 192.168.1.0 0.0.0.255
"Declaring a network segment"
[R1]display OSPF peer Brief
"View the neighbor table for OSPF"
[R1]reset OSPF process
"Restarting the OSPF process"
[R1-GIGABITETHERNET0/0/2]OSPF dr-priority 10
"Modify the priority of OSPF--default is 1"
[R1-GIGABITETHERNET0/0/2]OSPF Network-type Peer
"Modify Network Type"
OSPF working principle adjacency-Database