This article describes the basic working principles of routers in TCP/IP networks and introduces several functions of IP routers, the static and dynamic routing protocols, as well as the concepts of the internal gateway protocol and the external gateway protocol are given, at the same time, the most common RIP, OSPF, BGP and BGP-4 routing protocols are briefly introduced, and then the design objectives and types of routing algorithms are described, the link state method and distance vector method are introduced in detail. At the end of the article, we briefly describe the features of the new generation router. Www.2cto.com-over the past decade, with the continuous expansion of computer networks and the rapid development of large interconnected networks (such as the Internet), routing technology has gradually become a key part of network technology, the router becomes the most important network device. Users' Needs Promote the Development of routing technology and the popularization of routers. People are not satisfied with sharing information only on local networks, we hope to maximize the use of various types of network resources in various regions around the world. In the current situation, any computer network with a certain scale (such as Enterprise Network, campus network, smart building, etc.), whether it is using the large-scale network technology, FDDI technology, or ATM technology, it is inseparable from routers, otherwise it will be unable to operate and manage normally. 1. Network Interconnection: connecting your network with other networks, obtaining more information from the network, and publishing your own messages to the network is the main driving force for network interconnection. There are multiple network interconnection methods, among which the most commonly used are bridge interconnection and router interconnection. 1.1 network connected by a bridge-the second layer in the OSI model where the bridge works, that is, the link layer. The main purpose of data frame Forwarding is to provide transparent communication between Connected Networks. Bridge Forwarding is based on the source address and destination address in the data frame to determine whether a frame should be forwarded and to which port. The address in the frame is called the "MAC" address or "hardware" address, which is generally the address of the NIC. Www.2cto.com-the function of a bridge is to interconnect two or more networks to provide transparent communication. Devices on the network cannot see the existence of a bridge, and communication between devices is as convenient as on an Internet. Because the bridge forwards data frames, it can only connect to the same or similar network (data frames of the same or similar structure), such as between Ethernet, Ethernet and token ring) for different types of networks (different data frame structures), such as Ethernet and X.25, the bridge is powerless. -- Bridges expand the network scale, improve network performance, and facilitate network applications. In the past, bridges were widely used. However, bridge interconnection also brings many problems: one is the broadcast storm, which does not block the broadcast messages in the network. When the network scale is large (several bridges and multiple Ethernet segments ), broadcast storm may occur, and the whole network is full of broadcast information until it is completely paralyzed. The second problem is that when the network is connected to an external network, the bridge combines the internal network with the external network to become a network, and both parties open their own network resources to the other party. This interconnection method is obviously unacceptable when it is connected to an external network. The main cause of the problem is that the bridge only maximizes network communication, regardless of the information transmitted. 1.2 vro Interconnect Network-vro interconnect is related to the network protocol. We will discuss the limitations of the TCP/IP network. -- The layer-3 router in the OSI model, that is, the network layer. Vrouters use network addresses (IP addresses) defined in the "logic" of the network layer to differentiate different networks, achieve network interconnection and isolation, and maintain the independence of each network. Vrouters do not forward broadcast messages, but restrict broadcast messages to their respective networks. Data sent to other networks is first sent to the vro and then forwarded by the vro. -- The IP router only forwards IP groups and blocks the remaining parts in the network (including broadcast) to ensure the independence of each network. This can form a network with many subnets) large interconnected networks. Because of the interconnection at the network layer, the router can easily connect different types of networks. As long as the network layer runs the IP protocol, the router can connect. -- Devices in the network use their network addresses (IP addresses in the TCP/IP network) to communicate with each other. An IP address is a "logical" address unrelated to a hardware address. The router forwards data only by IP address. The IP address structure consists of two parts: one part defines the network number and the other part defines the host number in the network. At present, the subnet mask is used in Internet networks to determine the network address and Master Address in the IP address. The subnet mask is also 32bit like the IP address, and the two are one-to-one correspondence. it is specified that the part of the subnet mask whose number is "1" is the network number, the master ID corresponding to "0. The network and host numbers are combined to form a complete IP address. Host IP addresses in the same network must have the same network number. This network is called an IP subnet. -- Communication can only be performed between IP addresses with the same network number. To communicate with hosts with other IP address subnets, the communication must go through a vro or gateway on the same network. IP addresses of different network numbers cannot communicate directly, even if they are connected together. -- A vro has multiple ports used to connect multiple IP subnets. The network number of the IP address of each port must be the same as the network number of the connected IP subnet. Different ports have different network numbers and correspond to different IP subnets. In this way, the hosts in each subnet can send the requested IP addresses to the vro through their own subnet IP addresses. Routing principle of www.2cto.com 2-when one host in the IP subnet sends an IP group to another host in the same IP subnet, it will directly send the IP Group to the network, and the other party will receive the IP. To send the IP address to a host on the internet, you need to select a router that can reach the destination subnet and send the IP address group to the router. The router is responsible for sending the IP address group to the destination. If such a router is not found, the host sends the IP Group to a router called "default gateway. The "Default Gateway" is a configuration parameter on each host. It is the IP address that is connected to a vro port on the same network. -- When forwarding an IP group, the router selects an appropriate port based on the network number of the destination IP address of the IP Group and sends the IP Group out. Like a host, the vro must determine whether the port is connected to the destination subnet. If yes, the group is directly sent to the network through the port. Otherwise, the next vro must be selected to send the group. The router also has its default gateway to send IP groups that do not know where to send them. In this way, the router correctly forwards IP groups that know how to transfer them, and the IP groups that do not know are sent to the "Default Gateway" router. In this way, the IP Group will eventually be sent to the destination, IP groups that cannot be sent to the destination are discarded by the network. -- Currently, all TCP/IP networks are connected through routers. The Internet is an international network that connects thousands of IP subnets through routers. This type of network is called a router-based network, forming a "inter-network" with a vro as a node ". In "inter-network", routers are not only responsible for forwarding IP groups, but also responsible for communicating with other routers to jointly determine the routing selection and maintenance route table of "inter-network. -- A route action includes two basic items: path finding and forwarding. The routing algorithm is used to determine the optimal path to the destination. Because different routing protocols and routing algorithms are involved, it is more complicated. To determine the optimal route, the routing algorithm must start and maintain the route table containing route information. The routing information varies depending on the routing algorithm used. The routing algorithm fills in different information collected in the routing table, and tells the router about the relationship between the destination network and the next stop (nexthop) according to the route table. The router interconnection information is updated, and the route table is updated and maintained so that the network topology changes are correctly reflected. The optimal path is determined by the router according to the measurement. This is the routing protocol (routing protocol), such as the routing information protocol (RIP), Open Shortest Path First protocol (OSPF), and Border Gateway protocol (BGP. -- Forward refers to the information transfer group along the best path for path searching. The router first searches in the routing table and determines whether the router knows how to send the group to the next site (router or host). If the router does not know how to send the group, the router usually discards the group; otherwise, the group is sent to the next site based on the corresponding table items in the route table. If the destination network is directly connected to the vro, The vro sends the group directly to the corresponding port. This is the router protocol ). -- The routing and forwarding protocols are mutually compatible and independent. The former uses the route table maintained by the latter, at the same time, the latter should use the functions provided by the former to publish the Routing Protocol Data grouping. The routing protocols mentioned below, unless otherwise stated, refer to the routing selection protocols, which are also common habits. Www.2cto.com 3 routing protocol-typical routing methods include Static Routing and dynamic routing. -- Static Routing is a fixed route table set in a vro. The static route does not change unless the network administrator intervene. Because Static Routing cannot reflect network changes, it is generally used in a network with a small network size and a fixed topology. Static Routing is simple, efficient, and reliable. Among all the routes, static routes have the highest priority. When a dynamic route conflicts with a static route, the static route prevails. -- Dynamic Routing refers to the process in which routers in the network communicate with each other, transmit route information, and update the router table using the received route information. It can adapt to network structure changes in real time. If the route update information indicates that the network has changed, the route selection software recalculates the route and sends new route update information. This information is transmitted through various networks, causing routers to restart their routing algorithms and update their route tables to dynamically reflect network topology changes. Dynamic Routing is suitable for networks with large networks and complex network topologies. Of course, various dynamic routing protocols occupy network bandwidth and CPU resources to varying degrees. -- Static Routing and dynamic routing have their own characteristics and applicability. Therefore, dynamic routing is usually used as a supplement to Static Routing in the network. When a group is used to find the route in the vro, The vro first searches for the static route. If yes, the vro。 forwards the route according to the corresponding static route forwarding group. Otherwise, the vro searches for the dynamic route. -- Dynamic Routing Protocols are divided into internal gateway protocol (IGP) and external Gateway Protocol (EGP) based on whether they are used in an autonomous domain ). The Autonomous Region refers to a network with a unified management organization and a unified routing policy. The routing selection protocol used inside the autonomous domain is called the internal gateway protocol, which is commonly used with RIP and OSPF. The external gateway protocol is mainly used for routing selection between multiple autonomous domains, common are BGP and BGP-4. The following is a brief introduction. 3.1 RIP Routing Protocol-the RIP Protocol was originally designed for the Xerox parc common protocol in the Xerox network system and is a common Routing Protocol in the Internet. RIP uses the distance vector algorithm, that is, the router selects routes based on distance, which is also called the distance vector protocol. All the different paths of the router collection that can reach the destination, and save the path information about the minimum number of sites to reach each destination, except for the Optimal Path to the destination, any other information will be discarded. At the same time, the router also uses the RIP Protocol to notify neighboring routers of the route information. In this way, the correct routing information gradually spreads to the entire network. -- RIP is widely used, which is simple, reliable, and easy to configure. However, RIP is only applicable to a small homogeneous network, because it allows a maximum of 15 sites, any more than 15 sites are marked as inaccessible. In addition, the route information broadcast once every 30 s by RIP is also one of the important reasons for the network broadcast storm. Www.2cto.com 3.2 OSPF routing protocol-in the middle of 1980s, RIP was no longer able to adapt to the interconnection of large-scale heterogeneous networks, resulting in the generation of 0 SPF. It is a routing protocol developed for the IP network by the Internal Gateway Protocol Working Group of the inter-network engineering task organization (1ETF. -- 0SPF is a link-based routing protocol. Each router needs to send link status broadcast information to all other routers in the same management domain. All port information, all measurements, and other variables are included in the OSPF link status broadcast. A vro with 0SPF must first collect the relevant link status information and calculate the shortest path to each node based on certain algorithms. The Distance Vector-based routing protocol only sends route update information to its neighboring routers. -- Unlike RIP, OSPF divides an autonomous region into two different zones. There are two types of routes to be selected: when the source and destination are in the same zone, the intra-zone routes are used; when the source and destination are in different regions, the interval routing is used. This greatly reduces network overhead and increases Network stability. When a vro in a region fails, the normal operation of vrouters in other regions in the autonomous region is not affected, which also facilitates network management and maintenance. 3.3 BGP and BGP-4 routing protocol-BGP is an external gateway protocol designed for TCP/IP Internet for multiple autonomous domains. It is neither based on pure link state algorithms nor pure distance vector algorithms. Its main function is to exchange network accessibility information with BGP of other autonomous domains. Each autonomous domain can run different internal gateway protocols. The bgp update information includes the paired information of the network number/autonomous domain path. The autonomous domain path includes the autonomous domain string that must pass through a specific network. The update information is transmitted over TCP to ensure the transmission reliability. -- BGP is still evolving to meet the growing needs of the Internet. In the latest BGp4, similar routes can also be merged into one route. Priority of the route table entry in www.2cto.com 3.4-a static route and one or more dynamic routes can be configured in one vro. The route tables they maintain are provided to the forwarder, but the table items in these route tables may conflict. This conflict can be solved by configuring the priority of each route table. Generally, static routes have the highest priority by default. When other route table items conflict with them, they are all forwarded by static routes. 4. Routing Algorithms-Routing Algorithms play a vital role in the routing protocol. The algorithm used often determines the final routing result. Therefore, you must carefully select a routing algorithm. Generally, you need to consider the following design goals: -- (1) Optimization: the ability of the routing algorithm to select the optimal path. -- (2) conciseness: The algorithm design is concise, and the most effective function is provided with the least software and overhead. -- (3) Robustness: the routing algorithm runs correctly when it is in an abnormal or unpredictable environment, such as hardware failure, overload, or operation error. Because the routers are distributed on the network connection points, they will have serious consequences when they fail. The best router algorithms are often time-tested and proven to be reliable in various network environments. -- (4) fast convergence: convergence is the process in which all routers reach the same path. When a network event causes a route to be available or unavailable, the router sends an update message. The route update information is distributed throughout the network, causing re-calculation of the Optimal Path to eventually reach the best path recognized by all routers. Slow convergence routing algorithms may cause path loops or network interruptions. -- (5) Flexibility: routing algorithms can quickly and accurately adapt to various network environments. For example, if a CIDR Block fails, the routing algorithm must quickly discover the fault and select another optimal path for all routes using the CIDR block. -- Routing algorithms can be divided into the following types: static and dynamic, single and multi-path, equality and classification, source routing and transparent routing, intra-domain and Inter-Domain, link status and distance vector. The preceding features are basically the same as the literal meanings. Next we will introduce the link status and distance vector algorithms. Www.2cto.com-the link status algorithm (also called the shortest path algorithm) sends route information to all nodes on the Internet, only the routing table that sends it describes the status of its own link. The Distance Vector Algorithm (also known as the Bellman-Ford algorithm) requires each router to send all or part of its route table information, but only to the neighboring nodes. Essentially, the link status algorithm sends a small amount of update information to all parts of the network, while the Distance Vector Algorithm sends a large amount of update information to the adjacent router. -- Because the link state algorithm converges faster, it is more difficult to generate a route loop than the distance vector algorithm to a certain extent. On the other hand, the link state algorithm requires higher CPU capability and more memory space than the distance vector algorithm, so the link state algorithm will be more expensive to implement. In addition to these differences, the two algorithms can run well in most environments. -- It should be pointed out that the routing algorithm uses many different measurement standards to determine the optimal path. Complex routing algorithms may use multiple metrics to select routes. They are combined into a single composite metric and then entered into the routing table as the routing standard through a certain weighting operation. The commonly used measurements include path length, reliability, latency, bandwidth, load, and communication cost. 5. Next-generation routers: the bandwidth and speed of networks are increasing rapidly due to the development of multimedia applications in networks and the continuous adoption of new technologies such as ATM and Fast Ethernet, traditional routers cannot meet the performance requirements of routers. Because the design and implementation of group forwarding of traditional routers are based on software, grouping processing takes many steps during the forwarding process, and the forwarding process is complicated, making the forwarding rate slow. In addition, because the vro is a key device for network interconnection and a "Gateway" for network communication with other networks, it has high security requirements, therefore, the additional security measures in the vro increase the CPU burden, which makes the vro a "bottleneck" on the Internet ". -- A traditional Router performs a series of complex operations when forwarding each group, including route lookup, access control table matching, address resolution, priority management, and other additional operations. This series of operations greatly affects the performance and efficiency of the router, reduces the packet forwarding rate and forwarding throughput, and increases the CPU burden. Vro groups are highly correlated. groups with the same destination address and source address often arrive consecutively, which provides the possibility and basis for fast forwarding. New-generation routers, such as IP switches and Tag switches, use this design idea to implement fast forwarding using hardware, which greatly improves the performance and efficiency of routers. Www.2cto.com-the new-generation router uses the forwarding cache to simplify the forwarding operation of the group. In the process of fast forwarding, you only need to perform traditional route forwarding for the first several groups with the same destination address and source address, the destination address, source address, and next gateway address (next vro address) of the successfully forwarded group are placed in the forwarding cache. When the next group is to be forwarded, Yin first checks the forwarding cache. If the destination address and Source Address of the group match the forwarding cache, forwarding is directly based on the next gateway address in the forwarding cache, without the need for traditional complex operations, which greatly reduces the burden on the router and improves the router throughput. This article is from Zhongguancun Online Network