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.
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 – 2015-04-30T13:11:37.850
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. – user1686 – 2015-04-30T16:28:09.497