Network

Network code structure and network protocol.

Table of Contents


This is what I've learnt from a cursory reading of the XPilot source.

  1. Server broadcasts game state updates (new things, changed things, destroyed things, new positions, new velocities) to each player as it learns of each one either from other players or from its collision detection or physics code.
  2. Client receives each message and updates its state accordingly.
  3. Server sends 'done' message, signifying that it will not act further until the clients have done some computation.
  4. Client checks for user input.
  5. Client updates the objects for which it is responsible (moves its plane, its bullets, etc).
  6. Client sends changes as it computes them.
  7. Server receives them and updates accordingly.
  8. Client sends 'done'.
  9. Server does collision detection.
  10. Server updates the objects for which it is responsbile (moves soldiers).
  11. Server sends game state updates (new things, changed things, destroyed things, new positions, new velocities) to each player.

Synchronisation

In order to synchronise the clients and ensure one does not run faster than another, the server controls the progress of clients by requiring they receive its 'done' message before updating. Similarly, each client requires the server receive its 'done' message before updating. Therefore the server and client take turns proactively computing and sending, and reactivley receiving and updating their state.

I'm not sure if it would be good to go ahead with this design. I'll come back to it after doing some more research on the topic.


Copyright (c) 2002-2003, Greg McIntyre
SourceForge