5.3.3 Internet routing protocol (3) OSPF protocol
Earlier we learned the routing information protocol RIP based on the distance vector algorithm ( 5.3.2 Internet routing protocol (2) RIP protocol based on the distance vector algorithm ), in order to overcome the limitations of the RIP protocol, there is a new interior gateway protocol OSPF Protocol, OSPF is the abbreviation of Open Shortest Path First, and it is also known as the open shortest path first protocol. The shortest path first is because the shortest path algorithm SPF proposed by Dijkstra is used. This protocol is based on the state of the link when selecting the path .
1. Link status
The link state refers to the combination of a router in the link and those routers adjacent to each other, as well as the bandwidth, delay, line load and other factors of the link, that is to say, it will calculate its link status for each link. Cost, also known as Cost, after comprehensively considering the link state, OSPF will use the Dijkstra algorithm to select the best path.
2. OSPF routing information exchange
We know that in RIP, the current router only exchanges information with neighboring routers, but the OSPF protocol is different. It will notify all routers in the autonomous system of the link status information. Then how does it notify? In fact, OSPF uses a flooding method. As the name implies, the so-called flooding method is like a flood, and the current router is the center to transmit the message to the surroundings until all the routers have learned the message. Let's demonstrate how OSPF uses the flooding method to exchange link state information between routers.
as shown in the picture
We can see from the figure that it is an autonomous system formed by connecting routers A, B, C, and D. After initialization, router A acts as the source router. According to the rules of the flooding method, A first sends its own link The state information is sent to B and C adjacent to it. Of course, we did not write all the contents of the link state on it. In fact, it should also include the cost of the link connected to A, etc. B and C then share the link state information from A with their adjacent router D. This process is the process of exchanging link state information using the flooding method. After all the routers in the network have exchanged link states with each other, OSPF will enable each router to generate a topology structure of its own autonomous system according to the link state, and also know where it is in the topology structure. Each box in the figure marks the position of each router in the autonomous system.
3. Characteristics of OSPF protocol
- OSPF can set different costs for different links according to link bandwidth and other factors. When choosing which route to take, it does not choose a route with the least number of routers like RIP, but chooses a total The cheapest way.
- In a special case, if the two paths are the same, the OSPF protocol will evenly distribute datagrams to the two paths, that is to say, OSPF can realize load balancing among multiple paths.
- When the state of a link adjacent to a certain router changes, the current router will use the flooding method to notify all routers to know the news.
- OSPF stipulates that the link status in the database will be refreshed at intervals such as 30 minutes.
- Compared with RIP, the biggest advantage of OSPF is that when the interconnection scale is large, because OSPF is based on the link state, it only involves the state of the connection with the adjacent router, and has no direct relationship with the scale of the entire Internet. It also solves the problem that the RIP protocol cannot solve.
In fact, if the scale of the autonomous system is that the number of networks is relatively large, it can be divided into several areas (Area) in OSPF
as shown in the picture
In the autonomous system in the figure, four areas are divided, the three surrounding areas are general areas, and the middle part is the backbone area. The advantage of this is that the scope of using the flooding method to notify the link state is narrowed to all routers in an area. The routers in each area only know the topology of the area. Routing between areas and areas is accomplished through area border routers R3, R4, R7 and backbone area routers.