Switches
Hub
The switch's ancestor: it repeats every frame out of every port, so everyone hears everything.
The problem
A hub sends every frame to every port, so each device hears traffic meant for the others.
- Alice (
10.0.1.10), bob (10.0.1.11) and carol (10.0.1.12) each have one cable to the same box. - Alice pings bob. A hub keeps no table, so it copies her frame out of bob's port and carol's.
- Bob's reply is copied to alice and carol the same way: carol hears both sides.
- Only one device can send at a time; two at once collide, so everyone shares the wire (half duplex).
What you'd see
$ tcpdump -e -nn -i eth0 icmp
18:49:15.165904 b6:a0:12:30:a8:0b > 06:c7:51:36:4e:b8, ethertype IPv4 (0x0800), length 98: 10.0.1.10 > 10.0.1.11: ICMP echo request, id 68, seq 1, length 64
18:49:15.165918 06:c7:51:36:4e:b8 > b6:a0:12:30:a8:0b, ethertype IPv4 (0x0800), length 98: 10.0.1.11 > 10.0.1.10: ICMP echo reply, id 68, seq 1, length 64
18:49:16.224820 b6:a0:12:30:a8:0b > 06:c7:51:36:4e:b8, ethertype IPv4 (0x0800), length 98: 10.0.1.10 > 10.0.1.11: ICMP echo request, id 68, seq 2, length 64
18:49:16.224848 06:c7:51:36:4e:b8 > b6:a0:12:30:a8:0b, ethertype IPv4 (0x0800), length 98: 10.0.1.11 > 10.0.1.10: ICMP echo reply, id 68, seq 2, length 64
- Recorded on carol, with the switch told to forget every MAC at once (
ageing_time 0), so it floods everything like a hub. b6:a0:… > 06:c7:…: from alice's card to bob's. Carol's MAC is in neither field, yet the frame reached her.echo requestandecho reply: she hears both directions of a conversation she is not part of.
Guess first
Carol runs the same recording on a normal switch that has learned alice and bob. What does she see?
Show answer
Nothing: the switch sends alice's frames only to bob's port and bob's only to alice's. That is why sniffing works on a hub and not on a switch.
In short
A hub has no table and makes no decisions: a frame in on one port goes out of all the others, and only one device can talk at a time (one collision domain, half duplex). A switch learns which address is behind which port and sends each frame only where it belongs. That is also why sniffing works on a hub and not on a switch, unless the switch is tricked into flooding (MAC flooding) or the attacker gets in the middle.
Read next
- Switch Joins devices into one network, forwarding each frame toward the port its destination MAC was seen on.
- MAC flooding Filling a switch's MAC table with made-up addresses so that it floods everyone's frames to every port.
- MAC address table A switch's record of which port each MAC address was last seen on, learned from source addresses.
- Duplex and speed Whether a link's two ends may send at the same time, and how fast: agreed by auto-negotiation, or set by hand.