A layer is a piece of a bigger system that only ever talks to its own neighbours: the layer directly above it, and the layer directly below it. It never talks straight to a layer further away. A layer really has two neighbours to answer to at once, though: whatever its neighbour above hands it, and whatever its neighbour below hands it. In one step it reacts to both, and answers both back: something to send up, and something to send down.
Two layers can only sit next to each other when they agree on exactly what crosses the boundary between them. What one layer calls “what I hand down” has to be exactly what the layer below it calls “what I receive from above”: the very same values, on the very same ports.
As an example, here are the five layers a computer network is commonly built from, listed from the top (closest to the program sending something) down to the bottom (closest to the wire):
The application layer is where the program lives that actually wants to send or receive something.
The transport layer makes sure that what arrives at the other end matches what was sent, in the right order and without any of it missing.
The network layer moves what it is given across many networks, by choosing a path for it to travel along.
The data link layer moves what it is given between two machines that are directly connected to each other.
The physical layer turns what it is given into a raw signal, such as an electrical current, a beam of light, or a radio wave, and sends that signal out.
Six boundaries separate these five layers: one above the application layer, one below the physical layer, and one between every pair of neighbouring layers in between.
A layer sits between the interface it shares with its neighbour above (up) and the one it shares with its neighbour below (down). In one step it reacts to whatever both neighbours hand it at once, an input from above and an input from below, and answers both at once, an output to above and an output to below.
A layered architecture of n layers. interface k names the boundary directly above layer k (there are n + 1 boundaries in total for n layers: one above the very first layer, and one below every layer including the last). Consecutive layers automatically agree on what crosses the boundary between them, since they both refer to the very same interface value there.
A computer network’s own layered architecture: exactly the five layers described in this file’s own introduction, an instance of the general LayeredArchitecture above.