Results 1 to 9 of 9

Thread: How often to send packets?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    I'm using UDP, so packet loss is always some risk.

    After giving it a thought - at least for now - I'll do it like this: the client can send packets to the server as often as he wishes (100 input changes per second is possible, since we aim with the mouse), but the server will broadcast player info only when direction of movement changes. After all, the client needs other players' AimX & AimY only for drawing.

  2. #2
    Why do you need 100 packets in 1 second when you game probably runs on 30 FPS (frames per secnd). It is usles in sending more packets than teh usual framerate is (unles you do some realtime physics).

  3. #3
    You should not send more than 3-4 packets per second and make sure to send self-sufficient information, so you can reconstruct the necessary part of the scene based on the information you have. If one packet gets lost, then you should be able to get latest information from the next packet. Plan your dead-reckoning accordingly to interpolate the frames between packet reception intervals (linear interpolation, cubic splines, etc.)

    I would recommend that both server and client keep sending packets. If no useful information is to be send, just send acknowledgement. This way, if client and/or server does not deceive anything within some time interval, it assumes that the remote party has been disconnected.

  4. #4
    PGD Staff code_glitch's Avatar
    Join Date
    Oct 2009
    Location
    UK (England, the bigger bit)
    Posts
    933
    Blog Entries
    45
    Just out of curiosity, what library/interface are you using for your networking?
    I once tried to change the world. But they wouldn't give me the source code. Damned evil cunning.

  5. #5
    Since I do graphics in SDL, I went with SDL_net.

  6. #6
    PGD Staff code_glitch's Avatar
    Join Date
    Oct 2009
    Location
    UK (England, the bigger bit)
    Posts
    933
    Blog Entries
    45
    Cool, whats the stability on sdl_net if you don't mind my asking? I tried the low level units supplied by the LCL but linux can be dodgy at times so I'm reviewing a better way of going abouts it without needing any dll/so files
    I once tried to change the world. But they wouldn't give me the source code. Damned evil cunning.

  7. #7
    So far I did not have any major problems. Reading from UDP packets via typecasts didn't really work, so I had to use a for, and I could not really find a way to determine TCP connection status (that is, detect disconnects) - but other than that, everything seems to work quite fine.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •