Skip to content

Rollback Netcode, Featuring Frame-Based Simulation, Input Prediction with Confirmation, Automatic Rollback and Replay, UDP Socket Communication with Reliable Messaging, Real-Time Latency Measurement, Packet Loss Simulation, and Connection Management

Notifications You must be signed in to change notification settings

WillKirkmanM/rollback-netcode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rollback Netcode

Rollback Netcode, Featuring Frame-Based Simulation, Input Prediction with Confirmation, Automatic Rollback and Replay, UDP Socket Communication with Reliable Messaging, Real-Time Latency Measurement, Packet Loss Simulation, and Connection Management

Features

  • Frame-based simulation: The game state is updated in discrete frames, ensuring determinism.
  • Input prediction and confirmation: Local inputs are predicted immediately, while remote inputs are confirmed when they arrive.
  • Automatic rollback: When a late input arrives, the game state is rolled back to the correct frame, and the simulation is replayed.
  • Frame confirmation: Confirmed frames are used to clean up old data and reduce memory usage.
  • UDP Socket Communication: Real network I/O using tokio's UdpSocket
  • Packet Structure: Sequence numbers, acknowledgments, and timestamps
  • Connection Management: Handshake protocol and heartbeat monitoring
  • Ping/Latency Measurement: Real RTT calculation
  • Packet Loss Simulation: Optional packet loss for testing
  • Reliable Messaging: Basic acknowledgment system
  • Disconnect Handling: Proper cleanup when players leave

Usage

  1. Clone the repository:

    git clone https://github.com/WillKirkmanM/rollback-netcode
    cd rollback-netcode
  2. Run the project:

    cargo run -- host

    In another terminal:

    cargo run -- client 127.0.0.1:8000

    This will start two instances of the game, one acting as the host (player 0) and the other as the client (player 1). The client connects to the host via UDP.

About

Rollback Netcode, Featuring Frame-Based Simulation, Input Prediction with Confirmation, Automatic Rollback and Replay, UDP Socket Communication with Reliable Messaging, Real-Time Latency Measurement, Packet Loss Simulation, and Connection Management

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages