cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
5932
Views
25
Helpful
15
Replies

Layer 3 routing Vs Layer 3 switching

sathyasav
Level 1
Level 1

Hello,

Can someone brief me out the differene between layer 3 routing and layer 3 switching.

I got this doubt when i am reading CEF.

As per my understanding,

Layer 3 routing is what the router does----->Learning the routes via routing protocol and forwarding the packets based on the routing table information.

Layer 3 switching is what the CEF does---->Forwading the packets in hardware based on the FIB and ADjacency table information. 

1 Accepted Solution

Accepted Solutions

sathyasav wrote:

Hi Jon/Peter,

After reading your posts and some other posts,i am geeting more doubts.i am posting those things below.please help me with your answer.

1)Difference between software CEF and hardware CEF?

2)Does router use CEF to forward the packets.If yes then which CEF it uses,hardware CEF or Software CEF?

3)Difference between CAM and TCAM?What menmory L3 switches uses for hardware switching TCAM alone or both TCAM and CAM.

Please reply ASAP as i am scratching my head for the answer.

1) As far as i know all L3 switches use hardware based CEF.  Most routers ie. 88x up to 7200 use software based CEF. Some of the high end routers eg ASR/GSR have dedicated hardware chips so they use hardware based CEF but for routers these are the exception rather than the norm.

2) See 1)

3) The CAM table is the mac-address table on a switch. It is where the switch records mac-addresses to ports.

The TCAM is specialised memory in hardware that stores things such as access-list entries etc. so they can handled in hardware.

Jon

View solution in original post

15 Replies 15

Jon Marshall
Hall of Fame
Hall of Fame

sathyasav wrote:

Hello,

Can someone brief me out the differene between layer 3 routing and layer 3 switching.

I got this doubt when i am reading CEF.

As per my understanding,

Layer 3 routing is what the router does----->Learning the routes via routing protocol and forwarding the packets based on the routing table information.

Layer 3 switching is what the CEF does---->Forwading the packets in hardware based on the FIB and ADjacency table information. 

Not really.

L3 switching is basically a term used for routing in hardware as opposed to routing in software. CEF is just an optimised lookup table for L3 forwarding so both L3 routing and L3 switching can and do use CEF.

Simply put L3 switches have dedicated hardware chips (ASICs) for forwarding packets at both L2 and L3.

Routers generally don't have dedicated ASICs for L3 forwarding ie. it is done using the main CPU.

Hence the reason L3 switches have much better forwarding rates than routers although routers are more flexible in what they can do.

Jon

hi jon,

thanks for your prompt response.

CEF is just an optimised lookup table for L3 forwarding so both L3 routing and L3 switching can and do use CEF.---->can you explain this line little more.

My another question: Does router (which performs software switching) use CEF or this CEF is only used by switch.i guess CEF operation is only in switch but need more clarification on this.Please share your knowledge regarding this.

Thanks in advance

Jon,

Basically switching is a term used for any mechanism that defines treatment of how packets entering the device will exit the device. So in short switching is how packets enters and leaves a device. Practically all platforms uses some form of switching. There are currently 3 switching methods.

Software Switching (a.k.a process switching)

Fast switching

CEF switching

Process switching uses CPU to make the forwarding decission of any packets i.e. lookup from routing table , arp table... etc.

Fast switching same mechanism in a better way that it only sends the first packet through process level and caches its forwarding decission in cache and uses this result against subsequent packets of the same flow.

CEF uses more enhanced version of approach. It uses the routing table to builds it FIB (forwarding information base) and ARP cache to build ARP adjacency table. CEF programs these two table as one in hardware and a single CEF lookup in hardware provides the next-hop , ARP resolution to next-hop and etc stuff required for forwarding decision. Since this all is programmed before data could even flow and is always in sync with software. Hence faster , reliable and scalable.

L3 Routing is just about protocols that helps you discover reachability to destination. So router does both switching and routing and use software CEF to make fast decisions.

If you find this post usefull, please rate!!

-

Rgds,

Sebastian Fernandez

Sebastian, Jon,

First of all - Jon, I am more than happy to read your posts here again!

Wonderful - a discussion about principial terms and fundamental principles It is true, and I agree with Sebastian, than in a strict sense of the word, the switching relates to moving a datagram from an ingress to an egress interface, and the related decision work needed to select the outbound interface properly. Hence, even a router does switching.

On the other hand, I am somewhat reluctant to accept the definition of the term routing as "the sum of control-plane processes necessary to set up the data structures in the forwarding plane, without taking part in actual packet delivery". I would say that most articles and books about routing actually refer to routing as the process of selecting a path for a datagram, i.e. there is a definitive involvement in the actual packet delivery. Of course, from this point of view, the switching and routing terms overlap - and they probably should, for none of them is precise technical word; on the contrary, both of them are colloquial terms just adopted to describe certain processes in networking.

In a more free sense, or better said, in network engineer's daily routine, the words routing and switching indeed bear a connotation of how/where the process of path selection is implemented. I have always personally understood the L3 switching and L3 routing as functionally equivalent (both yielding the same result), yet differently implemented. I agree with Jon here that the L3 routing usually refers to making the routing decisions using the universal/main CPU of the router, while the L3 switching refers to hardware-assisted routing in ASICs (VIPs, RPs, TCAMs, whatever...).

The terminology about process switching, fast switching, CEF switching etc. is purely a Cisco lingo, and as much as I acknowledge it, I would not take it for a universally valid terminology. Also, I have to point out one misconception that seems to be widely adopted: even with CEF, there is no guarantee of any hardware-assisted routing. The CEF is about decomposing the routing information and frame rewrite information, and about holding these informations in data structures usable for very fast lookups. However, the CEF is not necessarily about having any of these structures in a specialized hardware. Even with CEF, an ISR or ISR G2 router principially performs software-based routing because both the FIB and ADJ tables are stored in the main memory - the FIB is a trie (a prefix tree), the ADJ an indexed table. There are still multiple lookups necessary on ISR/ISRG2 routers in the CEF FIB table to traverse the tree and actually arrive at the correct routing decision, and these lookups are performed by the CPU. Only on devices utilizing TCAMs (multilayer switches), the FIB is downloaded to the TCAM and the lookup is thus performed in the TCAM. So once again, CEF is about making the data structures necessary for path selection and frame rewrite nice, tidy and searchable very fast, but in no way it implies any hardware support for that.

Best regards,

Peter

L3 Routing is just about protocols that helps you discover reachability to destination

I agree with a lot of what you say but as with Peter, i would argue that the above is only one part of routing ie. the control plane. There is also the forwarding of the data which you refer to as switching.

On a L3 switch these functions are separated eg. the MSFC on a 6500 is responsible for the control plane and the PFC is responsible for the data plane. The PFC forwards packets in hardware. The performance hit on a 6500 is usually when packets cannot be forwarded by the PFC but have to be sent to the MSFC. The MSFC does not forward packets in hardware to my knowledge hence the reason that the more packets the MSFC has to forward the worse performance you get from the 6500.

On a router these functions are not separated by hardware to my knowledge. Both the control plane and the data plane are handled by the routers main CPU hence the reason performance on an equivalent router is so much poorer.

So to me when we talk about L3 switching we are talking about where the forwarding of the data takes place ie. hardware or software not how it is done. To say routing is only really to do with the control plane is IMO misleading and could lead to a lot of confusion.

Interestingly the original use of L3 switching was to distinguish it from routing because before the advent of L3 capable switches everybody knew that L2 switching was fast and routing (and i use routing in terms of forwarding packets) was slow. When L3 switches became available the term L3 switching was used to in effect say that forwarding of packets at L3 could now be as fast as L2.

Jon

Hi Jon,

Very nicely written.

Best regards,

Peter

Peter

Many thanks.

Was just wrting you an e-mail actually so expect one soon.

Jon

Jon,

I surely will!

Best regards,

Peter

Hi jon,peter,sebastian,

Thanks for you all.Jon you are awesome in replying to the query.

so as per the above conclusion,

L3 routing is populating the routing table and forwading the packets in software (what the router does)

L3 switching is forwading in hardware(ASIC) with the help of CEF.(what the layer 3 switch does)

Am i right.

sathyasav wrote:

Hi jon,peter,sebastian,

Thanks for you all.Jon you are awesome in replying to the query.

so as per the above conclusion,

L3 routing is populating the routing table and forwading the packets in software (what the router does)

L3 switching is forwading in hardware(ASIC) with the help of CEF.(what the layer 3 switch does)

Am i right..

Your statement about routing is correct.

Your statment about L3 switching is partially correct.  Routers use CEF as well. As Peter said, the use of CEF does  not say anything about whether the packet is hardware or software switched.  Also even with L3 switching the routing table has to be populated and is done in software on hardware switches.

Jon

Hi Jon,

Thanks a lot for your awesome answer and now am clear about the things which we discussed.

Routing in Router(Forwarding L3 packets)-----First it learns the routing information and populates the routing info in routing table (L3 routing) and forwarding packets which is called switching i.e data plane operation.CEF forwards the packet in software using its FIB and adjacency table info which they have lerned form IP routing and arp table.

Routing in Switch(Forwarding L3 packets)-----First it learns the routing information and populates the routing info in routing table (L3 routing) and forwards the packet in Switch hardware rather than in software which is a default behaviour of the router.

So basically switch and router both do the L3 routing for learning the destination info and CEF in both the router and switch forwards the packets, but in router CEF forwars that in software and in switch it does in hardware(ASIC).

Hi Jon/Peter,

After reading your posts and some other posts,i am geeting more doubts.i am posting those things below.please help me with your answer.

1)Difference between software CEF and hardware CEF?

2)Does router use CEF to forward the packets.If yes then which CEF it uses,hardware CEF or Software CEF?

3)Difference between CAM and TCAM?What menmory L3 switches uses for hardware switching TCAM alone or both TCAM and CAM.

Please reply ASAP as i am scratching my head for the answer.

sathyasav wrote:

Hi Jon/Peter,

After reading your posts and some other posts,i am geeting more doubts.i am posting those things below.please help me with your answer.

1)Difference between software CEF and hardware CEF?

2)Does router use CEF to forward the packets.If yes then which CEF it uses,hardware CEF or Software CEF?

3)Difference between CAM and TCAM?What menmory L3 switches uses for hardware switching TCAM alone or both TCAM and CAM.

Please reply ASAP as i am scratching my head for the answer.

1) As far as i know all L3 switches use hardware based CEF.  Most routers ie. 88x up to 7200 use software based CEF. Some of the high end routers eg ASR/GSR have dedicated hardware chips so they use hardware based CEF but for routers these are the exception rather than the norm.

2) See 1)

3) The CAM table is the mac-address table on a switch. It is where the switch records mac-addresses to ports.

The TCAM is specialised memory in hardware that stores things such as access-list entries etc. so they can handled in hardware.

Jon