[Multiplayer] How do I calculate total downloaded data size

Get help using Construct 2

Post » Sat Sep 27, 2014 6:28 pm

StatInboundBandwidth
StatOutboundBandwidth
Return the total estimated inbound and outbound bandwidth for all data transmission through the Multiplayer object, in bytes per second.

StatInboundCount
StatOutboundCount
Return the total number of separate inbound and outbound messages sent and received by the Multiplayer object. This includes internally-used messages for things like ping and synchronisation; generally the bandwidth is the more practically useful statistic.

Above is the excerpt from the manual, so what I'm trying to achieve here is calculating the total size of transferred data. I'm not sure whether this is doable or not, I've been trying, it seems I never get the math right for some reason/limitation. I've used events like every 1 second and all condition I can think of, but never seems to be plausible.

I need to start fresh with the math, so can anybody throw me some math expression to calculate this correctly?

Note: This is none important for game mechanics, but I think it will be useful to gauge the requirement of your game in terms of bandwidth. This is not an issue if the game is PC based, but for mobile, it might be important to gauge some game that throwing array.asjson in and out since mobile sometimes are limited in terms of available transfer quota. Think of Clash of Clans, it's the only game I play on mobile, and it can easily go over 500mb in a month of play.
B
28
S
8
G
4
Posts: 553
Reputation: 4,924

Post » Sun Sep 28, 2014 2:04 am

come, on guys give this dude some help, he really was specific...
B
8
S
2
Posts: 134
Reputation: 1,001

Post » Mon Sep 29, 2014 11:15 am

@Ashley is this possible to be done mathematically using the 4 available expression?
B
28
S
8
G
4
Posts: 553
Reputation: 4,924

Post » Mon Sep 29, 2014 1:12 pm

Just add up the estimated bandwidth every 1 second. It will be an underestimate since it measures only payload and not WebRTC/transport layer overhead.
Scirra Founder
B
403
S
238
G
89
Posts: 24,660
Reputation: 196,167

Post » Mon Sep 29, 2014 3:04 pm

Ashley wrote:Just add up the estimated bandwidth every 1 second. It will be an underestimate since it measures only payload and not WebRTC/transport layer overhead.

Oh I already did that, it just that the values are wildly inconsistent with marginal different more than 70%, so I thought there are more consistent way to measure it. Btw, this is just 7 sample of full gameplay of similar sequence/action.

I guess taking average of 200~500 sample and traditional statistical math is the way to go after all.
Nonetheless, thank you for the response. :)
B
28
S
8
G
4
Posts: 553
Reputation: 4,924

Post » Mon Sep 29, 2014 3:20 pm

All it does is add up the bandwidth in/out in bytes in the past second, and since the value updates every second, accumulating it every second should give you a reasonable value of the bandwidth as measured by the payload.

What is it different by 70% to? What else are you measuring it with?
Scirra Founder
B
403
S
238
G
89
Posts: 24,660
Reputation: 196,167

Post » Mon Sep 29, 2014 4:02 pm

Ashley wrote:All it does is add up the bandwidth in/out in bytes in the past second, and since the value updates every second, accumulating it every second should give you a reasonable value of the bandwidth as measured by the payload.

What is it different by 70% to? What else are you measuring it with?

This was a (max - min)/average difference from 7 game session with identical end game result. My test case are similar in all action. The 70% came from peerX, but peerO is much more consistent.

Code: Select all
game1: peerX=944kb;peerO=810kb
game2: peerX=657kb; peerO=799kb
game3: peerX=798kb; peerO=992kb
game4: peerX=1314kb; peerO=1009kb
game5: peerX=853kb; peerO=853kb
game6: peerX=1204kb; peerO=1115kb
game7: peerX=714kb; peerO=840kb

Setup:
DuelHost: Chrome
PeerX: Chrome
PeerO: Opera

My thought is the every 1 second can miss some of the kb/s information, possibly the reason some values doesn't add up. Anyway, another related question, is the information of kb/s exist for the whole one second? If it does, the math I did should produce a very small different in margin which I think around 10% should be the largest difference.

Do you think different time spent in a session would affect the calculation largely? Example I spent 10minutes on game1 but 8minutes in game2 even though I act similarly on both game.
B
28
S
8
G
4
Posts: 553
Reputation: 4,924

Post » Sat Oct 04, 2014 11:37 am

Problem Solved.

It seems that time spent on game does affect the calculation, because of some deep-rooted peerlist checking event I did months ago that I forgot it exist, because it's not logged, silly me. Disabling that portion gave me quite consistent result especially for inbound (<1% margin). Outbound still fluctuate a bit but I guess that is due to some packet losses when tested on 3G connection, and the client retry to send the packet, which adds to the outbound total. So far results from steady home internet gives me the most reliable result, I can almost conclude that there are almost no packet losses on steady connection, this gives me confident to continue heavily on the project, MP plugin is great, kudos to Scirra!
B
28
S
8
G
4
Posts: 553
Reputation: 4,924

Post » Sat Oct 04, 2014 1:28 pm

I wouldn't expect the bandwidth use to be deterministic. Expect variations even for identical runs.

Retransmissions happen at the OS layer and won't be counted by C2's stats. That just tells you how much it tried to send and how much it finally received, not counting whether one of those packets had to be retransmitted 10 times, or even if it got lost completely (it still will have counted the outbound bandwidth because it passed it to the OS network layer).
Scirra Founder
B
403
S
238
G
89
Posts: 24,660
Reputation: 196,167

Post » Sat Oct 04, 2014 2:02 pm

Ashley wrote:I wouldn't expect the bandwidth use to be deterministic. Expect variations even for identical runs.
The test is done with single device (laptop) with just different browser, I haven't done any test between 2 different network, which I plan to use my 3G dongle and home internet (HSBB fibre optic), I think the variation is very small because of the connection is from the same network that it took the LAN advantage. Should I be expecting bigger variation if I use different network? I'm thinking yes.
Now I just need another PC to test 2 different network. :D
Ashley wrote:it still will have counted the outbound bandwidth because it passed it to the OS network layer.
Ahh that's explain the result fluctuation for outbound. Thanks for the info!
B
28
S
8
G
4
Posts: 553
Reputation: 4,924


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 25 guests