Summary of OSPF protocol (1)

OSPF protocol summary

OSPF: Open Shortest Path First (Open Shortest Path First)

OSPF overview

Version: V1/V2/V3 (V3 uses IPv6)

Belongs to classless link state routing protocol-convergence based on topology information

Group wave update: 224.0.0.5

Trigger an update to update only the amount of change

Periodic update is based on the time period-a large amount of update

If a protocol wants to achieve incremental update-only trigger no cycle; hello mechanism (period keep-alive) ACK confirmation mechanism

1. OSPF packet type

Insert picture description here
Insert picture description here

  • OPSF Version: refers to the version number of OSPF. v2 means IPv4; v3 means IPv6
  • Message Type: indicates the type of data packet following the header

Insert picture description here

  • Packet Length: The length of the OSPF packet, including the length of the packet header, in octets.
  • Source OSPF Router: the ID of the originating router
  • Area ID: The area where the route originating the data packet is located. If the data packet is sent on a virtual link, the area ID is 0.0.0.0, which is the backbone area ID, because the virtual link is considered part of the backbone.
  • Packet Checksum: A standard IP checksum of the entire packet.
  • Auth Type: the authentication mode being used

Insert picture description here

  • Auth Data: Not finished ! ! ! ! ! ! ! ! ! !

Insert picture description here

ospf is cross-layer encapsulated in IPv4 header, the protocol number is 89;

There are 5 different types of packets

Insert picture description here

Types of effect
Hello bag Discovery, establishment, and periodic keep-alive of neighbors and adjacencies; hello time 10s or 30s; dead time is four times hello time Discovery, establishment, and periodic keep-alive of neighbors and adjacencies; hello time 10s or 30s; dead time is four times hello time
DBD package Database description package (database directory) Master-slave election during LSA update; LSA interaction
LSR package Link status request Request LSA information missing from itself
LSU package Link status update (carrying specific LSA information) LSA update information (response to the other party's LSR request)
LSack bag Link status confirmation packet Confirmation reply for LSA update

LSA (Link State Advertisement): routing or topology information (generating different types of topology or routing information under different conditions)

hello package

Insert picture description here

  • **Network Mask:** refers to the network mask of the interface that sends the data packet. If this mask does not match the network mask of the interface receiving the packet, the packet will be discarded. (It can be ensured that routers can become neighbors only when their shared network addresses exactly match).
  • **Hello Interval: **The time interval between the transmission of Hello packets on the interface, which is also a periodic time period. If the receiving and sending routers do not have the same value, the adjacency relationship cannot be established.
  • Option: To be continued ! ! ! ! ! ! ! ! ! ! !
  • **Router Priority: **Used for DR and BDR router election. If this field is 0, the originating router is not eligible to be selected as a DR and BDR router.
  • **Router Dead Interval: **The length of time that the originating router will wait for the Hello packet sent from the adjacent router before declaring the adjacent router invalid.
  • Designated Router: The IP address of the designated router interface on the network. Note: It is not the router ID of the designated router . If there is no DR (DR has not been selected or the network type does not require DR), then this field is set to 0.0.0.0
  • **Backup Desinated Router: **Backup the IP address of the designated router interface on the network. Not selected and set to 0.0.0.0
  • **Neighbor (Active Neighbor): ** is a recursive field. If the originating router has received valid Hello packets from some of its neighbors from the network within a Router DeadInterval in the past, it will be in this The RIDs of all these neighbors are listed in the field.

DBD package

(Database Description) database description package

Insert picture description here

  • Interface MTU (Interface MTU): The maximum IP data packet size that the originating router interface can send when the data packet is not fragmented. (Huawei devices do not detect the MTU value by default, and Cisco does it by default)
  • Options (option):
  • **I bit (initial bit): **When sending the first data packet in a series of database description packets, this bit is set to 1. Subsequent database description packets will set this bit to 0.
  • **M bit (More bit): **When the sent data packet is not the last one in a series of database description data packets, this bit is set to 1
  • MS bit (Master/Slave bit) : During database synchronization, this bit is set to 1, which is used to indicate that the router that originated the database description packet is the "master" router.
  • **Database description sequence number (DD Sequence): **During database synchronization, it is used to ensure that the router can receive the complete database description data packet sequence. This serial number will be set by the "master" router in the initial database description data packet to set some unique values, and the serial numbers of subsequent data packets will increase sequentially.
  • **LSA Header: ** lists some or all of the LSA headers in the link state database of the originating router. Note: LSA Header will not appear during DR/BDR election

Some questions about DBD:

1. Interface MTU. In the cisco system, the MTU value of the interface between neighbors is detected by default, and Huawei does not detect it by default;

The OSPF protocol requires that the MTU value between neighbors on the direct connection interface must be consistent;

[r1]interface GigabitEthernet 0/0/1

[r1-GigabitEthernet0/0/1]ospf mtu-enable enable Huawei MTU detection

2. About the mark bit of DBD

I is 1 to identify the first DBD packet sent locally and M is 1 to identify the last DBD packet that is not local

MS is 1 for master and 0 for slave

3. Use the serial number to confirm the implicit confirmation of DBD. Based on the serial number, the main serial number is used to confirm the main

After the adjacency relationship is established, the neighbors use the real DBD to obtain the neighboring LSDB directory, and then use LSR/LSU/LSack to obtain the local unknown LSA information; generate LSDB-database table;

LSR package

Link state request packet

Insert picture description here

  • Link-state Advertisement Type : LSA type
  • Link state ID (link state ID) : originating router ID
  • Advertising router : The router ID of the router that originated the LSA advertisement

LSU package

Link state update packet

Insert picture description here

  • Number of LSAs (number of LSAs) : The number of LSAs contained in this packet.
  • Link State Announcement (LSA) : All LSAs described in the LSA packet format of the OSPF protocol. Each update packet can carry multiple LSAs.

LSAck package

Link status confirmation packet

Insert picture description here

The confirmed LSA is confirmed based on whether the LSAck packet contains his header. Therefore, an LSAck consists of only the OSPF header and the LSA header.

2. OSPF state machine

(7 standards, there is an eighth)

  • Down : Once the Hello packet is sent locally, enter the next state machine

  • Init initialization : If there is a local RID in the received Hello packet, then enter the next state

  • 2way two-way communication : a sign of neighbor relationship establishment

    ​ Conditions:

    ​ 1. The point-to-point network type directly enters the next state

    ​ 2. The MA network will conduct DR/BDR election (40s), and non-DR/BDR cannot enter the next state

  • **Exstart pre-start: **Use the DBD package that does not carry directory information to conduct master-slave relationship election, the RID value is large, and the next state is given priority.

  • Exchange quasi-exchange : Use the real DBD package to interact with the database directory, which requires ack to confirm.

  • **Loading: **By comparing the local database directory of the opposite end, LSR is used to request the local unknown LSA information, and the opposite end uses LSU to respond, and finally ack is required for confirmation.

  • **FUll forwarding: **A sign that the adjacency relationship is established.

3. OSPF working process

After starting the OSPF protocol, the local uses multicast 224.0.0.5 for periodic hello sending and receiving based on all active interfaces; if the received hello packet has a local RID, a neighbor is established and a neighbor table is generated .

All neighbors in the table have conditions. If the condition fails to match, it will stay in the neighbor relationship. Only the hello period can be kept alive. ; After the condition is matched successfully, it needs to be further established as an adjacency relationship. The adjacency relationship needs to use the DBD package to share the database directory, use LSR/LSU/LSACK to obtain the local unknown LSA information, and complete the local LSDB (link state database) -The collection of all LSAs)-generate data tables ;

After the database synchronization is completed, the rest of the local SFP algorithm generates a directed graph based on the database, synthesizes the shortest path tree, and finally loads all the routes of the unknown network segment into the local routing table ;-the convergence is completed, the hello packet cycle is kept alive every 30 minutes Compare the database catalogs periodically;

Abrupt network structure:

1. New network segment-directly connected to the device of the newly added network segment, use the update package to notify all local neighbors, and then spread to the entire network, requiring ACK confirmation;

2. Disconnect the network segment-directly connect to the device that disconnects the network segment, use the update package to notify all local neighbors, and then spread to the entire network, requiring ACK confirmation;

3. Unable to communicate-when the dead time is up, the neighbor is disconnected and the neighbor is deleted; and the LSA obtained through the adjacency will no longer be used;

4. OSPF interface network type

The OSPF protocol works differently on interfaces of different network types.

Network Type How OSPF works
loopback Although Huawei is marked as point-to-point, it is actually a special work of loopback, without hello packet sending and receiving, and directly learning 32-bit host routing
Point to point 10s hello time; direct adjacency, no DR election; (PPP/HDLC on the serial line; ordinary GRE)
BMA (Ethernet) broadcast; 10s hello time; conduct DR/BDR election and finally establish adjacency
NBMA (MGRE) The default is a point-to-point work mode, which can only establish one neighbor; therefore, it will not be able to establish relationships with all nodes in the NMBA environment;

NBMA topology:

1. Star-center to site

2. Part of the mesh structure, excluding the star shape

3. Fully connected mesh structure

NBMA cannot establish adjacency relationship with all nodes. Solution: Modify the interface type to broadcast

[r1]interface Tunnel 0/0/0
[r1-Tunnel0/0/0]ospf network-type broadcast  该网段所有接口修改为broadcast;

Note:

1. If one end is point-to-point and the other end is broadcast, since the hello time is 10s, a neighbor relationship will be established, but it cannot work normally; therefore, once any ospf type is modified, it must be ensured that all nodes in the network segment are of the same type ;

2. In the star and partial mesh structure, if you use the broadcast mode of work, you must consider the position of dr; it is recommended to directly fix it at the central site; if it is a fully connected mesh structure, you can not use the dr position;

5. OSPF DR election

The conditions for the neighbor relationship to become the neighbor relationship:

​ In the MA network, since the number of nodes is not limited, the two are neighbors. If there is no control, there will be a lot of repeated updates; the distance vector protocol (RIP/EIGRP) has a split horizon mechanism to solve it; but the OSPF protocol Interface split horizon cannot be used (in from this port but not out from this port), so ospf chose the DR/BDR election method to solve it. There is a DR and a DBR in the MA network segment, and other devices are not DR/BDR, not DR/BDR No adjacency relationship is established between them, only neighbor relationships are maintained to avoid repeated updates.

Election rules:

1. Compare the priority of the interface, 0-255 is 1 by default; if the value is large, it is 0 to indicate no participation

2. If the interface priority is the same, compare the RID of the participating devices, the value is large;

[r1]interface GigabitEthernet 0/0/0
[r1-GigabitEthernet0/0/0]ospf dr-priority ?
  INTEGER<0-255>  Router priority value

6. OSPF basic configuration

[r1]ospf 1 router-id 1.1.1.1 
1.启动时需要定义进程号,仅具有本地意义;

2.同时建议配置RID,ipv4地址编写规则;必须全网唯一;

3.手工---》环回最大数值-》物理接口最大数值

[r1-ospf-1]

宣告:
1、激活—被选中接口可以收发ospf 的数据包
2、传递接口信息—被选中接口的信息将被共享给本地的其他邻接  3、区域划分
[r1-ospf-1]area 0

[r1-ospf-1-area-0.0.0.0]network 1.1.1.1 0.0.0.0

[r1-ospf-1-area-0.0.0.0]network 12.1.1.1 0.0.0.255

Zoning rules:

1. Star structure topology-area 0 is the backbone, and greater than 0 is non-backbone; non-backbone must be connected to the backbone area;

2. ARB—Area Border Router must exist between areas

After the startup configuration is completed, hello packets are sent and received between neighbors to establish a neighbor relationship, and a neighbor table is generated:

The contents of the Hello package

[External link image transfer failed. The source site may have an anti-leech link mechanism. It is recommended to save the image and upload it directly (img-sAWzwWax-1601902102827)(file:///C:/Users/Lenovo/AppData/Local/Temp/msohtmlclip1 /01/clip_image002.png)]

The parameters in the hello packet between neighbors must be completely consistent; otherwise, the neighbor relationship cannot be established;

1. Hello, dead time 2. Area ID (ABR) 3. Authentication 4. Peripheral area mark (special area)

5. In the hello packet of Huawei equipment, there is also the subnet mask of the local interface ip address. If the interface mask between neighbors is inconsistent, the neighbor relationship cannot be established.

[r2]display ospf peer 查看邻居关系

[r2]display ospf peer brief 摘要表格

After the neighbor relationship is established, the neighbors decide whether to establish the neighbor relationship based on the conditions; the neighbor relationship will use the DBD package to communicate;

The priority is 10; the reference bandwidth of cost is 100M; COST=reference bandwidth/interface bandwidth

Ospf chooses the path with the smallest sum of cost as the shortest path; if the interface bandwidth is greater than the reference bandwidth, and the cost value is 1, it may lead to poor routing. It is recommended to modify the reference bandwidth. When modifying, the entire network equipment must be modified to be consistent;

[r1]ospf 1

[r1-ospf-1]bandwidth-reference ?

 INTEGER<1-2147483648> The reference bandwidth (Mbits/s)

[r1-ospf-1]bandwidth-reference 1000

7. OSPF Irregular Area

1. The non-backbone area away from the backbone

2. Discontinuous backbone area

Note: If an ABR device is not connected to the backbone area, it will be defined as an illegal ABR, and inter-area information sharing is not allowed;

solution:

1. Tunnel establishes a tunnel between the illegal ABR and the legal ABR, and then announces the tunnel link in the OSPF protocol;

In the OSPF protocol, if multiple routes to the same destination are received, the route passed from the backbone area is first preferred;

If all routers are based on the backbone area, or are based on non-backbone area transmission, compare the cost values;

Disadvantages:

  1. Poor routing

  2. Periodic information occupies resources in the intermediate area

2. OSPF virtual link

The legal ABR authorizes the illegal ABR so that the illegal ABR can share routing information between areas;

Advantages: As there is no new link, there is no routing problem; normal routing

Disadvantages:

In order to avoid the impact of periodic information on the intermediate area, cisco closed the periodic behavior on the virtual link-loss of reliability

Huawei chooses to maintain periodic behavior—continue to occupy resources in the middle area

[r2]ospf 1 

[r2-ospf-1]area 1  两台ABR共同存在的区域

[r2-ospf-1-area-0.0.0.1]vlink-peer 4.4.4.4 对端ABR设备的RID;

[r2-ospf-1]display ospf vlink

3. Multi-process two-way re-release (recommended)

One device runs all routing protocol processes, and different processes have independent databases, which are not shared with each other;

Only load the calculated routes into the same routing table;

Announce the irregular part of the area to other ospf processes, and then use the re-release mechanism for route sharing;

Avoid cycle information and routing problems;

[r2]ospf 1 

[r2-ospf-1]import-route ospf 2 

[r2-ospf-1]q

[r2]ospf 2 

[r2-ospf-2]import-route ospf 1

Guess you like

Origin blog.csdn.net/qq_43710889/article/details/108932664