OSPF protocol & RIP protocol + OSPF experiment (eNSP)

This blog mainly explains single-region ospf, and multi-region ones are only for understanding.

Table of contents

1. Overview of OSPF routing protocol

1. Interior Gateway Protocol and Exterior Gateway Protocol

2. OSPF application environment

1. Consider the use of OSPF from the following aspects

2. Features of OSPF

3. Important basic concepts of OSPF

3.1. Distinguish neighbor and adjacency relationships and seven neighbor states

3.2, Election of DR and BDR

3.3, OSPF message format

3. OSPF workflow

3.1. Working process of OSPF protocol

4. OSPF experiment

4.1, Experimental requirements:

4.2, Part 1

4.3, Part 2 

Supplement: Why is the master-slave relationship only valid in DR and BDR?

Edit

at last


1. Overview of OSPF routing protocol

1. Interior Gateway Protocol and Exterior Gateway Protocol

  • Autonomous System(AS)
  • Interior Gateway Protocol (IGP): rip (old-fashioned, basically not used now), ospf, is-is, etc.
  • External Gateway Protocol (EGP): bgp, etc.

AS (autonomous system) : Network system = network architecture, a network system built by a unified manager and the same IGP protocol strategy is relatively simple.
Public AS: Generally, if the unit's network is relatively large or will develop into a larger network in the future, and has multiple exits, it is recommended to establish an autonomous system, which requires an AS number to identify the autonomous system. Public AS The number is not repeatable.
Private AS: No application is required, it is private.

Interior gateway protocol : A protocol that operates within an AS, such as OSPF, which we will talk about next.

External Gateway Protocol : A protocol that acts between two ASs. As shown below:

2. OSPF application environment

1. Consider the use of OSPF from the following aspects

  1. Network size
  2. Network topology
  3. Other special requirements
  4. Router’s own requirements

2. Features of OSPF

  1. Adaptable to large-scale networks
  2. Route changes converge quickly
  3. No routing loop
  4. Support variable length subnet mask VLSM
  5. Support regional division
  6. Supports sending protocol packets with multicast address

3. Important basic concepts of OSPF

1. OSPF area: In order to adapt to large networks, OSPF divides multiple areas within the AS.
Each OSPF router only maintains complete link status information in the area.

2. Area ID: Area ID can be expressed as a decimal number
or as an IP such as: 1.1.1.1, 0.0.0.0
3. Backbone area Area 0 (Area 0 is indispensable, other areas can be omitted) ):
Responsible for inter-area routing information dissemination
4. Non-backbone area: (for understanding only)
Non-backbone areas must communicate with each other through the backbone area
– standard area
– stub area
– total stub
– non-pure stub area nssa

5. OSPF process_ID : The process number of this device identifies the OSPF process. The process number is only meaningful locally and has no meaning between routers. For example: one of the R1 router and the R2 router uses process_ID 10, and the other uses It is process_ID 20, but as long as they establish an adjacency relationship, they will still exchange routing information to complete their LASDB, but their LSDB is different between different processes on the same device.

6. OSPF router_ID : Router ID. The LSA information generated by the device's ID card in the future will be associated with the Router-id. Configuration format = IP format - dotted decimal // has nothing to do with the IP address of this device.

Router_ID has two generation methods = artificial configuration is better than automatic generation //Choose the artificially specified method when configuring the protocol.

  1. Select the highest numerical IP address on the router's loopback interface
  2. If there is no loopback interface, the first Up interface is selected, and the address of this interface becomes Router-id.
    If they are both up at the same time, the one with the largest IP address is preferred to form the global RID.
  3. You can also use the router-id command to specify the Router ID (manually specified)

7. LSA : link-state-advertise: Link state advertisement, in layman’s terms, is local detailed routing information.

8. DBD : Simplified routing information, because if you send complete routing information, the link burden will be greater, so DBD is only used to tell the other party what network segments I have and see if the other party needs it.

9. LSDB : database: link state database // where LSA is stored // routing table where routes are stored.

10. Other types of packages:

Link status request packet (LSR): sent after the router receives the DBD containing new information, used to request more detailed information

Link State Update Packet (LsU): Sends Link State Advertisement (LSA) after receiving LSR. One LSU packet may contain several LSAs.

Link State Acknowledgment Packet (LSAck): Confirms that DBD/LSU has been received. Each LSA needs to be acknowledged separately.

3.1. Distinguish neighbor and adjacency relationships and seven neighbor states

1. The first stage of OSPF startup is the process of establishing neighbors using Hello packets. Note that only hello packets are used to establish these three states.

In fact, this picture is wrong (but I can't find any other pictures), so where is it wrong?

First of all, from a unilateral perspective, after R1 receives the first hello packet from R2, it will put the other party R2 from down to init state, and then R2 will also put me in init state. ,

After that, R1 puts R2 in the neighbor table and sends the second hello packet. R2 sees that the active neighbor in the hello packet sent by R1 is itself, so it puts R1 into the 2-way state. Similarly, R1 does the same for R2. .

2. The second stage of OSPF startup is to establish a complete adjacency relationship. 

Replenish: 

1. These seven statuses are used by this router to identify the status of the other router , not my own status.

2. When establishing a complete adjacency relationship, it involves the election of a master-slave relationship. However, in fact, the master-slave relationship is only to solve the problem of who sends the DBD packet first . We will know later that the master-slave relationship is only in the DR. Valid between and BDR.

3. The biggest difference between Init and 2-way:
init: received the hello message from the other party, but did not see its own RID on the active-router.
2-way: received the hello message from the other party, but saw it on the active-router. To his own RID, the following is the 2-way message. We can see that the second hello packet he sent to the other party placed the other party in the neighbor table.

3.2, Election of DR and BDR

Let's look at it with questions.

3.2.1. First of all, why should we elect DR and BDR? What problems can they solve?

First, assuming that there are the following four routers in the same broadcast domain, and they all run OSPF, how do they get each other's routing information? According to experience, if you want to get the routing information of the other party, you must establish a complete adjacency relationship. Then the following four routers must establish adjacency relationships between each other. To establish an adjacency relationship, five groups of messages must be sent, so the following four routers must The router needs to establish a total of 6 adjacencies and send 30 packets. If there are more and more routers in the same broadcast domain, more and more adjacency relationships will be established, and more messages to establish adjacency relationships will be sent, and the load on the link will be greater. According to the formula: n(n -1)/2, if there are five routers, 10 adjacencies must be established. Therefore, in a broadcast domain, a DR and a BDR need to be elected to synchronize the routing information of all routers in the same broadcast domain. In other words, only the DR and BDR need to establish adjacency relationships with all routers in the same broadcast domain. DR other (that is, non-DR and BDR routers) also obtains routing information from the DR. In this way, DR other only needs to send hello packets to maintain 2-way. Only 5 types of packets need to be sent between DR other and DR and BDR, thus reducing link waste.

3.2.2. How are DR and BDR elected?

Automatic election of DR and BDR : The router with the largest Router lID on the network segment will be elected as the DR, and the second largest router will be elected as the BDR.

Manually elect DR and BDR:

  • The priority range of the interface is 0~255. The larger the value, the higher the priority. The default is 1.
  • If the priorities are the same, you need to compare the Router ID
  • If the router's priority is set to 0, it will not participate in DR and DBR elections.

Election time: wait=40s A DR/BDR will be elected within 40s. The election of DR/BDR roles will begin as soon as the interface runs OSPF.

Elect DR and BDR after 2-WAY and before exstart.
DR = Designated Router = "Big Brother"
BDR = Backup Designated Router = "Second Brother" In order to ensure the stability of the DR and ensure that the network will not be interrupted for too long after a DR failure, the BDR will be elected in advance.
DRother= non-designated/backup designated router

Election characteristics: When there is a DR in the network but no BDR, a new BDR will be elected from the network, and so on. DR and BDR are not allowed to be preempted, that is, when the device has elected DR and BDR, even if a new device joins at this time,
in order to ensure stability, the role will not change again.
DR/BDR will establish FULL adjacency relationships with everyone.
Only 2-WAY neighbor relationships will be established between DRothers.

Difference and function:
DR and BDR election occurs in the 2-WAY state . Its function is to ensure that the traffic of useless flooding OSPF messages in a broadcast domain is reduced.
The master-slave relationship election occurs in the exstart state. Its function is to ensure the reliability and orderliness of database synchronization.

 The specific election process is as follows ( be the younger brother first and then the older brother ) :

3.3, OSPF message format

Universal header:

 hello package:

3. OSPF workflow

3.1. Working process of OSPF protocol

①Each router learns the activated directly connected network,

②Each router communicates with the directly connected router, sends Hello messages, and establishes neighbor relationships.

③Each router builds an LSA (link status advertisement) containing the directly connected link status, and the link status advertisement (LSA) records

All related routers, including the identity of neighboring routers, link type, bandwidth, etc.

④Each router floods link state advertisements (LSAs) to all neighboring routers, and locally stores the LSAs sent by neighboring routers, and then floods the received LSAs to all its neighbors until it reaches the same destination. All routers in the area have received all LSAs, and each router keeps a copy of all received LSAs in a local database. This database is called the "Link Status Database" (LSDB).

⑤Each router executes the "Shortest Path First (SPF)" algorithm based on the local "Link State Database (LSDB)", and uses this router as the root to generate an SPF tree. Based on this SPF tree, it calculates the path to each network. The shortest path is the final routing table.

4. OSPF experiment

The overall network topology is as follows:

4.1, Experimental requirements:

1. It is required that AR2 should be used as the DR in our area, and AR4 should be used as the BDR in our area.

2. If the router on the left wants to access R7, the packets it sends go to the lower part, but the packets sent back from R7 go to the upper part.

4.2, Part 1

We first use our ospf routing protocol for our 192.168.1.0/24 network segment

AR2 configuration is as follows:

1. First set the name R2 for AR2 (personal habit)

2. Set the IP address for the interface

3. Set the ospf process to 100

4. Specify the router-id. In real life, it is generally necessary to specify it, but if it is not specified, there will be no big problem in our experiment.

5. Set the area to which the router belongs

6. Announce the network segment to the outside world

Then let's take a look at our LSDB, and we can see that there is nothing in R2's LSDB now, because we only have R2 in area 0 now.

However, the DR in this area has now been determined, which is R2. The specific reason will not be explained.

Now let’s grab a random packet in the network segment and take a look.

It can be seen that R2 has been sending Holle messages to the multicast address. In the hello message, we can see that R2 has become the DR. The BDR is 0.0.0.0, which means there is no BDR yet.

Then we turned on R4 and let him become the BDR.

Configure R4 as follows:

After capturing the packet, we see that both R2 and R4 are sending Hello messages to the multicast address 224.0.0.5, and we can observe that the BDR is already R4. So far in the experiment, area 0 already has DR and BDR. We now need to configure other routers R1 and R3 so that they can also join area 0.

Here I only show the configuration of R3, the configuration of R1 is almost the same as that of R3!

R3 configuration is as follows:

Finally, we can view the neighbor status table in R3

4.3, Part 2 

Now that the purpose of our experiment on the left has been achieved, let's start the experiment on the right.

The configurations of R4, R5, R6, and R7 are as follows:

Note: Both R4 and R7 have a loopback port for testing, which can be seen in the picture above.

Then, we are going to declare the network segment on R4567. Only the R7 is shown here.

Note: The loopback port on the router also needs to be announced. Other routers can do the same thing. Note that all routers above have the same domain 0 added.

After that, we saw from R4 that R4 had learned the route from other neighbors and even gave you the next hop.

From the routing table above, we can see that there are two next hops to 7.7.7.7, so how do we control only the following one? We need to modify the cost value of the interface.

Then we need to understand how the cost value is calculated. Cost=100/interface bandwidth. Since we are using the G port here, the bandwidth is 1000, so the cost is 1 (less than 1 is treated as 1). And to calculate the cost value of a link, you need to look at the convergence direction of the source route of the target router . For R7, the convergence direction of one of the links for R4 is as follows, so the interfaces are also calculated based on the R5-g0/0/1 and R4-g0/0/1 interfaces. So here we can modify the cost value of the R5-g0/0/1 interface to erase the path from R4 to R7.

And why do we need to modify the cost value? This is related to the routing table addition principle. The table addition principle is as follows:

Here's how to do it:

R5:

Then we checked the route to R7 on R4, and we found that there was only the one we wanted.

Then we modify R6, because there are two routes from R7 to R4, and we only want the above route, so we modify R6-g0/0/0. The steps are the same as above, so I won’t demonstrate them.

Finally, let's verify it. Using the R4 test, we can see that the package does go from below. As shown below:

When using R1, see if you can ping 7.7.7.7. You can see that the ping is successful, so the test is successful.

Supplement: Why is the master-slave relationship only valid in DR and BDR?

Let’s look at the 192.168.1.0/24 network segment. From the above experiment, we can know that AR2 is DR and AR4 is BDR.

Looking at AR2, you can see that it is the owner of AR4.

Looking at AR4, we can see that AR4 is a subordinate of AR2.

Let's look at DR other R1 again. We can see that no matter who he is playing against, his status is Master.

Therefore, the master-slave relationship is only valid in DR and BDR.

at last

That’s it for this blog’s introduction and experiments on OSPF. If this blog is helpful to you, please like, collect and support it. Thank you! promise me! Don’t you want a prostitute account for free? Hahaha! See you in the next blog.

Guess you like

Origin blog.csdn.net/weixin_64972949/article/details/132004299