Hi there!
When starting to code the networking-part for my engine, I ran into a problem.
As you probably know, for a networking game which is supposed to have high responsiveness, UDP is most likely the way to got.
However, you never know if the packet you send will be dropped or not. Not good, since the player won't want to see his actions not beeing executed from time to time (and all the other problems that come with that).
I came up with a simple protocol to ensure they reach their target:
- When sending a packet, also push it into a queue "waitingForAk"
- When reciving a packet, send back an Ak-packet
- When reciving an Ak-packet, kick the packet with the contained packetID from "waitingForAk" queue
- In each game-cycle, check if "waitingForAk" contains packets that have not been Ak'd for over (PlayerPing*2 + Server-Tickrate + Some-bias).
If so, resend the packet.
- Save packet-IDs that were already recived, so when you get a packet twice because the Ak-packet was lost, you don't process it twice.
(Send the Ak-packet again)
That seems to work fine, however I am pretty sure that there is a way faster/better method. I don't think this will work well for bad connections, or cause problems when a player gets spikes in their connection.
What are the common practices for this (for high performance games)?
Thank you for your time!