Analysis of OSPF database and Hello packet

 Analysis of OSPF Database

As shown in the figure, OSPF is enabled in the network, AR2 and AR5 are ABRs, and the corresponding interfaces of all routers are advertised to the corresponding areas.

R1 announces the IP address of Loopback 0 to the OSPF process

Import static routes on R6, and configure g0/0/0 of AR6 as a silent interface:

        Silent interface: When an interface of an OSPF router is not connected to an OSPF neighbor, we can use the configuration of the silent interface. For example: the interface of the OSPF router is connected to the switch, and the switch is connected to the PC. After the silent interface is enabled, the interface will no longer send and receive OSPF protocol packets.

R6:
[AR6]ip route-static 10.10.7.7 32 192.168.67.7
[AR6-ospf-1]dis this
[V200R003C00]
#
ospf 1 router-id 6.6.6.6 
 import-route static
 silent-interface GigabitEthernet0/0/0
 area 0.0.0.56 
  network 192.168.56.0 0.0.0.255 
  network 192.168.67.0 0.0.0.255 

R7:
[AR7]ip route-static 192.168.0.0 16 192.168.67.6
[AR7]int g0/0/01
[AR7-GigabitEthernet0/0/1]ip add 192.168.67.7 24
[AR7-LoopBack0]ip add 10.10.7.7 32

Check the OSPF database on R1

<AR1>dis ospf lsdb 
	 OSPF Process 1 with Router ID 1.1.1.1
		 Link State Database 
		         Area: 0.0.0.12
 Type      LinkState ID    AdvRouter          Age  Len   Sequence   Metric
 Router    2.2.2.2         2.2.2.2            340  36    80000006       1
 Router    1.1.1.1         1.1.1.1           1124  48    80000007       1
 Network   192.168.12.1    1.1.1.1            333  32    80000004       0
 Sum-Net   192.168.67.0    2.2.2.2            210  28    80000001       5
 Sum-Net   192.168.45.0    2.2.2.2           1759  28    80000002       3
 Sum-Net   192.168.23.0    2.2.2.2            309  28    80000003       1
 Sum-Net   192.168.56.0    2.2.2.2           1620  28    80000002       4
 Sum-Net   192.168.34.0    2.2.2.2             51  28    80000003       2
 Sum-Asbr  6.6.6.6         2.2.2.2             61  28    80000001       4

		 AS External Database
 Type      LinkState ID    AdvRouter          Age  Len   Sequence   Metric
 External  10.10.7.7       6.6.6.6             65  36    80000001       1

[LSA] In an OSPF network, routers do not directly transmit routes, but transmit LSAs (Link State Advertisement Link State Advertisement). LSAs are included in OSPF protocol packets, and routers go to independent routes through received LSAs. The rules for calculating routes are the same.

  1. 【Type  】
    1. [Router——Type 1 LSA] In an OSPF area, if a router introduces itself, in the same OSPF process, different interfaces connect to different areas at the same time, then the router will generate a 1 in each area. LSA-like
    2. [ Network——Type 2 LSA ] In each network segment of broadcast or non-broadcast network type, a DR will be generated, and Type 2 LSA is used to represent DR
    3. [ Sum-Net——Type 3 LSA ] represents an example of OSPF inter-domain routing: In a straight line topology such as R1-R2-R3, R2 is an ABR. R2 will send the route of the R2-R3 area in the form of Type 3 LSA to R1
    4. [Sum-Asbr——Type 4 LSA] is generated by ABR and introduces LSAs of ASBRs in other areas to this area. For example: In R1-R2-R3 straight line topology, R2 is ABR and R3 is ASBR. At this time, R2 will generate a Type 4 LSA, sent to R1, introduces ASBR-R3 to R1
    5. [ External——Type 5 LSA ] indicates the route outside the OSPF domain (also called external route), that is, the route imported successfully by import-route
    6. [NSSA——Type 7 LSA]Function: In the NSSA area, transmit external routes. Propagation range: Passed in the NSSA area. In this example, after setting area 56 as the NSSA area, you will see this type of LSA on R5R6

            In the NSSA area, a Type 7 default route will be automatically generated to guide the NSSA area to access external routes.
            In the Totally NSSA, Type 3 and Type 7 default routes will be automatically generated. The router uses Type 3 default routes to guide data forwarding by default.

  2. 【 LinkState ID 】 The name of the LSA

  3. [AdvRouter] Advertisement Router (Advertisement Router) is, who sent this LSA

  • Does the default route (the default route) must be a static route?

    Not necessarily ip route-static 0.0.0.0 0 xxxx It is indeed possible to configure a static default route. In a dynamic routing protocol such as OSPF, a default route can also be generated. At this time, the default route is also dynamic. For example: in the Stub area , the ABR will flood a type 3 LSA representing the default route to the routers in the Stub area. At this time, the OSPF routers in the Stub area will form the OSPF default route.

Special area:

  • Stub area

    • Type 5 LSAs are not required in the area Because type 5 LSAs are not required, type 4 LSAs are not required. At this time, the ABR will generate a type 3 LSA representing the default route to the Stub area

  • Totally Stub area

    • Type 5 LSAs are not required in the area, so Type 4 LSAs are not required. At the same time, Type 3 LSAs are not required. At this time, the ABR will generate a Type 3 LSA representing the default route to the stub area.

      Extension: Advantages of the Stub area: Save system resources, save link resources and improve network stability (because it is not affected by frequent Up/Down of external routes)

  • NSSA area Type 5 LSA is not required in the area, so Type 4 LSA is not required. However, in this area, external routes (import-route) can be imported. External routes imported in this area are represented by Type 7 (NSSA) LSAs

    At this time, the ABR will issue a type 7 LSA (0.0.0.0) representing the default route (default route) to the NSSA area

  • Totally NSSA area does not need type 5 LSA in the area, so type 4 LSA is not required. However, in this area, external routes can be imported (import-route). At the same time, type 3 LSA is not required in the area (inter-domain routing is represented by type 3 LSA)

    Note: At this point, the ABR will generate Type 3 LSA and Type 7 LSA representing the default route at the same time. Other routers in the area will calculate the default route (default route) according to Type 3 LSA. LSA priority: 1>3>5> 7


OSPF Hello Packet Analysis

  • [TTL] OSPF Hello message, the TTL value of the IP header is 1, OSPF cannot establish neighbors across hops Example: R1-R2-R3, such a straight line topology R1 wants to send a Hello message to R3, and the message passes through R2 At this time, the TTL will be reduced by 1. At this time, the packet is discarded by R2, so R1 cannot cross R2 and establish a neighbor with R3
  • [ Protocol ] This field in the IP message is called the protocol number, which refers to what protocol is followed by the IP header. Different protocols use different protocol numbers to indicate that OSPF is in the IP message, and the protocol number is always 89.

  • [ OSPF Version ] refers to the version of the OSPF protocol running on this router Version 2: IPv4 version of OSPF Version 3: IPv6 version of OSPF
  • [Message Type] The message type refers to the OSPF message following the OSPF header, which type of message type 1 is the Hello message
  • 【Packet Length】The length of the packet
  • 【 Source OSPF Router 】 The OSPF router that generates this message is a so-called OSPF router that runs the OSPF protocol.
  • [Area ID] The OSPF area where the interface of the router that sends this OSPF packet is located is the area where the interface is located, because when the router sends the packet, the IP header is encapsulated in front of the OSPF packet and above the IP header, The source IP address is marked, and the source IP address is actually the IP address of the interface that sends this OSPF packet.
  • 【Packet Checksum】 The checksum is used to verify whether the packet is correct
  • [ Auth Type and Auth Data ] Fields about OSPF authentication Auth Type: is the authentication type Auth Data: is the authentication password (with plaintext or ciphertext)

  •  [Network Mask] refers to the mask of the IP address of the interface that sends the Hello message
  • 【Hello Interval】Hello interval refers to the interval for sending Hello packets on this interface. By default, the router sends a Hello packet every 10 seconds.
  • 【 Option 】 The special flag is related to the area
  • 【 Router Priority 】 The priority of DR
  • [Router Dead Interval] The dead time refers to how long I have not received the Hello message from the other party. I think the other party has hung up. By default, the dead time is 40 seconds Note: The dead time is 4 times the Hello time times
  • 【 DR 】
    • All OSPF routers have established a FULL adjacency relationship with DR, that is: all OSPF routers will synchronize the database with DR, and DR will send the synchronized database to everyone (the sending method is: the destination address is 224.0.0.5)
    • The role of DR to speed up database synchronization

    • DR election principle
      [1] Compare the Router Priority in the Hello message, the default is 1, the value range is 0-255, the larger the value, the better [2] If the Router Priority is the same, compare the router-id, the larger the better

    • Setting the priority of DR to 0 means that my OSPF router and this interface will never participate in the DR election of OSPF, that is, the DR priority is 0, which is not the lowest priority, but does not participate in the election

    • The characteristics of DR are stable! Can't preempt!
      In a network segment, once the DR is elected, even if other routers with higher DR priority appear in the network segment, the DR identity will not be preempted. If the DR identity must be preempted, We need to restart the OSPF process of all OSPF routers in the network segment

  • 【BDR】DB backup
    • DR hangs up, BDR will immediately take over the work of DR
    • At the beginning of the DR election process
      , a BDR is selected from all the routers with a non-zero DR priority in the network segment. At this time, there is no DR, so the BDR immediately becomes a DR. Then, because there is no BDR, the election starts again. out a BDR
    • In the process of BDR becoming DR
      , the priority of DR is hidden in the Hlelo message of OSPF, and the death time of OSPF router is 40 seconds by default. I thought the DR was down
    • Can a silent interface become the DR? Yes, because during the DR election, if I can’t receive the Hello message from the other party, I will think that the other party dare not compare with me, so my interface is DR
    • Can the interface connecting the OSPF router to the PC become the DR?
      Yes, for the same reason
  • [Avtice Neighbor] The activated neighbor is actually the router-id of the neighbor I recognize

 Option bits in the OSPF area

  • E and NP We can see the Options (special flag bit) in the OSPF Hello message. Among them, E: indicates that this router can import external routes (import-route) NP: indicates that this router is sending the interface of this Hello message The area where it is located is the NSSA area
  • E=1, NP=0 means that this area is a normal area
  • E=0, NP=0 means that this area is a Stub area (Totally Stub also indicates this)
  • E=0, NP=1 means that this area is an NSSA area (Totally NSSA also indicates this)

The difference between Network and Import-router in OSPF

  • 【 network 】 Announcement: Announce the directly connected network segment where the OSPF router interface is located
  • 【import-route】Import: The import is the route outside the OSPF network
  • [Difference] [Purpose] network can accurately declare a route (that is, a directly connected network segment) import-route can import a type of route. For example: there are ten static routes on a router. At this time, we are on this router import-route static in the OSPF process, you can import these ten static routes into the OSPF process at one time
  • [Priority] The OSPF route of the network, the priority is 10 by default. The external route of import-route, the priority is 150 by default

Summary of Common OSPF Commands

  • View interface configuration command
    display current-configuration interface GigabitEthernet 0/0/1
  • View the configured OSPF command
    display current-configuration configuration ospf
  • Display OSPF interface information
    display ospf interface
  • Display OSPF neighbor relationship
    display ospf peer brief
  • Check the OSPF database
    display ospf lsdb
  • View the routes calculated by OSPF in the IP routing table:
    display ip routing-table protocol ospf
  • Command to change area type
    ospf x area x stub/nssa/stub no-summary/nssa no-summary
  • Change the hello/dead time of an OSPF interface
    interface x/x/x ospf timer hello/dead x
  • Change the network type of an OSPF interface
    interface x/x/x ospf network-type broadcast/nbma/p2p/p2mp

Guess you like

Origin blog.csdn.net/weixin_45059947/article/details/127933927