网络游戏客户端如何能够如此快速地通过互联网交换数据?
让我们想象一下非常简单的游戏...我们有一个迷宫和两个玩家试图通过互联网实时找到出口。
在每次移动时,游戏客户端都应将玩家的坐标发送到服务器并接受另一个客户端的当前坐标。怎么可能让这种交换如此之快(就像所有现代游戏一样)。
好吧,我们可以使用memcache或者类似的技术来减少服务器端的数据挖掘操作。我们还可以使用最快的网络服务器等,但我们仍然会遇到计时问题。
那么,问题是...
- 游戏客户端通常使用什么协议与服务器交换信息?
- 哪些服务器技术可以解决这个问题?
- 应用什么算法来处理游戏等过程中出现延迟的战斗。
Let's imagine really simple game... We have a labirinth and two players trying to find out exit in real time through internet.
On every move game client should send player's coordinates to server and accept current coordinates of another client. How is it possible to make this exchange so fast (as all modern games do).
Ok, we can use memcache or similar technology to reduce data mining operations on server side. We can also use fastest webserver etc., but we still will have problems with timings.
So, the questions are...
- What protocol game clients are usually using for exchanging information with server?
- What server technologies are coming to solve this problem?
- What algorithms are applied for fighting with delays during game etc.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
通常采用网络插值和预测。 Gamedev 是一个很好的资源:http://www.gamedev.net/reference/list .asp?categoryid=30
另请查看此:http://developer.valvesoftware.com /wiki/Source_Multiplayer_Networking
Usually with Network Interpolation and prediction. Gamedev is a good resource: http://www.gamedev.net/reference/list.asp?categoryid=30
Also check out this one: http://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking
提示:无论如何,都会使用预测来平滑快速屏幕更新(~60fps),因为实际游戏速度通常较慢(~25fps)。
hint: prediction is used anyway to smooth the fast screen update (~60fps) since the actual game speed is usually slower (~25fps).
其他答案没有阐明原始帖子中的一些重要误解,即这些游戏不是网站并且运作方式完全不同。特别是:
需要加快速度。最快在线
游戏(例如第一人称射击游戏)
通常不会保存任何内容
比赛期间的磁盘。上网速度较慢
游戏,例如 MMO,可能会使用
数据库,主要用于存储
玩家信息,但对于大多数
他们将玩家和世界数据保存在内存中,
不在磁盘上。
网络服务器。 HTTP 相对较慢
协议,甚至 TCP 本身也可以
对于某些游戏来说太慢了。相反,他们
有专门为该特定游戏编写的定制服务器。通常,这些服务器会针对低延迟而不是吞吐量进行调整,因为它们通常不会像 Web 服务器那样提供大文档,而是提供许多微小的消息(例如,以字节而不是千字节为单位)。
解决了这两个问题后,您的速度问题就基本上消失了。您可以向服务器发送消息并在 100 毫秒内获得回复,并且每秒可以执行多次。
The other answers haven't spelled out a couple of important misconceptions in the original post, which is that these games aren't websites and operate quite differently. In particular:
to be speeded up. The fastest online
games (eg. first person shooters)
typically are not saving anything to
disk during a match. Slower online
games, such as MMOs, may use a
database, primarily for storing
player information, but for the most
part they hold their player and world data in memory,
not on disk.
webservers. HTTP is a relatively slow
protocol, and even TCP alone can be
too slow for some games. Instead they
have bespoke servers that are written just for that particular game. Often these servers are tuned for low latency rather than throughput, because they typically don't serve up big documents like a web server would, but many tiny messages (eg. measured in bytes rather than kilobytes).
With those two issues covered, your speed problem largely goes away. You can send a message to a server and get a reply in under 100ms and can do that several times per second.