RealTime Servers and Reliable UDP

Hi there,

https://docs.aws.amazon.com/gamelift/latest/developerguide/realtime-howitworks.html

The RealTime Servers documentation said

Communication between a Realtime server and connected game clients uses two channels: a TCP connection for reliable delivery and a UDP channel for fast delivery. When creating messages, game clients choose which protocol to use depending on the nature of the message. Message delivery is set to UDP by default. If a UDP channel is not set up or not available, all messages are sent using TCP as a fallback.

It didn’t mention if the UDP is a Reliable UDP implementation or not. If not, is there a plan to introduce a RUDP protocol in the future?

No, RTS doesn’t use Reliable UDP. It uses dgram provided by NodeJS (UDP/datagram sockets | Node.js v17.0.1 Documentation).

Could you help me understand your use case for this? Do you have any data to show that TCP or UDP are insufficient for what you are trying to do? With these info, I can work with the product team and send in a feature request.

Well, any genre that is latency-sensitive. For example, the real-time strategy genre.

I’m from a Unity background that almost every popular network solutions offer RUDP as the preferred network protocol. I’d like to borrow the concept of Ruffles (a reliable UDP library of Unity):

  • Reliable : All messages are guaranteed to be delivered, the order is not guaranteed, duplicates are dropped. Uses a fixed sliding window.
  • ReliableSequenced : All messages are guaranteed to be delivered with the order also being guaranteed, duplicates are dropped. Uses a fixed sliding window.
  • Unreliable : Delivery is not guaranteed, nor is the order. Duplicates are dropped.
  • UnreliableSequenced : Delivery is not guaranteed but the order is. Older packets and duplicate packets are dropped.

The most useful one is the first “reliable” type.

The problem is RUDP is just a layer on top of UDP. So there’s no gold standard or dominated cross-platform solution there.

Thanks for the details @favoyang, I’ve created a feature request for this.

Currently we are using DTLS to provide encryption in-flight over UDP. Do you know if RUDP has something similar? Could you recommend some popular RUDP libraries that are tried-and-true? Could you also share examples of your aforementioned network solutions which use RUDP?

GLIFT-15961

Low-level RUDP Libraries

Name Language Encryption
Ruffles C# n/a
LiteNetLib C# AES or XOR
Lidgren.Network C# AES
Hazel-Networking fork C# DTLS
ENet C n/a
ENet-CSharp C# n/a
KCP C n/a

Ruffles - GitHub - MidLevel/Ruffles: Lightweight and fully managed reliable UDP library.

LiteNetLib - GitHub - RevenantX/LiteNetLib: Lite reliable UDP library for Mono and .NET

Lidgren.Network (maintain mode) - GitHub - lidgren/lidgren-network-gen3: Lidgren Network Library

Hazel-Networking (fork) - GitHub - willardf/Hazel-Networking: Hazel Networking is a low level networking library for C# providing connection-oriented, message-based communication via RUDP.

ENet - GitHub - lsalzman/enet: ENet reliable UDP networking library

ENet-CSharp - GitHub - nxrighthere/ENet-CSharp: Reliable UDP networking library

KCP

High-Level Network Solution that supports RUDP

Name RUDP RUDP Library
MLAPI Y via Ruffles
UNET/Mirror Networking Y via Ignorance (an ENet wrapper)
DarkRift 2 non-official via EnetListener
Photon Y adopt from an early version of ENet

Well, asymmetric cryptography is not the focus of these RUDP libraries, very few implemented DTLS.

For reputation

  • ENET is the well-used one but lacks documentation.
  • KCP seems promising in the Chinese community.
  • Hazel-Networking (fork) is maintained by the author of Among Us (and the game uses it).
1 Like

Thanks for the detailed list! Those are definitely convincing.

If we pull in this feature, we would probably add one of the C# libraries in the C# RTS client; however, on the server side, we’d have to use NodeJS. It’s shame that there is no widely used or actively maintained RUDP NodeJS library as far as I see. I found these 2: GitHub - shovon/node-rudp: Reliable UDP for Node.js, GitHub - Raulmsm/RUDP: A reliable UDP Javascript implementation for node.js. The former is slightly more promising and could be looked into.

Last question that could help greatly in prioritization, is there any research that shows concrete numbers on how much improvements RUDP brings over UDP and TCP, e.g. in areas like throughput / packet loss rate? (No big deal if you don’t know, we’ll do this research ourselves, but it seems like you are an expert in this so doesn’t hurt to ask :slight_smile: )

For benchmark

For cross-platform, since RUDP is just a custom layer on top of UDP, different implementations are not compatible with each other. To get a cross-platform solution you may have to port one implementation to node, vice versa.

  • ENET is written in C, so it can be used anywhere with a wrapper layer.
  • KCP is also written in C and has both C# port and node wrapper.
  • Another idea is to use edge.js to integrate .NET DLL with node, then both server and client can stick with the same managed .NET solution.

Not really an expert, hope this information help.