And where do wireless routers and modems fit in?
In a word, intelligence.
Hubs, switches, and routers are all devices that connect computers to other computers, networked devices, and 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, switches, and routers
- 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.
- Wireless routers and access points are devices that add Wi-Fi support to your network.
If a message1 comes in destined for computer “A”, the hub sends that message to all the other ports, regardless of where computer “A” is.
When computer “A” responds, the hub send its response 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. 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 as a hub would.
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, not to “B” or “C”.
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. As a result, most network traffic only goes where it needs to, rather than to every port. On busy networks, this can make the entire 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 the 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 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 effectively acts as a 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.
There are two other devices that can be associated and/or confused with hubs, switches and routers. They perform some of the same tasks, but wirelessly. While we’re here, let’s define wireless access points and wireless routers.
Wireless access point
A wireless access point, or WAP, is similar to a hub or switch. It has no complicated intelligence.
Its job is to exchange messages between the wired connection — usually to a router and one or more devices connected to Wi-Fi.
A “wireless router” is just a router and a wireless access point combined in a single box.
It’s important to understand the difference between a wireless router and an access point. You really only want one router on your network, but you can add as many access points as you like.
Beware: The term “router” is often used to refer to both routers and wireless routers. Make sure you know what you’re dealing with when purchasing or configuring your own.
A note about speed
One other thing often mentioned about these devices is network speed. Most devices now are capable of both 100 mbps (100 megabits, or million bits, per second) as well as 1 gbps (one gigabit, or billion bits per second), and automatically detect speed.
Now that you know all the different devices available and how they relate, you might want to review how your own home network is set up. How Should I Set Up My Home Network? will guide you through the most common home configurations.
Subscribe to Confident Computing as well! Less frustration and more confidence, solutions, answers, and tips in your inbox every week.
Footnotes & References
1: I use “message” here to keep things conceptually simple. The more correct term would be “packet,” as each of these devices operate on discrete packets of information traveling on the network.