An overview of the

OSPF establishes an LSDB by sharing link status information between two routers. The LSDB is used to generate a routing table

The topology

Neighbors to establish

A neighbor relationship is established between two routers to share link status

TIME(second) SRC(Source IP address) DEST (multicast) Active Neighbor DR BDR State of the SRC DEST Info
0 10.0.12.1 224.0.0.5 0.0.0.0 0.0.0.0 0.0.0.0 Down Init Hello Packet
0 10.0.12.2 224.0.0.5 0.0.0.0 0.0.0.0 0.0.0.0 Init Init Hello Packet
After a round of packet exchange, Neighbor is identified
10 10.0.12.2 224.0.0.5 10.0.12.1 0.0.0.0 0.0.0.0 Init 2Way Hello Packet
10 10.0.12.1 224.0.0.5 10.0.12.2 0.0.0.0 0.0.0.0 2Way 2Way Hello Packet
20 10.0.12.1 224.0.0.5 10.0.12.2 0.0.0.0 0.0.0.0 2Way 2Way Hello Packet
20 10.0.12.2 224.0.0.5 10.0.12.1 0.0.0.0 0.0.0.0 2Way 2Way Hello Packet
30 10.0.12.1 224.0.0.5 10.0.12.2 0.0.0.0 0.0.0.0 2Way 2Way Hello Packet
30 10.0.12.2 224.0.0.5 10.0.12.1 0.0.0.0 0.0.0.0 2Way 2Way Hello Packet
40 10.0.12.1 224.0.0.5 10.0.12.2 0.0.0.0 0.0.0.0 2Way 2Way Hello Packet
40 10.0.12.2 224.0.0.5 10.0.12.1 0.0.0.0 0.0.0.0 2Way 2Way Hello Packet
Within 40 seconds, an interface on the router calculates the DR and BDR packets based on all the Hello packets in the received network segment
40 10.0.12.1 224.0.0.5 10.0.12.2 10.0.12.2 0.0.0.0 2Way 2Way Hello Packet
40 10.0.12.2 224.0.0.5 10.0.12.1 10.0.12.2 10.0.12.1 2Way 2Way Hello Packet
The DR and DBR have been calculated. The LSA packet exchange starts
Although it is calculated by DBR, each router may not be the same, but it does not affect the following LSA packet exchange (with DR interface is ok).
—- The process of exchanging LSA packets is omitted. For details, see the next title
After the baptism of Hello packets, DBRS tend to be the same
50 10.0.12.1 224.0.0.5 10.0.12.2 10.0.12.2 10.0.12.1 Full Full Hello Packet
50 10.0.12.2 224.0.0.5 10.0.12.1 10.0.12.2 10.0.12.1 Full Full Hello Packet

The adjacency exchanges state information

Routers that establish neighbor relationships exchange information through packets to achieve link state synchronization

TIME(second) SRC(Source IP address) DEST (multicast) Init More Master State of the SRC DEST Sequence Info
41 10.0.12.1 10.0.12.2 yes yes yes ExStart ExStart x DB Description
42 10.0.12.2 10.0.12.1 yes yes yes Exchange ExStart x DB Description
After the above operations, determine the primary and secondary relationship. InIt indicates the first packet, More indicates whether there are More packets, and Master indicates whether it is the primary packet
43 10.0.12.1 10.0.12.2 no no no Exchange Exchange x DB Description LSA
43 10.0.12.2 10.0.12.1 no no yes Exchange Exchange x DB Description LSA
After the preceding operations, brief Lsas are exchanged.
After receiving the brief LSA from the peer, you can send an LS Request immediately after comparing the LSA
Specific packets are shown in the following tables
50 10.0.12.1 10.0.12.2 no no no Full Full x+1 DB Description ACK
The Slave sends an ACK to the Master. Assume that LSDB synchronization is complete, so both routers are in Full state
Time SRC DEST Content Info
44 10.0.12.2 10.0.12.1 【 Advert Router=10.0.1.1】 【 Advert Router=10.0.1.1】 LS Request
44 10.0.12.1 10.0.12.2 【 Advert Router=10.0.1.2】 【 Advert Router=10.0.1.2】 LS Request
44 10.0.12.2 224.0.0.5 [router-LSA (1)] = {Links = [{Type: Sub, ID: 10.0.12.0, Data: 255.255.255.0, Metric: 1}]} LS Update
44 10.0.12.1 224.0.0.5 [router-LSA (1)] = {Links = [{Type: Sub, ID: 10.0.12.0, Data: 255.255.255.0, Metric: 1}]} LS Update
44s Both ends send a Request and actively update the CURRENT LSA. The router status changes from Exchange to Loading
The current LSA describes its link status. Each router has only one link or interface, whose type is Sub
Sub network: ID indicates the network number, Data indicates the subnet mask, and Metric indicates the Metric value
45 10.0.12.1 10.0.12.2 [Router-LSA(1)] = {Links = [{Type: Transit, ID: 10.0.12.2, Data: 10.0.12.1, Metric: 1}]} LS Update
45 10.0.12.2 10.0.12.1 [Router-LSA(1)] = {Links = [{Type: Transit, ID: 10.0.12.2, Data: 10.0.12.2, Metric: 1}]} LS Update
The 45S Update mainly changes the Sub network in Links to Transit type
Because of the 44s multicast Update, each router updates its Sub network to the Transit network
Transit network: ID indicates the ADDRESS of the DR interface, Data indicates the address of the interface that sends packets, and Metric indicates the Metric value
46 10.0.12.2 224.0.0.5 [Network-LSA(2)] = {Link State ID: 10.0.12.2, Advert Router: 10.0.1.2, NetMask: 255.255.255.0, Attached Router: [10.0.1.2, 10.0.1.1]} LS Update
The 46S is sent by the router on the DR interface. The router calculates a Network based on the Transit interface and proactively broadcasts the 46S. Only the router on the DR interface has the right to send network-LSA packets
The following are some LS Ack packets. The router status changes from Loading to Full

Generate the SPT shortest path tree

After multiple cycles of switching, a router always holds link state information about the entire network. The LSDB of R01 is as follows:

Type LinkState ID AdvRouter Age Len Seq Metric Self
Router 10.0.1.1 10.0.1.1 1514 36 001 1 yes
Router 10.0.1.2 10.0.1.2 1152 36 002 1 no
Network 10.0.12.2 10.0.1.2 1152 32 003 0 no

The LSDB of router R02 is as follows:

Type LinkState ID AdvRouter Age Len Seq Metric Self
Router 10.0.1.2 10.0.1.2 1514 36 001 1 yes
Network 10.0.12.2 10.0.1.2 1152 32 003 0 yes
Router 10.0.1.2 10.0.1.2 1152 36 002 1 no

Generate routing

The LSDB contents of each router can be built into a tree. A Router is a node and a Network is an edge

LSDB content can also be understood as a matrix. Router can be understood as each element, and Network can be understood as a binary unordered group, which can form an unordered graph, that is, a matrix

The LSDB generates a shortest spanning tree with itself as the root, and the path to each node is a route

In this example, no OSPF route is generated because all links are directly connected. The default route has a higher priority than OSPF