samedi 7 mars 2015

Optimising Network Bandwidth Use: Reusing strings


I'll try to be as brief and to the point as possible..


I currently develop a small, live "MMO" and would like to reduce the bandwidth use of host -> client.


The most costly of this is the use of strings, that, for the most part, are constantly repeated and sent to the clients. They differ only slightly, due to their nature, be it names or values, but the rest is repeated.


I have an idea that I'm sure has already been done, but can't really find any example of it.


Basically, these repeated strings, could be assigned a "stringcode" , then the variables, and then sent to the client. The clients already have enough information to fill in the blanks, so to speak, based on id numbers assigned to each player


So for example, in the case of names of a player..



"Supanova transfers 75 crew to Angus" // 35 bytes


becomes..



1 23 75 8 // only 6 bytes needed


where ..


1, is the "stringcode"

23, is the player ID of Supanova, (the client has the name already for this player

75, is the integer variable.

8, is the other player ID of Angus


In theory, I could find all of the strings sent to the client, and store them on the client, this is what I wish to avoid, as it's a painful process.


OR, create a dictionary of sorts, at runtime, assigning a "stringcode" value to each new string, the amount of variables, and quite possibly the order of the types would be needed. The host will send the packet contain just the "stringcode" and variables, if the client doesn't yet know the context of the string for that "stringcode", request the string, and then it can piece it together.


Not sure if I'm explaining this all too well, it's getting late and it sounds so much better in my head.....




Aucun commentaire:

Enregistrer un commentaire