"Process switching requires the CPU to be personally involved with every forwarding decision.
Fast
switching still uses the CPU, but after a packet has been forwarded,
information about how to reach the destination is stored in a
fast-switching cache. This way, when another packet going
to the same destination is seen, the next hop information can be re-used
from the cache, so the processor doesn’t have to look up and assemble
all the information again. If the information is not cached, (for example a first packet for a given destination network) the CPU will have a similar workload, for that packet, as if fast switching was not in use.
Cisco Express Forwarding (CEF), is the evolution of optimizing the router to make it be able to forward more packets faster. CEF cheats a little, by building a Forwarding Information Base (FIB), and an adjacency table. The
FIB is accessed very quickly based on how they built it (it is Cisco
proprietary), and contains pre-computed reverse lookups, next hop
information for routes including the interface and L2 information to
use. (All the stuff a router would have to consider when forwarding a packet).
In short:
Process switching is like doing math, long hand.
Fast
switching, using the cache, is like doing a problem once long hand, and
subsequent problems you remember the answer for, (from memory, or the
cache).
CEF is like having programmed an excel spreadsheet, and when the numbers hit the cells, the answer is already calculated.
Best wishes,
Keith (Barker)"
What is CEF?
Definition from Cisco.com :
Cisco Express Forwarding (CEF) is
advanced, Layer 3 IP switching technology. CEF optimizes network
performance and scalability for networks with large and dynamic traffic
patterns, such as the Internet, on networks characterized by intensive
Web-based applications, or interactive sessions.
To understand this better, one has to understand why and how CEF came
about. With Cisco IOS there are different Switching Methods, that
define how packets are forwarded through a router. The first method,
which happens to be the oldest and slowest is Process-Switching.
Alternatively when packets arrive, the interface processor can
interrupt the central CPU and asks it to switch the packet according to a
route cache or switching table. That cache or table can be built in
several ways, the two of interest here are Fast-Switching and CEF.
With Process-Switching,
when a packet enters the router the Layer-2 info is stripped off, the
packet is then copied to the CPU memory where a L3 lookup is performed,
and any other CPU required features, like NAT, queuing, compression
etc, along with any other housekeeping like lowering the TTL,
recalculating the CRC are done, before the frame is rewritten with the
new L2 destination address and sent to the outgoing interface. The Big,
the Bad and the Ugly!
With Fast-Switching, the first packet in a flow is
still copied to the CPU for the L3 lookup and housekeeping, before being
rewritten with the L2 destination address. The switching of the first
packet by the central CPU gives the CPU the opportunity to build a cache
called the fast-switching cache, which is used to switch all subsequent packets for the same destination using the same switching path across the router. With
Fast-Switching the cache is only built on demand, which can be time
consuming when huge numbers of potential destinations are involved. To
avoid this a pre-build cache was needed, and thus CEF was born.
With CEF (Cisco Express Forwarding), there are two main data structures:
- The Adjacency-Table :
is responsible for the MAC or Layer 2 rewrite. This adjacency can be
built from ATM, Frame Relay map statements, dynamic information learned
from Ethernet-ARP, inverse ARP on ATM, or Frame Relay. The Layer 2
rewrite string contains the new Layer 2 header which is used on the
forwarded frame. For Ethernet, this is the new destination and source
MAC address and the Ethertype. For PPP, the Layer 2 header is the
complete PPP header, including the Layer 3 protocol ID.
- FIB (Forwarding Information Base) Table
: The CEF table/FIB table holds the essential information, taken from
the routing table, to be able to make a forwarding decision for a
received IP packet. This information includes the IP prefix, the
recursively evaluated next hop, and the outgoing interface.
The CEF process flow:
- When a packet enters the router, the router strips off the Layer 2 information.
- The router looks up the destination IP address in the CEF table (FIB), and it makes a forwarding decision.
- The result of this forwarding decision points to one adjacency entry in the adjacency table.
- The information retrieved from the adjacency table is the Layer 2
rewrite string, which enables the router to put a new Layer 2 header
onto the frame,
- The packet is switched out onto the outgoing interface toward the next hop.
To enable Proccess-Switching on a interface you have to disable Fast-Switching and CEF that is enabled by default:
#no ip route-cache
#no ip cef
To enable Fast-Switching on a interface use the following command:
#ip route-cache
To display the IP Fast-Switching Route-Cache :
#show ip cache [verbose] [prefix mask]
To enable CEF globally (Default = Enabled) :
#ip cef
To enable CEF on the interface :
#ip route-cache cef
To see the CEF Adjacency Table, the [detail] option displays the L2-Rewrite string:
#show adjacency [detail]
To see the CEF FIB Table:
#sh ip cef [prefix]