Client -> Server Architecture Question

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Client -> Server Architecture Question

      Im looking at this from a very abstract level. But Im basically looking for some guidance. Here how I 'think' communication works between the server and clients, please tell me if im wrong...

      the server is started and listens for connections

      a client sends a message to the server requesting to join

      the server saves the ip/port info to a list and says ok

      .... repeat for all connecting clients ...

      so, whenever a client machine moves or performs an action, it must send a message to the server, the server then forwards this information to the other clients to sync them up?

      for instance, lets say client#1 moves forward....

      the server recieves the message to move from client#1 and forwards the message to client#2/#3/#4


      so, in essence, is that all the server does, is forward messages/events?

      if so, does the server need to track game objects, or is this done by the clients on a global scale ( ie. all clients are replicating the same enviornment on all other clients via the messages it recieves from the server )?

      thanks for any assistance,
      Stellar

      The post was edited 2 times, last by Stellar ().

    • RE: Client -> Server Architecture Question

      You've basically got it right.

      The server checks any client messages for validity - such as actually moving said object in the game world, and then responds with something the client can use to change the graphics.

      Client says - "Add forward force of 5N to my spaceship"

      Server grabs message, realizes that the game object is already at maximum speed.

      Server says to client - "No way hose. Are you some kind of hacker?"
      Mr.Mike
      Author, Programmer, Brewer, Patriot
    • I must be missing something still. Are these network messages supposed to be maintained 60 times a second? Perhaps its a process that works faster than I am imagiing. It's kinda hard for me to imagine that all clients are basically puppets and the server and netcode pull the strings. I've got to wonder how much data is sent over the network for games like ut2004.
    • You've hit on an important point - the messages are tuned to allow a certain amount of inaccuracy in the client, but not so much that it hurts gameplay.

      The server always has the authoritative view of the game - but the clients do some heavy lifting to make intelligent guesses about what is going on, especially when lag gets large - say, over 100ms or so.

      If you've ever played Project Gotham 2 on Xbox Live with eight players you know what I'm talking about....sometimes the cars will "warp" instantly from one place to another.

      What's going on behind the scenes is the server and client are updating the cars position at a much lower rate than 60Hz - in fact the client is estimating where all the cars are based on what it knows about linear velocity, linear acceleration, angular velocity, and angular acceleration. From time to time the server will send absolutes of all these values to all the clients, and the clients will try to "fix" things without looking stupid.

      This can be done by rapidly moving the cars over 500ms or so to their "correct" position and orientation. This looks better than a straight "warp". If you play some network shooters you'll see some funky stuff from time to time, like rockets turning 90 degree corners to frag someone - this is the same kind of "fixup" done on the client side.

      Any good game playable over the internet has to balance bandwith useage with accuracy of the simulation as percieved by the client. In the case of MMO's like World of Warcraft, saving a few bytes of bandwidth here and there can make a huge financial difference.
      Mr.Mike
      Author, Programmer, Brewer, Patriot
    • Well i'm gona try and get a little more details from this question. I guess what my question is this...

      Lets say for instance i'm playing World of Warcraft and i press the "w" to move forward. You have two (maybe more) options...

      -send the update right away telling the server that i moved "1 unit forward"

      or

      -travel forwards for a ms grab the new xyz coords of the character and send an update to the server with the new coords.

      Personally i would choose option 2. Using option 2 you could create some function that would send updates to the server on regular intervals or something. This would keep the net traffic down. The only problem i see with something like this is anything done from the client makes hacking easier. Then again i havent tried this because i have barely started my game but this seems most logical.

      It seems to me that in a game like World of Warcraft there are some things controlled client side, like movement, and some things server side, like combat and spellcasting.
      - Brian Wight
    • so your option 1 is basically a coded version of data, and your option 2 is an actuall data. sending straight text of course would be slowest, but just compress the data and you've both cut down on transfer size and on hackability. This is probably an easy area to get creative. An area I cant wait to start experimenting with. But, I fear, I have a long way to go before I get much enjoyment out of development. Right now, Im in the horrific learning phase when I go to sleep every night wondering how the next piece of the puzzle is going to fit.
    • hm.. yes and no.

      If i wanted to send a string of static text i would use a code to represent the string. Both server would have a list of these codes and know their meaning. Sending something thats 2 bytes long is much simpler then sending a string of text.

      Note: Dont take what i say as the truth, i'm as in-experienced codeing as you are if not more so. I just find the whole networking behind MMO's very intresting theres lots of neat stuff you can do with packets and opcodes. Mr Mikes book has gotten me all excited about game programing / development now, more then i ever was before...
      - Brian Wight

      The post was edited 1 time, last by Monalin ().

    • I would do both.

      Send a message to the server that says you are now in motion which allows the server to some guess as to where you will be in the future and then at intervals send the server your absolute location so the server can check the guesses it makes.

      Now i suposs the draw back is you are sending more data but if the server has your velocity and reletive location you can send the coordinates less and less. You can also prvent hacking by having a standard variation. If you are moving forward at 3 mph it doesnt make sense to the server to get a coordinate that is 500 miles away from where you were a second ago.
      .Code
      push you ; haha!
    • Few more questions to throw into the air...

      so does the server have the original instance of the game logic? Which would be from an administrators viewpoint ( the gameworld as it should be ), which, in turn, trys to keep a real-time copy on all the clients ( via forwarding messages/packets )?

      I thought it was interesting how mike combined the server and client executable, Im really going to have to look and the code closer and determine how he seperates the server code from the client, it looks like its pretty much the same thing ( and the book describes it as that way I believe ).
      In my case, I have a seperate server executable that links with the game logic library.

      Ill have to experiment with estimating ping and approximatly how much data can be send over a network at 100/50/20 ping respectivley and at what intervals.

      later,
      -stellar

      The post was edited 1 time, last by Stellar ().

    • The server would NEVER accept straight coordinates from a client - rather the server would get the command from the client that the client wanted to move forward.

      The server would check to see if that was legal, and if it was it would send an "OK" back to the client in some form.

      All the while the client performs its own local check of legality and where the unit would be placed if the server ok'd the move - that is done to keep things looking snappy on the client side.

      So - there is a version of game logic on the client, but it only serves to make good guesses about the world state to make the game appear delay-free. The reality is that the turnaround time for these requests and acknowledgements can be in the 200ms range or higher - which is extremely noticable by players.
      Mr.Mike
      Author, Programmer, Brewer, Patriot
    • And you can see the side affects as a result of this. Because they accept coords there are many teleport hacks. A hunter for instance can go into some zone, teleport up in the air where they cant be touched and kill just about anything then teleport to another location. Now i believe there are some more ways to fix this form of hacking on the server. WoW's coding isnt exactly the best thing around some of the ideas they came up with were very creative but the code lacks some reliability.

      Now to address what Mr Mike was saying. I understand the concept you explained but i think what I am still confused about is how you would handle the character moving long distances?

      Let say the character is going to move 500 meters ( unknown at this time to the server or client ) Lets just say there is a map with gridlines every 1 meter. Would you have to run through this procedure of checking location and giving the "ok" to the client 500 times or can you make some educated guesses to cut down on the net traffic. Maybe i'm underestimating how fast this can all be done.
      - Brian Wight
    • The more accuracy you want the more often you have to do the checks...it's totally dependant on what kind of game you have and what risks you have of people thowing controllers across the room if they get crappy lag based issues....
      Mr.Mike
      Author, Programmer, Brewer, Patriot
    • ok, I think i got it now. the client, tries to do a big balancing act on a highwire rope and the server doesnt pull all the client strings, it gently tugs them to keep the client from becoming too unstable and falling to his doom. the server puppetmaster can only tug with a light force though and no more than 10x a second depending on the string thickness :P

      Now, if that wasnt ambiguous :O

      The post was edited 1 time, last by Stellar ().

    • So bottom line i think....

      The server should never be "corrected" from its mistakes. Because it wont make mistakes. Whatever kind of information the server receives from the client needs to be enough to control the client during the times that its not receiving information.

      This is because the other clients get valuble information from the server, if the server attempts to change itself after clients have already received data then the correct data would have to be resent to the clients. Resending this data would cause more lag and things jumping around all over the place. The server is the source of data thus it should always be correct.

      Since the client's and the server's code are almost exactly alike hopefully the client will make the same decisions as the server and have very little corrections to make.
      - Brian Wight

      The post was edited 1 time, last by Monalin ().

    • With regard to World of Warcraft (which I play and enjoy greatly). There are distinct synchronisation problems between the client and the server.

      The server only seems to send relative movements for a mobile (mob) to the client. This allows a problem to arise where the client and server think the mob is in a different place. This can lead to you standing next to a mob and being told you are too far away to hit it (or being told you are facing the wrong way). Most annoyingly the client does not detect this and request an absolute location for the mob.

      This is also noticeable as often when a mob dies the body appears slightly moved from where it died. This is because the corpse is a separate object and is inserted into the client world space with an absolute position (where the server knew the mob was).

      Much as I admire the complexity of what they achieve (I would love to know the architecture of continent servers, instance servers, chat servers, authentication, and other data stores that make up realm and realm clusters), they do have real issues with the client/server comms and synchronisation.

      The question is how do you allow the client to detect when it has a material error in its local state and how do you correct it? WoW errs on the side of not stressing the comms but sometimes you get significant differences. Is there a better way?
      Gamma Testing - Where testing is extended to the full user community (AKA Shipping the Program)