在简单的基于 python-socket 的服务器和客户端之间同步时间

发布于 2024-08-15 01:30:16 字数 182 浏览 4 评论 0原文

我开始用 python 编写一个小型多人游戏作为学习练习。目前服务器以 10 fps 的速度运行,而客户端则以他们喜欢的任何速率运行。这可以很好地节省带宽,但除非客户端告诉服务器其输入何时发生,否则所有输入都会量化为 100 毫秒的间隔。如何同步客户端和服务器之间的时间以便进行这些更正?这里的一个主要障碍是我需要确定 ping 时间并对其进行补偿。

I have the beginnings of a small multiplayer game that I'm writing in python as a learning exercise. Currently the server runs at 10 fps, while the clients run at whatever rate they like. This works well to conserve bandwidth, but unless the client tells the server when its input happened, all input gets quantized to 100ms intervals. How can I synchronize time between client and server so that I can make these corrections? A major hurdle here is that I'll need to determine ping times and compensate for them.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

も星光 2024-08-22 01:30:16

我偶然发现了一篇非常精彩的博客文章,介绍了如何在一般(没有传统的客户预测)。我强烈推荐它以及 Fiedler 几年前展示的 GDC 幻灯片。祝你好运!

I accidentally came across an excruciatingly fine blog post on how to do distributed network physics in general (without traditional client prediction). I highly recommend it, along with the GDC slides Fiedler presented a couple of years ago. Good luck!

爱人如己 2024-08-22 01:30:16

这是一个非常有趣的问题。不幸的是,没有简单的答案。您只需很好地理解这个问题,并选择一个足够好的适合您的应用程序的解决方案即可。

我的第一直觉是,用于从 NTP 服务器设置机器时钟的网络时间协议 (NTP) 将已经解决了这个问题。其中解决的问题之一涉及抖动缓冲区,其中涉及数据包延迟变化RFC 3393 对此进行了详细说明; IP 性能指标的 IP 数据包延迟变化指标 (IPPM)

This is a very interesting question. Unfortunately there's no easy answer. You just have to understnad the issue well and settle for a solution that is good enough for your application.

My first instinct was that the Network Time Protocol (NTP) for setting machine clocks from NTP servers would have addressed this issue. One of the issues addressed there concerns Jitter Buffers, which involves packet delay variation. This is elaborated in RFC 3393; IP Packet Delay Variation Metric for IP Performance Metrics (IPPM).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文