XNA Creators Club Online
Page 1 of 1 (14 items)
Sort Posts: Previous Next

More players in a game = more outgoing traffic flow?

Last post 03-30-2008 1:13 PM by Twanks. 13 replies.
  • 03-24-2008 4:20 PM

    More players in a game = more outgoing traffic flow?

    In my network model, with one host and one client, the host is sending about 5KB/sec total. I'm using PacketWriter.Send() to do this without specifying a NetworkGamer to send it to (so as to send it to everone). My question is, will having another client (NetworkGamer) join the game require the outgoing traffic to double to 10KB/sec? Does the host have to send the packet individually to each player specifically? If so, then an 8-player game will require 40KB/sec, which isn't feasible over the internet... I can't test adding another player so if anyone knows how packets are managed by the XNA framework, help a brother out!
    __________________________________________________
    Check out my XNA project here:
    http://people.cis.ksu.edu/~ccaywood/astroblast/
  • 03-24-2008 4:23 PM In reply to

    Re: More players in a game = more outgoing traffic flow?

    I'd say you are probably sending out too much data per second. Perhaps see where you can cut back. Maybe only send packets every other frame or reduce the amount of data sent.

    Nick Gravelyn -- Microsoft XNA MVP
    Blog | Bloc - A New Twist on the Top-Down Shooter | Next-Gen
  • 03-24-2008 4:31 PM In reply to

    Re: More players in a game = more outgoing traffic flow?

    Sending 7 packets/sec per machine. Clients only send about 300 bytes/sec, but the host has to send 300 * (1 + numberOfAIBots) per second to update the AI players on the client machines. Testing using 20 AI bots. Aiming to support 16 players total in under 8 KB/Sec bandwidth, which is numerically possible because 16 * 0.3 < 8 KB. But if the packet must be send for each Network Player I may have to optimize further and perhaps split up AI management across all of the machines rather than making the host do everything.

    So really I just need to know, will upstream traffic be multiplied by the number of NetworkGamers?
    __________________________________________________
    Check out my XNA project here:
    http://people.cis.ksu.edu/~ccaywood/astroblast/
  • 03-24-2008 4:43 PM In reply to

    Re: More players in a game = more outgoing traffic flow?

    What do you need 300 bytes of information for a single AI for? That seems rather large.

    Nick Gravelyn -- Microsoft XNA MVP
    Blog | Bloc - A New Twist on the Top-Down Shooter | Next-Gen
  • 03-24-2008 5:10 PM In reply to

    Re: More players in a game = more outgoing traffic flow?

    Same information needed for players:

    12 bytes for each position, velocity (for network prediction), and orientation = 36.

    If fired main gun, need 32 bytes for projectile start position, velocity, yaw and pitch (roll irrelevant, so left out)

    If fired missile, need 12 bytes for starting position, and 1 byte for homing target index.
        Missile packets must also be sent as reliable.

    So total, we have between 36 * 7 (packets/sec) = 252 and 567 bytes/sec for player or AI, plus the packet headers, plus a few bits describing whether the player is dead/cloaked/has the flag. But a majority of the time, the player is not firing, so it averages about 300-350 bytes/sec. If the player is dead, it costs the packet header and 1 bit.

    Network traffic is minimal compared to the complexity of the world, projectiles are not talked about across the network once they are fired. Some dynamic objects are only synchronized once a minute (works well since their velocities are constant). I use heavy network prediction since I only send 7 packets a second, and even with simulated latency and packet loss I can still fight the AI without things getting too out of wack on the client machine.
    __________________________________________________
    Check out my XNA project here:
    http://people.cis.ksu.edu/~ccaywood/astroblast/
  • 03-24-2008 7:35 PM In reply to

    Re: More players in a game = more outgoing traffic flow?

    ouch i would seriously consider either googling delta Compression and/or Binary Compression to get things alot lower im still basic so i havnt had to deal with sizes yet but i know that will be a problem to come soon.
  • 03-25-2008 7:58 AM In reply to

    Re: More players in a game = more outgoing traffic flow?

    Yes, the outgoing bandwidth usage is proportional to the number of machines (not players: if there are several players logged in on the same machine, only a single packet needs to be sent to that machine) that you are sending data to.
    XNA Framework Developer - blog - homepage
  • 03-25-2008 9:12 AM In reply to

    Re: More players in a game = more outgoing traffic flow?

    Not wanting to hijack the thread too much, the question seemed relevant enough to ask...

    In a situation where you have a Live game with, say, 8 players, and 2 of those are in the same house, using the same internet connection (through the same outgoing router), will the data get passed directly between them (via the router) rather than going out onto the internet for a jaunt before returning back to the other machine? (Ie, will the latency be almost zero as it is under normal system link conditions?)

  • 03-25-2008 12:55 PM In reply to

    Re: More players in a game = more outgoing traffic flow?

    In general, for a peer-to-peer system, the bandwidth usage is:

    out: R * (S + O) * (P - 1)
    in: R * (S + O) * (P - 1)

    For a client/server system, the bandwidth usage is:

    client, out: R * (S + O)
    client, in: R * (S * (P - 1) + O)
    server, out: R * (S * (P - 1) + O) * (P - 1)
    server,in: R * (S + O) * (P - 1)

    R = send Rate (packets per second)
    S = Size of data per player
    O = per-packet Overhead
    P = number of Players

    As you see, client/server trades slightly more efficient client input (less pakcet overhead), and a lot more efficient client output, for a higher server output requirement. Exactly how this ends up mattering depends on your variables S, R and P. "O" is on the order of 40 bytes for Xbox Live! (there's some additional framing on top of the 28 bytes for UDP).

    Note that what the others said is true: there is no reason to send full 32-bit floats for any value. For positions, you can probably get away with 16-bit shorts, quantized. For quaternions, you may even get away with 4 bytes (or, perhaps, 3 bytes, treated as Euler angles).


    Jon Watte, Direct3D MVP kW X-port 3ds Max .X exporter kW Animation source code
  • 03-26-2008 12:13 AM In reply to

    Re: More players in a game = more outgoing traffic flow?

    Good call on packing singles into shorts, jwatte. I halved the amount of traffic and the side effects are only noticeable when players are moving very slowly (which shouldn't happen if the game is being played right). My next task is to split up bot control amongst all the machines so that the host isn't burdened with so much outgoing traffic, and then things should be golden. Thank you all for your help!
    __________________________________________________
    Check out my XNA project here:
    http://people.cis.ksu.edu/~ccaywood/astroblast/
  • 03-27-2008 11:25 PM In reply to

    Re: More players in a game = more outgoing traffic flow?

    To answer Adam Miles, I seriously doubt it would just go through the local network. The reason I say this is because I have three Xbox 360's all connected through the same router to Xbox Live, and before I did private chat with family members on my local network I had to configure my router's firewall to use different ports for Xbox Live. So in short, I don't think the data would just pass through the router.
    http://twanks.spaces.live.com
  • 03-28-2008 2:02 PM In reply to

    Re: More players in a game = more outgoing traffic flow?

    But... where else would it go? Microsoft's servers aren't servers in the traditional sense of a "dedicated server" for a PC game, that physically host any games / direct traffic, the LIVE API is inherently peer to peer. I simply can't think where the data could go if not over the local network.
  • 03-28-2008 2:09 PM In reply to

    Re: More players in a game = more outgoing traffic flow?