Packet size

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

Nexic
Posts: 31
Joined: 26 Jun 2008, 12:23

Packet size

Postby Nexic » 24 Aug 2017, 13:45

First of all, congrats on great product! SFS2x is much improved over the original and so far has been a joy to work with.

I've pretty much finished my multiplayer implementation for my current project. However I decided to check the bandwidth usage numbers and they are much higher than I expected.

Originally I was sending a single large SFSObject as a UserVariable 10 times per second. This method resulted in 6-7 kb/sec sent to the server per user. Meaning 600-700 bytes per packet. It seemed too high for what I was sending, but since I was sending an entire large object each time it seemed plausible.

I then tried a new method. I instead sent each value as a separate user variable, and *only* when they changed. Using this method most updates are sending approximately 13 integers per packet. However the bandwith shows up as 4-5kb/sec, which is am improvement but still too high. I don't understand how 13 integers can be 400-500 bytes?

The UserVariable names are all short, most of them are 2 ascii characters long. I had expected 2 bytes per int, plus say 3 bytes for the variable name. Maybe another 5 bytes for the user variable overhead? That would come out to 130 bytes. Based on that we should be using about 4 times less than we are.

It almost seems like each packet is being sent as a plaintext json object or something? I thought SFS2X used binary communication? Or is there something I'm missing here? Is there some kind of extra overhead using user variables,

I suspect there is something obvious I've missed, or misunderstood. If thats the case then I do apologise. But if you could point me in the right direction it would be a huge help.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Packet size

Postby Lapo » 24 Aug 2017, 13:57

Nexic wrote:First of all, congrats on great product! SFS2x is much improved over the original and so far has been a joy to work with.

I've pretty much finished my multiplayer implementation for my current project. However I decided to check the bandwidth usage numbers and they are much higher than I expected.

Originally I was sending a single large SFSObject as a UserVariable 10 times per second. This method resulted in 6-7 kb/sec sent to the server per user. Meaning 600-700 bytes per packet. It seemed too high for what I was sending, but since I was sending an entire large object each time it seemed plausible.

I then tried a new method. I instead sent each value as a separate user variable, and *only* when they changed. Using this method most updates are sending approximately 13 integers per packet. However the bandwith shows up as 4-5kb/sec, which is am improvement but still too high. I don't understand how 13 integers can be 400-500 bytes?

You must keep in mind that the final packets don't just contain your 13 integers. There's the IP protocol data, the TCP protocol data and the applicative protocol data. The whole network stack uses this onion like structure, so you can't expect the final packet to be of the size of your data. There's a necessary overhead for every level of the protocol stack.

This is normal and expected for every server out there. Plus sending 4-5Kb/s is very reasonable for a multiplayer game, unless your clients still use a dial up modem :)

More on this here:
https://en.wikipedia.org/wiki/OSI_model
Lapo
--
gotoAndPlay()
...addicted to flash games
Nexic
Posts: 31
Joined: 26 Jun 2008, 12:23

Re: Packet size

Postby Nexic » 24 Aug 2017, 14:09

So its normal for there to be about 350 bytes of overhead per packet with TCP IP? Would it be less if I used UDP for example?

5 kb/sec is what is sent in. But in a 4 player game that will end up as 20 kb/sec of outgoing bandwidth (and it doesn't even include chat, room updates, user count updates etc). So even with a 500 mbps unmetered connection, we'll still only manage a couple of thousand online, which is a fair bit less than I had hoped really.

Also I was a little surprised that for example, sending one large SFSObject with around 50 odd values including strings is 7kb/sec, when 13 UserVariable ints is 5kb/sec, you'd think it would be far lower in comparison.

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 60 guests