Cisco Routers' Routing Processes and Switching Processes
Routing and switching processes are two of the most essential tasks performed by routers. Some people in the internetworking field have a little difficulty with the idea that routers perform switching, but of course everybody is comfortable with the fact that routers perform routing. Nonetheless, as you will see, the distinctions between these operations will be quite useful in optimizing the router's performance. In the following paragraphs the concepts of routing and switching are defined. A discussion then follows about the benefit of distinguishing among these tasks while troubleshooting and about methods for examining the distinct processes and components of the routing and switching process.
Switching is commonly defined as the process that takes charge of moving data units (frames or packets) through the anatomy of internetworking devices. From the time data units arrive at an interface until they leave the router, several issues need to be constantly addressed. Where is the data unit stored? What type of information should accompany the data unit? Where does the data unit go next? How is the next destination determined? And which statistics need to be collected about this data unit? As you can imagine, the mere task of moving a data unit (a packet, in the context of routers) from one place to the next is one of the simplest and least resource-consuming internetworking tasks.
Routing can be simply defined as the operation that attempts to select an output interface and perhaps a next hop for a packet based on the packet's destination address. Different routing processes perform the task of routing different protocols' packets. For example, the IP routing process, which is enabled by default, handles routing of IP packets. The routing process makes its routing decision by consulting its routing table, which it builds and maintains dynamically. The sources of information of a routing process for building its routing table are
The network segments that the router is actively connected to.
The usable static routes available in the router configuration.
The dynamic routing entries that the routing protocols offer.
The routing policies or restrictions that are imposed.
The usable default routes available.
Imagine that a router (call it R1) is receiving a bunch of packets from its ethernet 0 interface and all of these packets have the same destination address.When the router receives the first layer 3 packet (call it P1), the data link header (layer 2 frame) is discarded and the packet stored in the E0 interface's buffer. Next, the packet will be moved through R1's internal bus into main memory, then stored in a packet buffer where it will wait its turn to be examined by the routing process. It is important to note that the packet is accompanied by additional information such as the interface the packet entered the router from. When it is P1's turn, the routing process uses the destination address of the packet and the routing table to select an interface for the packet to leave the router from. Finally, a frame appropriate to that interface must be created. This entails building a frame header, usually composed of layer 2 addressing and perhaps other information such as protocol type.
Notice that during this process the packet is moved by the switching process from one place to another (from the interface internal buffer to the main memory, for instance) several times. Hence, the first packet (P1) must be handled by both the routing and the switching processes. Performing both routing and switching tasks on a packet is called process switching. Now think about the second packet (call it P2) that has the same destination as P1. Does P2 have to be routed and switched (i.e., process switched) as well? The answer is usually negative.
To enhance efficiency and speed, the experience gained from the effort spent (through the routing task) on the first packet (P1, in our example) can be reused. P1's destination address and the outgoing interface (selected by the routing process) can be stored in a place referred to as a switching cache, and can be reused for quick processing of the subsequent packets (P2, P3, and so on, which have the same destination address as P1). Inside the switching cache, the router needs to store the first packet's destination address along with the output interface number. The information stored in the switching cache is used to quickly discover the output interface for the following packets (destined for the same network as P1), without having to perform the time-consuming task of routing on each of them.
You must remember that the router also caches information such as MAC addresses (in the ARP cache) so that it does not have to generate an ARP request for every packet. Hence, when dealing with a number of packets (with identical destination addresses) arriving at the router one after the other, the router must perform both the routing and the switching task on the first packet.
To process the following packets, using the information kept in the switching cache, the router can skip the routing task. This is commonly referred to as route caching (and loosely speaking, also called fast switching). Please keep in mind that there are more operations and tasks involved in the processing of each packet, most of which have to be performed for each packet individually. For example, security tasks (checking access lists) and accounting/queuing tasks still need to be performed for each packet (except in case of Netflow switching, which is presented later in this chapter).
Since the routing task is more resource consuming, is more complex, and introduces a longer latency, skipping this operation on all the packets except the first (all with the same destination address) is very advantageous and efficient. When a packet (such as P2) is not process switched (not subjected to routing), the packet is said to be fast switched. The switch cache, where the network layer destination address and the corresponding selected output interface (based on processing of the first packet) are stored, can be on one or more of the router's components. Where that information is stored depends on the type of router and its components, and based on that, the cache is referred to by a special term.