# Traffic estimation for a multiplayer flash game

hey, i want to know if my rough traffic estimations are right, it would be for a pretty simple realtime flashgame in the style of haxball (but not as a soccer game) heres a video of it http://www.youtube.com/watch?v=z_xBdFg1RcI

So here comes my estimation, i dont know if they are realistic! i hope someone can help me.

consider the packet attached as a typical one sent every 200ms, its 148bytes + 64 bytes of header will make around a 200bytes packet. The server will receive 200bytes x 6 players x 5 times a sec=6000bytes/s=5.85Kbytes/s=46.9kbit/s plus he has to send all back to the players, so at this point are 94Kbit/s.The server received all the information, perform the definitive calculation and send the new position to all players, in a bigger packet of around 900bytes that have to be delivered to the others 6, which makes 900bytes x 6 players x 5 times a sec=27000bytes/s=26Kbytes/s=210kbit/s. overall that would be 26kbyte per second. thats like 130mb traffic per hour for a 6player room. but somehow i think the numbers are too high? that would be really much traffic for such a simple game.

did i calculate something wrong?

-

That would be really much traffic for such a simple game.

The problem, your type of game faces, is that it needs to be extremely responsive. On first glance World of Warcraft may look like a highly complex game, but there is far less information that needs to be transferred to the client and status updates can be a lot less frequent.

The math look correct to me, but Kibibytes (1024) are only used for RAM, network traffic is described using normal Kilobytes (1000).

You said that the server has to sent the package from the clients back to each one. That's probably the first thing you can optimize by just removing this step. The client should know what he told the server so there is no need to sent this information back to it.

48,000b/s upstream + 216,000b/s downstream = 264,000b/s in sum. That is 120 MB/h.

Another optimization is to only sent information from the client to the server, when the user does some action such as pressing or releasing an arrow key.

900 bytes per status update seems large. Without knowing details, I'd expect

``````package_header + message_type + 7 * (position + vector)
64             + 1            + 7 * (2*4      + 2*4) = 177 bytes
``````
-

Actually there may be very little data transfer, it depends on the protocol you use. A TCP based protocol will ensure reliability and consistency amongst the data transfer but will have high latency and cost bandwidth charges. But using UDP the 2 players will exchange data primarily amongst themselves and the server will most likely be the super group handling ip allocation, In which case the packets aren't costing you money. If you want to make a realtime game, use UDP (but you need to program in game logic to best prevent hacking or cheating since the packets sent is amongst users)

-
You've mixed up two different things here. First talk about TCP vs UDP, and then you move to client-server vs peer-to-peer architecture. None of those imply each other. You can make both UDP client-server and TCP p2p as good. – Luker Mar 23 '11 at 7:14
UDP isn't available for Flash anyway, so the point is moot. See: stackoverflow.com/questions/907041/… – bummzack Mar 23 '11 at 9:59
It's a 6 player game and since most Internet accesss provider offer a much smaller upstream than downstream, a central server is a better approach than peer to peer. – Hendrik Brummermann Apr 9 '11 at 12:04
so I'm not sure which language this is being game is being made in, but I've been reading docs on rtmfp for flash and the most efficient way of creating a connection is using a "full mesh" system where you upload 1 stream (send) but download n strms. but the math would be similar to the one stated. Never realized how expensive it could be to create a multilayer game. I calculated a game cst for 1000 simultaneous users to be a bit more then \$100 a day or about \$3000 for band. and cpu on aws. with 1k simultaneous users the rev is less then a tenth of cost. How do indie dev make mltiplyr games? – Saad Apr 9 '11 at 20:28