如何将一个网络游戏处理计算和数据包发送成千上万的玩家每个刻度为真人游戏? [英] How would an MMO deal with calculating and sending packets for thousands of players every tick for a live action game?

查看:264
本文介绍了如何将一个网络游戏处理计算和数据包发送成千上万的玩家每个刻度为真人游戏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个游戏,我想进入网络。我一直在编程5年左右,上了游戏开发的最后2年。我15岁,所以我才真正在线并从我自己的时间书本学习。我打算做一个Java服务器亚马逊AWS EC2,但我只是想知道如何MMO的处理多个选手每一跳。

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 am 15 years old so I only really learn online and from books on my own time. I am planning to make a java server for Amazon AWS EC2, but I am just wondering how MMO's handle multiple players each tick.

难道服务器只是纯粹的权力?我不是找code或任何东西,只是一般的服务器是如何工作的。

Is it just the sheer power of servers? I am not looking for code or anything, just in general how the servers work.

服务器是否只是做所有的计算,所有的球员和几万或几十万的对象,然后发送和接收数据包数以千计每打勾的?这似乎只是像很多在一台计算机来处理,但它确实是一个服务器。

Does the server just do all of the calculations for all of the players and the tens or hundreds of thousands of objects and then send and receive thousands of packets every tick? It just seems like a lot for a single computer to handle, but it is indeed a server.

感谢。

推荐答案

如何工作的,什么是一台服务器的工作?

  • 您的服务器创建一个套接字并打开一个端口。

  • Your server create a socket and open a port.

该协议的网络游戏一般是在UDP,因为它更快。

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

您的服务器必须处理所有的客户端的连接。

Your server have to handle ALL the clients connections.

您可以添加一台服务器是谁能够登录的帐户和重定向他变成了一个游戏服务器(这是所有大型MMO的情况下)。

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.

不过,一台服务器要坚强!不喜欢一个客户,因为他并不需要一个大的GPU,但他需要的RAM / CPU的数量较大(取决于游戏),他还需要为留冷

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.

其实,游戏服务器能够处理大量的,因为UDP协议的连接,因为所有的重型零件的程序都在客户端。你可以看看这里:<一href="https://stackoverflow.com/questions/30227722/creating-a-multiplayer-game-in-python/30228185#30228185">Creating多人游戏在Python 并阅读部分时,我解释了UDP和TCP协议的区别。

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.

关于如何工作的一个网络游戏服务器的其他信息将在本主题的末尾链接。

现在,我们可以尝试建立一个服务器!

Now we can try to build a server!

首先,你知道如何创建一个服务器?

  • 程序或下载一个服务器做一个测试。(例如:TeamSpeak或波波)

  • 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.

您登录你的modem和前进/服务器的端口重定向到您的计算机。

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...!

您的计算机有三个IP地址:

  • 环回地址:本地主机,127.0.0.0(0可以改变)

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

内联网地址(IP连接到您的计算机):192.168.0.0,172.16.0.0,10.0.0.0

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

和互联网地址(IP连接到调制解调器):0.0.0.0

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

如何知道自己的Intranet / Internet的IP?这取决于你的操作系统和调制解调器。对于内网使用终端,并写上使用ifconfig或IPCONFIG。为您的互联网地址,它有时,当你登录你的调制解调器,或者你要访问一个网站是谁能够告诉你你的IP写。

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.

如果您创建一个服务器,并且没有端口,从您的调制解调器转发,您仍然可以访问到你的服务器在本地与您的环回地址并连接到相同的调制解调器其他电脑也可以访问到服务器的内网地址。另外,如果你需要测试,如果你的服务器是从Internet访问,您必须测试您的Internet IP的连接,但一些调制解调器不允许从内部网络的外部连接......所以,如果用互联网IP的连接不工作,尝试登录你从另一个调制解调器服务器(朋友的PC,网络咖啡...)。

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...).

最后,如何保护你的服务器?

这是真的很难,你不能创造一个完美的安全......特别是如果你按照我的意见​​,但你并没有与自己的研究完成我的知识。

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权限

这是最重要的部分。当LAMER尝试访问您的服务器,也只是尝试,如HTTP / SSH / FTP的简单连接。如果他可以访问到你的硬盘上,你没有选择一个强大的限制,他可以简单地读取/修改/删除你的游戏的数据库。该数据库包含所有有关账户的所有信息。

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.

  • 防火墙

我们已经谈论的连接/度计算的金额比服务器要处理。在一些攻击中,LAMER尝试创建连接的数量较大,并没有关闭它们。我们称之为一个DOS(带一台电脑)或DDOS(超过一台电脑)。从唯一的IP让你的服务器的唯一端口,允许只有X连接数量,并允许新的连接的每分钟只有X号

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.

  • 更新

这是最容易的部分:保持你的操作系统(以及其他应用程序)最新

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

  • 越少越好

不要安装很多无用的软件到您的服务器。如果软件没有为你的服务器导入,您不应该安装他是因为:首先,这可能是一个病毒。其次,恶意软件可以利用这个软件,安装了病毒或窃取的root权限。

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.

  • 加密

加密是块一个黑客真的很重要。例如,使用HTTPS协议,你可以从MITM攻击的保护了用户的密码。而随着鯥/ SHA /人,可以加密数据库为保护她即使黑客可以阅读。最重要的是始终阻止写入/修改/删除/黑客的执行权(事实上,你的游戏的所有客户端所需要的读访问)。

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).

  • 防病毒?

在一个在线游戏的情况下,防病毒是不是真的很重要(但仍建议所有操作系统的Linux / Unix也)。

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

  • 有一个好的服务器

如果你的服务器编程没有照顾的安全性,你可麻烦了。例如:在C / C ++缓冲区溢出攻击

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

如果您需要了解如何工作的一个网络游戏更多的信息,我建议你:

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

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

https://www.quora.com/How -DO-I创建-AN-MMORPG

提示 - 如果你是通过创建一个在线游戏的趣味性,你必须做很多的研究,我真的不能在这个问题回答,因为在主体的目的。而这个题目太大,写在每一个问题上新的答案......对程序的游戏,软​​件的使用?如何建立一个插座?在哪里开始?但是我在一些类似的问题已经回答。即使编程语言是不同的某个时候,我给你的链接,逻辑总是一样的,所以它也许可以帮助你:

  • <一个href="https://stackoverflow.com/questions/30227722/creating-a-multiplayer-game-in-python/30228185#30228185">Creating在python 多人游戏

<一个href="https://stackoverflow.com/questions/30564281/x$c$c-mass-multiplayer-not-what-youre-probably-thinking/30818450#30818450">X$c$c大众多人(不是你可能在想)

<一个href="https://stackoverflow.com/questions/29545597/multiplayer-game-in-java-connect-client-player-to-game-that-was-created-by-ot/30820890#30820890">Multiplayer游戏中的Java。连接客户端(播放器),以游戏,是由其他客户端创建

这篇关于如何将一个网络游戏处理计算和数据包发送成千上万的玩家每个刻度为真人游戏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆