1

I generally understand how L2 switching works. I want to understand how a switch and router work together to send traffic to a device off the L2 network.

For example. Computer A tries to send traffic to computer B for the very first time. Computer B is in a different subnet on the other side of a router. The switch does not find computer B in its MAC address table and floods the network to find it. Computer B is not in the broadcast domain and is not found.

So, how do the switch and router work together to take the traffic onto the router and route it to the destination device?

Specifically, does the router know that it should accept any floods and then investigate the traffic for an IP address in the header? I am not even sure if a frame on a switch would have an IP address included or even have a header. :)

Thanks all!

1
  • Did any answer help you? if so, you should accept the answer so that the question does not keep popping up forever, looking for an answer. Alternatively, you could post and accept your own answer.
    – Ron Maupin
    Dec 23, 2021 at 16:57

2 Answers 2

2

The switch isn't involved in "getting traffic to the Router".

The Host knows the traffic needs to get to the Router because the Host knows the target is on a foreign network.

When the Host sends the traffic to the Router, the L3 header will have the Source and Destination IP address of the Initial and Target host. And the L2 header will have the Source and Destination MAC address of the Initial Host and the Router. That is what will get the packet to the Router, which will then take it from there.

This is what "directs traffic to the Router" -- and the Switch is merely in the path to help it along.

I'd recommend these videos to understand Hosts and Switches:

Disclaimer: I created these videos and am suggesting them because I believe they will help you

3
  • Hey Eddie. Great answer. That is really helpful. Thanks for the quick reply. I will check out your videos tomorrow. Cheers, -R Feb 17, 2021 at 5:00
  • I watched the first video and it was exactly what I was looking for. Very well done, Eddie. Looking forward to the other videos tomorrow. Feb 17, 2021 at 5:25
  • @RobertJohnson Glad you enjoyed them. =)
    – Eddie
    Feb 17, 2021 at 23:10
1

I want to understand how a switch and router work together to send traffic to a device off the L2 network.

The L2 network is the mechanism for L3 nodes to get their packets transported. When two neighbor nodes in a shared subnet talk to each other, they determine the destination's MAC address (by ARP or NDP) and send the encapsulating frame to that address (assuming a MAC-based L2 like Ethernet).

When the destination is not in the same subnet, the encapsulating frame is sent to the respective gateway instead.

Computer B is in a different subnet on the other side of a router. The switch does not find computer B in its MAC address table and floods the network to find it.

No, for the first part. The source node checks its routing table first. That check either determines that the destination is within the same subnet (=> ARPed and sent to directly) or which gateway is required. If the source cannot determine a gateway (no route to destination) it cannot send the packet. The switch isn't involved in that.

If the switch didn't know the destination MAC address of a frame it would indeed flood the frame, but since the router's MAC has already been learned (and all the other local ones as well) there's very rarely a need to do so.

Since the router is also just an L2 node, it would ignore all received frames that are not addressed to its own MAC address or a broadcast address - so flooding a remote MAC wouldn't help. Also, A would have a hard time finding out B's MAC address as ARP uses (local) broadcasting to find the destination MAC - and broadcasts cannot not cross a router. In a nutshell, remote MAC addresses are meaningless, they're only useful within a shared broadcast domain.

1
  • Hey Zac67, that was also a really helpful perspective. Especially this part, "No, for the first part. The source node checks its routing table first. That check either determines that the destination is within the same subnet (=> ARPed and sent to directly) or which gateway is required." Thanks to the both of you for the quick replies! -R Feb 17, 2021 at 15:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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