Hub: repeat everything (layer 1)
A hub is the simplest device. It has no intelligence: any signal arriving on one port is repeated out of every other port. It does not read MAC or IP addresses; it only copies electrical signals, so it works at layer 1 (chapter 11).
B and D receive the frame, see a destination MAC that is not theirs (chapter 7), and drop it. The bandwidth was used anyway.
Wide by design - scroll it sideways.
- One shared medium. Only one device can send at a time. If two send at once, the signals collide and both must retry after a random wait (the old Ethernet rule called CSMA/CD).
- Half duplex: send or receive, never both at once.
- Everyone sees everything: any device can capture all traffic on the hub.
All devices on a hub are one collision domain. With more devices, collisions grow quickly and throughput falls apart. Hubs are obsolete; you will meet the idea mostly in exams and old buildings.
Switch: learn, then forward (layer 2)
A switch is the smart replacement. It reads each frame's MAC addresses (layer 2) and keeps a MAC address table: which MAC lives behind which port. It builds that table by itself:
| # | Step | What the switch does |
|---|---|---|
| 1 | Learn | A frame arrives on port 3 from MAC 3c:7c:3f:10:22:01, so that MAC is behind port 3. Write it down. |
| 2 | Look up | Find the destination MAC in the table |
| 3a | Forward | Known: send it out of that one port only |
| 3b | Flood | Unknown, or the broadcast MAC ff:ff:ff:ff:ff:ff: send it out of every port except the one it came in on |
| 4 | Age out | Forget entries not seen for a while (typically 5 minutes), so moved devices are relearned |
- Every port is its own collision domain, and links are full duplex: send and receive at once, no collisions at all.
- Many conversations at once: A ↔ B and C ↔ D run in parallel at full speed.
- Switches do not change frames and have no IP address on the data path (managed switches have one for their admin page).
Router: between networks (layer 3)
A router connects different networks. It reads the destination IP address (layer 3) and uses its routing table to pick the next hop (chapter 12). Switches move frames within a network; routers move packets between networks. On the way through, a router:
| 1 | Accepts only frames addressed to its own MAC (the "gateway" MAC the sender found with ARP, chapter 9) |
| 2 | Removes the frame, reads the IP header, looks up the destination network (longest prefix match) |
| 3 | Lowers the TTL and updates the checksum; may NAT (chapter 10) and filter (firewall) |
| 4 | Builds a new frame on the outgoing interface, with its own MAC as source and the next device's MAC as destination |
| 5 | Does not forward broadcasts (section 7) |
Watch frames move through a network
Here is a small version of Kadé's office. The staff network uses a switch; imagine the warehouse still had an old hub. Pick a sender and a receiver, send frames, and watch the switch learn. (ARP is assumed to be already done.)
- forwarded to one port
- flooded / repeated to all
- accepted · ignored (got a copy) · sender, written under each device
Try: send Front desk → Printer twice (flood, then forward), then Printer → Front desk. Then send inside the warehouse and compare.
| Switch MAC table | Port | Device |
|---|---|---|
| empty: the switch has learned nothing yet | ||
Hub, switch and router compared
| # | Hub | Switch | Router | |
|---|---|---|---|---|
| 1 | Layer | 1 · physical | 2 · data link | 3 · network |
| 2 | Reads | nothing (signals) | MAC addresses | IP addresses |
| 3 | Keeps a table of | - | MAC → port (learned) | network → next hop (routes) |
| 4 | Sends a frame to | every port | the right port (floods if unknown) | the next hop, in a new frame |
| 5 | Connects | devices, in one network | devices, in one network | networks |
| 6 | Collision domains | one for all ports | one per port | one per port |
| 7 | Broadcast domains | one | one (per VLAN, section 8) | one per interface: it separates them |
| 8 | Duplex | half | full | full |
| 9 | Changes the packet? | no | no | yes: TTL, checksum, MACs, maybe NAT |
| 10 | Today | obsolete | everywhere inside networks | every network edge |
Who a frame is for: unicast, broadcast, multicast
| # | Kind | Destination MAC | A switch sends it to | Examples |
|---|---|---|---|---|
| 1 | Unicast | one device's MAC | that device's port (once learned) | Almost everything: HTTP, SSH, DB queries |
| 2 | Broadcast | ff:ff:ff:ff:ff:ff | every port | ARP requests (chapter 9), DHCP Discover (chapter 27) |
| 3 | Multicast | a group MAC, e.g. 01:00:5e:… (IPv4) or 33:33:… (IPv6) | every port, unless the switch tracks group members (IGMP snooping) | IPv6's NDP (chapter 30), video to many screens |
Broadcast domains
A broadcast reaches every device in its network, but routers do not forward broadcasts. Everything a broadcast can reach is one broadcast domain. In the office, the router makes two:
Wide by design - scroll it sideways.
This is a big reason to split large networks into subnets (chapter 3). In one flat network of 2,000 devices, every ARP request and DHCP Discover interrupts all 2,000; as devices multiply, background broadcast traffic grows until the network slows down. Subnets keep each broadcast domain small, and give a router a place to apply firewall rules between groups.
VLANs: several networks on one switch
Buying a separate switch for every network gets expensive. A managed switch can be split into VLANs (virtual LANs): ports 1-8 belong to VLAN 10 (staff), ports 9-16 to VLAN 20 (warehouse). They behave like two separate switches: separate MAC tables and separate broadcast domains. Traffic between VLANs must go through a router, like any traffic between networks.
| Access port | Belongs to one VLAN; the connected device knows nothing about VLANs (a PC, a printer) |
| Trunk port | Carries many VLANs on one cable, each frame marked with a 4-byte VLAN tag (802.1Q). Used between switches, and to the router ("router on a stick": one cable, one sub-interface per VLAN). |
| Guest WiFi | A classic use: visitors on their own VLAN, reaching the internet but never the office printers or PCs |
Loops and spanning tree
People often connect switches with two cables for backup. Without protection, that creates a loop, and a single broadcast circles forever, since Ethernet frames have no TTL (chapter 12). Each switch floods it again, copies multiply, and within seconds the whole network is saturated: a broadcast storm.
Managed switches run Spanning Tree Protocol (STP, or its faster version RSTP): they talk to each other, find loops, and block the extra links, keeping them as backups that switch on if the main path fails. Cheap unmanaged switches usually lack it, which is how one wrong cable in a small office can take everything down.
The full journey, device by device
Putting it together: the front desk PC (staff network) prints a shipping label on the warehouse label printer (172.16.2.20):
| # | Device | Reads | Frame src → dst MAC | Does |
|---|---|---|---|---|
| 1 | Front desk PC | its mask | front desk → router eth1 | Sees 172.16.2.20 is another network, so sends to the gateway (chapters 4-5) |
| 2 | Staff switch | MACs | (unchanged) | Forwards out of the router's port only |
| 3 | Router | IP | router eth2 → label printer | Routes to eth2, lowers TTL, builds a new frame |
| 4 | Warehouse switch | MACs | (unchanged) | Forwards out of the label printer's port only |
| 5 | Label printer | everything | - | Its MAC and IP match: unwraps up to the print job (chapter 11) |
Summary
| # | Idea | In one line | New terms |
|---|---|---|---|
| 1 | Hub | Layer 1; repeats everything; one collision domain; half duplex; obsolete | hub, collision domain, CSMA/CD |
| 2 | Switch | Layer 2; learns MAC → port; forwards or floods; full duplex | MAC address table, flooding |
| 3 | Router | Layer 3; routes between networks; rewrites MACs; stops broadcasts | |
| 6 | Casting | Unicast, broadcast (ff:ff…), multicast (group MACs) | IGMP snooping |
| 7 | Broadcast domain | Everything a broadcast reaches; routers are the edges; keep them small | broadcast domain |
| 8 | VLANs | Split one switch into separate networks; trunks carry tagged frames | VLAN, 802.1Q, trunk |
| 9 | Loops | Redundant links cause broadcast storms; STP blocks the extras | broadcast storm, STP |
Try it yourself
All broadcast and multicast frames in your broadcast domain
- What to look for: ARP, DHCP, mDNS (
01:00:5e:00:00:fb), IPv6 NDP (33:33:…). - From section: 7. Broadcast domains
sudo tcpdump -n -e -i en0 broadcast or multicastUnicast frames that reached you
- What to look for: Almost only your own traffic: the switch forwards others' frames elsewhere.
- From section: 2. Switch: learn, then forward (layer 2)
sudo tcpdump -n -e -i en0 not broadcast and not multicastThe routers on your path
- What to look for: Switches never appear: they do not touch TTL.
- From section: 3. Router: between networks (layer 3)
traceroute 1.1.1.1A real switch's learned table
- Steps: Managed switch CLI:
show mac address-table - What to look for: MAC → port → VLAN, with dynamic entries aging out.
- From section: 2. Switch: learn, then forward (layer 2)
show mac address-tableWhich ports belong to which VLAN
- Steps: Managed switch CLI:
show vlan brief - What to look for: Staff and warehouse ports in separate VLANs.
- From section: 8. VLANs: several networks on one switch
show vlan brief