Comparison between dynamic routing protocol RIP and OSPF:
Three criteria for dynamic routing (IGP): good routing, fast convergence and less link resources
Dynamic routing protocol | Route selection | convergence | Occupied resources |
RIP | The number of hops is used as the overhead value in routing | The convergence rate is based on the timer | Less occupation of a single packet |
OSPF | The routing is based on bandwidth | Fast convergence | Large occupation of single packet |
Route comparison:
RIP [distance vector protocol]:
- RIP routing takes the number of hops as the overhead value (routing is not intelligent enough and out of the ring)
- The convergence speed is based on the timer (relatively slow, 30 + 180 + 120)
- A single packet occupies less, but there is a 30s cycle to update the keep alive packet (large occupation)
OSPF [link state protocol]:
- The routing is based on the bandwidth (SPF algorithm - tree structure will not cause loop problems)
- Fast convergence (link information calculated by algorithm)
- A single packet occupies a large amount, but the hello packet updated in 10s cycle occupies a small amount
Version comparison:
- RIP has three versions: RIPV1,RIPV2 for IPV4 and RIPNG for IPV6
- There are three versions of OSPF: ospfv1 (obsolete), OSPFV2 for IPv4 and OSPFv3 for IPV6
Differences between RIPV2 and OSPFV2:
Similarities:
- RIPV2 and OSPFV2 are classless routing protocols {carry subnet mask when transmitting routing information} and both support subnet division and subnet aggregation
- OSPFV2 uses 224.0.0.5 and 224.0.0.6 multicast packet addresses, while RIPV2 uses 224.0.0.9 multicast packet addresses
- Both OSPFV2 and RIPV2 support equal overhead load balancing
difference:
The difference between OSPF protocol and RIP protocol lies in the scope of application. RIP protocol is only applicable to small and medium-sized network environment (15 hop limit), while OSPF protocol can be applicable to large and medium-sized network environment (OSPF needs structured deployment, i.e. regional division, in order to adapt to large and medium-sized network environment)
OSPF: open shortest path first protocol
OSPF area division:
When the network scale is small, we can also divide the ospf network into one area, and the main ospf network: single area network. If an ospf network contains multiple OSPF areas: multi area ospf network
The main purpose of region division is to transfer topology information within OSPF regions and routing information between regions
OSPF is also known as link state routing protocol, and the distance vector feature of link state routing protocol is inter region transfer routing
Area boundary router ABR:
Requirements: it is at the boundary of multiple OSPF areas at the same time, and one interface of ABR corresponds to one area, and at least one interface belongs to the backbone area (central area). Multiple ABRs can exist between areas, and one ABR can correspond to multiple areas
Requirements for area division:
- ABR must exist between regions
- Regions must be divided according to the star topology, that is, all regions need to be connected to the central region (the center is called the backbone region)
In order to facilitate the differentiation and management of each area, we design a number for each area: Area ID. The area ID is represented by 32-bit binary, dotted decimal or decimal directly, but the area number of the backbone area must be 0
OSPF packet (text description):
hello package:
- Cycle discovery, establish and keep the neighbor relationship alive (the cycle is 10s/30s)
- Dead time: dead time(4 times hello time -- 40s/120s)
- The hello package will carry RID
OSPF transmits topology information and needs to clearly express the location relationship of all routers. Therefore, a parameter is required to distinguish all routers: RID is introduced to complete it
RID requirements:
- Uniqueness (unique within OSPF network area)
- Uniform format (composed of 32-bit binary, using IP address format, x.x.x format)
How to obtain RID:
- Manual configuration (the above two requirements shall be met)
- Automatic acquisition (if it is automatic acquisition, the device will select the IP segment of its loopback interface and take the largest IP as its RID)
DBD package:
The database description message carries the database directory information (while LSDB is the database that really stores LSA information)
LSR package (request):
The link state request message requests unknown LSA information (LSA information not available locally) based on the directory information of the received DBD packet
LSU package (update):
Link state update packet, a packet that really carries LSA information (a packet with link information)
LACK package:
Link status confirmation message (confirmation packet)
OSPF has a keep alive and confirm mechanism because of the existence of hello package and LACK package, so frequent periodic updates are not required. However, OSPF has a periodic update every 30Min (again ensure that the update is reliable)
OSPF state machine:
① Down state: after OSPF is started, send the hello package, which contains RID. After sending the hello package, enter the next state
② Init state: enter the next state when the opposite end hello package is received and contains RID
③ Two way state: indicates that the neighbor relationship is established, and condition matching will be performed at this time
# condition matching: if the matching is successful, it will enter the next state, otherwise it can only stay in the neighbor relationship. The neighbor relationship can only be live through the hello package
④ Exstart state: use the DBD package without data to elect the master-slave relationship
# master-slave relationship election: the master-slave relationship election is conducted by comparing the RID size in the DBD package without data. The one with a large RID is the main one, and the next state is given priority. The reason for using DBD packets without data is to distinguish them from neighbor states
#RID comparison is only a simple comparison of value size, independent of subnet mask (2.0.0.0 is larger than 1.255.255)
# note that at this time, the RID information is only compared with each other, and the ACK package is not used for confirmation - invisible confirmation
⑤ Exchange state: use the DBD package carrying data to share database directory information
# and the reason for electing the master-slave relationship: staggering the peak to send link information and reducing bandwidth congestion
⑥ Loading state: load the directory information in the opposite end's DBD package and compare it with the local LSDB database directory information (then decide to send LSA/LSR/LSU package)
# check the local unknown link information LSA by referring to the local database entry, and then request to obtain the LSA information of the unknown link through the LSR packet. At this time, the opposite end replies to the LSU packet carrying the unknown link information LSA, and finally sends a lake packet locally to confirm the obtained unknown link LSA information
⑦ FULL State: indicates that the adjacency relationship is confirmed
The # collar relationship is mainly used to distinguish from the previous neighbor relationship
OSPF working process:
① after configuring and starting OSPF, local OSPF will send hello packets to all local router interfaces running OSPF protocol with a multicast address of 224.0.0.5. This Hello packet will carry the RID of the local routing OSPF and the RID of the local known neighbor. Then record the collected neighbor relationship to the neighbor table {neighbor table} of the local OSPF
② after the neighbor table is created, condition matching will be performed. If the matching fails, it will stay in the neighbor relationship (only the hello package can be used for periodic preservation) / if it succeeds, it will start to establish the neighbor relationship. {condition matching determines neighbor relationship or collar relationship}
③ after the adjacency relationship is established, both parties of OSPF establishing the collar relationship will use the DBD package without data to elect the master-slave relationship. After the election is completed and the master-slave relationship is determined, the leader will first share the database directory using the DBD package carrying LSA link directory data. And send LSR/LSU/LACK packet to request / obtain / confirm the unknown local link LSA information, and finally complete the establishment of LSDB (link state database) {database table}
④ the local OSPF routing protocol generates a directed graph of routing topology based on the local link state database. Then, the directed graph is transformed into a spanning tree through the SPF algorithm, and the best routing of the local route to the unknown network segment is calculated. Finally, the best routing information is generated and added to the OSPF routing table {OSPF routing table}
⑤ after OSPF convergence, all routes still send hello packets to each other periodically (10s/30s) to keep alive and update periodically every 30 minutes
OSFP troubleshooting ideas:
Judge through the OSPF state machine and routing relationship. At this time, the OSPF neighbor table, database table and routing table will be traversed and queried to view the OSPF connection status and troubleshoot.
#View ospf neighbors table display ospf peer #View ospf neighbor profile display ospf peer brief #View ospf database table - only route entry information is displayed display ospf lsdb #Expand an LSA message - query the RID representation through OSPF in LSBD display ospf lsdb router X.X.X.X #View ospf routing table display ip routing-table protocol ospf
OSPF causes network structure mutation:
- A new network segment is suddenly added in the network: OSPF will trigger the update and send the change information directly by sending LSU packets. At this time, you need to wait for the opposite end to send lag packets for confirmation
- Suddenly disconnect a network segment in the network: OSPF will trigger the update and send the change information directly by sending LSU packet. At this time, you need to wait for the opposite end to send Lake packet for confirmation
- Unable to communicate: after the hello package + death countdown (10s+40s/30s+120s), if it still cannot be recovered, it will actively delete the network segment information
Basic configuration of OSPF
1. Start OSPF process
[R1]ospf 1 router-id X.X.X.X #10. X.x.x process number, local only (configuring rid manually)
2. Version selection (V1 obsolete, V2 by default)
[R1]ospf #IPV4 defaults to v2
3. Create area (after version selection)
[R1] area X #Select OSPF area. If 0, it represents backbone area
4. Declaration
Purpose:
① Active interface: only the active interface can send and receive OSPF data
② Publish route: only the network segment information corresponding to the active interface can be sent
[R11-ospf-1-area-X.X.X.X] network X.X.X.X x.x.x.x #Declare the OSPF configuration information of the route, and its corresponding configuration character is unmask #Difference between wildcard and unmask: #The inverse mask consists of consecutive zeros and consecutive ones: 0 is immutable and 1 is variable #Wildcards are composed of discontinuous 0 and 1: 0 is variable and 1 is immutable #Wildcard 0.255.0.255 --- the network segment information represented is: variable Immutable Variable Immutable #Unmask 0.0.0.255 --- the network segment information represented is: immutable Immutable Immutable variable
//Configure an ospf protocol for area0: //R1 [R1]interface g0/0/0 [R1-GigabitEthernet0/0/0]ip address 1.0.0.1 30 [R1-GigabitEthernet0/0/0]int l 0 [R1-LoopBack0]ip address 192.168.1.1 24 [R1-LoopBack0]q [R1]ospf 1 router-id 1.1.1.1 [R1-ospf-1]area 0 [R1-ospf-1-area-0.0.0.0]network 192.168.1.0 0.0.0.255 [R1-ospf-1-area-0.0.0.0]network 1.0.0.1 0.0.0.0 //R2 [R2]interface g0/0/0 [R2-GigabitEthernet0/0/0]ip address 1.0.0.2 30 [R2-GigabitEthernet0/0/0]int l 0 [R2-LoopBack0]ip address 192.168.2.1 24 [R2-LoopBack0]interface g0/0/1 [R2-GigabitEthernet0/0/1]ip address 2.0.0.1 30 [R2]ospf 1 router-id 2.2.2.2 [R2-ospf-1]area 0 [R2-ospf-1-area-0.0.0.0]network 192.168.2.0 0.0.0.255 [R2-ospf-1-area-0.0.0.0]network 1.0.0.2 0.0.0.0 [R2-ospf-1-area-0.0.0.0]network 2.0.0.1 0.0.0.0 //R3 [R3]interface g0/0/0 [R3-GigabitEthernet0/0/0]ip address 2.0.0.2 30 [R3-GigabitEthernet0/0/0]int l 0 [R3-LoopBack0]ip address 192.168.3.1 24 [R3-LoopBack0]q [R3]ospf 1 router-id 3.3.3.3 [R3-ospf-1]area 0 [R3-ospf-1-area-0.0.0.0]network 192.168.3.0 0.0.0.255 [R3-ospf-1-area-0.0.0.0]network 2.0.0.2 0.0.0.0 //At this time, R1-R2-R3 has completed OSPF configuration //Take R2 as an example to view the OSPF related tables of R2: #View ospf neighbor table: display ospf peer <R2>display ospf peer OSPF Process 1 with Router ID 2.2.2.2 Neighbors Area 0.0.0.0 interface 1.0.0.2(GigabitEthernet0/0/0)'s neighbors Router ID: 1.1.1.1 Address: 1.0.0.1 State: Full Mode:Nbr is Slave Priority: 1 DR: 1.0.0.1 BDR: 1.0.0.2 MTU: 0 Dead timer due in 40 sec Retrans timer interval: 5 Neighbor is up for 00:27:27 Authentication Sequence: [ 0 ] Neighbors Area 0.0.0.0 interface 2.0.0.1(GigabitEthernet0/0/1)'s neighbors Router ID: 3.3.3.3 Address: 2.0.0.2 State: Full Mode:Nbr is Master Priority: 1 DR: 2.0.0.2 BDR: 2.0.0.1 MTU: 0 Dead timer due in 37 sec Retrans timer interval: 5 Neighbor is up for 00:26:13 Authentication Sequence: [ 0 ] #View ospf neighbor profile: display ospf peer brief <R2>display ospf peer brief OSPF Process 1 with Router ID 2.2.2.2 Peer Statistic Information ---------------------------------------------------------------------------- Area Id Interface Neighbor id State 0.0.0.0 GigabitEthernet0/0/0 1.1.1.1 Full 0.0.0.0 GigabitEthernet0/0/1 3.3.3.3 Full ---------------------------------------------------------------------------- #View ospf database table [directory]: display ospf lsdb <R2>display ospf lsdb OSPF Process 1 with Router ID 2.2.2.2 Link State Database Area: 0.0.0.0 Type LinkState ID AdvRouter Age Len Sequence Metric Router 2.2.2.2 2.2.2.2 1610 60 80000007 1 Router 1.1.1.1 1.1.1.1 1682 48 80000006 1 Router 3.3.3.3 3.3.3.3 1611 48 80000005 1 Network 2.0.0.2 3.3.3.3 1611 32 80000001 0 Network 1.0.0.1 1.1.1.1 1684 32 80000002 0 #Expand an LSA message: display ospf lsdb router X.X.X.X <R2>display ospf lsdb router 1.1.1.1 OSPF Process 1 with Router ID 2.2.2.2 Area: 0.0.0.0 Link State Database Type : Router Ls id : 1.1.1.1 Adv rtr : 1.1.1.1 Ls age : 1712 Len : 48 Options : E seq# : 80000006 chksum : 0xb70f Link count: 2 * Link ID: 1.0.0.1 Data : 1.0.0.1 Link Type: TransNet Metric : 1 * Link ID: 192.168.1.1 Data : 255.255.255.255 Link Type: StubNet Metric : 0 Priority : Medium #View ospf routing table: display IP routing table protocol ospf <R2>display ip routing-table protocol ospf Route Flags: R - relay, D - download to fib ------------------------------------------------------------------------------ Public routing table : OSPF Destinations : 2 Routes : 2 OSPF routing table status : <Active> Destinations : 2 Routes : 2 Destination/Mask Proto Pre Cost Flags NextHop Interface 192.168.1.1/32 OSPF 10 1 D 1.0.0.1 GigabitEthernet 0/0/0 192.168.3.1/32 OSPF 10 1 D 2.0.0.2 GigabitEthernet 0/0/1 OSPF routing table status : <Inactive> Destinations : 0 Routes : 0
OSPF bandwidth (Huawei ENSP):
The default priority defined by Huawei equipment for OSPF is 10, and the default reference bandwidth of Huawei equipment OSPF is 100Mbps
OSPF takes bandwidth as the overhead value: COST = reference bandwidth / real bandwidth
If OSPF overhead value is decimal:
When the number is a decimal greater than 1, the decimal part is directly discarded and rounded (rounded down)
If the decimal number is less than 1, it is directly set to 1 (rounded up)
Modify the OSFP bandwidth of Huawei equipment:
[R2-ospf-1]bandwidth-reference ? INTEGER<1-2147483648> The reference bandwidth (Mbits/s)
If you want to modify the OSPF reference bandwidth, you need to modify the OSFP bandwidth on all devices!!!
DR/BDR of OSPF:
In condition matching:
In the MA network, if all devices maintain the adjacency relationship, there will be a large number of repeated updates (constantly sending repeated routing information to each other). In order to prevent this behavior, OSFP proposes to use DR/BDR to determine the dominant information transmission (equivalent to sending all data to Dr first, and then forwarding information to other routes in the region through DR), At this time, we need to conduct DR/BDR election.
DR (designated router): establish adjacency relationship between DR and MA networks and other devices
BDR (backup designated router): BDR also establishes adjacency relationship with other devices in MA network
DR other: in addition to establishing a collar relationship with DR/BDR, only a neighbor relationship is established between them
BDR function: BDR can replace DR in the first time when Dr fails, and play the effect of backup
In an MA network, if both DR and BDR exist, at least four devices are required to see the neighbor relationship between Dr other (only Dr other will establish a neighbor relationship)
Although DR/BDR is called designated router / backup designated router, they are actually just an interface concept, because DR/BDR is selected and determined in an MA network.
Election rules for DR/BDR (non MA network):
//By viewing the neighbor table of R2, you can see that in the neighbor relationship between R2 and R1, BD is R1 and BDR is R2 //In the neighbor relationship with R3, BD is R2 and BDR is R3 <R2>display ospf peer OSPF Process 1 with Router ID 2.2.2.2 Neighbors Area 0.0.0.0 interface 1.0.0.2(GigabitEthernet0/0/0)'s neighbors Router ID: 1.1.1.1 Address: 1.0.0.1 State: Full Mode:Nbr is Slave Priority: 1 DR: 1.0.0.1 BDR: 1.0.0.2 MTU: 0 Dead timer due in 38 sec Retrans timer interval: 5 Neighbor is up for 01:38:37 Authentication Sequence: [ 0 ] Neighbors Area 0.0.0.0 interface 2.0.0.1(GigabitEthernet0/0/1)'s neighbors Router ID: 3.3.3.3 Address: 2.0.0.2 State: Full Mode:Nbr is Master Priority: 1 DR: 2.0.0.2 BDR: 2.0.0.1 MTU: 0 Dead timer due in 31 sec Retrans timer interval: 5 Neighbor is up for 01:37:23 Authentication Sequence: [ 0 ]
1, Compare the priority first. The highest priority is DR, and the next highest priority is BDR. Generally, the priority is 1 by default
//At this time, modify the DR priority of OSPF of the interface on R1 [R1]interface g0/0/0 //The default priority value of DR is 0-255. 0 means to give up the priority of participating in Dr [R1-GigabitEthernet0/0/0]ospf dr-priority ? INTEGER<0-255> Router priority value [R1-GigabitEthernet0/0/0]ospf dr-priority 0 //OSPF routing will be performed again //Go to R2 again to check the OSPF neighbor table [R2]display ospf peer OSPF Process 1 with Router ID 2.2.2.2 Neighbors Area 0.0.0.0 interface 1.0.0.2(GigabitEthernet0/0/0)'s neighbors Router ID: 1.1.1.1 Address: 1.0.0.1 State: Full Mode:Nbr is Slave Priority: 0 DR: 1.0.0.2 BDR: None MTU: 0 #At this time, it is obvious that DR becomes R2, and R1 has no BDR because it abstains Dead timer due in 38 sec Retrans timer interval: 5 Neighbor is up for 00:00:12 Authentication Sequence: [ 0 ] Neighbors Area 0.0.0.0 interface 2.0.0.1(GigabitEthernet0/0/1)'s neighbors Router ID: 3.3.3.3 Address: 2.0.0.2 State: Full Mode:Nbr is Master Priority: 1 DR: 2.0.0.2 BDR: 2.0.0.1 MTU: 0 #DR is R3 and BDR is R2 Dead timer due in 32 sec Retrans timer interval: 5 Neighbor is up for 01:52:07 Authentication Sequence: [ 0 ] //At this time, set the DR priority of the corresponding interface of R2 to 255 [R2]interface g0/0/1 [R2-GigabitEthernet0/0/1]ospf dr-priority 255 //At this time, you need to manually shut down the interface, and then update the DR and BDR in undo [R2-GigabitEthernet0/0/1]shutdown [R2-GigabitEthernet0/0/1]undo shutdown //At this time, view the neighbor table on R2 [R2]display ospf peer OSPF Process 1 with Router ID 2.2.2.2 Neighbors Area 0.0.0.0 interface 1.0.0.2(GigabitEthernet0/0/0)'s neighbors Router ID: 1.1.1.1 Address: 1.0.0.1 State: Full Mode:Nbr is Slave Priority: 0 DR: 1.0.0.2 BDR: None MTU: 0 Dead timer due in 40 sec Retrans timer interval: 5 Neighbor is up for 00:09:03 Authentication Sequence: [ 0 ] Neighbors Area 0.0.0.0 interface 2.0.0.1(GigabitEthernet0/0/1)'s neighbors Router ID: 3.3.3.3 Address: 2.0.0.2 State: Full Mode:Nbr is Master Priority: 1 DR: 2.0.0.1 BDR: 2.0.0.2 MTU: 0 #At this time, it is obvious that R2 becomes DR and R3 becomes BDR Dead timer due in 39 sec Retrans timer interval: 5 Neighbor is up for 00:00:04 Authentication Sequence: [ 0 ]
2, When the priorities are the same, the RID is compared. The corresponding interface of the router with large RID is DR, and the next largest is BDR.
The election of DR/BDR is non preemptive. Once DR and BDR are selected, they cannot be replaced. The election time is the death time (40s), but the time is the same, not the same timer. This time is only the upper limit of the election (all devices added within this time can participate in preemption), but the election is generally completed in a short time, As long as it is completed, you will not be able to preempt (no matter how big your RID is, you cannot preempt and modify DR and BDR after the DR/BDR election is completed).
If you want to modify DR and BDR again, you need to shut down and restart (local) on the corresponding interface.