准确测量机之间的运行时间 [英] Accurately measuring elapsed time between machines

查看:176
本文介绍了准确测量机之间的运行时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想衡量一个消息之间的时间间隔从一台机器发送并接收由另一个。最初,我在EC2实例的网络测量这一点。在EC2实例使用NTP同步时间。我正在发送机器的系统时间时,它发出的消息,当它接收到消息的接收设备的系统时间减去。我不能确定这种方法的准确性;有时我得到奇怪的结果,即负数。我presuming该问题是时间同步的精度。没有任何一个有一个更好的方法是在测量机之间的时间更准确?注:我不想来衡量往返时间,因为由于协议的具体细节,在什么我需要测量方面也没有用

I am trying to measure the time elapsed between a message being sent from one machine and it being received by another. Initially I am measuring this in a network of EC2 instances. The EC2 instances are time synchronised using NTP. I am taking the system time of the sending machine when it sends the message and subtracting it from the system time of the receiving machine when it receives the message. I am unsure of the accuracy of this method; sometimes I get odd results, i.e. negative numbers. I am presuming that the problem is the accuracy of the time synchronisation. Does any one have a better approach that is more accurate at measuring elapsed time between machines? Note: I do not want to measure round-trip time, as due to the specifics of the protocol that would not be useful in terms of what I need to measure.

推荐答案

正确计算的经过的时间只能通过NTP方案的装置安全地完成:

Proper calculation of the elapsed time can only be done safely by means of "ntp schemes":

为此消息必须被发送来回。这样就可以计算出一个往返延迟时间和偏移。往返延迟计算为

For this purpose messages have to be send back and forth. This way you can compute a round-trip delay time and the offset. The round-trip delay is computed as

delta = (t_3 - t_0) - (t_2- t_1)

其中

t0 is the client's timestamp of the request packet transmission,
t1 is the server's timestamp of the request packet reception,
t2 is the server's timestamp of the response packet transmission and
t3 is the client's timestamp of the response packet reception. 

因此​​

t3 − t0 is the time elapsed on the client side between the emission 
        of the request packet and the reception of the response packet and
t2 − t1 is the time the server waited before sending the answer.

偏移THETA由

The offset theta is given by

theta = ((t_1 - t_0) + (t_2 - t_3))/2

同步是正确的,当客户机和服务器之间的传入和传出路由具有对称的标称延迟。如果路线不具有一个共同的标准延迟,同步具有一半的向前和向后的传播时间之间的差的系统偏差。

The synchronization is correct when both the incoming and outgoing routes between the client and the server have symmetrical nominal delay. If the routes do not have a common nominal delay, the synchronization has a systematic bias of half the difference between the forward and backward travel times.

必须有一个双向通信,以允许同步。知道了偏移将使计算经过从一台机器正在发送的信息,并接收由另一的之间的时间。

There has to be a two way communication to allow synchronization. Knowing the offset will allow to calculate the time elapsed between a message being sent from one machine and it being received by another.

这篇关于准确测量机之间的运行时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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