Networking basics
Hub vs. Switch vs. Router: What Is the Difference?
Three devices that connect computers, three different jobs. Learn what each does through a simple office example.
Imagine an office with three computers and a printer
The computers need to send documents to the printer and open websites. Printing within the office and reaching a server elsewhere involve different network jobs. A hub, switch and router may look like similar boxes with cable sockets, but they handle those jobs differently.
Think of the hub as repeating a message around the room, the switch as directing it to a particular desk, and the router as sending it toward another building. This analogy describes their basic roles; real equipment can combine several functions.
A hub repeats incoming signals
An Ethernet hub repeats a signal received on one port to the other ports. It does not learn which device is attached where. The connected devices share a collision domain, so simultaneous transmissions can interfere and need to be retried.
In the office analogy, everyone hears the announcement even when only the printer needs it. Ethernet hubs are mostly legacy equipment today. A USB hub is a different device; the shared name does not make it an Ethernet network hub.
A switch learns where local devices are
A basic Ethernet switch learns source MAC addresses, the link-layer addresses in Ethernet frames, and associates them with ports. For a known destination, it forwards the frame to the relevant port. Full-duplex switched links avoid the shared-cable collisions of a hub.
A switch still floods broadcasts and unknown destinations to eligible ports within the same VLAN. A VLAN is a logical separation within the network. Switching therefore does not mean that every frame is always sent to just one device, nor does it make the network automatically secure.
A router forwards traffic between networks
A router examines destination IP addresses and uses a routing table to select the next hop. Your computer normally sends traffic for other networks to its default gateway, often the office router.
For example, a printer on the same local subnet can be reached through the switch. A hosted website on another network is reached through the gateway. Routers can also connect internal networks, such as staff and guest networks. Firewall rules determine which communication is permitted when such controls are configured.
The differences at a glance
These are the basic roles. A Layer 3 switch can also route, and a home broadband box often combines several of these functions.
| Device | Decision basis | Main job |
|---|---|---|
| Hub | No destination lookup | Repeat signals to other ports |
| Layer 2 switch | MAC address table | Forward frames within a local network or VLAN |
| Router | IP routing table | Forward packets between IP networks |
Why your home router also has Wi-Fi and Ethernet ports
The box sold as a home router commonly includes a router, an Ethernet switch and a Wi-Fi access point. It may also include a modem or optical connection equipment. A separate access point connects wireless devices to the local network; it does not have to perform routing.
When expanding a network, identify the missing function. More wired connections usually call for switching. Wireless coverage calls for access points. Communication between networks calls for routing and suitable access controls. Check uplink capacity and the whole path before assuming an extra box will make the Internet faster.