Basics Of NetWorking

Game networking generally follows two paths depending on the platform and the "twitch" requirements of the gameplay.

1. WebSockets

2. UDP & TCP


What is Reliable UDP (RUDP)?

Most modern games use what you might call "Protected" or Reliable UDP. This is a custom layer built on top of raw UDP that selectively adds the safety of TCP back in, without the massive latency penalties.

How do I learn it?

Since RUDP is just a logic layer on top of a UDP socket, you must start with a solid foundation in raw UDP.

Key concepts to master:

  1. Sequence Numbers: Labeling every packet so the receiver knows the order.
  2. ACKs (Acknowledgments): The receiver sends a small packet back saying "I got packet #42."
  3. Data Validation: Using Checksums to ensure the data wasn't corrupted during the "fire and forget" phase.
  4. Packet Re-sending: If the sender doesn't get an ACK for a critical packet (like "I fired my gun"), it sends it again.

Recommendation: Don't Reinvent the Wheel

Building a robust RUDP layer from scratch is an "Engine-Level" task. If you want to see how it's done or build on top of a proven system, look at these low-level libraries:


Engine-Specific Implementations

If you aren't building your own low-level socket handler with ENet, you’ll likely be using the built-in systems for Unreal or Unity. Both engines use UDP by default but provide a "Reliable" layer for critical data.

1. Unreal Engine (C++)

Unreal’s networking is built into the core of the engine via the NetDriver. It uses a "Bunch" system to handle reliability.

   UFUNCTION(Server, Reliable) // Acts like TCP (Guaranteed delivery/order)
   void Server_SubmitScore(int32 Score);
   
   UFUNCTION(NetMulticast, Unreliable) // Raw UDP (Fast, might vanish)
   void Multicast_PlayExplosionEffect();

2. Unity (C#)

Unity’s modern networking revolves around the Unity Transport Package (UTP) and Netcode for GameObjects.


Summary Table: Networking Choice

Feature Unreal Engine Unity (UTP)
Language C++ C#
Default Protocol UDP (with custom RUDP layer) UDP (via Unity Transport)
Reliability Method Reliable RPCs / Property Replication Reliable Pipelines
Best For AAA shooters, massive worlds Mobile, cross-platform, modularity
Low-Level Access Direct Socket access via ISocketSubsystem Low-level NetworkDriver

References & Further Reading