Packet.School
HomeLevelsSandboxFreeAbout
XP0
L4 · Network Devices
Level 4
5 lessons
  • 01Hub vs Switch
  • 02Router
  • 03Build Network Topology
  • 04Firewall
  • 05Level 4 Quiz
Levels/L4 · Network Devices/Lesson 01
Simulation · 01

Hub vs Switch

Both connect devices; the difference fits in one sentence: a hub shouts, a switch whispers. That difference explains why modern networks are built on switches.

Duration
3min
Level
L4
Type
Simulation
Progress
1/ 5

01Hub

A hub works at OSI Layer 1 (Physical) — it doesn't understand the incoming signal, it just copies it.

code
       Hub
    /   |   \
  PC1  PC2  PC3

PC1 → Hub → send to everyone (broadcast)

Its properties

  • No intelligence: copies incoming data to every port
  • If two devices talk at once, you get a collision
  • Bandwidth is shared across all ports
  • Everyone sees everyone's traffic — zero security

Every device on a hub shares one collision domain: the line is a single lane and everybody drives in it.

02Switch

A switch works at OSI Layer 2 (Data Link) — it reads and learns MAC addresses.

code
       Switch (MAC table)
    /    |    \
  PC1   PC2   PC3

PC1 → Switch → deliver only to PC2 (unicast)

Its properties

  • Keeps a table of which MAC lives on which port
  • Forwards a frame only to its destination port
  • Every port is its own collision domain — no collisions
  • Every port gets full bandwidth
  • Traffic is only visible to the parties involved

The MAC address table

PortMAC address
1AA:BB:CC:DD:EE:01
2AA:BB:CC:DD:EE:02
3AA:BB:CC:DD:EE:03

The switch learns this table by itself: it notes the source MAC of every frame arriving on a port. If it sees a destination it doesn't know yet, it briefly acts like a hub and asks everyone (flooding).

03Comparison

FeatureHubSwitch
OSI layerLayer 1Layer 2
Decision logicNoneMAC table
ForwardingBroadcastUnicast
CollisionsYesNo
BandwidthSharedFull per port
SecurityNoneTraffic isolated

04Example scenario

With a hub: PC1 sends a file to PC2 → the hub copies it to PC3 and PC4 too → they discard it ("not for me"). Result: wasted traffic + a line anyone can eavesdrop.

With a switch: PC1 sends a file to PC2 → the switch checks its table → forwards only to Port 2. Result: efficient and isolated.

05Try it yourself

You don't have to read about this difference — you can watch it:

Sandbox · BuilderNetwork BuilderWire PCs to a hub, then a switch; fire the same packet and watch broadcast vs unicast play out.Open tool

06Summary

  • Hub = Layer 1, copies everything to everyone
  • Switch = Layer 2, delivers only to the target via its MAC table
  • A switch gives every port its own collision domain
  • Hubs are gone from modern networks; they survive as a teaching tool
Previous
Level 3 Quiz
Next
Router
On this page
  • Hub
  • Switch
  • Comparison
  • Example scenario
  • Try it yourself
  • Summary
Packet.School

An open, interactive curriculum for computer networking.

v3.0 · MIT22 lessons live

Learn

  • Lessons
  • Sandbox
  • Levels
  • Free
  • About

Simulations

  • Packet Journey
  • DNS Lookup
  • DHCP Simulator
  • Subnet Calc
  • Network Builder
  • Terminal

Project

  • About
  • Changelog
  • GitHub
  • Contributing
  • Style guide

Newsletter

One short email when a new level ships. No tracking pixels.

© 2026 Packet.School — MIT licensedSupport with a coffeebuilt in the open