Getting to know OSPF (1)
- Preface
- 1. Internal Gateway Protocol and External Gateway Protocol
- 2. The working process of OSPF
- Three, OSPF area
- Four, Router ID
- Five, DR and BDR
- Six, OSPF metrics
- Seven, OSPF packet types
- Eight, OSPF status
- Nine, 4 types of network division
- X. Features of OSPF
- 11. Comparison of OSPF and RIP
- 12. Simple configuration commands
- 13. Summary
Preface
OSPF (Open Shortest Path First) is an interior gateway protocol (Interior Gateway Protocol, IGP), which is used to make routing decisions in a single autonomous system (AS). It is an implementation of the link state routing protocol, which belongs to the interior gateway protocol (IGP), so it operates within the autonomous system.
1. Internal Gateway Protocol and External Gateway Protocol
1、AS
Autonomous System, or AS, refers to a group of networks that exchange routing information with each other through a unified routing policy or routing protocol.
2. Classification
1. Classified by agreement type:
- The distance vector routing protocol
router has an insecure understanding of the entire network topology. It is a "legendary route". For example, A sends routing information to B, and B adds its own metric and sends it to C. The information in the routing table is "listen". "Come on.
Mainly include: RIP, IGRP, EIGRP, etc. - Link-state routing protocol
routers have a complete understanding of the topology and are "routes for sending messages". For example, A puts a message in a letter and sends it to B, and B does not make any changes, copies it, and puts its own information in another In the letter, the two letters are sent to C together. In this way, any change or loss of information five, and finally all the routes receive the same bunch of letters, this bunch of letters is LSDB (link state database). Then each router uses the same SPF algorithm, takes itself as the root, calculates the SPF Tree (that is, each plan to reach the destination), selects the best path, and puts it into the routing table.
Mainly include: OSPF, IS-IS, etc.
2. Classified by self-made system:
-
Intranet IGP (Interior Gateway Routing Protocol): The
internal gateway routing protocol is a routing protocol that runs inside the AS. It mainly solves the problem of selection within the AS, discovers and calculates routes.
Including: RIP, OSPF, IS-IS, etc. -
Internet EGP (External Gateway Routing Protocol): The
external gateway reason protocol is a routing protocol running between AS and AS, which solves the problem of routing between ASs.
Contains: BGP.
2. The working process of OSPF
1. Three tables
OSPF has three tables, namely
- Neighbor table
- Link state database (topology table)
- Routing table
2. Form routing
Simply put, two adjacent routers become neighbors in the form of sending messages, and the neighbors send link state information to each other to form an adjacency, and then each calculates the route according to the shortest path algorithm, and puts it in the OSPF routing table. OSPF routing and other After route comparison, it is added to the global routing table optimally.
Three, OSPF area
1. Concept
To adapt to large-scale networks, OSPF divides multiple areas within the AS. Each OSPF router only maintains the complete link state information of the area in which it is located.
2. Area ID
The area ID can be expressed as a decimal number or as IP.
3. Regional classification
- 1. Backbone area area 0:
As a central entity, other areas are connected to it. The backbone area is numbered 0. In this area, all types of LSAs are allowed to be published. - 2. Non-backbone area:
- Standard area: The default area type except the backbone area. In this type of area, all types of LSAs are allowed to be published.
- Stub area: STUB area. This type of area does not accept routing information about AS outside, that is, it does not accept type 5 AS external LSAs. When routing to a network outside the autonomous system, the router uses the default route (0.0.0.0) , The stub area cannot contain the autonomous system border router ASBR.
- Completely stubby area: This type of area does not accept routing information about the outside of the AS, and also does not accept summary routes from other areas in the AS, that is, it does not accept type 3, type 4, and type 5 LSAs, and completely stub areas cannot be packaged. Change to an autonomous system border router ASBR.
Four, Router ID
1. Concept
Routh ID is the only IP address that represents the router in the OSPF area.
2. Election
Routh ID election rules:
- Election the IP address with the highest value on the loopback interface of the router
- If there is no Loopback interface, select the physical port with the highest IP address
- You can also use routher-id to appoint the specified Routh ID
Five, DR and BDR
1. Concept
When multiple OSPF routers are connected to the same multi-access network segment, if every two routers exchange LSAs with each other, then the network segment will be full of many LSA entries. In order to minimize the number of LSA propagation, through A core router is selected from the multi-access network segment, called DR (Designated Router). All OSPF routers in the network segment exchange LSAs with DR. In this way, DR will have all LSAs and will The LSA is forwarded to each router.
DR is like the LSA transfer station of this network segment. All routers exchange LSA with this transfer station. If the DR fails, it will cause the loss and incompleteness of LSA, so in the multi-access network, in addition to election In addition to DR, a router will be elected as the backup of DR, called BDR (Backup Designated Router). When DR is unavailable, BDR will replace DR.
2. Election of DR and BDR
- Automatic election
The route with the largest route ID on the network segment is DR, and the second largest route is BDR. - Manual election
- The priority range is 0~255, the larger the value, the higher the priority, the default is 1
- If the priority is the same, compare the Routh ID
- If the priority of the router is set to 0, it will not participate in the election of DR and BDR
Note : The router priority can affect an election process, but cannot force the replacement of the formed DR and BDR.
3. OSPF multicast
OSPF has two multicast addresses:
- 224.0.0.5
is the address used when sending the first Hello packet and DRothers monitoring during election. - 224.0.06
is the address used for DR and BDR monitoring.
Six, OSPF metrics
The OSPF metric value is Cost.
Cost value has a calculation method, Cost=10^8/BW
Interface Type | cost |
---|---|
Fast Ethernet | 1 |
Ethernet | 10 |
56K | 1785 |
Seven, OSPF packet types
1. Concept
OSPF packets are carried in IP packets, and the protocol number used is 89.
2. OSPF packet types
OSPF packet type | description |
---|---|
Hello bag | Used to discover and maintain neighbor relationships, elect DR and BDR |
Database Description Package (DBD) | Used to send summary information to neighbors to synchronize the link state database |
Data Link Status Packet (LSR) | After the router receives the DBD containing new information, it is sent to request more detailed information |
Data Link Update Package (LSU) | Send link state advertisement (LSA) after receiving LSR, one LSU packet may contain multiple LSAs |
Link status confirmation packet (LSAck) | Confirm that the DBD/LSU has been received, and each LSA needs to be confirmed separately |
Eight, OSPF status
The router also needs to go through a series of startup processes from starting the OSPF process to calculating the routing table based on the link state database. There are a total of 7 possible startup processes, but they do not necessarily go through these 7 processes. The specific processes are as follows:
Down → Init → Two-way → Exstart → Exchange → Loading → Full
The initial state of the Down neighbor state machine refers to the time when no Hello packet from the other party is received within the past Dead-Interval time or OSPF is not successfully started.
This state of Init indicates that the Hello message from the neighbor has been received, but the neighbor listed in the message does not contain my Router ID (the other party did not receive my Hello message).- The 2-way
state means that both parties have received Hello messages from the opposite end and established a neighbor relationship. In a broadcast and NBMA type network, the two routers whose interface status is DRother will stay in this state.
In this state of EXStart , the router and its neighbors exchange DD messages (the message does not contain the actual content, only some flag bits) to determine the master/slave relationship when sending, and establish the master/slave relationship. It is to ensure orderly transmission in the subsequent DD message exchange.- The EXchange
router uses DD packets to describe the local LSDB and sends it to neighbors. - The Louding
router sends an LSR packet to the neighbor to request a matching DD packet. - Full
In this state, all the LSAs in the LSDB of the neighboring router are present in the local router, that is, the local router and the neighbor have established an adjacency state.
Simple explanation process:
initialization→receive the first Hello packet→establish a two-way session→establish a master-slave relationship→exchange important information→load detailed information→complete connection
Nine, 4 types of network division
- Point-to-point network
Automatically discover neighbors without DR/BDR, multicast 224.0.0.5 - Broadcast multiple access network
automatically discover neighbors, elect DR/BDR, multicast 224.0.0.5, 224.0.0.6 - Non-broadcast multiple access network,
manually specify neighbors, elect DR/BDR, unicast - Point-to-multipoint network
automatically discovers neighbors without DR/BDR, multicast 224.0.0.5
X. Features of OSPF
- Adaptable to large-scale networks
- Fast convergence of route changes
- No routing loop
- Support variable length submask VLSM
- Support area division
- Supports sending protocol messages with multicast addresses
11. Comparison of OSPF and RIP
12. Simple configuration commands
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip add 11.0.0.2 24
[Huawei-GigabitEthernet0/0/0]undo shutdown
Info: Interface GigabitEthernet0/0/0 is not shutdown.
[Huawei-GigabitEthernet0/0/0]int g0/0/1
[Huawei-GigabitEthernet0/0/1]ip add 12.0.0.1 24
[Huawei-GigabitEthernet0/0/1]undo shutdown
Info: Interface GigabitEthernet0/0/1 is not shutdown.
[Huawei-GigabitEthernet0/0/1]int loopback 0
[Huawei-LoopBack0]ip add 1.1.1.1 32
[Huawei-LoopBack0]q
[Huawei]ospf 1 router-id 1.1.1.1 #创建OSPF进程,配置路由ID
[Huawei-ospf-1]area 0 #进入区域0,区域ID可以用数字表示,也可以用IP表示,若区域0则是骨干区域
[Huawei-ospf-1-area-0.0.0.0]network 1.1.1.1 0.0.0.0 #宣告OSPF区域内的直连网段,使用反掩码
[Huawei-ospf-1-area-0.0.0.0]network 12.0.0.0 0.0.0.255
13. Summary
OSPF simply means that two adjacent routers become neighbors in the form of sending messages, and the neighbors send link state information to each other to form an adjacency relationship, and then each calculates a route according to the shortest path algorithm, and puts it in the OSPF routing table, OSPF routing Add to the global routing table after comparing with other routes.