{"id":13523463,"url":"https://github.com/mas-bandwidth/reliable","last_synced_at":"2026-07-09T21:00:28.187Z","repository":{"id":37646799,"uuid":"89861379","full_name":"mas-bandwidth/reliable","owner":"mas-bandwidth","description":"Packet acknowledgement system for UDP","archived":false,"fork":false,"pushed_at":"2026-01-11T05:56:57.000Z","size":5456,"stargazers_count":634,"open_issues_count":0,"forks_count":81,"subscribers_count":27,"default_branch":"main","last_synced_at":"2026-01-21T02:13:51.565Z","etag":null,"topics":["ack","fragmentation","game-development","mtu","protocol","rtt","udp"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mas-bandwidth.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"mas-bandwidth"}},"created_at":"2017-04-30T16:06:56.000Z","updated_at":"2026-01-18T23:11:39.000Z","dependencies_parsed_at":"2024-01-11T18:25:47.584Z","dependency_job_id":"3ed56f88-0b26-44e4-8f68-09eeb264f1ff","html_url":"https://github.com/mas-bandwidth/reliable","commit_stats":null,"previous_names":["mas-bandwidth/reliable","networkprotocol/reliable.io","networkprotocol/reliable"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/mas-bandwidth/reliable","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mas-bandwidth%2Freliable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mas-bandwidth%2Freliable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mas-bandwidth%2Freliable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mas-bandwidth%2Freliable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mas-bandwidth","download_url":"https://codeload.github.com/mas-bandwidth/reliable/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mas-bandwidth%2Freliable/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35312540,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-09T02:00:07.329Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ack","fragmentation","game-development","mtu","protocol","rtt","udp"],"created_at":"2024-08-01T06:01:00.372Z","updated_at":"2026-07-09T21:00:27.801Z","avatar_url":"https://github.com/mas-bandwidth.png","language":"C","funding_links":["https://github.com/sponsors/mas-bandwidth"],"categories":["C","Libraries"],"sub_categories":[],"readme":"[![CI](https://github.com/mas-bandwidth/reliable/actions/workflows/ci.yml/badge.svg)](https://github.com/mas-bandwidth/reliable/actions/workflows/ci.yml)\n\n# Introduction\n\n**reliable** is a simple packet acknowledgement system for UDP-based protocols.\n\nIt's useful in situations where you need to know which UDP packets you sent were received by the other side.\n\n![image](https://github.com/mas-bandwidth/reliable/assets/696656/c58edcde-8bff-4683-8bc9-36c562ee7570)\n\nIt has the following features:\n\n1. Acknowledgement when packets are received\n2. Packet fragmentation and reassembly\n3. RTT, jitter and packet loss estimates\n4. Duplicate packets are detected and dropped\n\nreliable is stable and production ready.\n\n# Usage\n\nReliable is designed to operate with your own network socket library.\n\nIf you don't have one already, try [netcode](https://github.com/mas-bandwidth/netcode), it's designed to work well with reliable.\n\nFirst, create an endpoint on each side of the connection:\n\n```c\nstruct reliable_config_t config;\n\nreliable_default_config( \u0026config );\n\nconfig.max_packet_size = 32 * 1024;\nconfig.fragment_above = 1200;\nconfig.max_fragments = 32;\nconfig.fragment_size = 1024;\nconfig.transmit_packet_function = transmit_packet;\nconfig.process_packet_function = process_packet;\n\nreliable_endpoint_t * endpoint = reliable_endpoint_create( \u0026config, time );\nif ( endpoint == NULL )\n{\n  printf( \"error: could not create endpoint\\n\" );\n  exit(1);\n}\n```\n\nFor 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.\n\nNext, create a function to transmit packets:\n\n```c\nstatic void transmit_packet( void * context, uint64_t id, uint16_t sequence, uint8_t * packet_data, int packet_bytes )\n{\n    // send packet using your own udp socket\n}\n```\n\nAnd a function to process received packets:\n\n```c\nstatic int process_packet( void * context, uint64_t id, uint16_t sequence, uint8_t * packet_data, int packet_bytes )\n{\n    // read the packet here and process its contents, return 0 if the packet should not be acked\n    return 1;\n}\n```\n\nFor each packet you receive from your udp socket, call this on the endpoint that should receive it:\n\n```c\nreliable_endpoint_receive_packet( endpoint, packet_data, packet_bytes );\n```\n\nNow you can send packets through the endpoint:\n\n```c\nreliable_endpoint_send_packet( endpoint, packet_data, packet_bytes );\n```\n\nAnd get acks like this:\n\n```c\nint num_acks;\nuint16_t * acks = reliable_endpoint_get_acks( endpoint, \u0026num_acks );\nfor ( int i = 0; i \u003c num_acks; i++ )\n{\n    printf( \"acked packet %d\\n\", acks[i] );\n}\n```\n\nOnce you process all acks, clear them:\n\n```c\nreliable_endpoint_clear_acks( endpoint );\n```\n\nBefore you send a packet, you can ask reliable what sequence number the sent packet will have:\n\n```c\nuint16_t sequence = reliable_endpoint_next_packet_sequence( endpoint );\n```\n\nThis way you can map acked sequence numbers to the contents of packets you sent, for example, resending unacked messages until a packet that included that message was acked.\n\nMake sure to update each endpoint once per-frame. This keeps track of network stats like latency, jitter, packet loss and bandwidth:\n\n```c\nreliable_endpoint_update( endpoint, time );\n```\n\nYou can then grab stats from the endpoint:\n\n```c\nprintf( \"rtt = %.1fms | jitter = %.1fms | packet loss = %.1f%%\\n\", \n    reliable_endpoint_rtt_min( endpoint ),\n    reliable_endpoint_jitter_avg_vs_min_rtt( endpoint ),\n    reliable_endpoint_packet_loss( endpoint ) );\n```\n\nWhen you are finished with an endpoint, destroy it:\n\n```c\nreliable_endpoint_destroy( endpoint );\n```\n\n# Caveats\n\nreliable is a packet acknowledgement system, not a full messaging layer. Keep the following in mind:\n\n1. Acks accumulate until you call `reliable_endpoint_clear_acks`, so make sure you clear acks once you have processed them each frame. If the ack buffer fills up, additional acks are dropped and an error is logged.\n\n2. Endpoints are not thread safe. Use one endpoint per-thread, or protect each endpoint with your own lock. The log level, printf and assert handlers are global to the process.\n\n# Author\n\nThe author of this library is [Glenn Fiedler](https://www.linkedin.com/in/glenn-fiedler-11b735302/).\n\nOpen source libraries by the same author include: [netcode](https://github.com/mas-bandwidth/netcode), [serialize](https://github.com/mas-bandwidth/serialize),  and [yojimbo](https://github.com/mas-bandwidth/yojimbo)\n\nIf you find this software useful, [please consider sponsoring it](https://github.com/sponsors/mas-bandwidth). Thanks!\n\n# License\n\n[BSD 3-Clause license](https://opensource.org/licenses/BSD-3-Clause).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmas-bandwidth%2Freliable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmas-bandwidth%2Freliable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmas-bandwidth%2Freliable/lists"}