I have a small game engine done in Java, and re-creating it on C++. While re-creating it i've decided on adding basic p2p online multiplayer. However, after reading more about networking, there are multiple models, and the Client-server host with relay model seems attractive, since it overcomes most of NAT issues of port fowarding and does not expose players public IP.

My point is - can a relay server be used to do some minimal data processing? The goal is not to use a dedicated, full featured server application, but just do minimal calculations on the data to detect some basic cheats.

For example: Preventing internal speed hacks by sending the system timestamp every 60 cycles, and then the relay would store the previous time stamp and compare the next one, if the time difference is less than 1000ms, disconnect the player.

  • 1
    \$\begingroup\$ What law of physics or enforcement agency do you imagine would stop you from running any code you could conceive on the server? \$\endgroup\$ – DMGregory Feb 25 at 1:56
  • \$\begingroup\$ I believe none, if using a dedicated server to actually process the game. But as far as I know, this would add overhead and more input lag. Relay servers are faster and cheap, but all questions about it points to a fact - it can not process data, similar to using a VPN server to reduce lag. \$\endgroup\$ – DL a.k.a. Luiz Henrique Feb 25 at 2:05
  • \$\begingroup\$ So what you're really asking is "is the trade-off between processing speed/cost and validation worthwhile?" and the answer will depend on how critically your particular game depends on low latency and validation. Maybe you can write a very simple validation routine that covers your greatest needs AND is fast enough for your latency targets. Or maybe you need the lowest latency you can manage and can sacrifice some validation. Or maybe you need security and can tolerate incremental latency. These are not decisions that a stranger who doesn't know your game can make for you. \$\endgroup\$ – DMGregory Feb 25 at 2:09
  • \$\begingroup\$ You're right, this is the question. It's my naivety to think a relay server is something you just buy to relay data, like, set some configs about connection and its done, but in reality it's just a normal server where the relay itself is done by a server-side app, that, obviously, could be enhanced with these validations. Thanks for the enlightment. \$\endgroup\$ – DL a.k.a. Luiz Henrique Feb 25 at 2:23

There actually are SaaS providers who lease off-the-shelf relay server solutions to you. Photon or Playfab, for example. How much custom server-sided logic you can implement on those solutions depends on the product. But as usual with other people's software running on other people's servers (or "the cloud" how the marketing people call it): There are limits to how much you can customize them, and when you need to exceed these limits, you are out of luck.

But you can of course also develop your own relay server application from scratch. That way it's your decision where you want to place it on the sliding scale between a dumb relay and authoritative gameserver.

The most simple solution would be a relay which just forwards network messages without even looking at them. This is quick to develop and inexpensive to host, but very insecure when it comes to cheat prevention.

The other extreme would be a a full-fledged authoritative gameserver which checks every single incoming messages for whether or not that player can do that right now, calculates all game mechanics server-sided, and sends out the results of these calculations to only those client which are supposed to know about them. When you do this properly, then its very design makes any cheat impossible except for purely client-sided automation. But creating a server like that takes a lot of time, adds a lot of complexity to your network stack and makes your server computationally expensive, which drives up your hosting cost (but might actually reduce your network traffic cost due to server-sided censoring of hidden information).

Most online multiplayer games are somewhere between those two extremes.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.