The Tower So Far
Mira types on my way into Courtyard and presses enter. There is no new agreement in this chapter. The tower is built, and what follows is one climb back down through it, with every floor in place, so that you can see it as a single thing before Part II takes it apart. Follow those nine characters all the way to your screen.
Her client begins by shaping the message. It wraps the text in a message body, with sender, text, and timestamp, following the rules for compatible evolution from Chapter 19, so that your client can read it whatever version it happens to be running. Since it is a chat message it goes as a push frame, a type byte, a length, and the body, in the shape of Chapter 18. If this were a request to the feed instead, it would be a verb and a path and headers, from the same chapter, carrying an idempotency key if it were the kind of request a lost reply could duplicate (Chapter 20).
Before it goes anywhere, security wraps it. The whole thing is encrypted and tagged against tampering, inside the secure channel that was established when the connection opened; the key was exchanged then, and Mira’s certificate was verified then against your trusted roots (Chapter 21). From here down, everything is opaque to anyone watching.
The transport makes it reliable. The encrypted bytes are handed to the stream, which was the choice of Chapter 17: chat is text, every byte matters, so the reliable stream and not datagrams. The stream is a connection, opened earlier with a three-way handshake on unpredictable starting numbers (Chapter 12) and kept alive by heartbeats so that each side knows the other is there (Chapter 13). The bytes are numbered (Chapter 11). If they are too big for one frame they are cut into pieces (Chapter 10); on my way is not, but a photo would be. The transport will not send faster than your machine can receive, which is the flow control of Chapter 14, or faster than the path can carry, which is the congestion control of Chapter 16, and it keeps a copy of everything until you acknowledge it, ready to resend (Chapter 11). It stamps on the two ports, hers ephemeral and yours the one Courtyard listens on (Chapters 7 and 8).
The network addresses it. Each piece gets a location header, with your machine’s address as destination and hers as source (Chapter 5). Her operating system asks whether you are in her building. You are not; you are across the city, so the piece is bound for the router, the way out (Chapter 5).
The link carries it one hop. To hand the piece to the router, her machine needs the router’s identity, which it looks up, or remembers from its cache (Chapter 6). The piece is wrapped in a frame, with the router’s identity as destination and her card’s as source, a start marker so the boundary can be found, and a check so damage can be caught (Chapters 2, 3, and 4). Her card puts it on the wire as bits (Chapter 1).
The frame reaches the switch, which forwards it by identity toward the router (Chapter 4). The router opens the frame and reads the location header, not the identity, which was only ever for that one hop. It consults its table and sees that your building is reachable one particular way (Chapter 5). It wraps the piece in a new frame, addressed to the next identity on the path, and sends it on. The letter is untouched; the envelope is replaced at every hop, all the way across (Chapter 6). Between the buildings the piece may be reordered, delayed, or dropped by a full queue, and the transport at the ends, not anything in the middle, will deal with it (Chapter 10).
On your side, your card sees a frame addressed to its identity, checks it, finds that the check passes, strips the frame, and hands the contents up (Chapters 2, 3, and 4). Your operating system reads the location header and finds that it names this machine (Chapter 5). It reads the port header and finds Courtyard’s port. It reads the four-tuple and finds the connected socket for this conversation, not the listening one but a particular connection with Mira (Chapters 7 and 8). It places the piece by its number into that socket’s buffer, filling any gap and discarding any duplicate, and acknowledges what it now has in sequence (Chapter 11). It advertises how much room remains (Chapter 14).
Your Courtyard program, parked at the top of its event loop, is told that the socket is readable (Chapter 9). It reads the bytes, but only a complete message, since it knows where the message ends from the length in the frame (Chapter 18). It passes them through the secure channel, which decrypts them and verifies the integrity tag, and finds them unaltered (Chapter 21). It parses the body by the evolution rules, ignoring any field it does not recognise (Chapter 19). It is a message of type “text”, and the program shows it. on my way appears on your screen.
Sender · Application — shape: sender, text, time
The message is wrapped floor by floor going down, carried across a box that promises almost nothing, and unwrapped floor by floor going up. The full list of rungs, each linking to the chapter that earned it, is in the rail beside this page.
The whole tower, with one message tracing through it, top to bottom on Mira’s side and bottom to top on yours. Any rung can be clicked to reach the chapter that built it and the failure that made it necessary. This is the diagram every later chapter adds to.
You built that, every floor of it, because the floor below was not enough. Only now, because a name is a label for a thing you understand, is it time for the names the world uses to group these floors into layers.
The frame, the identity, the wire, and the switch, which occupied Chapters 1 through 4, make up the link layer: one hop, one physical medium, machine to machine across a single wire. The location header, the router, and forwarding by prefix, from Chapters 5 and 6, make up the network layer, also called the internet layer. It runs end to end across many hops and is read by every box on the path. The ports, the connection, reliability, flow, congestion, and the two transports, from Chapters 7, 8, and 10 through 17, make up the transport layer. It also runs end to end, but it is read only at the two ends. Its two members have the names you have been avoiding: the reliable stream is TCP, and the datagram service is UDP. The message shapes, the verbs, the evolution rules, the security, and the retry logic, from Chapters 18 through 21, make up the application layer, which is what the two programs actually say to each other.
Four layers, then: link, internet, transport, application. That is the model the internet is actually built on, and it is called the TCP/IP model after its two most important members. You will also meet a seven-layer version called OSI, which splits the application layer into three and adds names you will rarely use in anger. When someone says that a problem is a layer 7 problem they mean the application, and layer 3 means the network, and layer 2 means the link, counting OSI’s way.
The layers are a good story, and like all good stories they simplify. There are three places where the tidy picture is not quite true, and each is a thing you have already seen. The first is that the layers peek at each other. The transport’s checksum, in the real TCP, is computed partly over the network layer’s addresses; it reaches down a layer to make sure a piece was not misdelivered. And the boxes in the middle, which the model says should touch only the network layer, routinely read the transport ports to make decisions, and in Part II you will meet ones that rewrite them. The layers are not sealed. They are a description of concerns, not a set of walls.
The second is that security has no floor of its own. TLS from Chapter 21 sits above the transport and below the application, which is no layer in the four-layer model at all. It was bolted on, years later, into a gap the model had not anticipated, and that is why it feels like a separate thing you turn on rather than a rung you always had.
The third is that one layer’s single hop is another layer’s whole world. The link layer’s one hop across a wire hides, for a home connection, an entire second network of its own. The path from your building to your provider has its own framing, its own addressing, and its own switches, all beneath what your machine calls the link. The tower is a tower of towers, and the model draws one floor where reality has a basement.
None of this makes the model wrong. It makes it a map, and maps leave things out on purpose so that you can hold the shape in your head. You now know both the shape and the places where the shape is not the territory, and that is the right way to hold it.
Part I is complete. On one machine, or between two on a wire you can see, you can now get any message from any program to any other, reliably or in real time, in order, intact, unreadable by strangers, and robust to every failure the local world can produce. You built it as a tower of agreements, floor by floor, and you can name every floor. One thing remains to look at before you leave the single machine, which is that it is slower than it should be. The tower is correct, and a fast wire under it runs at a fraction of its rated speed, and the reason is in the machine itself, in everything the operating system does between the card and your program. That is the last chapter of Part I, and then Mira moves away, and the wire you have been standing on disappears.
Coming up · I·23 — It Works, and It's Too SlowThe tower is correct and the machine is saturated at a tenth of what the wire can carry. Every frame interrupts the processor, and every layer copies the payload again. Chapter 23.
→