用于延迟测试的客户端-服务器时间同步(套接字)

发布于 2025-01-14 12:49:04 字数 311 浏览 4 评论 0原文

我想使用 UDP 然后使用 TCP 来测量一个简单程序的延迟。我目前正在两端使用时间库中的 time.time() 并比较它们(在服务器发送之前的时间戳和在客户端接收之后的时间)。服务器将发送其时间戳,接收器将比较时间以计算延迟。 使用 127.0.0.1 环回地址时效果很好。由于在同一台机器上,时间参考是相同的。 如果我在服务器和客户端分开的实际应用程序上实现此功能,我将无法获得准确的延迟,因为两台机器之间存在时间差。

有没有办法同步时间以更好地计算延迟?

另外,当我的数据速率很高且接收后处理适中时,如何始终保持低UDP延迟?客户端的距离会影响延迟吗?

谢谢

I want to measure the latency for a simple program using UDP then TCP. I am currently using time.time() from time library at both ends and I compare them (time stamp before sending at the server and time after recieving at the client). The server would send its time stamp and the reciever will compare the time to calculate latency.
This worked fine when using 127.0.0.1 loopback address. Since its on the same machine, time reference is the same.
if I implement this on my actual application where the server and client are seperate, I can't get the accurate latency since there is a time difference between the two machine.

Is there a way to synchronize time for better latency calcultaion?

Also, how do I maintain low UDP latency all the time when I have high data rate and moderate processing fter receiving? and will the client's distance affect latency?

Thank you

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文