Saturday, 10 October 2015

Difference between PROCESS SWITCHING, FAST SWITCHING and CEF

Difference between PROCESS SWITCHING, FAST SWITCHING and CEF

Process Switching
Processed switched relies on the processor to switch packets. With this every packet is inspected by the processor. The original switching mechanism available on Cisco routers was process switching. However, process switching is very slow because it must find a destination in the routing table. Process switching must also construct a new Layer 2 frame header for every packet. As a result, process switching is no longer widely used in modern networks.

With process switching, when a packet comes in, the scheduler calls a process that examines the routing table, determines which interface the packet should be switched to and then switches the packet. The problem is, this happens for the every packet seen on every interface. This is why it is termed as slow.
The benefit of process switching is that is available on every Cisco router platform, regardless of size or age. SNMP traps from the router and telnet packets destined for the router are always process-switched.
There are no specific commands to enable Process switching just disable fast and CEF switching. 

Fast Switching
Cisco IOS platforms have the capability to overcome the slow performance of process switching. The platforms support several switching mechanisms that use a cache to store the most recently used destinations. Fast switching process-switching the first packet in a conversation, then stores the information learned about the destination for the packet in a table called route cache.
A cache uses a faster searching mechanism than process switching does while storing the entire Layer 2 frame header to improve the encapsulation performance. In cache-driven switching, an entry is created in the cache when the first packet whose destination is not found in the fast-switching cache is process switched. Rest of the packets are forwarded per destination basis. This is how the cache improves performance.
With the first packet, the router adds an entry to the fast-switching cache, sometimes called the route cache. The cache has the destination IP address, the next-hop information, and the data link header information (MAC) that needs to be added to the packet before forwarding. Future packets to the same destination address match the cache entry, so it takes the router less time to process and forward the packet.
Fast switching has a few drawbacks. The first packet must be process switched. The cache entries are timed out relatively quickly, because otherwise the cache could get overly large as it has an entry per each destination address, not per destination subnet/prefix. Also, load balancing can only occur per destination with fast switching not per packet basis.
While in the case of Fast Switching the IOS builds the Fast Switching cache entry after switching the first packet, and thus it will depend on the egress interface, thus if the ingress interface was Process or Fast Switching enabled, and the egress interface is Fast Switching enabled, thus the packet will be Fast switched on an interface that is currently process-switching, the interface command "ip route-cache" without arguments will enables fast switching.

Cisco Express Forwarding (CEF)
The most recent and preferred Cisco IOS platform switching mechanism is CEF, which incorporates the best of the previous switching mechanisms. One of the benefits of CEF is that this mechanism supports per-packet load balancing, which was previously supported only by process switching. CEF also supports per-source or per-destination load balancing, fast destination lookup, and many other features that are not supported by other switching mechanisms.
CEF uses a Forwarding Information Base (FIB) to make IP destination prefix-based switching decisions. The FIB is conceptually similar to a routing table or information base. It maintains a mirror image of the forwarding information contained in the IP routing table. When routing or topology changes occur in the network, the IP routing table is updated, and those changes are reflected in the FIB. The FIB maintains next-hop address information based on the information in the IP routing table.
Because there is a one-to-one correlation between FIB entries and routing table entries, the FIB contains all known routes and eliminates the need for route cache maintenance that is associated with switching paths such as fast switching.
CEF is enabled by default on all modern Cisco routers but if one wants to enable it on older routers "ip cef" command is used in global configuration mode. It can also be configured interface basis with command "ip route-cache cef". This command will load balance packets across
equal cost links. Per-destination load balancing is default but CEF support per destination load balancing and per-packet load balancing both, command "ip load-sharing <per-packet/per-destination>" is used.
If fast switching and CEF are both enabled, CEF will try to switch the packet first. If CEF cannot switch the packet, it will direct the packet to the next best available switching path-fast switching. If fast switching cannot process the packet, the router wills process-switch the packet. If all other switching paths are turned off, the router must process-switch all packets. "no ip route-cache” command will disable
CEF and fast switching both. CEF Switching is all about the ingress interface and has nothing to do with the egress interface because FIB is created before a packet is forwarded.
The ip cef global configuration command enables CEF for all interfaces on a Cisco router. The "no ip route-cache cef" interface subcommand can then be used to selectively disable CEF on an interface. On many of the higher-end Cisco platforms, CEF processing can be distributed to the linecards. Similarly, Cisco multilayer switches use CEF for Layer 3 forwarding, by loading CEF tables into the forwarding ASICs.
NOTE: IPv4 fast switching is removed with the implementation of the Cisco Express Forwarding infrastructure enhancements for Cisco IOS For these and later Cisco IOS releases, switching path are Cisco Express Forwarding switched or process switched. This makes the switching decision easier for future development of software features. Starting with the implementation of the Cisco Express Forwarding infrastructure enhancements and the removal of IPv4 fast switching, components that do not support Cisco Express Forwarding will work only in process switched mode.