Skip to content

Add Reliable UDP (RUDP) implementation - #1

Draft
Levvy055 with Copilot wants to merge 4 commits into
masterfrom
copilot/add-reliable-udp-implementation
Draft

Levvy055 with Copilot wants to merge 4 commits into
masterfrom
copilot/add-reliable-udp-implementation

Conversation

Copilot AI commented Feb 27, 2026 •

Copy link
Copy Markdown

Adds a reliability layer on top of existing UDP client/server with sequencing, ACKs, retransmission, and duplicate detection.

Protocol

  • 9-byte header: [1B flags][4B sequence][4B ack] prepended to payload
  • DATA flag triggers ACK response; ACK flag clears pending retransmission
  • Monotonically increasing sequence numbers for duplicate/ordering detection
  • Thread-safe receive sequence updates via Interlocked.CompareExchange

Core library (source/NetCoreServer/)

  • RudpClient — extends UdpClient, adds SendReliable/SendReliableAsync with all standard overloads
  • RudpServer — extends UdpServer, per-endpoint state tracking via ConcurrentDictionary
  • Internal ACK handling is transparent; ACK-only packets auto-continue the receive loop
  • OnReliableReceived delivers stripped payload; OnRetransmissionFailure signals exhausted retries

Settings (properties, matching existing conventions)

  • OptionRetransmissionTimeout — ms before retransmit (default: 1000)
  • OptionMaxRetransmissions — max retry count (default: 5)
  • OptionWindowSize — max unacked in-flight packets (default: 64)

Usage

// Server
class MyServer : RudpServer
{
    public MyServer(IPAddress addr, int port) : base(addr, port) {}
    protected override void OnStarted() => ReceiveAsync();
    protected override void OnReliableReceived(EndPoint ep, byte[] buf, long off, long sz)
        => SendReliable(ep, buf, off, sz); // echo
    protected override void OnSent(EndPoint ep, long sent)
        => ThreadPool.QueueUserWorkItem(_ => ReceiveAsync());
}

// Client
client.SendReliable("hello"); // sequenced, acked, retransmitted if needed

Tests, examples, perf

  • tests/RudpTests.cs — echo test, multi-message test, settings validation
  • examples/RudpEchoServer + RudpEchoClient — interactive examples
  • performance/RudpEchoServer + RudpEchoClient — benchmarking harness with throughput/latency reporting
  • All projects added to solution file
Original prompt

Add reliable UDP implementation (RUDP) for existing UDP implementation.
remember about examples, tests, perf, ...
If there can be some settings for a server, make them like they are in existing code by properties.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits February 27, 2026 22:48
Co-authored-by: Levvy055 <1311186+Levvy055@users.noreply.github.com>
Co-authored-by: Levvy055 <1311186+Levvy055@users.noreply.github.com>
…e test assertion

Co-authored-by: Levvy055 <1311186+Levvy055@users.noreply.github.com>
Copilot AI changed the title [WIP] Add reliable UDP implementation to existing code Add Reliable UDP (RUDP) implementation Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants