CN107360060B - Time delay measuring method and device - Google Patents

Time delay measuring method and device Download PDF

Info

Publication number
CN107360060B
CN107360060B CN201710666460.1A CN201710666460A CN107360060B CN 107360060 B CN107360060 B CN 107360060B CN 201710666460 A CN201710666460 A CN 201710666460A CN 107360060 B CN107360060 B CN 107360060B
Authority
CN
China
Prior art keywords
time
slave
virtual
virtual time
slave device
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201710666460.1A
Other languages
Chinese (zh)
Other versions
CN107360060A (en
Inventor
贺彦军
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Raisecom Technology Co Ltd
Original Assignee
Raisecom Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Raisecom Technology Co Ltd filed Critical Raisecom Technology Co Ltd
Priority to CN201710666460.1A priority Critical patent/CN107360060B/en
Publication of CN107360060A publication Critical patent/CN107360060A/en
Application granted granted Critical
Publication of CN107360060B publication Critical patent/CN107360060B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/08Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters
    • H04L43/0852Delays

Landscapes

  • Engineering & Computer Science (AREA)
  • Environmental & Geological Engineering (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Synchronisation In Digital Transmission Systems (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The invention relates to the field of network communication, in particular to a time delay measuring method and a time delay measuring device, which are used for solving the problem that the existing time delay measuring method has great limitation. The method comprises the steps that at least one virtual time is stored in a main device, and each virtual time is periodically updated; the method comprises the steps that a master device sends a measurement message to a slave device, and a first time point is determined according to virtual time corresponding to the slave device when the measurement message is sent; receiving a measurement response message returned by the slave equipment, and determining a fourth time point according to the virtual time corresponding to the slave equipment when the measurement response message is received; determining the offset of the virtual time corresponding to the slave device and the real time of the slave device according to the first time point, the second time point, the third time point and the fourth time point, and determining that the virtual time corresponding to the slave device is synchronous with the real time if the offset is not greater than a first threshold; and determines a one-way delay between the master device and the slave device.

Description

Time delay measuring method and device
Technical Field
The present invention relates to the field of network communication technologies, and in particular, to a time delay measuring method and apparatus.
Background
A Service-Level Agreement (SLA) is a real-time network performance detection and statistics technique based on application scenarios defined by Connectivity Fault Management (CFM), and detects and monitors network communication conditions by periodically sending set protocol messages so as to generate reports according to detection results. Key Performance Indicators (KPIs) of the SLA mainly include time Delay, packet Loss rate, and the like, and correspond to a Delay/jitter test (DM) and a packet Loss rate test (LM) of the SLA.
In some deployment scenarios, both the master and slave devices may initiate SLA measurements, such as measuring latency. A common protocol for measuring Delay in a two-layer network is a DMM (Delay measurement message)/DMR (Delay measurement response message) protocol. When measuring the latency between a master and a slave, a common way is to measure the one-way latency between the master and the slave, e.g. the one-way latency from the master to the slave and the one-way latency from the slave to the master. However, before measuring the one-way delay between the master device and the slave device, clock Synchronization between the master device and the slave device through ptp (precision Time Synchronization protocol)1588 protocol is required. The method of measuring one-way delay as shown in fig. 1, wherein a is a master device, B is a slave device, and is a one-way delay measurement initiated by the master device a; wherein T1 is the time when the master a sends the DMM packet, T2 is the time when the slave B receives the DMM packet, T3 is the time when the slave B sends the DMR packet, and T4 is the time when the master a receives the DMR packet; the one-way latency from master a to slave B is T2-T1 and the one-way latency from slave B to master a is T4-T3.
Since the one-way delay measurement can measure the delay in two independent directions respectively, it becomes more and more important in practical use. And typically the master needs to initiate one-way delay measurements for multiple slaves. Since the method shown in fig. 1 is used to measure the one-way delay, each slave device needs to keep clock synchronization with the master device, and thus each slave device is required to support PTP1588 protocol and maintain a clock synchronized with the master device; however, the master device is often a newly-networked high-performance head-end device, and the slave devices may be old or low-cost remote devices that do not support the PTP1588 protocol, and cannot meet the requirement of maintaining clock synchronization with the master device. When the slave device cannot keep clock synchronization with the master device, the current method cannot be used to measure the one-way delay between the master device and the slave device. Therefore, the current measurement method for measuring the time delay has great limitation.
Disclosure of Invention
The invention provides a time delay measuring method and a time delay measuring device, which are used for solving the problem that the time delay measuring method in the prior art has great limitation.
Based on the foregoing problems, an embodiment of the present invention provides a time delay measuring method, where at least one virtual time used for synchronizing with a slave device is stored in a master device, and the virtual time corresponds to the slave device to be measured one to one; the master device periodically updates each virtual time, and the method comprises the following steps:
the method comprises the steps that a master device sends a measurement message to a slave device, and a first time point representing the moment when the measurement message is sent is determined according to virtual time corresponding to the slave device when the measurement message is sent;
the master equipment receives a measurement response message returned by the slave equipment, and determines a fourth time point representing the moment when the measurement response message is received according to the virtual time corresponding to the slave equipment when the measurement response message is received; the measurement response message comprises a second time point representing the time when the slave device receives the measurement message and a third time point representing the time when the slave device sends the measurement response message;
the master device determines an offset between the virtual time corresponding to the slave device and the real time of the slave device according to the first time point, the second time point, the third time point and the fourth time point, and if the offset is not greater than a first threshold, determines that the virtual time corresponding to the slave device is synchronous with the real time of the slave device; and taking the difference value between the second time point and the first time point as the one-way time delay from the master device to the slave device, and taking the difference value between the fourth time point and the third time point as the one-way time delay from the slave device to the master device.
The virtual time corresponding to at least one slave device to be measured is stored in the master device in the embodiment of the invention, and the virtual time corresponding to each slave device is virtually synchronized with the real time; for any slave device, when the master device performs message interaction to the slave device, the master device determines time points for sending and receiving messages according to virtual time corresponding to the slave device; when calculating the one-way time delay between the master device and the slave device, the master device sends a measurement message to the slave device, determines a first time point according to the virtual time corresponding to the slave device at the moment of sending the message, and determines a fourth time point according to the virtual time corresponding to the slave device at the moment of receiving the measurement response message after receiving the measurement response message; the second time point and the third time point are determined by the slave device according to the real time of the slave device; the master device performs virtual synchronization on the virtual time corresponding to the slave device and the real time according to the first time point, the second time point and the third time point returned by the slave device, and the fourth time point; the one-way delay between the master device and the slave device is determined after synchronization. Because the method for measuring the one-way time delay of the embodiment of the invention does not need the slave equipment to keep clock synchronization with the master equipment, the method for measuring the one-way time delay of the embodiment of the invention only borrows the measurement message, and because the slave equipment in the network at least needs to support a certain standard or a private measurement protocol, the slave equipment in the network can support the response of the measurement message, and the slave equipment does not need to support a PTP1588 protocol. Therefore, the method for measuring the one-way delay in the embodiment of the invention is suitable for any slave equipment, and no matter whether the slave equipment supports the PTP1588 protocol or not, the hardware or software of the slave equipment does not need to be upgraded or changed, and the actual time of the master equipment is not influenced, so that the method for measuring the one-way delay in the embodiment of the invention has wide applicability.
Optionally, the method further includes:
and if the offset is larger than the first threshold, the master device modifies the virtual time corresponding to the slave device according to the offset, and returns to the step of sending the measurement message to the slave device by the master device.
According to the embodiment of the invention, before the unidirectional time delay between the master device and the slave device is measured, the virtual time corresponding to the slave device stored in the master device is synchronized with the real time of the slave device, so that the unidirectional time delay between the master device and the slave device is accurately measured.
Optionally, the determining, by the master device, an offset between a virtual time corresponding to the slave device and a real time of the slave device according to the first time point, the second time point, the third time point, and the fourth time point includes:
the master device determining a first difference between the second time point and the first time point and determining a second difference between the fourth time point and the third time point;
and the master device takes the quotient of the difference value of the first difference value and the second difference value and a preset parameter as the offset of the virtual time corresponding to the slave device and the real time of the slave device.
The embodiment of the invention provides the method for calculating the offset of the virtual time corresponding to the slave equipment and the real time of the slave equipment, so that the master equipment can conveniently measure the one-way time delay between the master equipment and the slave equipment after determining the synchronization between the virtual time corresponding to the slave equipment and the real time of the slave equipment according to the determined offset.
Optionally, if the master device stores virtual times corresponding to multiple slave devices, the master device combines the virtual times corresponding to the multiple slave devices into a virtual time array according to the sequence number of each slave device.
Because the embodiment of the invention stores the virtual time corresponding to a plurality of slave devices in a virtual time array mode, the occupation of resources is reduced; and when each virtual time in the virtual time array is updated, the virtual time in the virtual time array can be updated uniformly by adopting one resource, so that the consumption of storage and calculation resources is reduced, and the storage and the update of a plurality of virtual times are realized more economically.
Optionally, the periodically updating each virtual time by the master device includes:
and the master equipment updates the virtual time corresponding to each slave equipment in the virtual time array at intervals of an updating period.
Optionally, the determining, by the master device, a first time point representing a time when the measurement packet is sent according to the virtual time corresponding to the slave device when the measurement packet is sent includes:
the master device takes the virtual time corresponding to the slave device when the measurement message is sent as the first time point;
the determining, by the master device, a fourth time point representing a time when the measurement response packet is received according to the virtual time corresponding to the slave device when the measurement response packet is received, includes:
and the master device takes the virtual time corresponding to the slave device when receiving the measurement response message as the fourth time point.
Optionally, the periodically updating each virtual time by the master device includes:
in an updating period, the master device updates the virtual time corresponding to one slave device in the virtual time array at fixed time intervals according to the sequence number sequence of each slave device; wherein the fixed duration is a quotient of the update period and the number of virtual times included in the virtual time array.
Because the master device stores the virtual time corresponding to the plurality of slave devices in the embodiment of the invention, when the number of the stored slave devices is large, the master device is difficult to update the virtual time corresponding to the plurality of slave devices in one clock cycle. The embodiment of the invention polls and updates the virtual time corresponding to each slave device in an updating period, thereby enabling the master device to update the virtual time corresponding to a large number of slave devices more easily.
Optionally, the determining, by the master device, a first time point representing a time when the measurement packet is sent according to the virtual time corresponding to the slave device when the measurement packet is sent includes:
the master device determines the deviation of the virtual time corresponding to the slave device when sending the measurement message according to the serial number of the slave device corresponding to the current or latest updated virtual time, the serial number of the slave device needing to receive the measurement message and the fixed time length;
and the master device takes the sum of the virtual time corresponding to the slave device when the measurement message is sent and the deviation as the first time point.
Optionally, the determining, by the master device, a deviation of the virtual time corresponding to the slave device when the measurement packet is sent according to the serial number of the slave device corresponding to the current or latest updated virtual time, the serial number of the slave device that needs to receive the measurement packet, and the fixed time length by the master device includes:
if the serial number of the slave equipment corresponding to the current or latest updated virtual time is not less than the serial number of the slave equipment needing to receive the measurement message, the master equipment takes the product of the difference value between the serial number of the slave equipment corresponding to the current or latest updated virtual time and the serial number of the slave equipment needing to receive the measurement message and the fixed time length as the deviation of the virtual time corresponding to the slave equipment when the measurement message is sent;
if the serial number of the slave equipment corresponding to the current or latest updated virtual time is smaller than the serial number of the slave equipment needing to receive the measurement message, the master equipment determines the sum of the serial number of the slave equipment corresponding to the current or latest updated virtual time and the number of the slave equipment in the virtual time array; and taking the product of the difference value between the sum value and the serial number of the slave equipment which needs to receive the measurement message and the fixed time length as the deviation of the virtual time corresponding to the slave equipment when the measurement message is sent.
When the first time point is determined, according to the serial number of the slave equipment corresponding to the current or latest updated virtual time, the serial number of the slave equipment needing to receive the measurement message and the fixed time length, the virtual time corresponding to the slave equipment when the measurement message is sent is corrected, and the corrected time is taken as the first time point; therefore, the accuracy of calculating the virtual time and real time offset corresponding to the slave device is improved.
Optionally, the determining, by the master device, a fourth time point representing a time when the measurement response packet is received according to the virtual time corresponding to the slave device when the measurement response packet is received, includes:
the master device determines the deviation of the virtual time corresponding to the slave device when receiving the measurement response message according to the serial number of the slave device corresponding to the current or latest updated virtual time, the serial number of the slave device sending the measurement response message and the fixed time length;
and the master device takes the sum of the virtual time corresponding to the slave device when the measurement response message is received and the deviation as the fourth time point.
Optionally, the determining, by the master device, a deviation of the virtual time corresponding to the slave device when the measurement response packet is received according to the serial number of the slave device corresponding to the current or latest updated virtual time, the serial number of the slave device sending the measurement response packet, and the fixed time length by the master device includes:
if the serial number of the slave device corresponding to the current or latest updated virtual time is not less than the serial number of the slave device sending the measurement response message, the master device takes the product of the difference value between the serial number of the slave device corresponding to the current or latest updated virtual time and the serial number of the slave device sending the measurement response message and the fixed time length as the deviation of the virtual time corresponding to the slave device when the measurement response message is received;
if the serial number of the slave equipment corresponding to the current or latest updated virtual time is smaller than the serial number of the slave equipment sending the measurement response message, the master equipment determines the sum of the serial number of the slave equipment corresponding to the current or latest updated virtual time and the number of the slave equipment in the virtual time array; and taking the product of the difference value between the sum value and the serial number of the slave equipment sending the measurement response message and the fixed time length as the deviation of the virtual time corresponding to the slave equipment when the measurement response message is received.
When the fourth time point is determined, according to the serial number of the slave device corresponding to the current or latest updated virtual time, the serial number of the slave device sending the measurement response message and the fixed time length, the virtual time corresponding to the slave device when the measurement response message is received is corrected, and the corrected time is used as the fourth time point; therefore, the accuracy of calculating the virtual time and real time offset corresponding to the slave device is improved.
On the other hand, the embodiment of the invention also provides a time delay measuring device, which comprises a virtual time module, a message transceiving module, a timestamp sampling module, a synchronous calculation filtering module and an index calculation module; the virtual time module stores at least one virtual time for synchronizing with the slave equipment, and the virtual time corresponds to the slave equipment needing to be measured one by one; the virtual time module is used for periodically updating each virtual time;
the message receiving and sending module sends a measurement message to the slave equipment; the timestamp sampling module is used for determining a first time point representing the time for sending the measurement message according to the virtual time corresponding to the slave equipment when the measurement message is sent;
the message receiving and sending module is further used for receiving a measurement response message returned by the slave device; the timestamp sampling module is further configured to determine a fourth time point representing a time when the measurement response packet is received according to virtual time corresponding to the slave device when the measurement response packet is received; the measurement response message comprises a second time point representing the time when the slave device receives the measurement message and a third time point representing the time when the slave device sends the measurement response message;
the synchronization calculation filtering module is configured to determine, according to the first time point, the second time point, the third time point, and the fourth time point, an offset between a virtual time corresponding to the slave device and a real time of the slave device, and if the offset is not greater than a first threshold, determine that the virtual time corresponding to the slave device is synchronized with the real time of the slave device; the index calculation module is configured to use a difference between the second time point and the first time point as a one-way delay from the master device to the slave device, and use a difference between the fourth time point and the third time point as a one-way delay from the slave device to the master device.
Optionally, the synchronous computation filtering module is further configured to:
and if the offset is larger than the first threshold, modifying the virtual time corresponding to the slave equipment according to the offset, and returning to the step of sending the measurement message to the slave equipment by the master equipment.
Optionally, the synchronous calculation filtering module is specifically configured to:
determining a first difference between the second time point and the first time point, and determining a second difference between the fourth time point and the third time point; and taking the quotient of the difference value of the first difference value and the second difference value and a preset parameter as the offset of the virtual time corresponding to the slave equipment and the real time of the slave equipment.
Optionally, if the virtual time module stores virtual times corresponding to a plurality of slave devices, the synchronous calculation filtering module is further configured to:
and forming a virtual time array by the virtual times corresponding to the plurality of slave devices according to the sequence number of each slave device.
Optionally, the synchronous calculation filtering module is specifically configured to:
and updating the virtual time corresponding to each slave device in the virtual time array at the same time at intervals of the updating period.
Optionally, the timestamp sampling module is specifically configured to:
taking the virtual time corresponding to the slave device when the measurement message is sent as the first time point;
the timestamp sampling module is specifically configured to:
and taking the virtual time corresponding to the slave device when the measurement response message is received as the fourth time point.
Optionally, the synchronous calculation filtering module is specifically configured to:
in an updating period, updating the virtual time corresponding to one slave device in the virtual time array at fixed time intervals according to the sequence number sequence of each slave device; wherein the fixed duration is a quotient of the update period and the number of virtual times included in the virtual time array.
Optionally, the timestamp sampling module is specifically configured to:
determining the deviation of the virtual time corresponding to the slave equipment when the measurement message is sent according to the serial number of the slave equipment corresponding to the current or latest updated virtual time, the serial number of the slave equipment needing to receive the measurement message and the fixed time length; and taking the sum of the virtual time corresponding to the slave equipment and the deviation when the measurement message is sent as the first time point.
Optionally, the timestamp sampling module is specifically configured to:
if the serial number of the slave equipment corresponding to the current or latest updated virtual time is not less than the serial number of the slave equipment needing to receive the measurement message, taking the product of the difference value between the serial number of the slave equipment corresponding to the current or latest updated virtual time and the serial number of the slave equipment needing to receive the measurement message and the fixed time length as the deviation of the virtual time corresponding to the slave equipment when the measurement message is sent;
if the serial number of the slave equipment corresponding to the current or latest updated virtual time is smaller than the serial number of the slave equipment needing to receive the measurement message, determining the sum of the serial number of the slave equipment corresponding to the current or latest updated virtual time and the number of the slave equipment in the virtual time array; and taking the product of the difference value between the sum value and the serial number of the slave equipment which needs to receive the measurement message and the fixed time length as the deviation of the virtual time corresponding to the slave equipment when the measurement message is sent.
Optionally, the timestamp sampling module is specifically configured to:
determining the deviation of the virtual time corresponding to the slave equipment when the measurement response message is received according to the serial number of the slave equipment corresponding to the current or latest updated virtual time, the serial number of the slave equipment sending the measurement response message and the fixed time length; and taking the sum of the virtual time corresponding to the slave equipment when the measurement response message is received and the deviation as the fourth time point.
Optionally, the timestamp sampling module is specifically configured to:
if the serial number of the slave equipment corresponding to the current or latest updated virtual time is not less than the serial number of the slave equipment sending the measurement response message, taking the product of the difference value between the serial number of the slave equipment corresponding to the current or latest updated virtual time and the serial number of the slave equipment sending the measurement response message and the fixed time length as the deviation of the virtual time corresponding to the slave equipment when the measurement response message is received;
if the serial number of the slave equipment corresponding to the current or latest updated virtual time is smaller than the serial number of the slave equipment sending the measurement response message, determining the sum of the serial number of the slave equipment corresponding to the current or latest updated virtual time and the number of the slave equipment in the virtual time array; and taking the product of the difference value between the sum value and the serial number of the slave equipment sending the measurement response message and the fixed time length as the deviation of the virtual time corresponding to the slave equipment when the measurement response message is received.
Drawings
FIG. 1 is a diagram illustrating a method for measuring one-way delay in the prior art;
fig. 2 is a schematic structural diagram of a delay measurement system according to an embodiment of the present invention;
fig. 3 is a schematic diagram illustrating virtual time corresponding to a slave device stored in a master device according to an embodiment of the present invention;
FIG. 4 is a diagram of an RTC according to an embodiment of the present invention;
FIG. 5 is a diagram illustrating a first virtual time array according to an embodiment of the present invention;
FIG. 6 is a first schematic diagram illustrating a method for updating virtual time in a virtual time array according to an embodiment of the present invention;
FIG. 7A is a diagram illustrating a second virtual time array according to an embodiment of the present invention;
FIG. 7B is a diagram illustrating a third virtual time array according to an embodiment of the present invention;
FIG. 8 is a second schematic diagram illustrating a method for updating virtual time in a virtual time array according to an embodiment of the present invention;
fig. 9 is an overall flowchart of synchronizing virtual time and real time corresponding to a slave device according to an embodiment of the present invention;
FIG. 10 is a flowchart illustrating a method for measuring delay according to an embodiment of the present invention;
fig. 11 is a schematic structural diagram of a first delay measuring device according to an embodiment of the present invention;
fig. 12 is a schematic structural diagram of a second delay measuring device according to an embodiment of the present invention;
fig. 13 is a flowchart of a delay measurement method according to an embodiment of the present invention.
Detailed Description
The method comprises the steps that at least one virtual time used for synchronizing with slave equipment is stored in the master equipment, and the virtual time corresponds to the slave equipment needing to be measured one by one; the master device periodically updates each virtual time; the method comprises the steps that a master device sends a measurement message to a slave device, and a first time point representing the moment when the measurement message is sent is determined according to virtual time corresponding to the slave device when the measurement message is sent; the master equipment receives a measurement response message returned by the slave equipment, and determines a fourth time point representing the moment when the measurement response message is received according to the virtual time corresponding to the slave equipment when the measurement response message is received; the measurement response message comprises a second time point representing the time when the slave device receives the measurement message and a third time point representing the time when the slave device sends the measurement response message; the master device determines an offset between the virtual time corresponding to the slave device and the real time of the slave device according to the first time point, the second time point, the third time point and the fourth time point, and if the offset is not greater than a first threshold, determines that the virtual time corresponding to the slave device is synchronous with the real time of the slave device; and taking the difference value between the second time point and the first time point as the one-way time delay from the master device to the slave device, and taking the difference value between the fourth time point and the third time point as the one-way time delay from the slave device to the master device.
The virtual time corresponding to at least one slave device to be measured is stored in the master device in the embodiment of the invention, and the virtual time corresponding to each slave device is virtually synchronized with the real time; for any slave device, when the master device performs message interaction to the slave device, the master device determines time points for sending and receiving messages according to virtual time corresponding to the slave device; when calculating the one-way time delay between the master device and the slave device, the master device sends a measurement message to the slave device, determines a first time point according to the virtual time corresponding to the slave device at the moment of sending the message, and determines a fourth time point according to the virtual time corresponding to the slave device at the moment of receiving the measurement response message after receiving the measurement response message; the second time point and the third time point are determined by the slave device according to the real time of the slave device; the master device performs virtual synchronization on the virtual time corresponding to the slave device and the real time according to the first time point, the second time point and the third time point returned by the slave device, and the fourth time point; the one-way delay between the master device and the slave device is determined after synchronization. Because the method for measuring the one-way time delay of the embodiment of the invention does not need the slave equipment to keep clock synchronization with the master equipment, the method for measuring the one-way time delay of the embodiment of the invention only borrows the measurement message, and because the slave equipment in the network at least needs to support a certain standard or a private measurement protocol, the slave equipment in the network can support the response of the measurement message, and the slave equipment does not need to support a PTP1588 protocol. Therefore, the method for measuring the one-way delay in the embodiment of the invention is suitable for any slave equipment, and no matter whether the slave equipment supports the PTP1588 protocol or not, the hardware or software of the slave equipment does not need to be upgraded or changed, and the actual time of the master equipment is not influenced, so that the method for measuring the one-way delay in the embodiment of the invention has wide applicability.
In order to make the objects, technical solutions and advantages of the present invention clearer, the present invention will be described in further detail with reference to the accompanying drawings, and it is apparent that the described embodiments are only a part of the embodiments of the present invention, not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
As shown in fig. 2, a latency measurement system according to an embodiment of the present invention includes a master device 10 and at least one slave device 20.
The master device 10 stores the virtual time corresponding to the slave device 20, periodically updates the virtual time corresponding to each slave device 20, and the virtual time corresponding to the slave device 20 after the update is the sum of the virtual time corresponding to the slave device 20 before the update and the update period.
The master device 10 is configured to send a measurement packet to a slave device, and determine a first time point representing a time when the measurement packet is sent according to a virtual time corresponding to the slave device when the measurement packet is sent; receiving a measurement response message returned by the slave equipment, and determining a fourth time point representing the moment when the measurement response message is received according to the virtual time corresponding to the slave equipment when the measurement response message is received;
the slave device 20 is configured to add, after receiving the measurement packet, a second time point indicating a time when the slave device receives the measurement packet, and add, after needing to return a measurement response packet, a third time point indicating a time when the slave device sends the measurement response packet, to the measurement response packet, and send the measurement response packet to the master device;
the master device 10 is further configured to determine, according to the first time point, the second time point, the third time point, and the fourth time point, an offset between the virtual time corresponding to the slave device and the real time of the slave device, and if the offset is not greater than a first threshold, determine that the virtual time corresponding to the slave device is synchronized with the real time of the slave device; and taking the difference value between the second time point and the first time point as the one-way time delay from the master device to the slave device, and taking the difference value between the fourth time point and the third time point as the one-way time delay from the slave device to the master device.
The first threshold is an empirical value, or a preset value in the embodiment of the present invention.
With reference to the embodiment of the present invention, optionally, the first threshold is 10 ns.
In an embodiment of the present invention, the master device may be configured to measure a one-way delay with at least one slave device. Virtual time corresponding to at least one slave device is stored in the master device; the manner of storing the virtual Time corresponding to the slave device in the master device is similar to storing the virtual RTC (Real Time Clock) of at least one slave device in the master device. But the virtual RTC of the slave does not affect the real RTC of the master.
For example, as shown in fig. 3, the virtual RTCs of N slave devices are stored in the master device a. Wherein, RTC real represents the real RTC of the master device A; RTC virtual represents the virtual RTC of each slave device, for example, RTC virtual-1 is the virtual time of slave device B-1, RTC virtual-2 is the virtual time … … RTC virtual-N of slave device B-2 is the virtual time of slave device B-N.
The virtual time corresponding to each slave device has a share of physical resources in the master device, and is used for synchronizing the virtual time corresponding to the slave device with the real time of the slave device, so as to measure the one-way time delay between the master device and the slave device. Typically, an RTC comprises three segments: seconds s, nanoseconds ns and sub-nanoseconds sub-ns, as shown in fig. 4.
In the embodiment of the present invention, the virtual time corresponding to each slave device stored in the master device is periodically and continuously changed, and when the virtual time corresponding to the slave device is initially stored in the master device, the real time of the master device is used as the initial value of the virtual time corresponding to the slave device.
When the master device needs to measure the virtual time corresponding to the plurality of slave devices, the following two ways may be used for storing the virtual time corresponding to the plurality of slave devices.
Mode 1, virtual time corresponding to a plurality of slave devices is independently stored;
namely, the virtual time corresponding to each slave device occupies one resource and is updated independently.
The resources occupied by the virtual time comprise: storage resources (for storing virtual time) and computing resources (for updating virtual time).
Illustratively, the storage structures of the virtual times are the same, and the computing resources are the same. Therefore, the method and the device have the advantages that the number of the virtual time is correspondingly consumed, and the method and the device are suitable for the condition that the number of the virtual time is small.
And 2, the master device makes the virtual time corresponding to the plurality of slave devices form a virtual time array according to the sequence of each slave device.
Optionally, the master device collectively and uniformly stores the virtual time arrays in a Random Access Memory (RAM).
In addition, when each virtual time in the virtual time array is updated, the virtual time in the virtual time array is updated uniformly by using one resource, so that the consumption of storage and calculation resources is reduced, and the storage and the update of a plurality of virtual times are realized more economically.
For example, a virtual time array as shown in fig. 5. The RTC virtual-1 is the virtual time of the slave device B-1, and the RTC virtual-2 is the virtual time … … RTC virtual-N of the slave device B-2 is the virtual time of the slave device B-N.
Since the time itself is dynamically changed, the master device needs to dynamically update the virtual time corresponding to each slave device according to a preset period (preset time precision), so that the virtual time can accurately track the time change of the slave device.
The master device in the embodiment of the present invention periodically updates the virtual time corresponding to each slave device in the following different manners, which are described below.
Firstly, the master device updates the virtual time corresponding to each slave device in the virtual time array at the same time every interval of an update cycle.
For example, when the clock frequency is 125MHz, the clock cycle is 8 nanoseconds, and when the master device updates the virtual time corresponding to each slave device, the determined update cycle is 8 nanoseconds; that is, every other updating period, the master device accumulates the virtual time corresponding to each slave device for 8 nanoseconds.
In a real PTP1588 implementation, the clock used to drive the actual RTC has a high frequency, e.g. m Hz. When the number of slave devices which need to perform the one-way delay measurement in real time is small, that is, the number of virtual times stored in the master device is small, the virtual times can be updated within one clock cycle at the clock frequency of m Hz.
Correspondingly, when the virtual time corresponding to each slave device is updated in the first mode, the master device determines a first time point according to the following modes:
optionally, the master device takes a virtual time corresponding to the slave device when sending the measurement packet as the first time point;
and, the master device determines the fourth time point according to the following:
and the master device takes the virtual time corresponding to the slave device when receiving the measurement response message as the fourth time point.
In an updating period, the master device updates the virtual time corresponding to one slave device in the virtual time array at fixed time intervals according to the sequence number sequence of each slave device; wherein the fixed duration is a quotient of the update period and the number of virtual times included in the virtual time array.
Optionally, the fixed time period is an empirical value or a preset value.
In the second mode, the master device updates the virtual time corresponding to each slave device in the virtual array in sequence, and the virtual time corresponding to each slave device is updated at equal time intervals. That is, the master device updates the virtual time corresponding to each slave device in turn in a polling manner.
Assuming that the master device needs to measure the one-way delay with 1000 slave devices, a virtual time array composed of virtual times corresponding to the 1000 slave devices needs to be stored in the master device. For uniformly stored virtual time arrays, it is not possible to complete the update process for up to 1000 rtcvirtuals in one clock cycle at a high clock frequency of m Hz. Therefore, the embodiment of the invention adopts the extremely low speed frequency to update the virtual time in the virtual time array, for example, each virtual time is updated every n Hz, and the virtual time is added with 1/n second on the basis of the original value. Here, when n is 125KHz, it is 8000 ns update, and 8000 ns are accumulated each time. And polling the virtual time array by using a high-speed clock m Hz, namely updating two adjacent virtual times in the virtual time array every 1/m second, so as to ensure that every virtual time in every n Hz can be updated once, as shown in FIG. 6.
In the embodiment shown in fig. 6, the update cycle (time precision) of each virtual time in the virtual time array is: 1/n. For example, when n is 125KHz, the virtual time corresponding to each slave device is updated every 8000 ns, and the virtual time precision is 8000 ns. When the polled high-speed clock m is 125MHz, the interval between every two adjacent virtual time updates is 8 ns, so that each virtual time in the virtual time array is updated once within 8000 ns. Here m and n should satisfy the following relationship: m equals the number of virtual times multiplied by n, e.g. 125MHz equals 1000 times 125 KHz.
Whether a second updating mode is adopted or not is generally related to the realization of the main equipment and the cost requirement, and when the number of the recommended virtual time is more than 10, the virtual time array is adopted for unified storage and unified updating, so that the resources are saved, and the cost is reduced.
When the second updating mode is adopted, the updating period of the virtual time corresponding to each slave device is 1/n, for example, when n is 125KHz, the virtual time corresponding to the slave device is updated once every 8000 nanoseconds, and the virtual time precision is 8000 nanoseconds. If the virtual time is directly used for time stamp sampling of a measurement message in the virtual synchronization process with the master device, the precision loss of the time stamp is too large, and the Offset precision calculated by the upper layer software according to the time stamp precision of 8000 nanoseconds, namely 8 microseconds, can reach 8us, so that the master device cannot accurately track the time of the slave device.
Optionally, the master device determines the first time point according to the following manner:
the master device determines the deviation of the virtual time corresponding to the slave device when sending the measurement message according to the serial number of the slave device corresponding to the current or latest updated virtual time, the serial number of the slave device needing to receive the measurement message and the fixed time length; and the master device takes the sum of the virtual time corresponding to the slave device when the measurement message is sent and the deviation as the first time point.
In the second updating mode, the master device polls and updates the virtual time corresponding to each slave device. In one update cycle, if a measurement packet is sent to the slave device after the slave device is updated for a period of time, a large error is generated if the stored virtual time corresponding to the slave device is continuously used, so that the virtual time corresponding to the slave device at the time of sending the measurement packet needs to be corrected.
The master device of the embodiment of the invention determines the deviation of the virtual time corresponding to the slave device when sending the measurement message according to the following modes:
1. and if the serial number of the slave equipment corresponding to the current or latest updated virtual time is not less than the serial number of the slave equipment needing to receive the measurement message, taking the product of the difference value between the serial number of the slave equipment corresponding to the current or latest updated virtual time and the serial number of the slave equipment needing to receive the measurement message and the fixed time length as the deviation of the virtual time corresponding to the slave equipment when the measurement message is sent.
That is, when the serial number of the slave device corresponding to the current or latest updated virtual time is not less than the serial number of the slave device that needs to receive the measurement packet, the following formula is adopted to calculate the deviation of the virtual time corresponding to the slave device:
ΔT=(m-n)*t;
wherein, Δ T is a deviation of a virtual time corresponding to the slave device; m is the serial number of the slave equipment corresponding to the current or latest updated virtual time; n is the serial number of the slave equipment which needs to receive the measurement message; t is a preset fixed time length.
For example, a virtual time array as shown in fig. 7A. The master device stores a virtual time array consisting of 1000 virtual times corresponding to the slave devices; RTC virtual-1 is the virtual time of slave device 1, and RTC virtual-2 is the virtual time … … RTC virtual-N of slave device 2, which is the virtual time of slave device N. Assume that the virtual time of slave device 5 is currently being updated; if the master device needs to send a measurement message to the slave device 2, and the master device updates the virtual time corresponding to one slave device every a fixed time length of 8 ns, the determined deviation of the virtual time of the slave device 2 when the measurement message is sent is (5-2) × 8 ns-24 ns. When the virtual time corresponding to the slave device at the time of sending the measurement message is corrected, 24 nanoseconds are added to the virtual time of the slave device 2 at the time of sending the measurement message as a first time point.
2. If the serial number of the slave equipment corresponding to the current or latest updated virtual time is smaller than the serial number of the slave equipment needing to receive the measurement message, determining the sum of the serial number of the slave equipment corresponding to the current or latest updated virtual time and the number of the slave equipment in the virtual time array; and taking the product of the difference value between the sum value and the serial number of the slave equipment which needs to receive the measurement message and the fixed time length as the deviation of the virtual time corresponding to the slave equipment when the measurement message is sent.
That is, when the serial number of the slave device corresponding to the current or latest updated virtual time is smaller than the serial number of the slave device that needs to receive the measurement packet, the following formula is adopted to calculate the deviation of the virtual time corresponding to the slave device:
ΔT=(X+m-n)*t;
wherein, Δ T is a deviation of a virtual time corresponding to the slave device; x is the number of slave devices in the virtual time array; m is the serial number of the slave equipment corresponding to the current or latest updated virtual time; n is the serial number of the slave equipment which needs to receive the measurement message; t is a preset fixed time length.
For example, a virtual time array as shown in fig. 7B. The master device stores a virtual time array consisting of 1000 virtual times corresponding to the slave devices; RTC virtual-1 is the virtual time of slave device 1, and RTC virtual-2 is the virtual time … … RTC virtual-N of slave device 2, which is the virtual time of slave device N. Assume that the virtual time of slave device 5 is currently being updated; if the master device needs to send a measurement message to the slave device 10, and the master device updates the virtual time corresponding to one slave device every 8 ns at a fixed time interval, the determined deviation of the virtual time of the slave device 10 when sending the measurement message is (5-10+1000) × 8 ns ═ 7960 ns. The virtual time corresponding to the slave device at the time of sending the measurement packet is modified, and 7960 nanoseconds are added to the virtual time of the slave device 10 at the time of sending the measurement packet as the first time point.
Optionally, the master device determines the serial number of the slave device corresponding to the current or latest updated virtual time in a counter manner.
Specifically, a high-speed clock counter is maintained inside the master device, and the counting period of the counter is a fixed duration in the second virtual time updating manner. For example, if the master device updates the virtual time corresponding to one slave device every time interval t1, the counting period of the counter is t1, that is, one count is counted every time interval t 1.
For example, if 1000 virtual times exist in the current virtual time array, sampling is performed by adopting a 125MHz high-speed clock, each virtual time is updated once at 8000 nanoseconds, and the updating precision is 8000 nanoseconds; and updates a virtual time every 8 nanoseconds. The master device internally maintains a 125MHz high-speed clock counter, which is a loop counter that counts from 1 to 1000(1000 is the virtual time number), that is, starts to count again from 1 after counting to 1000. The counter is 8 ns every time it is incremented and cycles exactly 8000 ns.
As shown in fig. 8, the cycle counter and the virtual time update are synchronized, i.e. the counter counts to 5, the master is currently updating the virtual time of the slave 5. When the current master device needs to send a measurement packet to the slave device 2, the virtual time offset of the slave device 2 is as follows: (5-2) × 8 ns ═ 24 ns. The virtual time of the slave device 2 at the time of sending the measurement packet is corrected, and 24 nanoseconds are added to the virtual time of the slave device 2 at the time of sending the measurement packet as a first time point.
The master device determines the fourth time point according to the following manner:
the master device determines the deviation of the virtual time corresponding to the slave device when receiving the measurement response message according to the serial number of the slave device corresponding to the current or latest updated virtual time, the serial number of the slave device sending the measurement response message and the fixed time length; and the master device takes the sum of the virtual time corresponding to the slave device when the measurement response message is received and the deviation as the fourth time point.
In the second updating mode, the master device polls and updates the virtual time corresponding to each slave device. In an update cycle, if a measurement response message sent by a slave device is received within a period of time after the slave device is updated, a large error is generated if the stored virtual time corresponding to the slave device is continuously used, so that the virtual time corresponding to the slave device at the time when the measurement response message is received needs to be corrected.
The master device of the embodiment of the present invention determines the deviation of the virtual time corresponding to the slave device when receiving the measurement response packet according to the following manner:
1. if the serial number of the slave equipment corresponding to the current or latest updated virtual time is not less than the serial number of the slave equipment sending the measurement response message, taking the product of the difference value between the serial number of the slave equipment corresponding to the current or latest updated virtual time and the serial number of the slave equipment sending the measurement response message and the fixed time length as the deviation of the virtual time corresponding to the slave equipment when the measurement response message is received;
2. if the serial number of the slave equipment corresponding to the current or latest updated virtual time is smaller than the serial number of the slave equipment sending the measurement response message, determining the sum of the serial number of the slave equipment corresponding to the current or latest updated virtual time and the number of the slave equipment in the virtual time array; and taking the product of the difference value between the sum value and the serial number of the slave equipment sending the measurement response message and the fixed time length as the deviation of the virtual time corresponding to the slave equipment when the measurement response message is received.
It should be noted that, in the time delay measurement method according to the embodiment of the present invention, before determining the one-way time delay between the master device and the slave device according to the first time point, the second time point, the third time point, and the fourth time point, it is necessary to ensure that the virtual time corresponding to the slave device stored in the master device is synchronized with the formal time of the slave device.
Specifically, the following method may be adopted to determine whether the virtual time corresponding to the slave device stored in the master device is synchronized with the real time of the slave device:
1. and the master device determines the offset between the virtual time corresponding to the slave device and the real time of the slave device according to the first time point, the second time point, the third time point and the fourth time point, and if the offset is not greater than a first threshold, determines that the virtual time corresponding to the slave device stored in the device is synchronous with the real time of the slave device.
2. And the master device determines the offset between the virtual time corresponding to the slave device and the real time of the slave device according to the first time point, the second time point, the third time point and the fourth time point, and if the offset is not greater than a first threshold and the determined offset for the Nth time which is continuous is not greater than the first threshold, determines that the virtual time corresponding to the slave device stored in the device is synchronous with the real time of the slave device.
Optionally, in the embodiment of the present invention, the master device determines an offset between a virtual time corresponding to the slave device and a real time of the slave device according to the following manner:
the master device determining a first difference between the second time point and the first time point and determining a second difference between the fourth time point and the third time point; the master device takes the quotient of the difference value of the first difference value and the second difference value and a preset parameter as the offset of the virtual time corresponding to the slave device and the real time of the slave device;
optionally, the preset parameter is 2.
Specifically, the master device may calculate an offset between a virtual time corresponding to the slave device and a real time of the slave device by using the following formula:
offset is [ (T2-T1) - (T4-T3) ]/2 — formula one;
offset is the Offset of the virtual time corresponding to the slave device and the real time of the slave device; t1 is the first time point, T2 is the second time point, T3 is the third time point, and T4 is the fourth time point.
It should be noted that the above formula for calculating the offset between the virtual time corresponding to the slave device and the real time of the slave device is only an example for calculating the offset, and the manner for determining the offset between the virtual time corresponding to the slave device and the real time of the slave device, which is intended to be protected by the embodiment of the present invention, is not limited to the above example, and any manner capable of determining the offset between the virtual time corresponding to the slave device and the real time of the slave device is applicable to the present invention.
Before calculating the one-way time delay between the master device and the slave device, it is necessary to ensure that the virtual time corresponding to the slave device is synchronized with the real time.
The following describes in detail a process of synchronizing a virtual time corresponding to a slave device with a real time according to an embodiment of the present invention with reference to fig. 9.
As shown in fig. 9, an overall flowchart for synchronizing a virtual time corresponding to a slave device with a real time according to an embodiment of the present invention is shown.
The master device stores the initial value of the virtual time corresponding to the slave device as the real time of the slave device.
For example, when the virtual time of the slave B is stored in the master, the time of the master is t0, and t0 is set as the initial value of the virtual time of the slave B.
The following describes a process of synchronizing a virtual time corresponding to a slave device with a real time after the master device stores an initial virtual time of the slave device.
Step 901, a master device sends a measurement message to a slave device, and determines a first time point representing a time when the measurement message is sent according to a virtual time corresponding to the slave device when the measurement message is sent;
the master device may add the determined first time point to the measurement message; or locally recording the determined first point in time.
Step 902, the master device receives a measurement response packet returned by the slave device, and determines a fourth time point representing a time when the measurement response packet is received according to a virtual time corresponding to the slave device when the measurement response packet is received;
the measurement response message further includes a second time point indicating a time when the slave device receives the measurement message and a third time point indicating a time when the slave device transmits the measurement response message.
The master device may add the determined fourth time point to the measurement response message; or locally recording the determined fourth time point;
if the master device adopts a mode of adding the determined fourth time point into the measurement response message, specifically, the message transceiver module of the master device receives the measurement response message returned by the slave device, the timestamp sampling module of the master device determines the fourth time point according to the virtual time corresponding to the slave device when receiving the measurement response message, adds the fourth time point into the measurement response message, and sends the updated measurement response message to the message generation termination module.
Step 903, the master device determines, according to the first time point, the second time point, the third time point, and the fourth time point, an offset between a virtual time corresponding to the slave device and a real time of the slave device;
specifically, the offset of the virtual time corresponding to the slave device from the real time may be calculated in a manner shown in formula one.
Step 904, the master device determines whether the offset is not greater than a first threshold, if not, step 905 is executed; if yes, go to step 906;
optionally, the determination condition in this step may be that the primary device determines whether the determined offset is not greater than the first threshold for N consecutive times.
Step 905, the master device modifies the virtual time corresponding to the slave device according to the offset, and returns to step 901;
if the offset between the virtual time corresponding to the slave equipment and the real time is calculated in a formula one manner, taking the difference value between the virtual time corresponding to the slave equipment before modification and the offset as the virtual time corresponding to the modified slave equipment;
for example, if the calculated Offset amount is Offset and the virtual time corresponding to the slave device before modification is t1, the virtual time corresponding to the slave device after modification is t 1-Offset.
Step 906, the master device determines that the virtual time corresponding to the slave device is synchronized with the real time of the slave device.
Optionally, after determining that the virtual time corresponding to the slave device is synchronized with the real time, the master device uses a difference between a second time point in the measurement response message received last time and a first time point determined last time as a one-way time delay from the master device to the slave device, and uses a difference between a fourth time point determined last time and a third time point in the measurement response message received last time as a one-way time delay from the slave device to the master device.
For example, in the process of synchronizing the virtual time corresponding to the slave device with the real time, if five measurement messages are sent to the slave device by the master device, and after the fifth measurement message is sent, according to a first time point determined by the virtual time corresponding to the slave device when the fifth measurement message is sent and a second time point in a fifth measurement response message returned by the slave device, a difference value between the second time point and the first time point is used as the one-way delay from the master device to the slave device. And taking the difference value between the fourth time point and the third time point as the one-way time delay from the slave equipment to the master equipment according to the fourth time point determined by the virtual time corresponding to the slave equipment when the fifth measurement response message is received and the third time point in the fifth measurement response message returned by the slave equipment.
The master equipment in the embodiment of the invention interacts with each slave equipment by using the measurement message, and the slave equipment responds to the measurement message, thereby obtaining a first time point, a second time point, a third time point and a fourth time point; and the master device synchronizes the virtual time corresponding to the slave device with the real time according to the obtained first time point, the second time point, the third time point and the fourth time point, and calculates the one-way time delay between the master device and the slave device after synchronization.
The measurement packet of the embodiment of the present invention may be a packet for Time synchronization, such as a DMM/DMR packet, a packet based on NTP (Network Time Protocol), and a packet based on TWAMP (Two-Way active measurement Protocol).
It should be noted that the type of the measurement packet in the above embodiment of the present invention is only an example of the embodiment of the present invention, and the type of the measurement packet that the embodiment of the present invention intends to protect is not limited to the above example, and any measurement packet that enables the master device to determine the first time point, the second time point, the third time point, and the fourth time point by performing packet interaction with the slave device is applicable to the present invention.
The following describes the delay measurement method according to the embodiment of the present invention, taking the measurement packet as a DMM packet and the measurement response packet as a DMR packet, as shown in fig. 10.
Step 1001, a master device sends a DMM message to a slave device, and adds a first timestamp in the DMM message according to virtual time corresponding to the slave device when sending the DMM message;
specifically, the virtual time corresponding to the slave device when the DMM packet is sent is used as the first timestamp.
Step 1002, the master device receives a DMR message returned by the slave device, and adds a fourth timestamp to the DMR message according to a virtual time corresponding to the slave device when receiving the DMR message; the DMR message further includes a second timestamp indicating a time when the slave device receives the DMR message and a third timestamp indicating a time when the slave device transmits the DMR message.
Step 1003, the master device determines an offset between a virtual time corresponding to the slave device and a real time of the slave device according to the first time stamp, the second time stamp, the third time stamp and the fourth time stamp;
specifically, the offset of the virtual time corresponding to the slave device from the real time may be calculated in a manner shown in formula one.
Step 1004, the master device determines whether the offset is not greater than a first threshold, if not, step 1005 is executed; if yes, go to step 1006;
optionally, the determination condition in this step may be that the primary device determines whether the determined offset is not greater than the first threshold for N consecutive times.
Step 1005, the master device modifies the virtual time corresponding to the slave device according to the offset, and returns to step 1001.
Step 1006, the master device determines that the virtual time corresponding to the slave device is synchronized with the real time of the slave device.
Step 1007, the master device takes the difference between the second timestamp and the first timestamp as the one-way delay from the master device to the slave device, and takes the difference between the fourth timestamp and the third timestamp as the one-way delay from the slave device to the master device.
Based on the same inventive concept, the embodiment of the present invention further provides a delay measurement apparatus, and as the principle of the apparatus for solving the problem is similar to that of the delay measurement system, the implementation of the apparatus can refer to the implementation of the system, and repeated details are not repeated.
As shown in fig. 11, a delay measuring apparatus according to an embodiment of the present invention is located in a host device, and includes a virtual time module 1101, a message transceiver module 1102, a timestamp sampling module 1103, a synchronous computation filter module 1104, and an index computation module 1105;
the virtual time module 1101 stores at least one virtual time for synchronizing with the slave devices, and the virtual time corresponds to the slave devices to be measured one by one; the virtual time module 1101 is configured to periodically update each virtual time;
the message transceiver module 1102 sends a measurement message to the slave device; the timestamp sampling module 1003 is configured to determine a first time point representing a time when the measurement packet is sent according to virtual time corresponding to the slave device when the measurement packet is sent;
the message transceiver module 1102 is further configured to receive a measurement response message returned by the slave device; the timestamp sampling module 1103 is further configured to determine, according to the virtual time corresponding to the slave device when the measurement response packet is received, a fourth time point indicating a time when the measurement response packet is received; the measurement response message comprises a second time point representing the time when the slave device receives the measurement message and a third time point representing the time when the slave device sends the measurement response message;
the synchronization calculation filtering module 1104 is configured to determine, according to the first time point, the second time point, the third time point, and the fourth time point, an offset between a virtual time corresponding to the slave device and a real time of the slave device, and if the offset is not greater than a first threshold, determine that the virtual time corresponding to the slave device is synchronized with the real time of the slave device; the indicator calculating module 1105 is configured to use a difference between the second time point and the first time point as a one-way delay from the master device to the slave device, and use a difference between the fourth time point and the third time point as a one-way delay from the slave device to the master device.
It should be noted that the delay measuring apparatus in the embodiment of the present invention further includes a message generation terminating module 1106, where the message generation terminating module 1106 is configured to generate a measurement message and/or a terminating measurement response message; after the message generation and termination module 1106 generates a measurement message, the measurement message is transmitted to the message transceiving module 1102 to be sent to the slave device;
after determining the fourth time point, the timestamp sampling module 1103 may record the fourth time point locally, or add the fourth time point to the measurement response message; if the determined fourth time point is added to the measurement response message, specifically, the message transceiver module 1102 receives the measurement response message returned from the device, the timestamp sampling module 1103 determines the fourth time point, adds the fourth time point to the measurement response message, and sends the updated measurement response message to the message generation termination module 1106.
Optionally, the synchronous computation filtering module 1104 is further configured to: and if the offset is larger than the first threshold, modifying the virtual time corresponding to the slave equipment according to the offset, and returning to the step of sending the measurement message to the slave equipment by the master equipment.
Optionally, the synchronous calculation filtering module 1104 is specifically configured to: determining a first difference between the second time point and the first time point, and determining a second difference between the fourth time point and the third time point; and taking the quotient of the difference value of the first difference value and the second difference value and a preset parameter as the offset of the virtual time corresponding to the slave equipment and the real time of the slave equipment.
Optionally, if the virtual time module stores virtual times corresponding to a plurality of slave devices, the synchronous calculation filtering module 1104 is further configured to:
and forming a virtual time array by the virtual times corresponding to the plurality of slave devices according to the sequence number of each slave device.
Optionally, the synchronous calculation filtering module 1104 is specifically configured to:
and updating the virtual time corresponding to each slave device in the virtual time array at the same time at intervals of the updating period.
Optionally, the timestamp sampling module 1103 is specifically configured to:
taking the virtual time corresponding to the slave device when the measurement message is sent as the first time point;
the timestamp sampling module 1103 is specifically configured to:
and taking the virtual time corresponding to the slave device when the measurement response message is received as the fourth time point.
Optionally, the synchronous calculation filtering module 1104 is specifically configured to:
in an updating period, updating the virtual time corresponding to one slave device in the virtual time array at fixed time intervals according to the sequence number sequence of each slave device; wherein the fixed duration is a quotient of the update period and the number of virtual times included in the virtual time array.
Optionally, the timestamp sampling module 1103 is specifically configured to:
determining the deviation of the virtual time corresponding to the slave equipment when the measurement message is sent according to the serial number of the slave equipment corresponding to the current or latest updated virtual time, the serial number of the slave equipment needing to receive the measurement message and the fixed time length; and taking the sum of the virtual time corresponding to the slave equipment and the deviation when the measurement message is sent as the first time point.
Optionally, the timestamp sampling module 1103 is specifically configured to:
if the serial number of the slave equipment corresponding to the current or latest updated virtual time is not less than the serial number of the slave equipment needing to receive the measurement message, taking the product of the difference value between the serial number of the slave equipment corresponding to the current or latest updated virtual time and the serial number of the slave equipment needing to receive the measurement message and the fixed time length as the deviation of the virtual time corresponding to the slave equipment when the measurement message is sent;
if the serial number of the slave equipment corresponding to the current or latest updated virtual time is smaller than the serial number of the slave equipment needing to receive the measurement message, determining the sum of the serial number of the slave equipment corresponding to the current or latest updated virtual time and the number of the slave equipment in the virtual time array; and taking the product of the difference value between the sum value and the serial number of the slave equipment which needs to receive the measurement message and the fixed time length as the deviation of the virtual time corresponding to the slave equipment when the measurement message is sent.
Optionally, the timestamp sampling module 1103 is specifically configured to:
determining the deviation of the virtual time corresponding to the slave equipment when the measurement response message is received according to the serial number of the slave equipment corresponding to the current or latest updated virtual time, the serial number of the slave equipment sending the measurement response message and the fixed time length; and taking the sum of the virtual time corresponding to the slave equipment when the measurement response message is received and the deviation as the fourth time point.
Optionally, if the serial number of the slave device corresponding to the current or latest updated virtual time is not less than the serial number of the slave device sending the measurement response packet, taking the product of the difference value between the serial number of the slave device corresponding to the current or latest updated virtual time and the serial number of the slave device sending the measurement response packet and the fixed time length as the deviation of the virtual time corresponding to the slave device when the measurement response packet is received;
if the serial number of the slave equipment corresponding to the current or latest updated virtual time is smaller than the serial number of the slave equipment sending the measurement response message, determining the sum of the serial number of the slave equipment corresponding to the current or latest updated virtual time and the number of the slave equipment in the virtual time array; and taking the product of the difference value between the sum value and the serial number of the slave equipment sending the measurement response message and the fixed time length as the deviation of the virtual time corresponding to the slave equipment when the measurement response message is received.
In specific implementation, the virtual time module 1101 according to the embodiment of the present invention may be implemented by an FPGA (Field-Programmable Gate Array) or an ASIC (Application specific integrated Circuit);
the messaging module 1102 may be implemented by an ethernet PHY (physical layer) chip;
the timestamp sampling module 1103 may be implemented by an FPGA;
the index calculation module 1105 may be implemented by an FPGA;
the message generation and termination module 1106 is implemented by an FPGA.
As shown in fig. 12, an embodiment of the present invention further provides a latency measurement apparatus, where the latency measurement apparatus is located in a host device, and includes a processor 1201, a memory 1202, and a transceiver 1203;
the memory 1202 stores at least one virtual time for synchronizing with the slave device, and the virtual time corresponds to the slave device to be measured one by one; the memory 1202 has stored therein program code that, when executed by the processor 1201, causes the processor 1201 to perform the following processes:
sending a measurement message to the slave device via the transceiver 1203; determining a first time point representing the time when the measurement message is sent according to the virtual time corresponding to the slave equipment when the measurement message is sent;
receiving a measurement response message returned by the slave device through the transceiver 1203; determining a fourth time point representing the moment when the measurement response message is received according to the virtual time corresponding to the slave equipment when the measurement response message is received; the measurement response message comprises a second time point representing the time when the slave device receives the measurement message and a third time point representing the time when the slave device sends the measurement response message;
determining an offset between the virtual time corresponding to the slave device and the real time of the slave device according to the first time point, the second time point, the third time point and the fourth time point, and if the offset is not greater than a first threshold, determining that the virtual time corresponding to the slave device is synchronous with the real time of the slave device; taking the difference value between the second time point and the first time point as the one-way time delay from the master device to the slave device, and taking the difference value between the fourth time point and the third time point as the one-way time delay from the slave device to the master device;
the processor 1201 is also configured to periodically update each virtual time.
A transceiver 1203 configured to receive and transmit messages under control of the process 1201.
Optionally, if the memory stores virtual times corresponding to a plurality of slave devices, the processor 1201 is further configured to:
and forming a virtual time array by the virtual times corresponding to the plurality of slave devices according to the sequence number of each slave device.
Optionally, the processor 1201 is specifically configured to: determining a first difference between the second time point and the first time point, and determining a second difference between the fourth time point and the third time point; and taking the quotient of the difference value of the first difference value and the second difference value and a preset parameter as the offset of the virtual time corresponding to the slave equipment and the real time of the slave equipment.
Optionally, the processor 1201 is specifically configured to: and updating the virtual time corresponding to each slave device in the virtual time array at the same time every updating period.
Optionally, the processor 1201 is specifically configured to: taking the virtual time corresponding to the slave device when the measurement message is sent as the first time point; and taking the virtual time corresponding to the slave device when the measurement response message is received as the fourth time point.
Optionally, the processor 1201 is specifically configured to: in an updating period, updating the virtual time corresponding to one slave device in the virtual time array at fixed time intervals according to the sequence number sequence of each slave device; wherein the fixed duration is a quotient of the update period and the number of virtual times included in the virtual time array.
Optionally, the processor 1201 is specifically configured to: determining the deviation of the virtual time corresponding to the slave equipment when the measurement message is sent according to the serial number of the slave equipment corresponding to the current or latest updated virtual time, the serial number of the slave equipment needing to receive the measurement message and the fixed time length; and taking the sum of the virtual time corresponding to the slave equipment and the deviation when the measurement message is sent as the first time point.
Optionally, the processor 1201 is specifically configured to: if the serial number of the slave equipment corresponding to the current or latest updated virtual time is not less than the serial number of the slave equipment needing to receive the measurement message, taking the product of the difference value between the serial number of the slave equipment corresponding to the current or latest updated virtual time and the serial number of the slave equipment needing to receive the measurement message and the fixed time length as the deviation of the virtual time corresponding to the slave equipment when the measurement message is sent;
if the serial number of the slave equipment corresponding to the current or latest updated virtual time is smaller than the serial number of the slave equipment needing to receive the measurement message, determining the sum of the serial number of the slave equipment corresponding to the current or latest updated virtual time and the number of the slave equipment in the virtual time array; and taking the product of the difference value between the sum value and the serial number of the slave equipment which needs to receive the measurement message and the fixed time length as the deviation of the virtual time corresponding to the slave equipment when the measurement message is sent.
Optionally, the processor 1201 is specifically configured to: determining the deviation of the virtual time corresponding to the slave equipment when the measurement response message is received according to the serial number of the slave equipment corresponding to the current or latest updated virtual time, the serial number of the slave equipment sending the measurement response message and the fixed time length; and taking the sum of the virtual time corresponding to the slave equipment when the measurement response message is received and the deviation as the fourth time point.
Optionally, the processor 1201 is specifically configured to: if the serial number of the slave equipment corresponding to the current or latest updated virtual time is not less than the serial number of the slave equipment sending the measurement response message, taking the product of the difference value between the serial number of the slave equipment corresponding to the current or latest updated virtual time and the serial number of the slave equipment sending the measurement response message and the fixed time length as the deviation of the virtual time corresponding to the slave equipment when the measurement response message is received;
if the serial number of the slave equipment corresponding to the current or latest updated virtual time is smaller than the serial number of the slave equipment sending the measurement response message, determining the sum of the serial number of the slave equipment corresponding to the current or latest updated virtual time and the number of the slave equipment in the virtual time array; and taking the product of the difference value between the sum value and the serial number of the slave equipment sending the measurement response message and the fixed time length as the deviation of the virtual time corresponding to the slave equipment when the measurement response message is received.
Alternatively, the processor 1201 may be a CPU (central processing unit), ASIC, FPGA or CPLD (complex programmable Logic Device).
Based on the same inventive concept, the embodiment of the invention also provides a time delay measurement method, and as the principle of solving the problems of the method is similar to that of the time delay measurement system, the implementation of the method can refer to the implementation of the system, and repeated parts are not described again.
As shown in fig. 13, the method for measuring delay according to the embodiment of the present invention includes:
step 1301, the master device sends a measurement message to the slave device, and determines a first time point representing a time when the measurement message is sent according to virtual time corresponding to the slave device when the measurement message is sent;
step 1302, the master device receives a measurement response packet returned by the slave device, and determines a fourth time point representing a time when the measurement response packet is received according to a virtual time corresponding to the slave device when the measurement response packet is received; the measurement response message comprises a second time point representing the time when the slave device receives the measurement message and a third time point representing the time when the slave device sends the measurement response message;
step 1303, the master device determines, according to the first time point, the second time point, the third time point, and the fourth time point, an offset between the virtual time corresponding to the slave device and the real time of the slave device, and if the offset is not greater than a first threshold, it determines that the virtual time corresponding to the slave device is synchronized with the real time of the slave device; taking the difference value between the second time point and the first time point as the one-way time delay from the master device to the slave device, and taking the difference value between the fourth time point and the third time point as the one-way time delay from the slave device to the master device;
the method comprises the steps that at least one virtual time used for synchronizing with slave equipment is stored in the master equipment, and the virtual time corresponds to the slave equipment needing to be measured one by one; the master device periodically updates each virtual time.
Optionally, the method further includes:
and if the offset is larger than the first threshold, the master device modifies the virtual time corresponding to the slave device according to the offset, and returns to the step of sending the measurement message to the slave device by the master device.
Optionally, the determining, by the master device, an offset between a virtual time corresponding to the slave device and a real time of the slave device according to the first time point, the second time point, the third time point, and the fourth time point includes:
the master device determining a first difference between the second time point and the first time point and determining a second difference between the fourth time point and the third time point;
and the master device takes the quotient of the difference value of the first difference value and the second difference value and a preset parameter as the offset of the virtual time corresponding to the slave device and the real time of the slave device.
Optionally, if the master device stores virtual times corresponding to a plurality of slave devices that need to be measured, the master device combines the virtual times corresponding to the plurality of slave devices into a virtual time array according to the sequence number of each slave device.
Optionally, the periodically updating each virtual time by the master device includes:
and the master equipment updates the virtual time corresponding to each slave equipment in the virtual time array at the same time at intervals of the updating period.
Optionally, the determining, by the master device, a first time point representing a time when the measurement packet is sent according to the virtual time corresponding to the slave device when the measurement packet is sent includes:
the master device takes the virtual time corresponding to the slave device when the measurement message is sent as the first time point;
the determining, by the master device, a fourth time point representing a time when the measurement response packet is received according to the virtual time corresponding to the slave device when the measurement response packet is received, includes:
and the master device takes the virtual time corresponding to the slave device when receiving the measurement response message as the fourth time point.
Optionally, the periodically updating each virtual time by the master device includes:
in an updating period, the master device updates the virtual time corresponding to one slave device in the virtual time array at fixed time intervals according to the sequence number sequence of each slave device; wherein the fixed duration is a quotient of the update period and the number of virtual times included in the virtual time array.
Optionally, the determining, by the master device, a first time point representing a time when the measurement packet is sent according to the virtual time corresponding to the slave device when the measurement packet is sent includes:
the master device determines the deviation of the virtual time corresponding to the slave device when sending the measurement message according to the serial number of the slave device corresponding to the current or latest updated virtual time, the serial number of the slave device needing to receive the measurement message and the fixed time length;
and the master device takes the sum of the virtual time corresponding to the slave device when the measurement message is sent and the deviation as the first time point.
Optionally, the determining, by the master device, a deviation of the virtual time corresponding to the slave device when the measurement packet is sent according to the serial number of the slave device corresponding to the current or latest updated virtual time, the serial number of the slave device that needs to receive the measurement packet, and the fixed time length by the master device includes:
if the serial number of the slave equipment corresponding to the current or latest updated virtual time is not less than the serial number of the slave equipment needing to receive the measurement message, the master equipment takes the product of the difference value between the serial number of the slave equipment corresponding to the current or latest updated virtual time and the serial number of the slave equipment needing to receive the measurement message and the fixed time length as the deviation of the virtual time corresponding to the slave equipment when the measurement message is sent;
if the serial number of the slave equipment corresponding to the current or latest updated virtual time is smaller than the serial number of the slave equipment needing to receive the measurement message, the master equipment determines the sum of the serial number of the slave equipment corresponding to the current or latest updated virtual time and the number of the slave equipment in the virtual time array; and taking the product of the difference value between the sum value and the serial number of the slave equipment which needs to receive the measurement message and the fixed time length as the deviation of the virtual time corresponding to the slave equipment when the measurement message is sent.
Optionally, the determining, by the master device, a fourth time point representing a time when the measurement response packet is received according to the virtual time corresponding to the slave device when the measurement response packet is received, includes:
the master device determines the deviation of the virtual time corresponding to the slave device when receiving the measurement response message according to the serial number of the slave device corresponding to the current or latest updated virtual time, the serial number of the slave device sending the measurement response message and the fixed time length;
and the master device takes the sum of the virtual time corresponding to the slave device when the measurement response message is received and the deviation as the fourth time point.
Optionally, the determining, by the master device, a deviation of the virtual time corresponding to the slave device when the measurement response packet is received according to the serial number of the slave device corresponding to the current or latest updated virtual time, the serial number of the slave device sending the measurement response packet, and the fixed time length by the master device includes:
if the serial number of the slave device corresponding to the current or latest updated virtual time is not less than the serial number of the slave device sending the measurement response message, the master device takes the product of the difference value between the serial number of the slave device corresponding to the current or latest updated virtual time and the serial number of the slave device sending the measurement response message and the fixed time length as the deviation of the virtual time corresponding to the slave device when the measurement response message is received;
if the serial number of the slave equipment corresponding to the current or latest updated virtual time is smaller than the serial number of the slave equipment sending the measurement response message, the master equipment determines the sum of the serial number of the slave equipment corresponding to the current or latest updated virtual time and the number of the slave equipment in the virtual time array; and taking the product of the difference value between the sum value and the serial number of the slave equipment sending the measurement response message and the fixed time length as the deviation of the virtual time corresponding to the slave equipment when the measurement response message is received.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present invention have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all such alterations and modifications as fall within the scope of the invention.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present invention without departing from the spirit and scope of the invention. Thus, if such modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include such modifications and variations.

Claims (22)

1. A time delay measuring method is characterized in that at least one virtual time used for synchronizing with slave equipment is stored in master equipment, and the virtual time corresponds to the slave equipment needing to be measured one by one; the master device periodically updates each virtual time, and the method comprises the following steps:
the method comprises the steps that a master device sends a measurement message to a slave device, and a first time point representing the moment when the measurement message is sent is determined according to virtual time corresponding to the slave device when the measurement message is sent;
the master equipment receives a measurement response message returned by the slave equipment, and determines a fourth time point representing the moment when the measurement response message is received according to the virtual time corresponding to the slave equipment when the measurement response message is received; the measurement response message comprises a second time point representing the time when the slave device receives the measurement message and a third time point representing the time when the slave device sends the measurement response message;
the master device determines an offset between the virtual time corresponding to the slave device and the real time of the slave device according to the first time point, the second time point, the third time point and the fourth time point, and if the offset is not greater than a first threshold, determines that the virtual time corresponding to the slave device is synchronous with the real time of the slave device; and taking the difference value between the second time point and the first time point as the one-way time delay from the master device to the slave device, and taking the difference value between the fourth time point and the third time point as the one-way time delay from the slave device to the master device.
2. The method of claim 1, further comprising:
and if the offset is larger than the first threshold, the master device modifies the virtual time corresponding to the slave device according to the offset, and returns to the step of sending the measurement message to the slave device by the master device.
3. The method of claim 1, wherein the master device determining an offset of a virtual time corresponding to the slave device from a real time of the slave device according to the first time point, the second time point, the third time point, and the fourth time point comprises:
the master device determining a first difference between the second time point and the first time point and determining a second difference between the fourth time point and the third time point;
and the master device takes the quotient of the difference value of the first difference value and the second difference value and a preset parameter as the offset of the virtual time corresponding to the slave device and the real time of the slave device.
4. The method of claim 1, wherein if the master device stores virtual times corresponding to a plurality of slave devices, the master device composes a virtual time array from the virtual times corresponding to the plurality of slave devices according to the sequence number of each slave device.
5. The method of claim 4, wherein the master device periodically updating each virtual time comprises:
and the master equipment updates the virtual time corresponding to each slave equipment in the virtual time array at intervals of an updating period.
6. The method according to claim 5, wherein the determining, by the master device, a first time point representing a time when the measurement packet is transmitted according to the virtual time corresponding to the slave device when the measurement packet is transmitted, includes:
the master device takes the virtual time corresponding to the slave device when the measurement message is sent as the first time point;
the determining, by the master device, a fourth time point representing a time when the measurement response packet is received according to the virtual time corresponding to the slave device when the measurement response packet is received, includes:
and the master device takes the virtual time corresponding to the slave device when receiving the measurement response message as the fourth time point.
7. The method of claim 4, wherein the master device periodically updating the virtual time corresponding to each slave device comprises:
in an updating period, the master device updates the virtual time corresponding to one slave device in the virtual time array at fixed time intervals according to the sequence number sequence of each slave device; wherein the fixed duration is a quotient of the update period and the number of virtual times included in the virtual time array.
8. The method according to claim 7, wherein the determining, by the master device, a first time point representing a time when the measurement packet is transmitted according to the virtual time corresponding to the slave device when the measurement packet is transmitted includes:
the master device determines the deviation of the virtual time corresponding to the slave device when sending the measurement message according to the serial number of the slave device corresponding to the current or latest updated virtual time, the serial number of the slave device needing to receive the measurement message and the fixed time length;
and the master device takes the sum of the virtual time corresponding to the slave device when the measurement message is sent and the deviation as the first time point.
9. The method according to claim 8, wherein the determining, by the master device, the deviation of the virtual time corresponding to the slave device when sending the measurement packet according to the serial number of the slave device corresponding to the current or latest updated virtual time, the serial number of the slave device that needs to receive the measurement packet, and the fixed duration includes:
if the serial number of the slave equipment corresponding to the current or latest updated virtual time is not less than the serial number of the slave equipment needing to receive the measurement message, the master equipment takes the product of the difference value between the serial number of the slave equipment corresponding to the current or latest updated virtual time and the serial number of the slave equipment needing to receive the measurement message and the fixed time length as the deviation of the virtual time corresponding to the slave equipment when the measurement message is sent;
if the serial number of the slave equipment corresponding to the current or latest updated virtual time is smaller than the serial number of the slave equipment needing to receive the measurement message, the master equipment determines the sum of the serial number of the slave equipment corresponding to the current or latest updated virtual time and the number of the slave equipment in the virtual time array; and taking the product of the difference value between the sum value and the serial number of the slave equipment which needs to receive the measurement message and the fixed time length as the deviation of the virtual time corresponding to the slave equipment when the measurement message is sent.
10. The method according to claim 7, wherein the determining, by the master device, a fourth time point representing a time when the measurement response packet is received according to the virtual time corresponding to the slave device when the measurement response packet is received, by the master device, includes:
the master device determines the deviation of the virtual time corresponding to the slave device when receiving the measurement response message according to the serial number of the slave device corresponding to the current or latest updated virtual time, the serial number of the slave device sending the measurement response message and the fixed time length;
and the master device takes the sum of the virtual time corresponding to the slave device when the measurement response message is received and the deviation as the fourth time point.
11. The method according to claim 10, wherein the determining, by the master device, the deviation of the virtual time corresponding to the slave device when receiving the measurement response packet according to the serial number of the slave device corresponding to the current or latest updated virtual time, the serial number of the slave device sending the measurement response packet, and the fixed time length, comprises:
if the serial number of the slave device corresponding to the current or latest updated virtual time is not less than the serial number of the slave device sending the measurement response message, the master device takes the product of the difference value between the serial number of the slave device corresponding to the current or latest updated virtual time and the serial number of the slave device sending the measurement response message and the fixed time length as the deviation of the virtual time corresponding to the slave device when the measurement response message is received;
if the serial number of the slave equipment corresponding to the current or latest updated virtual time is smaller than the serial number of the slave equipment sending the measurement response message, the master equipment determines the sum of the serial number of the slave equipment corresponding to the current or latest updated virtual time and the number of the slave equipment in the virtual time array; and taking the product of the difference value between the sum value and the serial number of the slave equipment sending the measurement response message and the fixed time length as the deviation of the virtual time corresponding to the slave equipment when the measurement response message is received.
12. A time delay measuring device is characterized in that the device is applied to a main device; the device comprises a virtual time module, a message transceiving module, a timestamp sampling module, a synchronous calculation filtering module and an index calculation module; the virtual time module stores at least one virtual time for synchronizing with the slave equipment, and the virtual time corresponds to the slave equipment needing to be measured one by one; the virtual time module is used for periodically updating each virtual time;
the message receiving and sending module sends a measurement message to the slave equipment; the timestamp sampling module is used for determining a first time point representing the time for sending the measurement message according to the virtual time corresponding to the slave equipment when the measurement message is sent;
the message receiving and sending module is further used for receiving a measurement response message returned by the slave device; the timestamp sampling module is further configured to determine a fourth time point representing a time when the measurement response packet is received according to virtual time corresponding to the slave device when the measurement response packet is received; the measurement response message comprises a second time point representing the time when the slave device receives the measurement message and a third time point representing the time when the slave device sends the measurement response message;
the synchronization calculation filtering module is configured to determine, according to the first time point, the second time point, the third time point, and the fourth time point, an offset between a virtual time corresponding to the slave device and a real time of the slave device, and if the offset is not greater than a first threshold, determine that the virtual time corresponding to the slave device is synchronized with the real time of the slave device;
the index calculation module is configured to use a difference between the second time point and the first time point as a one-way delay from the master device to the slave device, and use a difference between the fourth time point and the third time point as a one-way delay from the slave device to the master device.
13. The apparatus of claim 12, wherein the synchronous computation filtering module is further to:
and if the offset is larger than the first threshold, modifying the virtual time corresponding to the slave equipment according to the offset, and returning to the step of sending the measurement message to the slave equipment by the master equipment.
14. The apparatus of claim 12, wherein the synchronization computation filtering module is specifically configured to:
determining a first difference between the second time point and the first time point, and determining a second difference between the fourth time point and the third time point; and taking the quotient of the difference value of the first difference value and the second difference value and a preset parameter as the offset of the virtual time corresponding to the slave equipment and the real time of the slave equipment.
15. The apparatus of claim 12, wherein if the virtual time module stores virtual times corresponding to a plurality of slave devices, the synchronization computation filtering module is further configured to:
and forming a virtual time array by the virtual times corresponding to the plurality of slave devices according to the sequence number of each slave device.
16. The apparatus of claim 15, wherein the synchronous computation filtering module is specifically configured to:
and updating the virtual time corresponding to each slave device in the virtual time array at the same time every updating period.
17. The apparatus of claim 16, wherein the timestamp sampling module is specifically configured to:
taking the virtual time corresponding to the slave device when the measurement message is sent as the first time point;
the timestamp sampling module is specifically configured to:
and taking the virtual time corresponding to the slave device when the measurement response message is received as the fourth time point.
18. The apparatus of claim 15, wherein the synchronous computation filtering module is specifically configured to:
in an updating period, updating the virtual time corresponding to one slave device in the virtual time array at fixed time intervals according to the sequence number sequence of each slave device; wherein the fixed duration is a quotient of the update period and the number of virtual times included in the virtual time array.
19. The apparatus of claim 18, wherein the timestamp sampling module is specifically configured to:
determining the deviation of the virtual time corresponding to the slave equipment when the measurement message is sent according to the serial number of the slave equipment corresponding to the current or latest updated virtual time, the serial number of the slave equipment needing to receive the measurement message and the fixed time length; and taking the sum of the virtual time corresponding to the slave equipment and the deviation when the measurement message is sent as the first time point.
20. The apparatus of claim 19, wherein the timestamp sampling module is specifically configured to:
if the serial number of the slave equipment corresponding to the current or latest updated virtual time is not less than the serial number of the slave equipment needing to receive the measurement message, taking the product of the difference value between the serial number of the slave equipment corresponding to the current or latest updated virtual time and the serial number of the slave equipment needing to receive the measurement message and the fixed time length as the deviation of the virtual time corresponding to the slave equipment when the measurement message is sent;
if the serial number of the slave equipment corresponding to the current or latest updated virtual time is smaller than the serial number of the slave equipment needing to receive the measurement message, determining the sum of the serial number of the slave equipment corresponding to the current or latest updated virtual time and the number of the slave equipment in the virtual time array; and taking the product of the difference value between the sum value and the serial number of the slave equipment which needs to receive the measurement message and the fixed time length as the deviation of the virtual time corresponding to the slave equipment when the measurement message is sent.
21. The apparatus of claim 18, wherein the timestamp sampling module is specifically configured to:
determining the deviation of the virtual time corresponding to the slave equipment when the measurement response message is received according to the serial number of the slave equipment corresponding to the current or latest updated virtual time, the serial number of the slave equipment sending the measurement response message and the fixed time length; and taking the sum of the virtual time corresponding to the slave equipment when the measurement response message is received and the deviation as the fourth time point.
22. The apparatus of claim 21, wherein the timestamp sampling module is specifically configured to:
if the serial number of the slave equipment corresponding to the current or latest updated virtual time is not less than the serial number of the slave equipment sending the measurement response message, taking the product of the difference value between the serial number of the slave equipment corresponding to the current or latest updated virtual time and the serial number of the slave equipment sending the measurement response message and the fixed time length as the deviation of the virtual time corresponding to the slave equipment when the measurement response message is received;
if the serial number of the slave equipment corresponding to the current or latest updated virtual time is smaller than the serial number of the slave equipment sending the measurement response message, determining the sum of the serial number of the slave equipment corresponding to the current or latest updated virtual time and the number of the slave equipment in the virtual time array; and taking the product of the difference value between the sum value and the serial number of the slave equipment sending the measurement response message and the fixed time length as the deviation of the virtual time corresponding to the slave equipment when the measurement response message is received.
CN201710666460.1A 2017-08-07 2017-08-07 Time delay measuring method and device Active CN107360060B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710666460.1A CN107360060B (en) 2017-08-07 2017-08-07 Time delay measuring method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710666460.1A CN107360060B (en) 2017-08-07 2017-08-07 Time delay measuring method and device

Publications (2)

Publication Number Publication Date
CN107360060A CN107360060A (en) 2017-11-17
CN107360060B true CN107360060B (en) 2020-04-10

Family

ID=60286992

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710666460.1A Active CN107360060B (en) 2017-08-07 2017-08-07 Time delay measuring method and device

Country Status (1)

Country Link
CN (1) CN107360060B (en)

Families Citing this family (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108768576B (en) * 2018-06-29 2020-11-17 广东星舆科技有限公司 Method and device for realizing high-precision time synchronization data of sensor based on single chip microcomputer
CN109450582A (en) * 2018-11-01 2019-03-08 百度在线网络技术(北京)有限公司 Sensor time stabs synchronous detecting method, device, equipment, medium and vehicle
CN109462453A (en) * 2018-11-22 2019-03-12 电信科学技术第五研究所有限公司 A kind of high-precision time synchronization method based on fiber optic network
CN109815102B (en) * 2019-01-21 2022-10-11 武汉斗鱼鱼乐网络科技有限公司 Test data statistical method, device and storage medium
CN110572233B (en) * 2019-09-20 2021-04-27 上海东土远景工业科技有限公司 Time keeping method and device using NTP (network time protocol) as auxiliary source
CN112752119B (en) * 2019-10-31 2023-12-01 中兴通讯股份有限公司 Delay error correction method, terminal equipment, server and storage medium
CN111490843B (en) * 2020-04-03 2021-10-26 腾讯科技(深圳)有限公司 Time checking method and device, computer equipment and storage medium
CN114124274A (en) * 2020-08-31 2022-03-01 华为技术有限公司 Method and device
CN113157046B (en) * 2021-03-25 2023-03-28 山东英信计算机技术有限公司 Method, device and system for managing server BMC time
WO2022247463A1 (en) * 2021-05-28 2022-12-01 中国移动通信有限公司研究院 Delay measurement method and apparatus, and digital twin network

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1960242A (en) * 2006-10-17 2007-05-09 中控科技集团有限公司 Method, device, system for implementing clock synchronization, and distribution system
CN101399653A (en) * 2007-09-25 2009-04-01 普然通讯技术(上海)有限公司 Time clock synchronization implementation method
CN102265549A (en) * 2008-09-22 2011-11-30 柯扎特·拉多·拉多莱斯库 Network timing synchronization systems
CN102742190A (en) * 2012-02-01 2012-10-17 华为技术有限公司 Synchronization method, device, and system
CN105794130A (en) * 2013-12-09 2016-07-20 哈利法科学技术研究大学 Method and devices for synchronization using linear programming

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7643595B2 (en) * 2004-09-13 2010-01-05 Nortel Networks Limited Method and apparatus for synchronizing clock timing between network elements

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1960242A (en) * 2006-10-17 2007-05-09 中控科技集团有限公司 Method, device, system for implementing clock synchronization, and distribution system
CN101399653A (en) * 2007-09-25 2009-04-01 普然通讯技术(上海)有限公司 Time clock synchronization implementation method
CN102265549A (en) * 2008-09-22 2011-11-30 柯扎特·拉多·拉多莱斯库 Network timing synchronization systems
CN102742190A (en) * 2012-02-01 2012-10-17 华为技术有限公司 Synchronization method, device, and system
CN105794130A (en) * 2013-12-09 2016-07-20 哈利法科学技术研究大学 Method and devices for synchronization using linear programming

Also Published As

Publication number Publication date
CN107360060A (en) 2017-11-17

Similar Documents

Publication Publication Date Title
CN107360060B (en) Time delay measuring method and device
KR101506138B1 (en) Method, apparatus and system for time distribution in a telecommunications network
US9923656B2 (en) Methods, systems, and computer readable media for testing recovered clock quality
CN106603183B (en) A kind of timestamp filter method and device
CN102421187B (en) High-accuracy clock synchronization method of wireless sensor network
CN104836630B (en) IEEE1588 clock synchronization system and implementation method therefor
WO2018006686A1 (en) Method, apparatus and device for optimizing time synchronization between communication network devices
CN108259109B (en) Network equipment in PTP domain and TOD synchronization method
JP6192995B2 (en) COMMUNICATION DEVICE, COMMUNICATION SYSTEM, COMMUNICATION METHOD, AND COMPUTER PROGRAM
CN103067112B (en) Clock synchronizing method, device and the network equipment
CN103368721A (en) Computing method for transparent clock in time-triggered Ethernet
EP3284217A1 (en) Methods, systems, and computer readable media for synchronizing timing among network interface cards (nics) in a network equipment test device
CN105577348B (en) Frequency deviation monitoring method and device based on time synchronization network
CN103929293A (en) Asymmetrically-delayed time synchronization method and system
CN108322280A (en) A kind of distributed computer network (DCN) clock synchronizing relay compensation method
WO2017032113A1 (en) Method and apparatus for measuring time synchronization deviation
CN102739386A (en) System and method to overcome wander accumulation to achieve precision clock distribution over large networks
CN112838904A (en) TSN network delay jitter measuring device and method
Luckinger et al. Software-based AUTOSAR-compliant precision clock synchronization over CAN
JP6684409B1 (en) Time synchronization system
US9442511B2 (en) Method and a device for maintaining a synchronized local timer using a periodic signal
CN101867431A (en) Network clock synchronization method
CN115333660A (en) Precision timestamp correction
CN103634239A (en) Packet clock network node frequency offset estimation method and device
CN115412463B (en) Time delay measurement method and device and digital twin network

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information
CB02 Change of applicant information

Address after: 100094 First to Fifth Floors of Building 11, East Yard, No. 10 Wangdong Road, Northwest Haidian District, Beijing

Applicant after: Raisecom Technology Inc.

Address before: 100085 No. 2 Building, No. 28 Shangdi Sixth Street, Haidian District, Beijing

Applicant before: Raisecom Technology Inc.

GR01 Patent grant
GR01 Patent grant