Cisco Router Forwarding Mechanism Briefly Explained
The primary function of the router is forwarding packets in the direction of their destination. The router received and accepts packets on one interface and forward it out via another interface, this is done by switching function of the router.
A main task of the switching function is to encapsulate packets in the proper data link frame type for the outgoing data link. Cisco routers support three types of packet-forwarding mechanism:
Process switching
This is an older packet forwarding mechanism which is the slowest packet forwarding mechanism. When the packet receives on router interface for processing, the router stores this packet in memory and then the CPU matches the destination address with an entry in its routing table, and then assign the exit interface and forwards the packet.
The router does this process for each incoming packet even if the destination is the same for a stream of packets. Therefore the process-switching mechanism is very slow and rarely implemented in modern networks.
The recent IOS versions have CEF as the default switching method for IP but we can enable process switching using the no ip route-cache interface configuration command in global configuration mode. Process switching solves a problem using math, even if it is the same problem.
Figures 1 illustrate the packet forwarding mechanisms of processed switched. Assume that a traffic flow consisting of three packets and all packets are for the same destination. As shown in Figure, with process switching, each packet must be processed by the CPU one by one.
Fast switching
Fast switching increases the process of switching by making use of a cache and store next-hop information. When the packet arrives on an interface, the router forwards this packet for further process and the CPU search for the match in the fast-switching cache. If it is not there, it is a further process using the process-switched method and forwarded to the exit interface.
The forwarding information for the packet is also sent and stored in the fast-switching cache. If more packets going to the same destination arrive on an interface, the next-hop information in the fast switching cache is re-used without CPU intervention, thus improving on the speed of this switching method.
Fast switching solves a problem using math one time and remembering the answer for next same problems. We use the ip route-cache command in interface configuration mode to enable fast switching, such as.
- Router>enable
- Router# configure terminal
- Router(config)# int fa0/0
- Router(config-if)# ip route-cache
- Router(config)# int fa0/1
- Router(config-if)# ip route-cache
We can verify the fast switching command configuration using show ip int fa0/0 | se ip fast and show ip cache command in user privileged mode. As we discuss that first packet to a destination is always process switched, which slow down and degraded in the event where the router receives a lot of traffic for destinations that stored and cache yet.
It is also, slow and degraded when fast cache invalidated due to route in the routing table changes, fast switching is not suitable where a large number of changing routes like Internet backbone routers occurred.
Figure 2 illustrates the fast switching, where only the first packet of a flow is process-switched and then stored to the fast-switching cache. The next two packets have quickly processed based on the information in the fast-switching cache.
Cisco Express Forwarding (CEF)
This is the method where the cache has built-in advance even before any packets need to be processed. It is the most recent, advanced and fastest mechanism for packet forwarding.
The CEF build a Forwarding Information Base, and adjacency table but the entries are not packet triggered like fast switching. It triggered when there are some changes in the network topology. The CEF solved every possible problem ahead of time in a spreadsheet
So, in the converged network, the Forwarding Information Base and adjacency tables contain all the information when forwarding a packet. The Forwarding Information Base contains pre-computed reverse lookups, next-hop information for routes including the interface and Layer 2 information.
The CEF not waiting for a packet before building the cache which greatly increased the performance of the switching. The configuration process of the CEF is the following:
- Router>enable
- Router# configure terminal
- Router(config)# int fa0/0
- Router(config-if)# ip route-cache cef
- Router(config)# int fa0/1
- Router(config-if)# ip route-cache cef
We can verify the configuration using the show ip cef and show adjacency command in user privileged mode
Figure 3, illustrates the CEF process where the CEF builds the FIB and adjacency tables after the network has converged and processed all packets quickly.