Hello, I'm working on networking for a 2D MMO and have researched enough for my system design thoughts to start coalescing. However, I'm having a hard time piecing together the various approaches to decide what my client/server synchronization should look like.
Some potentially relevant decisions (that could be changed, I'd appreciate a sanity check):
- I'm using a fixed timestep.
- I'm counting simulation ticks instead of using wall time.
- The client postdates “input" messages (with the server giving feedback if the date is too early or late).
- The client buffers received “NPC state" messages and processes ones from some amount earlier than its current tick.
- The client saves inputs and replays them over every received “player state” message from the server.
Many of these rely on the relation between the client tick and the server tick, but it's hard for me to conceptualize what the important points of that relationship are.
Reasoning questions:
- Must they always be “in sync", as in, processing the same tick at the same real-world time? What would happen if the server sent the client its tick number during a handshake and the client just worked “in the past”, postdating its messages enough that the server saw them as valid?
- What's the benefit of pinging to find latency in ms? When should I do it, and what do I use it for?
On top of that conceptual understanding, I have some specific questions about the technical approach:
- I saw on hplus's site (http://www.mindcontrol.org/~hplus/time-offset.html) a method for using the wall time to establish sync. Are there more techniques that I should know about? Any good resources for these?
- I saw it mentioned in a post somewhere that the server's feedback on the client's postdate should be enough to maintain sync, but how do you know that the ticks are still in sync and you haven't just compensated for them being off?
- What if the client is frozen and doesn't process ticks for a long while, then comes back? How do you detect this, and do you need to re-establish sync using the initial method?