Compared
Hub vs switch vs router
A hub repeats every frame out of every port. A switch learns which MAC address is behind which port and sends each frame only there. A router joins separate networks and forwards packets between them by IP address.
Side by side
| Hub | Switch | Router | |
|---|---|---|---|
| Reads | Nothing: it repeats the signal (layer 1) | The frame's MAC addresses (layer 2) | The packet's IP addresses (layer 3) |
| Decides by | No table, no decision | Its MAC address table, learned from the frames it sees | Its routing table |
| Sends a frame to | Every other port | The one port its destination was seen on; unknown addresses go out every port | The next hop toward the destination network, in a new frame |
| Broadcasts | Repeated to every port | Sent out every port: one broadcast domain | Not forwarded: each of its networks is its own broadcast domain |
| Collisions | One collision domain, half duplex: one device talks at a time | Each port is its own | Each card is its own |
| A hop in traceroute | No | No: it does not lower the TTL | Yes: it lowers the TTL by one |
Each one explained
- Hub
- The switch's ancestor: it repeats every frame out of every port, so everyone hears everything.
- Switch
- Joins devices into one network, forwarding each frame toward the port its destination MAC was seen on.
- Router
- A device on several networks that forwards packets between them, by destination address.
- MAC address table
- A switch's record of which port each MAC address was last seen on, learned from source addresses.
- Broadcast domain
- The set of devices a broadcast reaches: one network at the link layer.
See the difference on real machines
Each lab is a small network of real Linux machines in your browser.
- Network devices: what a hub, switch, router and firewall each do
- Learning switches: how a box with no list finds every machine
- Routing tables: how a router picks one line out of many
Open Network devices: what a hub, switch, router and firewall each do