{"id":13523463,"url":"https://github.com/mas-bandwidth/reliable","last_synced_at":"2025-12-29T23:26:58.427Z","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":"2024-09-19T17:03:15.000Z","size":5575,"stargazers_count":599,"open_issues_count":0,"forks_count":78,"subscribers_count":32,"default_branch":"main","last_synced_at":"2025-01-02T00:06:32.497Z","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},"funding":{"github":"mas-bandwidth"}},"created_at":"2017-04-30T16:06:56.000Z","updated_at":"2024-12-27T15:58:21.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"],"tags_count":8,"template":false,"template_full_name":null,"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","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246563353,"owners_count":20797443,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":"2025-12-15T03:05:54.056Z","avatar_url":"https://github.com/mas-bandwidth.png","language":"C","funding_links":["https://github.com/sponsors/mas-bandwidth"],"categories":["C","Libraries"],"sub_categories":[],"readme":"[![Build status](https://github.com/mas-bandwidth/reliable/workflows/CI/badge.svg)](https://github.com/mas-bandwidth/reliable/actions?query=workflow%3ACI)\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\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[j] );\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\n    printf( 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# 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"}