Part 14 · Electronics and Computing
Networks and the Internet
Connecting computers so they can exchange messages, files and programs — over wires, telephone lines and radio. How bits travel, how errors are caught and repaired, how packets find their way through a web of links, how to build a local network, and how the internet was assembled from many small networks.
- Difficulty
- ●●●●●
- Time
- An afternoon to join two computers with three wires; weeks for a reliable protocol; months to link towns by telephone line or radio
- Steps from zero
- 55 prerequisites →
This unlocks
The InternetThe full path from nothing — 55 steps before this one
- Fire
- Cordage and Rope
- Stone Tools
- Finding and Preparing Clay
- Finding and Identifying Ores
- Sulfur
- Writing and Numbers
- Hunting and Trapping
- Basic Woodworking
- The Kiln
- Pottery
- Charcoal
- Arithmetic and Fractions
- Hides and Leather
- Lime
- Bricks
- Salt
- Mercury
- Lye and Potash
- Fermentation
- The Wheel and Axle
- Logic and Binary
- Glass
- Firebrick and Refractories
- Bellows
- Saltpeter
- The Lathe
- Gears
- Copper Smelting
- Iron (the Bloomery)
- Lead
- Laboratory Glassware
- Sulfuric Acid
- Pumps
- The Waterwheel
- Lenses
- Blacksmithing
- Gold and Silver
- Hydrochloric Acid
- The Battery
- The Vacuum Pump
- Magnets
- The Light Bulb
- Copper Wire
- Photography
- The Generator
- The Electromagnet
- The Vacuum Tube
- The Electric Arc Furnace
- The Telegraph
- The Telephone
- Pure Silicon
- Semiconductors and the Transistor
- Integrated Circuits
- The Computer
- Networks and the Internet
Do them roughly in this order. See it on the tech tree →
Why it matters
A computer on its own is powerful. Computers that can talk to each other are far more: a message typed in one town arrives in another in seconds; a program written once can be copied to every machine that needs it; records can be kept in several places at once, so that one fire or flood cannot destroy them (Programming explains why that matters). Weather reports, prices, medical advice, warnings and news can move faster than any rider or train.
The first electrical network was the The Telegraph, and its operators already solved most of the problems in this chapter: codes, relays to pass messages on, and ways to ask for a repeat. A computer network is a telegraph network run by machines, sending numbers instead of words, and fast enough to carry anything that can be written as numbers — text, pictures, sound, programs.
You do not need the whole modern internet to get most of the benefit. Three wires between two computers in the same building are useful the first afternoon. A computer in each town that dials its neighbours once a night over a The Telephone line or by Radio, and passes on everyone's mail, gives a whole region written messages within a day.
How it works
Bits on a wire
Inside a computer, the eight bits of a number travel side by side on eight wires. Between computers, that would need too many wires, so the bits are sent one after another on a single wire (plus a return): this is serial sending.
The simplest way: current on (or a positive voltage) means 1, off means 0. Both ends agree on a speed, counted in bits per second. Each character is sent as a start bit (always 0) to say "wake up", then its 8 bits, lowest first, then a stop bit (always 1). The receiver sees the start bit begin, waits one and a half bit-times, and then looks at the line in the middle of each bit. Its timing only has to be right to within a few per cent, because it starts counting afresh with every character.
Tones for long lines and radio
A telephone line carries sound, not steady current, and a radio carries a wave. So the bits are turned into tones: one pitch for 1 and another for 0. A device that does this is a modem (modulator–demodulator). At the receiving end, two tuned filters — one for each pitch — decide which tone is present.
| Link | Typical speed | Notes |
|---|---|---|
| Two computers, short wires (a few metres) | 9,600 bits per second and up | Voltage signals; three wires |
| Current loop on a long line (kilometres) | 50–300 bits per second | Like a telegraph line; relays at each end |
| Telephone line with a simple modem | 300–1,200 bits per second | Two tones each way, e.g. 1,070/1,270 Hz one way and 2,025/2,225 Hz the other |
| Short-wave radio | 50–300 bits per second | Long distance; fading and noise; needs strong error correction |
| VHF radio, line of sight | 1,200 bits per second | Tones of 1,200 and 2,200 Hz through an ordinary voice radio |
| Twisted-pair cable with chips | Millions of bits per second | Within a building or a town |
For scale: a page of text is about 2,000 characters, 20,000 bits with start and stop bits; at 1,200 bits per second it takes about 17 seconds. The whole text of a thick book (3 million characters) takes about 7 hours.
Errors, and how to beat them
Noise — lightning crackle, a motor starting, a bad joint — flips bits. You cannot stop it; you can only catch it and send again.
- Detect. Add a checksum to everything you send (the method in Programming works well; stronger codes called CRCs are used in practice). The receiver works out the checksum again and compares. If they differ, the data is bad. A single extra parity bit per character (making the count of 1s always even) catches any single flipped bit, but not two.
- Acknowledge. When good data arrives, the receiver sends back a short acknowledgement (ACK) quoting its number.
- Repeat. If the sender hears no ACK within a set time, it sends again. After, say, five failures it gives up and reports the line as down.
- Number everything, so that if an ACK is lost and the data arrives twice, the receiver knows it is a repeat.
This scheme turns an unreliable line into a reliable one. It is slower on a noisy line, but it is never wrong without saying so.
Packets
Long messages are cut into packets of a few dozen to a few thousand bytes. Each packet carries its own addresses, number and checksum, so it can travel on its own.
Packets have three great advantages over a dedicated line for each conversation (as in a telephone call):
- Sharing. Many conversations take turns on the same line, packet by packet; no line sits idle reserved for someone who is thinking.
- Repair. A bad packet is re-sent alone, not the whole message.
- Survival. If there are several paths, packets go round a broken line or a dead computer. A network of many cross-links keeps working when parts of it are destroyed — the reason it was first proposed.
Each computer that passes packets on (a router) keeps a routing table: for each destination, which of its lines to use. Neighbours regularly tell each other how many hops away they are from each destination, and each picks the neighbour with the shortest distance. When a line dies, the news spreads and the tables change by themselves.
Protocols and layers
A protocol is an agreement about exactly what to send and how to answer: the packet format, the meaning of every byte, how long to wait, what to do when things go wrong. Write every protocol down in full (Programming) — two machines built from the same description must be able to talk.
Good networks are built in layers, each relying only on the one below:
| Layer | Job | Example in this chapter |
|---|---|---|
| Line | Move bits between two neighbours | Voltage, current loop, tones |
| Link | Frames between neighbours, checked and acknowledged | START … CHECK, ACK, resend |
| Network | Packets across many hops to an address | Routing tables, store and forward |
| Transport | Whole messages, in order, nothing missing | Packet numbers, reassembly |
| Application | What people actually want | Mail, files, news, a library catalogue |
Because of the layering, you can replace the bottom layer — wires today, radio tomorrow — without changing anything above it.
What you need
- Computers (The Computer), each with a serial port: a shift register that turns a byte into a train of bits and back, a clock at the agreed speed, and a line driver.
- Wire: twisted pairs of insulated copper (Copper Wire) — twisting the two wires of a pair round each other cancels most of the noise they pick up. Existing The Telegraph and The Telephone lines.
- Modems for telephone and radio links: tone oscillators and tuned filters (Amplifiers and Oscillators).
- Radios, for links without wire (Radio).
- Protection for any line that runs outdoors: a spark gap or lightning arrester and a fuse where it enters each building, connected to a good earth rod.
- Isolation between buildings: a relay, a small transformer (The Transformer), or a lamp shining on a photocell, so that the two buildings' wiring is never directly joined.
Step by step
1. Two computers, three wires
- Connect computer 1's send to computer 2's receive, computer 2's send to computer 1's receive, and the two grounds together.
- Set both to the same speed — start slowly, 300 bits per second — and the same format (8 data bits, 1 stop bit).
- Loopback test first: on one computer, join its own send to its own receive, and check that everything it sends comes straight back. Then do the same at the far end of the cable, so you test the wire too.
- Write a program on each machine: whatever is typed is sent; whatever arrives is printed. Now two people can type to each other.
- Raise the speed step by step until errors appear, then go back two steps.
For runs longer than about 15 m, or between buildings, use a current loop instead: the sender switches a steady current (about 20 milliamps) through the line, and at the far end that current works a relay or lights a lamp facing a photocell. It is slow, but it works over kilometres, and it keeps the two buildings electrically apart.
2. A reliable link
Add the packet format from the figure, a checksum, numbering and acknowledgements. In the simple language of Programming:
function send_packet(to, number, data):
let tries = 0
while tries < 5:
transmit(make_packet(to, MY_ADDRESS, number, data))
let reply = wait_for_reply(2) # wait up to 2 seconds
if reply_is_ack(reply, number):
return 1 # delivered
tries = tries + 1
return 0 # give up: report the line as down
The receiver, for every packet that arrives:
- If the checksum is wrong, ignore it (the sender will try again).
- If it is not addressed here, pass it on (if this computer is a relay) or ignore it.
- Send an ACK with the packet's number.
- If the number is the same as the last one from that sender, it is a repeat (our ACK was lost): do not use the data twice.
One detail: if the START byte happens to occur inside the data, the receiver will think a new packet begins. Fix it by escaping: whenever START (or the escape byte itself) appears in the data, send the escape byte first, and have the receiver remove it.
3. A local network
Star: one central computer with a serial line to each of the others. It receives every packet and forwards it to the right line. Simple, and easy to find faults in; but if the centre fails, everything stops.
Shared line: one twisted pair running past every machine, with a resistor (about 100–150 ohms) across the pair at each end to stop signals reflecting back. Everyone hears every packet and keeps only the ones addressed to it. Two rules prevent chaos:
- Listen before talking. Only start sending when the line has been quiet for a moment.
- If two start at once — the checksum fails, or a sender notices that what is on the line is not what it is sending — both stop, each waits a random time, and tries again. Because the waits are random, they will not collide again for ever.
4. Between towns
- By telephone line: each town has a computer with a modem. At set times (at night, when lines are free) it calls its neighbours and exchanges all waiting messages and files: store and forward. Mail crosses a country in a day or two this way, over ordinary telephone lines.
- By radio: a VHF radio carries 1,200 bits per second between hilltops in sight of each other; relay stations on hills pass packets onwards. Short-wave radio reaches hundreds of kilometres at a few hundred bits per second, if you use strong error checking and patience.
- By hand: a box of tapes carried on a train is a network too, with very high capacity. Never despise it.
Give every computer a unique number as its address, keep a printed (and copied) directory of names and numbers, and agree on a few standard applications from the start: mail, file copying, and a shared catalogue of what is stored where.
How to tell it worked
- Loopback: every byte sent comes back unchanged, at the near end and at the far end of the cable.
- Echo test: computer 1 sends a numbered packet; computer 2 sends it straight back; computer 1 compares and counts. Run it overnight: thousands of packets, zero undetected errors, and a count of how many needed resending (a measure of the line's quality).
- Pull the plug: disconnect a line in the middle of a transfer. The sender should report the failure, not crash; when the line returns, the transfer should finish correctly.
- Routing: in a network with a loop of lines, break one; messages should still arrive by the other way.
Note Troubleshooting. Garbled characters → the two ends are at different speeds or formats. Check both settings. Nothing at all → send and receive not crossed (send joined to send), no common ground, or a break. Test each machine by loopback first. Works on a short cable, not a long one → the line is too slow for the speed; lower it, use a current loop, or use a better cable. Errors whenever a motor or welder runs → noise pickup: use twisted pair, keep data lines away from power cables, and use isolation between buildings. The same message arrives twice → the ACK was lost and the data resent; the receiver is not checking packet numbers. Everything stops when two machines talk at once → the random wait is missing, or both machines use the same "random" sequence.
Dangers
Danger Lightning. Any long outdoor wire — telegraph, telephone or data — can carry a lightning surge of thousands of volts into a building, killing a person at the equipment and starting fires. Fit a lightning arrester (a spark gap to a good earth rod) and a fuse where every outdoor line enters a building, and never work on outdoor lines or touch the equipment during a thunderstorm.
Danger Power lines. Never run data or telephone wires on the same poles as power lines without proper spacing, and treat any line that might have fallen against a power wire as live. See Wiring and Electrical Safety.
- Different earths. Two buildings' "ground" can differ by many volts, especially when a fault happens. Joining them with a data wire can make it carry dangerous current. Isolate links between buildings (relay, transformer or light).
- Radio transmitters use high voltages: see Radio.
- Trust. Anyone on a shared line or radio channel can read and send messages. Do not send anything secret or important without a way of checking who sent it (Codes, Ciphers and Encryption); important orders (medicine, money, dams, power stations) should be confirmed by a second means.
Going further
- Faster lines: better modems that send several bits per tone; coaxial cable; optical fibre, which carries light in glass threads with very little loss (Fibre Optics).
- Reaching further: relay stations (Radio Telescopes and Microwave Links), satellites in the long run (Satellites, Mobile Phones and GPS (Overview)).
- Applications: shared library catalogues (Libraries and Preserving Knowledge), weather networks (Reading the Weather), market prices, telemedicine, distance teaching (Teaching and Schools).
- A network of networks: connect separate local networks through routers, all using the same addresses and packet rules — which is exactly what the internet is (The Internet).
How it was first done
Telegraph networks from the 1840s already passed messages on from station to station, later by punching them onto paper tape at each relay office and sending them onwards — store and forward. Teleprinters sent letters as five-bit codes with start and stop bits from the early twentieth century.
In the early 1960s Paul Baran at the RAND Corporation in the United States proposed a network of many cross-linked nodes, passing small blocks of data that could route round damage. Independently, Donald Davies at the National Physical Laboratory in Britain proposed the same idea in 1965 and named the blocks "packets". The American ARPANET sent its first message on 29 October 1969, from the University of California, Los Angeles, to the Stanford Research Institute; the system crashed after the first two letters, "LO". Electronic mail between computers, with the @ sign, followed in 1971 (Ray Tomlinson). In 1971 ALOHAnet linked the Hawaiian islands by radio packets, with the "wait a random time and retry" rule, and in 1973 Robert Metcalfe at Xerox PARC adapted it to a shared cable, Ethernet.
In 1974 Vinton Cerf and Robert Kahn published the design of TCP, a way of joining different networks into one, with reliable delivery handled by the computers at the ends. ARPANET switched over to TCP/IP on 1 January 1983, which is often taken as the birth of the internet; the system of names for addresses (DNS) followed in 1983–84. In 1989 Tim Berners-Lee at CERN in Geneva proposed the World Wide Web, linked pages of text that anyone on the network could read; it opened to the public in 1991. Every one of those steps rested on the plain ideas of this chapter: bits in a row, checksums, acknowledgements, packets and agreed rules.
Source: content/entries/electronics/networks.md