Thursday 11 October 2012

11 - L3 Switching - Understanding CEF Optimization


A foundation look at what exactly CEF is and how it works:








When switch boots up, everything has to be learnt (routes etc) this is then copied down to the FIB
FIB = Forwarding Information Base (Which is a high speed cache in the ASIC)

The ADJ table holds all the Layer 2 information (Mac etc)

Now once the switch has booted up, the switch proactivly checks all the routes in the FIB and then finds all the MAC addresses for the next hop addresses (upstream routers/L3/static etc)

So by the time this switch/router is ready to forward packets it already has the entire routing table cached and it has all the ARP mappings/next hop MAC addresses.

So now when a packet comes into the router/switch it comes straight into the hardware, looks at hardware cache /routing table, has MAC already, swaps the header and out it goes at WIRE SPEED at LAYER 3!

So all inter-vlan traffic, routed ports and routing all happens in CEF at wire speed. Major advantage




Now days all L3 switches come with CEF enabled by default, meaning you have to disable it if you dont want it.

to enable
conf t
ip cef

handy command/feature to find bandwidth hogs (ip cef traffic-statistics)




You can run the command on the VLANS,:


so the switch has all these prefixes/routes in its FIB, also if we check the ARP table we can see this has been
moved in the adjacency table for CEF, 


So when copying data from one host to another in different VLANS, we dont need an routing lookups (we have it all already), it has it all already and off it goes!