◆ Rebuild

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 →

You need first

The ComputerThe Telephone

This unlocks

The Internet
The full path from nothing — 55 steps before this one
  1. Fire
  2. Cordage and Rope
  3. Stone Tools
  4. Finding and Preparing Clay
  5. Finding and Identifying Ores
  6. Sulfur
  7. Writing and Numbers
  8. Hunting and Trapping
  9. Basic Woodworking
  10. The Kiln
  11. Pottery
  12. Charcoal
  13. Arithmetic and Fractions
  14. Hides and Leather
  15. Lime
  16. Bricks
  17. Salt
  18. Mercury
  19. Lye and Potash
  20. Fermentation
  21. The Wheel and Axle
  22. Logic and Binary
  23. Glass
  24. Firebrick and Refractories
  25. Bellows
  26. Saltpeter
  27. The Lathe
  28. Gears
  29. Copper Smelting
  30. Iron (the Bloomery)
  31. Lead
  32. Laboratory Glassware
  33. Sulfuric Acid
  34. Pumps
  35. The Waterwheel
  36. Lenses
  37. Blacksmithing
  38. Gold and Silver
  39. Hydrochloric Acid
  40. The Battery
  41. The Vacuum Pump
  42. Magnets
  43. The Light Bulb
  44. Copper Wire
  45. Photography
  46. The Generator
  47. The Electromagnet
  48. The Vacuum Tube
  49. The Electric Arc Furnace
  50. The Telegraph
  51. The Telephone
  52. Pure Silicon
  53. Semiconductors and the Transistor
  54. Integrated Circuits
  55. The Computer
  56. 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.

Sending the letter "A" (code 65 = 01000001), one bit at a time On a wire: current on = 1, off = 0. Lowest bit first. Dots: where the receiver looks, in the middle of each bit. 10 start 1 0 0 0 0 0 1 0 stop bit 0 bit 1 bit 2 bit 3 bit 4 bit 5 bit 6 bit 7 idle Over a telephone line or radio: two tones, low for 1 and high for 0 (for example 1,200 and 2,200 Hz). At 300 bits a second each bit lasts 3.3 milliseconds, and this letter takes 10 bit-times: 33 milliseconds. The start bit warns the receiver; it waits one and a half bits, then reads every bit in the middle. The stop bit returns the line to idle. Sender and receiver must agree on the speed to within a few per cent.
Fig. 1 The letter "A" sent serially: a start bit, eight data bits lowest first, and a stop bit. Below, the same bits sent as two tones, which is how data crosses telephone lines and radio.

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.

  1. 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.
  2. Acknowledge. When good data arrives, the receiver sends back a short acknowledgement (ACK) quoting its number.
  3. 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.
  4. 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.

A packeteach box is one byte (8 bits) except DATA and CHECK START marks the start TO address FROM address No. counts packets LEN how many bytes DATA 0–64 bytes of the message CHECK checksum 1 2 3 A B C D E F Packets find their own way A message from A to F is cut into packets 1, 2 and 3. line broken Each computer on the way stores a packet, checks it, and sends it on along the best working line it knows. When F has them all, it puts them in order by number and sends back an acknowledgement. If a line breaks, packets go round it. If a packet is lost, A sends it again.
Fig. 2 Above: a simple packet. Below: packets crossing a network. Each computer stores a packet, checks it, and forwards it along the best working line; a broken line is simply avoided.

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

Two computers three wires; cross send and receive Computer 1Computer 2 sendsend receivereceive groundground Each computer's "send" goes to the other's "receive". With voltage signals: up to about 15 m at 9,600 bits a second. Longer lines: a current loop through a relay at each end, and a lower speed. Many computers on one line a twisted pair with a resistor at each end No. 1 No. 2 No. 3 No. 4 Everyone hears everything; each keeps only packets addressed to it. Rule: listen before talking. If two start at once, both stop, wait a random time, retry.
Fig. 3 Left: joining two computers — each one's "send" goes to the other's "receive", with a common ground. Right: many computers sharing one line.
  1. Connect computer 1's send to computer 2's receive, computer 2's send to computer 1's receive, and the two grounds together.
  2. Set both to the same speed — start slowly, 300 bits per second — and the same format (8 data bits, 1 stop bit).
  3. 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.
  4. Write a program on each machine: whatever is typed is sent; whatever arrives is printed. Now two people can type to each other.
  5. 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.

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:

  1. If the checksum is wrong, ignore it (the sender will try again).
  2. If it is not addressed here, pass it on (if this computer is a relay) or ignore it.
  3. Send an ACK with the packet's number.
  4. 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:

  1. Listen before talking. Only start sending when the line has been quiet for a moment.
  2. 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

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