The bit in a transistor is the bit across a continent.
Parts I and II stayed inside one machine. Part III leaves it. The same bit that switched a transistor in Chapter 1 now travels: across the motherboard as a voltage step, out a network interface, down a cable, across an ocean as light in glass, into another machine on the other side of the planet. The bit is unchanged; only what carries it changes. What grows is the discipline required to keep the signal intact over that distance.
A wire, electrically, is a conductor with two ends. Push voltage in at
one; some attenuated, slightly delayed version of that voltage shows up at
the other. The delay is a function of length and cable type: about
5 ns per metre on copper, about the same on fibre. The
attenuation is a function of frequency, distance, and material. The noise
added along the way is a function of everything nearby: lightning,
fluorescent lights, other wires. A one-metre USB cable inside a desk hides
all of this. A two-thousand-kilometre undersea cable cannot.
How do you keep a signal readable after a kilometre of copper, a hundred kilometres of fibre, or a radio link through a forest in the rain? That is the problem this chapter works on, and the rest of Part III is built on top of the answer.
A bit crossing a micrometre of chip wiring and a bit crossing 5,600 km of ocean are the same thing at scales a trillion times apart: a signal guided along a line, in copper or in glass. On the chip it arrives unchanged; under the sea it fades with distance, and repeaters every 50 to 100 km restore it.
How it works
- The speed. Light in fibre travels at about two-thirds of its speed in vacuum, so New York to London takes about 28 ms one way.
- The repeaters. Modern undersea repeaters amplify the light directly, in erbium-doped fibre, without turning it back into electricity.
- The voltage. Processor cores run at around 1 V; the older 3.3 V and 5 V levels survive only at the edges of boards and chips.
Electrons in copper, photons in glass, waves through air.
All networking happens over one of three substrates: copper, fibre and wireless. They look very different but do the same job: transport bits as variations in some physical quantity that a receiver at the other end can measure.
Copper is the original. The signal is the voltage difference between two wires twisted around each other (a twisted pair), and the receiver reads only that difference. Interference from outside induces almost the same voltage on both wires at once; subtract one from the other and the shared noise cancels, while the signal, which is opposite on the two wires, survives. The twist keeps neither wire systematically closer to any noise source, so the two stay balanced along the whole run. Copper is cheap and easy to connect, but loses signal fast: at the ~100 MHz frequencies modern Ethernet uses, about 20 dB per hundred metres (decibels count by factors of ten: every 10 dB leaves a tenth of the power, so 20 dB leaves a hundredth), which limits a single copper run to roughly 100 metres before a switch or repeater is required. Almost every cable inside a house or office is copper.
Fibre is glass. The signal is light, switched on and off to carry the bits. It travels down a hair-thin glass core wrapped in a cladding of glass with a slightly lower refractive index, which reflects light meeting it at a shallow angle back into the core (total internal reflection), so the light stays trapped all the way to the receiver. The loss is far lower: modern fibres lose about 0.2 dB per kilometre, so repeaters can sit tens of kilometres apart (50 to 100 km on an undersea cable). Every undersea cable, every long-distance internet trunk, every data-centre backbone is fibre. The first transatlantic fibre cable, TAT-8, went into service in 1988 and carried 280 megabits per second.
Wireless needs no cable at all: the bits are variations in a radio wave travelling through space. Wi-Fi runs at 2.4, 5 and 6 GHz; cellular from below 1 GHz to tens of GHz; satellite up to tens of GHz. The trade: no wire to install, but every receiver in range hears every transmission, the medium is shared with every microwave oven and every Bluetooth device, and atmospheric absorption is a factor at the higher frequencies. The mathematics of how to share that single medium efficiently is the bulk of cellular and Wi-Fi design.
The substrate is the first attack surface. Copper wires emit small amounts of electromagnetic radiation that a receiver nearby can turn back into the original signal. This is the basis of TEMPEST, the US codename for standards, dating to the 1960s, for shielding sensitive equipment against it. (Van Eck showed in 1985 that the picture on an unshielded monitor could be rebuilt from its emissions across the street; a modern software radio does the same to a leaky cable from across a room.) Optical fibres are harder but not immune: bending a fibre slightly leaks a small fraction of its light through the cladding, and the Snowden documents in 2013 revealed that the NSA and GCHQ had been systematically tapping undersea fibre cables at landing stations for years. Wireless is hardest of all to secure. The whole story of Wi-Fi security, from WEP (Wired Equivalent Privacy, 1997, broken by 2001) through WPA (2003, broken 2008) and WPA2 (2004, broken 2017 by the KRACK attack) to WPA3 (2018; the flaws found in it in 2019 were patched), is the engineering response to the fact that on a radio link, the attacker is always already in the room.
A request from a laptop to a distant server crosses all three substrates: radio to the router, copper or fibre to the internet provider, and glass across the ocean. Each hop encodes the bits its own way, and the programs above see none of it.
How it works
- Copper. Cheap and easy to connect, but it loses signal quickly at high frequencies: Cat 6 loses about 20 dB per 100 m at 100 MHz, so Ethernet runs stop at 100 m.
- Glass. At 1550 nm fibre loses about 0.2 dB per km, so light travels tens of kilometres between amplifiers.
- Radio. It shares the air with every neighbour; cellular networks use bands from below 1 GHz to tens of GHz, Wi-Fi 2.4, 5 and 6 GHz.
1948. Bell Labs again. The number behind every wire.
In July and October of 1948, Claude Shannon, a thirty-two-year-old mathematician at Bell Labs, published "A Mathematical Theory of Communication" in two parts of the Bell System Technical Journal. Before this paper, "amount of information" was close to a metaphor (Hartley had only counted equally likely messages, in 1928). After it, information had units (bits) and a formula (entropy). And Shannon proved a result that still defines every modern network: every channel has a maximum bit rate, you can send reliably below it, and you cannot send reliably above it.
Shannon is one of the strangest figures in twentieth-century science. At twenty-one he wrote the 1937 master's thesis, met in Chapter 2, that put Boole's algebra into relay circuits; Howard Gardner later called it "possibly the most important, and also the most famous, master's thesis of the century."
He stayed strange. At Bell Labs, where he wrote the information theory paper on his own (the whole field sprang from one head, in one paper, more or less complete), he was known for riding a unicycle through the corridors while juggling. In 1950 he built Theseus, an electromechanical mouse that could solve a maze and remember the solution: arguably the first artificial learning machine. The papers he wrote in his "spare time" included the first paper on computer chess, the first paper on cryptography as information theory (classified during the war, declassified 1949), and a theory of juggling that reduced the art to an equation relating hands, balls, and air time. Alzheimer's took him slowly through the 1990s; he died in 2001, having given the mathematics to a networked world he could no longer quite see.
The key definition in his 1948 paper is entropy (named after the physics quantity it resembles). It measures how much surprise a source of symbols carries: on average, the fewest well-chosen yes-or-no questions needed to learn each symbol it sends. A fair coin needs one question per flip; a coin that always lands heads needs none, because you already know the answer. For a source whose symbols come with probabilities p₁, p₂, …, pₙ, the entropy is:
H = −Σ pᵢ log₂(pᵢ)
Measured in bits per symbol. Each term is the questions one symbol costs: a symbol with chance ⅛ is pinned down by three halving questions (log₂ 8 = −log₂ ⅛), and entropy averages those costs, weighted by how often each symbol comes. The fair coin (½, ½) gives H = 1, the most a two-sided source can carry; the always-heads coin (1, 0) gives 0. A coin that lands heads nine times in ten (0.9, 0.1) gives H ≈ 0.47 bits: if you code several flips at a time, with short codes for the likely runs and longer ones for the rare runs, a long run of them fits in about 0.47 bits per flip. This number is also the shortest average code length any lossless compression scheme can achieve on long messages: a source cannot be compressed below its entropy. Every lossless compressor, ZIP and PNG included, is judged by how close it gets to that floor.
Entropy of a two-symbol source against p, the chance of a 1: 0 when every symbol is predictable, 1 bit for the fair coin, symmetric about it. A 90/10 source is marked at 0.47 bits, the least any lossless code can average for it.
How it works
- The formula. H(p) = −p log₂ p − (1 − p) log₂(1 − p): the average surprise, in bits, of one symbol.
- Symmetry. A 30/70 source is exactly as uncertain as a 70/30 one; the curve does not care which side is likelier.
- Reaching the floor. Arithmetic coding comes within a few percent of H for long messages; coding bit by bit cannot go below 1 bit per symbol.
Shannon's second result, the noisy channel coding theorem, put a number on what a wire can carry. Given a channel of bandwidth B hertz (the width of the band of frequencies it passes, not its bit rate) and signal-to-noise ratio SNR (signal power divided by noise power, a plain ratio: 30 dB is 1,000), the maximum reliable bit rate, the channel capacity, is:
C = B · log₂(1 + SNR)
The shape of the formula can be read straight off the physics. A receiver can only tell two signal levels apart if they differ by more than the noise blurs them: with signal power S and noise power N (a voltage grows as the square root of the power it carries), the received range spans about √(S+N) and the blur is about √N, so the number of reliably distinguishable levels is their ratio: √(1+SNR). A pulse carrying one of those levels delivers log₂ of that many bits: ½ · log₂(1+SNR). And a channel of bandwidth B can carry at most 2B independent pulses per second, a limit Harry Nyquist had derived in 1928. Multiply the two, and the halves cancel: C = B · log₂(1+SNR). Bandwidth buys pulses per second; signal-to-noise buys bits per pulse; capacity is their product. Even the +1 earns its place, because the receiver's measuring range contains the noise as well as the signal.
If you transmit at rate R < C, there exists a coding scheme (a way of adding redundant bits so the receiver can find and repair what the noise damaged) that achieves arbitrarily low error rate. If R > C, errors are inevitable, no matter how clever the coding. The proof is non-constructive: Shannon proved good codes exist, decades before anyone knew how to build them. Modern error-correcting codes (LDPC, Polar, Turbo) approach within a fraction of a dB of Shannon's limit.
Shannon's limit, the curve: a channel of bandwidth B carries at most B · log₂(1 + SNR) bits per second, and above it errors cannot be avoided. A phone line at 30 dB (signal 1,000 times the noise) allows about 10 bits per hertz, about 34 kbps over the 3.43 kHz band V.34 modems use; they reached 33.6 kbps.
How it works
- Reading it. At high SNR each doubling of signal power (+3 dB) buys about one more bit per hertz; doubling the bandwidth doubles the capacity outright.
- Wi-Fi 6. At about 20 dB the limit is 6.7 bits per hertz; over an 80 MHz channel that is a few hundred Mbps per stream.
- 56k modems. They beat 33.6k only because the downstream path stayed digital until the last stretch of phone line, dodging most of the noise.
How a one-or-zero rides on a continuous wave.
Knowing the channel can carry ten million bits per second tells you nothing about how to represent those bits as voltage, light, or radio. Encoding is the layer that maps abstract ones and zeros onto physical waveforms the receiver can decode. Different encodings exist because they trade different properties: clock recovery, bandwidth efficiency, robustness to noise.
The most naive encoding is NRZ (Non-Return to Zero). High voltage means 1; low voltage means 0. The signal sits at one of two levels and changes only when a bit differs from the one before it. It is dead simple, with one fatal weakness: a long run of identical bits looks like a flat line. The receiver, reading bits at some clock rate, has no way to know when one bit ends and the next begins. Drift even slightly out of sync and the receiver counts one bit too many or too few, so every bit after it lands one place out.
Manchester encoding solves the synchronisation problem by embedding the clock in the data. Every bit is split into two halves; a transition in the middle carries the bit value (in Ethernet's convention, rising for a 1 and falling for a 0). There is a transition in every bit period, no matter what the data is. The receiver locks onto those transitions and stays in sync indefinitely. The cost is double bandwidth: every bit needs two half-bit slots. The first standard Ethernet (Section 05) used Manchester encoding because it could not afford to lose synchronisation on a long run of zeros.
The bits 1 0 1 1 0 0 1 in Manchester code: each mid-bit edge gives the bit and keeps the receiver's clock in step.
How it works
- Two conventions. Ethernet (IEEE 802.3) uses rising for 1; the older G. E. Thomas convention is the reverse. Either works if both ends agree.
- The bandwidth. 10 Mbps Ethernet carries up to 20 million signal changes per second, which is why the next speed, 100 Mbps, moved to more efficient line codes.
- Boundary edges. Between two equal bits the line must also change at the boundary, to be on the right side for the next mid-bit edge.
Sent to a receiver whose clock runs fast, NRZ's four zeros are one flat stretch with nothing to correct against, so the receiver reads five zeros. Manchester gives it an edge in every bit, so it corrects its clock each time and reads all seven bits correctly.
How it works
- Real drift. Real clocks differ by parts per million, not 20%, but over a long enough run of identical bits the error adds up the same way.
- The compromise. Modern links use codes such as 8b/10b and 64b/66b, which keep NRZ's simplicity but bound the longest flat run: 8b/10b never repeats a bit more than five times, and 64b/66b guarantees an edge in every 66-bit block.
- NRZ. Non-return-to-zero simply holds the level for each bit: high for 1, low for 0.
Radio, DSL and cable modems cannot send bare on-and-off levels like those of Fig 8.6. The bits ride instead on a carrier wave, a steady high-frequency wave the medium carries well. Modulation changes one property of the carrier in step with the data: its size (amplitude, AM), how fast it oscillates (frequency, FM), or where each cycle starts (phase, PSK). QAM (Quadrature Amplitude Modulation) changes size and phase together, so each symbol, one short stretch of the wave, carries several bits.
The bits 1 0 1 0 carried three ways: with each bit the wave's size, its speed or its starting direction changes. Wi-Fi and cable modems change size and phase together (QAM), packing many bits into each symbol: up to 10 in Wi-Fi 6, but only on a far cleaner signal than the 20 dB point in Fig 8.4.
How it works
- Noise. Interference mostly disturbs amplitude, so FM and PSK resist it better; Edwin Armstrong patented FM in 1933 for exactly that reason.
- QAM. 16 combinations of size and phase carry 4 bits per symbol; Wi-Fi 6 uses 1024 combinations (10 bits) and Wi-Fi 7 uses 4096 (12 bits) when the signal is clean, dropping to fewer as it degrades.
Metcalfe, 1973: many computers, one cable.
In 1973, Bob Metcalfe at Xerox PARC invented Ethernet, carrying onto a wire an idea from a radio network in Hawaii. The rule is plain: any number of computers share one cable; they all listen; whenever no one else is talking, anyone can send; if two start at the same time and the signals collide, both detect it, both back off for a random interval, and both try again. That rule is Carrier Sense, Multiple Access, with Collision Detection: CSMA/CD. In ever faster versions, Ethernet became the dominant local-area networking technology on the planet.
Metcalfe's Harvard PhD thesis on packet networking had been rejected (the committee felt it lacked theoretical depth), and the rejection sent him into a foul mood and onto a flight to Hawaii, where he had heard about a packet-radio network called ALOHAnet built by Norm Abramson at the University of Hawaii. ALOHAnet let the islands' campuses share one radio frequency by transmitting whenever they had data and retransmitting after random delays when collisions occurred. Metcalfe spent weeks there modelling the system, realised Abramson had badly underestimated how much of the channel's time could carry data with smarter timing, wrote the corrections into a revised thesis, and got his doctorate. Ethernet was the same insight on a wire, improved with carrier sensing ("listen before transmit").
The Xerox PARC of 1973 held an unusual concentration of computing talent. Down the hall from Metcalfe, Chuck Thacker and Butler Lampson were building the Alto, a personal computer with a screen that drew pictures (the machine that later showed Steve Jobs what a graphical interface could be), and Gary Starkweather had brought the laser printer to life. Metcalfe's job was to network these machines together. His first Ethernet memo, dated May 22, 1973 and full of hand-drawn diagrams, shows the architecture: many machines tapped onto one shared cable, the "ether".
PARC's original Ethernet ran at 2.94 megabits per second; the standardised 10BASE5 that spread through the industry ran at 10, over a single thick coaxial cable up to 500 metres long: the "thicknet" of the 1980 DIX standard (DEC, Intel and Xerox). By the 1990s, switches replaced the shared cable. Each device got its own dedicated cable to the switch; with no one else on the wire, collisions stopped happening, and the collision-detection machinery now mostly sits unused. But every Ethernet frame (the block of bits sent in one go) still starts with a header designed for that shared cable, which names sender and receiver by 48-bit MAC address (below).
"Members and affiliates of the Intergalactic Computer Network."
J.C.R. Licklider, ARPA memo salutation, 1963Two stations hear a quiet cable and start at almost the same moment; their signals collide, both notice, send a short jamming signal and stop. Each then waits a random number of slots (the time a signal takes to cross the cable and back), so one goes first and the other finds the line busy.
How it works
- The backoff. In truncated binary exponential backoff, after the k-th collision in a row a station waits a random 0 to 2k − 1 slot times (k stops growing at 10), and gives up after 16 tries.
- Why random. If both waited the same time they would collide again; each further collision doubles the range of waits, so the stations spread out as the line gets busier.
- Today. Wi-Fi uses the same random backoff but tries to avoid collisions rather than detect them.
Every Ethernet device has a MAC address (Media Access
Control; no relation to Apple's Mac), a 48-bit
identifier burned into the network card at manufacture. The first 24 bits
are the OUI (Organizationally Unique Identifier),
assigned to the manufacturer by the IEEE; the next 24 are the
device-specific portion. So the address tells you who built the card:
older Raspberry Pi boards begin B8:27:EB, newer ones DC:A6:32
and other prefixes; Apple's begin
00:03:93 or any of a few hundred other prefixes. Public
databases map every OUI to its owner.
MAC addresses identify devices on the local link; IP addresses, which
we'll meet in Chapter 9, identify them on the global network.
ARP (Address Resolution Protocol) bridges the two. When
a host wants to send a packet to 192.168.1.5 on its own local network, it broadcasts a question to every device on the link: "Who has
192.168.1.5? Tell me your MAC." The owner replies; the asker caches the
answer for a while (seconds to minutes, depending on the system); subsequent packets to that IP go straight to
the matching MAC.
One MAC address split into maker and card, and the ARP exchange that finds it: broadcast the question, the owner replies, the answer is cached.
How it works
- Expiry. Entries age out after seconds to minutes, depending on the system, so a device that leaves or changes card is soon forgotten.
- No proof. ARP checks nothing: any host on the link can answer for any address. Chapter 15 returns to what that allows.
A hub repeats every frame out of every port. A switch learns which address sits behind which port by reading the source of each frame, floods only while a destination is still unknown, and after that sends each frame down the one right cable.
How it works
- Self-configuring. Nobody fills the table in: it builds itself from traffic, and entries expire when a device stops talking.
- No more collisions. With one device per switch port and both ends able to send at the same time (full duplex), collision detection never fires.
- Broadcasts. Frames addressed to everyone, such as ARP requests, still go out of every port.
MAC flooding: when a switch forgets it is a switch.
A switch's MAC table has finite size, usually a few thousand entries
on consumer hardware and tens of thousands on enterprise gear. An
attacker with access to one port can rapidly send frames with a
million different fabricated source MACs (the burned-in address is only a
default: software writes each frame's source field, and the switch takes it on
trust). The switch records each one, fills the table to capacity, and so can no
longer keep or relearn the real entries as they expire; with real destinations
unknown, it falls back to what it does when it does not know which port a
destination MAC sits on: flood the frame out of every port. The switch has been downgraded to a
hub, and every frame on the LAN is now visible to the attacker. This
attack, called MAC flooding,
was packaged into a point-and-shoot tool, macof, around
1999 and is the reason serious networks turn on port security, a cap on how many addresses each switch port will learn. The pattern recurs across networking: the
polite, table-based, learning-by-listening designs of the 1990s assumed
every participant played fair, and an attacker who declined to could
turn cooperative infrastructure against its users.
Why every textbook draws the same cake.
The layer model is why network engineers can talk about network problems precisely. Each layer does one thing only. Each layer is a customer of the layer below and a provider for the layer above. On the way out, each layer hands its data to the layer below, which wraps it in a header of its own; on arrival each layer removes its header and hands the rest up (Fig 8.11). Once you've drawn the layers, nearly every protocol falls into one slot, and every conversation about networking becomes "which layer is this happening at?"
The canonical reference is the OSI seven-layer model, named for Open Systems Interconnection and standardised by the International Organization for Standardization in 1984. Bottom to top: Physical, Data link, Network, Transport, Session, Presentation, Application. Each layer is named after the abstraction it provides. Physical moves bits over a medium. Data link moves frames between machines on the same local network, over cable, switch or radio link. Network moves packets across many networks joined together. Transport moves byte streams reliably or messages unreliably end to end. Session, Presentation, and Application are about what the bytes mean.
The TCP/IP four-layer model is the one that actually runs the internet. It collapses Physical and Data Link into a single "Link" layer (since the IP layer doesn't care which kind of link is below it), and collapses Session, Presentation, and Application into a single "Application" layer (since real applications usually handle their own session semantics). Even so, the OSI model remains the teaching reference because its separations are cleaner to teach.
Each layer serves the one above, and most add their own wrapping on the way down: TLS (the encryption of Chapter 11) around the request for a page, then a TCP header, an IP header, and an Ethernet header and checksum, until layer 1 sends it as signals.
How it works
- Examples. 7: HTTP, DNS, SSH. 6: TLS (its placement varies), compression. 5: session handling. 4: TCP, UDP. 3: IP, ICMP. 2: Ethernet, Wi-Fi. 1: copper, fibre, radio.
- On arrival. The receiver works upward, each layer removing its own header and handing the rest up, in the reverse order.
- The standard. ISO published the model in 1984 as ISO 7498; its protocols lost to TCP/IP, but its layer numbers stayed in engineers' vocabulary.
Read across: TCP/IP's Application covers OSI's top three layers and its Link the bottom two. OSI says where a feature belongs; TCP/IP describes what is on the wire.
How it works
- The names. TCP/IP's layers come from RFC 1122 (1989): link, internet, transport, application.
- Where TLS sits. It encrypts between the application and TCP, which is one reason neither model places it cleanly.
The seam to Chapter 9
Chapter 8 has been about the physical and link layers: how a single bit makes it across one hop. Chapter 9 climbs to the network layer. Every mechanism so far has moved bits between two devices on one wire, or a few on one Ethernet segment. The internet is billions of devices on tens of thousands of independently administered networks, none aware of most of the others, and a packet must find its way across all of them from any source to any destination. The idea that made this work was small, strange, and explicitly Cold War.