Hacker News new | ask | show | jobs
by fxtentacle 1767 days ago
I'm working on something similar, which will be called CloudGamepad. The trick to getting good quality and low latency is forward error correction and UDP. UDP will arrive quickly but is lossy. And the FEC allows you to recover a certain percentage of lost packages.
1 comments

Does it work similar to rollback netcode in fighting games? Where the game tries to predict what the other player is going to do by looking at what they’ve done in previous frames, and if there’s lag or dropped packets and a destiny happens it rolls back the game state and replays it correctly?
Not exactly, FEC basically means you add in redundant data to your transmission so that if some of the data is lost, you can “rebuild” the missing data from the packets that did arrive. The cost of this is extra bandwidth spent on the redundancy, as well as a little latency.

Rollback is as you say, if the game loses connection with your opponent, rollback 1) uses your opponent’s past actions to predict what they will do next and then presents that to you as if they did it then 2) when the connection is restored, reconcile (if necessary) the difference between what your opponent actually did with what it predicted, rolling back if needed.

thanks for the explanation
FEC in basic form works like raid 5. M parity packets for every N data packets, allowing loss recovery of up to M of the M+N packets without round trip back to host.

You can dynamically tune M and N based on measured loss rates and RTT.