How would an MMO deal with calculating and sending packets for thousands of players every tick for a live action game?

后端 未结 2 1773
醉梦人生
醉梦人生 2021-01-27 03:17

I am working on a game and I am thinking about getting into networking. I have been programming for about 5 years and got into game development the last 2 years. I only really l

相关标签:
2条回答
  • 2021-01-27 04:04

    How work and what is the job of a server?

    • Your server create a socket and open a port.

    • The protocol for an online game is generally in UDP because it is faster.

    • Your server have to handle ALL the clients connections.

    • You can add a server who is able to log an account and redirect him into a game server (this is the case for all the big MMO).

    • Your server have to manage all the calculations from the Data Base: when an enemy hit another enemy, subtract a part of your money when you buy some stuffs...

    • So the server is the main part of an online game.

    In fact, a computer is really fast for do some calculations, the most heavy part for a modern video game is the physics and graphics... Fortunately, these both parts are on the client part.

    But, a server have to be strong! Not like a client because he doesn't need a big GPU, but he need a big amount of RAM/CPU (depend of the game) and he also need to stay cold.

    In fact, a game server is able to handle a large amounts of connections because of the UDP protocol and because all the heavy parts of the program are on the client side. You can take a look here: Creating a Multiplayer game in python and read the part when I explain the difference between the UDP and the TCP protocol.

    All the others informations about how work an MMO server are linked at the end of this topic.

    Now we can try to build a server!

    Firstly, do you know how to create a server?

    • Program or download a server for do a test (example: TeamSpeak or Mumble).

    • Launch him from your computer and allow his input connections from your firewall.

    • Log you on your modem and forward/redirect the port of your server into your computer.

    For the last part, you need to do some research: Which port is used by my server and how to forward a port with my modem (each modem is different).

    Now you can try to log you into your server. But...!

    Your computer have three IPs:

    • The Loopback address: localhost, 127.0.0.0 (The "0" can change)

    • The Intranet address (IP linked to your computer): 192.168.0.0, 172.16.0.0, 10.0.0.0

    • And the internet address (IP linked to your modem): 0.0.0.0

    How to know your Intranet/internet IP? That depend of your Operating System and your modem. For the Intranet use your terminal and write "ifconfig" or "ipconfig". For your internet address, it is sometime write when you log you to your modem, or you have to visit a website who is able to show you your IP.

    If you create a server and you didn't forward the port from your modem, you can still access to your server in local with your Loopback address and the others computers connected to the same modem can also access to the server with the Intranet address. Also, if you need to test if your server is accessible from internet, you have to test the connection with your internet IP, but some modem don't allow the externals connections from the Intranet... So if your connection with the internet IP doesn't work, try to log you to your server from another modem (friend's PC, Cyber-Coffee...).

    Lastly, how to protect your server?

    This is really difficult and you cannot create a perfect security... Especially if you follow my advices but you didn't complete my knowledge with your own research.

    • Root access

    This is the most important part. When a lamer try to access to your server, he can just try a simple connection like the http/ssh/ftp. If he can access to your hard disk and you haven't chose a strong restriction, he can simply read/modify/delete the Data Base of your game. The Data Base contain all the informations about the accounts.

    • Firewall

    We have already talk about the amount of connections/calculation than a server have to handle. In some attack, the lamer try to create a big amount of connections and didn't close them. We call that a DOS (with 1 computer) or DDOS (more than 1 computer). So you need a good firewall for: allow only the port of your server, allow only X numbers of connections from an unique IP and allow only X numbers of new connections every minutes.

    • Updates

    This is the easiest part: keep your Operating System (and the others applications) up to date.

    • Less is better

    Don't install many useless software to your server. If a software is not import for your server, you shouldn't install him because: firstly, that can be a virus. Secondly, a malware can exploit this software for install a virus or steal the root access.

    • Encryption

    The encryption is really important for block an Hacker. For example, with the https protocol you can protected the user's passwords from the MITM attack. And with the Bluefish/SHA/others, you can encrypt your Data Base for protect her even if an Hacker can read it. The most important is always to block the write/modify/deletion/execute right of the Hacker (in fact, all the clients of your game need the read access).

    • Anti-virus?

    In the case of an online-game, an anti-virus is not really important (But still recommended for all Operating System, Linux/Unix also).

    • Have a good server

    If your server is programmed without take care of the security, you can be in trouble. Example: Buffer Overflow attack in C/C++.

    If you need more informations about how work an MMO, I recommend you:

    • http://electronics.howstuffworks.com/mmorpg6.htm

    • https://en.wikipedia.org/wiki/Server_%28computing%29

    • https://en.wikipedia.org/wiki/Game_server

    • https://www.quora.com/How-do-I-create-an-MMORPG

    Hint - If you are interesting by create an online game, you have to do many research, I cannot really answer in this question because is not the purpose of the subject. And this subject is too large for write a new answer at each question... Which software use for program a game? How to build a socket? Where started? But I have already answer at some similar questions. Even if the programming language are sometime different, I give you the link, the logic is always the same so it can maybe help you:

    • Creating a Multiplayer game in python

    • Xcode Mass Multiplayer (Not What You're Probably Thinking)

    • Multiplayer game in Java. Connect client (player) to game that was created by other client

    0 讨论(0)
  • 2021-01-27 04:12

    Most MMO's have a healthy amount of client logic so that the server doesn't need to send multitudes of packets to every player all the time. The server doesn't do calculations for all players, the client does the heavy lifting and the server deals with the clients and the state of the virtual world in a database.

    For example, your client and server could have the same world model. That way your player can navigate the world and the client code tell the server on a fairly course interval (say 100's of msecs).

    Generally you want your clients to update themselves to the server, and have the server response deal with keeping the clients in sync.

    MMOs also run multiple servers in their farms, from tens to hundreds. These servers typically talk to a large high-performance database - basically the state of the virtual world is in the database, and the servers sit in between keeping the database up to date and communicating to the client apps.

    0 讨论(0)
提交回复
热议问题