Octet

What is the difference between a hub, a switch and a router?

Show the answer

Say this first

A hub is layer 1: it repeats every bit out every other port, so all ports share one collision domain and run half duplex. A switch is layer 2: it learns source MACs and forwards each frame only to the port where the destination lives; each port is its own collision domain, but all ports in a VLAN share one broadcast domain. A router is layer 3: it forwards packets between networks by IP address and does not forward broadcasts, so each interface is its own broadcast domain.

Go deeper

Comparison

HubSwitchRouter
Layer123
Decides onNothingDestination MACDestination IP (longest prefix match)
Collision domainsOne for all portsOne per portOne per interface
Broadcast domainsOneOne per VLANOne per interface
DuplexHalf onlyFull on each portFull on each interface
Unknown destinationRepeats everywhereFloods within the VLANDrops (or uses default route)

Details worth adding

  • A switch floods three things inside the VLAN: broadcasts, unknown unicast and multicast without IGMP snooping.
  • A router rewrites the layer 2 header and decrements TTL. A switch forwards the frame unchanged (apart from VLAN tagging).
  • A layer 3 switch does both jobs in hardware. Routers usually win on WAN interfaces, deep buffers, large routing tables and features like NAT, VPN and full BGP tables.

Traps

  • Saying a switch "breaks up broadcast domains". Only VLANs and routers do that.
How did you do?Book 3.2 Switched EthernetBook 3.1 Switching Basics