I. the basic principle of CEF express exchange vro and vswitch are the most important parts of the basic network. vrouters and vswitches have two main purposes: first, how to accurately set data packets (frames) from the source address to the target address, and how to deliver the address more quickly. Of course, the priority of the second point is lower than that of the first point. In order to better accomplish these two tasks, after years of development, the methods for switching packets between vswitches and vrouters are constantly improved, no matter how it changes, it is to better fulfill these two fundamental tasks. The topic of this article is to explain the basic principles of CEF.
Www.2cto.com first, let's take a look at the packet forwarding process. Generally, there are three steps for a vro: 1. Check whether the destination address of the package is reachable. 2. determine the next hop and interface of the destination address. 3. Rewrite the MAC header so that it can successfully reach the next hop.
The above three steps are fundamental to vro Packet Exchange, and all the derived Packet Exchange methods so far must complete the above three processes.
In order to better understand the CEF, we will discuss the other two well-known Packet Exchange Methods: Process exchange and fast forwarding.
Www.2cto.com
Process Switching
The oldest exchange method is supported by all platforms.
For ease of understanding, use a diagram to illustrate the process exchange method. 1. the interface process (input interface processor) first discovers a data packet in the network, and then passes it to "input/output memory" (input/output memory) 2. the interface process creates an interruption to Data. During this interruption, the central processor determines the type of the package (generally IP). If necessary, copy it To the memory (processor memory ). Finally, the processor places the package in an appropriate process ('input queue) and cancels the interruption. 3. then the scheduler starts the IP_INPUT process www.2cto.com 4. when the IP_INPUT process starts, it starts to determine the next hop and outgoing interface from the RIB (route table), and then finds the MAC address of the next hop in the ARP cache. (ARP broadcast will be performed if there is no corresponding address in the cache) 5. the MAC address of the IP_INPUT process rewrite package, and then put the package in the outgoing queue of the appropriate port. 6. Copy the packet from the outgoing queue of the outgoing port to the outgoing transmission queue. 7. The outgoing interface processor finds this package in the outgoing queue and then transmits the package to the network.
Next let's look at the second important exchange method: fast exchange 1. The interface processor discovers packets in the network, and then transmits the packets to the input/output memory2. interface processor to create a receiving interrupt. During this interruption, the central processor determines the package type (assuming the IP type) and immediately starts switching the package. 3. The processor starts to search for the route cache to determine whether the package's destination address is reachable, what the outbound interface is, and how the package needs to rewrite the MAC to reach the next hop. 4. Copy the package to the outgoing port transmission queue or outgoing Queue (this varies with different vendors ). At this time, the reception interruption is canceled, and the processor continues the task that has not been completed. 5. the processor of the outbound interface finds data packets in the transmission queue and then transmits the packets to the network.
Now, let's look at the differences between the two exchange methods.
Before talking about the differences between the two, insert a concept.
So far, there have been N Packet Exchange methods, two of which are important. The first is process exchange, and the second is called Interrupt Context Switching ", the second type includes the "quick exchange", the well-known CEF, and the Optimum exchange.
Before reading the following text, you must understand this hierarchy.
The so-called process exchange, as the name implies, is to create a process. We know that the processor works according to the schedule (Plan) while working, and process exchange is like this, it will create a process named "IP_INPUT" (assuming the IP package is discussed), put it in the SCHEDULE of the processor, and wait, and when will the process be executed. Have you found any problems? The queuing rules are very good from the design perspective, but there is some drag-and-drop for packet switching. Suppose there is other work to be done on the processor, at this time, the process "IP_INPUT" created by it must be in the SCHEDULE medium and cannot be executed. It can only be executed when it is exceeded. This is obviously a waste of time.
In contrast, Interrupt Context Switching requires a lot of "overlord". Pay attention to this "INTERRUPT" and pay attention to my italics. The difference between this exchange method and process exchange is "not queuing ", as long as there is a package, it will be processed first. When it is finished, the processor will go back to its work in SCHEDULE.
These are one of the differences between process Switching and Interrupt Context Switching.
Another difference is that if you have read my previous article, you may be impressed by the addition of "cache ", the processor does not directly search for the route table but the cache when looking for information such as the reachable target address and the next hop. This is also the second difference.
The first difference makes exchange grow much faster. What is the difference between the second and second? "What is the purpose of cache ?"
There are three different exchange methods for Interrupt Context Switching. They are
Fast Switching
Optimum Switching
Cisco Express Forwarding
The main differences between these three methods are reflected in the differences in their cache construction methods, and they are precisely due to this difference that some of their features are different.
First, let's talk about the most basic Fast Switching. For example, this is a binary tree, which is also the cache data structure in the Fast switch, in quick exchange, the outgoing interface information and the MAC address to be rewritten are placed on the corresponding node in the binary tree, and the destination address to be forwarded is the address represented by the node on the binary tree. So how does this traversal work? For example, if a number is 4 and converted to binary 100, the query starts from the highest bit and starts from the root node. The first step is to go to the right subtree of the root node, because the first digit of 100 (the highest bit) it is 1, and then goes to the left subtree, and then continues to the left subtree direction. At this time, 100 is found. If this is a real IPV4 address, it takes up to 32 queries to find the desired CIDR Block quickly? Due to the length of IPV4 addresses, the depth of the binary tree for fast exchange is 32. The above is a quick exchange of the data structure in the cache, as well as the search method. Let's take a look at some of the resulting features and find out its shortcomings. 1. Because the cache is created out of thin air, there is no connection between the route table and the MAC cache, therefore, when we want to use quick exchange for search, we must first perform a complete process exchange. 2. Because a node in the cache corresponds to an address and no pointer can be linked to each node, recursive queries cannot be implemented. However, this does not affect the router's use of recursive queries, because when every new packet comes in, a process exchange is required, during which recursive queries have been completed. 3. Because the node information is created from the route table and ARP cache, when the route table or ARP cache is refreshed, the corresponding node should be invalid and a binary tree must be created again, in this process, fast exchange is not usable and can only be exchanged with traditional processes. Imagine if this is a very large network, its network status will change constantly, this will greatly affect the efficiency of quick exchange. By introducing quick exchange, we have now solved a problem. Why is it faster to create a cache than to directly find a route table. However, the analysis shows that it is not perfect. Is there a better solution? Let's look at the next Switching method: Optimum Switching
Faster! Faster! The idea of a binary tree is good, but it may look a little more than 32 levels. Is it faster? Optimum Switching mainly improves the data structure for fast exchange. It reconstructs a multi-branch (256-way mtree ),, in this way, it takes up to four queries to achieve the goal, and generally only one or three queries are required. This is a good idea, but it does not improve other aspects of quick exchange. It can only be regarded as an upgraded version of quick exchange, but it plays a crucial role. Next let's take a look at the revolutionary CEF! CEF is a third generation exchange method based on Interrupt Context Switching developed based on the rapid exchange and Optimum Switching. It overcomes the disadvantages of the first two methods. Ii. CEF provides the following advantages: 1. Improved performance. CEF is less CPU-intensive than fast switching routing cache. More CPU processing capabilities can be used for layer-3 services, such as QoS and encryption. 2. Scalability: the distributed CEF (dCEF) model is positive when each line card provides sufficient switching capacity. 3 • the elastic CEF provides an unprecedented level of consistency and stability switch in large dynamic networks. 4 • although you can use CEF in any part of a network, it is designed for high-performance, highly elastic layer-3rd IP backbone switching. For example, it shows the core aggregation point (GSRS) traffic level, density, and performance of the Cisco 12000 series Gigabit exchange router running in CEF. In a typical high-capacity Internet Service Provider environment, a Cisco 7500 class architecture review on the supported networking links to Cisco 12012 series routers or core aggregation devices of other connection devices. On these platforms, CEF provides the required performance and scalability at the core of the network to cope with the increasing and increasing network traffic. CEF is a distributed switching mechanism with linear expansion of the interface card and bandwidth installed on the router. 5. CEF has two components: FIB (Forwarding Information Base) and Adjacency Table. These two tables contain all the Forwarding Information, the forwarding information is constructed based on the route table and ARP. The FIB table can be viewed as a RIB (Router Information Base) image, which corresponds to one-to-one, that is, compared with the fast forwarding CEF, it does not need to maintain the high-speed cache, the FIB table also changes when the route table changes. An adjacent table is used to create a layer-2 information table. When a neighbor is found (from the ARP table) and learns its layer-2 information, the adjacent table writes this information into the table and is associated with the layer-3 FIB table in advance.
To quickly find the destination address accessibility information, it still uses the mtree method of Optimum Switching, the only difference is that the mtree node built by CEF does not contain the MAC address of the outbound interface. Instead, it becomes a pointer pointing to a separately created table. CEF uses a forwarding table with four levels of 256 channels at each level to specify the position of the forwarding entry. The forwarding table contains information such as next hop, covering the entire IPv4 address range, A pointer points to another adjacent table. Forwarding entries (such as MAC addresses) are stored in a separate adjacent table. If the preceding steps are complete, a data packet can be forwarded smoothly after it is queried for the destination address after it is entered, greatly saving the CPU resources, in addition, process exchange can be completely discarded. 6. CEF simplifies the Query Process and improves the work efficiency per unit of time. In addition, the routing information and forwarding information are separated from each other. packet forwarding is based only on the forwarding information instead of the routing information. dedicated hardware functions can be fully utilized to achieve line rate forwarding, compared with the first two exchange methods, CEF improves the routing information in an "independent" manner. The advantage of this independence is that it can perform "pre-search ", you do not need to wait until the data packets arrive for the search. It is not subject to route changes or other factors, ensuring high-speed and efficient forwarding. This is the key factor for CEF to speed up. 3. During vro initialization, the CEF creates a route selection table based on the information in the vro software configuration (such as static routing, direct connection routing, and routing selection protocol to exchange dynamically learned routes ). After a route selection table is created, the CPU automatically creates a FIB and an adjacent table. FIB and the neighboring table show the data that appears in the route selection table according to the best forwarding method. Unlike communication stream-based stream caching, the cEF table is based on the network topology. When a group enters a vswitch, the layer-2 forwarding engine ASIC of the vswitch searches for the longest matching value based on the destination network and the most detailed network mask. It does not involve any software except the route selection table and pre-created FIB table. In addition, once the route selection table changes, all cEF tables will be updated immediately. This makes this method highly efficient, and the cache will not be ineffective due to route flip. CEF is more adaptable to network topology changes. In the software form, CEF achieves the separation of routing and switching functions, which does not mean the separation of the physical structure of the router. Therefore, it can also be implemented on some multi-layer switches and low-end routers. Its high speed is manifested in the following aspects:
1> the query method simplifies the process and increases the speed;
2> the routing and forwarding functions are separated. The explanation of CEF has ended. For CEF, It is revolutionary not only because it improves the search method, but also because it has many other features, for example, Server Load balancer has made great progress compared with other switching methods. If we want to enable MPLS, we must use CEF, because only CEF can add tags to the forwarded packets. Summary: looking back at the development of the entire vro Packet Exchange, we can divide it into two categories and four methods. The two types are Process Switching and Interrupt Context Switching. Four Methods: Process Switching belongs to Process Switching, and the other three Fast Switching, Optimum Switching, and CEF (Cisco Express Forwarding) belong to Interrupt Context Switching