TR Version
Atlas Atlas Network Engineer • • 1,154 words • 6 min read

How Multiplayer Games Rewind Time: Netcode Lag Compensation

Discover how online games hide physical network latency through client-side prediction, server reconciliation, and rollback netcode architecture.

#netcode #gaming #latency #networking
How Multiplayer Games Rewind Time: Netcode Lag Compensation

TL;DR (Direct Answer): Multiplayer games cannot show true real-time reality because data takes physical time to travel across cables. Game engines hide delay through lag compensation, running local simulation ahead and rewinding server history when players shoot. Server checks past positions, verifies hits, and snaps incorrect client states back into alignment. Without this architecture, fast online action feels sluggish across long distances.

Letter-Mail Duel: Why Real-Time Is Physics Myth

Two duelists stand ten paces apart. Duelists cannot see each other directly. Players write movements on paper letters, hand letters to mail carriers. Mail carrier takes three days to cross town. Duelist shoots based on letter received Monday. Target already moved elsewhere Tuesday.

Light in fiber optic glass moves 200 kilometers per millisecond. Cross-continent packet takes 50 to 80 milliseconds round trip. Direct real-time synchronization breaks physical laws. Game code must predict future actions and roll back calculation mistakes. Inspect visual network paths directly on AI Playground.

Netcode Pipeline: How Games Hide Delay

Online games synchronize separate physical realities through strict tick loops. When you press buttons, engine executes five distinct steps to keep gameplay smooth:

  1. Input Sampling: Local client reads keyboard, mouse, or gamepad hardware inputs at start of local tick.
  2. Client-Side Prediction: Game client applies your movement immediately on screen so controls feel instant without waiting for network response.
  3. Server Snapshot Validation: Client bundles inputs into UDP packets with tick timestamps and sends them to authoritative server.
  4. State Reconciliation: Server runs authoritative physics simulation, compares received inputs against world state, and broadcasts definitive world snapshot back to all clients.
  5. Lag Compensation Rewind: When shooter fires weapon, server inspects packet timestamp, rewinds target hitboxes back to that exact past tick, verifies line of sight, registers hit, and restores current time.

Delay-Based Lockstep vs Rollback Architecture

Delay-based lockstep waits. Player presses button. Game delays local action until opponent input arrives across network. When ping spikes, game freezes. Controls feel like moving through mud.

Rollback netcode predicts. Action executes on local screen instantly at frame zero. Opponent inputs arrive later over network. Engine checks predicted state against received state. If mismatch occurs, engine rewinds game state, applies true input, and resimulates frames forward within single visual tick.

Feature Delay-Based Lockstep Rollback Netcode
Input Response Latency creates input delay Instant local execution
Packet Spikes Screen freezes, game stutters Visual snap, smooth gameplay
CPU Overhead Low, single physics run High, multiple tick resimulations
State Storage Minimal frame cache Deep circular state ring-buffer
Genre Match Turn-based strategy, RTS Fast shooters, fighting games

Visualizing Time: Round-Trip Delay vs Rollback Tick Timeline

Diagram shows client firing shot while target moves on authoritative server.

Shooter Client (30ms travel time to server):
Tick 100: Fire shot at target (sees target at Position X)
          [Send packet with timestamp: Tick 100]

Server World State Timeline:
Tick 100: Target at Position X
Tick 101: Target moves to Position Y
Tick 102: Target moves to Position Z
Tick 103: Packet arrives. Server detects Tick 100 timestamp.
          Server rewinds Target hitbox back to Position X.
          Server confirms line of sight, applies damage.
          Server snaps Target back to Position Z for Tick 104.

Server rewinds time to validate shooter view, preventing artificial lead-aim requirements.

Netcode Myths: Shot Behind Walls and High Ping Advantage

Dying behind cover frustrates players. Root cause is server lag compensation window, not bad collision meshes.

Target sprints behind brick wall on local screen. High-ping shooter fired shot 80 milliseconds earlier when target stood exposed in open doorway. Packet reaches server late. Server validates shooter packet timestamp. Server rewinds target hitbox back into open doorway. Server awards kill. Target drops dead behind cover. Target view lags behind server truth.

High ping does not give pure advantage. High latency introduces peeker advantage when rounding corners, but causes severe desync penalties. High-ping player suffers late hit notifications, dropped inputs, and harsh position rollback snaps. Test latency physics inside Interactive Engineering Simulations.

Real-World Case: Street Fighter V Rollback Failure vs GGPO Standard

Street Fighter V launched with flawed rollback netcode in 2016. Custom netcode failed to synchronize system clocks evenly between opponents. One player machine drifted ahead in simulation time. Forward machine received opponent inputs too late to predict smoothly. Forward player suffered one-sided rollback: teleporting punches, massive visual stutter, unplayable frames. Opponent experienced perfectly smooth gameplay.

GGPO (Good Game Peace Out) middleware solved this issue through balanced clock synchronization. GGPO syncs simulation time bases, predicts inputs accurately, and hides resimulation behind smart visual blending. Modern competitive titles abandon delay-based netcode and flawed custom implementations in favor of GGPO-style rollback standards.

Frequently Asked Questions (FAQ)

What is the difference between tick rate and frame rate?

Tick rate measures how many times per second game server updates physics, positions, and game logic (typically 60Hz or 128Hz). Frame rate measures how many visual images your local graphics card displays each second (such as 144Hz or 240Hz). High frame rates smooth visual motion on screen, but game rules, shot registration, and movement resolve strictly on fixed server tick intervals.

How do interpolation delay settings affect multiplayer hitboxes?

Interpolation delay buffers received server snapshots by small window (typically 15 to 30 milliseconds) to render smooth enemy movement between ticks. Client displays smoothly blended past positions instead of jerky snapshots. Setting interpolation buffer too high adds artificial visual delay, showing opponents behind their actual server position. Setting interpolation buffer too low causes enemy models to jitter when packets arrive out of order.

How does packet loss concealment prevent character teleportation?

When network drops incoming UDP coordinate packet, engine uses packet loss concealment to estimate movement. Engine extrapolates character velocity vector forward along last known trajectory. Character continues running in current direction until valid packet arrives. If next packet reveals player changed direction, engine smoothly blends character to true location, hiding temporary network drops without freezing whole simulation.

Why do real-time multiplayer games use UDP instead of TCP?

TCP enforces guaranteed delivery and strict packet ordering through handshake acknowledgments. When TCP packet drops, connection halts all incoming data until missing packet retransmits, creating massive latency spikes. Real-time games use UDP because speed matters more than complete reliability. Dropped position packet becomes obsolete immediately; engine discards old data and processes newest incoming coordinate packet without delay.

How does Wi-Fi network jitter degrade rollback netcode performance?

Wi-Fi uses shared radio frequencies vulnerable to radio interference, wall obstacles, and channel competition. Signal fluctuations cause network jitter, meaning packet arrival times vary wildly between ticks. Rollback netcode depends on stable, predictable time offsets between machines. Unstable packet delivery forces engine to constantly resize prediction windows, causing sudden visual teleports, dropped hit confirms, and jarring audio glitches during matches.

Related Engineering Deep Dives

All Articles →