Sign in to follow this  
HopeDagger

Feedback on network model?

Recommended Posts

HopeDagger    970
Hey everyone. Right now I'm in the process of starting a rewrite on the network code for Skirmish Online. The last method I used was definitely better than the code in my previous online games, although neither were very scalable, and thus suffered when I had over 6 players online, and the packet-count per-second ran over 120. Doh. So the new idea is to send N packets per second (likely 3 or 4) about all events that have occured client-side or server-side during that timeframe -- the timeframe being the time since the last update packet was sent. This will result in a server in/out of Players*N, and a client in/out of N packets per second, although the per-packet size will be somewhat larger. So a typical packet from the server might look like this (pseudoly): -- Bitvector of Packet Types (let's us know what type of actions we deal with in the packet) -- Add-Player Byte ----- Player Name String ----- Player Password String -- Projectile-Fired Byte ----- Number-of-Projectiles-to-process Byte -------- Loop that number of times and add the projectiles -- Player-Movement Byte ----- Number-of-Players-to-process Byte -------- Loop that number of times and update the players -- Player-Quit Byte ----- Number-of-Players-to-remove Byte -------- Loop that number of times and remove the players And so on. The only data included of course in these packets will be data that the client or server can afford to lose. Reliable data will be handled on another system. This isn't a really concise description of what I'm doing, but gives the general idea of my scheme. I'm just looking for feedback on possible shortcomings of this, or ways to make it more scalable when the player-count starts to go up. If you want some more clarification on any part of the method I'm proposing, just ask. :)

Share this post


Link to post
Share on other sites
Nit    533
I happen to be working on my UDP communication layer of my game now as well! One very important thing that I try to emphasize in my design is that packet != message. All a packet really needs in my implementation is the packet size, and id, and the payload. Under this notion, you should be able to pack several messages into a packet, until that packet is ready to send, or until you have reached your max packet size (you don't want to exceed the Max Transmission Unit which I think is 512 bytes). This should achieve what you are trying to do, without requiring a bitvector of packet types.

If you haven't already, I recommend you read the Reliable UDP Protocol chapter in Game Programming Gems 5. It does a great job of minimizing the number of ACKs sent.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this