I · One Machine · Chapter 5

The Second Network

By the end of the year the courtyard has filled up. There are a dozen machines in your building and a dozen in Mira’s, and the switch in the courtyard has run out of sockets. So you buy a second switch, put it in Mira’s building, and run a single wire from it across the courtyard to yours. You now have two switches, one link between them, and twenty-four machines.

It works, and it works without your having to tell the switches anything about each other. Mira’s switch sees frames arriving on the courtyard wire with your building’s names in the source field, and it learns what it always learns, that those names live on that socket. Your switch learns the mirror image. From the point of view of any one machine there is still a single network. The only difference is that the tables inside the boxes have grown a little longer.

So you keep going. The building next door wants in, and then the one after that. Someone runs a wire down the street, and by spring there are eleven buildings, each with a switch, all linked, and three hundred machines among them. Then somebody in the next street over hears about it.

It is worth following what happens inside the switches as this grows. Every switch on the street has to know where every machine on the street is, because any machine might send a frame to any other and the switch has to know which socket to copy it onto. So every switch’s table holds a row for every machine. Three hundred machines means three hundred rows, in each of eleven boxes. Ten thousand machines across the neighbourhood means ten thousand rows in every box. A city means millions of rows in every box, and each row is a separate fact that had to be separately learned by watching a frame go by.

The facts also go stale. Priya moves her machine from the ground floor up to Theo’s flat, which is the same building but a different socket. Every switch that had learned that Priya’s name lives on the old socket is now wrong, and it stays wrong until it happens to see a frame arrive from her new position. In the meantime her frames are being copied onto a wire she no longer sits on.

Then there is the special name from Chapter 4. A frame addressed to everybody has to be copied to every socket on every switch, because that is what the name means. On one courtyard that was a dozen machines being interrupted. On a city, it is every machine in the city being interrupted every time anyone, anywhere, asks a question of the room. Machines ask questions of the room constantly, as you will see in the next chapter, and if that happens a few thousand times a second the wires carry nothing but broadcasts.

loading…

Add buildings to the street and machines to the buildings, and watch the switch tables grow: one row per machine, in every box, without limit. Then switch to the second scheme and watch the same tables collapse to a handful of rows.

None of this is a flaw in the switch. The switch is doing what it did in Chapter 4, and doing it faithfully. The flaw is in the names. Look at one of them:

a4:83:e7:2b:91:0c

It says which factory made the card, and that is all it says. It says nothing about which street, which building, or which switch. So the only way for any box to know where that name is, is to have been told, which means to have seen a frame from it and remembered. There is no way to group such names, no way to say “everything in Mira’s building”, no way to summarise. Every machine is its own separate entry, forever, in every box. The warning at the end of Chapter 4 has come due.

Suppose instead that Mira’s building were building 12, and every machine in it had a name that began with 12. There would be machine 12.1, machine 12.2, and so on. Your building is 7, and you are 7.3.

Now think about the box in the middle of the courtyard, between your building and hers. A frame arrives for 12.9. The box does not need to have seen 12.9 before, and it does not need a row for 12.9. It needs one row, which says that anything starting with 12 goes across the courtyard. That one row covers the whole building, including machines that have not been plugged in yet.

The idea extends as far as you care to take it. Say the street is 40, so that Mira’s building is 40.12 and her machine is 40.12.9. A box at the end of the street holds one row for the whole street: anything starting with 40 goes this way. A box in the next city holds one row for your entire city. The tables stop growing with the number of machines and start growing with the number of places, and there are vastly fewer places than machines.

Priya moving upstairs no longer changes anything for the box in the courtyard. She is still in building 12, and the box’s row still says that building 12 is across the courtyard. The switch inside the building has to relearn her socket, but that is one switch, one building, and a dozen machines, and nobody outside the building needs to know. The name for everybody can be scoped as well. Everybody in building 12 is now a thing you can say, because building 12 is a thing that exists in the naming, and the rest of the city does not have to hear it.

This is the whole idea, and it deserves to be stated plainly before we dress it up. A name that encodes location can be summarised, and a name that does not encode location cannot. Every box in the middle of a network is a table, and the only way to keep the tables small is to give the names a hierarchy.

There is a consequence, and it is the reason this chapter exists rather than being a footnote to the last one. The factory that made your card had no idea it would end up in building 7 on street 40. It could not have known. Cards are made by the million and shipped everywhere. A name that encodes location can only be assigned at the location, when the machine is plugged in, by someone or something that knows which building this is.

So this is a second name. The card keeps its factory name, and there is no way for it not to, since the name is in the hardware. But the machine also acquires a location name, assigned when it joins a network and changed if it moves to a different one. Your machine now has two names. One says who it is, and one says where it is.

You may well wonder why you do not throw the factory name away and use the location name for everything. It is a good question, and it is the whole of the next chapter. For the moment the position is that you have been handed two names by two different mechanisms for two different reasons, and neither can do the other’s job.

Let’s build the location-aware box properly. It sits between two wires, say your building’s switch on one side and the courtyard link on the other, and it has a card on each. Frames arrive on one card. Rather than looking at the factory name in the frame header and remembering which socket it came from, this box looks inside the frame, at the content, where the location name of the final destination is written. It compares the building part of that name against its table, which is short, one row per building or per group of buildings it knows about, and decides which card to send the frame out of. Then it builds a new frame on that side and sends it.

loading…

Two buildings, a switch in each, and a box between them with a card on each side. The switches forward by factory name within a building; the box forwards by location name between them. The table in the box has two rows.

The box does not need to know where any individual machine is. It needs to know where buildings are. If it has never seen 12.9 before it does not care; 12.9 starts with 12, and 12 is across the courtyard.

What you have built is what the field calls a router, and the location name is an IP address. The building part of the address is the network part, and the rest, the part that picks out one machine within the building, is the host part. A group of machines that share a network part and can reach each other through switches alone, with no router between them, is a subnet.

The real thing is thirty-two bits long and is written as four numbers, each from 0 to 255:

203.0.113.9

with a notation for saying how many of those bits are the network part:

203.0.113.0/24        first 24 bits are the network; last 8 pick the host
└────┬────┘
 the building

So 203.0.113.9 and 203.0.113.42 are in the same building, since they share their first twenty-four bits, and 198.51.100.7 is somewhere else entirely. The number after the slash marks the line between where and which. The thirty-two-bit pattern of ones up to that line and zeros after it is called the subnet mask, and it is precisely the tool a router needs in order to ask “which building?” of any address. It masks off the host part and looks at what is left.

There is one more piece, and it is on your side rather than the router’s. Your machine wants to send to Mira, and it knows her IP address. What should it do with the frame? It could hand it to the switch, addressed to Mira directly, or it could hand it to the router.

It decides by comparing. It takes Mira’s address, masks off the host part, and looks at the network part. If that matches its own network part, she is in this building, and the frame goes to the switch addressed to her. If it does not match, she is somewhere else, and the frame goes to the router, which can worry about the rest.

For this to work your machine has to know where the router is. It is told, when it joins the network, alongside its IP address and its mask: this is your address, this is your building’s mask, and this is the address of the box that leads out. That last item is called the default gateway, and it is where frames go when they are not for anyone here. Three facts, configured once, and your machine can reach anything: its own address, its mask, and the way out.

The idea in this chapter is larger than addresses, and you will want to recognise it when it comes back. You had a flat space of names, and everything that had to find things in that space needed a complete list. You imposed a hierarchy, a prefix that means this region and a further prefix that means this sub-region, and after that the things in the middle only needed to know about regions rather than individuals. The cost was that names had to be assigned according to the hierarchy rather than freely. The benefit was that the whole system could grow without every part of it growing.

You are going to make this move again. You will make it with the things a server holds, when one program has too many resources to name them flat. You will make it with human-readable names, when one list of every name in the world stops being possible. And you will make it with data, when it no longer fits on one machine and has to be divided by some prefix of its key. Each time the move is the same: put a structure on the names so that the middle can summarise.

Coming up · I·6 — Two Names for One Machine

Two names, from two mechanisms, for two reasons. The next chapter is about why both survive, and about how a machine that has only its factory name manages to acquire its location name at all.

→