Jump to content
  • Advertisement
Sign in to follow this  
Sulix

UDP Lockstep and Sync Errors.

This topic is 4077 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm working on an RTS game, and I'm using a UDP based client/server architecture. My current protocol sends the current sequence (network turn) to all connected clients, and then allows clients to send a NACK if a previous sequence is missing. Clients send commands to the server unreliably along with a command number. This command number is sent back when the command is sent to all clients in the sequence message. All the clients execute 10 logic frames per sequence, with each logic frame lasting 20ms. If one client falls behind, the others can continue while the slow one can catch up be executing frames as fast as they can until they reach the same sequence. All this is achieved with the bare minimum amount of data sent from the client to the server. This however, presents a problem. As data is only sent to the server when either (a) a command is sent or (b) a packet is lost, the server has no way of knowing the client's state or for checking that all the clients are synchronized. (The state would contain a checksum of the positions and states of all objects and variables in the game). Do you think that it's worth making the client send its state every sequence, or at another regular interval? If I send the state every sequence, it'd increase bandwidth use a lot, and would render my current system to deal with packet loss obsolete. If I send the state at a regular interval (say, every 16 sequences) then it'd be simpler to verify the states, but the information would be a little bit out of date, so it would be difficult to see when a sync error actually occurred. I'm currently leaning towards the latter option, but I thought that I'd ask around first, as this is my first network game. (Although, admittedly, not my first attempt at one, but having it crash every time a packet was sent/received wasn't a good feature). Thanks in advance, Sulix.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
If one client falls behind, the others can continue while the slow one can catch up be executing frames as fast as they can until they reach the same sequence.


You can't do that and stay in lock-step, because the other clients won't have the command data from the slow client. With lock-step, you HAVE to have data from step X from all the other clients, to advance the game to step X+1.

The way this is usually handled, is to send commands for some future step, and let there be some latency in commands taking effect. If you don't have all the commands from all the clients, you have to pause logic updating until you get all the commands.

Btw: I would send a packet for each step. In you case, because each packet covers 20 ms, I'd send five packets a second. If the client is doing nothing, that's 28 bytes additional bandwidth per packet, which you just have to count into your bandwidth budget.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!