How much data being sent/received is too much?

As of right now, I’ve just been testing things over the relay servers because it’s simple and I’ve yet to learn how to handle making my own server with Unet.

My question is: Being new to networking for games, my current project is intended to be a simple client/server set up for a small multiplayer top-down RPG (2D). I’ve written my own scripts for handling syncing player/item movements over the network through commands and RPC’s. It’s working extremely smoothly visually and I would like to keep it this way, as even with latency over the relay servers things are working very nicely.

I was sending my inputs through to the server via Command every 0.1s, holding the past 5 inputs from FixedUpdate in an array of Vector4’s (x,y for input, z for a modifier key to sprint, and w for the tick of the input) I then applied these movements in FixedUpdate on the server as if it were receiving input directly, and sent the resulting position back to the client after the server finished its movement. Syncing using ticks allowed me to implement client-side prediction and all was well. I realize its likely a novice mistake to use Vector4’s to do this but it was just for ease of understanding for myself. If my math is correct, by sending these 5 Vector4’s every 0.1s I was sending a total of (5 vector4’s * 4 floats per vector4 * 5 bytes per float * 10 times a second) 1000 bytes per second.

Since I’ve modified these scripts to instead send a single byte that is interpreted on both sides as my input (only 8 direction + modifier so the byte is 0-16 representing these different inputs) so this dropped the data sent to an array of bytes and one int per 0.1 seconds, for a total of (1 int * 4 bytes per int + 5 bytes of input * 10 times a second) 90 bytes per second.

Now, all of this is just the data to send the player input, which currently isn’t much, but every result of this from the server is a position (Vector3) and tick (int) for each player, and likely any NPC from the server as well. Just syncing its position 10 times a second, it costs nearly 200 bytes per second, per entity on the screen.

It’s early optimization to try to change this for myself, but is this even close to an issue for a typical networked game? Is there some rule of thumb for a typical amount of data to try to stay close to for a simple networked PC game, in regards to hosting ones own server and avoiding the relay servers?

Any info on this would be greatly appreciated.

1 Like

@foxifi This is a great question for which there aren’t any good answers out there that I can find. Did you come to any conclusions that helped answer this?

If not, has anyone else analyzed the amount of data/bytes that is reasonable to send, say, per second from a host or from a client?

1 Like

I haven’t really, but using some other tools and looking into it, it seems there’s a decent amount of overhead I guess with Unet sending data, making the data/second higher than I anticipated.

I haven’t seen any issues with it yet, but I also still have no idea what a general baseline per second is, which would be helpful in kind of planning what’s possible in the long run.

1 Like

I’m not a networking expert, but someone with 512kbps of upload (rather low, by today’s standards) could potentially send ~65,000 bytes per second, right?

Just speaking from personal experience playing Counter Strike and using a bandwidth monitor, you generally upload 6-12kB/sec (~6,000-12,000 bytes), and download 12-20kB/sec (meaning the server clearly requires a lot more upstream bandwidth).

If you play on a higher tickrate server, those values go up exponentially.

2 Likes

Don’t forget the giant overhead of the packet itself. This is going to be around 20-50 bytes depending on how the packet is setup. The smallest UDP packet size is 8 bytes, but more will be added to that I’m pretty sure.

So really the best and biggest gain ever, is simply sending less frequently, if you can, even delaying unimportant packets and throwing them on the end of your next regular update.

I’m not very experienced in networking, but for the small jobs I did do, I found the most gains from just sending less, rather than weird compression (which probably really helps if you merge the results of all those into a larger packet).

1 Like

Thanks for the answers!

@hippocoder I’ve gotten mine down sending 90b/s and receiving 200b/s per player, but IDK really how to cut that down or if its necessary. I’m assuming that ultimately there is a way to sort of cull out the players that aren’t close enough to matter, you know? Like if I have a large 2D top-down map, there’s no reason to get every single player’s position 10 times a second, but maybe cut it down to 1 time a second unless they are within x-distance or something.

Again, I think this is early optimization and what not and not that important right now, but its a little worrisome not knowing at all what the target is to shoot for. At the moment its not an issue, but I would say that updating an entity’s position 10 times a second is not ridiculous.

1 Like