Differences

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

HubSwitchRouter
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 decisionIts MAC address table, learned from the frames it seesIts routing table
Sends a frame to Every other portThe one port its destination was seen on; unknown addresses go out every portThe next hop toward the destination network, in a new frame
Broadcasts Repeated to every portSent out every port: one broadcast domainNot forwarded: each of its networks is its own broadcast domain
Collisions One collision domain, half duplex: one device talks at a timeEach port is its ownEach card is its own
A hop in traceroute NoNo: it does not lower the TTLYes: 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.

Open Network devices: what a hub, switch, router and firewall each do

Sources

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Sign in with Google or email to start.

Start this lab