If I have a LAN and and connect it with a switch, I understand it uses a CAM table to route packets in layer 2 (by saving mac to port relations). So far all good.

However, when using a router for a LAN (ONLY for a LAN, not to connect it to "the outside" WAN/internet/etc) I get a bit confused as to how it internally processes packets. I would first split this into two router scenarios:

Router with buit-in switch

In this scenario, I would expect that it will act exactly as a switch with a CAM table internally. This would probably benefit a bit in speed (guessing here?) compared to the next option.

Router without built-in switch

Here is where I get confused. If hostA wants to send a packet to hostB, it will ARP to find hostB's MAC address and send it there. Now, if we had a switch (above scenario) this would be easy. But how does it work now in a router WITHOUT a switch?

If I would guess, hostA would send an Ethernet frame with hostB's MAC address to the line. The router would fetch the packet (even though the router has another MAC address, it would still fetch this packet even if it only contains hostB's MAC address). It would strip the Ethernet frame header and check the IP, and then check its own internal ARP table again for the MAC address.

Now, this would seem like a waste of resources compared to a router with a built-in switch. But maybe it does not work like that at all. Does it also contain a CAM table? If that would be true, what would then the difference between these two routers really be?

closed as not a real question by Ward, Kenny Rasschaert, TomTom, ewwhite, Sven Dec 8 '12 at 19:21

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 4
    You are confused about what a router does. – Ward Dec 8 '12 at 18:04
  • 2
    Also voting to close. This is an interesting question, but it is sort of the question you get answered BEFORE going to a pro board. It is pretty much a "get a book and learn how networks work" level question, and this is a place for people doing this stuff in professional environments. Too basic, sorry. – TomTom Dec 8 '12 at 18:49
  • Admittedly my question could maybe have been better. However, if it is an interesting question maybe more would want to know the answer. If you didn't understand it, it would be better to point out what was not understandable or where the logic is wrong. Thanks. – servernewbie Dec 8 '12 at 19:56
  1. a LAN isn't a physical entity. a LAN is a logical construct created by connecting 2 or more network hosts to a common network infrastructure that allows those hosts to communicate with each other across said network infrastructure.

  2. Switches don't route network traffic, they forward (or switch) network traffic. Routing implies Layer 3. A switch, when it's performing switching functions, operates solely at Layer 2 and doesn't route traffic. When a Layer 3 switch is performing routing functions it is acting as a router, not a switch. When you talk about Layer 2 operations you refer to it as switching or forwarding and when you talk about Layer 3 functions you refer to it as routing. A Layer 3 switch can do both but a distinction has to be made between switching functions and routing functions, because they occur at different layers of the OSI/DOD model (switching vs. routing, respectively).

  3. In your "router without a switch" scenario: Assuming that the router has two or more interfaces and that hostA and hostB are each connected to a different interface, the router would ROUTE traffic from hostA to hostB. The router does not switch/forward traffic in the way that a switch does (ignoring for the moment any discussion of bridging on the router). That means that hostA ARPs for it's Default Gateway, which is the router and then sends the traffic there. The router then ARPs for hostB and then ROUTES the traffic from one interface (the interface connected to hostA) to the other interface (the interface connected to hostB). hostB then ARPs for it's DG (the router) and sends the return traffic there. Because a router operates at Layer 3 it has an ARP cache but does not have a CAM table. It does not track what MAC addresses are connected to what ports (MAC address to port mapping) because it doesn't switch/forward traffic at Layer 2. It maintains an ARP cache (ip address to MAC address mapping) because it routes traffic at Layer 3.

  4. A router with a built in switch does both Layer 2 switching and Layer 3 routing. When it is switching it FORWARDS traffic from one port to another based on its CAM table. When it is routing it ROUTES traffic from one network to another based on its routing table.

  • Thanks joeqwerty! Good answers. One follow-up question for point 3. If hostA and hostB are on the same network identifier (same LAN), then would what you say still hold true? Online documentation mostly says that hostA it would just ARP for hostB directly, not looking at the DG (even when they have a DG such as a router). – servernewbie Dec 8 '12 at 19:53
  • Yes. If hostA and hostB are connected to the same Layer 2 network and are in the same Layer 3 network then the traffic will be sent directly between the two, so hostA will ARP for hostB. Traffic only transits a router when that traffic is not local to the hosts in that Layer 3 network. – joeqwerty Dec 8 '12 at 21:27
  • That it was confuses me. If hostA is connected to a port on the router, and hostB to another port on the router, the traffic has to go through the router. To me it sounds like it would do what you describe in 3, but your latest answer says it would ARP directly. But traffic has to transit through the rouher "physically" at least. What am I missing? – servernewbie Dec 8 '12 at 21:49
  • I think you're misunderstanding what I'm saying. If hostA and hostB are in the same LAN (the same Layer 3 network) then they will communicate directly. If hostA and hostB are on different Layer 3 networks then they will communicate with their respective DG. If they are each connected to a different router interface they will communicate with the router because the router interfaces are routed interfaces, they are not switch ports. Each router interface is a different network. – joeqwerty Dec 9 '12 at 2:48
  • Glad to help... – joeqwerty Dec 9 '12 at 18:31

Not the answer you're looking for? Browse other questions tagged or ask your own question.