Let me get straight to the point and first show you a panoramic picture. The concept of routingIn TCP/IP communication, the role of the network layer is to achieve point-to-point communication between terminals. The IP protocol sends data packets to the destination host through the IP address, allowing any two hosts on the Internet to communicate. IP addresses can identify hosts and routers, and routers can connect networks around the world. What is a RouterA router can connect to multiple networks. It has multiple ports, each connected to a different network area. It identifies the network number of the destination IP address and forwards data according to the routing table. The router maintains a routing table, and the router can forward IP packets correctly based on the information in the routing table. What is RoutingRouting is the operation of network devices forwarding data according to IP addresses. When a router receives a data packet, it queries the routing table according to the destination IP address of the data packet. If there is a matching routing entry, the data packet is forwarded according to the query result. If there is no matching routing entry, the data packet is discarded. This process is IP routing. In addition to routers, three-layer switches, firewalls, load balancing devices and even hosts can perform routing operations as long as the device supports routing functions. What is a routing tableIn order to send data packets to the destination node, all nodes maintain a routing table. The routing table is the routing entries obtained by the router through various means. Each routing entry contains information such as the destination network segment address/subnet mask, routing protocol, outbound interface, next hop IP address, routing priority and metric. The routing table records which router the IP packet should be sent to at the next hop. IP packets are transmitted on various data links according to the routing table. Routing table sourceIn an actual network, a router usually contains multiple routing entries, which are obtained from different sources. The sources of the routing table can be divided into three categories: direct routing, static routing, and dynamic routing. Direct route: A route entry that is directly connected to a router. As long as the router interface is configured with an IP address and the interface status is normal, the corresponding direct route will be automatically generated. Static route: The route entry manually added through the command is a static route. Dynamic routing: Routing entries dynamically learned from adjacent routers through routing protocols. Route priorityRoutes from different sources have different priorities. The smaller the priority value, the higher the priority of the route. When there are multiple entries with the same network segment but different sources, the route with the highest priority becomes the optimal route and will be added to the routing table, while other routes are inactive and not displayed in the routing table. The default priorities of routing protocols are as follows: Routing loopA routing loop is a situation where data forwarding forms an infinite loop and cannot correctly reach the destination. Routing loopThe main cause of routing loops is incorrectly configured routing or network planning errors. For example, if two routers are configured with routing table entries for the same destination address and the next hop points to each other, a routing loop will be created. In addition, improper configuration of certain dynamic routing protocols may also cause loops. Black Hole RoutingA routing entry, whether static or dynamic, needs to be associated with an outbound interface, which refers to the outbound interface of the device to reach the destination network. The outbound interface of the route can be the physical interface of the device, such as a Gigabit network port, or a logical interface, such as a VLAN interface, or a tunnel interface. There is a very special interface, the Null interface, which has only one number, which is 0. Null0 is a logical interface reserved by the system. When the network device is forwarding data packets, if the route with the outbound interface Null0 is used, the data packet will be discarded, just like being thrown into a black hole. Therefore, the routing entry with the outbound interface Null0 is also called a black hole route. Black hole routing is a very useful routing entry, which is suitable for the following scenarios:
Dynamic Routing ProtocolsStatic routes are added manually. If there are 100 network segments, a router needs to set up nearly 100 routing information. In the process of network use, it is inevitable that network segments are added, deleted, and modified. These updated routing information needs to be set up on all routers. There is also a problem that cannot be ignored. Once a router fails, data transmission cannot automatically bypass the failed node and can only be restored to normal through manual settings. If dynamic routing is used, the routing protocol is set up in advance, and the routers will exchange routing information regularly. The routers will know the information of other network segments in the network and dynamically generate routing tables. If the network changes and the network segments need to be added, deleted, or modified, you only need to configure dynamic routing on the corresponding routers. It is not necessary to modify it on all routers like static routing. For large networks with a large number of routers, dynamic routing protocols are mainly used. Even if a node on the network fails, as long as there is another path to bypass, the router's routing table will be automatically reset and the data packet will automatically choose this path. After adopting the routing protocol, the response speed of network topology changes will be greatly improved. Whether it is normal addition, deletion, or abnormal network failure, the adjacent routers will detect the change and notify other routers in the network of the topology change, so that their routing tables will change accordingly. This process is much faster and more accurate than manually modifying the routing table. For small networks with less than 10 routers, static routing may be able to meet the needs, but in large and medium-sized networks, dynamic routing protocols are usually used, or a combination of dynamic routing and static routing protocols to build the network. Basic principles of routing protocolsRouters need to run the same routing protocol to exchange routing information. Each routing protocol has its own language, namely the corresponding routing protocol message. If two routers start the same routing protocol, they have a basis for mutual communication. Different routing protocols have the same purpose, which is to calculate and maintain the routing table. The working process usually includes 4 stages:
Autonomous SystemWith the development of IP networks, the network scale has become very large. No matter which routing protocol is used, it is impossible to complete the routing calculation of the entire network. Therefore, the network is divided into many autonomous systems (AS) or routing domains. Autonomous systems can formulate their own routing strategies and manage the set of routers that perform specific routing control within the autonomous system. Each autonomous system has a unique autonomous system number. The basic idea is to distinguish different autonomous systems through different numbers. Through routing protocols and autonomous system numbers, routers can determine the routing path and the way to exchange routing information. If an autonomous system lacks sufficient security mechanisms, the number can be used to change the path to avoid it. The number range of autonomous systems is 1 to 65535, of which 1 to 64511 are registered Internet numbers and 64512 to 65535 are private network numbers. EGP and IGPThe protocol used for dynamic routing within an autonomous system (routing domain) is the intra-domain routing protocol, or IGP. The routing control between autonomous systems uses the inter-domain routing protocol, or EGP. The relationship between IGP and EGP is similar to the relationship between the network number and the host number of an IP address. Routing is selected in the network based on the network number of the IP address, and host identification is performed within the network segment based on the host number. Routing can be selected between regional networks based on EGP, and host identification can be performed within the regional network based on IGP. Routing protocols are divided into two levels: EGP and IGP. Without EGP, there would be no communication between the networks of different organizations in the world, and without IGP, there would be no communication within organizations. IGP refers to a routing protocol that exchanges routing information within the same autonomous system. RIP, RIP2, and OSPF belong to IGP. The main purpose of IGP is to discover and calculate routing information within the autonomous system. EGP is different from IGP. EGP is used to connect different autonomous systems and exchange routing information between them. The main purpose of EGP is to control the propagation of routing information between autonomous systems by using routing policies and routing filtering. BGP belongs to EGP. Dynamic routing protocol typeAccording to the routing algorithm and the way of exchanging routing information, routing protocols can be divided into distance vector (DV) routing protocols and link state (Link-State) routing protocols. The typical distance vector protocol is RIP, and the typical link state protocol is OSPF. Distance Vector Routing ProtocolDistance vector routing protocol refers to a routing protocol based on distance vector, and RIP is the most representative distance vector routing protocol. The concept of distance vector contains two key information: distance and direction, where distance refers to the metric value to reach the destination network (that is, the number of routers to pass through), and direction refers to the next hop device to reach the destination network. Each router running the distance vector routing protocol will periodically advertise its routing table. Adjacent routers receive the routing information and update their own routing tables, and then continue to advertise the routing information to other directly connected routers. Eventually, every router in the network will know the routes of each network segment. This process is called routing flooding. Routers exchange information about the direction and distance of the destination network and use this information to update the routing table. This method is relatively simple to process, but since there is only information about distance and direction, when the network structure becomes complex, it takes a certain amount of time to obtain stable routing information (i.e., the routing convergence time is long), and it is also very easy to cause routing loops and other problems. Link State Routing ProtocolRouters running link state routing protocols use some special information to describe the network topology and IP segments. This information is called link state information (LSA). All routers generate link state information for their directly connected interfaces. The router collects the link state information flooded in the network and stores it in a database, which is the LSDB (Link State Database). The LSDB describes the topology of the entire network and the IP network segment. Routers have the same LSDB. For any router, the network topology is exactly the same. Next, all routers use the shortest route first algorithm based on LSDB to calculate and obtain a loop-free shortest path tree with themselves as the root, and load the obtained routes into the routing table. The link state algorithm uses an incremental update mechanism, and routing update information is sent only when the state of the link changes. Compared with distance vector routing protocols, link state routing protocols have greater scalability and faster convergence speed, but their algorithms consume more memory and CPU processing power. Performance indicators of the Link Router protocolDifferent routing protocols have different characteristics. The performance indicators of each routing protocol are as follows:
Main routing protocolsVarious routing protocols need to use IP for message encapsulation, but the details are different. RIP protocol is the earliest routing protocol, which provides simple and easy-to-use dynamic routing for small networks. RIP protocol messages are encapsulated in UDP, and the port number is 520. Since UDP is an unreliable transport layer protocol, RIP protocol needs to broadcast protocol messages periodically to ensure that neighbors receive routing information. OSPF is the most widely used routing protocol, which can provide hierarchical and reliable routing services for large and medium-sized networks. OSPF directly uses IP for encapsulation, and all protocol messages are transmitted after being encapsulated by IP. The protocol number is 89. IP is a best-effort network layer protocol, which is unreliable in itself. Therefore, in order to ensure the reliability of transmission, OSPF uses a complex confirmation mechanism to ensure reliable transmission. BGP uses TCP to ensure the reliability of protocol transmission, and the TCP port number is 179. BGP does not need to design its own reliable transmission mechanism, which reduces the complexity and overhead of protocol messages. Several major routing protocol tables are as follows: |
<<: Online interview experience: Is it absolutely safe to use HTTPS?
>>: Mobile performance optimization series - startup speed
The Internet of Things has the characteristics of...
According to OpenAI's data analysis, the amou...
Why take the IPv4 side road when there is the IPv...
Author: Wei Fei, Unit: China Mobile Smart Home Op...
Why should we care about switch security??? Verti...
5G will become one of the hot technologies in the...
In early 2020, the coronavirus pandemic hit IT li...
When a user uses a command with the TCP/IP appli...
[Beijing, China, October 15] In September this ye...
Speaking of 5G, what do you think of first? If yo...
Does it feel like you’re hearing the term “data-d...
Kvmla has not released promotional information fo...
Forrester Research pointed out in its research th...
Many people may not know that the traditional rad...
The Industrial Ethernet market will grow from a c...