hop 9 of 32 · 5 min
Hubs, switches and how a frame finds its port
Connecting several machines needs a device in the middle, and which device you use changes the network's behaviour completely.
Hub, switch, router
Hub: repeats every incoming signal to every other port. One shared collision domain, everybody sees everybody's traffic. Obsolete, and useful to understand because a switch is defined against it.
Switch: learns which device is on which port and forwards only there. Each port is its own collision domain, so there are effectively no collisions.
Router: forwards between different networks, using IP addresses rather than MAC addresses.
| Hub | Switch | Router | |
|---|---|---|---|
| Layer | physical | data link | network |
| Decides by | nothing | MAC address | IP address |
| Collision domains | one | one per port | one per port |
| Broadcast domains | one | one | one per interface |
How a switch learns
Nothing is configured. It builds the table from traffic it sees:
1. a frame arrives on port 3 from aa:bb:cc:...
-> record that address as reachable via port 3
2. a frame arrives for dd:ee:ff:...
-> known? forward to that port only
-> unknown? flood to every port except the one it came from
3. the reply teaches the switch where dd:ee:ff isEntries expire after a few minutes so a device that moves is relearned. This is why the very first frame to a new device is flooded and everything after is not.
Circuit and packet switching
Two fundamentally different ways to move data, and the distinction is a standard exam question.
Circuit switching, as in the traditional telephone network: a dedicated path is reserved for the whole conversation. Guaranteed bandwidth and constant latency, and the capacity is wasted during silence.
Packet switching, as in the internet: data is split into packets, each routed independently, sharing links with everyone else. Efficient because idle users consume nothing, at the cost of variable delay and possible loss.
circuit: reserve -> use -> release predictable, wasteful
packet: send each packet independently efficient, variableThe internet chose packet switching, which is why a video call degrades under congestion rather than being refused at the start. A phone call was refused up front and then guaranteed, which is a genuinely different trade rather than a worse one.