简体   繁体   English

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

[英]Synchronizing time between simple python-socket-based server and clients

I have the beginnings of a small multiplayer game that I'm writing in python as a learning exercise. 我有一个小型多人游戏的开头,我正在用python作为学习练习。 Currently the server runs at 10 fps, while the clients run at whatever rate they like. 目前,服务器以10 fps运行,而客户端以他们喜欢的任何速率运行。 This works well to conserve bandwidth, but unless the client tells the server when its input happened, all input gets quantized to 100ms intervals. 这样可以很好地节省带宽,但除非客户端告诉服务器输入何时发生,否则所有输入都会被量化为100ms间隔。 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. 这里的一个主要障碍是我需要确定ping时间并补偿它们。

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. 我强烈推荐它,以及几年前Fiedler提出的GDC幻灯片。 Good luck! 祝好运!

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. 你只需要understnad问题以及和解决的一个解决方案,为您的应用足够好

My first instinct was that the Network Time Protocol (NTP) for setting machine clocks from NTP servers would have addressed this issue. 我的第一直觉是,用于从NTP服务器设置机器时钟的网络时间协议(NTP)可以解决这个问题。 One of the issues addressed there concerns Jitter Buffers , which involves packet delay variation . 其中一个问题涉及抖动缓冲器 ,它涉及数据包延迟变化 This is elaborated in RFC 3393; 这在RFC 3393中详细说明; IP Packet Delay Variation Metric for IP Performance Metrics (IPPM) . IP性能指标(IPPM)的IP数据包延迟变化指标

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM