Back to all articles
HardwareLayer 1Layer 2Layer 3SwitchRouter

Hub vs Switch vs Router: Understanding the Hardware of Networking

David ChenJuly 21, 2024

If you walk into a server room and look at a rack of networking equipment, it all looks remarkably similar. It's mostly just flat metal boxes with dozens of Ethernet ports and aggressively blinking green lights.

But not all boxes are created equal. Historically and functionally, network hardware is divided into three distinct categories: Hubs, Switches, and Routers.

Understanding the difference between them is the quickest way to understand the first three layers of the OSI model. Let's break them down.

The Hub: The Dumb Broadcaster (Layer 1)

Imagine a small room with five people in it. They all speak different languages, but they all have megaphones. When Person A wants to say something to Person C, they don't walk over and whisper. They just yell it into the megaphone. Everyone in the room hears it, but only Person C pays attention. If Person B tries to talk at the exact same time, the two voices crash into each other, creating a garbled mess, and they both have to stop and try again.

This is exactly how a Hub works.

A Hub is a pure Layer 1 (Physical Layer) device. It is incredibly stupid. It has absolutely no brains, no memory, and no understanding of network addresses.

When an electrical signal (a frame of data) comes into Port 1 on a Hub, the Hub simply takes that electrical signal, amplifies it, and blasts it out of every single other port simultaneously.

Because of this, all devices connected to a Hub share the same bandwidth. If two computers try to transmit at exactly the same microsecond, the electrical signals physically collide on the wire, corrupting the data. This is called a Collision Domain. The computers detect the collision, wait a random number of milliseconds, and try again.

Hubs were cheap and popular in the 1990s, but they are catastrophically inefficient. Today, they belong in museums. You cannot buy a Hub anymore; they have been entirely replaced by Switches.

The Switch: The Intelligent Traffic Cop (Layer 2)

If a Hub is a room full of megaphones, a Switch is a highly efficient telephone switchboard operator.

When you plug computers into a Switch, the Switch actively listens and learns. It pays attention to the MAC Addresses (the physical hardware addresses) of the devices plugged into its ports.

A Switch is a Layer 2 (Data Link Layer) device. It has memory. It builds an internal database called a MAC Address Table.

  • "Ah, MAC address AA:AA is on Port 1."
  • "MAC address BB:BB is on Port 4."
  • When Computer A (Port 1) wants to send data to Computer B (Port 4), it sends the Ethernet frame to the Switch. The Switch opens the frame, looks at the Destination MAC Address, checks its internal table, and says, "I know exactly where that is."

    Instead of blasting the data out of every port like a Hub, the Switch creates a temporary, dedicated electrical connection *only* between Port 1 and Port 4.

    This means Computer C and Computer D can be talking to each other at the exact same time without causing any collisions. A Switch eliminates collisions entirely, allowing every device to use the full bandwidth of the network simultaneously.

    Switches are the backbone of all modern local networks (LANs).

    The Router: The Global Navigator (Layer 3)

    Switches are brilliant at moving traffic *within* a single local network. But they are completely blind to the outside world. A Switch only understands MAC addresses, which are only valid locally. If a Switch receives a packet destined for a Google server, it has no idea what to do with it.

    To talk to a different network, you need a Router.

    A Router is a Layer 3 (Network Layer) device. It doesn't care about MAC addresses (except for its immediate physical connections). It cares about IP Addresses.

    While a Switch connects computers together, a Router connects *networks* together.

    Imagine you are mailing a letter.

  • The **Switch** is the mail carrier walking down your specific street, handing letters to specific houses based on the name on the door (MAC address).
  • The **Router** is the regional post office sorting facility. It looks at the zip code (IP address), figures out which city the letter needs to go to, and loads it onto the correct airplane.
  • When your computer wants to load a webpage, it sends the data to the Switch. The Switch forwards it to the Router. The Router rips off the Layer 2 Ethernet frame, inspects the Layer 3 IP packet, consults its massive Routing Table, and decides which of its external internet connections is the best path to reach the destination. It then wraps the packet in a new frame and sends it on its way.

    The Blurring Lines: Layer 3 Switches and Home Routers

    If the definitions above seem perfectly neat and tidy, prepare to be slightly annoyed by modern marketing and engineering.

    In enterprise environments, engineers realized that sending traffic up to a Router every time two local VLANs needed to talk was slow. So they built Layer 3 Switches. These are incredibly fast Switches that have routing software built directly into the silicon. They can route IP packets between local subnets at wire-speed, without needing a dedicated standalone Router box.

    On the consumer side, the box sitting in your living room that your ISP gave you is universally called a "Router." But it's actually a chimera. A home "Router" is actually four different devices crammed into one plastic shell:

    1. A Router: To route traffic between your home network and the ISP.

    2. A Switch: Those four yellow Ethernet ports on the back? That's a built-in Layer 2 switch.

    3. A Wireless Access Point: The antennas that broadcast WiFi.

    4. A Firewall/NAT device: To protect your network and translate IP addresses.

    So, the next time you look at a blinking network box, ask yourself: Is it moving data based on physical hardware addresses, or is it navigating the global map of IP addresses? That is the difference between switching and routing.