In a word, intelligence.
Hubs, switches, and routers are all devices that let you connect one or more computers to other computers, networked devices, or even other networks. Each has two or more connectors called ports, into which you plug the cables to make the connection.
Varying degrees of magic happen inside each device — and therein lies the difference.
Become a Patron of Ask Leo! and go ad-free!
- Hubs are “dumb” devices that pass on anything received on one connection to all other connections.
- Switches are semi-intelligent devices that learn which devices are on which connection.
- Routers are essentially small computers that perform a variety of intelligent tasks.
If a message1 comes in destined for computer “A”, that message is sent out to all the other ports, regardless of which computer “A” is.
When computer “A” responds, its response also goes out to every other port on the hub.
Every computer connected to the hub “sees” everything every other computer on the hub does. It’s up to the computers themselves to decide if a message is for them and whether or not it should be paid attention to. The hub itself is blissfully ignorant of the data being transmitted.
For many years, hubs were quick and easy ways to connect computers in small networks. In recent years, hubs aren’t as common, and switches have come into greater use.
A switch does what a hub does, but more efficiently. By paying attention to the traffic that comes across it, it learns which computers are connected to which port.
Initially, a switch knows nothing, and simply sends on incoming messages to all ports.
Just by accepting that first message, however, the switch has learned something: it knows on which connection the sender of the message is located. Thus, when machine “A” responds to the message, the switch only needs to send that message out to the one connection.
By processing the response, the switch has learned something else: it now knows on which connection machine “A” is located. That means subsequent messages destined for machine “A” need only be sent to that one port.
Switches learn the location of the devices they are connected to almost instantaneously. The result is, most network traffic only goes where it needs to, rather than to every port. On busy networks, this can make the network significantly faster.
A router is the smartest and most complicated of the three. Routers come in all shapes and sizes, from small, four-port broadband routers to large industrial-strength devices that drive the internet itself.
One way to think of a router is as a computer2 that can be programmed to understand, manipulate, and act on the data it handles.
A router operates as a switch for basic routing: it learns the location of the computers sending traffic, and routes information only to the necessary connections.
DHCP — Dynamic Host Configuration Protocol — is how dynamic IP addresses are assigned. When it first connects to the network, a device asks for an IP address to be assigned to it, and a DHCP server responds with an IP address assignment. A router connected to your ISP-provided internet connection will ask your ISP’s server for an IP address; this will be your IP address on the internet. Your local computers, on the other hand, will ask the router for an IP address, and these addresses are local to your network.
NAT — Network Address Translation- – is the way the router translates the IP addresses of packets that cross the internet/local network boundary. When computer “A” sends a packet, the IP address that it’s “from” is that of computer “A” — 192.168.0.1, in the example above. When the router passes that on to the internet, it replaces the local IP address with the internet IP address assigned by the ISP — 126.96.36.199, in the example. It also keeps track, so if there’s a response the router knows to do the translation in reverse, replacing the internet IP address with the local IP address for machine “A”, and then sending that response packet on to machine “A”.
A side effect of NAT is that machines on the internet cannot initiate communications to local machines; they can only respond to communications initiated by them. This means that the router also acts as an effective firewall.
Malware that spreads by trying to independently connect to your computer over the network cannot do so.
All routers include some kind of user interface for configuring how the router treats traffic. Really large routers include the equivalent of a full-blown programming language to describe how they should operate, as well as the ability to communicate with other routers to describe or determine the best way to get network traffic from point A to point B.
What about wireless?
Of the devices we’ve discussed, only routers can be wireless. The wireless component is simply another way of making a connection to the device. For example, a wireless router might have four physical network connections to which cables can be connected, but the wireless component allows many more devices to connect over the air.
A note about speed
One other thing often mentioned with these devices is network speed. Most devices now are capable of both 100mbps (100 megabits, or million bits, per second) as well as 1gbps (one gigabit, or billion bits per second), and automatically detect speed.