MMORPG Networking

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

    • MMORPG Networking

      So i've been without internet for almsot 2 weeks now and its been killing me lol. But last week i started actually producing some code for a game i'm making. So far i've got a Loginserver a Worldserver and a client. I might branch the worldserver off into other servers to manage game and just use the worldsever for character selection and a few other things i'm not sure yet. I also thing i might add a chat server to manage the chat for the game so players can communicate even if they're on different servers.

      But basically heres what i've got working.

      All of the programs
      - Send and Recv packets of information
      - Interpret the packets recieved and decide what to do with this information
      - Combine multiple structs of data into a single packet (must be same type) to reduce the ammount of data sent.
      - Each packet knows where it came from, where its suppose to go, its size, and the type of packet.
      - The ability to dump the contents of the packet in hex or binary to a file or the console screen.
      - Load settings from an ini file. Such as login server port, ip to connect to.
      - Reconizes any dropped connections and deals with them accordingly.

      Loginserver
      - Accepts connections from multiple worldserver and users
      - Authenticates the login of the worldserver and users by checking information with a MySQL database and replies letting them know if it was successfull, or there was an error (if there was an error it goes into more detail)
      - Sends the client a list of worldservers to connect to upon request with the world name and status (Up, down, locked)
      - When the user asks to log into a worldserver it double checks that the server is up and unlocked then it does a type of hand off to the worldserver. It lets the world know which client to expect a connection from. Then sends the client the ip and port to connect to. Then disconnects the client from the loginserver.
      - Connects to a MySQL database from data loaded into the program by a ini file. It can then recv any information it wants from this database such as username password for clients and worldservers.
      - Reconizes special types of users ( GameMasters or Devs etc )

      Worldserver
      - Doesnt really do much right now except for connecting to the loginserver and accepting clients upon the request of the loginserver.
      - Reads a ini file containing the port its listening on and the port and ip of the loginserver
      - It can connect to the database the same way the loginserver can though it doesnt use it for anything yet.
      - If a connection with the loginserver is lost it will attempt to reconnect every 20 seconds or so you dont have to stop people from playing if something happens to the loginserver.

      Client
      - Checks for available loginservers ( right now it can check for three ) which are all loaded from an ini file. It will connect to the first available loginserver that it finds.
      - Upon connecting to a loginserver it will send authentication information such as username password to verify that we have an account.
      - Send a request to the loginserver for a list of worldservers to choose from.
      - Request to connect to a specific worldserver. If the reply from the loginserver gives the ok it will attempt to connect to the worldserver and if successful it will drop the connection from the loginserver and send some validation information to the worldserver so i can log in


      Anyways thats basically what i've done this past week. You'd be supprised how much codeing you can get done when you have no internet, no current job and classes havent started back up yet. I guess my whole point in writing this is to see if i'm going along the right path or if something in this architecture needs to change before i get to much into this. Also i'm not sure what type of security measures i need to take to prevent a client from bypassing the authentication process from the loginserver and going straight into the worldserver. It doesnt seem like it would be that difficult for someone to spend some time with a packet collector and figure out how to immitate a loginserver for the client. So if you have any advice/criticism, besides complaining that my post is too long, then it would be appreciated, cause i'm very new to this and i've already torn down my programs and rebuilt them from scratch cause i didnt like the way i handled things. I'm not afraid to do it again to make the code better and learn more.

      Oh yeah almost forgot. I know how to use a md5 encrpytion for php or something but how would you get a cpp program to generate one. Cause right now the passwords arent encrypted in the database ( go go hackers ).

      PS: I forgot to add Mr Mike, I just moved to austin lol i'm loving every minute of it.
      - Brian Wight

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

    • It seems you are going along the right track. The original Ultima Online server system worked in much the same way.

      If you want to keep someone from attaching to a world server directly - have the login server generate a "ticket" of some kind when it detects a successful login - something like a random 128 bit number or something - and have the login server send this ticket to the client and the worldserver.

      When the client attaches to the worldserver, it must present a valid ticket or the worldserver will know the client is bogus.

      One more thing - make sure all of these transactions are recorded in a log file of some kind, or perhaps your database, so that you can sift through them later and find out how something went off the rails.

      In Ultima Online, and in most MMO's I expect, the WorldServer is actually hidden behind a firewall - clients would never attach directly to anything that is actually running the game. Instead, the clients attach to a UserServer which handles all the TCP/UDP traffic from clients, and figures out what to do with it before sending them along to a WorldServer. This helps you scale your system - by being able to add UserServers and WorldServers independant of one another, but more importantly it provides security for the WorldServer. These important systems should never be touched directly by your clients.

      One other thing you'll need to create is something that will allow valid client accounts to be generated - something like a web site where gamers can fill in a form and have an account created - with their password, etc., and have it emailed to them. You'll also want an administrator portion of the same web site where you can reset their passwords or lock out users who are behaving badly. If I were you - I'd use the some forum software like vBulletin or Burning Board - you can grab userids and passwords from their MySQL databases and jump start your community all at the same time.

      Then all you need is the game client, and the game server, and you have a bare bones MMO client authentication/login system with a little administrative support.
      Mr.Mike
      Author, Programmer, Brewer, Patriot
    • Well first i'd like to say thanks for the information you gave me. I knew that i'd need to have some type of web based account creation i have a lot of experience designing websites that should be very easy to do. The SQL table i have already has columns for the account validation and if they've been banned or not.

      I hope to get back to the network side of the programming soon cause i really enjoy it (mostly because i'm starting to understand it now), but right now i'm trying to figure out all this DX9 API stuff. Hopefully it wont take long for me to get a hang of that too and start loving it as much as i love the networking side of things.
      - Brian Wight