Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
R

reliable

> 编程语言
Open source

Packet acknowledgement system for UDP

654 stars0 likes0 views
WebsiteGitHub

About

Packet acknowledgement system for UDP

Introduction

If this library helps you, please support it: Become a supporter

reliable is a simple packet acknowledgement system for UDP-based protocols.

It's useful in situations where you need to know which UDP packets you sent were received by the other side.

It has the following features:

  1. Acknowledgement when packets are received
  2. Packet fragmentation and reassembly
  3. RTT, jitter and packet loss estimates
  4. Duplicate packets are detected and dropped

reliable is stable and production ready.

Usage

Reliable is designed to operate with your own network socket library.

If you don't have one already, try netcode, it's designed to work well with reliable.

First, create an endpoint on each side of the connection:

c
struct reliable_config_t config;

reliable_default_config( &config );

config.max_packet_size = 32 * 1024;
config.fragment_above = 1200;
config.max_fragments = 32;
config.fragment_size = 1024;
config.transmit_packet_function = transmit_packet;
config.process_packet_function = process_packet;

reliable_endpoint_t * endpoint = reliable_endpoint_create( &config, time );
if ( endpoint == NULL )
{
  printf( "error: could not create endpoint\n" );
  exit(1);
}

reliable_endpoint_create returns NULL, in debug and release alike, if the config is not valid or if an allocation fails, and it frees everything it took before it does. Check the result.

For example, in a client/server setup you would have one endpoint on each client, and n endpoints on the server, one for each client slot.

Next, create a function to transmit packets:

c
static void transmit_packet( void * context, uint64_t id, uint16_t sequence, uint8_t * packet_data, int packet_bytes )
{
    // send packet using your own udp socket
}

And a function to process received packets:

c
static int process_packet( void * context, uint64_t id, uint16_t sequence, uint8_t * packet_data, int packet_bytes )
{
    // read the packet here and process its contents, return 0 if the packet should not be acked
    return 1;
}

For each packet you receive from your udp socket, call this on the endpoint that should receive it:

c
reliable_endpoint_receive_packet( endpoint, packet_data, packet_bytes );

Now you can send packets through the endpoint:

c
reliable_endpoint_send_packet( endpoint, packet_data, packet_bytes );

And get acks like this:

c
int num_acks;
const uint16_t * acks = reliable_endpoint_get_acks( endpoint, &num_acks );
for ( int i = 0; i  reliable - Glenn Fiedler and Rowan Claude

The license doesn't require this. It's an official request, and honoring it is appreciated. Fair credit keeps open source honest.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Cackfragmentationgame-developmentmtu

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言