Four machines, one LAN, and a rule that sounds impossible: every machine must compute the same world, or none of them should. Doom had no authoritative server. It had no server at all. It had an array of twelve commands per player [2], a tick that fires thirty five times a second, and a check that compares a single integer between machines and kills the session the moment they disagree [5].

That check is four lines long. Reading it is the fastest way to understand what multiplayer cost in 1993, and why the games that came after it look nothing like it.

The wall

A deathmatch on a 1993 network is not a bandwidth problem. Doom’s packets are tiny; the whole command for one player for one tick fits in eight bytes. The wall is worse than bandwidth: the machines have no way to know they still agree.

There is no server holding the truth. Each machine receives the other players’ inputs and simulates all four players locally, using the same code, the same tables and the same random number generator. As long as everyone runs the same simulation on the same inputs, the four worlds stay identical for free. The moment one of them diverges, by a rounding difference, a dropped packet applied twice, or a bug that reads uninitialised memory, they are playing different games and neither knows.

So the design had to answer a question modern engines avoid by architecture: how do you detect divergence when you have already decided nobody is in charge?

The move, in three parts

Send intent, not state. A command carries what the player did, not where the player ended up [1]. The struct is six fields and eight bytes:

// d_ticcmd.h
typedef struct
{
    char  forwardmove;   // *2048 for move
    char  sidemove;      // *2048 for move
    short angleturn;     // <<16 for angle delta
    short consistancy;   // checks for net game
    byte  chatchar;
    byte  buttons;
} ticcmd_t;

Eight bytes. No positions, no velocities, no float. If the wire carried state, each machine would be told what to believe and the game would be an illusion of authority; carrying intent forces every machine to be the same simulation.

Ship the last twelve ticks, every time. The packet is a header and a run of commands [2]:

// d_net.h
typedef struct
{
    unsigned checksum;      // high bit is a retransmit request
    byte     retransmitfrom;
    byte     starttic;
    byte     player;
    byte     numtics;
    ticcmd_t cmds[BACKUPTICS];
} doomdata_t;

BACKUPTICS is 12, and TICRATE is 35 [2][3]. Twelve tics at 35 hertz is a third of a second of history, and every packet re-sends a window of it, so a lost packet costs latency rather than the session. The packet length is not transmitted; it is implied by numtics, and a length that does not match the implied size is dropped silently, logged only to a debug file [4].

Never run more than five tics ahead. The loop that builds commands stops itself:

// d_net.c
if (maketic - gameticdiv >= BACKUPTICS/2-1)
    break;          // can't hold any more

BACKUPTICS/2-1 is five [4]. Five tics at 35 hertz is 142.9 milliseconds of buffered intent, computed rather than measured. That number is the whole design in one constant: enough slack for the network to deliver a packet, small enough that the player does not feel queued. It is not a bandwidth calculation. It is a patience budget.

The number they compare

Each machine keeps the previous tick’s x position of each player, or the random index if that player has no body this tic:

// g_game.c
short consistancy[MAXPLAYERS][BACKUPTICS];
...
consistancy[i][buf] = players[i].mo->x;

When a packet arrives, its stored value is compared against what this machine remembers:

// g_game.c
if (netgame && !netdemo && !(gametic%ticdup) )
    if (gametic > BACKUPTICS
        && consistancy[i][buf] != cmd->consistancy)
        I_Error ("consistency failure (%i should be %i)",
                 cmd->consistancy, consistancy[i][buf]);

A single integer, one axis, one tick behind. Not a hash of the world, not a checksum of state. It is a smoke alarm rather than a fire investigation: it cannot tell you what diverged, only that something did. And when it fires, the game does not attempt to repair anything.

I_Error means the session ends.

That is the part worth sitting with. A modern engine would resync, roll back, or at least kick the player who drifted. Doom had nowhere to resync to: there is no authority to ask, and no snapshot to rewind. The honest options were divergence without detection, or detection with a hard stop. They chose the stop.

Why demos came for free

The same pipe carries the recorded game. Demo playback reads commands through the same path that multiplayer reads them from the network, and recording writes the same commands out:

void G_ReadDemoTiccmd (ticcmd_t* cmd);
void G_WriteDemoTiccmd (ticcmd_t* cmd);

This is not a feature bolted on later. It is the consequence of a design where the game is a function of inputs: if the simulation is deterministic enough to keep four machines in sync, it is deterministic enough to replay a single machine’s inputs from a file. Doom’s .lmp files are small for the same reason the netcode packets are small.

Every deterministic replay system since, from fighting games to speedrun verification, inherits the same bargain: the replay is small and exact because nobody was trusted with the truth.

The shadow

The cost is input delay, and it is not incidental. A netgame consumes a command only when its tic comes round, and the queue can hold five tics ahead, so a command can wait up to 143 milliseconds between being built and being simulated. The design bought agreement with responsiveness.

Two more costs compound it. The consistency check only samples one value, so a divergence that happens to preserve that x coordinate for one tic passes. And because the check is fatal, a single desync ends the match for everyone; there was no way to drop the offending player, because no machine knew which one was wrong.

Modern netcode is the mirror image. A server that owns the truth costs a server, plus prediction and reconciliation on the client to hide the latency, plus correction paths for when the prediction is wrong. In exchange it can recover from nearly anything, including a player who is cheating rather than merely drifting. Doom chose the cheapest possible version of correctness: everyone computes, nobody decides, and disagreement is fatal.

What the code settles

QuestionAnswer
Does the wire carry state?No. Eight bytes of intent per tic.
How much history is kept?Twelve tics.
How far ahead can input queue?Five tics.
What happens on divergence?I_Error, the session ends.
Are demos a separate system?No, they reuse the command pipe.

References

[1] id Software, DOOM, linuxdoom-1.10/d_ticcmd.h, ticcmd_t. https://github.com/id-Software/DOOM/blob/master/linuxdoom-1.10/d_ticcmd.h

[2] id Software, linuxdoom-1.10/d_net.h, doomdata_t and #define BACKUPTICS 12. https://github.com/id-Software/DOOM/blob/master/linuxdoom-1.10/d_net.h

[3] id Software, linuxdoom-1.10/doomdef.h, #define TICRATE 35. https://github.com/id-Software/DOOM/blob/master/linuxdoom-1.10/doomdef.h

[4] id Software, linuxdoom-1.10/d_net.c, NetbufferSize, the queue bound BACKUPTICS/2-1, and the packet length check. https://github.com/id-Software/DOOM/blob/master/linuxdoom-1.10/d_net.c

[5] id Software, linuxdoom-1.10/g_game.c, consistancy[MAXPLAYERS][BACKUPTICS], the comparison and I_Error ("consistency failure ..."). https://github.com/id-Software/DOOM/blob/master/linuxdoom-1.10/g_game.c