Sub topic 3
Why switches replaced hubs
This chapter assumes you know what a MAC address is, what the fields of an Ethernet frame are (destination MAC, source MAC, EtherType), and that hubs, switches and routers do different jobs. It explains the problem a hub has and why a switch needs a MAC address table to solve it.
What a hub does
A hub is a layer 1 repeater. It does not read frames. When a signal arrives on one port, the hub regenerates it and sends it out of every other port. Every attached host receives every frame. Each host's network card then checks the destination MAC and discards frames not meant for it.
All ports on a hub share one collision domain. This is the set of devices whose transmissions can interfere with each other. If two hosts transmit at the same moment, their signals collide and both frames are corrupted. Ethernet handles this with CSMA/CD (carrier sense multiple access with collision detection). A host listens before sending, detects a collision, stops, waits a random time and tries again.
This causes three problems:
- Shared bandwidth. A 100 Mb/s hub gives 100 Mb/s to all hosts combined.
- Half duplex. A host cannot send and receive at the same time, because both would use the same shared medium.
- No privacy. Any host can capture traffic meant for others.
As more hosts join, collisions rise and throughput falls.
What a switch changes
A switch reads the destination MAC address in each frame. It sends the frame only toward the port where that address is found. Each switch port is its own collision domain. With one host on a port, there is nothing to collide with, so the port can run full duplex: sending and receiving at the same time at full link speed.
| Property | Hub | Switch |
|---|---|---|
| OSI layer | 1 | 2 |
| Reads MAC addresses | No | Yes |
| Collision domains | One for all ports | One per port |
| Duplex | Half | Full |
| Bandwidth | Shared | Dedicated per port |
Why the table is needed
A switch must know which port leads to each MAC address before it can send a frame to one port only. An administrator could enter these mappings by hand, but that does not scale and breaks whenever a cable moves. Instead, the switch builds a MAC address table by itself from the traffic it sees. The next chapters cover what the table stores and how it is filled.
A switch still sends some frames out of many ports. Broadcasts always do, and so do frames whose destination it has not learned yet. For those frames it behaves like a hub, but only for as long as it lacks the information.
Exercise
Ten hosts connect to a 100 Mb/s hub, and later to a 100 Mb/s switch with one host per port. How do the collision domains and the bandwidth available to each host differ?
Show answer
On the hub, all ten hosts share one collision domain and 100 Mb/s of half-duplex bandwidth. On the switch, each host has its own collision domain, so there are ten. Each host gets a dedicated 100 Mb/s full-duplex link, and collisions cannot occur on a port with a single host.