6

In my networking class I learned that routers send data to all computers on the network, compared to switches that send data only to the MAC address that is needed.

My question is if devices are connected to a router (like BT-Infinity) by Ethernet cables, do the packets still travel to all devices on the network? Or do they travel only to the MAC address that is needed?

0

6 Answers 6

8

In my networking class I learned that routers send data to all computers on the network, compared to switches that send data only to the MAC address that is needed.

Switches work on layer 2, which uses MAC addresses to identify hosts. A switch can only move frames to another host on that switch. There is an assumption that when you send frames to a MAC address, that it is on the same medium as yourself.

Routers work on layer 3, which uses IP addresses to identify hosts.

IP packets are independent of a medium; addresses not in private ranges are meant to be globally reachable. Layer 3 has the notion of a network to allow it not to care about the actual medium (or anything Layer 2 does).

Obviously though, you have local neighbors (on your switch, for example, or associated to your wireless AP) that are reachable directly, and then hosts you probably want to talk to outside of your network. Thus, the concept of a router or forwarder is needed. Hosts in the same network can reach each other directly, if they are not in the same network, then one or more routers need to hand off traffic between networks.

So routers do not send data to all computers on the network, but forward traffic between networks.

My question is if devices are connected to a router (like BT-Infinity) by ethernet cables, do the packets still travel to all devices on the network, or do they travel only to the MAC address that is needed?

Keep in mind that most consumer "routers" actually are combination of a router and a switch.

If a number of machines are connected to a switch, all devices will receive traffic from a source under these conditions only:

  • The source has sent a broadcast frame (Layer 2 works on frames, not packets) - i.e. a frame to the destination mac FF:FF:FF:FF:FF:FF. This is the broadcast MAC. An IP packet addressed to the networks broadcast address can cause this to happen.

  • The switch does not know which port the destination MAC lives on. So it floods each port with the frame in an attempt to find it. It will remember which port the response comes in on, and in the future, only send traffic for that destination MAC through that port.

  • The switch has forgotten which port the destination MAC lives on. It will do the flooding thing again. Switches can remember a limited number of MAC addresses.

  • Nothing the router does has any bearing.

A hub does not remember MAC addresses and always floods all frames out on all ports. But hubs are not in common use since the 100Mbit days of networking, and I believe only very old routers would have built-in hubs as opposed to a built-in switch. If your router has Gigabit LAN ports, it's 100% sure not a hub.

So basically the frames will travel only to the MAC needed, unless the switch has not seen that MAC before, or it's broadcast MAC.

4

I think you may have a slight misunderstanding of the concept. A true switch only knows about local devices - devices it can talk to directly by MAC address. When a frame enters a switch, the switch looks at the destination MAC address, checks its CAM table for the egress interface, and sends the frame on its way.

A router, on the other hand, goes one step further. A frame enters the router; the router strips the packet from the frame; the router looks at the destination IP address in the packet; the router checks its routing table for the next hop; the router checks its ARP table for the MAC address of the IP of the next hop (or ARPs for the MAC if there is no entry in the ARP table); the router then checks its equivalent of a CAM table for the egress interface; the router then encapsulates the packet into a layer 2 frame and sends it on its way, which could be the destination device or another router to go through this process until the packet eventually arrives at its destination.

So the short answer to your question is no. Like a switch, a router sends the packet only to the next hop device, which could be the destination or another router.

This example ignores multicast, directed broadcasts, flooding, etc.

2
  • So even if the devices are wired routers will send data to all devices on the network and not to individual devices? Is that what you are meaning?
    – iProgram
    Apr 30, 2015 at 13:11
  • 1
    This is a bit incomplete; true, 'real' routers work this way, but most "home gateways" have an actual switch on the LAN side of the router. Apr 30, 2015 at 16:28
3

Who is teaching this class? I would recommend you change class or at least the instructor, because what you have learned is not correct.

You seem to be a bit confused: what do you mean when you talk about "all devices in the network"? Are you talking about IP broadcasts or frame flooding?

When you connect a device to your router via an Ethernet cable, what you are connecting it to is effectively a switch that is embedded in your router. The same thing happens when you buy an off-the-shelf router and you are able to use wireless with it out of the box because it has a built-in access point inside so you don't have to go out and buy an external one yourself.

So to summarize, the wired interfaces on your router are switch interfaces. The router will be able to handle packets flowing into these interfaces even at layer 3, but otherwise they will behave like normal switch ports.

1

On a high level, the hierarchy of capability of network devices is as follows, from smallest to largest feature set:

  • Hub - Receives packets on an external port and rebroadcasts them blindly to all connected client ports. Does not support Network Address Translation (NAT; creation of an isolated internal network/subnet).
  • Switch - Receives packets on an external port, identifies the destinations of each, and retransmits packets only on the ports leading to their actual destinations. Does not support NAT.
  • Router - Effectively the same as a switch, but does typically support NAT.

There are some further differences/subtleties (Ryan's answer describes some), but this gives the general idea.

1

Test it out with Wireshark

One way to differentiate between switching and routing is to see the MAC address of Ethernet frames.

If you get the MAC address of the other computer directly, it's acting like a switch.

If you get the MAC address of the router, it's acting like a router.

E.g. you could test this by pinging computer 2 from computer 1 terminal 1:

ping 192.168.1.102

and then on computer 1 terminal 2:

sudo wireshark -f 'host 192.168.1.102 and icmp' -k

You can then see the packet disassembly to decide, and compare with the MAC addresses obtained with:

ip a

from both machines.

On my TP-Link archer VR2800, I observe switch behavior both on Ethernet and Wi-Fi.

Tested on two Ubuntu 23.10 machines.

0

The packets travel only to the device(s) with the the specified MAC address(es). A hub instead would send the packets to all devices.

To support my argument here is a page supporting my answer: http://en.wikipedia.org/wiki/Router_%28computing%29

If the router would send the packets to every host, it would be nonsense to determine the ultimate destination.

This only describes the unicast packets, of course the router can send broadcast and multicast packets where multiple hosts will be addressed.

5
  • Thanks for the answer. Just clarify what I am thinking Home Hubs (like BT-Infinity) act like routers even though they are home 'hubs'. Am I correct?
    – iProgram
    Apr 30, 2015 at 13:00
  • @iprogram, Please ask questions about home services on Super User. Apr 30, 2015 at 13:04
  • Im not familiar with this kind of product but from what I can see on their product page, they just the name it 'hub' but it is indeed a router.
    – Jan Pflugmacher
    Apr 30, 2015 at 13:05
  • @JanPflugmacher Thought so. Glad to know I was paying attention to class!
    – iProgram
    Apr 30, 2015 at 13:06
  • @MikePennington I was asking if it was a hub or a router. That is to do with networking more then home services isn't it?
    – iProgram
    Apr 30, 2015 at 13:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .