What is the difference between a hub, a switch and a router?
EasyConceptNetwork Basics & Devices
Answer
A hub works at the physical layer (layer 1) and simply repeats every incoming signal out of all its other ports. A switch works at the data link layer (layer 2) and forwards each frame only to the port where the destination MAC address is connected, using a MAC address table. A router works at the network layer (layer 3) and forwards packets between different networks using IP addresses and a routing table.
- All hub ports share one collision domain (the devices whose transmissions can collide), so performance drops as devices are added.
- A switch learns MAC addresses from the source of each frame and floods only unknown or broadcast frames; each switch port is its own collision domain.
- A router separates broadcast domains (the set of devices a broadcast reaches) and connects a LAN to other networks, such as the internet.
Example: PC A on port 1 sends a frame to PC C on port 3. A hub copies it to ports 2, 3 and 4. A switch that has learned C → port 3 sends it only to port 3. If the destination is a web server on the internet, A sends the frame to the router, which forwards the packet towards the server's network.