◆ Rebuild

Part 14 · Electronics and Computing

The Internet

The internet is not one network but an agreement that lets thousands of separate networks pass each other's packets. How every machine gets an address, how routers pass packets from network to network, how the computers at the ends turn lost and jumbled packets back into perfect messages, how names, mail, web pages and search work, and how a rebuilding society can grow its own internet from one town network, starting with slow links and small computers.

Difficulty
●●●●●
Time
A week to put internet rules on a town network that already works; months to join several towns; decades of industry for the full-speed global internet
Steps from zero
77 prerequisites →

You need first

Networks and the InternetFibre OpticsMicroprocessors and Personal Computers

This unlocks

Codes, Ciphers and Encryption
The full path from nothing — 77 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. Glass Fibre and Glass Wool
  30. Copper Smelting
  31. Iron (the Bloomery)
  32. Lead
  33. Laboratory Glassware
  34. Sulfuric Acid
  35. Pumps
  36. The Waterwheel
  37. Lenses
  38. Blacksmithing
  39. Gold and Silver
  40. The Blast Furnace and Cast Iron
  41. Bronze
  42. Hydrochloric Acid
  43. The Battery
  44. The Vacuum Pump
  45. Magnets
  46. The Spectroscope
  47. Steel
  48. Chimneys, Stoves and Heating
  49. Bearings and Lubrication
  50. The Steam Engine
  51. The Light Bulb
  52. Copper Wire
  53. Electrolysis
  54. Photography
  55. Hydrogen, Oxygen and Gases
  56. Centrifugal Pumps and Fans
  57. Machine Tools
  58. The Generator
  59. The Electromagnet
  60. The Vacuum Tube
  61. The Electric Arc Furnace
  62. Ammonia
  63. The Telegraph
  64. Ice and Refrigeration
  65. The Telephone
  66. Pure Silicon
  67. Ventilation and Air Conditioning
  68. Semiconductors and the Transistor
  69. Clean Rooms
  70. Integrated Circuits
  71. Lasers
  72. The Computer
  73. Fibre Optics
  74. Making Microchips
  75. Networks and the Internet
  76. Programming
  77. Microprocessors and Personal Computers
  78. The Internet

Do them roughly in this order. See it on the tech tree →

Why it matters

The Networks and the Internet chapter shows how to join computers with bits, checksums, packets and routing tables. But each group that builds a network makes its own choices of packet format and addresses, and two different networks cannot talk. The internet is a short list of rules, written down in full and shared freely, that any network can follow on top of whatever wires or radios it already has. Follow them and your network can pass packets to every other network that does, and so to every machine on Earth.

The rules ask only that links carry a packet most of the time; all the cleverness sits in the computers at the ends. That is why the internet runs over telephone lines, radio, fibre and satellites.

You do not need the modern internet to get most of the value: mail between towns, a shared library catalogue, weather and market news and medical advice all work at a few thousand bits a second on small computers. This chapter explains the rules, then how to grow an internet step by step.

How it works

One address for every machine

Every machine on the internet has an address: a number 32 bits long (four bytes), written as four numbers from 0 to 255 separated by dots, such as 10.3.7.21. There are about 4.3 billion such numbers. (The newer version uses 128-bit addresses, enough for every grain of sand; the ideas are the same.)

Addresses are handed out in blocks, and a block is named by its first address and how many bits at the front are fixed, its prefix. 10.3.0.0/16 means "every address whose first 16 bits are 10.3", which is 65,536 addresses. 10.3.7.0/24 is the 256 addresses from 10.3.7.0 to 10.3.7.255.

This is what makes routing possible on a world scale: a router far away needs only one line in its table saying "everything starting 10.3 goes that way". Plan your addresses like a postal system: region, then town, then street, then house.

Block Who Size
10.0.0.0/8 The whole region 16.7 million addresses
10.3.0.0/16 One town 65,536
10.3.7.0/24 One building or local network 256
10.3.7.21 One machine 1

The internet packet

Every internet packet starts with the same header of 20 bytes, whatever network it crosses. The important parts:

  • Destination address and source address.
  • Time to live: a number, usually 64, that every router reduces by one. A router that brings it to zero throws the packet away. If a mistake in the tables ever sends packets round in a loop, they die after 64 hops instead of circling for ever.
  • Protocol: which program at the far end the packet is for (the reliable stream, the quick question-and-answer kind, or a test message).
  • Length and a header checksum.

The packet is carried "best effort": routers try to deliver it, but may drop it if a line is busy or broken, or send two packets of one message by different ways so they arrive out of order. This keeps routers simple, fast and cheap; putting things right is the job of the computers at the ends.

On each link, the internet packet travels inside that link's own frame, like a letter inside an envelope inside a mail sack. On a local network, every network card has its own fixed link address (on Ethernet, 48 bits, set when the card is made). To deliver a packet to 10.3.7.21 on the same local network, a computer first shouts on the network: "Who has 10.3.7.21?" and that machine answers with its link address. The answer is remembered for a few minutes. For anything outside the local network, the computer simply sends the packet to its local router and lets it worry about the rest.

Applicationwhat the user wants StreamTCP InternetIP, same everywhere Linknew each hop Linewire, radio, light GET /weather.html ports 1042 → 80bytes from 4,001 the request to 10.3.0.5, from10.1.2.9; TTL 64 stream header the request link addressesof this hop IP headerstream headerthe request check bits: one after another, as voltage, tones, radio or flashes of light
Fig. 1 How each layer wraps the one above. The words of a web request travel inside a numbered piece of a reliable stream, which travels inside an internet packet carrying the addresses, which travels inside the frame of whatever link it is crossing at that moment. Each router unwraps the frame, reads the internet header, and wraps the packet in a new frame for the next link.

Reliable streams

Most programs want a stream: every byte sent arrives, once, in order, or the program is told the connection broke. The computers at the two ends build this on top of unreliable packets (the method is called TCP):

  1. Ports. Each stream is between a numbered port on each machine, so one computer can hold many conversations at once. Services listen on agreed ports: mail on 25, names on 53, web pages on 80.
  2. Handshake. The caller sends "let's talk, my bytes will be numbered from 4,000"; the answer is "agreed, mine from 9,000"; the caller confirms. Both now know the other is alive and listening.
  3. Every byte is numbered. The receiver acknowledges "I have everything up to byte 6,500", fills gaps from packets that arrived early, and throws away duplicates.
  4. Many packets in flight. Waiting for an acknowledgement after every packet wastes most of a long line's time. Instead the sender keeps a window of packets travelling at once, for example 20 packets, and slides it forward as acknowledgements come back.
  5. A timer that learns. The sender measures how long acknowledgements take to return, and re-sends anything not acknowledged within a little more than that time: perhaps 5 seconds on a radio link, a thousandth of a second on town fibre.
  6. Polite sending. If many senders all push as fast as they can, router queues overflow, packets are lost, everyone re-sends, and the network chokes on its own repeats. So each sender starts with one packet in flight, doubles it each round trip while all goes well, and the moment it sees a loss, halves its window and then grows it only slowly. Every sender doing this shares a busy line fairly, with nobody in charge.

For a quick question and answer, such as looking up a name, the stream is too much trouble: one packet out, one back, and ask again if no answer comes (this is UDP).

Routing between networks

Town 110.1.0.0/16 Town 210.2.0.0/16 Town 310.3.0.0/16 server10.3.0.5 telephone line1,200 bits a second radio fibrebroken here router Town 1 router's table 10.1.0.0/16 → here 10.2.0.0/16 → phone line 10.3.0.0/16 → fibre; if the fibre fails, via Town 2
Fig. 2 An internet of three towns. Each town runs its own network with its own block of addresses; their routers are joined by links of different kinds, and each router keeps a table of which link leads to which block. If the direct link from Town 1 to Town 3 fails, packets go round through Town 2.

Inside one organisation's network, routers share a map: each tells all the others which links it has and how good they are, and each works out the shortest paths to everywhere (Networks and the Internet gives a simple form).

Between networks run by different people, routers announce what they can reach: "I, network 3, can reach 10.3.0.0/16." A neighbour that accepts it passes it on with its own number added: "via network 2 then network 3." Each router chooses among the paths it hears, usually the one through the fewest networks, but each network may refuse to carry traffic for someone it has no agreement with. A router that hears a path already containing its own number knows it is a loop and ignores it.

A router looks up each packet's destination by the longest matching prefix. If its table says "10.0.0.0/8 → link A" and "10.3.0.0/16 → link B", a packet for 10.3.7.21 matches both and goes by B, the more exact. A default route ("everything else → link A") lets a small network send whatever it doesn't know to its bigger neighbour.

Where many networks meet, they connect at one place, an exchange point: a single fast switch in a building where each network's router plugs in, so that every pair can swap traffic without a separate line for each.

Names

People remember news.town3.region, not 10.3.0.5. At first, keep a single list of names and addresses, kept by one person, copied to every machine every week. That works for a few hundred machines; the early internet ran that way until about 1984.

Then share the work. A name server for each town answers for the names in that town. A server for the region knows the address of each town's name server. A machine wanting news.town3.region asks its own town's server, which asks the region's server "who answers for town3?", then asks town 3's server for the address, and remembers the answer for a few hours so it rarely needs to ask again.

Mail

Mail is a short conversation in plain text between two servers. The sending server connects to port 25 of the receiving one:

SERVER: 220 mail.town3.region ready
SENDER: HELO mail.town1.region
SERVER: 250 hello
SENDER: MAIL FROM:<doctor@town1.region>
SERVER: 250 ok
SENDER: RCPT TO:<clinic@town3.region>
SERVER: 250 ok
SENDER: DATA
SERVER: 354 send the message, end with a line holding a single full stop
SENDER: Subject: cholera case
SENDER: (the message lines)
SENDER: .
SERVER: 250 accepted
SENDER: QUIT

The receiving server puts the message into the person's mailbox (a file), and they read it at their leisure. If the far server cannot be reached, the sender keeps the message and tries again every half hour for several days. The name system also says which machine takes the mail for each town, so a message for anyone@town3.region finds its way without the sender knowing more.

The web

A web page is a text file with simple marks, tags, that say how to show it and where its links go:

<h1>Weather for Town 3</h1>
<p>Frost tonight. Cover the seedlings.</p>
<p>See the <a href="http://library.town1.region/frost.html">frost guide</a>.</p>

A web address (URL) such as http://news.town3.region/weather.html names the method, the machine and the file. A browser looks up the machine's name, opens a stream to its port 80, and sends one line asking for the file; the web server sends back a status line and the file; the browser shows it, with the links underlined. Click one and it does the same with that address. The heart of it: anyone can publish a page, and any page can point to any other.

Browser10.1.2.9 Name servertown 1 Web server10.3.0.5, port 80 where is news.town3.region? it is 10.3.0.5 let's talk; my bytes start at 4,000 agreed; mine start at 9,000 confirmed GET /weather.html 200 OK, and the page finished finished handshakethree packets requestand replyclose
Fig. 3 Fetching a web page. The browser first asks a name server for the web server's address, then opens a stream with a three-way handshake, sends a single request line, receives the page, and closes. Each arrow is one or more packets.

A search engine has three parts:

  1. A crawler: a program that fetches a page, notes every link on it, fetches those pages, and so on, revisiting each page every few days.
  2. An index: like the index at the back of a book, it lists for every word every page that contains it, and where. A question with three words looks up three lists and keeps the pages in all of them.
  3. Ranking: of the thousands of pages that match, which first? Count how often and where the words appear (a title counts more); then trust pages that many other pages link to, and trust a link more if it comes from a page that is itself well linked.

A town library's catalogue (Libraries and Preserving Knowledge) is a hand-made index of the same kind, and the first thing to put on any new network.

What you need

Item Notes
Computers Any stored-program computer (The Computer, Microprocessors and Personal Computers) with a few kilobytes of memory to spare can follow the internet rules; useful servers want far more memory and disk storage (Displays, Printers and Data Storage)
Links Whatever you have: serial lines, telephone lines with modems, packet radio (Networks and the Internet, Radio); twisted-pair cable in buildings; Fibre Optics between towns when you can
The rules, written down Every format and every exchange, in full, printed and copied, with examples. Two machines built by strangers from the same pages must work together
An address and name registry One person or office that hands out blocks of addresses and town names, and keeps the list
Steady power A battery and charger for each router and server, so a power cut does not lose mail or break the network (The Rechargeable Battery)
Programmers and operators People who understand the rules, keep the machines running and answer when something breaks (Programming, Teaching and Schools)

Step by step: growing an internet

  1. Start with one working local network (Networks and the Internet). Choose an address block for the town (10.1.0.0/16) and give every machine its own address in it. Write them in a register.
  2. Put the internet rules on each machine. The packet header, the "who has this address?" exchange, the test message (a machine receiving an echo request sends it straight back), quick question-and-answer packets, and reliable streams. This has been done on 8-bit computers with a few kilobytes of memory. Test every machine by sending echo requests to every other.
  3. Build a router between two local networks: one computer with a connection to each (see The router below). Give each network its own block (10.1.1.0/24 and 10.1.2.0/24), tell each machine "anything not on my own block, send to the router", and give the router its table.
  4. Add services: a name server, a mail server, a web server with a front page that links to everything else, and a copy of the library catalogue. Choose simple, robust programs over clever ones.
  5. Join a second town. Give it its own block (10.2.0.0/16), link the two routers by telephone line, radio or fibre, and add a line to each table. Mail now flows between the towns; so do web pages.
  6. Join many towns. Link each to two or more others where you can, so no single failure cuts anyone off. Let the routers share their tables automatically. Where several links meet, set up an exchange point.
  7. Upgrade the trunks. As traffic grows, replace the busiest radio and telephone links with fibre; nothing above the link layer needs to change.

At 1,200 bits per second a short letter crosses in a second or two and a page of plain text in 15 seconds; a picture takes minutes. Keep pages to text and small drawings while links are slow, and send big files at night.

The router

What it is. A computer with two or more network connections whose only job is to take in each packet, check it, find where it goes, and send it on.

The simplest version. Any computer with two connections (two serial ports, or a serial port and a network card), looping for ever: take the next packet; drop it if the header checksum is bad; reduce the time to live (drop it at zero and tell the sender); look up the destination by longest matching prefix; queue it for that link. A small 8-bit machine forwards tens of packets a second, plenty for links of a few thousand bits a second. Keep its table in memory that survives a power cut, or printed beside it.

The better version. A dedicated box with a microprocessor, several interface boards, no moving parts, its settings in non-volatile memory, and a battery, so it restarts by itself after every power cut. It learns routes from its neighbours and counts packets sent, received and dropped on each line.

The industrial version. In a large router, a control computer builds the table, but forwarding is done by custom chips on each line card, which look up each destination among a million or more prefixes in a few billionths of a second and pass packets to the right outgoing card, where laser modules turn them into light (Fibre Optics). A core router for a national backbone fills a 2 m cabinet, draws over 10 kW and forwards trillions of bits a second.

A good router forwards at full line speed without losing packets until a line is genuinely full, finds a new path within seconds when a link fails, and comes back by itself after a power cut.

The server

What it is. Any computer that stays switched on and answers requests from others: names, mail, web pages, files, the library catalogue. Being a server is a job, not a kind of machine.

The simplest version. A computer with as much memory and disk storage as you can give it (Displays, Printers and Data Storage), a network connection, a battery that carries it through power cuts and shuts it down tidily if it runs low, and a cool, dry, locked room. Log everything.

The better version. Make the machine survive its own failures:

  • Two disks, mirrored: every write goes to both; when one fails, the other carries on while you replace it.
  • Error-correcting memory, which adds check bits to every word so a single flipped bit is corrected and a double one reported (Networks and the Internet explains checksums).
  • Backups: copy everything every night to a separate disk or tape, and every week carry a copy to another building. A backup you have never restored is a hope, not a backup: once a month, restore one at random and check it.
  • Two servers for anything important (names, mail), in different buildings, so one can be repaired while the other works.

The industrial version. Servers are flat drawers in a standard rack 482.6 mm (19 inches) wide, with heights in units of 44.45 mm; a 2 m rack holds about 40 servers and draws 5–20 kW, all of which comes out as heat. A data centre is a building of thousands of racks, cold air fed to the fronts and hot air drawn from the backs, with batteries that carry the load for the seconds to minutes it takes diesel generators to start (The Generator, Power Lines and Distribution).

A good server runs for months without needing a restart; its logs show what it did and every error; it survives a pulled power plug with nothing lost; its backups restore; and its room stays below about 27 °C.

The network switch

Inside one building, a switch replaces the shared cable of Networks and the Internet. Each computer has its own cable to a port on the switch. The switch watches the source link address of every frame and learns which machine is on which port; it then sends each frame only out of the port where its destination lives (or out of all ports, if it has not learned it yet). There are no collisions, and every cable runs at full speed at once. A simple switch is a small computer with several ports running this rule. Twisted-pair cable reaches up to 100 m from the switch.

What the full-scale internet needs

The rules themselves fit in a few hundred printed pages and cost nothing. What makes today's internet is the industry under them: chips by the billion from a full Making Microchips industry; Lasers, fibre and cable ships for the long links; a reliable Power Lines and Distribution; one registry for addresses and names, open standards and agreements between networks to carry each other's traffic; and thousands of people who can write, run and repair the software.

The realistic first internet is a regional one: a few dozen towns, small computers, links of a few thousand bits a second, with mail, a name service, plain-text pages and a shared catalogue. That is roughly what the research internet offered in the early 1980s, and it changed how people worked even then.

How to tell it worked

  • Echo test: an echo request from any machine to any other, in any town, comes back, with its round-trip time: milliseconds across a building, hundreds across radio.
  • Route trace: send packets with a time to live of 1, then 2, then 3; each router along the way discards one and reports back, listing every hop.
  • Pull a link: unplug a line between two towns; within a minute echoes get through another way, and mail sent during the break arrives later.
  • Mail and web: a letter to every town's postmaster is answered; a page in one town, linking to pages in two others, can be read and followed from a fourth.

Note Troubleshooting. Machines on the same network reach each other but nothing beyond → the default route is missing or points to the wrong machine; or the router's table lacks a return route (packets get there, answers don't come back). Echo works but names don't → the name server is down or the machine is asking the wrong one; try the address directly. Streams start but stall on big transfers → packets larger than some link can carry are being dropped; make packets smaller. Everything slows to a crawl at busy times → some sender is not backing off when packets are lost, or a link is simply too small; measure each link's load and upgrade the busiest. Packets circle and die → two routers each think the other is the way; check their tables. Two machines fight over one address → the register is wrong; give each machine its own address and write it down.

Dangers

Danger Battery rooms and mains power. The batteries that keep routers and servers running are large banks of lead-acid cells that can deliver thousands of amperes into a short circuit, melting tools and causing severe burns, and that give off explosive hydrogen while charging. Ventilate the room, keep flames and sparks away, insulate every tool, and never wear rings or watches at the battery rack. Mains wiring in server rooms: Wiring and Electrical Safety. Lightning on outdoor lines: Networks and the Internet.

  • Dependence. Once mail, records and orders travel by network, a failure can stop work everywhere at once. Water treatment, hospitals, dams and the Power Lines and Distribution must keep working without the network, by hand if need be, and essential records must also exist on paper.
  • Lost data. Disks fail and rooms burn: keep backups in a separate building.
  • Trust and theft. On a network anyone can pretend to be anyone. Use passwords, keep them secret, give each person only the access they need, check important orders by a second route, and learn to sign and encrypt messages with keys (Codes, Ciphers and Encryption) as soon as you can.
  • Privacy. Server operators can read whatever passes through them. Agree rules on who may read what, write them down, and hold operators to them (Organising a Community).

What this unlocks

Mail and news across a whole country in seconds. Shared catalogues and libraries of instructions (Libraries and Preserving Knowledge), distance teaching (Teaching and Schools), medical advice for remote clinics, market prices and weather warnings (Reading the Weather). Remote control and monitoring of the Power Lines and Distribution, waterworks and railways (Telemetry and Remote Control). In time, the mobile data networks of Smartphones, and with them almost every service people use today.

How it was first done

The Networks and the Internet chapter tells the story of packets, the ARPANET (1969), electronic mail and Ethernet. Steve Crocker wrote the first of the ARPANET's openly published "Request for Comments" (RFC) notes in April 1969; the habit of writing every rule down in public, for anyone to implement, did as much as any invention to make the internet work. Vinton Cerf and Robert Kahn described their internetwork design in 1974; by 1978 it was split into the simple internet packet (IP) and the reliable stream (TCP), and Jon Postel, editor of the RFCs for nearly thirty years, published the definitive versions in 1981 and the mail exchange (SMTP) in 1982. The ARPANET switched over on 1 January 1983.

Paul Mockapetris designed the domain name system in 1983, replacing a single list of hosts kept at the Stanford Research Institute. In October 1986 the internet suffered its first "congestion collapse", when traffic between two Berkeley sites fell about a thousandfold; Van Jacobson's 1988 rules for backing off fixed it. BGP, by which networks announce their routes to each other, was first written in 1989. Tim Berners-Lee at CERN wrote the first web server and browser in 1990; the Mosaic browser (1993) made the web easy to use, and Larry Page and Sergey Brin's link-based ranking (1998) made searching it useful. The American government's research backbone was retired in 1995, leaving the internet to the commercial networks that carry it today.

Source: content/entries/electronics/the-internet.md