Handling Extra Messages

Started by
6 comments, last by Butabee 10 years, 9 months ago
I have a message queue that pumps out messages as long as the queue isn't empty and there is available bandwidth. But what do I do when I have more messages than the bandwidth can handle? I don't want to discard them but not sure what else to do. I think I might be able to slow down how many messages are added to the queue but things would start getting laggy.
Advertisement

If you mean like a server sending updates, im afraid youre going to have to reduce the quality, at least for some of the clients (if you have more important clients, like ones with a membership)

Possible solutions:

-Reduce non-necessary packets (fewer position updates, fewer 'visuals' updates...)

-Activate a laggy compressor to make the packets smaller by sacrificing some CPU under low bandwidth

-Slow down the simulation speed (depends what youre working on)

o3o

Thanks, I've come up with this to adjust the message queue update rate:

[source]
if(m_updateMessages.Count * messagesize < m_bandWidth * 3.2f)
{
m_updateThresh = Mathf.Lerp(3.2f,0.2f,1.0f / (m_updateMessages.Count + 1.0f));
}
else
{
//shutdown. Too laggy.
}
[/source]

this only currently handles update messages though so messagesize is constant.
This happens after the messages are processed so the count would be excess messages that bandwidth couldn't handle.

Is this a decent solution, or should I try something else?

If you need to send more data than the network can tolerate, then you will fail, and you might as well disconnect the users.

If you don't need to send the data, then why are you sending it?

The main challenge is to reduce the number of messages you need to send; the secondary challenge is to reduce the size of each message you send.

No matter what you do, you have to be prepared for falling behind. The available bandwidth may at some point go close to zero, for various reasons (none of the good,) and you need to know what to do in that case. Typically, send a message to each connected client that there's a problem, and then disconnect all users.

Oh, and send email to the pager of whoever runs the servers to have them wake up and look into it, as they weren't on the ball as available bandwidth was starting to go down :-)

enum Bool { True, False, FileNotFound };
I was thinking I would start disconnecting players instead of shutting down. The update messages are pretty much positional updates plus a couple other things that are lerped between on the client side. They do need to be sent at a decent rate for the game to be playable as it's an action type game, but if players decide to clump up there's nothing sane I can do to prevent that. The code above will decrease messages sent up to 16 times before I shutdown or start booting players. I'd have to test how the game plays at an update rate of once per 3.2 seconds, but I'm thinking it won't be remotely playable. I'd have to start booting way before that. There's no set upload bandwidth since the servers will be player ran. I think the lowest update rate I can get away with is 1 per second, but not sure until I test it out.

The code above will decrease messages sent up to 16 times before I shutdown or start booting players.


Decreasing the rate you send messages isn't going to help if you still generate messages faster than you can send them.

You have to decrease the rate at which you *generate* those messages. For example, do not generate a new update for an entity if the previous update for that entity is still pending in the queue -- that would auto-balance the network to send no faster than it could support.

The next question is: what do you use as an indication that you "can't send" a packet? Are you using TCP or UDP? If UDP, then your local network interface can send messages very quickly without blocking, but those get dropped as soon as they hit your upstream cable modem / DSL router / ISP interface if you exceed capacity.
enum Bool { True, False, FileNotFound };
Sorry, that's what I meant, the threshhold variable slows down the rate the messages are generated, not sent.
Thanks, I decided to use your method of checking for previous updates in the queue.

This topic is closed to new replies.

Advertisement