ReactiveDrop / reactivedrop_public_src

Alien Swarm: Reactive Drop game source code and issue tracker.
https://reactivedrop.com
104 stars 35 forks source link

[Suggestion] Networking code overhaul to improve UDP packet transmission performance in low quality network environment #768

Open ywgATustcbbs opened 1 month ago

ywgATustcbbs commented 1 month ago

The game uses raw UDP protocol in game engine level, i think. Its hard to hack engine part of the networking code. But there is a wallkaround for it.

My suggestion is to hack the data transmission part of the game. Since the engine is actually sending a UDP packet to an IP:port, it is possible to take over the transmission part.

To improve UDP performance, especially packet loss and network jitter, we could just add an application level protocol.

There are many application level UDP protocols that can achieve that goal. KCP protocol is one of them. KCP si widely used by many modern moba games for fast, stable, and loss-less UDP connection. It has Automatic Repeat Request and Forward Error Correction fetures, which can avoid packet loss.

image

As shown above, we can integrate the KCP protocol into the game (protocol level or tunnelling level). Protocol level might be hard. But tunnelling level is eaiser. Clients will connect to servers as normal. After connection established, the game server can inform clients / negotiate the KCP and Stun parameters. Then they can send data via KCP tunnelling. If that fails, they can still use old steam networking.

There are open source KCP libs written in c/c++. There are also open source KCP tunnelling software for both TCP and UDP conncetions. I've tested tunnelling for dedicated server, it works prefectly, no packet loss.