23 diagrams explain routing protocols in detail

The concept of routing

In TCP/IP communication, the role of the network layer is to realize point-to-point communication of terminals. The IP protocol sends data packets to the destination host through the IP address, enabling any two hosts on the Internet to communicate. IP addresses can identify hosts and routers, and routers can connect networks all over the world.

what is a router

A router can connect multiple networks. It has multiple ports, respectively connected to different network areas. By identifying the network number of the destination IP address, the data is forwarded according to the routing table. The router maintains a routing table , and the router can forward IP packets correctly only through the information in the routing table .

what is routing

Routing is an operation in which network devices forward data based on 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, it forwards the data packet according to the query result. If there is no matching routing entry, it forwards the data packet Discard, this process is IP routing . In addition to routers, devices such as Layer 3 switches, firewalls, load balancing devices, and even hosts can perform routing operations, as long as the device supports routing functions .

what is routing table

In order to send data packets to the destination node, all nodes maintain a routing table . The routing table is a routing entry obtained by the router through various channels. Each routing entry contains information such as destination network segment address / subnet mask, routing protocol, outgoing interface, next-hop IP address, routing priority, and metric value. The routing table records which router the IP packet should be sent to at the next hop. IP packets are transmitted on each data link according to the routing table.

routing table source

In an actual network, a router usually contains multiple routing entries, which are obtained from different sources. The source of the routing table can be divided into three categories, namely direct routing , static routing and dynamic routing .

  • Direct route : The route entry directly connected to the 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 routing : Routing entries manually added through commands are static routing.

  • Dynamic routing : Routing entries dynamically learned from neighboring routers through routing protocols.

routing priority

Routes from different sources have different priorities , and the smaller the value of the priority, the higher the priority of the route. When there are multiple entries with the same network segment but different routes, the route with the highest priority becomes the optimal route and will be added to the routing table , while other routes are inactive and will not be displayed in the routing table .

The default priorities of routing protocols are as follows:

routing loop

A routing loop is an endless loop of data forwarding that cannot reach the destination correctly.

Routing loops are mainly caused by misconfigured routes or wrong network planning . For example, if two routers are configured with routing entries to the same destination address, the next hop points to each other, which will cause a routing loop. In addition, if some dynamic routing protocols are improperly configured, loops may also occur.

black hole routing

A routing entry, no matter it is static or dynamic, needs to be associated with an outbound interface. The outbound interface refers to the outbound interface for the device to reach the destination network. The outgoing interface of the route can be a physical interface of the device, such as a Gigabit Ethernet port, or a logical interface, such as a VLAN interface, or a tunnel interface. One of the interfaces is very special, that is the Null interface, which has only one number, that is 0 . Null0 is a logical interface reserved by the system. When a network device is forwarding a data packet, if the route of the outgoing interface Null0 is used, the data packet will be discarded, as if thrown into a black hole, so the outgoing interface is the route of Null0 Entries are also known as blackhole routes .

Blackhole routing is a very useful routing entry, applicable to the following scenarios:

  • In network use, data packets are directed to the black hole route as needed to realize traffic filtering.
  • In a network where route summarization has been deployed, it is used to prevent loops in data forwarding.
  • In a network where NAT is deployed, it is used to prevent loops in data forwarding.
  • In the BGP network, it is used to advertise the route of a specific network segment.

dynamic routing protocol

Static routes are added manually. If there are 100 network segments, a router needs to set nearly 100 pieces of routing information. In the process of using the network, it is inevitable that network segments will be added, deleted, modified, etc. These updated routing information need to be set on all routers. There is another 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 should be set up in advance, and routing information will be exchanged regularly between routers. The router will know the information of other network segments in the network and dynamically generate routing tables. If the network changes and the network segment needs to be added, deleted or modified, it is only necessary to configure dynamic routing on the corresponding router. It does not need to be modified on all routers like static routing. For a large network 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 that can be bypassed, the routing table of the router will be automatically reset , and the data packet will automatically choose this path.

After adopting the routing protocol, the response speed of the network topology result change will be greatly improved . Regardless of normal network additions, deletions, or abnormal network failures, adjacent routers will detect changes, and will notify other routers in the network of topology changes, causing corresponding changes in their routing tables. 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 requirements, but in large and medium-sized networks, dynamic routing protocols, or a combination of dynamic routing and static routing protocols are usually used to build this network .

Fundamentals of Routing Protocols

Routers need to run the same routing protocol to exchange routing information with each other. Each routing protocol has its own language, that is, the corresponding routing protocol packets. If two routers start the same routing protocol, then there is a basis for mutual communication. Different routing protocols have the same purpose, which is to calculate and maintain routing tables. Usually the working process consists of 4 stages:

  • Neighbor discovery stage : After running the routing protocol, the router will actively send its own network segment information to the adjacent router. Routing protocol messages can be sent by broadcast or unicast to designated neighbor routers.
  • Exchanging routing information stage : After discovering neighbors, each router sends its own routing information to the adjacent router, and the adjacent router sends it to the next adjacent router. After a period of time, each router will receive all routing information in the network.
  • Computing routing stage : Each router will run some algorithm to calculate the final routing table.
  • Routing maintenance stage : In order to perceive sudden network failures, such as equipment failures or line interruptions, the routing protocol stipulates that two adjacent routers should periodically send protocol packets. If the router does not receive the protocol packet from the neighbor within a period of time, it considers the neighbor router to be invalid.

autonomous system

With the development of IP network, the network scale has become very large, no matter which routing protocol can complete the routing calculation of the whole network, so the network is divided into many autonomous systems ( AS, Autonomous System ) or routing domain ( Routing Domain ) . The autonomous system can formulate its own routing policy and manage the set of routers that perform specific routing control in the autonomous system.

Each autonomous system has a unique autonomous system number , and its basic idea is to distinguish different autonomous systems through different numbers. Through the routing protocol and the autonomous system number, the router can determine the routing path and the exchange method of routing information. If an autonomous system lacks sufficient security mechanism, it can avoid it by changing the route by using the number.

The number range of the autonomous system is 1 ~ 65535 , among which 1 ~ 64511 is the registered Internet number, and 64512 ~ 65535 is the private network number.

EGP and IGP

The protocol used for dynamic routing inside the autonomous system (routing domain) is the intra-domain routing protocol , ie IGP . The routing control between autonomous systems uses the inter-domain routing protocol , namely EGP .

The relationship between IGP and EGP is similar to the relationship between the IP address network number and the host number. Routing in the network based on the network number of the IP address is the same as performing host identification within the network segment based on the host number. Routing between regional networks can be performed according to  EGP , and host identification can be performed within a regional network according to IGP .

Routing protocols are divided into two levels, EGP and IGP . Without EGP , there would be no communication among different institutional networks in the world, and without IGP , intra-organizational communication would be impossible.

IGP is a routing protocol for exchanging 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 an autonomous system.

EGP is different from IGP . EGP is used to connect different autonomous systems and exchange routing information between different autonomous systems. The main purpose of EGP is to control the propagation of routing information between autonomous systems by means of routing policy and routing filtering. BGP belongs to EGP .

Dynamic Routing Protocol Type

According to routing algorithms and routing information exchange methods, routing protocols can be divided into distance vector ( 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 Protocol

A distance vector routing protocol refers to a distance vector based routing protocol, and RIP is the most representative distance vector routing protocol. The concept of distance vector contains two key pieces of information: distance and direction , where distance refers to the metric value of reaching 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 own routing table, and the adjacent routers will receive the routing information and update their own routing tables, and then continue to advertise routing information to other directly connected routers. Each router in the network can know the routes of each network segment, and this process is called the route flooding process.

Routers exchange information on the direction and distance of the destination network, and update the routing table with this information. This method is relatively simple in processing, but since there is only distance and direction information, when the network structure becomes complex, it takes a certain amount of time before obtaining stable routing information (that is, the routing convergence time is long), and it is also very easy to occur. Problems such as routing loops.

Link State Routing Protocol

Routers running link-state routing protocols will use some special information to describe the network topology and IP network segments. This information is called link state information ( LSA ). All routers will generate link state information for their own directly connected interfaces. .

The router collects the link state information flooded in the network and stores it in a database. This database is LSDB (Link State Database). LSDB is a description of the entire network topology and IP network segment. The router has the same LSDB . For any router, the network topology is exactly the same.

Next, all routers are calculated based on the LSDB using the shortest route first algorithm to obtain a shortest path tree with itself as the root and without loops , and load the obtained route into the routing table.

The link state algorithm uses an incremental update mechanism, and only when the state of the link changes, the routing update information is sent.

Compared with the distance vector routing protocol, the link state routing protocol has greater scalability and faster convergence speed, but its algorithm consumes more memory and CPU processing power.

Performance Metrics for Routing Protocols

Different routing protocols have different characteristics. The performance indicators of each routing protocol are as follows:

  • The correctness of protocol calculation : refers to whether the algorithm of the routing protocol will generate wrong routes and cause network loops. Different routing protocols use different algorithms, so routing correctness is also different. Link-state routing protocols (such as OSPF) eliminate the possibility of routing loops in the algorithm, which is better than distance vector routing protocols.
  • Route convergence speed : Route convergence means that the routing table of routers on the entire network reaches a consistent state. The fast convergence speed means that when the network topology changes, the router can sense faster and update the corresponding routing information in time. OSPF, BGP and other protocols converge faster than RIP.
  • System overhead occupied by the protocol : the system resources that the router needs to consume when running the routing protocol, such as: CPU, memory, etc. Depending on the working principle, each routing protocol has different requirements for system resources. The system overhead of OSPF routing technology is greater than that of RIP protocol.
  • The security of the protocol itself : refers to whether the protocol is designed to prevent network attacks. OSPF and RIPv2 have corresponding authentication methods to prevent attacks, but RIPv1 does not.
  • Protocol applicable network scale : Different routing protocols are applicable to different network scales and topological structures. The RIP protocol has a limit of 16 hops, so it can only be applied in a small-scale network; while OSPF can be applied in a large-scale network with hundreds of routers; BGP can manage all routers in the world, and the scale of the network it manages Size is limited only by system resources.

main routing protocol

Various routing protocols require the use of IP for packet encapsulation, but the details vary.

The RIP protocol is the earliest routing protocol, which provides simple and easy-to-use dynamic routing for small networks. RIP protocol packets are encapsulated with UDP , and the port number is 520 . Since UDP is an unreliable transport layer protocol, RIP needs to periodically broadcast protocol packets to ensure that neighbors receive routing information.

OSPF is currently the most widely used routing protocol, which can provide layered and reliable routing services for large and medium-sized networks. OSFP directly uses IP for encapsulation, and all protocol messages are transmitted after IP encapsulation, and the protocol number is 89 . IP is a best-effort network layer protocol, which is unreliable itself. Therefore, in order to ensure the reliability of transmission, OSPF adopts 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 a reliable transmission mechanism, which reduces the complexity and overhead of protocol packets.

Several main routing protocol tables are as follows:

Guess you like

Origin blog.csdn.net/m0_60797416/article/details/132006666