1. The Story
Press "Next" to go through it step by step. In each step, a character appears and explains what they are doing.
Prologue: A Quick Review
Step 1 of 13
How Octo delivers today
Remember me? I'm a Switch. I read the recipient's MAC Address (hardware address) on the Frame, and if I know it, I send the Frame only to that one Port (cable socket).
Animation text version (all steps)
- Prologue: A Quick Review
- How Octo delivers today · Octo: Remember me? I'm a Switch. I read the recipient's MAC Address (hardware address) on the Frame, and if I know it, I send the Frame only to that one Port (cable socket).
- Details: Network Story 1, "Octo's First Day: How a Switch Delivers"
- Act 1: The Age of Hubs
- Professor Arpa's time machine · Professor Arpa: A long, long time ago... well, actually in the 1990s, most LANs (Local Area Networks) didn't have Octo yet. Back then, people plugged their network cables into a box called a Hub.
- 1973: Ethernet is born; at first, all computers share one coaxial cable
- 1990: the 10BASE-T standard appears, so twisted-pair cables can connect to a Hub
- The Hub ignores name tags · Pip: Mac wants to send a photo to the desktop computer. The Hub doesn't look at the MAC Address on my backpack at all. It just boosts the electrical signal it receives and sends it out of all the other Ports.
- A Hub only handles electrical signals, so it is a Layer 1 device
- It doesn't learn, and it has no MAC Address Table
- The TV gets mail that isn't its own · Pip: The TV got me too. It checks the recipient:
00:00:5E:00:53:04. That isn't the TV, so it has to throw me away. Every single Frame has to be checked like this, which wastes time. - Everyone shares one line · Professor Arpa: Devices connected to a Hub are really sharing the same line. So only one device can talk at a time; while one is sending, the others have to wait.
- This "take turns to send or receive" mode is called Half-duplex, like a walkie-talkie
- A 10 Mbps Hub: all the devices share those 10 Mbps
- Bang! A crash · Pip: Oh no! Mac and the TV sent at the same time. The two signals smashed into each other on the line and turned into noise nobody can read. This is called a Collision, and both pieces of data have to be sent again.
- Listen before you talk: CSMA/CD · Professor Arpa: Engineers came up with a set of rules called CSMA/CD (Carrier Sense Multiple Access with Collision Detection): listen before sending; only start when the line is free; keep listening while sending, and stop at once if there's a collision.
- ① Carrier Sense: first listen for anyone talking
- ② Multiple Access: when it's quiet, anyone can talk
- ③ Collision Detection: on a collision, send a Jam Signal to tell everyone
- Each waits a random time · Pip: After the crash, Mac and the TV each wait a random amount of time before trying again. Because their waits are different, this time Mac sends first, and the TV hears the line is busy, so it patiently waits again.
- This random wait is called Backoff
- The more collisions, the wider the range of waiting times to choose from
- More devices mean more collisions, and a slower network
- Act 2: Octo Takes Over
- One lane per Port · Octo: Later on, Switches like me got cheaper and cheaper, and replaced Hubs. Each of my Ports is its own separate lane, and I send a Frame only to the recipient's Port, so even if two computers send at the same time, there's no collision.
- Sending and receiving together · Octo: A device connected directly to my Port can even send and receive at the same time, just like a phone call. This is called Full-duplex. Since there are no collisions, CSMA/CD can take a rest.
- Half-duplex: take turns to send or receive, like a walkie-talkie (Hub)
- Full-duplex: send and receive at the same time, like a phone (Switch)
- Where crashes happen: Collision Domain · Octo: A group of devices that will collide if they talk at the same time is called a Collision Domain. All the devices on a Hub make 1; on me, each Port is its own 1.
- Hub + 3 computers: 1 Collision Domain
- Switch + 3 computers: 3 Collision Domains
- But a Broadcast still goes to everyone · Pip: Watch out: if the recipient is a Broadcast, Octo still sends it to every Port. The area a Broadcast can reach is called a Broadcast Domain. Neither a Hub nor a Switch splits it up.
- To split up a Broadcast Domain, you need a Router or a VLAN (Virtual LAN), covered in later stories
- Summary: the predecessor retires · Professor Arpa: Hubs were simple and cheap, and served early LANs for many years. But they made everyone share one line and crash into each other a lot. Today's networks have almost all switched to Switches, and the Hub has retired with honour.
- Hub: Layer 1, sends to every Port, shared line, has Collisions
- Switch: Layer 2, sends only to the correct Port, each Port independent, no Collisions
- Neither splits up the Broadcast Domain
2. Where Is the Problem
Imagine a classroom where only one student can speak at a time. If two students start talking together, nobody can hear anything clearly, and both of them have to say it again.
That is exactly what happens to computers connected to a Hub, a simple box that links network cables together:
- Everyone gets everything. A Hub sends every Frame out of all the other Ports (cable sockets). Every computer has to check each one and throw away the ones not meant for it.
- Everyone takes turns. All the devices share the same "line", so only one device can send at a time.
- Talk at the same time and you crash. If two devices send together, their signals smash into each other and turn into noise. This is called a Collision, and both pieces of data have to be sent again.
The more devices there are, the more often they collide, and the less speed each one gets.
3. How the Network Solves It
Step 1: set some speaking rules. Like in a meeting: "Listen first, and only speak when nobody else is talking. If you bump into someone, stop, and each wait a bit before trying again." This set of rules is called CSMA/CD (Carrier Sense Multiple Access with Collision Detection). It makes a shared line just about workable.
Step 2: switch to a Switch. Octo gives every device its own separate lane and sends each Frame only to the recipient's Port. Everyone travels in their own lane, so naturally there are no collisions.
Today's wired networks almost all use Switches. Hubs have retired.
4. A Closer Look
A Hub Is a Layer 1 Device
A Hub does not look at MAC Addresses (hardware addresses), and it has no MAC Address Table. It does just one thing: it boosts the electrical signal it receives on one Port and sends it out of all the other Ports. That is why a Hub is also called a "multiport repeater".
Because it only handles electrical signals and does not understand what is inside a Frame, the industry calls it a Layer 1 device. A Switch looks at MAC Addresses, so it is a Layer 2 device.
A Little History
| Year | What happened |
|---|---|
| 1973 | Ethernet is born; at first, all computers share one coaxial cable |
| 1990 | The 10BASE-T standard appears, so computers can connect to a Hub with twisted-pair network cables |
| Mid-to-late 1990s | Switches get cheaper and start replacing Hubs |
| Today | New Ethernet equipment uses only Switches; Hubs have almost disappeared |
Notice: whether it is one coaxial cable or one Hub, all the devices connected to it share the same line.
The Three Parts of CSMA/CD
| Part | Meaning | Meeting analogy |
|---|---|---|
| Carrier Sense | Before sending, listen for a signal on the line | First listen to check whether anyone is talking |
| Multiple Access | When the line is free, any device can start sending | If nobody is talking, anyone can speak |
| Collision Detection | Listen while sending; if a collision is detected, stop and send a Jam Signal | If you bump into someone, stop and say "Collision!" |
After a Collision: Backoff
After a collision, each device waits a random amount of time before trying again. This waiting is called Backoff.
- The waiting time is counted in "slot times". On 10 Mbps Ethernet, one slot time is about 51.2 microseconds.
- After the 1st collision, a device picks randomly between 0 and 1 slot times; after the 2nd, between 0 and 3; after that, the range roughly doubles with each collision (up to 0 to 1023).
- If it still fails after 16 collisions, it gives up on that Frame.
The benefit of picking randomly: the two devices will very likely choose different times, so they will not collide again next time.
Half-duplex and Full-duplex
| Mode | Meaning | Analogy | Used with |
|---|---|---|---|
| Half-duplex | Can only send or receive at any one time | Walkie-talkie | Hub |
| Full-duplex | Can send and receive at the same time | Telephone | Devices connected directly to a Switch |
With Full-duplex, collisions simply cannot happen, so CSMA/CD no longer needs to run.
Collision Domain and Broadcast Domain
- Collision Domain: a group of devices that will collide if they send at the same time.
- Broadcast Domain: the area a Broadcast Frame can reach, meaning all the devices that receive a Frame whose recipient is
FF:FF:FF:FF:FF:FF.
| Device | Collision Domains with 3 computers attached | Broadcast Domains |
|---|---|---|
| Hub | 1 | 1 |
| Switch | 3 (one per Port) | 1 |
| Router | One per interface | One per interface |
A Switch splits up Collision Domains, but it does not split up the Broadcast Domain. To stop Broadcasts, you need a Router or a VLAN (Virtual LAN), which later stories will cover.
5. Try It Yourself
Task: Tell a Walkie-Talkie from a Telephone
- Think about talking on a walkie-talkie: you have to hold the button to talk, and let go to listen. That is Half-duplex.
- Now think about a phone call: two people can talk at the same time. It may be rude, but the voices do not "break". That is Full-duplex.
- If you use a computer, look in the network settings for "Speed & Duplex" (the exact name depends on the operating system) and see whether your wired connection says "Full Duplex".
Mini game
Hub or Switch?
Sort each item below into Hub or Switch:
-
1Sends every Frame it receives out of all the other Ports, no matter what
-
2Remembers which Port each MAC Address is on
-
3Devices connected to it have to use CSMA/CD
-
4Each Port is a separate Collision Domain
-
5Devices can use Full-duplex to send and receive at the same time
-
6Is a Layer 1 device
All sorted correctly! A Hub is Layer 1: it sends signals to every Port and everyone shares the line. A Switch is Layer 2: it delivers by MAC Address, and each Port is independent.
6. Where the Analogy Breaks
- A Hub does not "copy" Pip. A Hub just boosts the electrical signal it receives straight away and sends it out of all its Ports. It does not even care where a Frame starts or ends.
- A collision is not two parcels crashing. A Collision is two electrical signals adding up on the same wire and turning into an unreadable waveform. Nothing actually gets "smashed".
- Random waiting is not really "patience". A device simply picks a random number according to the rules and waits that many slot times. It is a purely mechanical calculation.
- Wi-Fi can "collide" too, but it handles it differently. Wireless devices cannot listen while they send, so they do not use CSMA/CD. They use a different method that tries to avoid collisions in the first place (Story 4 covers Wi-Fi).
- A Switch is not totally free of traffic jams. There are no Collisions on a Switch Port, but if many devices send data to the same Port at once, the data still has to queue, and if there is too much, some of it gets dropped.
7. Quiz
8. Key Notes
- A Hub is a Layer 1 device: it does not look at MAC Addresses, it sends signals out of all the other Ports, and everyone shares the line.
- When two devices on a shared line send at the same time, a Collision happens; CSMA/CD says "listen before you talk, stop if you collide, wait a random time and try again".
- Each Port on a Switch is independent and can use Full-duplex to send and receive at the same time, so there are no Collisions.
- All the Ports on a Hub form 1 Collision Domain; on a Switch, each Port is its own Collision Domain.
- Neither a Hub nor a Switch splits up the Broadcast Domain.
Further reading
The Hub has retired, and with Octo in charge, nobody has to collide any more. But Octo only understands MAC Addresses. If Mac only knows the TV's IP Address (its network address), how does he fill in the recipient? In the next story, Mac shouts across the LAN (Local Area Network): "Who is 192.168.1.11?" That is ARP (Address Resolution Protocol).