Comparison diagram of a hub, a switch and a router and the OSI layer each one works at
Category: Network+ course

From the outside, hubs, switches and routers look alike: a box with some ports. The difference is what they do with a packet when it arrives. Once you know that, network design and troubleshooting get much easier.

Hub: layer 1, everything to everyone

A hub understands no addresses. Any signal arriving on one port is sent out of every other port. The result:

  • Everyone is in one collision domain, so only one device can talk at a time.
  • It works half-duplex, and the network slows down as more devices are added.
  • Anyone can see everyone else's traffic.

Hubs have all but disappeared from the market, but the exam still asks about them.

Switch: layer 2, based on MAC addresses

Every network card has a six-byte MAC address, such as 00:1A:2B:3C:4D:5E. A switch learns which MAC is behind which port and sends each frame only to that port:

  1. A frame arrives on port 3; the switch records the source MAC against port 3 in its MAC table.
  2. If it knows the destination MAC, it sends the frame only to that port.
  3. If it doesn't, it sends this one frame to everyone (flooding) and learns from the reply.

Each switch port is its own collision domain and runs full-duplex. But all ports are still in one broadcast domain, so a broadcast reaches everyone.

On a Cisco switch you view the MAC table like this:

show mac address-table
show mac address-table interface GigabitEthernet1/0/5

ARP: the bridge between IP and MAC

To send a packet on the local network, a computer needs the destination MAC. The ARP protocol asks with a broadcast, "who has this IP?", and the owner replies with its MAC. View the Windows ARP table with arp -a.

VLANs: several networks on one switch

With VLANs you split one physical switch into several separate logical networks; for example, cameras, phones and users each get their own VLAN. Each VLAN is a separate broadcast domain, so camera broadcasts don't reach computers, and security improves too.

  • An access port belongs to one VLAN and connects to a computer or camera.
  • A trunk port carries several VLANs, tagged with 802.1Q, between switches or up to a router.

Router: layer 3, based on IP addresses

A router connects different networks: the internal network to the internet, or the finance VLAN to the server VLAN. It decides where to send each packet based on the destination IP and its routing table. A router doesn't forward broadcasts, so each of its ports is a separate broadcast domain.

Most routers do other jobs too: NAT for sharing an internet connection, firewalling, DHCP and VPN. MikroTik is a familiar example.

What is a layer 3 switch?

A layer 3 switch is a switch that also routes between VLANs, in hardware and much faster than a router. In enterprise networks, internal routing between VLANs is usually done by the core switch, and the router or firewall is left only for the internet connection.

Summary in one table

DeviceLayerForwards byCollision domainBroadcast domain
Hub1Nothing; sends to allOne for allOne
Switch2MAC addressOne per portOne (or one per VLAN)
Router3IP addressOne per portOne per port

Network+ course parts

  1. The OSI and TCP/IP models made simple
  2. IP addresses, classes and subnetting
  3. Hub vs switch vs router
  4. TCP, UDP and important network ports
  5. How DNS and DHCP work
  6. Network cabling: Cat5e, Cat6, Cat6A and fibre
  • Network+
  • CompTIA Network+
  • switch vs router
  • hub
  • MAC address
  • VLAN
  • layer 3 switch