How often should UDP packets be sent?

I wrote an application in Python 2.7 and I am using UDP sockets to implement networking. Although my application is not a game, I would call it a network game because the screen is redrawn 60 times per second.

I don't need extreme precision, so I don't need to send a ton of packets per second, but the way I have implemented networking makes other users look "choppy" if not enough packets are being sent per second.

After some research and exercise, I decided to send one packet every 50 milliseconds. This makes other users look pretty "slick" for a while, but after about a minute they get more and more choppy, eventually until no updates happen.

How can I implement networking, for example, on a network made in video games? It looks like I'm fundamentally missing something.

+3


source to share


1 answer


It seems to me that the network is loading up, forwarding old packets that are in the router queues and dropping new ones.



UDP programming is a black art - it requires reacting to network congestion when needed and slowing down the sending speed. A simple solution is for the receiver to send a periodic summary of the packets received (say once per RTT) and reduce the sending rate when you see too much loss. Ideally, you would combine this with an accurate RTT estimate and outperform the send rate when the RTT suddenly rises.

0


source







All Articles