[go: up one dir, main page]

CN118074839A - Clock synchronization method, device and system - Google Patents

Clock synchronization method, device and system Download PDF

Info

Publication number
CN118074839A
CN118074839A CN202211466808.XA CN202211466808A CN118074839A CN 118074839 A CN118074839 A CN 118074839A CN 202211466808 A CN202211466808 A CN 202211466808A CN 118074839 A CN118074839 A CN 118074839A
Authority
CN
China
Prior art keywords
node
clock
clock synchronization
message
synchronization
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.)
Pending
Application number
CN202211466808.XA
Other languages
Chinese (zh)
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.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies 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 Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Priority to CN202211466808.XA priority Critical patent/CN118074839A/en
Publication of CN118074839A publication Critical patent/CN118074839A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04JMULTIPLEX COMMUNICATION
    • H04J3/00Time-division multiplex systems
    • H04J3/02Details
    • H04J3/06Synchronising arrangements
    • H04J3/0635Clock or time synchronisation in a network
    • H04J3/0638Clock or time synchronisation among nodes; Internode synchronisation
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04JMULTIPLEX COMMUNICATION
    • H04J3/00Time-division multiplex systems
    • H04J3/02Details
    • H04J3/06Synchronising arrangements
    • H04J3/0635Clock or time synchronisation in a network
    • H04J3/0638Clock or time synchronisation among nodes; Internode synchronisation
    • H04J3/0658Clock or time synchronisation among packet nodes
    • H04J3/0661Clock or time synchronisation among packet nodes using timestamps
    • H04J3/0667Bidirectional timestamps, e.g. NTP or PTP for compensation of clock drift and for compensation of propagation delays

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Synchronisation In Digital Transmission Systems (AREA)

Abstract

The embodiment of the application provides a clock synchronization method, a clock synchronization device and a clock synchronization system, which comprise the following steps: the method comprises the steps that a first node sends a subscription request message to a control node, wherein the subscription request message is used for subscribing clock synchronization services of the first node and a second node, and the second node is a node which performs clock synchronization with the first node; the control node determines a strategy sending message according to the subscription request message, wherein the strategy sending message comprises a clock synchronization algorithm; the first node obtains a clock synchronization parameter for a clock synchronization service, the clock synchronization parameter being determined according to a clock synchronization algorithm. The clock synchronization method, the clock synchronization device and the clock synchronization system provided by the embodiment of the application can be applied to heterogeneous systems with complex structures, and the system resource expenditure is reduced on the premise of meeting the node synchronization requirement.

Description

时钟同步方法、装置和系统Clock synchronization method, device and system

技术领域Technical Field

本申请实施例涉及通信技术领域,尤其涉及一种时钟同步方法、装置和系统。The embodiments of the present application relate to the field of communication technology, and in particular, to a clock synchronization method, device and system.

背景技术Background Art

网络通信为人们的日常生活和工作提供了各种信息交换和共享的便捷服务。随着业务应用、网络流量和连接设备的日益增长,网络的复杂性和异构性越来越突出。例如,各个节点在计算、存储和供电资源方面的差异,以太网、蓝牙、WiFi等物理链路类型的多样性,星型、树型、总线型、混合型等组网结构的复杂性,网卡时钟、系统时钟等节点时钟读取的差异性等。Network communication provides convenient services for information exchange and sharing in people's daily life and work. With the increasing business applications, network traffic and connected devices, the complexity and heterogeneity of the network are becoming more and more prominent. For example, the differences in computing, storage and power supply resources of each node, the diversity of physical link types such as Ethernet, Bluetooth, WiFi, the complexity of star, tree, bus, hybrid and other networking structures, and the differences in node clock reading such as network card clock and system clock.

设计一种能够满足复杂网络系统的时钟同步方法以满足处于不同网络环境、具有不同配置的网络节点的时钟同步需求尤为关键。It is particularly important to design a clock synchronization method that can meet the clock synchronization requirements of complex network systems and network nodes in different network environments and with different configurations.

发明内容Summary of the invention

本申请实施例提供一种时钟同步方法、装置和系统,能够实现异构网络中对于处于不同网络环境、具有不同配置的节点的不同的时钟同步需求,确定不同的时钟同步方案,减小系统中的资源开销。The embodiments of the present application provide a clock synchronization method, device and system, which can realize different clock synchronization requirements for nodes in different network environments and with different configurations in a heterogeneous network, determine different clock synchronization schemes, and reduce resource overhead in the system.

第一方面,提供了一种时钟同步方法,包括:第一节点向控制节点发送订阅请求报文,所述订阅请求报文用于订阅所述第一节点与第二节点的时钟同步服务,所述第二节点是与所述第一节点进行时钟同步的节点;所述控制节点根据所述订阅请求报文,确定策略下发报文,所述策略下发报文包括时钟同步算法;所述第一节点获取时钟同步参数,所述时钟同步参数用于所述时钟同步服务,所述时钟同步参数是根据所述时钟同步算法确定的。In a first aspect, a clock synchronization method is provided, comprising: a first node sends a subscription request message to a control node, wherein the subscription request message is used to subscribe to a clock synchronization service between the first node and a second node, and the second node is a node that performs clock synchronization with the first node; the control node determines a policy sending message based on the subscription request message, and the policy sending message includes a clock synchronization algorithm; the first node obtains clock synchronization parameters, and the clock synchronization parameters are used for the clock synchronization service, and the clock synchronization parameters are determined according to the clock synchronization algorithm.

在该实施例中,控制节点能够根据第一节点发送的订阅请求报文,为第一节点确定合适的时钟同步算法,从而第一节点能够获取根据该时钟同步算法确定的时钟同步参数,实现与第二节点的时钟同步。控制节点能够根据不同节点的差异,为不同节点之间的时钟同步服务确定不同的时钟同步算法。此外,控制节点还可以根据实时的网络负载和通信质量等动态因素的变化,调整使用的时钟同步算法。例如,对于系统中配置不高或者计算和存储能力不强的节点,可以在满足节点的同步需求的前提下,使用对节点的计算和存储能力的要求适中的时钟同步算法;对于同步精度的要求较高的节点,可以采用更加复杂的时钟同步算法,也可以对现有的时钟同步算法进行改进,减小时钟同步误差。进而本申请实施例提供的时钟同步方法可以适用于组成复杂的异构系统,实现较小的系统负载,并减小系统的资源开销。该实施例中时钟同步算法的示例可以参考图2以及图9至图11以及相关介绍,该实施例且各个步骤的具体细节可以参考图3的描述,订阅请求报文的具体结构可以参考图5及相关描述,策略下发报文的具体结构可以参考图6及相关描述。In this embodiment, the control node can determine a suitable clock synchronization algorithm for the first node according to the subscription request message sent by the first node, so that the first node can obtain the clock synchronization parameters determined according to the clock synchronization algorithm and realize clock synchronization with the second node. The control node can determine different clock synchronization algorithms for the clock synchronization services between different nodes according to the differences between different nodes. In addition, the control node can also adjust the clock synchronization algorithm used according to the changes in dynamic factors such as real-time network load and communication quality. For example, for nodes with low configuration or weak computing and storage capabilities in the system, a clock synchronization algorithm with moderate requirements on the computing and storage capabilities of the node can be used on the premise of meeting the synchronization requirements of the node; for nodes with high requirements on synchronization accuracy, a more complex clock synchronization algorithm can be used, or the existing clock synchronization algorithm can be improved to reduce the clock synchronization error. Furthermore, the clock synchronization method provided in the embodiment of the present application can be applied to complex heterogeneous systems, achieve a smaller system load, and reduce the resource overhead of the system. For examples of the clock synchronization algorithm in this embodiment, please refer to Figures 2 and 9 to 11 and related introductions. For specific details of this embodiment and each step, please refer to the description in Figure 3. For the specific structure of the subscription request message, please refer to Figure 5 and related descriptions. For the specific structure of the policy delivery message, please refer to Figure 6 and related descriptions.

结合第一方面,在第一方面的某些实现方式中,所述策略下发报文包括执行节点的标识,所述方法还包括:所述控制节点向所述执行节点发送所述策略下发报文;所述执行节点根据所述策略下发报文,执行所述时钟同步算法,所述时钟同步参数是根据所述执行节点执行所述时钟同步算法发送和/或接收的同步报文的时间信息确定的,所述时间信息包括与所述执行节点发送所述同步报文关联的时钟计数器的数值或者时间戳,和/或,所述时间信息包括与所述执行节点接收所述同步报文关联的时钟计数器的数值或者时间戳。In combination with the first aspect, in certain implementations of the first aspect, the policy delivery message includes an identifier of an execution node, and the method further includes: the control node sends the policy delivery message to the execution node; the execution node executes the clock synchronization algorithm according to the policy delivery message, and the clock synchronization parameters are determined based on the time information of the synchronization message sent and/or received by the execution node when executing the clock synchronization algorithm, the time information includes the value or timestamp of the clock counter associated with the execution node sending the synchronization message, and/or the time information includes the value or timestamp of the clock counter associated with the execution node receiving the synchronization message.

在该实施例中,控制节点会确定执行时钟同步算法的执行节点。执行节点可以包括第一节点和第二节点,执行节点也可以不包括第一节点和/或第二节点。示例性的,执行节点可以由控制节点根据第一节点和第二节点的时钟同步精度需求、第一节点和第二节点的硬件配置、第一节点和第二节点的通信状况等确定,当第一节点和第二节点硬件配置较高且具有一定的报文收发能力时,执行节点可以包括第一节点和第二节点。相反,当第一节点和第二节点配置较低或通信状况较差时,执行节点可以包括网络中的其他节点,以减小第一节点和第二节点的时钟同步开销。执行节点是用于执行时钟同步算法的,并且根据执行节点执行时钟同步算法过程中的时间信息可以确定时钟同步参数。与执行节点发送或接收同步报文关联的时间戳或时钟计数器的数值可以与发送该同步报文的时间对应,该时间戳或时钟计数器的数值可以是同步报文的发送节点发送之前、发送之时或发送之后读取或标记的,也可以是同步报文的接收节点接收同步报文之时或接收之后读取或标记的。时钟计数器的数值可以例如通过后文提及的TSF时钟(也称为TSF计数器)读取,时间戳可以例如通过后文提及的系统时钟读取,时钟计数器的数值和时间戳还可以通过其他时钟读取,本申请对此不做限定。该实施例中执行节点执行时钟同步算法的过程可以参考图2至图3,图9至图11的相关描述。In this embodiment, the control node determines the execution node that executes the clock synchronization algorithm. The execution node may include the first node and the second node, or the execution node may not include the first node and/or the second node. Exemplarily, the execution node may be determined by the control node according to the clock synchronization accuracy requirements of the first node and the second node, the hardware configuration of the first node and the second node, the communication status of the first node and the second node, etc. When the hardware configuration of the first node and the second node is high and has a certain message sending and receiving capability, the execution node may include the first node and the second node. On the contrary, when the configuration of the first node and the second node is low or the communication status is poor, the execution node may include other nodes in the network to reduce the clock synchronization overhead of the first node and the second node. The execution node is used to execute the clock synchronization algorithm, and the clock synchronization parameter can be determined according to the time information in the process of executing the clock synchronization algorithm by the execution node. The timestamp or the value of the clock counter associated with the execution node sending or receiving the synchronization message may correspond to the time when the synchronization message is sent, and the timestamp or the value of the clock counter may be read or marked before, when or after the sending node of the synchronization message is sent, or may be read or marked when or after the receiving node of the synchronization message receives the synchronization message. The value of the clock counter can be read, for example, by the TSF clock (also referred to as the TSF counter) mentioned later, and the timestamp can be read, for example, by the system clock mentioned later, and the value and timestamp of the clock counter can also be read by other clocks, which is not limited in this application. The process of executing the clock synchronization algorithm by the execution node in this embodiment can refer to the relevant descriptions of Figures 2 to 3 and Figures 9 to 11.

结合第一方面,在第一方面的某些实现方式中,所述策略下发报文还包括汇聚节点的标识,所述汇聚节点不是所述第一节点,在所述第一节点获取时钟同步参数之前,所述方法还包括:所述控制节点向所述汇聚节点发送所述策略下发报文;所述执行节点向所述汇聚节点发送时间信息上传报文,所述时间信息上传报文包括所述时间信息;所述汇聚节点根据所述时钟同步算法和所述时间信息确定所述时钟同步参数;所述汇聚节点向所述第一节点发送参数发布报文,所述参数发布报文包括所述时钟同步参数。In combination with the first aspect, in certain implementations of the first aspect, the policy delivery message also includes an identifier of a convergence node, and the convergence node is not the first node. Before the first node obtains the clock synchronization parameters, the method also includes: the control node sends the policy delivery message to the convergence node; the execution node sends a time information upload message to the convergence node, and the time information upload message includes the time information; the convergence node determines the clock synchronization parameters based on the clock synchronization algorithm and the time information; the convergence node sends a parameter release message to the first node, and the parameter release message includes the clock synchronization parameters.

在该实施例中,控制节点还会确定汇聚节点,汇聚节点可以与第一节点不是同一个节点,由汇聚节点根据时钟同步算法和执行节点执行时钟同步算法过程中的报文发送/接收时间信息确定时钟同步参数。本申请中计算时钟同步参数的是控制节点确定的汇聚节点。该汇聚节点,示例性的可以具有较高的计算和存储能力,从而控制节点可以根据确定的时钟同步算法的计算复杂程度和系统中节点的配置、计算和存储能力,确定汇聚节点。这样能够减小对计算和存储能力不强的节点带来的负担,避免时钟同步对网络正常业务的不利影响,提高时钟同步的鲁棒性。该实施例中时间信息上传报文的具体结构可以参考图7及相关描述,参数发布报文的具体结构可以参考图8及相关描述。In this embodiment, the control node will also determine the convergence node, which may not be the same node as the first node, and the convergence node determines the clock synchronization parameters according to the clock synchronization algorithm and the message sending/receiving time information during the execution of the clock synchronization algorithm by the execution node. In this application, the convergence node determined by the control node calculates the clock synchronization parameters. The convergence node can exemplarily have a high computing and storage capacity, so that the control node can determine the convergence node according to the computational complexity of the determined clock synchronization algorithm and the configuration, computing and storage capacity of the nodes in the system. In this way, the burden on nodes with weak computing and storage capabilities can be reduced, the adverse effects of clock synchronization on normal network services can be avoided, and the robustness of clock synchronization can be improved. The specific structure of the time information upload message in this embodiment can refer to Figure 7 and related descriptions, and the specific structure of the parameter release message can refer to Figure 8 and related descriptions.

汇聚节点计算出时钟同步参数后,直接将该时钟同步参数发送给第一节点,从而第一节点可以对应调整其时钟值。After calculating the clock synchronization parameter, the sink node directly sends the clock synchronization parameter to the first node, so that the first node can adjust its clock value accordingly.

结合第一方面,在第一方面的某些实现方式中,所述策略下发报文还包括汇聚节点的标识,所述汇聚节点不是所述第一节点,在所述第一节点获取时钟同步参数之前,所述方法还包括:所述控制节点向所述汇聚节点发送所述策略下发报文;所述执行节点向所述汇聚节点发送时间信息上传报文,所述时间信息上传报文包括所述时间信息;所述汇聚节点根据所述时钟同步算法和所述时间信息确定所述时钟同步参数;所述汇聚节点向所述控制节点发送所述时钟同步参数;所述控制节点向所述第一节点发送参数发布报文,所述参数发布报文包括所述时钟同步参数。In combination with the first aspect, in certain implementations of the first aspect, the policy delivery message also includes an identifier of a convergence node, and the convergence node is not the first node. Before the first node obtains the clock synchronization parameters, the method also includes: the control node sends the policy delivery message to the convergence node; the execution node sends a time information upload message to the convergence node, and the time information upload message includes the time information; the convergence node determines the clock synchronization parameters based on the clock synchronization algorithm and the time information; the convergence node sends the clock synchronization parameters to the control node; the control node sends a parameter release message to the first node, and the parameter release message includes the clock synchronization parameters.

在该实施例中,控制节点会确定汇聚节点,在汇聚节点计算出时钟同步参数后,将该时钟同步参数发送给控制节点,由控制节点将该时钟同步参数携带在参数发布报文中发送给第一节点,使得该第一节点可以相应地调节时钟值。汇聚节点到第一节点的路由路径比控制节点到第一节点的路由路径长,从而控制节点可以辅助该时钟同步参数的发布。该实施例中时间信息上传报文的具体结构可以参考图7及相关描述,参数发布报文的具体结构可以参考图8及相关描述。In this embodiment, the control node determines the aggregation node, and after the aggregation node calculates the clock synchronization parameter, the clock synchronization parameter is sent to the control node, and the control node carries the clock synchronization parameter in the parameter release message and sends it to the first node, so that the first node can adjust the clock value accordingly. The routing path from the aggregation node to the first node is longer than the routing path from the control node to the first node, so that the control node can assist in the release of the clock synchronization parameter. The specific structure of the time information upload message in this embodiment can refer to Figure 7 and related descriptions, and the specific structure of the parameter release message can refer to Figure 8 and related descriptions.

结合第一方面,在第一方面的一些实现方式中,所述策略下发报文还包括汇聚节点的标识,所述汇聚节点是所述第一节点,在所述第一节点获取时钟同步参数之前,所述方法还包括:所述执行节点向所述汇聚节点发送时间信息上传报文,所述时间信息上传报文包括所述时间信息;所述第一节点获取时钟同步参数,包括:所述第一节点根据所述时间信息,确定所述时钟同步参数。In combination with the first aspect, in some implementations of the first aspect, the policy sending message also includes an identifier of a convergence node, and the convergence node is the first node. Before the first node obtains the clock synchronization parameters, the method also includes: the execution node sends a time information upload message to the convergence node, and the time information upload message includes the time information; the first node obtains the clock synchronization parameters, including: the first node determines the clock synchronization parameters based on the time information.

在该实施例中,当第一节点具有较高的计算和存储能力时,控制节点可以将汇聚节点确定为第一节点,在执行节点执行完时钟同步算法后,可以将对应的时间信息发送给第一节点计算时钟同步参数。In this embodiment, when the first node has higher computing and storage capabilities, the control node may determine the aggregation node as the first node, and after the execution node executes the clock synchronization algorithm, the corresponding time information may be sent to the first node to calculate the clock synchronization parameters.

结合第一方面,在第一方面的某些实现方式中,所述订阅请求报文包括所述第一节点的标识、所述第二节点的标识和时钟同步精度。In combination with the first aspect, in some implementations of the first aspect, the subscription request message includes an identifier of the first node, an identifier of the second node, and a clock synchronization accuracy.

在该实施例中,订阅请求报文中包括第一节点和第二节点的标识和时钟同步精度,从而控制节点可以根据订阅请求报文中携带的同步需求和控制节点确定的第一节点和第二节点的通信介质信息,确定合适的时钟同步算法。可选的,该订阅请求报文中还可以包括第一节点的通信介质类型、第一节点对时钟同步服务性能和同步流程执行方面的需求,例如时钟同步周期、时钟同步收敛速度、时间信息标记方式,同步报文处理优先级等。In this embodiment, the subscription request message includes the identifiers of the first node and the second node and the clock synchronization accuracy, so that the control node can determine the appropriate clock synchronization algorithm according to the synchronization requirements carried in the subscription request message and the communication medium information of the first node and the second node determined by the control node. Optionally, the subscription request message may also include the communication medium type of the first node, the first node's requirements for clock synchronization service performance and synchronization process execution, such as clock synchronization period, clock synchronization convergence speed, time information marking method, synchronization message processing priority, etc.

结合第一方面,在第一方面的某些实现方式中,所述策略下发报文还包括以下至少一项:第一时钟同步周期、所述同步报文的类型、所述同步报文传输使用的通信介质、所述同步报文的时间信息标记方式,所述第一时钟同步周期是所述执行节点执行所述时钟同步算法的周期。In combination with the first aspect, in certain implementation methods of the first aspect, the policy-sent message also includes at least one of the following: a first clock synchronization cycle, the type of the synchronization message, the communication medium used for transmission of the synchronization message, and a time information marking method of the synchronization message, wherein the first clock synchronization cycle is the period in which the execution node executes the clock synchronization algorithm.

控制节点可以例如根据第一节点和第二节点的可用剩余电量、网络资源使用情况和通信情况等因素确定第一时钟同步周期。控制节点还可以确定同步报文的类型、同步报文传输使用的通信介质和时间信息标记方式等。The control node may determine the first clock synchronization period, for example, based on factors such as the available remaining power of the first node and the second node, network resource usage, and communication conditions. The control node may also determine the type of synchronization message, the communication medium used for synchronization message transmission, and the time information marking method.

结合第一方面,在第一方面的某些实现方式中,所述方法还包括:所述控制节点根据所述第一节点的时钟值的置信区间的长度和所述时钟同步精度,确定第二时钟同步周期;或者,所述控制节点根据所述第二节点的时钟值的置信区间的长度和所述时钟同步精度,确定所述第二时钟同步周期;其中,所述第一节点的时钟值的置信区间或者所述第二节点的时钟值的置信区间是所述汇聚节点根据所述时钟同步参数确定的;所述控制节点向所述执行节点发送所述第二时钟同步周期;所述执行节点根据所述第二时钟同步周期,执行所述时钟同步算法;其中,当所述置信区间的长度与所述时钟同步精度的差值的绝对值小于第一预设阈值时,所述第一时钟同步周期是所述第二时钟同步周期;当所述置信区间的长度与所述时钟同步精度的差值的绝对值大于第一预设阈值且所述置信区间的长度大于所述时钟同步精度时,所述第二时钟同步周期小于所述第一时钟同步周期,当所述置信区间的长度与所述时钟同步精度的差值的绝对值大于第一预设阈值且所述置信区间的长度小于所述时钟同步精度时,所述第二同步周期大于所述第一时钟同步周期。In combination with the first aspect, in some implementations of the first aspect, the method further includes: the control node determines a second clock synchronization period according to the length of the confidence interval of the clock value of the first node and the clock synchronization accuracy; or, the control node determines the second clock synchronization period according to the length of the confidence interval of the clock value of the second node and the clock synchronization accuracy; wherein the confidence interval of the clock value of the first node or the confidence interval of the clock value of the second node is determined by the convergence node according to the clock synchronization parameter; the control node sends the second clock synchronization period to the execution node; the execution node executes the clock synchronization algorithm according to the second clock synchronization period; wherein, when the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is less than a first preset threshold, the first clock synchronization period is the second clock synchronization period; when the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is greater than the first preset threshold and the length of the confidence interval is greater than the clock synchronization accuracy, the second clock synchronization period is less than the first clock synchronization period, and when the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is greater than the first preset threshold and the length of the confidence interval is less than the clock synchronization accuracy, the second synchronization period is greater than the first clock synchronization period.

在该实施例中,控制节点可以例如根据网络资源使用情况和通信情况更新时钟同步周期,控制节点可以根据第一节点要求的时钟同步精度以及第一节点的时钟值的置信区间的长度,调整时钟同步周期。满足第一节点时钟同步精度需求的同时,减小时钟同步的整体开销。In this embodiment, the control node can update the clock synchronization period according to the network resource usage and communication conditions, and the control node can adjust the clock synchronization period according to the clock synchronization accuracy required by the first node and the length of the confidence interval of the clock value of the first node. While meeting the clock synchronization accuracy requirement of the first node, the overall overhead of clock synchronization is reduced.

可选的,控制节点在确定第二同步周期后,可以基于网络资源使用情况和网络节点负载,更新同步报文传输使用的通信介质,同步报文的时间信息标记方式、同步报文的类型等。Optionally, after determining the second synchronization period, the control node may update the communication medium used for synchronization message transmission, the time information marking method of the synchronization message, the type of synchronization message, etc. based on network resource usage and network node load.

结合第一方面,在第一方面的一些实现方式中,所述方法还包括:所述控制节点根据所述第一节点的时钟值的置信区间的长度和所述时钟同步精度,确定第二时钟同步周期;或者,所述控制节点根据所述第二节点的时钟值的置信区间的长度和所述时钟同步精度,确定所述第二时钟同步周期;其中,所述第一节点的时钟值的置信区间或者所述第二节点的时钟值的置信区间是所述汇聚节点根据所述时钟同步参数确定的;所述控制节点向所述执行节点发送所述第二时钟同步周期;所述执行节点根据所述第二时钟同步周期,执行所述时钟同步算法;其中,当所述置信区间的长度小于所述时钟同步精度时,所述第二同步周期大于所述第一时钟同步周期;当所述置信区间的长度大于所述时钟同步精度且所述置信区间的长度与所述时钟同步精度的差值的绝对值小于第一预设阈值时,所述第二时钟同步周期为所述第一时钟同步周期;当所述置信区间的长度大于所述时钟同步精度且所述置信区间的长度与所述时钟同步精度的差值的绝对值大于第一预设阈值时,所述第二时钟同步周期小于所述第一时钟同步周期。In combination with the first aspect, in some implementations of the first aspect, the method further includes: the control node determines a second clock synchronization period according to the length of the confidence interval of the clock value of the first node and the clock synchronization accuracy; or, the control node determines the second clock synchronization period according to the length of the confidence interval of the clock value of the second node and the clock synchronization accuracy; wherein the confidence interval of the clock value of the first node or the confidence interval of the clock value of the second node is determined by the convergence node according to the clock synchronization parameter; the control node sends the second clock synchronization period to the execution node; the execution node executes the clock synchronization algorithm according to the second clock synchronization period; wherein, when the length of the confidence interval is less than the clock synchronization accuracy, the second synchronization period is greater than the first clock synchronization period; when the length of the confidence interval is greater than the clock synchronization accuracy and the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is less than a first preset threshold, the second clock synchronization period is the first clock synchronization period; when the length of the confidence interval is greater than the clock synchronization accuracy and the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is greater than a first preset threshold, the second clock synchronization period is less than the first clock synchronization period.

在该实施例中,为了减小系统的开销,在置信区间的长度小于时钟同步精度时,即增大时钟同步周期。当置信区间的长度大于时钟同步精度且两者的差值的绝对值大于第一预设阈值将时钟同步周期调小,从而满足需要时钟同步服务的节点的时钟同步精度的需求。In this embodiment, in order to reduce the system overhead, when the length of the confidence interval is less than the clock synchronization accuracy, the clock synchronization period is increased. When the length of the confidence interval is greater than the clock synchronization accuracy and the absolute value of the difference between the two is greater than the first preset threshold, the clock synchronization period is reduced to meet the clock synchronization accuracy requirements of the nodes that need the clock synchronization service.

结合第一方面,在第一方面的某些实现方式中,所述执行节点包括所述第一节点和所述第二节点,所述第一节点和所述第二节点位于不同的局域网中,所述时间信息包括第一同步报文的TSF接收时间和所述第一同步报文的TSF发送时间、第二同步报文的TSF接收时间和所述第二同步报文的TSF发送时间;所述时钟同步参数包括以下至少一项:所述第一节点的TSF时钟值和所述第二节点的TSF时钟值的差值以及所述第一节点的TSF时钟频率和所述第二节点的TSF时钟频率的差值;其中,所述执行节点执行所述时钟同步算法,包括:所述第一节点将所述第一节点的TSF时钟与所述第一节点的系统时钟对齐;所述第一节点向所述第二节点发送所述第一同步报文;所述第二节点向所述第一节点发送所述第二同步报文;所述第二节点根据所述时钟同步参数,调节所述第二节点的TSF时钟;所述第二节点根据调整后的TSF时钟,调节所述第二节点的系统时钟。In combination with the first aspect, in certain implementations of the first aspect, the execution node includes the first node and the second node, the first node and the second node are located in different local area networks, the time information includes the TSF reception time of the first synchronization message and the TSF sending time of the first synchronization message, the TSF reception time of the second synchronization message, and the TSF sending time of the second synchronization message; the clock synchronization parameters include at least one of the following: the difference between the TSF clock value of the first node and the TSF clock value of the second node and the difference between the TSF clock frequency of the first node and the TSF clock frequency of the second node; wherein, the execution node executes the clock synchronization algorithm, including: the first node aligns the TSF clock of the first node with the system clock of the first node; the first node sends the first synchronization message to the second node; the second node sends the second synchronization message to the first node; the second node adjusts the TSF clock of the second node according to the clock synchronization parameters; the second node adjusts the system clock of the second node according to the adjusted TSF clock.

在该实施例中,第一节点和第二节点在不同的局域网中时,传统的基于WiFi TSF的时钟同步算法无法使用,本申请实施例通过改进该时钟同步算法,通过使得第一节点的系统时钟与TSF时钟对齐-第二节点的TSF时钟向第一节点的TSF时钟对齐-第二节点的系统时钟向第二节点的TSF时钟对齐的步骤实现不同局域网的两个节点时钟对齐,使得本申请实施例提供的时钟同步算法适用范围较广。该实施例中,第一同步报文的TSF发送时间以及第二同步报文的TSF接收时间是指第一节点将系统时钟和TSF时钟同步后,发送第一同步报文和接收第二同步报文时的TSF时钟值,并且,第一节点的TSF时钟值和第二节点的TSF时钟值的差值以及第一节点的TSF时钟频率和第二节点的TSF时钟频率的差值也均是以第一节点将系统时钟和TSF时钟同步后的TSF时钟与第二节点的TSF时钟的时钟偏移值以及时钟频率偏差。该实施例的具体细节可以参考图11及相关描述。In this embodiment, when the first node and the second node are in different local area networks, the traditional clock synchronization algorithm based on WiFi TSF cannot be used. The embodiment of the present application improves the clock synchronization algorithm, and realizes the clock alignment of two nodes in different local area networks by aligning the system clock of the first node with the TSF clock-aligning the TSF clock of the second node to the TSF clock of the first node-aligning the system clock of the second node to the TSF clock of the second node, so that the clock synchronization algorithm provided by the embodiment of the present application has a wider scope of application. In this embodiment, the TSF sending time of the first synchronization message and the TSF receiving time of the second synchronization message refer to the TSF clock value when the first node sends the first synchronization message and receives the second synchronization message after synchronizing the system clock and the TSF clock, and the difference between the TSF clock value of the first node and the TSF clock value of the second node and the difference between the TSF clock frequency of the first node and the TSF clock frequency of the second node are also based on the clock offset value and clock frequency deviation of the TSF clock after the first node synchronizes the system clock and the TSF clock with the TSF clock of the second node. The specific details of this embodiment can be referred to Figure 11 and related descriptions.

可选的,也可以先由第二节点将系统时钟和TSF时钟对齐,再将第一节点的TSF时钟向第二节点的TSF时钟对齐,最后第一节点的系统时钟向第一节点的TSF时钟对齐的方式实现第一节点和第二节点之间的时钟同步。Optionally, the clock synchronization between the first node and the second node can be achieved by first aligning the system clock and the TSF clock of the second node, then aligning the TSF clock of the first node to the TSF clock of the second node, and finally aligning the system clock of the first node to the TSF clock of the first node.

结合第一方面,在第一方面的某些实现方式中,所述执行节点包括所述第一节点、所述第二节点和第三节点,所述时间信息包括:所述第一节点接收多个参考报文的时间和所述第二节点接收所述多个参考报文的时间;所述时钟同步参数包括以下至少一项:所述第一节点的时钟值和所述第二节点的时钟值的差值以及所述第一节点的时钟频率和所述第二节点的时钟频率的差值;或者,所述时钟同步参数包括以下至少一项:所述第一节点的时钟值和第一参考时钟值的差值、所述第二节点的时钟值和所述第一参考时钟值的差值、所述第一节点的时钟频率和第一参考时钟频率的差值以及所述第二节点的时钟频率和所述第一参考时钟频率的差值;其中,所述执行节点执行所述时钟同步算法包括:所述第三节点向所述第一节点和所述第二节点发送所述多个参考报文。In combination with the first aspect, in some implementations of the first aspect, the execution node includes the first node, the second node and the third node, and the time information includes: the time when the first node receives multiple reference messages and the time when the second node receives the multiple reference messages; the clock synchronization parameters include at least one of the following: the difference between the clock value of the first node and the clock value of the second node and the difference between the clock frequency of the first node and the clock frequency of the second node; or, the clock synchronization parameters include at least one of the following: the difference between the clock value of the first node and the first reference clock value, the difference between the clock value of the second node and the first reference clock value, the difference between the clock frequency of the first node and the first reference clock frequency, and the difference between the clock frequency of the second node and the first reference clock frequency; wherein, the execution node executes the clock synchronization algorithm including: the third node sends the multiple reference messages to the first node and the second node.

在该实施例中,当第一节点和第二节点时钟同步时,控制节点额外选定第三节点,第三节点向第一节点和第二节点发送多个参考报文,第一节点和第二节点向汇聚节点上传该多个参考报文的接收时间,接收该多个参考报文的时间可以通过时间戳或时钟计数器的数值表示,从而汇聚节点计算第一节点和第二节点的时钟同步参数。本申请实施例提供的时钟同步算法通过单向报文传输的形式执行时钟同步过程,可以减小传统双向报文交互过程报文往返时延不对称带来的误差,且能够屏蔽报文封装、信道接入等协议栈通信以及系统调度处理时延的不确定性,能够提高时钟同步精度。该实施例的具体细节可以参考图10及其相关描述。In this embodiment, when the clocks of the first node and the second node are synchronized, the control node additionally selects a third node, and the third node sends multiple reference messages to the first node and the second node. The first node and the second node upload the reception time of the multiple reference messages to the aggregation node, and the time of receiving the multiple reference messages can be represented by the numerical value of the timestamp or the clock counter, so that the aggregation node calculates the clock synchronization parameters of the first node and the second node. The clock synchronization algorithm provided in the embodiment of the present application performs the clock synchronization process in the form of unidirectional message transmission, which can reduce the error caused by the asymmetric round-trip delay of the message in the traditional two-way message interaction process, and can shield the uncertainty of the protocol stack communication such as message encapsulation and channel access and the system scheduling processing delay, and can improve the clock synchronization accuracy. For specific details of this embodiment, please refer to Figure 10 and its related description.

结合第一方面,在第一方面的某些实现方式中,所述时间信息还包括所述多个参考报文的发送时间。In combination with the first aspect, in certain implementations of the first aspect, the time information also includes sending times of the multiple reference messages.

结合第一方面,在第一方面的某些实现方式中,所述执行节点不包括所述第一节点,所述时钟同步参数包括第二参考时钟值和/或第二参考时钟频率,所述方法还包括:所述第一节点根据所述时钟同步参数,更新所述第一节点的时钟为所述第二参考时钟值和/或第二参考时钟频率。In combination with the first aspect, in certain implementations of the first aspect, the execution node does not include the first node, the clock synchronization parameters include a second reference clock value and/or a second reference clock frequency, and the method further includes: the first node updates the clock of the first node to the second reference clock value and/or the second reference clock frequency based on the clock synchronization parameters.

在该实施例中,控制节点确定的执行时钟同步算法的节点不包括第一节点,而是选择例如具有较丰富的存储、计算能力的节点作为执行节点。这些节点可以持续地执行多种不同的时钟同步算法,构成本地的时钟同步域。时间信息可以由这些执行节点上传给汇聚节点计算时钟同步参数,接着汇聚节点将时钟同步参数发送给控制节点,控制节点可以确定经过校准的第二参考时钟值和/或第二参考时钟频率,并将该第二参考时钟值和/或第二参考时钟频率发送给第一节点,从而实现第一节点和第二节点的时钟同步。该第二参考时钟值和/或第二参考时钟频率还可以发给第二节点,从而第二节点也能够将本地系统时钟调节到第二参考时钟值和/或第二参考时钟频率,由此第一节点和第二节点实现时钟同步。当第一节点和第二节点不需要时钟同步时,可以取消该时钟同步服务的订阅。本申请实施例提供的时钟同步方案可以避免部署专用设备,摆脱特定模组安装和组网拓扑等的限制,从而可以便捷地进行时钟同步操作,实现计算和存储能力极其有限的节点的时钟同步。In this embodiment, the node for executing the clock synchronization algorithm determined by the control node does not include the first node, but selects a node with richer storage and computing capabilities as the execution node. These nodes can continuously execute a variety of different clock synchronization algorithms to form a local clock synchronization domain. The time information can be uploaded by these execution nodes to the convergence node to calculate the clock synchronization parameters, and then the convergence node sends the clock synchronization parameters to the control node. The control node can determine the calibrated second reference clock value and/or second reference clock frequency, and send the second reference clock value and/or second reference clock frequency to the first node, thereby realizing the clock synchronization of the first node and the second node. The second reference clock value and/or the second reference clock frequency can also be sent to the second node, so that the second node can also adjust the local system clock to the second reference clock value and/or the second reference clock frequency, thereby realizing the clock synchronization of the first node and the second node. When the first node and the second node do not need clock synchronization, the subscription of the clock synchronization service can be canceled. The clock synchronization scheme provided in the embodiment of the present application can avoid the deployment of special equipment, get rid of the limitations of specific module installation and networking topology, so that the clock synchronization operation can be conveniently performed to realize the clock synchronization of nodes with extremely limited computing and storage capabilities.

第二方面,提供了一种时钟同步方法,包括:第一节点向控制节点发送订阅请求报文,所述订阅请求报文用于订阅所述第一节点与第二节点的时钟同步服务,所述第二节点是与所述第一节点进行时钟同步的节点;所述第一节点接收来自所述控制节点的策略下发报文,所述策略下发报文是所述控制节点根据所述订阅请求报文确定的,所述策略下发报文包括时钟同步算法和执行节点的标识,所述执行节点包括所述第一节点和所述第二节点;所述第一节点根据所述策略下发报文,执行所述时钟同步算法;所述第一节点获取时钟同步参数,所述时钟同步参数用于所述时钟同步服务,所述时钟同步参数是根据所述时钟同步算法确定的。In a second aspect, a clock synchronization method is provided, including: a first node sends a subscription request message to a control node, the subscription request message is used to subscribe to the clock synchronization service of the first node and a second node, and the second node is a node that performs clock synchronization with the first node; the first node receives a policy delivery message from the control node, the policy delivery message is determined by the control node according to the subscription request message, the policy delivery message includes a clock synchronization algorithm and an identifier of an execution node, and the execution node includes the first node and the second node; the first node executes the clock synchronization algorithm according to the policy delivery message; the first node obtains clock synchronization parameters, the clock synchronization parameters are used for the clock synchronization service, and the clock synchronization parameters are determined according to the clock synchronization algorithm.

结合第二方面,在第二方面的某些实现方式中,所述策略下发报文还包括汇聚节点的标识,所述汇聚节点不是所述第一节点,所述方法还包括:所述第一节点向所述汇聚节点发送时间信息上传报文,所述时间信息上传报文包括时间信息,所述时间信息用于所述汇聚节点确定所述时钟同步参数,所述时间信息包括与所述执行节点执行所述时钟同步算法发送同步报文关联的时钟计数器的数值或时间戳,和/或,所述时间信息包括与所述执行节点执行所述时钟同步算法接收所述同步报文关联的时钟计数器的数值或时间戳;所述第一节点从所述汇聚节点或所述控制节点接收参数发布报文,所述参数发布报文包括所述时钟同步参数。In combination with the second aspect, in certain implementations of the second aspect, the policy delivery message also includes an identifier of a convergence node, and the convergence node is not the first node. The method also includes: the first node sends a time information upload message to the convergence node, and the time information upload message includes time information, and the time information is used by the convergence node to determine the clock synchronization parameters, and the time information includes a value or timestamp of a clock counter associated with the execution node executing the clock synchronization algorithm to send a synchronization message, and/or, the time information includes a value or timestamp of a clock counter associated with the execution node executing the clock synchronization algorithm to receive the synchronization message; the first node receives a parameter release message from the convergence node or the control node, and the parameter release message includes the clock synchronization parameters.

结合第二方面,在第二方面的某些实现方式中,所述订阅请求报文包括所述第一节点的标识、所述第二节点的标识和时钟同步精度。In combination with the second aspect, in some implementations of the second aspect, the subscription request message includes an identifier of the first node, an identifier of the second node, and a clock synchronization accuracy.

结合第二方面,在第二方面的某些实现方式中,所述策略下发报文还包括以下至少一项:第一时钟同步周期、所述同步报文的类型、所述同步报文传输使用的通信介质、所述同步报文的时间信息标记方式,所述第一时钟同步周期是所述执行节点执行所述时钟同步算法的周期。In combination with the second aspect, in certain implementation methods of the second aspect, the policy-sent message also includes at least one of the following: a first clock synchronization cycle, the type of the synchronization message, the communication medium used for transmission of the synchronization message, and a time information marking method of the synchronization message, wherein the first clock synchronization cycle is the period in which the execution node executes the clock synchronization algorithm.

结合第二方面,在第二方面的某些实现方式中,所述方法还包括:所述第一节点从所述控制节点接收第二时钟同步周期;所述第一节点根据所述第二时钟同步周期,执行所述时钟同步算法;其中所述第二时钟同步周期是所述控制节点根据所述第一节点的时钟值的置信区间的长度和所述同步精度确定的,或者所述第二时钟同步周期是所述控制节点根据所述第二节点的时钟值的置信区间的长度和所述同步精度确定的;所述第一节点的时钟值的置信区间或所述第二节点的时钟值的置信区间是所述汇聚节点根据所述时钟同步参数确定的;当所述置信区间的长度与所述时钟同步精度的差值的绝对值小于第一预设阈值时,所述第一时钟同步周期是所述第二时钟同步周期;当所述置信区间的长度与所述时钟同步精度的差值的绝对值大于第一预设阈值且所述置信区间的长度大于所述时钟同步精度时,所述第二时钟同步周期小于所述第一时钟同步周期,当所述置信区间的长度与所述时钟同步精度的差值的绝对值大于第一预设阈值且所述置信区间的长度小于所述时钟同步精度时,所述第二同步周期大于所述第一时钟同步周期。结合第二方面,在第二方面的一些实现方式中,所述方法还包括:所述第一节点从所述控制节点接收第二时钟同步周期;所述第一节点根据所述第二时钟同步周期,执行所述时钟同步算法;其中所述第二时钟同步周期是所述控制节点根据所述第一节点的时钟值的置信区间的长度和所述同步精度确定的,或者所述第二时钟同步周期是所述控制节点根据所述第二节点的时钟值的置信区间的长度和所述同步精度确定的;所述第一节点的时钟值的置信区间或所述第二节点的时钟值的置信区间是所述汇聚节点根据所述时钟同步参数确定的;其中,当所述置信区间的长度小于所述时钟同步精度时,所述第二同步周期大于所述第一时钟同步周期;当所述置信区间的长度大于所述时钟同步精度且所述置信区间的长度与所述时钟同步精度的差值的绝对值小于第一预设阈值时,所述第二时钟同步周期为所述第一时钟同步周期;当所述置信区间的长度大于所述时钟同步精度且所述置信区间的长度与所述时钟同步精度的差值的绝对值大于第一预设阈值时,所述第二时钟同步周期小于所述第一时钟同步周期。In combination with the second aspect, in some implementations of the second aspect, the method further includes: the first node receives a second clock synchronization cycle from the control node; the first node executes the clock synchronization algorithm according to the second clock synchronization cycle; wherein the second clock synchronization cycle is determined by the control node according to the length of the confidence interval of the clock value of the first node and the synchronization accuracy, or the second clock synchronization cycle is determined by the control node according to the length of the confidence interval of the clock value of the second node and the synchronization accuracy; the confidence interval of the clock value of the first node or the confidence interval of the clock value of the second node is determined by the convergence node according to the clock synchronization parameter; when the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is less than a first preset threshold, the first clock synchronization cycle is the second clock synchronization cycle; when the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is greater than the first preset threshold and the length of the confidence interval is greater than the clock synchronization accuracy, the second clock synchronization cycle is less than the first clock synchronization cycle, and when the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is greater than the first preset threshold and the length of the confidence interval is less than the clock synchronization accuracy, the second synchronization cycle is greater than the first clock synchronization cycle. In combination with the second aspect, in some implementations of the second aspect, the method further includes: the first node receives a second clock synchronization cycle from the control node; the first node executes the clock synchronization algorithm according to the second clock synchronization cycle; wherein the second clock synchronization cycle is determined by the control node according to the length of the confidence interval of the clock value of the first node and the synchronization accuracy, or the second clock synchronization cycle is determined by the control node according to the length of the confidence interval of the clock value of the second node and the synchronization accuracy; the confidence interval of the clock value of the first node or the confidence interval of the clock value of the second node is determined by the convergence node according to the clock synchronization parameter; wherein, when the length of the confidence interval is less than the clock synchronization accuracy, the second synchronization cycle is greater than the first clock synchronization cycle; when the length of the confidence interval is greater than the clock synchronization accuracy and the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is less than a first preset threshold, the second clock synchronization cycle is the first clock synchronization cycle; when the length of the confidence interval is greater than the clock synchronization accuracy and the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is greater than a first preset threshold, the second clock synchronization cycle is less than the first clock synchronization cycle.

结合第二方面,在第二方面的某些实现方式中,所述第一节点和第二节点位于不同的局域网中,所述时间信息包括第一同步报文的TSF接收时间和所述第一同步报文的TSF发送时间、第二同步报文的TSF接收时间和所述第二同步报文的TSF发送时间;所述时钟同步参数包括以下至少一项:所述第一节点的TSF时钟值和所述第二节点的TSF时钟值的差值以及所述第一节点的TSF时钟频率和所述第二节点的TSF时钟频率的差值;所述第一节点执行所述时钟同步算法包括:所述第一节点接收来自所述第二节点的所述第一同步报文;所述第一节点向所述第二节点发送所述第二同步报文;所述第一节点根据所述时钟同步参数,调节所述第一节点的TSF时钟;所述第一节点根据调整后的TSF时钟,调节所述第一节点的系统时钟。In combination with the second aspect, in certain implementations of the second aspect, the first node and the second node are located in different local area networks, and the time information includes the TSF reception time of the first synchronization message and the TSF sending time of the first synchronization message, the TSF reception time of the second synchronization message, and the TSF sending time of the second synchronization message; the clock synchronization parameters include at least one of the following: the difference between the TSF clock value of the first node and the TSF clock value of the second node and the difference between the TSF clock frequency of the first node and the TSF clock frequency of the second node; the first node executes the clock synchronization algorithm including: the first node receives the first synchronization message from the second node; the first node sends the second synchronization message to the second node; the first node adjusts the TSF clock of the first node according to the clock synchronization parameters; the first node adjusts the system clock of the first node according to the adjusted TSF clock.

结合第二方面,在第二方面的某些实现方式中,所述执行节点还包括第三节点,所述时间信息包括:所述第一节点接收所述多个参考报文的时间和所述第二节点接收所述多个参考报文的时间;所述时钟同步参数包括以下至少一项:所述第一节点的时钟值和所述第二节点的时钟值的差值以及所述第一节点的时钟频率和所述第二节点的时钟频率的差值;或者,所述时钟同步参数包括以下至少一项:所述第一节点的时钟值和第一参考时钟值的差值、所述第二节点的时钟值和所述第一参考时钟值的差值、所述第一节点的时钟频率和第一参考时钟频率的差值、所述第二节点的时钟频率和所述第一参考时钟频率的差值;其中,所述第一节点执行所述时钟同步算法包括:所述第一节点接收来自所述第三节点的所述多个参考报文。In combination with the second aspect, in some implementations of the second aspect, the execution node also includes a third node, and the time information includes: the time when the first node receives the multiple reference messages and the time when the second node receives the multiple reference messages; the clock synchronization parameters include at least one of the following: the difference between the clock value of the first node and the clock value of the second node and the difference between the clock frequency of the first node and the clock frequency of the second node; or, the clock synchronization parameters include at least one of the following: the difference between the clock value of the first node and the first reference clock value, the difference between the clock value of the second node and the first reference clock value, the difference between the clock frequency of the first node and the first reference clock frequency, and the difference between the clock frequency of the second node and the first reference clock frequency; wherein, the first node executes the clock synchronization algorithm including: the first node receives the multiple reference messages from the third node.

结合第二方面,在第二方面的某些实现方式中,所述时间信息还包括所述多个参考报文的发送时间。In combination with the second aspect, in certain implementations of the second aspect, the time information also includes sending times of the multiple reference messages.

第三方面,提供了一种时钟同步方法,包括:控制节点接收来自第一节点的订阅请求报文,所述订阅请求报文用于订阅所述第一节点与第二节点的时钟同步服务,所述第二节点是与所述第一节点进行时钟同步的节点;所述控制节点根据所述订阅请求报文,确定策略下发报文,所述策略下发报文用于确定时钟同步参数,所述时钟同步参数用于所述时钟同步服务。According to a third aspect, a clock synchronization method is provided, comprising: a control node receives a subscription request message from a first node, the subscription request message is used to subscribe to a clock synchronization service between the first node and a second node, the second node being a node that performs clock synchronization with the first node; the control node determines a policy sending message based on the subscription request message, the policy sending message is used to determine clock synchronization parameters, and the clock synchronization parameters are used for the clock synchronization service.

结合第三方面,在第三方面的某些实现方式中,所述策略下发报文包括时钟同步算法和执行节点的标识,所述方法还包括:所述控制节点向执行节点发送所述策略下发报文,以便于所述执行节点获取执行所述时钟同步算法过程中的时间信息,所述时间信息包括所述与执行节点发送所述同步报文关联的时钟计数器的数值或时间戳,和/或,所述时间信息包括与所述执行节点接收所述同步报文关联的时钟计数器的数值或时间戳。In combination with the third aspect, in certain implementations of the third aspect, the policy delivery message includes an identifier of a clock synchronization algorithm and an execution node, and the method further includes: the control node sends the policy delivery message to the execution node so that the execution node obtains time information during the execution of the clock synchronization algorithm, the time information includes the value or timestamp of the clock counter associated with the execution node sending the synchronization message, and/or the time information includes the value or timestamp of the clock counter associated with the execution node receiving the synchronization message.

结合第三方面,在第三方面的某些实现方式中,所述策略下发报文还包括汇聚节点的标识,所述时钟同步参数是所述汇聚节点根据从所述执行节点获取的所述时间信息确定的;所述方法还包括:所述控制节点向所述汇聚节点发送所述策略下发报文。In combination with the third aspect, in certain implementations of the third aspect, the policy delivery message also includes an identifier of the aggregation node, and the clock synchronization parameter is determined by the aggregation node based on the time information obtained from the execution node; the method also includes: the control node sending the policy delivery message to the aggregation node.

结合第三方面,在第三方面的某些实现方式中,所述方法还包括:所述控制节点接收来自所述汇聚节点的所述时钟同步参数;所述控制节点向所述第一节点发送参数发布报文,所述参数发布报文包括所述时钟同步参数。In combination with the third aspect, in certain implementations of the third aspect, the method further includes: the control node receiving the clock synchronization parameters from the aggregation node; the control node sending a parameter publishing message to the first node, and the parameter publishing message includes the clock synchronization parameters.

结合第三方面,在第三方面的某些实现方式中,所述订阅请求报文包括所述第一节点的标识、所述第二节点的标识和时钟同步精度。In combination with the third aspect, in certain implementations of the third aspect, the subscription request message includes an identifier of the first node, an identifier of the second node, and a clock synchronization accuracy.

结合第三方面,在第三方面的某些实现方式中,所述订阅请求报文还包括以下至少一项:第一时钟同步周期、所述同步报文的类型、所述同步报文传输使用的通信介质、所述同步报文的时间信息标记方式,所述第一时钟同步周期是所述执行节点执行所述时钟同步算法的周期。In combination with the third aspect, in certain implementations of the third aspect, the subscription request message also includes at least one of the following: a first clock synchronization cycle, the type of the synchronization message, the communication medium used for transmission of the synchronization message, and a time information marking method of the synchronization message, wherein the first clock synchronization cycle is the period in which the execution node executes the clock synchronization algorithm.

结合第三方面,在第三方面的某些实现方式中,所述方法还包括:所述控制节点根据所述第一节点的时钟值的置信区间的长度和所述时钟同步精度确定所述第二时钟同步周期,或者,所述控制节点根据所述第二节点的时钟值的置信区间的长度和所述时钟同步精度确定所述第二时钟同步周期,所述第一节点的时钟值的置信区间或所述第二节点的时钟值的置信区间是根据所述时钟同步参数确定的;当所述置信区间的长度与所述时钟同步精度的差值的绝对值小于第一预设阈值时,所述第一时钟同步周期是所述第二时钟同步周期;当所述置信区间的长度与所述时钟同步精度的差值的绝对值大于第一预设阈值且所述置信区间的长度大于所述时钟同步精度时,所述第二时钟同步周期小于所述第一时钟同步周期,当所述置信区间的长度与所述时钟同步精度的差值的绝对值大于第一预设阈值且所述置信区间小于所述时钟同步精度时,所述第二同步周期大于所述第一时钟同步周期。In combination with the third aspect, in certain implementations of the third aspect, the method further includes: the control node determines the second clock synchronization period according to the length of the confidence interval of the clock value of the first node and the clock synchronization accuracy, or the control node determines the second clock synchronization period according to the length of the confidence interval of the clock value of the second node and the clock synchronization accuracy, and the confidence interval of the clock value of the first node or the confidence interval of the clock value of the second node is determined according to the clock synchronization parameter; when the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is less than a first preset threshold, the first clock synchronization period is the second clock synchronization period; when the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is greater than a first preset threshold and the length of the confidence interval is greater than the clock synchronization accuracy, the second clock synchronization period is less than the first clock synchronization period, and when the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is greater than the first preset threshold and the confidence interval is less than the clock synchronization accuracy, the second synchronization period is greater than the first clock synchronization period.

结合第三方面,在第三方面的某些实现方式中,所述方法还包括:所述控制节点根据所述第一节点的时钟值的置信区间的长度和所述时钟同步精度确定所述第二时钟同步周期,或者,所述控制节点根据所述第二节点的时钟值的置信区间的长度和所述时钟同步精度确定所述第二时钟同步周期,所述第一节点的时钟值的置信区间或所述第二节点的时钟值的置信区间是根据所述时钟同步参数确定的;其中,当所述置信区间的长度小于所述时钟同步精度时,所述第二同步周期大于所述第一时钟同步周期;当所述置信区间的长度大于所述时钟同步精度且所述置信区间的长度与所述时钟同步精度的差值的绝对值小于第一预设阈值时,所述第二时钟同步周期为所述第一时钟同步周期;当所述置信区间的长度大于所述时钟同步精度且所述置信区间的长度与所述时钟同步精度的差值的绝对值大于第一预设阈值时,所述第二时钟同步周期小于所述第一时钟同步周期。In combination with the third aspect, in certain implementations of the third aspect, the method further includes: the control node determines the second clock synchronization period based on the length of the confidence interval of the clock value of the first node and the clock synchronization accuracy, or the control node determines the second clock synchronization period based on the length of the confidence interval of the clock value of the second node and the clock synchronization accuracy, and the confidence interval of the clock value of the first node or the confidence interval of the clock value of the second node is determined based on the clock synchronization parameter; wherein, when the length of the confidence interval is less than the clock synchronization accuracy, the second synchronization period is greater than the first clock synchronization period; when the length of the confidence interval is greater than the clock synchronization accuracy and the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is less than a first preset threshold, the second clock synchronization period is the first clock synchronization period; when the length of the confidence interval is greater than the clock synchronization accuracy and the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is greater than a first preset threshold, the second clock synchronization period is less than the first clock synchronization period.

第四方面,提供了一种时钟同步方法,包括:汇聚节点接收来自控制节点的策略下发报文,所述策略下发报文是所述控制节点根据第一节点发送的订阅请求报文确定的,所述订阅请求报文用于订阅所述第一节点和第二节点的时钟同步服务,所述策略下发报文包括时钟同步算法、执行节点的标识和所述汇聚节点的标识;所述汇聚节点接收来自执行节点的时间信息上传报文,所述时间信息上传报文包括时间信息,所述时间信息包括与所述执行节点发送所述同步报文关联的时钟计数器的数值或者时间戳,和/或,所述时间信息包括与所述执行节点接收所述同步报文关联的时钟计数器的数值或者时间戳;所述汇聚节点根据所述时钟同步算法和所述时间信息,确定时钟同步参数,所述时钟同步参数用于所述时钟同步服务。In a fourth aspect, a clock synchronization method is provided, comprising: a convergence node receives a policy delivery message from a control node, the policy delivery message is determined by the control node based on a subscription request message sent by a first node, the subscription request message is used to subscribe to the clock synchronization services of the first node and the second node, the policy delivery message includes a clock synchronization algorithm, an identifier of an execution node and an identifier of the convergence node; the convergence node receives a time information upload message from an execution node, the time information upload message includes time information, the time information includes a value or timestamp of a clock counter associated with the execution node sending the synchronization message, and/or the time information includes a value or timestamp of a clock counter associated with the execution node receiving the synchronization message; the convergence node determines clock synchronization parameters based on the clock synchronization algorithm and the time information, and the clock synchronization parameters are used for the clock synchronization service.

结合第四方面,在第四方面的某些实现方式中,所述汇聚节点不是所述第一节点,所述方法还包括:所述汇聚节点向所述第一节点发送参数发布报文,所述参数发布报文包括所述时钟同步参数。In combination with the fourth aspect, in some implementations of the fourth aspect, the aggregation node is not the first node, and the method further includes: the aggregation node sends a parameter publishing message to the first node, and the parameter publishing message includes the clock synchronization parameter.

结合第四方面,在第四方面的某些实现方式中,所述汇聚节点不是所述第一节点,所述方法还包括:所述汇聚节点向所述控制节点发送所述时钟同步参数,以便于所述控制节点向所述第一节点发送参数发布报文,所述参数发布报文包括所述时钟同步参数。In combination with the fourth aspect, in certain implementations of the fourth aspect, the aggregation node is not the first node, and the method also includes: the aggregation node sends the clock synchronization parameters to the control node so that the control node sends a parameter release message to the first node, and the parameter release message includes the clock synchronization parameters.

结合第四方面,在第四方面的某些实现方式中,所述订阅请求报文包括所述第一节点的标识、所述第二节点的标识和时钟同步精度。In combination with the fourth aspect, in certain implementations of the fourth aspect, the subscription request message includes an identifier of the first node, an identifier of the second node, and a clock synchronization accuracy.

结合第四方面,在第四方面的某些实现方式中,所述策略下发报文还包括以下至少一项:第一时钟同步周期、所述同步报文的类型、所述同步报文传输使用的通信介质、所述同步报文的时间信息标记方式,所述第一时钟同步周期是所述执行节点执行所述时钟同步算法的周期。In combination with the fourth aspect, in certain implementation methods of the fourth aspect, the policy-sent message also includes at least one of the following: a first clock synchronization cycle, the type of the synchronization message, the communication medium used for transmission of the synchronization message, and a time information marking method of the synchronization message, wherein the first clock synchronization cycle is the period in which the execution node executes the clock synchronization algorithm.

结合第四方面,在第四方面的某些实现方式中,所述方法还包括:所述汇聚节点根据所述时钟同步参数,确定所述第一节点的时钟值的置信区间和/或所述第二节点的时钟值的置信区间,所述汇聚节点将所述置信区间发送给所述控制节点,以便于所述控制节点根据所述置信区间的长度确定第二时钟同步周期;其中,当所述置信区间的长度与所述时钟同步精度的差值的绝对值小于第一预设阈值时,所述第一时钟同步周期是所述第二时钟同步周期;当所述置信区间的长度与所述时钟同步精度的差值的绝对值大于第一预设阈值且所述置信区间的长度大于所述时钟同步精度时,所述第二时钟同步周期小于所述第一时钟同步周期,当所述置信区间的长度与所述时钟同步精度的差值的绝对值大于第一预设阈值且所述置信区间小于所述时钟同步精度时,所述第二同步周期大于所述第一时钟同步周期。In combination with the fourth aspect, in certain implementations of the fourth aspect, the method further includes: the aggregation node determines the confidence interval of the clock value of the first node and/or the confidence interval of the clock value of the second node based on the clock synchronization parameter, and the aggregation node sends the confidence interval to the control node so that the control node determines the second clock synchronization period based on the length of the confidence interval; wherein, when the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is less than a first preset threshold, the first clock synchronization period is the second clock synchronization period; when the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is greater than a first preset threshold and the length of the confidence interval is greater than the clock synchronization accuracy, the second clock synchronization period is less than the first clock synchronization period, and when the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is greater than a first preset threshold and the confidence interval is less than the clock synchronization accuracy, the second synchronization period is greater than the first clock synchronization period.

结合第四方面,在第四方面的某些实现方式中,所述方法还包括:所述汇聚节点根据所述时钟同步参数,确定所述第一节点的时钟值的置信区间和/或所述第二节点的时钟值的置信区间,所述汇聚节点将所述置信区间发送给所述控制节点,以便于所述控制节点根据所述置信区间的长度确定第二时钟同步周期;其中,当所述置信区间的长度小于所述时钟同步精度时,所述第二同步周期大于所述第一时钟同步周期;当所述置信区间的长度大于所述时钟同步精度且所述置信区间的长度与所述时钟同步精度的差值的绝对值小于第一预设阈值时,所述第二时钟同步周期为所述第一时钟同步周期;当所述置信区间的长度大于所述时钟同步精度且所述置信区间的长度与所述时钟同步精度的差值的绝对值大于第一预设阈值时,所述第二时钟同步周期小于所述第一时钟同步周期。In combination with the fourth aspect, in certain implementations of the fourth aspect, the method also includes: the aggregation node determines the confidence interval of the clock value of the first node and/or the confidence interval of the clock value of the second node based on the clock synchronization parameters, and the aggregation node sends the confidence interval to the control node so that the control node determines the second clock synchronization period based on the length of the confidence interval; wherein, when the length of the confidence interval is less than the clock synchronization accuracy, the second synchronization period is greater than the first clock synchronization period; when the length of the confidence interval is greater than the clock synchronization accuracy and the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is less than a first preset threshold, the second clock synchronization period is the first clock synchronization period; when the length of the confidence interval is greater than the clock synchronization accuracy and the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is greater than a first preset threshold, the second clock synchronization period is less than the first clock synchronization period.

第五方面,提供了一种时钟同步系统,包括:第一节点,用于向所述控制节点发送订阅请求报文,所述订阅请求报文用于订阅所述第一节点与第二节点的时钟同步服务,所述第二节点是与所述第一节点进行时钟同步的节点;控制节点,用于根据所述订阅请求报文,确定策略下发报文,所述策略下发报文包括时钟同步算法;所述第一节点,还用于获取时钟同步参数,所述时钟同步参数用于所述时钟同步服务,所述时钟同步参数是根据所述时钟同步算法确定的。In a fifth aspect, a clock synchronization system is provided, comprising: a first node, used to send a subscription request message to the control node, the subscription request message is used to subscribe to the clock synchronization service of the first node and a second node, the second node is a node that performs clock synchronization with the first node; a control node, used to determine a policy sending message based on the subscription request message, the policy sending message includes a clock synchronization algorithm; the first node is also used to obtain clock synchronization parameters, the clock synchronization parameters are used for the clock synchronization service, and the clock synchronization parameters are determined based on the clock synchronization algorithm.

结合第五方面,在第五方面的某些实现方式中,所述策略下发报文包括执行节点的标识,所述系统还包括执行节点;所述控制节点,还用于向所述执行节点发送所述策略下发报文;所述执行节点用于根据所述策略下发报文,执行所述时钟同步算法,所述时钟同步参数是根据所述执行节点执行所述时钟同步算法发送和/或接收的同步报文的时间信息确定的,所述时间信息包括与所述执行节点发送所述同步报文关联的时钟计数器的数值或者时间戳,和/或,所述时间信息包括与所述执行节点接收所述同步报文关联的时钟计数器的数值或者时间戳。In combination with the fifth aspect, in certain implementations of the fifth aspect, the policy sending message includes an identifier of an execution node, and the system also includes an execution node; the control node is also used to send the policy sending message to the execution node; the execution node is used to execute the clock synchronization algorithm according to the policy sending message, and the clock synchronization parameters are determined based on the time information of the synchronization message sent and/or received by the execution node when executing the clock synchronization algorithm, and the time information includes the value or timestamp of the clock counter associated with the execution node sending the synchronization message, and/or the time information includes the value or timestamp of the clock counter associated with the execution node receiving the synchronization message.

结合第五方面,在第五方面的某些实现方式中,所述策略下发报文还包括汇聚节点的标识,所述汇聚节点不是所述第一节点,所述系统还包括汇聚节点;所述控制节点,还用于向所述汇聚节点发送所述策略下发报文;所述执行节点,还用于向所述汇聚节点发送时间信息上传报文,所述时间信息上传报文包括所述时间信息;所述汇聚节点,用于:根据所述时间信息和所述时钟同步算法确定所述时钟同步参数;向所述第一节点发送参数发布报文,所述参数发布报文包括所述时钟同步参数。In combination with the fifth aspect, in certain implementation methods of the fifth aspect, the policy delivery message also includes an identifier of a convergence node, the convergence node is not the first node, and the system also includes a convergence node; the control node is also used to send the policy delivery message to the convergence node; the execution node is also used to send a time information upload message to the convergence node, and the time information upload message includes the time information; the convergence node is used to: determine the clock synchronization parameters based on the time information and the clock synchronization algorithm; send a parameter release message to the first node, and the parameter release message includes the clock synchronization parameters.

结合第五方面,在第五方面的某些实现方式中,所述策略下发报文还包括汇聚节点的标识,所述汇聚节点不是所述第一节点,所述系统还包括汇聚节点;所述控制节点,还用于向所述汇聚节点发送所述策略下发报文;所述执行节点,还用于向所述汇聚节点发送时间信息上传报文,所述时间信息上传报文包括所述时间信息;所述汇聚节点,用于:根据所述时间信息和所述时钟同步算法确定所述时钟同步参数;向所述控制节点发送所述时钟同步参数;所述控制节点,还用于向所述第一节点发送参数发布报文,所述参数发布报文包括所述时钟同步参数。In combination with the fifth aspect, in certain implementations of the fifth aspect, the policy delivery message also includes an identifier of a convergence node, the convergence node is not the first node, and the system also includes a convergence node; the control node is also used to send the policy delivery message to the convergence node; the execution node is also used to send a time information upload message to the convergence node, and the time information upload message includes the time information; the convergence node is used to: determine the clock synchronization parameters based on the time information and the clock synchronization algorithm; send the clock synchronization parameters to the control node; the control node is also used to send a parameter release message to the first node, and the parameter release message includes the clock synchronization parameters.

结合第五方面,在第五方面的某些实现方式中,所述策略下发报文还包括汇聚节点的标识,所述汇聚节点是所述第一节点;所述执行节点还用于,向所述汇聚节点发送时间信息上传报文,所述时间信息上传报文包括所述时间信息;所述第一节点具体用于:根据所述时间信息,确定所述时钟同步参数。In combination with the fifth aspect, in certain implementation methods of the fifth aspect, the policy sending message also includes an identifier of a convergence node, and the convergence node is the first node; the execution node is also used to send a time information upload message to the convergence node, and the time information upload message includes the time information; the first node is specifically used to: determine the clock synchronization parameters based on the time information.

结合第五方面,在第五方面的某些实现方式中,所述订阅请求报文包括所述第一节点的标识、所述第二节点的标识和时钟同步精度。In combination with the fifth aspect, in certain implementations of the fifth aspect, the subscription request message includes the identifier of the first node, the identifier of the second node, and the clock synchronization accuracy.

结合第五方面,在第五方面的某些实现方式中,所述策略下发报文还包括以下至少一项:第一时钟同步周期、所述同步报文的类型、所述同步报文传输使用的通信介质、所述同步报文的时间信息标记方式,所述第一时钟同步周期是所述执行节点执行所述时钟同步算法的周期。In combination with the fifth aspect, in certain implementation methods of the fifth aspect, the policy-sent message also includes at least one of the following: a first clock synchronization cycle, the type of the synchronization message, the communication medium used for transmission of the synchronization message, and a time information marking method of the synchronization message, wherein the first clock synchronization cycle is the period in which the execution node executes the clock synchronization algorithm.

结合第五方面,在第五方面的某些实现方式中,所述控制节点还用于:根据所述第一节点的时钟值的置信区间的长度和所述时钟同步精度,确定第二时钟同步周期,或者,根据所述第二节点的时钟值的置信区间的长度和所述时钟同步精度,确定第二时钟同步周期,所述第一节点的时钟值的置信区间或所述第二节点的置信区间是所述汇聚节点根据所述时钟同步参数确定的;向所述执行节点发送所述第二时钟同步周期;所述执行节点,还用于根据所述第二时钟同步周期,执行所述时钟同步算法;其中,当所述置信区间的长度与所述时钟同步精度的差值的绝对值小于第一预设阈值时,所述第一时钟同步周期是所述第二时钟同步周期;当所述置信区间的长度与所述时钟同步精度的差值的绝对值大于第一预设阈值且所述置信区间的长度大于所述时钟同步精度时,所述第二时钟同步周期小于所述第一时钟同步周期;当所述置信区间的长度与所述时钟同步精度的差值的绝对值大于第一预设阈值且所述置信区间的长度小于所述时钟同步精度时,所述第二同步周期大于所述第一时钟同步周期。In combination with the fifth aspect, in certain implementations of the fifth aspect, the control node is further used to: determine the second clock synchronization period according to the length of the confidence interval of the clock value of the first node and the clock synchronization accuracy, or determine the second clock synchronization period according to the length of the confidence interval of the clock value of the second node and the clock synchronization accuracy, the confidence interval of the clock value of the first node or the confidence interval of the second node is determined by the aggregation node according to the clock synchronization parameter; send the second clock synchronization period to the execution node; the execution node is further used to execute the clock synchronization algorithm according to the second clock synchronization period; wherein, when the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is less than a first preset threshold, the first clock synchronization period is the second clock synchronization period; when the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is greater than the first preset threshold and the length of the confidence interval is greater than the clock synchronization accuracy, the second clock synchronization period is less than the first clock synchronization period; when the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is greater than the first preset threshold and the length of the confidence interval is less than the clock synchronization accuracy, the second synchronization period is greater than the first clock synchronization period.

结合第五方面,在第五方面的某些实现方式中,所述控制节点还用于:根据所述第一节点的时钟值的置信区间的长度和所述时钟同步精度,确定第二时钟同步周期,或者,根据所述第二节点的时钟值的置信区间的长度和所述时钟同步精度,确定第二时钟同步周期,所述第一节点的时钟值的置信区间或所述第二节点的置信区间是所述汇聚节点根据所述时钟同步参数确定的;向所述执行节点发送所述第二时钟同步周期;所述执行节点,还用于根据所述第二时钟同步周期,执行所述时钟同步算法;其中,当所述置信区间的长度小于所述时钟同步精度时,所述第二同步周期大于所述第一时钟同步周期;当所述置信区间的长度大于所述时钟同步精度且所述置信区间的长度与所述时钟同步精度的差值的绝对值小于第一预设阈值时,所述第二时钟同步周期为所述第一时钟同步周期;当所述置信区间的长度大于所述时钟同步精度且所述置信区间的长度与所述时钟同步精度的差值的绝对值大于第一预设阈值时,所述第二时钟同步周期小于所述第一时钟同步周期。In combination with the fifth aspect, in certain implementations of the fifth aspect, the control node is further used to: determine a second clock synchronization period based on the length of a confidence interval of the clock value of the first node and the clock synchronization accuracy, or determine the second clock synchronization period based on the length of a confidence interval of the clock value of the second node and the clock synchronization accuracy, the confidence interval of the clock value of the first node or the confidence interval of the second node being determined by the aggregation node based on the clock synchronization parameters; send the second clock synchronization period to the execution node; the execution node is further used to execute the clock synchronization algorithm based on the second clock synchronization period; wherein, when the length of the confidence interval is less than the clock synchronization accuracy, the second synchronization period is greater than the first clock synchronization period; when the length of the confidence interval is greater than the clock synchronization accuracy and the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is less than a first preset threshold, the second clock synchronization period is the first clock synchronization period; when the length of the confidence interval is greater than the clock synchronization accuracy and the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is greater than a first preset threshold, the second clock synchronization period is less than the first clock synchronization period.

结合第五方面,在第五方面的某些实现方式中,所述执行节点包括所述第一节点和所述第二节点,所述第一节点和所述第二节点位于不同的局域网中,所述时间信息包括第一同步报文的TSF接收时间和所述第一同步报文的TSF发送时间、第二同步报文的TSF接收时间和所述第二同步报文的TSF发送时间;所述时钟同步参数包括以下至少一项:所述第一节点的TSF时钟值和所述第二节点的TSF时钟值的差值以及所述第一节点的TSF时钟频率和所述第二节点的TSF时钟频率的差值;所述第一节点,具体用于:将所述第一节点的TSF时钟与所述第一节点的系统时钟对齐;向所述第二节点发送所述第一同步报文;所述第二节点,具体用于:向所述第一节点发送所述第二同步报文;根据所述时钟同步参数,调节所述第二节点的TSF时钟;根据调整后的TSF时钟,调节所述第二节点的系统时钟。In combination with the fifth aspect, in certain implementations of the fifth aspect, the execution node includes the first node and the second node, the first node and the second node are located in different local area networks, the time information includes the TSF reception time of the first synchronization message and the TSF sending time of the first synchronization message, the TSF reception time of the second synchronization message, and the TSF sending time of the second synchronization message; the clock synchronization parameters include at least one of the following: the difference between the TSF clock value of the first node and the TSF clock value of the second node and the difference between the TSF clock frequency of the first node and the TSF clock frequency of the second node; the first node is specifically used to: align the TSF clock of the first node with the system clock of the first node; send the first synchronization message to the second node; the second node is specifically used to: send the second synchronization message to the first node; adjust the TSF clock of the second node according to the clock synchronization parameters; adjust the system clock of the second node according to the adjusted TSF clock.

结合第五方面,在第五方面的某些实现方式中,所述执行节点包括所述第一节点、所述第二节点和第三节点,所述时间信息包括:所述第一节点接收所述多个参考报文的时间和所述第二节点接收所述多个参考报文的时间;所述时钟同步参数包括以下至少一项:所述第一节点的时钟值和所述第二节点的时钟值的差值以及所述第一节点的时钟频率和所述第二节点的时钟频率的差值;或者,所述时钟同步参数包括以下至少一项:所述第一节点的时钟值和第一参考时钟值的差值、所述第二节点的时钟值和所述第一参考时钟值的差值、所述第一节点的时钟频率和第一参考时钟频率的差值、所述第二节点的时钟频率和所述第一参考时钟频率的差值;其中,所述第三节点,具体用于向所述第一节点和所述第二节点发送所述多个参考报文。In combination with the fifth aspect, in certain implementations of the fifth aspect, the execution nodes include the first node, the second node and the third node, and the time information includes: the time when the first node receives the multiple reference messages and the time when the second node receives the multiple reference messages; the clock synchronization parameters include at least one of the following: the difference between the clock value of the first node and the clock value of the second node and the difference between the clock frequency of the first node and the clock frequency of the second node; or, the clock synchronization parameters include at least one of the following: the difference between the clock value of the first node and the first reference clock value, the difference between the clock value of the second node and the first reference clock value, the difference between the clock frequency of the first node and the first reference clock frequency, and the difference between the clock frequency of the second node and the first reference clock frequency; wherein the third node is specifically used to send the multiple reference messages to the first node and the second node.

结合第五方面,在第五方面的某些实现方式中,所述时间信息还包括所述多个参考报文的发送时间。In combination with the fifth aspect, in certain implementations of the fifth aspect, the time information also includes the sending time of the multiple reference messages.

结合第五方面,在第五方面的某些实现方式中,所述执行节点不包括所述第一节点,所述时钟同步参数包括第二参考时钟值和第二参考时钟频率,所述第一节点还用于:根据所述时钟同步参数,更新所述第一节点的时钟为所述第二参考时钟值和/或所述第二参考时钟频率。In combination with the fifth aspect, in certain implementations of the fifth aspect, the execution node does not include the first node, the clock synchronization parameters include a second reference clock value and a second reference clock frequency, and the first node is further used to: update the clock of the first node to the second reference clock value and/or the second reference clock frequency according to the clock synchronization parameters.

第六方面,提供了一种时钟同步装置,所述时钟同步装置是第一节点,该时钟同步装置包括:收发单元,用于向控制节点发送订阅请求报文,所述订阅请求报文用于订阅所述第一节点与第二节点的时钟同步服务,所述第二节点是与所述第一节点进行时钟同步的节点;所述收发单元,还用于接收来自所述控制节点的策略下发报文,所述策略下发报文是所述控制节点根据所述订阅请求报文确定的,所述策略下发报文包括时钟同步算法和执行节点的标识,所述执行节点包括第一节点和所述第二节点;处理单元,用于根据所述策略下发报文,执行所述时钟同步算法;所述收发单元,还用于获取时钟同步参数,所述时钟同步参数用于所述时钟同步服务,所述时钟同步参数是根据所述时钟同步算法确定的。In a sixth aspect, a clock synchronization device is provided, which is a first node and includes: a transceiver unit, used to send a subscription request message to a control node, wherein the subscription request message is used to subscribe to the clock synchronization service of the first node and the second node, and the second node is a node that performs clock synchronization with the first node; the transceiver unit is also used to receive a policy message from the control node, wherein the policy message is determined by the control node according to the subscription request message, and the policy message includes a clock synchronization algorithm and an identifier of an execution node, and the execution node includes a first node and the second node; a processing unit, used to execute the clock synchronization algorithm according to the policy message; the transceiver unit is also used to obtain clock synchronization parameters, wherein the clock synchronization parameters are used for the clock synchronization service, and the clock synchronization parameters are determined according to the clock synchronization algorithm.

结合第六方面,在第六方面的某些实现方式中,所述策略下发报文还包括汇聚节点的标识,所述汇聚节点不是所述第一节点,所述收发单元,还用于:向所述汇聚节点发送时间信息上传报文,所述时间信息上传报文包括时间信息,所述时间信息用于所述汇聚节点确定所述时钟同步参数,所述时间信息包括与所述执行节点执行所述时钟同步算法发送同步报文关联的时钟计数器的数值或时间戳,和/或,所述时间信息包括与所述执行节点执行所述时钟同步算法接收所述同步报文关联的时钟计数器的数值或时间戳;从所述汇聚节点接收参数发布报文,所述参数发布报文包括所述时钟同步参数。In combination with the sixth aspect, in certain implementation methods of the sixth aspect, the policy sending message also includes an identifier of a convergence node, and the convergence node is not the first node. The transceiver unit is also used to: send a time information upload message to the convergence node, the time information upload message includes time information, and the time information is used by the convergence node to determine the clock synchronization parameters, the time information includes the value or timestamp of the clock counter associated with the execution node executing the clock synchronization algorithm to send the synchronization message, and/or the time information includes the value or timestamp of the clock counter associated with the execution node executing the clock synchronization algorithm to receive the synchronization message; receive a parameter release message from the convergence node, and the parameter release message includes the clock synchronization parameters.

结合第六方面,在第六方面的某些实现方式中,所述订阅请求报文包括所述第一节点的标识、所述第二节点的标识和时钟同步精度。In combination with the sixth aspect, in certain implementations of the sixth aspect, the subscription request message includes the identifier of the first node, the identifier of the second node, and the clock synchronization accuracy.

结合第六方面,在第六方面的某些实现方式中,所述策略下发报文还包括以下至少一项:第一时钟同步周期、所述同步报文的类型、所述同步报文传输使用的通信介质、所述同步报文的时间信息标记方式,所述第一时钟同步周期是所述执行节点执行所述时钟同步算法的周期。In combination with the sixth aspect, in certain implementation methods of the sixth aspect, the policy-sent message also includes at least one of the following: a first clock synchronization cycle, the type of the synchronization message, the communication medium used for transmission of the synchronization message, and a time information marking method of the synchronization message, wherein the first clock synchronization cycle is the period in which the execution node executes the clock synchronization algorithm.

结合第六方面,在第六方面的某些实现方式中,所述收发单元,还用于:从所述控制节点接收第二时钟同步周期;所述处理单元,还用于根据所述第二时钟同步周期,执行所述时钟同步算法;其中所述第二时钟同步周期是所述控制节点根据所述第一节点的时钟值的置信区间的长度和所述时钟同步精度确定的,或者,所述第二时钟同步周期是所述控制节点根据所述第二节点的时钟值的置信区间的长度和所述时钟同步精度确定的;所述第一节点的时钟值的置信区间和所述第二节点的时钟值的置信区间是所述汇聚节点根据所述时钟同步参数确定的;其中,当所述置信区间的长度与所述时钟同步精度的差值的绝对值小于第一预设阈值时,所述第一时钟同步周期是所述第二时钟同步周期;当所述置信区间的长度与所述时钟同步精度的差值的绝对值大于第一预设阈值且所述置信区间的长度大于所述时钟同步精度时,所述第二时钟同步周期小于所述第一时钟同步周期;当所述置信区间的长度与所述时钟同步精度的差值的绝对值大于第一预设阈值且所述置信区间小于所述时钟同步精度时,所述第二同步周期大于所述第一时钟同步周期。In combination with the sixth aspect, in certain implementations of the sixth aspect, the transceiver unit is further used to: receive a second clock synchronization period from the control node; the processing unit is further used to execute the clock synchronization algorithm according to the second clock synchronization period; wherein the second clock synchronization period is determined by the control node according to the length of the confidence interval of the clock value of the first node and the clock synchronization accuracy, or the second clock synchronization period is determined by the control node according to the length of the confidence interval of the clock value of the second node and the clock synchronization accuracy; the confidence interval of the clock value of the first node and the confidence interval of the clock value of the second node are the aggregation node Determined according to the clock synchronization parameters; wherein, when the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is less than a first preset threshold, the first clock synchronization period is the second clock synchronization period; when the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is greater than a first preset threshold and the length of the confidence interval is greater than the clock synchronization accuracy, the second clock synchronization period is less than the first clock synchronization period; when the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is greater than a first preset threshold and the confidence interval is less than the clock synchronization accuracy, the second synchronization period is greater than the first clock synchronization period.

结合第六方面,在第六方面的某些实现方式中,所述收发单元,还用于:从所述控制节点接收第二时钟同步周期;所述处理单元,还用于根据所述第二时钟同步周期,执行所述时钟同步算法;其中所述第二时钟同步周期是所述控制节点根据所述第一节点的时钟值的置信区间的长度和所述时钟同步精度确定的,或者,所述第二时钟同步周期是所述控制节点根据所述第二节点的时钟值的置信区间的长度和所述时钟同步精度确定的;所述第一节点的时钟值的置信区间和所述第二节点的时钟值的置信区间是所述汇聚节点根据所述时钟同步参数确定的;其中,当所述置信区间的长度小于所述时钟同步精度时,所述第二同步周期大于所述第一时钟同步周期;当所述置信区间的长度大于所述时钟同步精度且所述置信区间的长度与所述时钟同步精度的差值的绝对值小于第一预设阈值时,所述第二时钟同步周期为所述第一时钟同步周期;当所述置信区间的长度大于所述时钟同步精度且所述置信区间的长度与所述时钟同步精度的差值的绝对值大于第一预设阈值时,所述第二时钟同步周期小于所述第一时钟同步周期。In combination with the sixth aspect, in certain implementations of the sixth aspect, the transceiver unit is further used to: receive a second clock synchronization period from the control node; the processing unit is further used to execute the clock synchronization algorithm according to the second clock synchronization period; wherein the second clock synchronization period is determined by the control node according to the length of the confidence interval of the clock value of the first node and the clock synchronization accuracy, or the second clock synchronization period is determined by the control node according to the length of the confidence interval of the clock value of the second node and the clock synchronization accuracy; the confidence interval of the clock value of the first node and the confidence interval of the clock value of the second node are determined by the aggregation node according to the clock synchronization parameters; wherein, when the length of the confidence interval is less than the clock synchronization accuracy, the second synchronization period is greater than the first clock synchronization period; when the length of the confidence interval is greater than the clock synchronization accuracy and the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is less than a first preset threshold, the second clock synchronization period is the first clock synchronization period; when the length of the confidence interval is greater than the clock synchronization accuracy and the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is greater than a first preset threshold, the second clock synchronization period is less than the first clock synchronization period.

结合第六方面,在第六方面的某些实现方式中,所述第一节点和第二节点位于不同的局域网中,所述时间信息包括第一同步报文的TSF接收时间和所述第一同步报文的TSF发送时间、第二同步报文的TSF接收时间和所述第二同步报文的TSF发送时间;所述时钟同步参数包括以下至少一项:所述第一节点的TSF时钟值和所述第二节点的TSF时钟值的差值以及所述第一节点的TSF时钟频率和所述第二节点的TSF时钟频率的差值;所述第一节点执行所述时钟同步算法包括:所述第一节点接收来自所述第二节点的所述第一同步报文;所述第一节点向所述第二节点发送所述第二同步报文;所述第一节点根据所述时钟同步参数,调节所述第一节点的TSF时钟;所述第一节点根据调整后的TSF时钟,调节所述第一节点的系统时钟。In combination with the sixth aspect, in certain implementations of the sixth aspect, the first node and the second node are located in different local area networks, and the time information includes the TSF reception time of the first synchronization message and the TSF sending time of the first synchronization message, the TSF reception time of the second synchronization message, and the TSF sending time of the second synchronization message; the clock synchronization parameters include at least one of the following: the difference between the TSF clock value of the first node and the TSF clock value of the second node and the difference between the TSF clock frequency of the first node and the TSF clock frequency of the second node; the first node executes the clock synchronization algorithm including: the first node receives the first synchronization message from the second node; the first node sends the second synchronization message to the second node; the first node adjusts the TSF clock of the first node according to the clock synchronization parameters; the first node adjusts the system clock of the first node according to the adjusted TSF clock.

结合第六方面,在第六方面的某些实现方式中,所述执行节点还包括第三节点,所述时间信息包括:所述第一节点接收所述多个参考报文的时间戳和所述第二节点接收所述多个参考报文的时间;所述时钟同步参数包括以下至少一项:所述第一节点的时钟值和所述第二节点的时钟值的差值以及所述第一节点的时钟频率和所述第二节点的时钟频率的差值;或者,所述时钟同步参数包括以下至少一项:所述第一节点的时钟值和第一参考时钟值的差值、所述第二节点的时钟值和所述第一参考时钟值的差值、所述第一节点的时钟频率和第一参考时钟频率的差值、所述第二节点的时钟频率和所述第一参考时钟频率的差值;其中,所述处理单元包括第二收发子单元,用于接收来自所述第三节点的所述多个参考报文。In combination with the sixth aspect, in certain implementations of the sixth aspect, the execution node also includes a third node, and the time information includes: the timestamp of the first node receiving the multiple reference messages and the time when the second node receives the multiple reference messages; the clock synchronization parameters include at least one of the following: the difference between the clock value of the first node and the clock value of the second node and the difference between the clock frequency of the first node and the clock frequency of the second node; or, the clock synchronization parameters include at least one of the following: the difference between the clock value of the first node and the first reference clock value, the difference between the clock value of the second node and the first reference clock value, the difference between the clock frequency of the first node and the first reference clock frequency, and the difference between the clock frequency of the second node and the first reference clock frequency; wherein the processing unit includes a second transceiver subunit for receiving the multiple reference messages from the third node.

结合第六方面,在第六方面的某些实现方式中,所述时间信息还包括所述多个参考报文的发送时间。In combination with the sixth aspect, in certain implementations of the sixth aspect, the time information also includes the sending time of the multiple reference messages.

第七方面,提供了一种时钟同步装置,所述时钟同步装置是控制节点,所述时钟同步装置包括:收发单元,用于接收来自第一节点的订阅请求报文,所述订阅请求报文用于订阅所述第一节点与第二节点的时钟同步服务,所述第二节点是与所述第一节点进行时钟同步的节点;处理单元,用于根据所述订阅请求报文,确定策略下发报文,所述策略下发报文用于确定时钟同步参数,所述时钟同步参数用于所述时钟同步服务。In the seventh aspect, a clock synchronization device is provided, which is a control node, and includes: a transceiver unit, used to receive a subscription request message from a first node, wherein the subscription request message is used to subscribe to the clock synchronization service of the first node and a second node, and the second node is a node that performs clock synchronization with the first node; a processing unit, used to determine a policy sending message based on the subscription request message, wherein the policy sending message is used to determine clock synchronization parameters, and the clock synchronization parameters are used for the clock synchronization service.

结合第七方面,在第七方面的某些实现方式中,所述策略下发报文包括时钟同步算法和执行节点的标识,所述收发单元,还用于向执行节点发送所述策略下发报文,以便于所述执行节点获取执行所述时钟同步算法过程中的时间信息,所述时间信息包括与所述执行节点发送所述同步报文关联的时钟计数器的数值或时间戳,和/或,所述时间信息包括与所述执行节点接收所述同步报文关联的时钟计数器的数值或时间戳。In combination with the seventh aspect, in certain implementation methods of the seventh aspect, the policy delivery message includes an identifier of a clock synchronization algorithm and an execution node, and the transceiver unit is further used to send the policy delivery message to the execution node so that the execution node can obtain time information during the execution of the clock synchronization algorithm, wherein the time information includes a value or timestamp of a clock counter associated with the execution node sending the synchronization message, and/or the time information includes a value or timestamp of a clock counter associated with the execution node receiving the synchronization message.

结合第七方面,在第七方面的某些实现方式中,所述策略下发报文还包括汇聚节点的标识,所述时钟同步参数是所述汇聚节点根据从所述执行节点获取的所述时间信息确定的;所述收发单元,还用于所述控制节点向所述汇聚节点发送所述策略下发报文。In combination with the seventh aspect, in certain implementation methods of the seventh aspect, the policy delivery message also includes an identifier of the aggregation node, and the clock synchronization parameter is determined by the aggregation node based on the time information obtained from the execution node; the transceiver unit is also used by the control node to send the policy delivery message to the aggregation node.

结合第七方面,在第七方面的某些实现方式中,所述收发单元,还用于接收来自所述汇聚节点的所述时钟同步参数;向所述第一节点发送参数发布报文,所述参数发布报文包括所述时钟同步参数。In combination with the seventh aspect, in certain implementations of the seventh aspect, the transceiver unit is further used to receive the clock synchronization parameters from the aggregation node; and send a parameter publishing message to the first node, wherein the parameter publishing message includes the clock synchronization parameters.

结合第七方面,在第七方面的某些实现方式中,所述订阅请求报文包括所述第一节点的标识、所述第二节点的标识和时钟同步精度。In combination with the seventh aspect, in certain implementations of the seventh aspect, the subscription request message includes the identifier of the first node, the identifier of the second node, and the clock synchronization accuracy.

结合第七方面,在第七方面的某些实现方式中,所述策略下发报文还包括以下至少一项:第一时钟同步周期、所述同步报文的类型、所述同步报文传输使用的通信介质、所述同步报文的时间信息标记方式,所述第一时钟同步周期是所述执行节点执行所述时钟同步算法的周期。In combination with the seventh aspect, in certain implementation methods of the seventh aspect, the policy-sent message also includes at least one of the following: a first clock synchronization cycle, the type of the synchronization message, the communication medium used for transmission of the synchronization message, and a time information marking method of the synchronization message, wherein the first clock synchronization cycle is the period in which the execution node executes the clock synchronization algorithm.

结合第七方面,在第七方面的某些实现方式中,所述处理单元,还用于根据所述第一节点的时钟值的置信区间的长度和所述时钟同步精度确定第二时钟同步周期,或者,根据所述第二节点的时钟值的置信区间的长度和所述时钟同步精度确定所述第二时钟同步周期,所述第一节点的时钟值的置信区间或所述第二节点的时钟值的置信区间是所述汇聚节点根据所述时钟同步参数确定的;其中,当所述置信区间的长度与所述时钟同步精度的差值的绝对值小于第一预设阈值时,所述第一时钟同步周期是所述第二时钟同步周期;当所述置信区间的长度与所述时钟同步精度的差值的绝对值大于第一预设阈值且所述置信区间的长度大于所述时钟同步精度时,所述第二时钟同步周期小于所述第一时钟同步周期;当所述置信区间的长度与所述时钟同步精度的差值的绝对值大于第一预设阈值且所述置信区间的长度小于所述时钟同步精度时,所述第二同步周期大于所述第一时钟同步周期。In combination with the seventh aspect, in certain implementations of the seventh aspect, the processing unit is further used to determine the second clock synchronization period based on the length of the confidence interval of the clock value of the first node and the clock synchronization accuracy, or to determine the second clock synchronization period based on the length of the confidence interval of the clock value of the second node and the clock synchronization accuracy, the confidence interval of the clock value of the first node or the confidence interval of the clock value of the second node is determined by the aggregation node according to the clock synchronization parameters; wherein, when the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is less than a first preset threshold, the first clock synchronization period is the second clock synchronization period; when the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is greater than a first preset threshold and the length of the confidence interval is greater than the clock synchronization accuracy, the second clock synchronization period is less than the first clock synchronization period; when the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is greater than a first preset threshold and the length of the confidence interval is less than the clock synchronization accuracy, the second synchronization period is greater than the first clock synchronization period.

结合第七方面,在第七方面的某些实现方式中,所述处理单元,还用于根据所述第一节点的时钟值的置信区间的长度和所述时钟同步精度确定第二时钟同步周期,或者,根据所述第二节点的时钟值的置信区间的长度和所述时钟同步精度确定所述第二时钟同步周期,所述第一节点的时钟值的置信区间或所述第二节点的时钟值的置信区间是所述汇聚节点根据所述时钟同步参数确定的;其中,当所述置信区间的长度小于所述时钟同步精度时,所述第二同步周期大于所述第一时钟同步周期;当所述置信区间的长度大于所述时钟同步精度且所述置信区间的长度与所述时钟同步精度的差值的绝对值小于第一预设阈值时,所述第二时钟同步周期为所述第一时钟同步周期;当所述置信区间的长度大于所述时钟同步精度且所述置信区间的长度与所述时钟同步精度的差值的绝对值大于第一预设阈值时,所述第二时钟同步周期小于所述第一时钟同步周期。In combination with the seventh aspect, in certain implementations of the seventh aspect, the processing unit is further used to determine the second clock synchronization period based on the length of the confidence interval of the clock value of the first node and the clock synchronization accuracy, or to determine the second clock synchronization period based on the length of the confidence interval of the clock value of the second node and the clock synchronization accuracy, the confidence interval of the clock value of the first node or the confidence interval of the clock value of the second node is determined by the aggregation node according to the clock synchronization parameters; wherein, when the length of the confidence interval is less than the clock synchronization accuracy, the second synchronization period is greater than the first clock synchronization period; when the length of the confidence interval is greater than the clock synchronization accuracy and the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is less than a first preset threshold, the second clock synchronization period is the first clock synchronization period; when the length of the confidence interval is greater than the clock synchronization accuracy and the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is greater than a first preset threshold, the second clock synchronization period is less than the first clock synchronization period.

第八方面,提供了一种时钟同步装置,所述时钟同步装置是汇聚节点,所述时钟同步装置包括收发单元,用于接收来自控制节点的策略下发报文,所述策略下发报文是所述控制节点根据第一节点发送的订阅请求报文确定的,所述订阅请求报文用于订阅所述第一节点和第二节点的时钟同步服务,所述策略下发报文包括时钟同步算法;接收来自执行节点的时间信息上传报文,所述时间信息上传报文包括时间信息,所述时间信息包括与所述执行节点发送所述同步报文关联的时钟计数器的数值或者时间戳,和/或,所述时间信息包括与所述执行节点接收所述同步报文关联的时钟计数器的数值或者时间戳;处理单元,用于根据所述时钟同步算法和所述时间信息,确定时钟同步参数,所述时钟同步参数用于所述时钟同步服务。In an eighth aspect, a clock synchronization device is provided, which is a convergence node, and the clock synchronization device includes a transceiver unit, which is used to receive a policy message from a control node, and the policy message is determined by the control node according to a subscription request message sent by the first node, and the subscription request message is used to subscribe to the clock synchronization service of the first node and the second node, and the policy message includes a clock synchronization algorithm; receiving a time information upload message from an execution node, and the time information upload message includes time information, and the time information includes a value or timestamp of a clock counter associated with the execution node sending the synchronization message, and/or, the time information includes a value or timestamp of a clock counter associated with the execution node receiving the synchronization message; a processing unit, which is used to determine clock synchronization parameters according to the clock synchronization algorithm and the time information, and the clock synchronization parameters are used for the clock synchronization service.

结合第八方面,在第八方面的某些实现方式中,所述汇聚节点不是所述第一节点,所述收发单元,还用于向所述第一节点发送参数发布报文,所述参数发布报文包括所述时钟同步参数。In combination with the eighth aspect, in certain implementations of the eighth aspect, the aggregation node is not the first node, and the transceiver unit is further used to send a parameter publishing message to the first node, and the parameter publishing message includes the clock synchronization parameter.

结合第八方面,在第八方面的某些实现方式中,所述收发单元,还用于向所述控制节点发送所述时钟同步参数,以便于所述控制节点向所述第一节点发送参数发布报文,所述参数发布报文包括所述时钟同步参数。In combination with the eighth aspect, in certain implementations of the eighth aspect, the transceiver unit is further used to send the clock synchronization parameter to the control node, so that the control node sends a parameter publishing message to the first node, and the parameter publishing message includes the clock synchronization parameter.

结合第八方面,在第八方面的某些实现方式中,所述订阅请求报文包括所述第一节点的标识、所述第二节点的标识和时钟同步精度。In combination with the eighth aspect, in certain implementations of the eighth aspect, the subscription request message includes the identifier of the first node, the identifier of the second node, and the clock synchronization accuracy.

结合第八方面,在第八方面的某些实现方式中,所述策略下发报文还包括以下至少一项:第一时钟同步周期、所述同步报文的类型、所述同步报文传输使用的通信介质、所述同步报文的时间信息标记方式,所述第一时钟同步周期是所述执行节点执行所述时钟同步算法的周期。In combination with the eighth aspect, in certain implementation methods of the eighth aspect, the policy-sent message also includes at least one of the following: a first clock synchronization cycle, the type of the synchronization message, the communication medium used for transmission of the synchronization message, and a time information marking method of the synchronization message, wherein the first clock synchronization cycle is the period in which the execution node executes the clock synchronization algorithm.

结合第八方面,在第八方面的某些实现方式中,所述处理单元,还用于根据所述时钟同步精度,确定所述第一节点或所述第二节点的时钟值的置信区间;所述收发单元,还用于向所述控制节点发送所述第一节点或所述第二节点的时钟值的置信区间,以便于所述控制节点确定第二时钟同步周期;其中,当所述置信区间的长度与所述时钟同步精度的差值的绝对值小于第一预设阈值时,所述第一时钟同步周期是所述第二时钟同步周期;当所述置信区间的长度与所述时钟同步精度的差值的绝对值大于第一预设阈值且所述置信区间的长度大于所述时钟同步精度时,所述第二时钟同步周期小于所述第一时钟同步周期,当所述置信区间的长度d与所述时钟同步精度的差值的绝对值大于第一预设阈值且所述置信区间的长度小于所述时钟同步精度时,所述第二同步周期大于所述第一时钟同步周期。In combination with the eighth aspect, in certain implementations of the eighth aspect, the processing unit is further used to determine a confidence interval of the clock value of the first node or the second node based on the clock synchronization accuracy; the transceiver unit is further used to send the confidence interval of the clock value of the first node or the second node to the control node, so that the control node can determine a second clock synchronization period; wherein, when the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is less than a first preset threshold, the first clock synchronization period is the second clock synchronization period; when the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is greater than a first preset threshold and the length of the confidence interval is greater than the clock synchronization accuracy, the second clock synchronization period is less than the first clock synchronization period, and when the absolute value of the difference between the length d of the confidence interval and the clock synchronization accuracy is greater than a first preset threshold and the length of the confidence interval is less than the clock synchronization accuracy, the second synchronization period is greater than the first clock synchronization period.

结合第八方面,在第八方面的某些实现方式中,所述处理单元,还用于根据所述时钟同步精度,确定所述第一节点或所述第二节点的时钟值的置信区间;所述收发单元,还用于向所述控制节点发送所述第一节点或所述第二节点的时钟值的置信区间,以便于所述控制节点确定第二时钟同步周期;其中,当所述置信区间的长度小于所述时钟同步精度时,所述第二同步周期大于所述第一时钟同步周期;当所述置信区间的长度大于所述时钟同步精度且所述置信区间的长度与所述时钟同步精度的差值的绝对值小于第一预设阈值时,所述第二时钟同步周期为所述第一时钟同步周期;当所述置信区间的长度大于所述时钟同步精度且所述置信区间的长度与所述时钟同步精度的差值的绝对值大于第一预设阈值时,所述第二时钟同步周期小于所述第一时钟同步周期。In combination with the eighth aspect, in certain implementations of the eighth aspect, the processing unit is further used to determine the confidence interval of the clock value of the first node or the second node based on the clock synchronization accuracy; the transceiver unit is further used to send the confidence interval of the clock value of the first node or the second node to the control node, so that the control node can determine a second clock synchronization period; wherein, when the length of the confidence interval is less than the clock synchronization accuracy, the second synchronization period is greater than the first clock synchronization period; when the length of the confidence interval is greater than the clock synchronization accuracy and the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is less than a first preset threshold, the second clock synchronization period is the first clock synchronization period; when the length of the confidence interval is greater than the clock synchronization accuracy and the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is greater than a first preset threshold, the second clock synchronization period is less than the first clock synchronization period.

第九方面,提供了一种时钟同步方法,用于时钟同步系统,所述时钟同步系统包括第一节点、第二节点和第三节点,所述第一节点和所述第二节点是需要进行时钟同步的节点,所述方法包括:所述第三节点向所述第一节点和所述第二节点发送R个参考报文;根据时间信息,确定所述第一节点和所述第二节点的时钟偏移值和/或时钟频率偏差,所述时间信息包括所述R个参考报文的接收时间;所述第一节点和/或所述第二节点根据所述时钟偏移值和/或所述时钟频率偏差,进行时钟同步。In a ninth aspect, a clock synchronization method is provided for a clock synchronization system, wherein the clock synchronization system comprises a first node, a second node and a third node, wherein the first node and the second node are nodes that require clock synchronization, and the method comprises: the third node sends R reference messages to the first node and the second node; based on time information, the clock offset value and/or clock frequency deviation of the first node and the second node is determined, wherein the time information includes the reception time of the R reference messages; and the first node and/or the second node performs clock synchronization based on the clock offset value and/or the clock frequency deviation.

在该实施例中,由第三节点向需要时钟同步的第一节点和第二节点发送参考报文,并且根据参考报文的接收时间,可以确定第一节点和第二节点的时钟偏移值和/或时钟频率偏差。可以由第一节点或第二节点或者第三节点确定该时钟偏移值和/或时钟频率偏差,也可以由其他计算或处理能力较强的节点计算该时钟偏移值和/或时钟频率偏差,本申请对此不做限定。In this embodiment, a reference message is sent by a third node to a first node and a second node that need clock synchronization, and the clock offset value and/or clock frequency deviation of the first node and the second node can be determined according to the reception time of the reference message. The clock offset value and/or clock frequency deviation can be determined by the first node, the second node, or the third node, or can be calculated by other nodes with strong computing or processing capabilities, and this application does not limit this.

本申请实施例提供的时钟同步方法通过单向报文传输的形式执行时钟同步过程,可以减小传统双向报文交互过程报文往返时延不对称带来的误差,且能够屏蔽报文封装、信道接入等协议栈通信以及系统调度处理时延的不确定性,能够提高时钟同步精度。该实施例的具体细节可以参考图10及其相关描述。The clock synchronization method provided in the embodiment of the present application performs the clock synchronization process in the form of unidirectional message transmission, which can reduce the error caused by the asymmetric round-trip delay of the traditional two-way message interaction process, and can shield the uncertainty of protocol stack communication such as message encapsulation and channel access and system scheduling processing delay, and can improve the clock synchronization accuracy. For specific details of this embodiment, please refer to Figure 10 and its related description.

结合第九方面,在第九方面的某些实现方式中,在忽略所述第一节点和所述第二节点的时钟频率偏差且所述第三节点和第一节点之间报文通信时延的不确定性部分以及所述第三节点和所述第二节点之间的报文通信时延的不确定性部分满足正态分布的情况下,所述第一节点和所述第二节点的时钟偏移值θoffset满足以下公式:In combination with the ninth aspect, in some implementations of the ninth aspect, when the clock frequency deviation of the first node and the second node is ignored and the uncertainty part of the message communication delay between the third node and the first node and the uncertainty part of the message communication delay between the third node and the second node satisfy a normal distribution, the clock offset value θ offset of the first node and the second node satisfies the following formula:

其中,所述T2,i是所述第一节点对第i个参考报文的接收时间,所述T3,i是所述第二节点对所述第i个参考报文的接收时间。Wherein, the T 2,i is the time when the first node receives the i-th reference message, and the T 3,i is the time when the second node receives the i-th reference message.

结合第九方面,在第九方面的某些实现方式中,所述时间信息还包括所述参考报文的发送时间。In combination with the ninth aspect, in certain implementations of the ninth aspect, the time information also includes the sending time of the reference message.

结合第九方面,在第九方面的某些实现方式中,在不忽略所述第一节点和所述第二节点的时钟频率偏差且所述第三节点和第一节点之间报文通信时延的不确定性部分以及所述第三节点和所述第二节点之间的报文通信时延的不确定性部分满足正态分布的情况下,所述第一节点和所述第二节点的时钟偏移值θoffset以及时钟频率偏差θskew满足以下公式:In combination with the ninth aspect, in some implementations of the ninth aspect, without ignoring the clock frequency deviation of the first node and the second node and the uncertainty part of the message communication delay between the third node and the first node and the uncertainty part of the message communication delay between the third node and the second node satisfy a normal distribution, the clock offset value θ offset and the clock frequency deviation θ skew of the first node and the second node satisfy the following formula:

x[i]=T2,i-T3,ix[i]=T 2,i -T 3,i

μ=dKL-dKN μ=d KL -d KN

Di=T1,i-T1,1 D i = T 1,i -T 1,1

其中,所述T2,i是所述第一节点L对第i个参考报文的接收时间,所述T3,i是所述第二节点N对所述第i个参考报文的接收时间,所述T1,i是所述第三节点K对所述第i个参考报文的发送时间,所述T1,1是所述第三节点对第一个参考报文的发送时间,所述dKL为所述第一节点和所述第三节点的报文通信时延的确定性部分,所述dKN为所述第二节点和所述第三节点的报文通信时延的确定性部分。Among them, the T 2,i is the reception time of the i-th reference message by the first node L, the T 3,i is the reception time of the i-th reference message by the second node N, the T 1,i is the sending time of the i-th reference message by the third node K, the T 1,1 is the sending time of the first reference message by the third node, the d KL is the deterministic part of the message communication delay between the first node and the third node, and the d KN is the deterministic part of the message communication delay between the second node and the third node.

第十方面,提供了一种时钟同步方法,用于第一节点和第二节点的时钟同步,所述第一节点和所述第二节点位于不同的局域网中,所述方法包括:所述第一节点将所述第一节点的TSF时钟与所述第一节点的系统时钟对齐;所述第一节点向所述第二节点发送第一同步报文;所述第二节点向所述第一节点发送第二同步报文;根据所述第一同步报文的TSF发送时间、所述第一同步报文的TSF接收时间、所述第二同步报文的TSF发送时间、所述第二同步报文的TSF接收时间,确定所述第一节点和所述第二节点的TSF时钟的时钟偏移值和/或时钟频率偏差;所述第二节点根据所述时钟偏移值和/或所述时钟频率偏差,调节所述第二节点的TSF时钟;所述第二节点根据调整后的TSF时钟,调节所述第二节点的系统时钟。In the tenth aspect, a clock synchronization method is provided for clock synchronization of a first node and a second node, wherein the first node and the second node are located in different local area networks, and the method comprises: the first node aligns the TSF clock of the first node with the system clock of the first node; the first node sends a first synchronization message to the second node; the second node sends a second synchronization message to the first node; according to the TSF sending time of the first synchronization message, the TSF receiving time of the first synchronization message, the TSF sending time of the second synchronization message, and the TSF receiving time of the second synchronization message, the clock offset value and/or clock frequency deviation of the TSF clocks of the first node and the second node are determined; the second node adjusts the TSF clock of the second node according to the clock offset value and/or the clock frequency deviation; the second node adjusts the system clock of the second node according to the adjusted TSF clock.

结合第十方面,在第十方面的某些实现方式中,在忽略所述第一节点和所述第二节点的时钟频率偏差以及第一节点和第二节点之间报文的往返通信时延的差异的情况下,所述第一节点和所述第二节点的TSF时钟的时钟偏移值θoffset满足以下公式:In combination with the tenth aspect, in some implementations of the tenth aspect, while ignoring the clock frequency deviation between the first node and the second node and the difference in round-trip communication delay of the message between the first node and the second node, the clock offset value θ offset of the TSF clock of the first node and the second node satisfies the following formula:

其中,所述T1,i为所述第一同步报文的TSF接收时间,所述T0,i为所述第一同步报文的TSF发送时间,所述T3,i为所述第二同步报文的TSF接收时间,所述T2,i为所述第二同步报文的TSF发送时间。Among them, the T 1,i is the TSF receiving time of the first synchronization message, the T 0,i is the TSF sending time of the first synchronization message, the T 3,i is the TSF receiving time of the second synchronization message, and the T 2,i is the TSF sending time of the second synchronization message.

结合第十方面,在第十方面的某些实现方式中,在考虑所述第一节点和所述第二节点之间报文的往返通信时延的差异,忽略所述第一节点和所述第二节点的时钟频率偏差以及第一节点和第二节点之间报文通信时延的不确定性部分满足正态分布的情况下,所述第一节点和所述第二节点的TSF时钟的时钟偏移值θoffset满足以下公式:In combination with the tenth aspect, in some implementations of the tenth aspect, considering the difference in round-trip communication delay of the message between the first node and the second node, ignoring the clock frequency deviation of the first node and the second node and the uncertainty part of the message communication delay between the first node and the second node satisfying the normal distribution, the clock offset value θ offset of the TSF clock of the first node and the second node satisfies the following formula:

其中,所述T1,i为第i轮同步报文交互时第一同步报文的TSF接收时间,所述T0,i为第i轮同步报文交互时所述第一同步报文的TSF发送时间,所述T3,i为第i轮同步报文交互时所述第二同步报文的TSF接收时间,所述T2,i为第i轮同步报文交互时所述第二同步报文的TSF发送时间,N为同步报文的交互轮次。Among them, the T 1,i is the TSF reception time of the first synchronization message during the i-th round of synchronization message interaction, the T 0,i is the TSF sending time of the first synchronization message during the i-th round of synchronization message interaction, the T 3,i is the TSF reception time of the second synchronization message during the i-th round of synchronization message interaction, the T 2,i is the TSF sending time of the second synchronization message during the i-th round of synchronization message interaction, and N is the interaction round of the synchronization message.

结合第十方面,在第十方面的某些实现方式中,在考虑所述第一节点和所述第二节点之间报文的往返通信时延的差异,忽略所述第一节点和所述第二节点的时钟频率偏差以及第一节点和第二节点之间报文通信时延的不确定性部分满足指数分布的情况下,所述第一节点和所述第二节点的TSF时钟的时钟偏移值θoffset满足以下公式:In combination with the tenth aspect, in some implementations of the tenth aspect, considering the difference in round-trip communication delay of the message between the first node and the second node, ignoring the clock frequency deviation of the first node and the second node and the uncertainty part of the message communication delay between the first node and the second node satisfying the exponential distribution, the clock offset value θ offset of the TSF clock of the first node and the second node satisfies the following formula:

Ui=T1,i-T0,i U i = T 1,i - T 0,i

Vi=T3,i-T2,i V i = T 3,i - T 2,i

其中,所述T1,i为第i轮同步报文交互时第一同步报文的TSF接收时间,所述T0,i为第i轮同步报文交互时所述第一同步报文的TSF发送时间,所述T3,i为第i轮同步报文交互时所述第二同步报文的TSF接收时间,所述T2,i为第i轮同步报文交互时所述第二同步报文的TSF发送时间,N为同步报文的交互轮次。Among them, the T 1,i is the TSF reception time of the first synchronization message during the i-th round of synchronization message interaction, the T 0,i is the TSF sending time of the first synchronization message during the i-th round of synchronization message interaction, the T 3,i is the TSF reception time of the second synchronization message during the i-th round of synchronization message interaction, the T 2,i is the TSF sending time of the second synchronization message during the i-th round of synchronization message interaction, and N is the interaction round of the synchronization message.

结合第十方面,在第十方面的某些实现方式中,在考虑所述第一节点和所述第二节点之间报文的往返通信时延的差异和所述第一节点和所述第二节点的时钟频率偏差以及以及第一节点和第二节点之间报文通信时延的不确定性部分满足正态分布的情况下,所述第一节点和所述第二节点的TSF时钟的时钟偏移值θoffset、时钟频率偏差θskew满足以下公式:In combination with the tenth aspect, in some implementations of the tenth aspect, considering that the difference in the round-trip communication delay of the message between the first node and the second node and the clock frequency deviation of the first node and the second node and the uncertainty part of the message communication delay between the first node and the second node satisfy the normal distribution, the clock offset value θ offset and the clock frequency deviation θ skew of the TSF clock of the first node and the second node satisfy the following formula:

其中,所述T1,为第i轮同步报文交互时第一同步报文的TSF接收时间,所述T0,为第i轮同步报文交互时所述第一同步报文的TSF发送时间,所述T3,为第i轮同步报文交互时所述第二同步报文的TSF接收时间,所述T2,为第i轮同步报文交互时所述第二同步报文的TSF发送时间,N为同步报文的交互轮次。Among them, the T1 is the TSF receiving time of the first synchronization message during the i-th round of synchronization message interaction, the T0 is the TSF sending time of the first synchronization message during the i-th round of synchronization message interaction, the T3 is the TSF receiving time of the second synchronization message during the i-th round of synchronization message interaction, the T2 is the TSF sending time of the second synchronization message during the i-th round of synchronization message interaction, and N is the interaction round of the synchronization message.

第十一方面,提供了一种时钟同步装置,包括至少一个处理器,所述处理器与存储器耦合,所述存储器用于存储指令,所述指令被所述处理器运行时,使得所述处理器执行如第一方面或第一方面任意一种实现方式至第四方面或第四方面任意一种实现方式的方法。In the eleventh aspect, a clock synchronization device is provided, comprising at least one processor, wherein the processor is coupled to a memory, wherein the memory is used to store instructions, and when the instructions are executed by the processor, the processor executes a method as in the first aspect or any one of the implementations of the first aspect to the fourth aspect or any one of the implementations of the fourth aspect.

第十二方面,提供了一种计算机可读存储介质,存储有计算机可执行指令,当所述计算机可执行指令在计算机上运行时,使得所述计算机执行如使得所述处理器执行如第一方面或第一方面任意一种实现方式至第四方面或第四方面任意一种实现方式的方法。In the twelfth aspect, a computer-readable storage medium is provided, storing computer-executable instructions, which, when executed on a computer, cause the computer to execute a method such as causing the processor to execute the first aspect or any one of the implementations of the first aspect to the fourth aspect or any one of the implementations of the fourth aspect.

第十三方面,提供了一种计算机程序产品,所述计算机程序产品包括:计算机程序代码,当所述计算机程序代码被运行时,实现如使得所述处理器执行如第一方面或第一方面任意一种实现方式至第四方面或第四方面任意一种实现方式的方法。In the thirteenth aspect, a computer program product is provided, comprising: a computer program code, which, when executed, implements a method such as causing the processor to execute a method such as the first aspect or any one of the implementations of the first aspect to the fourth aspect or any one of the implementations of the fourth aspect.

附图说明BRIEF DESCRIPTION OF THE DRAWINGS

图1是本申请实施例适用的系统。FIG1 is a system to which the embodiments of the present application are applicable.

图2是一种时钟同步方法的示意图。FIG. 2 is a schematic diagram of a clock synchronization method.

图3是本申请实施例提供的一种时钟同步方法。FIG3 is a clock synchronization method provided in an embodiment of the present application.

图4是本申请实施例提供的同步控制报文的示意性结构图。FIG4 is a schematic structural diagram of a synchronization control message provided in an embodiment of the present application.

图5是本申请实施例提供的订阅请求报文的示意性结构图。FIG5 is a schematic structural diagram of a subscription request message provided in an embodiment of the present application.

图6是本申请实施例提供的策略下发报文的示意性结构图。FIG6 is a schematic structural diagram of a policy delivery message provided in an embodiment of the present application.

图7是本申请实施例提供的时间信息上传报文的示意性结构图。FIG. 7 is a schematic structural diagram of a time information upload message provided in an embodiment of the present application.

图8是本申请实施例提供的参数发布报文的示意性结构图。FIG8 is a schematic structural diagram of a parameter publishing message provided in an embodiment of the present application.

图9是适用于本申请实施例的一种时钟同步算法示意图。FIG. 9 is a schematic diagram of a clock synchronization algorithm applicable to an embodiment of the present application.

图10是本申请实施例提供的一种时钟同步算法的示意图。FIG10 is a schematic diagram of a clock synchronization algorithm provided in an embodiment of the present application.

图11是本申请实施例提供的一种时钟同步算法的示意图。FIG. 11 is a schematic diagram of a clock synchronization algorithm provided in an embodiment of the present application.

图12是本申请实施例提供的一种用户界面示意图。FIG. 12 is a schematic diagram of a user interface provided in an embodiment of the present application.

图13是本申请实施例提供的一种时钟同步装置。FIG. 13 is a clock synchronization device provided in an embodiment of the present application.

图14是本申请实施例提供的另一种时钟同步装置。FIG. 14 is another clock synchronization device provided in an embodiment of the present application.

具体实施方式DETAILED DESCRIPTION

下面将结合附图,对本申请实施例中的技术方案进行描述。The technical solutions in the embodiments of the present application will be described below in conjunction with the accompanying drawings.

本申请的实施方式部分使用的术语仅用于对本申请的具体实施例进行解释,而非旨在限定本申请。The terms used in the implementation section of this application are only used to explain the specific embodiments of this application and are not intended to limit this application.

本申请中术语“第一”“第二”“第三”等字样用于对作用和功能基本相同的相同项或相似项进行区分,“第一”、“第二”和“第三”之间不具有逻辑或时序上的依赖关系,也不对数量和执行顺序进行限定。In this application, the terms "first", "second", "third", etc. are used to distinguish the same or similar items with basically the same role and function. There is no logical or temporal dependency between "first", "second" and "third", and the quantity and execution order are not limited.

本申请将围绕可包括多个设备、组件、模块等的系统来呈现各个方面、实施例或特征。应当理解和明白的是,各个系统可以包括另外的设备、组件、模块等,并且/或者可以并不包括结合附图讨论的所有设备、组件、模块等。此外,还可以使用这些方案的组合。The present application will present various aspects, embodiments or features around a system that may include multiple devices, components, modules, etc. It should be understood and appreciated that each system may include additional devices, components, modules, etc., and/or may not include all of the devices, components, modules, etc. discussed in conjunction with the figures. In addition, combinations of these schemes may also be used.

另外,在本申请实施例中,“示例的”、“例如”等词用于表示作例子、例证或说明。本申请中被描述为“示例”的任何实施例或设计方案不应被解释为比其它实施例或设计方案更优选或更具优势。确切而言,使用示例的一词旨在以具体方式呈现概念。In addition, in the embodiments of the present application, words such as "exemplary" and "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" in the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of the word "exemplary" is intended to present concepts in a concrete way.

本申请实施例描述的网络架构以及业务场景是为了更加清楚的说明本申请实施例的技术方案,并不构成对于本申请实施例提供的技术方案的限定,本领域普通技术人员可知,随着网络架构的演变和新业务场景的出现,本申请实施例提供的技术方案对于类似的技术问题,同样适用。The network architecture and business scenarios described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. A person of ordinary skill in the art can appreciate that with the evolution of the network architecture and the emergence of new business scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.

在本说明书中描述的参考“一个实施例”或“一些实施例”等意味着在本申请的一个或多个实施例中包括结合该实施例描述的特定特征、结构或特点。由此,在本说明书中的不同之处出现的语句“在一个实施例中”、“在一些实施例中”、“在其他一些实施例中”、“在另外一些实施例中”等不是必然都参考相同的实施例,而是意味着“一个或多个但不是所有的实施例”,除非是以其他方式另外特别强调。术语“包括”、“包含”、“具有”及它们的变形都意味着“包括但不限于”,除非是以其他方式另外特别强调。References to "one embodiment" or "some embodiments" etc. described in this specification mean that a particular feature, structure or characteristic described in conjunction with the embodiment is included in one or more embodiments of the present application. Thus, the phrases "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. appearing in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.

本申请中,“至少一个”是指一个或者多个,“多个”是指两个或两个以上。“和/或”,描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B的情况,其中A,B可以是单数或者复数。字符“/”一般表示前后关联对象是一种“或”的关系。“以下至少一项(个)”或其类似表达,是指的这些项中的任意组合,包括单项(个)或复数项(个)的任意组合。例如,a,b或c中的至少一项(个),可以表示:a,b,c,a-b,a-c,b-c,或a-b-c,其中a,b,c可以是单个,也可以是多个。In the present application, "at least one" means one or more, and "plurality" means two or more. "And/or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and/or B can mean: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character "/" generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, a-b, a-c, b-c, or a-b-c, where a, b, c can be single or multiple.

下面,结合图1介绍适用于本申请实施例的系统架构。Next, a system architecture applicable to an embodiment of the present application is introduced in conjunction with FIG. 1 .

如图1所示,图1中包括多个节点,且多个节点可以通过不同的通信介质连接或处于不同的网络中。As shown in FIG. 1 , FIG. 1 includes multiple nodes, and the multiple nodes may be connected via different communication media or be in different networks.

示例性的,图1中包括节点10、节点11、节点12、节点13、节点14和节点15,节点10至节点15可以处于局域网1中,例如局域网1可以为家庭网络。节点10可以为控制节点,并且可以与其他所有节点连接。图1中的任一节点可以为不同的设备,例如节点10(设备10)可以为全屋智能主机或家庭存储中心等,连接所使用的通信介质可以不同。每个节点对应一个设备,也可以对应多个设备,例如,节点10的设备可以由多个服务器通过有线或无线连接组成,以下用一个节点对应一个设备为例说明本申请实施例的应用的系统架构。节点10可以是本地设备,也可以位于云端。节点11(设备11)至节点15(设备15)可以分别使用通信介质1至通信介质5与设备10连接,示例性的,通信介质1至通信介质5可以为蓝牙、以太网、紫蜂(ZigBeetechnology)、无线保真技术(wirelessfidelity,WiFi)等。Exemplarily, FIG. 1 includes nodes 10, 11, 12, 13, 14, and 15, and nodes 10 to 15 may be in a local area network 1, for example, the local area network 1 may be a home network. Node 10 may be a control node and may be connected to all other nodes. Any node in FIG. 1 may be a different device, for example, node 10 (device 10) may be a whole-house smart host or a home storage center, etc., and the communication medium used for the connection may be different. Each node corresponds to one device, or may correspond to multiple devices. For example, the device of node 10 may be composed of multiple servers connected by wire or wireless. The following uses one node corresponding to one device as an example to illustrate the system architecture of the application of the embodiment of the present application. Node 10 may be a local device or may be located in the cloud. Node 11 (device 11) to node 15 (device 15) may be connected to device 10 using communication medium 1 to communication medium 5, respectively. Exemplarily, communication medium 1 to communication medium 5 may be Bluetooth, Ethernet, ZigBee technology, wireless fidelity technology (WiFi), etc.

设备11和设备12可以处于局域网2中,例如,设备11可以为路由器,设备12可以为平板电脑,两者可以通过通信介质6通信,示例性的,通信介质6可以为WiFi。Device 11 and device 12 may be in a local area network 2. For example, device 11 may be a router and device 12 may be a tablet computer. The two may communicate via a communication medium 6. Exemplarily, the communication medium 6 may be WiFi.

设备13和设备14可以处于局域网3中,设备13可以为智能灯,设备14可以为智能音箱,设备15可以为手机,设备15可以与设备14通过通信介质7通信,示例性的,通信介质7可以为蓝牙。Device 13 and device 14 may be in a local area network 3, device 13 may be a smart light, device 14 may be a smart speaker, device 15 may be a mobile phone, and device 15 may communicate with device 14 via a communication medium 7. Exemplarily, communication medium 7 may be Bluetooth.

当两个节点之间需要协同通信或数据融合时,需要进行时钟同步。节点的时钟包括系统时钟、TSF时钟等。TSF时钟是节点网卡上的时钟,系统时钟是节点的处理器或CPU使用的时钟,由于上层应用或服务能够较为方便地读取系统时钟,本申请实施例所叙述的两个节点进行时钟同步主要指的是两个节点进行系统时钟的同步。When collaborative communication or data fusion is required between two nodes, clock synchronization is required. The clocks of the nodes include system clocks, TSF clocks, etc. The TSF clock is the clock on the node network card, and the system clock is the clock used by the processor or CPU of the node. Since the upper-layer application or service can read the system clock more conveniently, the clock synchronization of the two nodes described in the embodiment of the present application mainly refers to the synchronization of the system clocks of the two nodes.

图2示出了一种时钟同步的方法。如图2所示,节点1为设备1,节点2为设备2,设备1和设备2在一个WiFi网络中,设备1和设备2分别具有各自的系统时钟以及TSF时钟,其中两个设备的TSF时钟已经根据周期性信标帧实现同步,在设备1和设备2建立连接后,两个设备的系统时钟进行时钟同步的过程可以包括以下步骤:FIG2 shows a method for clock synchronization. As shown in FIG2, node 1 is device 1, node 2 is device 2, device 1 and device 2 are in a WiFi network, device 1 and device 2 have their own system clocks and TSF clocks, respectively, wherein the TSF clocks of the two devices have been synchronized according to the periodic beacon frame, after device 1 and device 2 establish a connection, the process of clock synchronization of the system clocks of the two devices may include the following steps:

S202,设备1在应用层向WiFi驱动下发本地时间测量指令。S204,设备1的WiFi驱动向网卡固件发起时钟同步功能TSF(timingsynchronizationfunction,TSF)计数器(也可以称为TSF时钟)的数值获取请求。S202, device 1 sends a local time measurement instruction to the WiFi driver at the application layer. S204, the WiFi driver of device 1 initiates a value acquisition request of a TSF (timing synchronization function, TSF) counter (also called TSF clock) to the network card firmware.

S206,设备1的WiFi驱动收到网卡固件(firmware)响应,获取到TSF计数器的数值k1,同时获取本地系统时钟数值t1。S206, the WiFi driver of device 1 receives a response from the network card firmware, obtains the value k1 of the TSF counter, and simultaneously obtains the value t1 of the local system clock.

在S206中,网卡固件中可以读取TSF计数器的数值,TSF计数器的数值是根据本地振荡器以统一速率递增的TSF计数器的值,TSF计数器是64位计数器,每一微秒递增一次。在同一个WiFi系统中,WiFi接入点设备会周期性地向接入WiFi的设备(设备1和设备2)发送信标帧,该信标帧携带时间信息(时间信息可以例如为时间戳或时钟计数器的数值),从而设备1和设备2可以根据周期性接收的信标帧以及估算出的本地延迟,完成设备1和设备2的TSF时钟与WiFi接入点设备的时钟的同步。In S206, the value of the TSF counter can be read in the network card firmware. The value of the TSF counter is the value of the TSF counter incremented at a uniform rate according to the local oscillator. The TSF counter is a 64-bit counter that increments once every microsecond. In the same WiFi system, the WiFi access point device periodically sends beacon frames to the devices (device 1 and device 2) connected to the WiFi. The beacon frame carries time information (the time information can be, for example, a timestamp or a value of a clock counter), so that device 1 and device 2 can complete the synchronization of the TSF clocks of device 1 and device 2 with the clock of the WiFi access point device according to the periodically received beacon frames and the estimated local delay.

系统时钟是设备1和设备2的处理器或CPU使用的时钟,系统时钟可以由设备固件以上的层次读取到,WiFi驱动侧可以读取到系统时钟。The system clock is the clock used by the processor or CPU of device 1 and device 2. The system clock can be read by the layer above the device firmware, and the WiFi driver side can read the system clock.

S208,设备1的WiFi驱动将t1和k1上报给应用层。S208, the WiFi driver of device 1 reports t1 and k1 to the application layer.

S210,设备1向设备2发送时间差测量请求报文,并在时间差测量请求报文中携带t1和k1。S210, device 1 sends a time difference measurement request message to device 2, and carries t1 and k1 in the time difference measurement request message.

S212,设备2的应用层收到时间差测量请求报文后,向WiFi驱动下发本地时间测量指令。S212, after receiving the time difference measurement request message, the application layer of device 2 sends a local time measurement instruction to the WiFi driver.

S214,设备2的WiFi驱动向网卡固件发起TSF计数器的数值获取请求。S214, the WiFi driver of device 2 initiates a TSF counter value acquisition request to the network card firmware.

S216,设备2的WiFi驱动收到网卡固件响应,获取到TSF计数器的数值k2,同时获取本地系统时钟数值t2。S216, the WiFi driver of device 2 receives the response from the network card firmware, obtains the value k2 of the TSF counter, and simultaneously obtains the value t2 of the local system clock.

S218,设备2的WiFi驱动将t2和k2上报给应用层。S218, the WiFi driver of device 2 reports t2 and k2 to the application layer.

S220,设备2在应用层向设备1发送时间差测量响应报文,并在时间差测量响应报文中携带t2和k2。S220, device 2 sends a time difference measurement response message to device 1 at the application layer, and carries t2 and k2 in the time difference measurement response message.

由于两个设备的TSF时钟已经通过周期性信标帧同步,则可以认为两个设备的TSF时钟的时钟偏移值为0,如果设备1的系统时钟与设备2的系统时钟是同步的,则图2中的k2-k1的数值应该等于t2-t1的数值。因此,根据k1、k2和t1、t2,设备1和设备2可以分别计算出两个设备之间的系统时钟的时钟偏移值td=(t2-t1)-(k2-k1)。Since the TSF clocks of the two devices have been synchronized through periodic beacon frames, the clock offset value of the TSF clocks of the two devices can be considered to be 0. If the system clock of device 1 is synchronized with the system clock of device 2, the value of k2-k1 in Figure 2 should be equal to the value of t2-t1. Therefore, according to k1, k2 and t1, t2, device 1 and device 2 can respectively calculate the clock offset value td = (t2-t1)-(k2-k1) of the system clocks between the two devices.

图2所示的时钟同步方法需要进行时钟同步的两个设备处于同一个WiFi网络中且需要两个设备具备TSF同步的能力,也就是说,需要依赖系统硬件和通信协议的支持,使得该同步方法通用性较差。例如对于图1所示的系统,如果局域网1和局域网3不是WiFi网络,而局域网2为WiFi网络,则只有设备11和设备12在一个WiFi网络中。只有配备WiFi网卡且使用WiFi协议的设备才可能实现TSF的时钟同步,部分设备可能不具备WiFi网卡,例如设备14代表的智能音箱可能没有WiFi网卡,从而不具备TSF同步的能力,无法将图2所示的时钟同步方法应用于任意设备之间的时钟同步。The clock synchronization method shown in FIG2 requires that the two devices for clock synchronization are in the same WiFi network and that the two devices have the ability of TSF synchronization. In other words, it needs to rely on the support of system hardware and communication protocols, which makes the synchronization method less versatile. For example, for the system shown in FIG1, if LAN 1 and LAN 3 are not WiFi networks, and LAN 2 is a WiFi network, only device 11 and device 12 are in the same WiFi network. Only devices equipped with WiFi network cards and using WiFi protocols can achieve TSF clock synchronization. Some devices may not have WiFi network cards. For example, the smart speaker represented by device 14 may not have a WiFi network card, and thus does not have the ability of TSF synchronization. The clock synchronization method shown in FIG2 cannot be applied to clock synchronization between any devices.

图3示出了本申请实施例提供的一种时钟同步方法,能够适用于包括不同硬件配置、通信能力和组网形式的异构设备的系统,该方法包括:FIG3 shows a clock synchronization method provided by an embodiment of the present application, which can be applicable to a system including heterogeneous devices with different hardware configurations, communication capabilities and networking forms. The method includes:

S310,第一节点向控制节点发送订阅请求报文,订阅请求报文用于订阅第一节点与第二节点的时钟同步服务,该第二节点是与第一节点进行时钟同步的节点。S310, the first node sends a subscription request message to the control node, where the subscription request message is used to subscribe to a clock synchronization service between the first node and a second node, where the second node is a node that performs clock synchronization with the first node.

对应,控制节点接收来自第一节点的订阅请求报文。Correspondingly, the control node receives the subscription request message from the first node.

在本申请实施例中,节点对应于本申请实施例应用的异构网络拓扑中的各个路由节点的设备,对于一个节点,该节点对应的设备的数量可能不止一个,例如对于控制节点来说,可能包含多个设备,例如多个服务器或终端设备通过有线或无线连接组合而形成节点。In the embodiment of the present application, the node corresponds to the device of each routing node in the heterogeneous network topology applied in the embodiment of the present application. For a node, the number of devices corresponding to the node may be more than one. For example, for a control node, it may include multiple devices, such as multiple servers or terminal devices combined through wired or wireless connections to form a node.

另外,本申请实施例不限定需要进行时钟同步的节点的数量,例如除了第二节点,第一节点需要时钟同步的目标节点还可以包括其他节点,则订阅请求报文里还会包括该其他节点的标识。为了便于说明,下面以第一节点和第二节点需要进行时钟同步为例对本申请实施例的技术方案进行说明。In addition, the embodiment of the present application does not limit the number of nodes that need to perform clock synchronization. For example, in addition to the second node, the target node that the first node needs to perform clock synchronization may also include other nodes, and the subscription request message will also include the identifier of the other node. For ease of explanation, the technical solution of the embodiment of the present application is described below using the example that the first node and the second node need to perform clock synchronization.

为了实现时钟同步服务的订阅与发布,各个节点之间需要交互相关信息,这些信息可以通过报文发送,例如订阅请求报文以及后文提及的参数发布报文、策略下发报文和时间信息上传报文等,上述报文可以统称为同步控制报文,同步控制报文可以通过通信系统中各种通信介质的链路层数据帧传输。In order to realize the subscription and publication of clock synchronization services, each node needs to exchange relevant information, which can be sent through messages, such as subscription request messages and parameter publishing messages, policy delivery messages and time information upload messages mentioned later. The above messages can be collectively referred to as synchronization control messages. Synchronization control messages can be transmitted through link layer data frames of various communication media in the communication system.

图4示出了本申请实施例提供的一种同步控制报文的结构,如图4所示,同步控制报文可以包括链路层帧头、有效负载字段和校验字段。其中链路层帧头携带与传输控制协议相关的控制信息,校验字段用于检测报文的正确性和完整性。有效负载字段中携带时钟同步控制消息,可以由固定头字段、可变头字段和数据字段组成。FIG4 shows the structure of a synchronization control message provided by an embodiment of the present application. As shown in FIG4, the synchronization control message may include a link layer frame header, a payload field, and a check field. The link layer frame header carries control information related to the transmission control protocol, and the check field is used to detect the correctness and integrity of the message. The payload field carries a clock synchronization control message, which may be composed of a fixed header field, a variable header field, and a data field.

固定头字段可以存在于所有类型的同步控制报文中,表示同步控制报文中控制消息的类型以及对应该类型控制消息相关的标志位。通过定义有效负载固定头字段中不同的控制消息类型字段值,可以表示该同步控制报文具体是属于订阅请求报文、策略下发报文、时间信息上传报文还是参数发布报文。对应于不同的同步控制报文,该同步控制报文用于表示时钟同步和网络节点的相关操作,例如网络节点的连接建立和断开、时钟同步服务的订阅和取消订阅、时钟同步策略的指定、时间信息汇聚节点的选取、同步报文时间信息的上报、时钟同步参数的发布、心跳维持等。控制消息标志位包括对应每个控制消息类型字段的特定标志,如重复发送标志和服务质量(qualityofservice,QoS)等级等。长度字段可以标识当前时钟同步控制报文中剩余部分的字节数,包括可变头字段和数据字段的长度。The fixed header field can exist in all types of synchronization control messages, indicating the type of control message in the synchronization control message and the flag bit corresponding to the type of control message. By defining different control message type field values in the payload fixed header field, it can be indicated whether the synchronization control message specifically belongs to a subscription request message, a policy delivery message, a time information upload message or a parameter release message. Corresponding to different synchronization control messages, the synchronization control message is used to indicate the related operations of clock synchronization and network nodes, such as the establishment and disconnection of network node connections, the subscription and unsubscription of clock synchronization services, the designation of clock synchronization strategies, the selection of time information aggregation nodes, the reporting of synchronization message time information, the release of clock synchronization parameters, heartbeat maintenance, etc. The control message flag bit includes a specific flag corresponding to each control message type field, such as a repeat transmission flag and a quality of service (QoS) level. The length field can identify the number of bytes remaining in the current clock synchronization control message, including the length of the variable header field and the data field.

可变头字段可以包含该同步控制报文及收发该同步控制报文的节点使用的协议名、协议版本、连接标志、报文标识符等。The variable header field may include the synchronization control message and the protocol name, protocol version, connection flag, message identifier, etc. used by the node that sends or receives the synchronization control message.

数据字段包括的具体内容与同步控制报文的具体类型有关,具体的,会随着同步控制报文为订阅请求报文、策略下发报文、时间信息上传报文还是参数发布报文的变化而变化,后文具体介绍。The specific content included in the data field is related to the specific type of the synchronization control message. Specifically, it will change with whether the synchronization control message is a subscription request message, a policy delivery message, a time information upload message or a parameter release message, which will be described in detail later.

控制节点可以为远端设备,例如为云服务器,控制节点也可以为本地设备,例如可以为全屋智能主机或家庭存储中心等设备。第一节点和第二节点可以为图1中除节点10以外的其他节点,是需要进行时钟同步的节点,可以为图1所示的异构网络中由不同通信介质连接的各种终端设备,例如第一节点可以为智能手机15,第二节点可以为智能音箱14;或者第一节点可以为路由器11,第二节点可以为平板12等。The control node may be a remote device, such as a cloud server, or a local device, such as a whole-house smart host or a home storage center. The first node and the second node may be other nodes except node 10 in FIG. 1 , which are nodes that require clock synchronization, and may be various terminal devices connected by different communication media in the heterogeneous network shown in FIG. 1 , for example, the first node may be a smart phone 15, and the second node may be a smart speaker 14; or the first node may be a router 11, and the second node may be a tablet 12, etc.

第一节点和第二节点可以根据实际应用需要进行时钟同步。例如,节点1和节点2上的设备都有需要进行时钟同步的应用1,示意性的,应用1可以为通信类应用,节点1和节点2需要通过应用1进行通信,则该订阅请求报文既可以由节点1和节点2中的一个节点发送,例如可以是节点1和节点2之间进行通信的发送节点或发起通信的节点发送该订阅请求报文,在这种情况下,第一节点是节点1,第二节点是节点2。也可以由节点1和节点2均发送该订阅请求报文,在这种情况下,对于节点1发送的订阅请求报文1,第一节点是节点1,第二节点是节点2;对于节点2发送的订阅请求报文2,第一节点是节点2,第二节点是节点1。The first node and the second node can perform clock synchronization according to actual application needs. For example, the devices on node 1 and node 2 both have application 1 that needs to perform clock synchronization. Schematically, application 1 can be a communication application. Node 1 and node 2 need to communicate through application 1. Then the subscription request message can be sent by one of nodes 1 and 2. For example, the subscription request message can be sent by a sending node or a node that initiates communication between node 1 and node 2. In this case, the first node is node 1 and the second node is node 2. The subscription request message can also be sent by both node 1 and node 2. In this case, for subscription request message 1 sent by node 1, the first node is node 1 and the second node is node 2; for subscription request message 2 sent by node 2, the first node is node 2 and the second node is node 1.

应理解,本申请并不限制一个节点只能发送一个订阅请求报文,例如对于上述应用1来说,在节点1为发送节点的情况下,可以由节点1发送订阅请求报文1;同时,节点1和节点3的设备上有需要时钟同步的应用2,当节点1与节点3使用应用2进行交互时,节点1也是应用2进行的交互的发起节点,则节点1还可以发送订阅请求报文3。下面以应用1中由节点1发送订阅请求报文1为例,详细叙述本申请实施例的细节。It should be understood that the present application does not limit a node to only send one subscription request message. For example, for the above-mentioned application 1, when node 1 is a sending node, node 1 can send subscription request message 1; at the same time, there is application 2 that requires clock synchronization on the devices of node 1 and node 3. When node 1 and node 3 interact using application 2, node 1 is also the initiating node of the interaction performed by application 2, then node 1 can also send subscription request message 3. The following takes the example of node 1 sending subscription request message 1 in application 1 as an example to describe the details of the embodiment of the present application in detail.

在S310中,该订阅请求报文中可以包括第一节点的标识(本端节点标识)、第二节点的标识(目标节点标识)和时钟同步精度。可选的,该订阅请求报文中还可以包括第一节点支持的通信介质、时钟同步周期、时钟同步收敛速度、时间信息标记方式、同步报文处理优先级中的任意一项或多项。In S310, the subscription request message may include the identifier of the first node (local node identifier), the identifier of the second node (target node identifier) and the clock synchronization accuracy. Optionally, the subscription request message may also include any one or more of the communication medium supported by the first node, the clock synchronization period, the clock synchronization convergence speed, the time information marking method, and the synchronization message processing priority.

图5示出了本申请实施例提供的订阅请求报文的结构,该订阅请求报文中固定头字段以及可变头字段的细节可以参考图4以及对应的同步控制报文的相关介绍。而数据字段中由本端节点标识字段承载第一节点的标识、目标节点标识字段承载第二节点的标识、时钟同步精度字段承载第一节点和第二节点的时钟同步精度需求。数据字段中还可以包括通信介质类型字段,承载第一节点支持的通信介质类型,还可以包括选项字段作为扩展字段,以说明第一节点对时钟同步服务性能和同步流程执行等方面的需求,例如选项字段可以承载期望的时钟同步周期、时钟同步收敛速度、时间信息标记方式、同步报文处理优先级等中的一项或多项。FIG5 shows the structure of a subscription request message provided in an embodiment of the present application. The details of the fixed header field and the variable header field in the subscription request message can refer to FIG4 and the relevant introduction of the corresponding synchronization control message. In the data field, the local node identification field carries the identification of the first node, the target node identification field carries the identification of the second node, and the clock synchronization accuracy field carries the clock synchronization accuracy requirements of the first node and the second node. The data field may also include a communication medium type field, which carries the type of communication medium supported by the first node, and may also include an option field as an extension field to illustrate the first node's requirements for clock synchronization service performance and synchronization process execution. For example, the option field may carry one or more of the expected clock synchronization period, clock synchronization convergence speed, time information marking method, synchronization message processing priority, etc.

第一节点的标识是发送该订阅请求报文的节点的标识。例如可以为该节点的客户端标识、用户标识、物理地址(例如可以为媒体接入控制(media access control,MAC)地址)、序列号(serial number,SN),国际移动节点身份码(international mobileequipment identity,IMEI)、国际移动用户识别码(international mobile subscriberidentification,IMSI)、属性哈希值等用于标识第一节点的唯一的标识。The identifier of the first node is the identifier of the node that sends the subscription request message. For example, it can be the client identifier, user identifier, physical address (for example, it can be a media access control (MAC) address), serial number (SN), international mobile equipment identity (IMEI), international mobile subscriber identification (IMSI), attribute hash value, etc. of the node, which are used to uniquely identify the first node.

第二节点的标识是与第一节点进行时钟同步的目标节点标识,具体的,可以为第二节点的客户端标识、用户标识、物理地址(例如可以为媒体接入控制(media accesscontrol,MAC)地址)、序列号(serial number,SN),国际移动节点身份码(internationalmobile equipment identity,IMEI)、国际移动用户识别码(international mobilesubscriber identification,IMSI)、属性哈希值等唯一的标识。The identifier of the second node is the target node identifier for clock synchronization with the first node. Specifically, it can be a unique identifier such as the client identifier, user identifier, physical address (for example, a media access control (MAC) address), serial number (SN), international mobile equipment identity (IMEI), international mobile subscriber identification (IMSI), attribute hash value, etc. of the second node.

节点标识可以区分网络中不同特征的设备节点。例如可以区分节点是否支持多种通信介质、区分节点是否登录同一账号、区分节点是否属于可信设备群组等。通过第一节点的标识,控制节点可以确定是否为该第一节点制定相应的时钟同步策略。例如,如果控制节点通过该第一节点的标识确定该第一节点不属于可信设备群组,控制节点可以不为该第一节点制定相应的时钟同步策略或者优先满足可信设备群组里的节点或设备的时钟同步需求。The node identifier can distinguish device nodes with different characteristics in the network. For example, it can distinguish whether the node supports multiple communication media, whether the node is logged in to the same account, whether the node belongs to a trusted device group, etc. Through the identifier of the first node, the control node can determine whether to formulate a corresponding clock synchronization strategy for the first node. For example, if the control node determines that the first node does not belong to a trusted device group through the identifier of the first node, the control node may not formulate a corresponding clock synchronization strategy for the first node or give priority to meeting the clock synchronization requirements of the nodes or devices in the trusted device group.

时钟同步精度可以具有不同等级,可以为秒级、毫秒级或微秒级等,具体与第一节点和第二节点运行的具体业务类型和要求的服务质量有关,例如对于以视频播放和文件分享为目的的通信业务,所需要的时钟同步精度是不同的。The clock synchronization accuracy can have different levels, which can be seconds, milliseconds or microseconds, etc., which is related to the specific business type and required service quality of the first node and the second node. For example, for communication services for the purpose of video playback and file sharing, the required clock synchronization accuracy is different.

第一节点支持的通信介质类型用于表示第一节点可以使用的通信介质和连接方式,如以太网、无线保真(wireless fidelity,WiFi)、蓝牙、紫蜂技术(ZigBeetechnology)、电力线载波(powerlinecarrier,PLC)等。The communication medium type supported by the first node is used to indicate the communication medium and connection method that the first node can use, such as Ethernet, wireless fidelity (WiFi), Bluetooth, ZigBee technology, power line carrier (PLC), etc.

时钟同步周期可以根据业务类型、网络状况、同步精度需求的不同而具有不同的值,用于表征同步流程执行过程中同步报文的发送周期和第一节点的时钟调整周期。The clock synchronization period may have different values according to different service types, network conditions, and synchronization accuracy requirements, and is used to characterize the transmission period of the synchronization message and the clock adjustment period of the first node during the execution of the synchronization process.

时钟同步收敛速度可以表示时钟同步操作完成的速度或者达到稳定的时钟同步需要花费的时间。The clock synchronization convergence speed may indicate the speed at which the clock synchronization operation is completed or the time required to achieve stable clock synchronization.

时间信息标记方式表示第一节点标记同步报文发送时间和接收时间的方式,例如在用户空间读取系统时间(软件时钟)、在内核空间读取网卡时间(硬件时钟)等。The time information marking method refers to the method in which the first node marks the sending time and receiving time of the synchronization message, such as reading the system time (software clock) in the user space and reading the network card time (hardware clock) in the kernel space.

同步报文处理优先级表示同步报文路由节点对同步报文的处理优先级,如报文编码发送的优先级和报文接收解码的优先级等,进行时钟同步过程第一节点发送以及接收的各种同步控制报文可能需要第三方路由节点的转发,通过在订阅请求报文中标记同步报文处理优先级,可以使得控制节点以及路由节点能够确定第一节点的时钟同步服务的优先级,并据此协调包括第一节点的时钟同步服务在内的多个时钟同步服务的处理顺序。The synchronization message processing priority indicates the processing priority of the synchronization message routing node for the synchronization message, such as the priority of message encoding and sending and the priority of message receiving and decoding. During the clock synchronization process, various synchronization control messages sent and received by the first node may need to be forwarded by a third-party routing node. By marking the synchronization message processing priority in the subscription request message, the control node and the routing node can determine the priority of the clock synchronization service of the first node, and coordinate the processing order of multiple clock synchronization services including the clock synchronization service of the first node accordingly.

S320,控制节点根据订阅请求报文,确定策略下发报文,该策略下发报文包括时钟同步算法。S320: The control node determines a policy delivery message according to the subscription request message, where the policy delivery message includes a clock synchronization algorithm.

S330,第一节点获取时钟同步参数,该时钟同步参数用于时钟同步服务,该时钟同步参数是根据时钟同步算法确定的。S330, the first node obtains a clock synchronization parameter, where the clock synchronization parameter is used for a clock synchronization service and is determined according to a clock synchronization algorithm.

在S320中,控制节点会根据订阅请求报文,确定策略下发报文。具体的,控制节点可以参考第一节点和第二节点的时钟同步精度、第一节点的通信介质类型和第二节点的通信介质类型确定策略下发报文中的内容,例如时钟同步算法。In S320, the control node determines the policy delivery message according to the subscription request message. Specifically, the control node can determine the content of the policy delivery message, such as the clock synchronization algorithm, by referring to the clock synchronization accuracy of the first node and the second node, the communication medium type of the first node and the communication medium type of the second node.

当订阅请求报文中不包括第一节点支持的通信介质类型时,控制节点可以根据第一节点的标识确定第一节点支持的通信介质类型并且根据第二节点的标识确定第二节点支持的通信介质类型。当仅由第一节点发送携带第一节点支持的通信介质类型的订阅请求报文时,第二节点可以额外通过其他信息向控制节点发送第二节点支持的通信介质类型或者由控制节点根据订阅请求报文中第二节点的标识确定第二节点支持的通信介质类型。从而控制节点可以获取两个节点支持的通信介质类型和时钟同步精度,并据此确定策略下发报文。When the subscription request message does not include the communication medium type supported by the first node, the control node can determine the communication medium type supported by the first node according to the identifier of the first node and determine the communication medium type supported by the second node according to the identifier of the second node. When only the first node sends a subscription request message carrying the communication medium type supported by the first node, the second node can send the communication medium type supported by the second node to the control node through other information or the control node can determine the communication medium type supported by the second node according to the identifier of the second node in the subscription request message. In this way, the control node can obtain the communication medium type and clock synchronization accuracy supported by the two nodes, and determine the strategy to send the message accordingly.

当订阅请求报文中还包括时钟同步周期、时钟同步收敛速度、时间信息标记方式、同步报文处理优先级等这些信息时,控制节点还可以参考这些信息确定策略下发报文中的内容,例如时钟同步算法。When the subscription request message also includes information such as clock synchronization period, clock synchronization convergence speed, time information marking method, synchronization message processing priority, etc., the control node can also refer to this information to determine the content of the policy delivery message, such as the clock synchronization algorithm.

此外,控制节点确定策略下发报文时还会参考网络节点(第一节点和第二节点)的负载、网络资源的使用情况和通信状况等中的至少一项,并且控制节点确定的策略下发报文可以发送给相应的节点。In addition, when the control node determines the policy sending message, it will also refer to at least one of the load of the network nodes (first node and second node), the usage of network resources and the communication status, and the policy sending message determined by the control node can be sent to the corresponding node.

在S330中,第一节点会获取时钟同步参数,时钟同步参数是根据控制节点确定的时钟同步算法确定的,时钟同步参数可以包括以下任意一项:第一节点与第二节点的时钟偏移值,第一节点和第二节点的时钟频率偏差,第一节点的时钟值和第一参考时钟值的差值,第一节点的时钟频率和第一参考时钟频率的差值,第一节点的目标时钟值,第一节点的目标时钟频率等。In S330, the first node obtains clock synchronization parameters, which are determined according to the clock synchronization algorithm determined by the control node. The clock synchronization parameters may include any one of the following: the clock offset value between the first node and the second node, the clock frequency deviation between the first node and the second node, the difference between the clock value of the first node and the first reference clock value, the difference between the clock frequency of the first node and the first reference clock frequency, the target clock value of the first node, the target clock frequency of the first node, etc.

例如,第一节点可以根据第一节点和第二节点的时钟偏移值或频率偏移值,将第一节点的时钟向第二节点的时钟对齐(或者第二节点根据第一节点和第二节点的时钟偏移值、时钟率偏移值将第二节点的时钟向第一节点对齐)。For example, the first node may align the clock of the first node with the clock of the second node based on the clock offset value or frequency offset value of the first node and the second node (or the second node may align the clock of the second node with the first node based on the clock offset value or clock rate offset value of the first node and the second node).

再如,第一节点可以根据第一节点的时钟值和第一参考时钟值的差值,第一节点的时钟频率和第一参考时钟频率的差值,将第一节点的时钟调节到第一参考时钟值和第一参考时钟频率(第二节点也可以根据第二节点的时钟值和第一参考时钟值的差值,第二节点的时钟频率和第一参考时钟频率的差值将第二节点的时钟调节到第一参考时钟值和第一参考时钟频率),从而第一节点的时钟和第二节点的时钟能够对齐。For another example, the first node may adjust the clock of the first node to the first reference clock value and the first reference clock frequency based on the difference between the clock value of the first node and the first reference clock value and the difference between the clock frequency of the first node and the first reference clock frequency (the second node may also adjust the clock of the second node to the first reference clock value and the first reference clock frequency based on the difference between the clock value of the second node and the first reference clock value and the difference between the clock frequency of the second node and the first reference clock frequency), so that the clock of the first node and the clock of the second node can be aligned.

又如,第一节点可以根据目标时钟值或目标时钟频率,将第一节点的时钟调节到目标时钟值或目标时钟频率(第二节点可以根据目标时钟值或目标时钟频率,将第二节点的时钟调节到目标时钟值或目标时钟频率),从而第一节点和第二节点的时钟实现对齐。For example, the first node can adjust the clock of the first node to the target clock value or target clock frequency based on the target clock value or target clock frequency (the second node can adjust the clock of the second node to the target clock value or target clock frequency based on the target clock value or target clock frequency), so that the clocks of the first node and the second node are aligned.

应理解,当需要时钟同步的节点还包括其他节点,例如第三节点时,也就是第一节点、第二节点、第三节点需要时钟同步时,可以使得两个节点的时钟值向另一个节点对齐,例如让第一节点和第三节点的时钟都向第二节点对齐,从而对于第一节点的时钟同步参数为第一节点和第二节点的时钟偏移值和/或时钟频率偏差,对于第三节点的时钟同步参数为第三节点与第二节点的时钟偏移值和/或时钟频率偏差。也可以使得所有节点向一个参考时钟值和参考时钟频率对齐,本申请不限定时钟同步参数的具体形式。并且,当在时钟同步过程中某个节点需要调节本地时钟值或时钟频率时,该节点可以获取相应的时钟同步参数,本申请实施例以第一节点需要调节本地时钟为例介绍本申请实施例提供的技术方案,并不意味着对调节本地时钟的节点的限制,例如,当第一节点无需调节本地时钟时,S330可以为,第二节点获取时钟同步参数。此外,第一节点不需要调节本地时钟时,也可以获取时钟同步参数,也就是说,需要进行时钟同步的节点都可以获取时钟同步参数,但是仅由需要调节本地时钟的节点根据该时钟同步参数调节本地时钟。It should be understood that when the nodes that need clock synchronization also include other nodes, such as a third node, that is, when the first node, the second node, and the third node need clock synchronization, the clock values of the two nodes can be aligned to another node, for example, the clocks of the first node and the third node are aligned to the second node, so that the clock synchronization parameter for the first node is the clock offset value and/or clock frequency deviation of the first node and the second node, and the clock synchronization parameter for the third node is the clock offset value and/or clock frequency deviation of the third node and the second node. All nodes can also be aligned to a reference clock value and a reference clock frequency, and the present application does not limit the specific form of the clock synchronization parameter. In addition, when a node needs to adjust the local clock value or clock frequency during the clock synchronization process, the node can obtain the corresponding clock synchronization parameter. The embodiment of the present application takes the first node needing to adjust the local clock as an example to introduce the technical solution provided in the embodiment of the present application, and does not mean a restriction on the node that adjusts the local clock. For example, when the first node does not need to adjust the local clock, S330 can be, the second node obtains the clock synchronization parameter. In addition, when the first node does not need to adjust the local clock, it can also obtain the clock synchronization parameters. That is, all nodes that need to perform clock synchronization can obtain the clock synchronization parameters, but only the nodes that need to adjust the local clock adjust the local clock according to the clock synchronization parameters.

在本申请实施例中,策略下发报文还可以包括执行节点的标识,控制节点可以将策略下发报文发送给执行节点;执行节点根据该策略下发报文,执行时钟同步算法,时钟同步参数是根据执行节点执行时钟同步算法发送和/或接收的同步报文的时间信息确定的,时间信息包括与执行节点发送同步报文关联的时钟计数器的数值或者时间戳和/或与执行节点接收同步报文关联的时钟计数器的数值或者时间戳。In an embodiment of the present application, the policy delivery message may further include an identifier of the execution node, and the control node may send the policy delivery message to the execution node; the execution node executes the clock synchronization algorithm according to the policy delivery message, and the clock synchronization parameters are determined according to the time information of the synchronization message sent and/or received by the execution node when executing the clock synchronization algorithm, and the time information includes the value or timestamp of the clock counter associated with the execution node sending the synchronization message and/or the value or timestamp of the clock counter associated with the execution node receiving the synchronization message.

也就是说,控制节点会确定时钟同步算法和执行该时钟同步算法的节点(执行节点),由控制节点将策略下发报文发送给执行节点,从而执行节点可以执行相应的时钟同步算法。由于针对第一节点与第二节点的时钟同步服务的时钟同步算法是由控制节点制定的,从而控制节点能够根据第一节点和/或第二节点的硬件配置、支持的通信介质类型、所在网络的组网形式、网络资源使用情况和时钟同步精度等信息中的一项或多项确定合适的时钟同步算法,并且确定执行该时钟同步算法的执行节点。最终可以由执行节点或者控制节点根据执行时钟同步算法过程中收集的数据信息(时间信息),计算用于第一节点和第二节点时钟同步服务的时钟同步参数。That is to say, the control node will determine the clock synchronization algorithm and the node (execution node) that executes the clock synchronization algorithm, and the control node will send the policy message to the execution node, so that the execution node can execute the corresponding clock synchronization algorithm. Since the clock synchronization algorithm for the clock synchronization service of the first node and the second node is formulated by the control node, the control node can determine the appropriate clock synchronization algorithm based on one or more of the information such as the hardware configuration of the first node and/or the second node, the type of communication medium supported, the networking form of the network, the network resource usage and the clock synchronization accuracy, and determine the execution node that executes the clock synchronization algorithm. Finally, the execution node or the control node can calculate the clock synchronization parameters for the clock synchronization service of the first node and the second node based on the data information (time information) collected during the execution of the clock synchronization algorithm.

在本申请实施例中,执行节点可以包括第一节点和第二节点,执行节点也可以不包括第一节点和/或第二节点,以下先以执行节点包括第一节点和第二节点为例介绍本申请实施例的具体方案。In an embodiment of the present application, the execution node may include a first node and a second node, or the execution node may not include the first node and/or the second node. The following first takes the execution node including the first node and the second node as an example to introduce the specific scheme of the embodiment of the present application.

在由执行节点根据时钟同步算法执行过程中的时间信息计算时钟同步参数的情况下,如果执行节点包括第一节点和第二节点,则可以直接由第一节点或第二节点计算时钟同步参数,可以预先规定例如由发送订阅请求报文的第一节点计算时钟同步参数并更新本地时钟,第一节点可以直接获取该时钟同步参数。也可以由第一节点和第二节点分别计算时钟同步参数,并将各自的本地时钟向参考时钟值和/或参考时钟频率对齐。In the case where the execution node calculates the clock synchronization parameters according to the time information during the execution of the clock synchronization algorithm, if the execution node includes a first node and a second node, the clock synchronization parameters can be directly calculated by the first node or the second node, and it can be pre-specified that, for example, the first node that sends the subscription request message calculates the clock synchronization parameters and updates the local clock, and the first node can directly obtain the clock synchronization parameters. The first node and the second node can also calculate the clock synchronization parameters separately and align their respective local clocks to the reference clock value and/or reference clock frequency.

在由执行节点将时间信息上传给控制节点的情况下,由控制节点确定时钟同步参数,可以将该时钟同步参数携带在参数发布报文中发送给第一节点。对于异构网络系统中的不同节点和不同目的或应用的时钟同步服务,控制节点能够制定不同的时钟同步策略,在满足第一节点和第二节点时钟同步服务的要求的前提下,降低系统的整体开销。When the execution node uploads the time information to the control node, the control node determines the clock synchronization parameters, and the clock synchronization parameters can be carried in the parameter publishing message and sent to the first node. For different nodes and clock synchronization services for different purposes or applications in the heterogeneous network system, the control node can formulate different clock synchronization strategies to reduce the overall system overhead while meeting the requirements of the clock synchronization services of the first node and the second node.

本申请实施例中所提及时间戳和时钟计数器的数值都与执行节点发送或接收同步报文时该节点的时间对应,可以为发送或接收报文前读取或标记的时间戳或时钟计数器的数值,也可以为发送或接收报文时或发送或接收同步报文之后读取或标记的时间戳或时钟计数器的数值。本地时钟可以为系统时钟或TSF时钟等物理时钟、逻辑时钟等,这些时钟通过时间戳或时钟计数器的数值的形式显示时间(例如时钟计数器的数值可以通过后文提及的TSF时钟读取,时间戳可以通过后文提及的系统时钟读取,时钟计数器的数值和时间戳还可以通过其他时钟读取,此处不再赘述)。在一些实施例中,时钟同步参数可以通过接收同步报文时标记的时间戳或读取的时钟计数器的数值确定,同步报文可以是执行节点之间交互的一个或多个报文。在另一些实施例中,时钟同步参数可以通过发送同步报文时(或者发送同步报文之前)以及接收同步报文时标记的时间戳或读取的时钟计数器的数值确定。The timestamp and the clock counter values mentioned in the embodiments of the present application correspond to the time of the node when the execution node sends or receives the synchronization message. It can be the timestamp or the clock counter value read or marked before sending or receiving the message, or it can be the timestamp or the clock counter value read or marked when sending or receiving the message or after sending or receiving the synchronization message. The local clock can be a physical clock, a logical clock, etc. such as a system clock or a TSF clock, and these clocks display the time in the form of a timestamp or a clock counter value (for example, the clock counter value can be read by the TSF clock mentioned later, the timestamp can be read by the system clock mentioned later, and the clock counter value and the timestamp can also be read by other clocks, which will not be repeated here). In some embodiments, the clock synchronization parameter can be determined by the timestamp marked when receiving the synchronization message or the value of the clock counter read, and the synchronization message can be one or more messages exchanged between the execution nodes. In other embodiments, the clock synchronization parameter can be determined by the timestamp marked when sending the synchronization message (or before sending the synchronization message) and the timestamp marked when receiving the synchronization message or the value of the clock counter read.

在本申请一些实施例中,策略下发报文中还可以包括汇聚节点的标识,汇聚节点不是第一节点,在第一节点获取时钟同步参数之前,控制节点还会将策略下发报文发送给汇聚节点(包括同步报文交互形式、时间信息处理方法等),执行节点可以向汇聚节点发送时间信息上传报文,该时间信息上传报文中包括时间信息;从而汇聚节点根据时间信息和时钟同步算法确定时钟同步参数,并将时钟同步参数携带在参数发布报文中发送给第一节点。也就是说,控制节点会确定汇聚节点,由汇聚节点根据执行节点执行时钟同步算法过程中的时间信息和时钟同步算法,确定时钟同步参数,之后由汇聚节点将时钟同步参数通过参数发布报文发送给第一节点。In some embodiments of the present application, the policy delivery message may also include the identifier of the aggregation node. The aggregation node is not the first node. Before the first node obtains the clock synchronization parameters, the control node will also send the policy delivery message to the aggregation node (including the synchronization message interaction form, time information processing method, etc.), and the execution node can send a time information upload message to the aggregation node, and the time information upload message includes time information; thus, the aggregation node determines the clock synchronization parameters according to the time information and the clock synchronization algorithm, and carries the clock synchronization parameters in the parameter release message and sends it to the first node. In other words, the control node will determine the aggregation node, and the aggregation node will determine the clock synchronization parameters according to the time information and the clock synchronization algorithm in the process of the execution node executing the clock synchronization algorithm, and then the aggregation node will send the clock synchronization parameters to the first node through the parameter release message.

例如,汇聚节点可以为第二节点。当执行节点包括第一节点和第二节点时,第一节点和第二节点执行时钟同步算法时,第一节点可以将发送和/或接收同步报文关联的时间戳或时钟计数器的数值(时间信息)携带在时间信息上传报文中发送给第二节点,从而第二节点作为汇聚节点可以计算时钟同步参数,并将时钟同步参数发送给第一节点。For example, the aggregation node may be the second node. When the execution node includes the first node and the second node, when the first node and the second node execute the clock synchronization algorithm, the first node may carry the timestamp or the value of the clock counter (time information) associated with the sending and/or receiving synchronization message in the time information upload message and send it to the second node, so that the second node as the aggregation node can calculate the clock synchronization parameters and send the clock synchronization parameters to the first node.

再如,汇聚节点可以不是第一节点和第二节点。第一节点和第二节点执行时钟同步算法时,第一节点和第二节点可以将发送和/或接收同步报文关联的时间戳或时钟计数器的数值(时间信息)携带在时间信息上传报文中发送给汇聚节点,由汇聚节点计算时钟同步参数并发送给第一节点和/或第二节点。For another example, the aggregation node may not be the first node and the second node. When the first node and the second node execute the clock synchronization algorithm, the first node and the second node may carry the timestamp or the value of the clock counter (time information) associated with sending and/or receiving the synchronization message in the time information upload message and send it to the aggregation node, and the aggregation node calculates the clock synchronization parameter and sends it to the first node and/or the second node.

可选的,除了由汇聚节点直接将时钟同步参数发送给第一节点,在一些场景中,例如汇聚节点到第一节点的路由路径的长度大于控制节点到第一节点的路由路径的长度,可以由汇聚节点将时钟同步参数发送给控制节点,由控制节点将该时钟同步参数携带在参数发布报文中发送给第一节点。Optionally, in addition to the aggregation node directly sending the clock synchronization parameters to the first node, in some scenarios, for example, when the length of the routing path from the aggregation node to the first node is greater than the length of the routing path from the control node to the first node, the aggregation node can send the clock synchronization parameters to the control node, and the control node carries the clock synchronization parameters in a parameter publishing message and sends it to the first node.

也就是说,参数发布报文可以是第一节点从控制节点接收的,在第一节点获取时钟同步参数之前,控制节点会通过策略下发报文告知汇聚节点当前使用的时钟同步算法(包括同步报文交互形式、时间信息处理方法等),执行节点可以向汇聚节点发送时间信息上传报文,该时间信息上传报文中包括时间信息;从而汇聚节点根据时间信息和时钟同步算法确定时钟同步参数并发送给控制节点;控制节点向第一节点发送携带该时钟同步参数的参数发布报文。That is to say, the parameter release message can be received by the first node from the control node. Before the first node obtains the clock synchronization parameters, the control node will send a message through a policy to inform the aggregation node of the clock synchronization algorithm currently used (including the synchronization message interaction form, time information processing method, etc.). The execution node can send a time information upload message to the aggregation node, and the time information upload message includes time information; thereby, the aggregation node determines the clock synchronization parameters based on the time information and the clock synchronization algorithm and sends them to the control node; the control node sends a parameter release message carrying the clock synchronization parameters to the first node.

在本申请另一些实施例中,策略下发报文还包括汇聚节点的标识,汇聚节点是第一节点,第一节点获取时钟同步参数包括:执行节点向汇聚节点发送时间信息上传报文,时间信息上传报文包括时间信息;汇聚节点根据时间信息,确定时钟同步参数。In other embodiments of the present application, the policy message also includes the identifier of the aggregation node, the aggregation node is the first node, and the first node obtains the clock synchronization parameters including: the execution node sends a time information upload message to the aggregation node, the time information upload message includes time information; the aggregation node determines the clock synchronization parameters based on the time information.

也就是说,汇聚节点为第一节点,当第一节点和第二节点执行时钟同步算法时,可以由第二节点将发送和/或接收同步报文关联的时间戳或时钟计数器的数值携带在时间信息上传报文中发送给第一节点,第一节点根据时间信息计算出时钟同步参数后,可以直接根据该时钟同步参数调整本地时钟,第一节点还可以将时钟同步参数发送给第二节点,第二节点也可以根据该时钟同步参数对应调节本地时钟。That is to say, the aggregation node is the first node. When the first node and the second node execute the clock synchronization algorithm, the second node can carry the timestamp or clock counter value associated with the sending and/or receiving synchronization message in the time information upload message and send it to the first node. After the first node calculates the clock synchronization parameters based on the time information, it can directly adjust the local clock according to the clock synchronization parameters. The first node can also send the clock synchronization parameters to the second node, and the second node can also adjust the local clock accordingly according to the clock synchronization parameters.

控制节点发送的策略下发报文中包括时钟同步算法,还可以包括执行节点的标识、汇聚节点的标识中至少一项。在一些实施例中,策略下发报文中还可以包括第一时钟同步周期、同步报文的类型、同步报文传输使用的通信介质、同步报文的时间信息标记方式中至少一项,第一时钟同步周期是执行节点执行时钟同步算法的周期。The policy delivery message sent by the control node includes a clock synchronization algorithm and may also include at least one of an identifier of an execution node and an identifier of a convergence node. In some embodiments, the policy delivery message may also include at least one of a first clock synchronization period, a type of synchronization message, a communication medium used for transmission of the synchronization message, and a time information marking method of the synchronization message. The first clock synchronization period is a period during which the execution node executes the clock synchronization algorithm.

图6示出了本申请实施例提供的一种策略下发报文的结构,如图6所示,该报文的固定头字段以及可变头字段的细节可以参考图4的介绍,数据字段可以包括:时钟同步策略标志字段,可选的,策略下发报文的数据字段还可以包括:用于表示执行节点标识、汇聚节点标识、同步报文类型、第一时钟同步周期、同步报文通信介质、同步报文时间信息标记方式的字段中的至少一项。如果策略下发报文中只包括时钟同步策略标志字段,则可以默认由订阅时钟同步服务的第一节点以及第二节点执行该时钟同步算法并计算时钟同步参数,完成时钟同步服务。当控制节点根据第一节点和/或第二节点的硬件配置、负载、网络资源的使用情况和通信状况,确定执行时钟同步算法的执行节点和进行时钟同步参数计算的汇聚节点时,可以在策略下发报文中设置相应的字段。FIG6 shows the structure of a policy-sent message provided by an embodiment of the present application. As shown in FIG6 , the details of the fixed header field and the variable header field of the message can refer to the introduction of FIG4 . The data field may include: a clock synchronization policy flag field. Optionally, the data field of the policy-sent message may also include: at least one of the fields for indicating the execution node identifier, the aggregation node identifier, the synchronization message type, the first clock synchronization cycle, the synchronization message communication medium, and the synchronization message time information marking method. If the policy-sent message only includes the clock synchronization policy flag field, the first node and the second node that subscribe to the clock synchronization service can be defaulted to execute the clock synchronization algorithm and calculate the clock synchronization parameters to complete the clock synchronization service. When the control node determines the execution node that executes the clock synchronization algorithm and the aggregation node that performs the clock synchronization parameter calculation based on the hardware configuration, load, network resource usage and communication status of the first node and/or the second node, the corresponding fields can be set in the policy-sent message.

其中,时钟同步策略标志字段代表控制节点为订阅时钟同步服务的节点(第一节点和/或第二节点)指定的时钟同步算法,执行节点标识字段和汇聚节点标识字段分别承载执行节点的标识和汇聚节点的标识,同步报文类型字段承载同步报文类型,时钟同步周期字段承载第一时钟同步周期。Among them, the clock synchronization policy flag field represents the clock synchronization algorithm specified by the control node for the nodes (first node and/or second node) subscribing to the clock synchronization service, the execution node identification field and the aggregation node identification field carry the identification of the execution node and the aggregation node respectively, the synchronization message type field carries the synchronization message type, and the clock synchronization cycle field carries the first clock synchronization cycle.

时钟同步算法可以包括:网络时间协议(network time protocol,NTP)、精确时间协议(precision time protocol,PTP)、洪泛时钟同步协议(floodingtimesynchronizationprotocol,FTSP)、梯度时钟同步协议(gradienttimesynchronizationprotocol,GTSP)、概率时钟同步协议、基于WiFi TSF的时钟同步协议和基于加权平均的时钟同步协议等。The clock synchronization algorithms may include: network time protocol (NTP), precision time protocol (PTP), flooding time synchronization protocol (FTSP), gradient time synchronization protocol (GTSP), probabilistic clock synchronization protocol, WiFi TSF-based clock synchronization protocol, and weighted average-based clock synchronization protocol.

执行节点是执行该同步策略的节点,执行节点可以包括时钟同步服务的订阅节点(订阅请求报文中本端节点和目标节点指示的节点),还可以包括时钟同步服务的订阅节点之外的节点,执行节点的标识是执行该时钟同步算法的节点的标识。The execution node is the node that executes the synchronization strategy. The execution node may include the subscription node of the clock synchronization service (the node indicated by the local node and the target node in the subscription request message), and may also include nodes other than the subscription node of the clock synchronization service. The identifier of the execution node is the identifier of the node that executes the clock synchronization algorithm.

同步报文类型表示执行节点在执行时钟同步算法时交互的报文类型,通过指定同步报文类型,执行节点可以使用对应的协议流程和处理机制来交互同步报文和标记时间戳(时钟计数器的值),例如同步报文类型可以为用户数据报协议(userdatagramprotocol,UDP)报文、传输控制协议(transmissioncontrolprotocol,TCP)报文、链路层数据帧、信标帧和心跳报文等。控制节点可以根据执行节点支持的通信介质类型、节点负载、通信质量、选择的时钟同步算法等因素确定同步报文的类型。例如,UDP报文开销较小,可以在执行节点负载较大或者对同步精度要求较高时将同步报文的类型确定为UDP报文;WiFi网络支持TCP和UDP报文,当执行节点之间通过WiFi收发报文时,可以选择TCP或UDP报文;而当执行节点之间通过蓝牙收发报文时,报文的类型是链路层数据帧。The synchronization message type indicates the message type that the execution node exchanges when executing the clock synchronization algorithm. By specifying the synchronization message type, the execution node can use the corresponding protocol flow and processing mechanism to exchange synchronization messages and mark timestamps (clock counter values). For example, the synchronization message type can be a user datagram protocol (UDP) message, a transmission control protocol (TCP) message, a link layer data frame, a beacon frame, and a heartbeat message. The control node can determine the type of synchronization message based on factors such as the communication medium type supported by the execution node, the node load, the communication quality, and the selected clock synchronization algorithm. For example, the UDP message has a small overhead, and the type of synchronization message can be determined as a UDP message when the execution node load is large or the synchronization accuracy requirement is high; the WiFi network supports TCP and UDP messages. When the execution nodes send and receive messages through WiFi, TCP or UDP messages can be selected; and when the execution nodes send and receive messages through Bluetooth, the message type is a link layer data frame.

时钟同步周期表示执行节点进行时钟同步流程的平均时间间隔,该时钟同步周期可以与订阅请求报文中订阅时钟同步服务的节点(第一节点)在选项字段中携带的时钟同步周期一致,也可以不一致。该时钟同步周期可以是控制节点根据第一节点或第二节点的历史时钟值的置信区间的长度和时钟同步精度确定的,控制节点还会结合通信状况,节点的资源等因素确定该时钟同步周期。The clock synchronization period indicates the average time interval for executing the clock synchronization process of the node. The clock synchronization period may be consistent with or inconsistent with the clock synchronization period carried in the option field of the node (first node) subscribing to the clock synchronization service in the subscription request message. The clock synchronization period may be determined by the control node based on the length of the confidence interval of the historical clock value of the first node or the second node and the clock synchronization accuracy. The control node may also determine the clock synchronization period based on factors such as the communication status and the resources of the node.

汇聚节点是执行节点在执行时钟同步策略时时间信息上报以及汇聚的节点。也就是说,执行节点在时钟同步算法的执行和同步报文交互的过程中,会将时间信息(标记的报文发送时间信息、标记的报文接收时间信息、与同步报文发送或接收关联的时钟计数器数值中的至少一项)发送给汇聚节点,以便于汇聚节点进行同步参数的计算。The aggregation node is the node to which the execution node reports and aggregates time information when executing the clock synchronization strategy. That is to say, during the execution of the clock synchronization algorithm and the interaction of synchronization messages, the execution node will send time information (at least one of the marked message sending time information, the marked message receiving time information, and the clock counter value associated with the sending or receiving of the synchronization message) to the aggregation node, so that the aggregation node can calculate the synchronization parameters.

汇聚节点例如可以具有较强的计算能力和存储能力,能够根据执行节点上报的时间信息计算执行节点之间的时钟同步参数(例如,执行节点的时钟偏移值和/或频率偏移值),并下发相应的时钟同步参数。For example, the aggregation node may have strong computing and storage capabilities, and may calculate clock synchronization parameters between execution nodes (eg, clock offset values and/or frequency offset values of execution nodes) based on time information reported by the execution nodes, and issue corresponding clock synchronization parameters.

在控制节点将策略下发报文发送给执行节点和汇聚节点后,执行节点可以根据策略下发报文执行时钟同步算法,并通过时间信息上传报文向汇聚节点上传时间信息。After the control node sends the policy delivery message to the execution node and the aggregation node, the execution node can execute the clock synchronization algorithm according to the policy delivery message and upload the time information to the aggregation node through the time information upload message.

时间信息可以包括时间信息类型和对应的时间信息数据,还包括该时间信息对应的同步报文的发送节点的标识和接收节点的标识。The time information may include the time information type and the corresponding time information data, and also include the identifier of the sending node and the identifier of the receiving node of the synchronization message corresponding to the time information.

图7示出了本申请实施例提供的一种时间信息上传报文的结构。时间信息上传报文的固定头字段和可变头字段的细节可以参考图4的具体描述,数据字段中可以包括:本端节点标识字段、对端节点标识字段以及多个时间信息结构字段。具体的,本端节点标识字段和对端节点标识字段可以承载该时间信息对应的报文的发送节点和接收节点的标识,多个时间信息结构字段可以承载不同的时间信息。其中每个时间信息结构可以包括时间信息类型和时间信息数据。FIG7 shows the structure of a time information upload message provided by an embodiment of the present application. The details of the fixed header field and the variable header field of the time information upload message can refer to the specific description of FIG4 , and the data field may include: a local node identification field, a peer node identification field, and multiple time information structure fields. Specifically, the local node identification field and the peer node identification field may carry the identification of the sending node and the receiving node of the message corresponding to the time information, and multiple time information structure fields may carry different time information. Each time information structure may include a time information type and time information data.

发送节点和接收节点是该时间信息对应的同步报文的发送节点和接收节点。因此,一个时间信息上传报文中只包括两个节点之间交互的同步报文的时间信息(时间戳或时钟计数器数值)。例如,在执行时钟同步算法时,如果需要节点1和节点2进行同步报文交互,且需要节点1和节点3之间进行同步报文交互。则可以由节点1和/或节点2发送时间信息上传报文1,用于对节点1和节点2之间同步报文交互的时间信息进行上传,并且由节点1和/或节点3发送时间信息上传报文2,用于对节点1和节点3之间同步报文交互的时间信息进行上传。对应于不同的时钟同步算法,需要上传的时间信息是不同的,例如对于使用双向报文交互的时钟同步算法,同步报文的发送时间以及同步报文的接收时间都需要携带在时间信息上传报文中上传给汇聚节点(也就是说可以上传发送同步报文时读取的时钟计数器数值或标记的时间戳以及接收同步报文时读取的时钟计数器数值或标记的时间戳,也就是与同步报文的发送和接收关联的时钟计数器的数值或时间戳)。而对于使用单向报文传输的时钟同步算法,可以只上传同步报文的接收时间戳或接收同步报文时读取的时钟计数器数值(与同步报文的接收关联的时钟计数器的数值或时间戳)。The sending node and the receiving node are the sending node and the receiving node of the synchronization message corresponding to the time information. Therefore, a time information upload message only includes the time information (timestamp or clock counter value) of the synchronization message exchanged between the two nodes. For example, when executing the clock synchronization algorithm, if it is necessary for nodes 1 and 2 to interact with each other through synchronization messages, and it is necessary for nodes 1 and 3 to interact with each other through synchronization messages. Then, node 1 and/or node 2 may send time information upload message 1 to upload the time information of the synchronization message interaction between node 1 and node 2, and node 1 and/or node 3 may send time information upload message 2 to upload the time information of the synchronization message interaction between node 1 and node 3. Different clock synchronization algorithms require different time information to be uploaded. For example, for a clock synchronization algorithm that uses two-way message interaction, both the sending time and receiving time of the synchronization message need to be carried in the time information upload message and uploaded to the aggregation node (that is, the clock counter value or marked timestamp read when sending the synchronization message and the clock counter value or marked timestamp read when receiving the synchronization message can be uploaded, that is, the clock counter value or timestamp associated with the sending and receiving of the synchronization message). For a clock synchronization algorithm that uses one-way message transmission, only the receiving timestamp of the synchronization message or the clock counter value read when receiving the synchronization message (the clock counter value or timestamp associated with the reception of the synchronization message) can be uploaded.

时间信息上传报文中每个时间信息结构中可以包括时间信息类型和时间信息数据。时间信息类型与同步时执行节点使用的时钟同步算法有关。例如对于基于WiFi TSF的时钟同步协议(图2)来说,可以包括与同步报文的发送和接收关联的时间戳和时钟计数器的数值),时间信息数据即相应时间信息类型的具体数值。Each time information structure in the time information upload message may include a time information type and time information data. The time information type is related to the clock synchronization algorithm used by the execution node during synchronization. For example, for the WiFi TSF-based clock synchronization protocol (Figure 2), it may include a timestamp and a clock counter value associated with the sending and receiving of synchronization messages), and the time information data is the specific value of the corresponding time information type.

在上述实施例中,由于执行节点执行时钟同步算法过程中的时间信息会通过时间信息上传报文发送给汇聚节点,当汇聚节点根据时间信息确定时钟同步参数后,会将时钟同步参数通过参数发布报文发送给需要时钟同步服务的第一节点和/或第二节点。In the above embodiment, since the time information of the execution node during the execution of the clock synchronization algorithm will be sent to the aggregation node through the time information upload message, when the aggregation node determines the clock synchronization parameters based on the time information, it will send the clock synchronization parameters to the first node and/or the second node that needs the clock synchronization service through the parameter publishing message.

应理解,在本申请实施例中,第一节点和第二节点进行时钟同步时,由第一节点订阅时钟同步服务,而需要调节本地时钟(系统时钟或TSF时钟等物理时钟、逻辑时钟)的节点可以为第一节点或第二节点中的一个,也可以为第一节点和第二节点。而汇聚节点会根据需要调节本地时钟的节点的分布(如为需要时钟同步服务的部分节点和需要时钟同步服务的全部节点),计算出相应的时钟同步参数。It should be understood that in the embodiment of the present application, when the first node and the second node perform clock synchronization, the first node subscribes to the clock synchronization service, and the node that needs to adjust the local clock (physical clock such as system clock or TSF clock, logical clock) can be one of the first node or the second node, or the first node and the second node. The aggregation node will calculate the corresponding clock synchronization parameters according to the distribution of nodes that need to adjust the local clock (such as some nodes that need clock synchronization services and all nodes that need clock synchronization services).

仍然以第一节点和第二节点需要进行时钟同步为例,为了便于应用,可以默认由订阅时钟同步服务的节点(发送订阅请求报文的节点,第一节点)调节本地时钟,也可以由控制节点在制定时钟同步策略或汇聚节点在计算时钟同步参数时自行确定,本申请对此不做限定。汇聚节点可以将时钟同步参数携带在参数发布报文中发送给需要调节时钟的节点,也可以将参数发布报文发送给所有需要时钟同步的节点,而不考虑该节点是否需要调节时钟。下面以第一节点接收包括时钟同步参数的参数发布报文为例,介绍参数发布报文的具体细节。Still taking the need for clock synchronization between the first node and the second node as an example, for ease of application, the node that subscribes to the clock synchronization service (the node that sends the subscription request message, the first node) can adjust the local clock by default, or it can be determined by the control node when formulating the clock synchronization strategy or the aggregation node when calculating the clock synchronization parameters. This application does not limit this. The aggregation node can carry the clock synchronization parameters in a parameter release message and send it to the node that needs to adjust the clock, or it can send the parameter release message to all nodes that need clock synchronization, regardless of whether the node needs to adjust the clock. The following takes the example of the first node receiving a parameter release message including clock synchronization parameters to introduce the specific details of the parameter release message.

图8示出了本申请实施例提供的一种参数发布报文的结构。如图8所示,该报文的固定头字段和可变头字段的细节可以参考图4的相关描述,数据字段可以包括节点标识和时钟同步参数,节点标识字段承载需要调整本地时钟的节点,时钟同步参数字段可以承载时钟偏移值和/或时钟频率偏差和/或执行节点更新的时钟值等。Figure 8 shows the structure of a parameter publishing message provided by an embodiment of the present application. As shown in Figure 8, the details of the fixed header field and the variable header field of the message can refer to the relevant description of Figure 4, the data field can include a node identifier and a clock synchronization parameter, the node identifier field carries the node that needs to adjust the local clock, and the clock synchronization parameter field can carry a clock offset value and/or a clock frequency deviation and/or a clock value for executing node updates, etc.

时钟同步参数可以包括需要时钟同步服务的不同节点之间的时钟偏移值(clockoffset)和时钟频率偏差(clockskew)等参数,参数发布报文中还可以包括节点标识,该节点标识对应需要调节时钟的节点,例如对于第一节点和第二节点进行时钟同步的场景,可以为第一节点的标识和/或第二节点的标识。Clock synchronization parameters may include parameters such as the clock offset value (clockoffset) and clock frequency deviation (clockskew) between different nodes that require clock synchronization services. The parameter release message may also include a node identifier, which corresponds to the node that needs to adjust the clock. For example, in the scenario where the first node and the second node are synchronized, it may be the identifier of the first node and/or the identifier of the second node.

在本申请实施例中,控制节点发送策略发布报文后还可以更新时钟同步周期、时钟同步算法以及其他策略下发报文中携带的内容。In an embodiment of the present application, after the control node sends the policy release message, it can also update the clock synchronization period, the clock synchronization algorithm and the content carried in other policy release messages.

具体的,对于时钟同步周期,控制节点可以根据第一节点的时钟值的置信区间长度和时钟同步精度,确定第二时钟同步周期,或者,控制节点可以根据第二节点的时钟值的置信区间长度和时钟同步精度,确定第二时钟同步周期,第一节点的时钟值的置信区间或第二节点的时钟值的置信区间是汇聚节点根据时钟同步参数确定的;汇聚节点向控制节点发送时钟值的置信区间,接着控制节点向执行节点发送第二时钟同步周期;执行节点根据第二时钟同步周期,执行时钟同步算法;其中,当置信区间的长度与时钟同步精度的差值的绝对值小于第一预设阈值时,第一时钟同步周期是第二时钟同步周期;当置信区间的长度与时钟同步精度的差值的绝对值大于第一预设阈值且置信区间的长度大于时钟同步精度时,第二时钟同步周期小于第一时钟同步周期;当置信区间的长度与时钟同步精度的差值的绝对值大于第一预设阈值且置信区间的长度小于时钟同步精度时,第二同步周期大于第一时钟同步周期。Specifically, for the clock synchronization cycle, the control node can determine the second clock synchronization cycle based on the length of the confidence interval of the clock value of the first node and the clock synchronization accuracy, or the control node can determine the second clock synchronization cycle based on the length of the confidence interval of the clock value of the second node and the clock synchronization accuracy, the confidence interval of the clock value of the first node or the confidence interval of the clock value of the second node is determined by the aggregation node according to the clock synchronization parameters; the aggregation node sends the confidence interval of the clock value to the control node, and then the control node sends the second clock synchronization cycle to the execution node; the execution node executes the clock synchronization algorithm according to the second clock synchronization cycle; wherein, when the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is less than a first preset threshold, the first clock synchronization cycle is the second clock synchronization cycle; when the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is greater than the first preset threshold and the length of the confidence interval is greater than the clock synchronization accuracy, the second clock synchronization cycle is less than the first clock synchronization cycle; when the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is greater than the first preset threshold and the length of the confidence interval is less than the clock synchronization accuracy, the second synchronization cycle is greater than the first clock synchronization cycle.

也就是说,控制节点可以根据对第一节点和第二节点的时钟值的置信区间的估算和时钟同步精度需求,调整第一节点和第二节点的时钟同步周期。That is, the control node may adjust the clock synchronization period of the first node and the second node according to the estimation of the confidence interval of the clock values of the first node and the second node and the clock synchronization accuracy requirement.

例如,对于需要进行时钟同步的第一节点和第二节点,汇聚节点接收到时间信息后,利用统计学习方法可以计算出第一节点和第二节点的时钟同步参数(时钟偏移值和时钟频率偏差)。汇聚节点可以基于收集的第二节点侧的时钟值(T2),确定第一节点侧的预测时钟值 For example, for a first node and a second node that need to perform clock synchronization, after receiving the time information, the sink node can calculate the clock synchronization parameters (clock offset value) of the first node and the second node using a statistical learning method. and clock frequency deviation The sink node may determine the predicted clock value of the first node based on the collected clock value (T 2 ) of the second node.

另外,汇聚节点可以基于收集的第一节点侧的实际时钟值以及概率统计理论,估算第一节点的时钟值预测的置信区间,该置信区间可以发送给控制节点。控制节点通过比较时钟值预测的置信区间的长度和订阅请求报文携带的时钟同步精度的大小,可以将第一节点和第二节点的时钟同步周期更新为第二同步周期。In addition, the aggregation node can estimate the confidence interval of the clock value prediction of the first node based on the actual clock value collected on the first node side and probability statistics theory, and the confidence interval can be sent to the control node. The control node can update the clock synchronization period of the first node and the second node to the second synchronization period by comparing the length of the confidence interval of the clock value prediction and the size of the clock synchronization accuracy carried by the subscription request message.

当第一节点的置信区间的长度与时钟同步精度的差值的绝对值大于预设阈值时,可以调整第一节点和第二节点的时钟同步周期。具体的,当置信区间的长度与预设阈值的和小于时钟同步精度时,可以调大第一节点和第二节点的时钟同步周期,例如,将时钟同步周期调整为原来的两倍。当第一节点的时钟预测值的置信区间的长度与预设阈值的和大于时钟同步精度时,可以调小第二节点和第一节点的时钟同步间隔,例如将时钟同步周期调整为原来的一半。当第一节点的置信区间的长度与时钟同步精度的差值的绝对值小于预设阈值时,可以不调整第一节点和第二节点的时钟同步周期。When the absolute value of the difference between the length of the confidence interval of the first node and the clock synchronization accuracy is greater than a preset threshold, the clock synchronization period of the first node and the second node can be adjusted. Specifically, when the sum of the length of the confidence interval and the preset threshold is less than the clock synchronization accuracy, the clock synchronization period of the first node and the second node can be increased, for example, the clock synchronization period is adjusted to twice the original. When the sum of the length of the confidence interval of the clock prediction value of the first node and the preset threshold is greater than the clock synchronization accuracy, the clock synchronization interval between the second node and the first node can be reduced, for example, the clock synchronization period is adjusted to half of the original. When the absolute value of the difference between the length of the confidence interval of the first node and the clock synchronization accuracy is less than the preset threshold, the clock synchronization period of the first node and the second node may not be adjusted.

该预设阈值可以与依赖时钟同步的业务应用、节点负载和网络资源使用情况等因素有关,例如可以设置为时钟同步精度的倍数(例如,1.2倍、2倍等)。The preset threshold may be related to factors such as business applications that rely on clock synchronization, node load, and network resource usage, and may be set to a multiple of the clock synchronization accuracy (eg, 1.2 times, 2 times, etc.).

在确定第二时钟同步周期后,控制节点可以将第二时钟同步周期发送给执行节点和控制节点,以使得执行节点按照第二时钟同步周期交互同步报文进行时钟同步操作。After determining the second clock synchronization cycle, the control node may send the second clock synchronization cycle to the execution node and the control node, so that the execution node exchanges synchronization messages according to the second clock synchronization cycle to perform clock synchronization operations.

应理解,控制节点在确定第一节点和第二节点进行时钟同步的第一时钟同步周期时,可以依据第一节点或第二节点的历史时钟值的置信区间的长度和时钟同步精度确定该第一时钟同步周期,控制节点还会结合通信状况,节点的资源等因素确定该第一时钟同步周期。It should be understood that when the control node determines the first clock synchronization period for clock synchronization of the first node and the second node, it can determine the first clock synchronization period based on the length of the confidence interval of the historical clock value of the first node or the second node and the clock synchronization accuracy. The control node will also determine the first clock synchronization period based on factors such as communication conditions and node resources.

进一步的,控制节点在确定第二时钟同步周期后,可以基于网络资源使用情况和网络节点负载,更新执行节点使用的时钟同步算法,从而在满足时钟同步精度需求的前提下降低时钟同步的整体开销。例如,将时钟同步算法由基于WiFi TSF同步的方式调整为基于同步报文双向交互的方式,以避免对底层芯片硬件的依赖以及减小处理器的负载。再如,将时钟同步算法由基于WiFi传输同步报文的方式调整为基于蓝牙传输同步报文的方式,以减少时钟同步的功耗。Furthermore, after determining the second clock synchronization period, the control node can update the clock synchronization algorithm used by the execution node based on the network resource usage and the network node load, thereby reducing the overall clock synchronization overhead while meeting the clock synchronization accuracy requirements. For example, the clock synchronization algorithm is adjusted from a method based on WiFi TSF synchronization to a method based on two-way interaction of synchronization messages to avoid dependence on the underlying chip hardware and reduce the processor load. For another example, the clock synchronization algorithm is adjusted from a method based on WiFi transmission of synchronization messages to a method based on Bluetooth transmission of synchronization messages to reduce the power consumption of clock synchronization.

此外,控制节点还可以更新同步报文传输使用的通信介质,同步报文的时间信息标记方式、同步报文的类型等。In addition, the control node may also update the communication medium used for synchronization message transmission, the time information marking method of the synchronization message, the type of the synchronization message, etc.

在一些实施例中,也可以由汇聚节点按照与控制节点类似的方式确定第二时钟同步周期,并根据第二时钟同步周期确定第二时钟同步算法,再向执行节点发送新的策略下发报文,该策略下发报文包括第二同步周期和第二时钟同步算法,从而执行节点可以根据该策略下发报文执行第二时钟同步算法。In some embodiments, the aggregation node can also determine the second clock synchronization cycle in a manner similar to the control node, and determine the second clock synchronization algorithm based on the second clock synchronization cycle, and then send a new policy message to the execution node. The policy message includes the second synchronization cycle and the second clock synchronization algorithm, so that the execution node can execute the second clock synchronization algorithm according to the policy message.

对于控制节点确定的时钟同步算法(对应于策略下发报文中的时钟同步策略标志字段),控制节点是基于第一节点和第二节点的时钟同步需求(时钟同步精度)、网络资源使用情况、网络连接状况和节点时间读取方式等因素确定的时钟同步算法。下面以图9至图11为例,介绍在不同情况下,本申请实施例具体使用的时钟同步算法。For the clock synchronization algorithm determined by the control node (corresponding to the clock synchronization policy flag field in the policy delivery message), the control node determines the clock synchronization algorithm based on the clock synchronization requirements of the first node and the second node (clock synchronization accuracy), network resource usage, network connection status, and node time reading method. The clock synchronization algorithm specifically used in the embodiments of the present application in different situations is introduced below using Figures 9 to 11 as examples.

对于只能在用户态(或非网卡驱动固件侧)标记报文时间信息的节点,当需要毫秒级的时钟同步精度时,可以使用基于双向报文交互的同步方法。以第一节点和第二节点需要时钟同步为例,图9给出了该时钟同步算法的示例,包括:For nodes that can only mark message time information in user mode (or non-NIC driver firmware side), when millisecond-level clock synchronization accuracy is required, a synchronization method based on two-way message interaction can be used. Taking the first node and the second node requiring clock synchronization as an example, Figure 9 gives an example of the clock synchronization algorithm, including:

S910,第一节点向第二节点发送同步请求报文。S910: The first node sends a synchronization request message to the second node.

第一节点会在协议栈上层(如应用层)记录此时发送同步请求报文的时间T0,,并在该同步请求报文中携带该时间T0,The first node will record the time T 0, when the synchronization request message is sent at the upper layer of the protocol stack (such as the application layer), and carry the time T 0, in the synchronization request message.

S920,第一节点接收第二节点返回的同步响应报文。S920: The first node receives a synchronization response message returned by the second node.

该同步响应报文中包括第二节点接收同步请求报文的时间T1,以及发送同步响应报文的时间T2,,第一节点同时会在接收到该同步响应报文时,在协议栈上层记录接收该同步响应报文的时间T3,The synchronization response message includes the time T1 when the second node receives the synchronization request message and the time T2 when the synchronization response message is sent. When the first node receives the synchronization response message, it will record the time T3 when the synchronization response message is received in the upper layer of the protocol stack .

图9中的T0,和T3,是第一节点的系统时间,而T1,和T2,是第二节点的系统时间,将第一节点与第二节点之间的时钟偏移定义为θoffset,第一节点和第二节点之间单向的报文通信时延定义为d,,当忽略第一节点和第二节点之间的时钟漂移时(时钟频率偏差为0),则基于记录的时间信息T0,、T1,、T2,和T3,,可以通过以下方程(2)关联第一节点和第二节点之间的时钟偏移θoffset以及单向报文通信时延d的值:In FIG9 , T 0, and T 3, are the system time of the first node, and T 1, and T 2, are the system time of the second node. The clock offset between the first node and the second node is defined as θ offset , and the one-way message communication delay between the first node and the second node is defined as d . When the clock drift between the first node and the second node is ignored (the clock frequency deviation is 0), based on the recorded time information T 0, , T 1, , T 2, and T 3, , the clock offset θ offset between the first node and the second node and the one-way message communication delay d can be associated by the following equation (2):

T1,1=T0,1offset+dT 1,1 =T 0,1offset +d

T3,1=T2,1offset+d(2)T 3,1 =T 2,1offset +d(2)

通过求解上述方程(2),可以计算出第一节点和第二节点之间的时钟偏移值θoffset以及单向报文通信时延d的值,如公式(3)所示:By solving the above equation (2), the clock offset value θ offset between the first node and the second node and the value of the one-way message communication delay d can be calculated, as shown in formula (3):

当控制节点制定的时钟同步策略使用基于图9所示的同步方法时,策略下发报文中时钟同步策略标志位可以指示使用双向报文交互的同步方法,执行节点标识可以包括第一节点发送的订阅请求报文中的本端节点标识和目标节点标识,同步报文类型可以为:UDP报文、TCP报文和链路层数据帧等。时钟同步周期可以根据第一节点的订阅请求报文中携带的时钟同步周期、网络资源使用情况和通信状况等确定,也可以由系统预设值指定,汇聚节点标识可以为第一节点或第二节点的标识,也可以为其他节点的标识。When the clock synchronization strategy formulated by the control node uses the synchronization method shown in FIG9 , the clock synchronization strategy flag in the strategy delivery message may indicate the synchronization method using two-way message interaction, the execution node identifier may include the local node identifier and the target node identifier in the subscription request message sent by the first node, and the synchronization message type may be: UDP message, TCP message, link layer data frame, etc. The clock synchronization period may be determined based on the clock synchronization period carried in the subscription request message of the first node, the network resource usage, and the communication status, etc., or may be specified by a system preset value, and the aggregation node identifier may be the identifier of the first node or the second node, or the identifier of another node.

以汇聚节点为其他节点为例,可以由第一节点将时间信息上报给汇聚节点,时间信息上传报文中可以包括4个时间信息结构,“时间信息类型-时间信息数据”分别为:同步请求报文发送时间-T0,,同步请求报文接收时间-T1,,同步响应报文发送时间-T2,和同步响应报文接收时间-T3,Taking the aggregation node as other nodes as an example, the first node can report the time information to the aggregation node. The time information upload message can include 4 time information structures, and the "time information type-time information data" are: synchronization request message sending time-T 0 , synchronization request message receiving time-T 1, synchronization response message sending time-T 2, and synchronization response message receiving time-T 3 .

汇聚节点在接收到该时间信息上传报文后,可以计算出第一节点相对于第二节点的时钟偏移值,并将该时钟偏移值与第一节点标识携带在参数发布报文中发送给第一节点和控制节点,从而第一节点可以按照该报文的时钟偏移值调整本地系统时钟,以实现和第二节点的时钟同步。After receiving the time information upload message, the aggregation node can calculate the clock offset value of the first node relative to the second node, and carry the clock offset value and the first node identifier in the parameter publishing message to the first node and the control node, so that the first node can adjust the local system clock according to the clock offset value of the message to achieve clock synchronization with the second node.

当需要时钟同步服务的节点需要较高的时钟同步精度时,由于报文时间信息标记(时间戳标记或时钟计数器数值读取)的不确定性和报文交互时延的不对称性,基于双向报文交互的时钟同步算法将难以满足要求。为此,可以采用被动监听公共节点(如路由节点和网络访问点)单向广播参考报文的方式,取代双向报文交互,从而避免报文交互时延的不对称性,并减少报文时间信息标记的不确定性。When nodes that require clock synchronization services require higher clock synchronization accuracy, clock synchronization algorithms based on two-way message interaction will be difficult to meet the requirements due to the uncertainty of message time information marking (timestamp marking or clock counter value reading) and the asymmetry of message interaction delay. To this end, the method of passively monitoring public nodes (such as routing nodes and network access points) unidirectional broadcast reference messages can be used to replace two-way message interaction, thereby avoiding the asymmetry of message interaction delay and reducing the uncertainty of message time information marking.

在该时钟同步算法中,以第一节点和一个第二节点需要进行时钟同步为例,执行节点包括第一节点、第二节点和第三节点,第三节点作为参考报文发送节点。上报给汇聚节点的时间信息包括:第一节点接收多个参考报文的时间和第二节点接收多个参考报文的时间;汇聚节点确定的时钟同步参数包括以下至少一项:第一节点的时钟值和第二节点的时钟值的差值以及第一节点的时钟频率和第二节点的时钟频率的差值;或者,时钟同步参数包括以下至少一项:第一节点的时钟值和第一参考时钟值的差值、第二节点的时钟值和第一参考时钟值的差值、第一节点的时钟频率和第一参考时钟频率的差值以及第二节点的时钟频率和第一参考时钟频率的差值;其中,执行节点执行时钟同步算法包括:第三节点向第一节点和第二节点发送多个参考报文。In the clock synchronization algorithm, taking the need for clock synchronization between a first node and a second node as an example, the execution nodes include the first node, the second node and the third node, and the third node is used as a reference message sending node. The time information reported to the convergence node includes: the time when the first node receives multiple reference messages and the time when the second node receives multiple reference messages; the clock synchronization parameter determined by the convergence node includes at least one of the following: the difference between the clock value of the first node and the clock value of the second node and the difference between the clock frequency of the first node and the clock frequency of the second node; or, the clock synchronization parameter includes at least one of the following: the difference between the clock value of the first node and the first reference clock value, the difference between the clock value of the second node and the first reference clock value, the difference between the clock frequency of the first node and the first reference clock frequency, and the difference between the clock frequency of the second node and the first reference clock frequency; wherein, the execution node executes the clock synchronization algorithm including: the third node sends multiple reference messages to the first node and the second node.

该参考报文可以是周期性发送的。在一些实施例中,参考报文的发送周期与第一节点和第二节点之间的时钟同步周期一致。在另一实施例中,第三节点在每一个时钟同步周期内发送该多个周期性参考报文。The reference message may be sent periodically. In some embodiments, the sending period of the reference message is consistent with the clock synchronization period between the first node and the second node. In another embodiment, the third node sends the multiple periodic reference messages in each clock synchronization period.

具体的,图10示出了本申请实施例提供的基于单向广播报文的时钟同步方法的具体实施例,如图10的(a)和图10的(b)所示,例如L节点、N节点需要进行时钟同步,控制节点为A节点,汇聚节点为D节点,执行节点为L节点、N节点、K节点,其中,K节点不是需要时钟同步服务的节点,K节点是由A节点(控制节点)选取的参考报文广播节点。Specifically, Figure 10 shows a specific embodiment of the clock synchronization method based on unidirectional broadcast messages provided in an embodiment of the present application, as shown in Figure 10 (a) and Figure 10 (b), for example, L node and N node need to perform clock synchronization, the control node is A node, the aggregation node is D node, and the execution nodes are L node, N node, and K node, wherein K node is not a node that requires clock synchronization service, and K node is a reference message broadcast node selected by A node (control node).

执行时钟同步算法时,可以由K节点通过广播形式向L节点、N节点发送R个参考报文,从而两个节点可以在收到广播参考报文后,根据时钟同步算法和本端时间读取能力,在内核态(例如网卡固件)或用户态记录多个参考报文的接收时间并将该接收时间上传给汇聚节点D。When executing the clock synchronization algorithm, the K node can send R reference messages to the L node and the N node in the form of broadcasting, so that after receiving the broadcast reference message, the two nodes can record the reception time of multiple reference messages in the kernel state (such as the network card firmware) or user state according to the clock synchronization algorithm and the local time reading capability, and upload the reception time to the aggregation node D.

L节点接收第i个同步报文的时间T2,i和N节点接收第i个同步报文的时间T3,i满足公式(4)所示的关系:The time T 2,i when the L node receives the i-th synchronization message and the time T 3,i when the N node receives the i-th synchronization message satisfy the relationship shown in formula (4):

其中,是K节点向L节点发送第i个同步报文的时延的不确定性部分,是K节点向N节点发送第i个同步报文的时延的不确定性部分,θskew和θoffset分别是L节点和N节点之间的时钟频率偏差和时钟偏移值,dKL和dKN分别为K节点向L节点和N节点发送同步报文的单向传输时延的确定性部分,L节点的时间信息上传报文中包括的“时间信息类型-时间信息数据”为“第i次报文接收时间-T2,i”,N节点的时间信息上传报文中包括的“时间信息类型-时间信息数据”为“第i次报文接收时间-T3,i”,K节点的时间信息上传报文中包括的时间信息类型-时间信息数据为“第i次报文发送时间-T1,i”。K节点和L节点之间的时钟频率偏差和时钟偏移值K节点和N节点的时钟频率偏差和时钟偏移值满足公式(5)的关系:in, is the uncertainty part of the delay of node K sending the i-th synchronization message to node L, is the uncertainty part of the delay of K node sending the i-th synchronization message to N node, θ skew and θ offset are the clock frequency deviation and clock offset values between L node and N node respectively, d KL and d KN are the deterministic part of the one-way transmission delay of K node sending synchronization message to L node and N node respectively, the "time information type-time information data" included in the time information upload message of L node is "i-th message reception time-T 2,i ", the "time information type-time information data" included in the time information upload message of N node is "i-th message reception time-T 3,i ", and the time information type-time information data included in the time information upload message of K node is "i-th message sending time-T 1,i ". Clock frequency deviation and clock offset values between K node and L node and Clock frequency deviation and clock offset value of K node and N node and The relationship satisfying formula (5) is:

当KL和KN之间的时延的不确定性部分满足正态分布并且忽略L节点和N节点之间的节点漂移(时钟频率偏差)时,θskew=0,则L节点和N节点的时钟偏移值θoffset可以通过公式(6)计算:When the uncertainty of the delay between KL and KN is and When the normal distribution is satisfied and the node drift (clock frequency deviation) between the L node and the N node is ignored, θ skew = 0, then the clock offset value θ offset of the L node and the N node can be calculated by formula (6):

当KL和KN之间的时延的不确定性部分满足正态分布并且考虑L节点和N节点之间的节点漂移(时钟频率偏差不为0)时,L节点和N节点的时钟偏移值θoffset、时钟频率偏差θskew可以通过公式(7)计算:When the uncertainty of the delay between KL and KN is and When the normal distribution is satisfied and the node drift between the L node and the N node is considered (the clock frequency deviation is not 0), the clock offset value θ offset and the clock frequency deviation θ skew of the L node and the N node can be calculated by formula (7):

x[i]=T2,i-T3,ix[i]=T 2,i -T 3,i

μ=dKL-dKN μ=d KL -d KN

Di=T1,i-T1,1 (7)D i = T 1,i -T 1,1 (7)

汇聚节点D在计算出时钟偏移值和/或时钟频率偏差后,可以将时钟偏移值和/或时钟频率偏差携带在时钟同步参数发布报文中分别发送给L节点或N节点。可选的,汇聚节点D也可以先将同步参数发送给控制节点A节点,再由A节点发送给L节点或N节点。应理解,上述公式(6)和公式(7)中是将L节点向N节点对齐或者N节点向L节点对齐,在一些实施例中,也可以将L节点和N节点调节到同一个参考时钟值和/或参考时钟频率,本申请不限定具体时钟的调节方式。After calculating the clock offset value and/or clock frequency deviation, the aggregation node D can carry the clock offset value and/or clock frequency deviation in the clock synchronization parameter release message and send it to the L node or N node respectively. Optionally, the aggregation node D can also first send the synchronization parameter to the control node A node, and then the A node sends it to the L node or N node. It should be understood that the above formula (6) and formula (7) align the L node to the N node or the N node to the L node. In some embodiments, the L node and the N node can also be adjusted to the same reference clock value and/or reference clock frequency. The present application does not limit the specific clock adjustment method.

对于支持WiFi通信和TSF计数器读取的网络同步节点,可以利用TSF计数器进行系统时钟的同步。例如对于需要同步的节点处于同一个局域网下的场景,可以使用图2所示的同步方法进行时钟同步。For network synchronization nodes that support WiFi communication and TSF counter reading, the TSF counter can be used to synchronize the system clock. For example, for a scenario where the nodes to be synchronized are in the same local area network, the synchronization method shown in Figure 2 can be used for clock synchronization.

而对于需要同步的节点不在同一个局域网下的场景,本申请实施例提供了一种时钟同步方法。第一节点和第二节点可以按照顺序先进行时钟同步,当需要与第一节点进行时钟同步的节点还包括其他节点时,可以在第一节点和第二节点进行时钟同步后,用其他节点按照与第二节点类似的方式与第一节点进行时钟同步,最终实现所有需要时钟同步服务的节点实现时钟同步。下面首先介绍第一节点和第二节点进行时钟同步的过程。执行节点包括第一节点和第二节点,该第一节点和第二节点在不同的局域网中,执行节点执行时钟同步算法的过程可以包括以下步骤:第一节点将第一节点的TSF时钟与第一节点的系统时钟对齐;第一节点向第二节点发送第一同步报文;第二节点向第一节点发送第二同步报文;第二节点根据时钟同步参数,调节第二节点的TSF时钟;第二节点根据调整后的TSF时钟,调节第二节点的系统时钟。需要由执行节点中的第一节点和第二节点上传给汇聚节点的时间信息包括:第一同步报文的TSF接收时间和TSF发送时间,第二同步报文的TSF发送时间和TSF接收时间(TSF接收时间或TSF发送时间指的是接收或发送报文时读取的TSF时钟的数值)。For the scenario where the nodes that need to be synchronized are not in the same local area network, an embodiment of the present application provides a clock synchronization method. The first node and the second node can first perform clock synchronization in sequence. When the nodes that need to perform clock synchronization with the first node also include other nodes, after the first node and the second node perform clock synchronization, other nodes can be used to perform clock synchronization with the first node in a similar manner to the second node, and finally all nodes that require clock synchronization services achieve clock synchronization. The following first introduces the process of clock synchronization between the first node and the second node. The execution node includes a first node and a second node, and the first node and the second node are in different local area networks. The process of executing the clock synchronization algorithm by the execution node may include the following steps: the first node aligns the TSF clock of the first node with the system clock of the first node; the first node sends a first synchronization message to the second node; the second node sends a second synchronization message to the first node; the second node adjusts the TSF clock of the second node according to the clock synchronization parameters; the second node adjusts the system clock of the second node according to the adjusted TSF clock. The time information that needs to be uploaded to the aggregation node by the first node and the second node in the execution node includes: the TSF reception time and TSF sending time of the first synchronization message, the TSF sending time and TSF reception time of the second synchronization message (TSF reception time or TSF sending time refers to the value of the TSF clock read when receiving or sending the message).

图11示出了该时钟同步算法的具体实施例,如图11所示,可以在需要同步的节点中选取主节点和从节点,将从节点的时钟向主节点的时钟对齐。FIG11 shows a specific embodiment of the clock synchronization algorithm. As shown in FIG11 , a master node and a slave node may be selected from the nodes that need to be synchronized, and the clock of the slave node may be aligned with the clock of the master node.

示例性的,发送订阅请求报文的第一节点可以为主节点,而第二节点可以为从节点,可以先将第一节点的系统时钟与第一节点的TSF时钟对齐,再将第二节点的TSF时钟向第一节点的TSF时钟对齐,最后将第二节点的系统时钟向第二节点的TSF时钟对齐。Exemplarily, the first node that sends the subscription request message can be the master node, and the second node can be the slave node. The system clock of the first node can be aligned with the TSF clock of the first node first, and then the TSF clock of the second node can be aligned with the TSF clock of the first node, and finally the system clock of the second node can be aligned with the TSF clock of the second node.

对于将第一节点的系统时钟与TSF时钟对齐的过程,可以使得其系统时钟向TSF时钟对齐,也可以使得第一节点的TSF时钟向系统时钟对齐,以将第一节点的TSF时钟向系统时钟对齐为例,如图11中的S1110所示,可以由第一节点分别读取系统时钟和TSF时钟并最小化系统时钟和TSF时钟的差异,从而将TSF时钟同步到系统时钟。实际过程中,TSF时钟或系统时钟读取存在一定的时延和波动。可以采取多次连续读取系统时钟和TSF时钟并选取最小读取时钟数值差的方式,减小读取波动的影响。该多次读取可以是周期性或非周期性读取。对于周期性读取的情况,可以按照时钟同步周期读取系统时钟和TSF时钟(一个时钟同步周期读取一次系统时钟和TSF时钟),也可以在一个时钟同步周期内多次读取系统时钟和TSF时钟。For the process of aligning the system clock of the first node with the TSF clock, its system clock can be aligned with the TSF clock, or the TSF clock of the first node can be aligned with the system clock. Taking the alignment of the TSF clock of the first node with the system clock as an example, as shown in S1110 in Figure 11, the first node can read the system clock and the TSF clock respectively and minimize the difference between the system clock and the TSF clock, so as to synchronize the TSF clock to the system clock. In the actual process, there is a certain delay and fluctuation in the reading of the TSF clock or the system clock. The system clock and the TSF clock can be read continuously for multiple times and the minimum reading clock value difference can be selected to reduce the influence of the reading fluctuation. The multiple readings can be periodic or non-periodic readings. For the case of periodic reading, the system clock and the TSF clock can be read according to the clock synchronization cycle (the system clock and the TSF clock are read once in one clock synchronization cycle), or the system clock and the TSF clock can be read multiple times in one clock synchronization cycle.

例如,Tk+1与Tk-1的差值小于Tk+4与Tk+2的差值,且小于其他读取差值,可以使用Tk+1与Tk-1这一组读取数据计算第一节点的系统时钟和TSF时钟的偏移值如下面的公式(8)所示:For example, the difference between T k+1 and T k-1 is smaller than the difference between T k+4 and T k+2 , and smaller than other read differences. The offset value of the system clock and TSF clock of the first node can be calculated using the set of read data T k+1 and T k-1. As shown in the following formula (8):

之后,可以根据S1120中的一轮同步报文交互同步第二节点和第一节点的TSF时钟,利用双向报文交互的方式,第二节点将其TSF时钟同步到第一节点的TSF时钟。在同步报文交互的过程中,第二节点和第一节点网卡可以用TSF时钟标记报文的发送时间和接收时间。在每一轮同步报文交互后(S1120中N轮同步报文交互可以对应N个时钟同步周期内的每个时钟同步周期需要进行的同步报文交互过程),如果不考虑第一节点和第二节点的时钟频率偏差和同步报文往返通信时延的差异时,两个节点的TSF时钟的时钟偏移值θoffset可以按如下公式(9)计算:Afterwards, the TSF clocks of the second node and the first node can be synchronized according to a round of synchronization message interaction in S1120, and the second node synchronizes its TSF clock to the TSF clock of the first node by using a two-way message interaction method. During the synchronization message interaction process, the second node and the first node network card can use the TSF clock to mark the sending time and receiving time of the message. After each round of synchronization message interaction (N rounds of synchronization message interaction in S1120 can correspond to the synchronization message interaction process that needs to be performed in each clock synchronization cycle within N clock synchronization cycles), if the clock frequency deviation between the first node and the second node and the difference in the round-trip communication delay of the synchronization message are not considered, the clock offset value θ offset of the TSF clocks of the two nodes can be calculated according to the following formula (9):

其中,T1,i为第一同步报文的TSF接收时间,T0,i为第一同步报文的TSF发送时间、T3,i为第二同步报文的TSF接收时间,T2,i为第二同步报文的TSF发送时间,第一同步报文的TSF发送时间以及第二同步报文的TSF接收时间是指第一节点将系统时钟和TSF时钟同步后,发送第一同步报文和接收第二同步报文时的TSF时钟值。据此,第二节点可以调整其TSF时钟值,以最小化第二节点TSF时钟和第一节点TSF时钟的差异。由于第一节点系统时钟和TSF时钟已经同步(S1110),从而第二节点的TSF时钟也同步于第一节点的系统时钟(或第一节点的TSF时钟)。Wherein, T 1,i is the TSF receiving time of the first synchronization message, T 0,i is the TSF sending time of the first synchronization message, T 3,i is the TSF receiving time of the second synchronization message, T 2,i is the TSF sending time of the second synchronization message, and the TSF sending time of the first synchronization message and the TSF receiving time of the second synchronization message refer to the TSF clock value when the first node sends the first synchronization message and receives the second synchronization message after synchronizing the system clock and the TSF clock. Accordingly, the second node can adjust its TSF clock value to minimize the difference between the TSF clock of the second node and the TSF clock of the first node. Since the system clock and the TSF clock of the first node are synchronized (S1110), the TSF clock of the second node is also synchronized with the system clock of the first node (or the TSF clock of the first node).

如果考虑同步报文的单向通信时延的不确定性部分,可以按照图11的S1120步骤,第一节点和第二节点进行多次(N次)双向报文交互(第一同步报文和第二同步报文)。该多次报文交互可以是周期性报文交互或者非周期性报文交互。对于周期性报文交互,可以按照时钟同步周期进行双向报文交互(在一个时钟同步周期内执行一次第一同步报文和第二同步报文的交互),也可以在一个时钟同步周期内进行N次双向报文交互(在一个时钟同步周期内执行N次第一同步报文和第二同步报文的交互)。在第i次报文交互过程中,第一节点向第二节点发送第一同步报文,并接收来自第二节点的第二同步报文。第一节点会记录发送第一同步报文的时间T0,i以及接收第二同步报文的时间T3,i,第二节点会记录接收第一同步报文的时间T1,i和发送第二同步报文的时间T2,iIf the uncertainty of the one-way communication delay of the synchronization message is considered, the first node and the second node can perform multiple (N) two-way message interactions (first synchronization message and second synchronization message) according to step S1120 of Figure 11. The multiple message interactions can be periodic message interactions or non-periodic message interactions. For periodic message interactions, two-way message interactions can be performed according to the clock synchronization cycle (the interaction of the first synchronization message and the second synchronization message is performed once in a clock synchronization cycle), or N two-way message interactions can be performed in a clock synchronization cycle (the interaction of the first synchronization message and the second synchronization message is performed N times in a clock synchronization cycle). During the i-th message interaction process, the first node sends a first synchronization message to the second node and receives a second synchronization message from the second node. The first node will record the time T 0,i of sending the first synchronization message and the time T 3,i of receiving the second synchronization message, and the second node will record the time T 1,i of receiving the first synchronization message and the time T 2,i of sending the second synchronization message.

图11中的T0,i和T3,i是第一节点的TSF时间,而T1,i和T2,i是第二节点的TSF时间,将第一节点与第二节点之间的TSF时钟偏移定义为θoffset,第一节点和第二节点之间第i次报文交互过程中单向的报文通信时延的确定性部分定义为d,单向的报文通信时延的不确定性部分定义为Xi(第一节点向第二节点发送第一同步报文的通信时延的不确定性部分)和Yi(第二节点向第一节点发送第二同步报文的通信时延的不确定性部分),当忽略第一节点和第二节点之间的时钟漂移时(时钟频率偏差为0),则基于记录的TSF时间T0,i、T1,i、T2,i和T3,i,可以通过以下方程(10)关联第一节点和第二节点之间的时钟偏移θoffset以及单向报文通信时延的确定性部分d和不确定性部分Xi、YiIn FIG11 , T 0,i and T 3,i are TSF times of the first node, and T 1,i and T 2,i are TSF times of the second node. The TSF clock offset between the first node and the second node is defined as θ offset . The deterministic part of the one-way message communication delay during the i-th message interaction between the first node and the second node is defined as d. The uncertainty part of the one-way message communication delay is defined as Xi (the uncertainty part of the communication delay of the first node sending the first synchronization message to the second node) and Yi (the uncertainty part of the communication delay of the second node sending the second synchronization message to the first node). When the clock drift between the first node and the second node is ignored (the clock frequency deviation is 0), based on the recorded TSF times T 0,i , T 1,i , T 2,i and T 3,i , the clock offset θ offset between the first node and the second node and the deterministic part d and the uncertainty parts Xi and Yi of the one-way message communication delay can be associated by the following equation (10):

T1,i=T0,ioffset+d+Xi T 1,i =T 0,ioffset +d+X i

T3,i=T2,ioffset+d+Yi (10)T 3,i =T 2,ioffset +d+Y i (10)

基于对上述方程(10)中对第一节点和第二节点之间报文通信时延的不确定性部分建模,可以计算出时钟偏移θoffset的值。例如,当第一节点和第二节点之间报文通信时延的不确定性部分满足正态分布时,可以按照公式(11)计算出第一节点和第二节点之间的时钟偏移值θoffsetBased on modeling the uncertainty part of the message communication delay between the first node and the second node in the above equation (10), the value of the clock offset θ offset can be calculated. For example, when the uncertainty part of the message communication delay between the first node and the second node satisfies the normal distribution, the clock offset value θ offset between the first node and the second node can be calculated according to formula (11):

当第一节点和第二节点之间报文通信时延的不确定性部分满足指数分布时,可以按公式(12)的方式计算出第一节点和第二节点之间的时钟偏移θoffsetWhen the uncertainty of the message communication delay between the first node and the second node satisfies the exponential distribution, the clock offset θ offset between the first node and the second node can be calculated according to formula (12):

Ui=T1,i-T0,i U i = T 1,i - T 0,i

Vi=T3,i-T2,i (12)V i = T 3,i -T 2,i (12)

当考虑第一节点和第二节点之间的时钟漂移(时钟频率偏差不为0)时,可以通过以下方程关联第一节点和第二节点之间的时钟偏移θoffset和时钟频率偏差θskew以及单向报文通信时延的确定性部分d和不确定性部分Xi、YiWhen the clock drift between the first node and the second node is considered (the clock frequency deviation is not 0), the clock offset θ offset and the clock frequency deviation θ skew between the first node and the second node and the deterministic part d and the uncertain parts Xi and Yi of the one-way message communication delay can be associated by the following equation:

T1,i=T0,ioffset+d+Xiskew(T0,i-T0,1+d+Xi)T 1,i =T 0,ioffset +d+X iskew (T 0,i -T 0,1 +d+X i )

T2,i=T3,ioffset-d-Yiskew(T3,i-T0,1-d-Yi) (13)T 2,i =T 3,ioffset -dY iskew (T 3,i -T 0,1 -dY i ) (13)

基于对上述方程(13)中第一节点和第二节点之间报文通信时延的不确定性部分的建模,可以计算出时钟偏移θoffset和时钟频率偏差θskew的值。例如,当第一节点和第二节点之间报文通信时延的不确定性部分满足正态分布时,可以按公式(14)的方式计算出第一节点和第二节点之间的时钟偏移θoffset和时钟频率偏差θskewBased on the modeling of the uncertainty part of the message communication delay between the first node and the second node in the above equation (13), the values of the clock offset θ offset and the clock frequency deviation θ skew can be calculated. For example, when the uncertainty part of the message communication delay between the first node and the second node satisfies the normal distribution, the clock offset θ offset and the clock frequency deviation θ skew between the first node and the second node can be calculated according to formula (14):

当控制节点制定的时钟同步策略使用基于图11所示的同步方法时,策略下发报文中时钟同步策略标志位可以指示使用该同步算法,执行节点标识可以包括第一节点发送的订阅请求报文中的本端节点标识和目标节点标识,同步报文类型可以为:UDP报文、TCP报文和链路层数据帧等。时钟同步周期可以根据第一节点的订阅请求报文中携带的时钟同步周期、网络资源使用情况和通信状况等确定,也可以由系统预设值指定,汇聚节点标识可以为第一节点或第二节点的标识,也可以为其他节点的标识。When the clock synchronization strategy formulated by the control node uses the synchronization method shown in FIG11, the clock synchronization strategy flag in the strategy delivery message can indicate the use of the synchronization algorithm, the execution node identifier can include the local node identifier and the target node identifier in the subscription request message sent by the first node, and the synchronization message type can be: UDP message, TCP message, link layer data frame, etc. The clock synchronization period can be determined based on the clock synchronization period carried in the subscription request message of the first node, the network resource usage and communication status, etc., or can be specified by the system preset value, and the aggregation node identifier can be the identifier of the first node or the second node, or the identifier of other nodes.

以汇聚节点为其他节点为例,可以由第一节点将时间信息上报给汇聚节点,对于第i次报文交互过程,则时间信息上传报文中可以包括4个时间信息结构,“时间信息类型-时间信息数据”分别为:第一同步报文发送时间-T0,,第一同步报文接收时间-T1,,第二同步报文发送时间-T2,和第二同步报文接收时间-T3,Taking the aggregation node as other nodes as an example, the first node can report the time information to the aggregation node. For the i-th message interaction process, the time information upload message can include 4 time information structures, and the "time information type-time information data" are: the first synchronization message sending time-T 0, the first synchronization message receiving time-T 1 , the second synchronization message sending time-T 2, and the second synchronization message receiving time-T 3 .

汇聚节点在接收到该时间信息上传报文后,可以计算出第一节点的TSF时钟相对于第二节点的TSF时钟的时钟偏移值和/或时钟频率偏差,并将该时钟偏移值和/或时钟频率偏差与第一节点标识携带在参数发布报文中发送给第二节点,从而第二节点可以按照该报文的时钟偏移值和/或时钟频率偏差调整TSF时钟,以实现和第一节点的TSF时钟同步。After receiving the time information upload message, the aggregation node can calculate the clock offset value and/or clock frequency deviation of the TSF clock of the first node relative to the TSF clock of the second node, and carry the clock offset value and/or clock frequency deviation together with the first node identifier in a parameter publishing message and send it to the second node, so that the second node can adjust the TSF clock according to the clock offset value and/or clock frequency deviation of the message to achieve synchronization with the TSF clock of the first node.

最后,按照S1130同步第二节点的系统时钟和TSF时钟。与S1110类似,通过分别读取系统时钟和TSF时钟,第二节点可以将其系统时钟同步到TSF时钟。由于第二节点的TSF时钟已经同步于第一节点的系统时钟(步骤S1120),所以第一节点的系统时钟也会同步于第二节点的系统时钟。Finally, the system clock and TSF clock of the second node are synchronized according to S1130. Similar to S1110, by reading the system clock and TSF clock respectively, the second node can synchronize its system clock to the TSF clock. Since the TSF clock of the second node has been synchronized with the system clock of the first node (step S1120), the system clock of the first node will also be synchronized with the system clock of the second node.

由于TSF时钟可以在网卡固件侧读取,从而可以减少同步报文时间信息标记过程中系统调度和协议栈处理等的不确定性,提高时钟同步的精度。对于图11中步骤S1120同步报文的交互,第二节点和第一节点将会把读取的TSF时钟的数值上传给汇聚节点,由其计算出第一节点和第二节点的TSF时钟偏移值并发布给第一节点和第二节点。Since the TSF clock can be read on the network card firmware side, the uncertainty of system scheduling and protocol stack processing in the synchronization message time information marking process can be reduced, and the accuracy of clock synchronization can be improved. For the interaction of the synchronization message in step S1120 in Figure 11, the second node and the first node will upload the read TSF clock value to the aggregation node, which will calculate the TSF clock offset value of the first node and the second node and publish it to the first node and the second node.

前文是以将发送订阅请求报文的发送节点第一节点作为主节点,并且第一节点发送第一同步报文为例介绍了在第一节点和第二节点处于不同的WiFi网络中进行时钟同步的过程。在实际情况中,也可以由第一节点作为从节点,即由第二节点发送第一同步报文,而由发送订阅请求报文的第一节点使用时钟同步参数调节其TSF时钟,在这种情况下时钟同步的过程如下:The previous article takes the first node that sends the subscription request message as the master node and the first node sends the first synchronization message as an example to introduce the process of clock synchronization when the first node and the second node are in different WiFi networks. In actual situations, the first node can also be used as a slave node, that is, the second node sends the first synchronization message, and the first node that sends the subscription request message uses the clock synchronization parameters to adjust its TSF clock. In this case, the clock synchronization process is as follows:

第二节点将第二节点的TSF时钟与第二节点的系统时钟对齐;第二节点向第一节点发送第一同步报文;第一节点向第二节点发送第二同步报文;第一节点根据时钟同步参数和第二节点的TSF时钟,调节第一节点的TSF时钟;第一节点根据调整后的TSF时钟,调节第一节点的系统时钟。从而需要执行节点上传给汇聚节点的时间信息包括:第一同步报文的TSF接收时间和第一同步报文的TSF发送时间、第二同步报文的TSF接收时间和第二同步报文的TSF发送时间。The second node aligns the TSF clock of the second node with the system clock of the second node; the second node sends the first synchronization message to the first node; the first node sends the second synchronization message to the second node; the first node adjusts the TSF clock of the first node according to the clock synchronization parameters and the TSF clock of the second node; the first node adjusts the system clock of the first node according to the adjusted TSF clock. Therefore, the time information that needs to be uploaded to the aggregation node by the execution node includes: the TSF receiving time of the first synchronization message and the TSF sending time of the first synchronization message, the TSF receiving time of the second synchronization message and the TSF sending time of the second synchronization message.

前文以主节点系统时钟向TSF时钟同步-从节点向主节点同步TSF时钟-从节点系统时钟向TSF时钟同步为例介绍了本申请的针对WiFi-TSF同步方案的改进。在实际中,也可以先同步两个节点的TSF时钟,再分别将各自的系统时钟向TSF时钟同步,本申请实施例不限定针对该方法的实施步骤。The above article introduces the improvement of the WiFi-TSF synchronization scheme of the present application by taking the master node system clock synchronizing with the TSF clock - the slave node synchronizing with the master node TSF clock - the slave node system clock synchronizing with the TSF clock as an example. In practice, the TSF clocks of the two nodes can also be synchronized first, and then the respective system clocks are synchronized with the TSF clock. The embodiments of the present application do not limit the implementation steps of the method.

在本申请实施例中,如果第一节点和/或第二节点设备的计算能力、存储能力、通信能力和可用电量都比较有限,且对于时钟同步精度的要求不高,控制节点确定的执行节点也可以不包括第一节点和/或第二节点。以图1的系统为例,局域网3中的第一节点(设备13)和第二节点(设备14)需要进行时钟同步,但是两个节点的硬件配置较差。则控制节点确定时钟同步策略时,可以将局域网2中的节点选为执行节点和汇聚节点,当局域网2中选择的执行节点时钟同步到第二参考时钟值(和/或第二参考时钟频率)时,可以将该第一时钟值上报给控制节点,由控制节点将该第二参考时钟值(和/或第二参考时钟频率)携带在参数发布报文中发送给第一节点和第二节点。第一节点和第二节点可以各自将时钟值调整到第二参考时钟值(和/或第二参考时钟频率),实现时钟同步,该第二参考时钟值(和/或第二参考时钟频率)即前文所述的时钟同步参数,这里可以为一个更新的时钟值(和/或更新的时钟频率)。In an embodiment of the present application, if the computing power, storage capacity, communication capacity and available power of the first node and/or the second node device are relatively limited, and the requirements for clock synchronization accuracy are not high, the execution node determined by the control node may not include the first node and/or the second node. Taking the system of Figure 1 as an example, the first node (device 13) and the second node (device 14) in the local area network 3 need to be clock synchronized, but the hardware configuration of the two nodes is poor. When the control node determines the clock synchronization strategy, the nodes in the local area network 2 can be selected as execution nodes and aggregation nodes. When the execution node clock selected in the local area network 2 is synchronized to the second reference clock value (and/or the second reference clock frequency), the first clock value can be reported to the control node, and the control node carries the second reference clock value (and/or the second reference clock frequency) in the parameter release message and sends it to the first node and the second node. The first node and the second node can each adjust the clock value to a second reference clock value (and/or a second reference clock frequency) to achieve clock synchronization. The second reference clock value (and/or the second reference clock frequency) is the clock synchronization parameter mentioned above, which can be an updated clock value (and/or an updated clock frequency) here.

控制节点可以根据第一节点和第二节点之间不同的时钟同步精度的要求,指示局域网2中的执行节点使用不同的时钟同步算法进行时钟同步,从而局域网2中的执行节点可以形成时钟同步域,执行节点之间的时钟同步参数可以由局域网2中的设备或者执行节点自身计算,也可也上传到远端控制节点或者云端,由其进行时钟同步参数的计算。使需要同步的节点在无需执行时钟同步算法的情况下,也可以便捷地获取时钟同步服务,实现本地时钟的同步。The control node can instruct the execution nodes in the local area network 2 to use different clock synchronization algorithms for clock synchronization according to the different clock synchronization accuracy requirements between the first node and the second node, so that the execution nodes in the local area network 2 can form a clock synchronization domain, and the clock synchronization parameters between the execution nodes can be calculated by the devices in the local area network 2 or the execution nodes themselves, or can also be uploaded to the remote control node or the cloud, which calculates the clock synchronization parameters. This allows the nodes that need to be synchronized to easily obtain clock synchronization services without executing the clock synchronization algorithm, thereby achieving synchronization of the local clock.

应理解,上述仅示意性地通过图9至图11以及图2介绍了几种时钟同步算法,在实际情况下,根据通信连接、节点配置、网络资源使用情况等因素的变化,还可以使用其他不同的时钟同步算法实现,本申请实施例不再一一列举。It should be understood that the above only schematically introduces several clock synchronization algorithms through Figures 9 to 11 and Figure 2. In actual situations, according to changes in factors such as communication connections, node configurations, and network resource usage, other different clock synchronization algorithms can also be used, and the embodiments of the present application will not list them one by one.

本申请实施例提供的时钟同步方法允许用户参与设置与更新,用户可以在电子设备上通过相应的应用查看时钟同步方法以及参与时钟同步方法的细节设置。The clock synchronization method provided in the embodiment of the present application allows the user to participate in the setting and updating. The user can view the clock synchronization method and participate in the detailed setting of the clock synchronization method through the corresponding application on the electronic device.

示例性的,家庭网络中的各个设备之间进行时钟同步可以使用前文示例的时钟同步方法,用户如图12的(a)和(b)所示,用户可以通过点击电子设备上界面1210上的应用图标1211进入家庭网络中不同设备时钟同步情况的预览界面1220。示意性的,家庭网中包括设备1至设备9,其中,设备1可以为家庭网关(可选的,可以为全屋智能主机或家庭存储中心),设备2可以为路由器等,设备2和设备1之间可以通过例如网线实现局域网连接。家庭网中不同设备之间可以通过与路由器直接连接或者不同的设备通过都连接到路由器上实现WiFi-P2P连接,不同的设备之间还可以通过蓝牙连接。该预览界面上会向用户显示不同设备之间的连接情况以及连接的通信介质,也可以向用户显示该设备是否在线。示意性的,设备是否在线可以通过设备图标附近的控件来显示,图12中的设备7和设备9附近显示设备标号的控件颜色(如控件1221所示)与其他设备附近标识设备标号的控件(例如控件1222所示)不同,这设备7和设备9可以处于离线状态,例如设备7或设备9可以处于关机状态或者离开家庭网的区域内。Exemplarily, the clock synchronization method of the above example can be used for clock synchronization between various devices in the home network. As shown in (a) and (b) of Figure 12, the user can enter the preview interface 1220 of the clock synchronization status of different devices in the home network by clicking the application icon 1211 on the interface 1210 of the electronic device. Schematically, the home network includes devices 1 to 9, wherein device 1 can be a home gateway (optionally, it can be a whole-house smart host or a home storage center), device 2 can be a router, etc., and the local area network connection between device 2 and device 1 can be achieved through, for example, a network cable. Different devices in the home network can be connected to the router directly or different devices can be connected to the router to achieve WiFi-P2P connection, and different devices can also be connected via Bluetooth. The preview interface will show the user the connection status between different devices and the communication medium of the connection, and can also show the user whether the device is online. Schematically, whether a device is online can be displayed by a control near the device icon. The color of the control that displays the device number near device 7 and device 9 in Figure 12 (as shown in control 1221) is different from the color of the control that identifies the device number near other devices (for example, as shown in control 1222). This means that device 7 and device 9 may be offline, for example, device 7 or device 9 may be turned off or out of the home network area.

用户可以点击设备之间的连接线查看两个设备的同步情况,示例性的,设备之间的同步情况可以通过在界面1220上弹出的卡片显示,例如,用户正在使用设备4(手机1)在设备3(客厅的电视)上投屏,可以通过点击设备3和设备4之间的连接线1223查看其同步情况,则界面1220上可以弹出卡片1224,卡片上可以包括设备3和设备4的同步情况,如图12的(c)所示,例如时钟同步精度、执行节点、汇聚节点和时钟同步算法等信息。The user can click on the connection line between the devices to view the synchronization status of the two devices. Exemplarily, the synchronization status between the devices can be displayed by a card popping up on the interface 1220. For example, the user is using device 4 (mobile phone 1) to project the screen on device 3 (the TV in the living room). The user can view the synchronization status by clicking on the connection line 1223 between device 3 and device 4. A card 1224 can pop up on the interface 1220. The card may include the synchronization status of device 3 and device 4, as shown in (c) of Figure 12, such as information such as clock synchronization accuracy, execution nodes, aggregation nodes, and clock synchronization algorithm.

在本申请实施例中,可以允许用户参与对设备之间的时钟同步服务的设置。例如,当用户在使用手机1在客厅的电视上投屏时,发现投屏时产生界面卡顿等情况,可以例如通过长按控件1223,从而进入设备3和设备4的时钟同步服务的设置界面1230。界面1230上可以包括时钟同步服务的多个设置选项,示意性的,图12的(d)中包括同步周期、同步算法、控制节点、汇聚节点、执行节点、同步精度等设置选项,界面1230会像用户提示当前的同步设置,该同步设置可以是控制节点按照前文叙述的方法确定或选择的。In an embodiment of the present application, the user may be allowed to participate in the setting of the clock synchronization service between devices. For example, when the user uses mobile phone 1 to project the screen on the TV in the living room, and finds that the interface freezes during the projection, the user may, for example, long press control 1223 to enter the setting interface 1230 of the clock synchronization service of device 3 and device 4. Interface 1230 may include multiple setting options for the clock synchronization service. Schematically, (d) of Figure 12 includes setting options such as synchronization period, synchronization algorithm, control node, convergence node, execution node, synchronization accuracy, etc. Interface 1230 will prompt the user with the current synchronization setting, which may be determined or selected by the control node according to the method described above.

为了使得投屏的界面卡顿情况得到缓解,用户可以点击界面1230上的一项或多项,从而更改相应的同步设置。示例性的,用户可以点击控件1231,进入时钟同步周期的设置界面1240。如图12的(e)所示,为了便于用户选择,可以在界面上向用户显示提示控件1241,用于向用户提示该时钟同步周期的几个方面的评分,例如,该控件1241可以包括延迟评分、省电评分和网络评分(分别为1~10分),延迟评分可以与该时钟同步周期的对应的时钟同步精度有关,时钟同步周期越小,同步精度越高,该延迟评分也可以越高;省电评分可以与用户使用该时钟同步周期所消耗的电量有关,这个方面的评分对于用户使用移动终端进行时钟同步时有一定的参考意义;网络评分是指该时钟同步周期对应的网络带宽的占用情况。应理解,图12的(e)仅示意性的显示了若干个评分,还可以基于其他方面因素向用户提示其他评分,从而便于用户的选择。In order to alleviate the stuck situation of the screen projection interface, the user can click one or more items on the interface 1230 to change the corresponding synchronization settings. Exemplarily, the user can click on the control 1231 to enter the setting interface 1240 of the clock synchronization cycle. As shown in (e) of Figure 12, in order to facilitate the user's selection, a prompt control 1241 can be displayed to the user on the interface to prompt the user with several aspects of the score of the clock synchronization cycle. For example, the control 1241 can include a delay score, a power saving score and a network score (1 to 10 points respectively). The delay score can be related to the clock synchronization accuracy corresponding to the clock synchronization cycle. The smaller the clock synchronization cycle, the higher the synchronization accuracy, and the higher the delay score; the power saving score can be related to the power consumed by the user using the clock synchronization cycle. This aspect of the score has a certain reference significance for the user when using the mobile terminal for clock synchronization; the network score refers to the occupancy of the network bandwidth corresponding to the clock synchronization cycle. It should be understood that (e) of Figure 12 only schematically shows several scores, and other scores can also be prompted to the user based on other factors to facilitate the user's selection.

另外,由于设备3和设备4的其他时钟同步因素的限制,例如时钟同步算法、执行节点、汇聚节点、时钟同步精度的限制,界面1240上显示的多个时钟同步周期中可能只有数个可以满足当前其他时钟同步因素的限制。示意性的,当前使用的时钟同步周期“1s”可以用例如加粗的字体显示,允许用户选择的时钟同步周期,例如“0.5s”和“2s”可以正常显示,不允许用户选择的时钟同步周期可以用其他字体表示,例如灰色字体,如“0.1s”和“5s”所示。当用户点击灰色字体的时钟同步周期时,可以通过弹出卡片提示用户该时钟同步周期不能选择的原因,例如向用户提示“请更换时钟同步算法”等。In addition, due to the limitations of other clock synchronization factors of device 3 and device 4, such as the limitations of clock synchronization algorithm, execution node, convergence node, and clock synchronization accuracy, only a few of the multiple clock synchronization cycles displayed on interface 1240 may meet the limitations of other current clock synchronization factors. Schematically, the currently used clock synchronization cycle "1s" can be displayed in, for example, a bold font, and the clock synchronization cycles that are allowed to be selected by the user, such as "0.5s" and "2s" can be displayed normally, and the clock synchronization cycles that are not allowed to be selected by the user can be represented by other fonts, such as gray fonts, as shown in "0.1s" and "5s". When the user clicks on the clock synchronization cycle in gray font, a pop-up card can be used to prompt the user why the clock synchronization cycle cannot be selected, such as prompting the user to "Please change the clock synchronization algorithm".

同样,用户可以点击界面1230上的控件1232,从而进入时钟同步算法的设置界面1250,如图12的(f)所示,在该界面1250上,用户可以更换时钟同步算法,电子设备的显示界面上也会向用户提示几个方面的评分供用户参考选择时钟同步算法,示例性的,可以通过控件1251向用户提示用户评分、延迟评分、省电评分和网络评分,用户评分可以是用户使用该时钟同步算法给出的评分,其他三项评分可以是研发人员或电子设备根据网络情况、设备的同步情况和电量进行计算或估算的。本申请实施例提供的技术方案还可以允许用户导入外部的时钟同步算法,例如用户可以点击界面1250上的“导入”,从而导入本地或云端的时钟同步算法到用于设备3和设备4的时钟同步服务的执行节点和汇聚节点中。用户在使用完该时钟同步算法后,还可以对该时钟同步算法进行评分,以供其他用户选择时钟同步算法时进行参考。Similarly, the user can click on the control 1232 on the interface 1230 to enter the setting interface 1250 of the clock synchronization algorithm, as shown in (f) of Figure 12. On the interface 1250, the user can change the clock synchronization algorithm, and the display interface of the electronic device will also prompt the user with several ratings for the user to refer to and select the clock synchronization algorithm. For example, the user can be prompted with the user rating, delay rating, power saving rating and network rating through the control 1251. The user rating can be the rating given by the user using the clock synchronization algorithm, and the other three ratings can be calculated or estimated by the R&D personnel or the electronic device according to the network situation, the synchronization situation of the device and the power. The technical solution provided in the embodiment of the present application can also allow the user to import an external clock synchronization algorithm. For example, the user can click on "Import" on the interface 1250 to import the local or cloud clock synchronization algorithm into the execution node and the aggregation node of the clock synchronization service for device 3 and device 4. After using the clock synchronization algorithm, the user can also rate the clock synchronization algorithm for reference when other users select the clock synchronization algorithm.

当用户点击界面1230上其他时钟同步设置选项时,可以参考对时钟同步周期和时钟同步算法进行设置的界面,此处不再赘述。When the user clicks on other clock synchronization setting options on interface 1230, the interface for setting the clock synchronization period and the clock synchronization algorithm can be referred to, which will not be described in detail here.

除了允许用户单独选择时钟同步服务的每个设置选项之外,还可以在电子设备的界面上显示时钟同步策略,该时钟同步策略包括时钟同步算法、时钟同步精度、时钟同步周期、汇聚节点、执行节点等,并在界面上显示打包的时钟同步策略的评分,供用户选择时钟同步策略时参考。示例性的,用户在界面1220上长按控件1223时,可以出现如图12的(g)所示的界面1260,界面1260上可以为打包的时钟同步策略,并且界面1260上可以显示时钟同步策略的用户评分以及几个方面的评分,从而便于用户选择合适的时钟同步策略。In addition to allowing the user to select each setting option of the clock synchronization service individually, the clock synchronization strategy can also be displayed on the interface of the electronic device, which includes the clock synchronization algorithm, clock synchronization accuracy, clock synchronization cycle, convergence node, execution node, etc., and the rating of the packaged clock synchronization strategy can be displayed on the interface for the user to refer to when selecting the clock synchronization strategy. Exemplarily, when the user long presses the control 1223 on the interface 1220, the interface 1260 shown in (g) of Figure 12 may appear, and the interface 1260 may be the packaged clock synchronization strategy, and the user rating of the clock synchronization strategy and the ratings of several aspects may be displayed on the interface 1260, so as to facilitate the user to select the appropriate clock synchronization strategy.

图13示出了本申请实施例提供的一种时钟同步装置1300,该时钟同步装置1300包括收发单元1310和处理单元1320。FIG. 13 shows a clock synchronization device 1300 provided in an embodiment of the present application. The clock synchronization device 1300 includes a transceiver unit 1310 and a processing unit 1320 .

在本申请的一个实施例中,该时钟同步装置1300可以相当于图3所示的实施例中的控制节点,该时钟同步装置1300可以包括执行图3中的由控制节点执行的步骤的单元,该时钟同步装置1300中的各单元和上述其他操作和/或功能分别为了实现图3中的方法的相关流程。In one embodiment of the present application, the clock synchronization device 1300 may be equivalent to the control node in the embodiment shown in Figure 3, and the clock synchronization device 1300 may include a unit for executing the steps performed by the control node in Figure 3. The units in the clock synchronization device 1300 and the above-mentioned other operations and/or functions are respectively for implementing the relevant processes of the method in Figure 3.

具体的,该时钟同步装置1300,包括:收发单元1310,用于接收来自第一节点的订阅请求报文,所述订阅请求报文用于订阅所述第一节点与第二节点的时钟同步服务,所述第二节点是与所述第一节点进行时钟同步的节点;处理单元1320,用于根据所述订阅请求报文,确定策略下发报文,所述策略下发报文用于确定时钟同步参数,所述时钟同步参数用于所述时钟同步服务。Specifically, the clock synchronization device 1300 includes: a transceiver unit 1310, used to receive a subscription request message from a first node, the subscription request message is used to subscribe to the clock synchronization service of the first node and a second node, the second node is a node that performs clock synchronization with the first node; a processing unit 1320, used to determine a policy sending message based on the subscription request message, the policy sending message is used to determine clock synchronization parameters, and the clock synchronization parameters are used for the clock synchronization service.

在本申请实施例中,所述策略下发报文包括时钟同步算法和执行节点的标识,所述收发单元1310,还用于向执行节点发送所述策略下发报文,以便于所述执行节点获取执行所述时钟同步算法过程中的时间信息,所述时间信息包括与所述执行节点发送所述同步报文关联的时钟计数器的数值或时间戳,和/或,所述时间信息包括与所述执行节点接收所述同步报文关联的时钟计数器的数值或标记的时间戳。In an embodiment of the present application, the policy delivery message includes an identifier of a clock synchronization algorithm and an execution node. The transceiver unit 1310 is also used to send the policy delivery message to the execution node so that the execution node can obtain time information during the execution of the clock synchronization algorithm. The time information includes a value or timestamp of a clock counter associated with the execution node sending the synchronization message, and/or the time information includes a value or timestamp of a clock counter associated with the execution node receiving the synchronization message.

在本申请实施例中,所述策略下发报文还包括汇聚节点的标识,所述时钟同步参数是所述汇聚节点根据从所述执行节点获取的所述时间信息确定的;所述收发单元1310,还用于所述控制节点向所述汇聚节点发送所述策略下发报文。In an embodiment of the present application, the policy delivery message also includes an identifier of the aggregation node, and the clock synchronization parameter is determined by the aggregation node based on the time information obtained from the execution node; the transceiver unit 1310 is also used by the control node to send the policy delivery message to the aggregation node.

在本申请实施例中,所述收发单元1310,还用于接收来自所述汇聚节点的所述时钟同步参数;向所述第一节点发送参数发布报文,所述参数发布报文包括所述时钟同步参数。In the embodiment of the present application, the transceiver unit 1310 is further used to receive the clock synchronization parameter from the aggregation node; and send a parameter publishing message to the first node, wherein the parameter publishing message includes the clock synchronization parameter.

在本申请实施例中,所述订阅请求报文包括所述第一节点的标识、所述第二节点的标识和时钟同步精度。In an embodiment of the present application, the subscription request message includes the identifier of the first node, the identifier of the second node and the clock synchronization accuracy.

在本申请实施例中,所述策略下发报文还包括以下至少一项:第一时钟同步周期、所述同步报文的类型、所述同步报文传输使用的通信介质、所述同步报文的时间信息标记方式,所述第一时钟同步周期是所述执行节点执行所述时钟同步算法的周期。In an embodiment of the present application, the policy-sent message also includes at least one of the following: a first clock synchronization cycle, the type of the synchronization message, the communication medium used for transmission of the synchronization message, and a time information marking method of the synchronization message. The first clock synchronization cycle is the period in which the execution node executes the clock synchronization algorithm.

在本申请实施例中,所述处理单元1320,还用于根据所述第一节点的时钟值的置信区间的长度和所述时钟同步精度确定第二时钟同步周期,或者,根据所述第二节点的时钟值的置信区间的长度和所述时钟同步精度确定所述第二时钟同步周期,所述第一节点的时钟值的置信区间或所述第二节点的时钟值的置信区间是所述汇聚节点根据所述时钟同步参数确定的;当所述置信区间的长度与所述时钟同步精度的差值的绝对值小于第一预设阈值时,所述第一时钟同步周期是所述第二时钟同步周期;当所述置信区间的长度与所述时钟同步精度的差值的绝对值大于第一预设阈值且所述置信区间的长度大于所述时钟同步精度时,所述第二时钟同步周期小于所述第一时钟同步周期;当述置信区间的长度与所述时钟同步精度的差值的绝对值大于第一预设阈值且所述置信区间的长度小于所述时钟同步精度时,所述第二同步周期大于所述第一时钟同步周期。In an embodiment of the present application, the processing unit 1320 is also used to determine the second clock synchronization period according to the length of the confidence interval of the clock value of the first node and the clock synchronization accuracy, or to determine the second clock synchronization period according to the length of the confidence interval of the clock value of the second node and the clock synchronization accuracy, the confidence interval of the clock value of the first node or the confidence interval of the clock value of the second node is determined by the aggregation node according to the clock synchronization parameters; when the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is less than a first preset threshold, the first clock synchronization period is the second clock synchronization period; when the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is greater than a first preset threshold and the length of the confidence interval is greater than the clock synchronization accuracy, the second clock synchronization period is less than the first clock synchronization period; when the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is greater than the first preset threshold and the length of the confidence interval is less than the clock synchronization accuracy, the second synchronization period is greater than the first clock synchronization period.

在本申请的另一个实施例中,该时钟同步装置1300可以相当于图3所示的实施例中的第一节点,该时钟同步装置1300可以包括执行图3、图9至图11中的由第一节点执行的步骤的单元,该时钟同步装置1300中的各单元和上述其他操作和/或功能分别为了实现图3、图9至图11中的方法的相关流程。In another embodiment of the present application, the clock synchronization device 1300 may be equivalent to the first node in the embodiment shown in Figure 3, and the clock synchronization device 1300 may include a unit for executing the steps performed by the first node in Figures 3, 9 to 11, and each unit in the clock synchronization device 1300 and the above-mentioned other operations and/or functions are respectively for implementing the relevant processes of the methods in Figures 3, 9 to 11.

具体的,该时钟同步装置1300,包括:收发单元1310,用于向控制节点发送订阅请求报文,所述订阅请求报文用于订阅所述第一节点与第二节点的时钟同步服务,所述第二节点是与所述第一节点进行时钟同步的节点;所述收发单元1310,还用于接收来自所述控制节点的策略下发报文,所述策略下发报文是所述控制节点根据所述订阅请求报文确定的,所述策略下发报文包括时钟同步算法和执行节点的标识,所述执行节点包括第一节点和所述第二节点;处理单元1320,用于根据所述策略下发报文,执行所述时钟同步算法;所述收发单元1310,还用于获取时钟同步参数,所述时钟同步参数用于所述时钟同步服务,所述时钟同步参数是根据所述时钟同步算法确定的。Specifically, the clock synchronization device 1300 includes: a transceiver unit 1310, used to send a subscription request message to a control node, wherein the subscription request message is used to subscribe to the clock synchronization service of the first node and the second node, and the second node is a node that performs clock synchronization with the first node; the transceiver unit 1310 is also used to receive a policy message from the control node, wherein the policy message is determined by the control node according to the subscription request message, and the policy message includes a clock synchronization algorithm and an identifier of an execution node, and the execution node includes a first node and the second node; a processing unit 1320, used to execute the clock synchronization algorithm according to the policy message; the transceiver unit 1310 is also used to obtain clock synchronization parameters, wherein the clock synchronization parameters are used for the clock synchronization service, and the clock synchronization parameters are determined according to the clock synchronization algorithm.

在本申请实施例中,所述策略下发报文还包括汇聚节点的标识,所述汇聚节点不是所述第一节点,所述收发单元1310,还用于:向所述汇聚节点发送时间信息上传报文,所述时间信息上传报文包括时间信息,所述时间信息用于所述汇聚节点确定所述时钟同步参数,所述时间信息包括与所述执行节点执行所述时钟同步算法发送同步报文关联的时钟计数器的数值或时间戳,和/或,所述时间信息包括与所述执行节点执行所述时钟同步算法接收所述同步报文关联的时钟计数器的数值或时间戳;从所述汇聚节点接收参数发布报文,所述参数发布报文包括所述时钟同步参数。In an embodiment of the present application, the policy sending message also includes an identifier of a convergence node, and the convergence node is not the first node. The transceiver unit 1310 is also used to: send a time information upload message to the convergence node, and the time information upload message includes time information, and the time information is used by the convergence node to determine the clock synchronization parameters, and the time information includes the value or timestamp of the clock counter associated with the execution node executing the clock synchronization algorithm to send the synchronization message, and/or, the time information includes the value or timestamp of the clock counter associated with the execution node executing the clock synchronization algorithm to receive the synchronization message; receive a parameter release message from the convergence node, and the parameter release message includes the clock synchronization parameters.

在本申请实施例中,所述订阅请求报文包括所述第一节点的标识、所述第二节点的标识和时钟同步精度。In an embodiment of the present application, the subscription request message includes the identifier of the first node, the identifier of the second node and the clock synchronization accuracy.

在本申请实施例中,所述策略下发报文还包括以下至少一项:第一时钟同步周期、所述同步报文的类型、所述同步报文传输使用的通信介质、所述同步报文的时间信息标记方式,所述第一时钟同步周期是所述执行节点执行所述时钟同步算法的周期。In an embodiment of the present application, the policy-sent message also includes at least one of the following: a first clock synchronization cycle, the type of the synchronization message, the communication medium used for transmission of the synchronization message, and a time information marking method of the synchronization message. The first clock synchronization cycle is the period in which the execution node executes the clock synchronization algorithm.

在本申请实施例中,所述收发单元1310,还用于:从所述控制节点接收第二时钟同步周期;所述处理单元1320,还用于根据所述第二时钟同步周期,执行所述时钟同步算法;其中所述第二时钟同步周期是所述控制节点根据所述第一节点的时钟值的置信区间的长度和所述时钟同步精度确定的,或者,所述第二时钟同步周期是所述控制节点根据所述第二节点的时钟值的置信区间的长度和所述时钟同步精度确定的;所述第一节点的时钟值的置信区间和所述第二节点的时钟值的置信区间是所述汇聚节点根据所述时钟同步参数确定的;当所述置信区间的长度与所述时钟同步精度的差值的绝对值小于第一预设阈值时,所述第一时钟同步周期是所述第二时钟同步周期;当所述置信区间的长度与所述时钟同步精度的差值的绝对值大于第一预设阈值且所述置信区间的长度大于所述时钟同步精度时,所述第二时钟同步周期小于所述第一时钟同步周期;当所述置信区间的长度与所述时钟同步精度的差值的绝对值大于第一预设阈值且所述置信区间小于所述时钟同步精度时,所述第二同步周期大于所述第一时钟同步周期。In an embodiment of the present application, the transceiver unit 1310 is also used to: receive a second clock synchronization period from the control node; the processing unit 1320 is also used to execute the clock synchronization algorithm according to the second clock synchronization period; wherein the second clock synchronization period is determined by the control node based on the length of the confidence interval of the clock value of the first node and the clock synchronization accuracy, or the second clock synchronization period is determined by the control node based on the length of the confidence interval of the clock value of the second node and the clock synchronization accuracy; the confidence interval of the clock value of the first node and the confidence interval of the clock value of the second node are the roots of the aggregation node Determined according to the clock synchronization parameters; when the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is less than a first preset threshold, the first clock synchronization period is the second clock synchronization period; when the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is greater than the first preset threshold and the length of the confidence interval is greater than the clock synchronization accuracy, the second clock synchronization period is less than the first clock synchronization period; when the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is greater than the first preset threshold and the confidence interval is less than the clock synchronization accuracy, the second synchronization period is greater than the first clock synchronization period.

在本申请实施例中,所述第一节点和第二节点位于不同的局域网中,所述时间信息包括第一同步报文的TSF接收时间和所述第一同步报文的TSF发送时间、第二同步报文的TSF接收时间和所述第二同步报文的TSF发送时间;所述时钟同步参数包括以下至少一项:所述第一节点的TSF时钟值和所述第三节点的TSF时钟值的差值以及所述第一节点的TSF时钟频率和所述第三节点的TSF时钟频率的差值;所述第一节点执行所述时钟同步算法包括:所述第一节点接收来自所述第二节点的所述第一同步报文;所述第一节点向所述第二节点发送所述第二同步报文;所述第一节点根据所述时钟同步参数,调节所述第一节点的TSF时钟;所述第一节点根据调整后的TSF时钟,调节所述第一节点的系统时钟。In an embodiment of the present application, the first node and the second node are located in different local area networks, and the time information includes the TSF reception time of the first synchronization message and the TSF sending time of the first synchronization message, the TSF reception time of the second synchronization message, and the TSF sending time of the second synchronization message; the clock synchronization parameters include at least one of the following: the difference between the TSF clock value of the first node and the TSF clock value of the third node and the difference between the TSF clock frequency of the first node and the TSF clock frequency of the third node; the first node executes the clock synchronization algorithm including: the first node receives the first synchronization message from the second node; the first node sends the second synchronization message to the second node; the first node adjusts the TSF clock of the first node according to the clock synchronization parameters; the first node adjusts the system clock of the first node according to the adjusted TSF clock.

在本申请实施例中,所述执行节点还包括第三节点,所述时间信息包括:所述第一节点接收所述多个参考报文的时间和所述第二节点接收所述多个参考报文的时间;所述时钟同步参数包括以下至少一项:所述第一节点的时钟值和所述第二节点的时钟值的差值以及所述第一节点的时钟频率和所述第二节点的时钟频率的差值;或者,所述时钟同步参数包括以下至少一项:所述第一节点的时钟值和第一参考时钟值的差值、所述第二节点的时钟值和所述第一参考时钟值的差值、所述第一节点的时钟频率和第一参考时钟频率的差值、所述第二节点的时钟频率和所述第一参考时钟频率的差值;其中,所述处理单元1320包括第二收发子单元,用于接收来自所述第三节点的所述多个参考报文。In an embodiment of the present application, the execution node also includes a third node, and the time information includes: the time when the first node receives the multiple reference messages and the time when the second node receives the multiple reference messages; the clock synchronization parameters include at least one of the following: the difference between the clock value of the first node and the clock value of the second node and the difference between the clock frequency of the first node and the clock frequency of the second node; or, the clock synchronization parameters include at least one of the following: the difference between the clock value of the first node and the first reference clock value, the difference between the clock value of the second node and the first reference clock value, the difference between the clock frequency of the first node and the first reference clock frequency, and the difference between the clock frequency of the second node and the first reference clock frequency; wherein the processing unit 1320 includes a second transceiver subunit for receiving the multiple reference messages from the third node.

在本申请实施例中,时间信息还包括发送该多个参考报文的时间。In an embodiment of the present application, the time information also includes the time of sending the multiple reference messages.

图14示出了本申请实施例提供的一种时钟同步装置。图14所示的时钟同步装置1400可对应于前文描述的时钟同步装置或者图1中的系统中的节点(设备),具体地,时钟同步装置1400可以是图13中的时钟同步装置具体的例子。时钟同步装置1400包括:处理器1420。在本申请的实施例中,处理器1420用于实现相应的控制管理操作,例如,处理器1420用于支持时钟同步装置执行前述实施例的方法或操作或功能。可选的,时钟同步装置1400还可以包括:存储器1410和通信接口1430;处理器1420、通信接口1430以及存储器1410可以相互连接或者通过总线1440相互连接。其中,通信接口1430用于支持该时钟同步装置与服务商的后台系统等进行通信,存储器1410用于存储时钟同步装置的程序代码和数据。处理器1420调用存储器1410中存储的代码或者数据实现相应的操作。该存储器1410可以跟处理器耦合在一起,也可以不耦合在一起。本申请实施例中的耦合是时钟同步装置、单元或模块之间的间接耦合或通信连接,可以是电性,机械或其它的形式,用于时钟同步装置、单元或模块之间的信息交互。FIG14 shows a clock synchronization device provided by an embodiment of the present application. The clock synchronization device 1400 shown in FIG14 may correspond to the clock synchronization device described above or the node (device) in the system in FIG1 . Specifically, the clock synchronization device 1400 may be a specific example of the clock synchronization device in FIG13 . The clock synchronization device 1400 includes: a processor 1420. In an embodiment of the present application, the processor 1420 is used to implement corresponding control management operations. For example, the processor 1420 is used to support the clock synchronization device to perform the method, operation or function of the aforementioned embodiment. Optionally, the clock synchronization device 1400 may also include: a memory 1410 and a communication interface 1430; the processor 1420, the communication interface 1430 and the memory 1410 may be interconnected or interconnected through a bus 1440. Among them, the communication interface 1430 is used to support the clock synchronization device to communicate with the backend system of the service provider, etc., and the memory 1410 is used to store the program code and data of the clock synchronization device. The processor 1420 calls the code or data stored in the memory 1410 to implement the corresponding operation. The memory 1410 may be coupled to the processor or not. The coupling in the embodiment of the present application is an indirect coupling or communication connection between clock synchronization devices, units or modules, which may be electrical, mechanical or other forms, and is used for information exchange between clock synchronization devices, units or modules.

其中,处理器1420可以是中央处理器单元,通用处理器,数字信号处理器,专用集成电路,现场可编程门阵列或者其他可编程逻辑器件、晶体管逻辑器件、硬件部件或者其任意组合。其可以实现或执行结合本申请公开内容所描述的各种示例性的逻辑方框,模块和电路。所述处理器也可以是实现计算功能的组合,例如包含一个或多个微处理器组合,数字信号处理器和微处理器的组合等等。通信接口1430可以是收发器、电路、总线、模块或其它类型的通信接口。总线1440可以是外设部件互连标准(peripheral componentinterconnect,PCI)总线或扩展工业标准结构(extended industry standardarchitecture,EISA)总线等。所述总线可以分为地址总线、数据总线、控制总线等。为便于表示,图14中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。Among them, the processor 1420 can be a central processing unit, a general processor, a digital signal processor, an application-specific integrated circuit, a field programmable gate array or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. It can implement or execute various exemplary logic blocks, modules and circuits described in conjunction with the disclosure of this application. The processor can also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a digital signal processor and a microprocessor, etc. The communication interface 1430 can be a transceiver, a circuit, a bus, a module or other types of communication interfaces. The bus 1440 can be a peripheral component interconnect standard (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in Figure 14, but it does not mean that there is only one bus or one type of bus.

本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统、装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

在本申请所提供的几个实施例中,应该理解到,所揭露的系统、装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

所述功能如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(read-only memory,ROM)、随机存取存储器(random access memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims (39)

1.一种时钟同步方法,其特征在于,包括:1. A clock synchronization method, comprising: 第一节点向控制节点发送订阅请求报文,所述订阅请求报文用于订阅所述第一节点与第二节点的时钟同步服务,所述第二节点是与所述第一节点进行时钟同步的节点;The first node sends a subscription request message to the control node, where the subscription request message is used to subscribe to a clock synchronization service between the first node and a second node, where the second node is a node that performs clock synchronization with the first node; 所述控制节点根据所述订阅请求报文,确定策略下发报文,所述策略下发报文包括时钟同步算法;The control node determines a policy delivery message according to the subscription request message, wherein the policy delivery message includes a clock synchronization algorithm; 所述第一节点获取时钟同步参数,所述时钟同步参数用于所述时钟同步服务,所述时钟同步参数是根据所述时钟同步算法确定的。The first node acquires a clock synchronization parameter, where the clock synchronization parameter is used for the clock synchronization service and is determined according to the clock synchronization algorithm. 2.根据权利要求1所述的方法,其特征在于,所述策略下发报文包括执行节点的标识,所述方法还包括:2. The method according to claim 1, wherein the policy delivery message includes an identifier of an execution node, and the method further comprises: 所述控制节点向所述执行节点发送所述策略下发报文;The control node sends the policy delivery message to the execution node; 所述执行节点根据所述策略下发报文,执行所述时钟同步算法,所述时钟同步参数是根据所述执行节点执行所述时钟同步算法发送和/或接收的同步报文的时间信息确定的,所述时间信息包括与所述执行节点发送所述同步报文关联的时钟计数器的数值或者时间戳,和/或,所述时间信息包括与所述执行节点接收所述同步报文关联的时钟计数器的数值或者时间戳。The execution node sends a message according to the strategy and executes the clock synchronization algorithm. The clock synchronization parameters are determined based on the time information of the synchronization message sent and/or received by the execution node when executing the clock synchronization algorithm. The time information includes the value or timestamp of the clock counter associated with the execution node sending the synchronization message, and/or the time information includes the value or timestamp of the clock counter associated with the execution node receiving the synchronization message. 3.根据权利要求2所述的方法,其特征在于,所述策略下发报文还包括汇聚节点的标识,所述汇聚节点不是所述第一节点,在所述第一节点获取时钟同步参数之前,所述方法还包括:3. The method according to claim 2, wherein the policy delivery message further includes an identifier of a sink node, the sink node is not the first node, and before the first node obtains the clock synchronization parameter, the method further includes: 所述控制节点向所述汇聚节点发送所述策略下发报文;The control node sends the policy delivery message to the aggregation node; 所述执行节点向所述汇聚节点发送时间信息上传报文,所述时间信息上传报文包括所述时间信息;The execution node sends a time information upload message to the aggregation node, where the time information upload message includes the time information; 所述汇聚节点根据所述时钟同步算法和所述时间信息确定所述时钟同步参数;The sink node determines the clock synchronization parameter according to the clock synchronization algorithm and the time information; 所述汇聚节点向所述第一节点发送参数发布报文,所述参数发布报文包括所述时钟同步参数。The aggregation node sends a parameter publishing message to the first node, where the parameter publishing message includes the clock synchronization parameter. 4.根据权利要求2所述的方法,其特征在于,4. The method according to claim 2, characterized in that 所述策略下发报文还包括汇聚节点的标识,所述汇聚节点不是所述第一节点,在所述第一节点获取时钟同步参数之前,所述方法还包括:The policy delivery message further includes an identifier of a sink node, and the sink node is not the first node. Before the first node acquires the clock synchronization parameter, the method further includes: 所述控制节点向所述汇聚节点发送所述策略下发报文;The control node sends the policy delivery message to the aggregation node; 所述执行节点向所述汇聚节点发送时间信息上传报文,所述时间信息上传报文包括所述时间信息;The execution node sends a time information upload message to the aggregation node, where the time information upload message includes the time information; 所述汇聚节点根据所述时钟同步算法和所述时间信息确定所述时钟同步参数;The sink node determines the clock synchronization parameter according to the clock synchronization algorithm and the time information; 所述汇聚节点向所述控制节点发送所述时钟同步参数;The aggregation node sends the clock synchronization parameter to the control node; 所述控制节点向所述第一节点发送参数发布报文,所述参数发布报文包括所述时钟同步参数。The control node sends a parameter publishing message to the first node, where the parameter publishing message includes the clock synchronization parameter. 5.根据权利要求2所述的方法,其特征在于,所述策略下发报文还包括汇聚节点的标识,所述汇聚节点是所述第一节点,在所述第一节点获取时钟同步参数之前,所述方法还包括:5. The method according to claim 2, wherein the policy delivery message further includes an identifier of a sink node, the sink node is the first node, and before the first node obtains the clock synchronization parameter, the method further includes: 所述执行节点向所述汇聚节点发送时间信息上传报文,所述时间信息上传报文包括所述时间信息;The execution node sends a time information upload message to the aggregation node, where the time information upload message includes the time information; 所述第一节点获取时钟同步参数,包括:The first node acquires the clock synchronization parameter, including: 所述第一节点根据所述时间信息,确定所述时钟同步参数。The first node determines the clock synchronization parameter according to the time information. 6.根据权利要求3至5中任一项所述的方法,其特征在于,所述订阅请求报文包括所述第一节点的标识、所述第二节点的标识和时钟同步精度。6. The method according to any one of claims 3 to 5, characterized in that the subscription request message includes the identifier of the first node, the identifier of the second node and the clock synchronization accuracy. 7.根据权利要求6所述的方法,其特征在于,所述策略下发报文还包括以下至少一项:7. The method according to claim 6, wherein the policy delivery message further comprises at least one of the following: 第一时钟同步周期、所述同步报文的类型、所述同步报文传输使用的通信介质、所述同步报文的时间信息标记方式,所述第一时钟同步周期是所述执行节点执行所述时钟同步算法的周期。The first clock synchronization cycle, the type of the synchronization message, the communication medium used for the transmission of the synchronization message, and the time information marking method of the synchronization message. The first clock synchronization cycle is the cycle in which the execution node executes the clock synchronization algorithm. 8.根据权利要求7所述的方法,其特征在于,所述方法还包括:8. The method according to claim 7, characterized in that the method further comprises: 所述控制节点根据所述第一节点的时钟值的置信区间的长度或所述第二节点的时钟值的置信区间的长度和所述时钟同步精度,确定第二时钟同步周期;其中,所述第一节点的时钟值的置信区间或者所述第二节点的时钟值的置信区间是所述汇聚节点根据所述时钟同步参数确定的;The control node determines the second clock synchronization period according to the length of the confidence interval of the clock value of the first node or the length of the confidence interval of the clock value of the second node and the clock synchronization accuracy; wherein the confidence interval of the clock value of the first node or the confidence interval of the clock value of the second node is determined by the convergence node according to the clock synchronization parameter; 所述控制节点向所述执行节点发送所述第二时钟同步周期;The control node sends the second clock synchronization cycle to the execution node; 所述执行节点根据所述第二时钟同步周期,执行所述时钟同步算法;The execution node executes the clock synchronization algorithm according to the second clock synchronization cycle; 其中,当所述置信区间的长度与所述时钟同步精度的差值的绝对值小于第一预设阈值时,所述第一时钟同步周期是所述第二时钟同步周期;当所述置信区间的长度与所述时钟同步精度的差值的绝对值大于第一预设阈值且所述置信区间的长度大于所述时钟同步精度时,所述第二时钟同步周期小于所述第一时钟同步周期,当所述置信区间的长度与所述时钟同步精度的差值的绝对值大于第一预设阈值且所述置信区间的长度小于所述时钟同步精度时,所述第二同步周期大于所述第一时钟同步周期。Among them, when the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is less than a first preset threshold, the first clock synchronization period is the second clock synchronization period; when the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is greater than the first preset threshold and the length of the confidence interval is greater than the clock synchronization accuracy, the second clock synchronization period is less than the first clock synchronization period; when the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is greater than the first preset threshold and the length of the confidence interval is less than the clock synchronization accuracy, the second synchronization period is greater than the first clock synchronization period. 9.根据权利要求3至8中任一项所述的方法,其特征在于,9. The method according to any one of claims 3 to 8, characterized in that 所述执行节点包括所述第一节点和所述第二节点,所述第一节点和所述第二节点位于不同的局域网中,所述时间信息包括第一同步报文的TSF接收时间和所述第一同步报文的TSF发送时间、第二同步报文的TSF接收时间和所述第二同步报文的TSF发送时间;The execution node includes the first node and the second node, the first node and the second node are located in different local area networks, and the time information includes a TSF reception time of a first synchronization message, a TSF transmission time of the first synchronization message, a TSF reception time of a second synchronization message, and a TSF transmission time of the second synchronization message; 所述时钟同步参数包括以下至少一项:所述第一节点的TSF时钟值和所述第二节点的TSF时钟值的差值以及所述第一节点的TSF时钟频率和所述第二节点的TSF时钟频率的差值;The clock synchronization parameter includes at least one of the following: a difference between a TSF clock value of the first node and a TSF clock value of the second node and a difference between a TSF clock frequency of the first node and a TSF clock frequency of the second node; 其中,所述执行节点执行所述时钟同步算法,包括:The execution node executes the clock synchronization algorithm, including: 所述第一节点将所述第一节点的TSF时钟与所述第一节点的系统时钟对齐;The first node aligns a TSF clock of the first node with a system clock of the first node; 所述第一节点向所述第二节点发送所述第一同步报文;The first node sends the first synchronization message to the second node; 所述第二节点向所述第一节点发送所述第二同步报文;The second node sends the second synchronization message to the first node; 所述第二节点根据所述时钟同步参数,调节所述第二节点的TSF时钟;The second node adjusts the TSF clock of the second node according to the clock synchronization parameter; 所述第二节点根据调整后的TSF时钟,调节所述第二节点的系统时钟。The second node adjusts the system clock of the second node according to the adjusted TSF clock. 10.根据权利要求3至8中任一项所述的方法,其特征在于,10. The method according to any one of claims 3 to 8, characterized in that 所述执行节点包括所述第一节点、所述第二节点和第三节点,所述时间信息包括:所述第一节点接收多个参考报文的时间和所述第二节点接收所述多个参考报文的时间;The execution nodes include the first node, the second node and the third node, and the time information includes: the time when the first node receives the multiple reference messages and the time when the second node receives the multiple reference messages; 所述时钟同步参数包括以下至少一项:所述第一节点的时钟值和所述第二节点的时钟值的差值以及所述第一节点的时钟频率和所述第二节点的时钟频率的差值;或者,The clock synchronization parameter includes at least one of the following: a difference between a clock value of the first node and a clock value of the second node and a difference between a clock frequency of the first node and a clock frequency of the second node; or, 所述时钟同步参数包括以下至少一项:所述第一节点的时钟值和第一参考时钟值的差值、所述第二节点的时钟值和所述第一参考时钟值的差值、所述第一节点的时钟频率和第一参考时钟频率的差值以及所述第二节点的时钟频率和所述第一参考时钟频率的差值;The clock synchronization parameter includes at least one of the following: a difference between a clock value of the first node and a first reference clock value, a difference between a clock value of the second node and the first reference clock value, a difference between a clock frequency of the first node and a first reference clock frequency, and a difference between a clock frequency of the second node and the first reference clock frequency; 其中,所述执行节点执行所述时钟同步算法包括:The execution node executing the clock synchronization algorithm includes: 所述第三节点向所述第一节点和所述第二节点发送所述多个参考报文。The third node sends the multiple reference messages to the first node and the second node. 11.根据权利要求2至6中任一项所述的方法,其特征在于,所述执行节点不包括所述第一节点,所述时钟同步参数包括第二参考时钟值和/或第二参考时钟频率,所述方法还包括:11. The method according to any one of claims 2 to 6, wherein the execution node does not include the first node, the clock synchronization parameter includes a second reference clock value and/or a second reference clock frequency, and the method further comprises: 所述第一节点根据所述时钟同步参数,将所述第一节点的时钟更新为所述第二参考时钟值和/或所述第二参考时钟频率。The first node updates the clock of the first node to the second reference clock value and/or the second reference clock frequency according to the clock synchronization parameter. 12.一种时钟同步方法,其特征在于,包括:12. A clock synchronization method, comprising: 第一节点向控制节点发送订阅请求报文,所述订阅请求报文用于订阅所述第一节点与第二节点的时钟同步服务,所述第二节点是与所述第一节点进行时钟同步的节点;The first node sends a subscription request message to the control node, where the subscription request message is used to subscribe to a clock synchronization service between the first node and a second node, where the second node is a node that performs clock synchronization with the first node; 所述第一节点接收来自所述控制节点的策略下发报文,所述策略下发报文是所述控制节点根据所述订阅请求报文确定的,所述策略下发报文包括时钟同步算法和执行节点的标识,所述执行节点包括所述第一节点和所述第二节点;The first node receives a policy delivery message from the control node, where the policy delivery message is determined by the control node according to the subscription request message, and the policy delivery message includes a clock synchronization algorithm and an identifier of an execution node, where the execution node includes the first node and the second node; 所述第一节点根据所述策略下发报文,执行所述时钟同步算法;The first node sends a message according to the strategy and executes the clock synchronization algorithm; 所述第一节点获取时钟同步参数,所述时钟同步参数用于所述时钟同步服务,所述时钟同步参数是根据所述时钟同步算法确定的。The first node acquires a clock synchronization parameter, where the clock synchronization parameter is used for the clock synchronization service and is determined according to the clock synchronization algorithm. 13.根据权利要求12所述的方法,其特征在于,所述策略下发报文还包括汇聚节点的标识,所述汇聚节点不是所述第一节点,所述方法还包括:13. The method according to claim 12, wherein the policy delivery message further includes an identifier of a sink node, and the sink node is not the first node, and the method further includes: 所述第一节点向所述汇聚节点发送时间信息上传报文,所述时间信息上传报文包括时间信息,所述时间信息用于所述汇聚节点确定所述时钟同步参数,所述时间信息包括与所述执行节点执行所述时钟同步算法发送同步报文关联的时钟计数器的数值或时间戳,和/或,所述时间信息包括与所述执行节点执行所述时钟同步算法接收所述同步报文关联的时钟计数器的数值或时间戳;The first node sends a time information upload message to the aggregation node, the time information upload message includes time information, the time information is used by the aggregation node to determine the clock synchronization parameter, the time information includes the value or timestamp of the clock counter associated with the execution node executing the clock synchronization algorithm to send the synchronization message, and/or, the time information includes the value or timestamp of the clock counter associated with the execution node executing the clock synchronization algorithm to receive the synchronization message; 所述第一节点从所述汇聚节点或所述控制节点接收参数发布报文,所述参数发布报文包括所述时钟同步参数。The first node receives a parameter publishing message from the aggregation node or the control node, where the parameter publishing message includes the clock synchronization parameter. 14.根据权利要求13所述的方法,其特征在于,所述订阅请求报文包括所述第一节点的标识、所述第二节点的标识和时钟同步精度。14. The method according to claim 13, characterized in that the subscription request message includes the identifier of the first node, the identifier of the second node and the clock synchronization accuracy. 15.根据权利要求13或14所述的方法,其特征在于,所述策略下发报文还包括以下至少一项:15. The method according to claim 13 or 14, characterized in that the policy delivery message further comprises at least one of the following: 第一时钟同步周期、所述同步报文的类型、所述同步报文传输使用的通信介质、所述同步报文的时间信息标记方式,所述第一时钟同步周期是所述执行节点执行所述时钟同步算法的周期。The first clock synchronization cycle, the type of the synchronization message, the communication medium used for the transmission of the synchronization message, and the time information marking method of the synchronization message. The first clock synchronization cycle is the cycle in which the execution node executes the clock synchronization algorithm. 16.根据权利要求14所述的方法,其特征在于,所述方法还包括:16. The method according to claim 14, characterized in that the method further comprises: 所述第一节点从所述控制节点接收第二时钟同步周期;The first node receives a second clock synchronization cycle from the control node; 所述第一节点根据所述第二时钟同步周期,执行所述时钟同步算法;The first node executes the clock synchronization algorithm according to the second clock synchronization period; 其中所述第二时钟同步周期是所述控制节点根据所述第一节点的时钟值的置信区间的长度和所述同步精度确定的,或者所述第二时钟同步周期是所述控制节点根据所述第二节点的时钟值的置信区间的长度和所述同步精度确定的;所述第一节点的时钟值的置信区间或所述第二节点的时钟值的置信区间是所述汇聚节点根据所述时钟同步参数确定的;当所述置信区间的长度与所述时钟同步精度的差值的绝对值小于第一预设阈值时,所述第一时钟同步周期是所述第二时钟同步周期;当所述置信区间的长度与所述时钟同步精度的差值的绝对值大于第一预设阈值且所述置信区间的长度大于所述时钟同步精度时,所述第二时钟同步周期小于所述第一时钟同步周期,当所述置信区间的长度与所述时钟同步精度的差值的绝对值大于第一预设阈值且所述置信区间的长度小于所述时钟同步精度时,所述第二同步周期大于所述第一时钟同步周期。The second clock synchronization period is determined by the control node according to the length of the confidence interval of the clock value of the first node and the synchronization accuracy, or the second clock synchronization period is determined by the control node according to the length of the confidence interval of the clock value of the second node and the synchronization accuracy; the confidence interval of the clock value of the first node or the confidence interval of the clock value of the second node is determined by the convergence node according to the clock synchronization parameter; when the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is less than a first preset threshold, the first clock synchronization period is the second clock synchronization period; when the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is greater than a first preset threshold and the length of the confidence interval is greater than the clock synchronization accuracy, the second clock synchronization period is less than the first clock synchronization period, and when the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is greater than a first preset threshold and the length of the confidence interval is less than the clock synchronization accuracy, the second synchronization period is greater than the first clock synchronization period. 17.根据权利要求13至16中任一项所述的方法,其特征在于,17. The method according to any one of claims 13 to 16, characterized in that 所述第一节点和第二节点位于不同的局域网中,所述时间信息包括第一同步报文的TSF接收时间和所述第一同步报文的TSF发送时间、第二同步报文的TSF接收时间和所述第二同步报文的TSF发送时间;The first node and the second node are located in different local area networks, and the time information includes a TSF reception time of the first synchronization message and a TSF transmission time of the first synchronization message, a TSF reception time of the second synchronization message and a TSF transmission time of the second synchronization message; 所述时钟同步参数包括以下至少一项:所述第一节点的TSF时钟值和所述第二节点的TSF时钟值的差值以及所述第一节点的TSF时钟频率和所述第二节点的TSF时钟频率的差值;The clock synchronization parameter includes at least one of the following: a difference between a TSF clock value of the first node and a TSF clock value of the second node and a difference between a TSF clock frequency of the first node and a TSF clock frequency of the second node; 所述第一节点执行所述时钟同步算法包括:The first node executing the clock synchronization algorithm includes: 所述第一节点接收来自所述第二节点的所述第一同步报文;The first node receives the first synchronization message from the second node; 所述第一节点向所述第二节点发送所述第二同步报文;The first node sends the second synchronization message to the second node; 所述第一节点根据所述时钟同步参数,调节所述第一节点的TSF时钟;The first node adjusts the TSF clock of the first node according to the clock synchronization parameter; 所述第一节点根据调整后的TSF时钟,调节所述第一节点的系统时钟。The first node adjusts the system clock of the first node according to the adjusted TSF clock. 18.根据权利要求13至16中任一项所述的方法,其特征在于,18. The method according to any one of claims 13 to 16, characterized in that 所述执行节点还包括第三节点,所述时间信息包括:所述第一节点接收所述多个参考报文的时间戳和所述第二节点接收所述多个参考报文的时间;The execution node further includes a third node, and the time information includes: a timestamp of when the first node receives the plurality of reference messages and a time when the second node receives the plurality of reference messages; 所述时钟同步参数包括以下至少一项:所述第一节点的时钟值和所述第二节点的时钟值的差值以及所述第一节点的时钟频率和所述第二节点的时钟频率的差值;或者,The clock synchronization parameter includes at least one of the following: a difference between a clock value of the first node and a clock value of the second node and a difference between a clock frequency of the first node and a clock frequency of the second node; or, 所述时钟同步参数包括以下至少一项:所述第一节点的时钟值和第一参考时钟值的差值、所述第二节点的时钟值和所述第一参考时钟值的差值、所述第一节点的时钟频率和第一参考时钟频率的差值、所述第二节点的时钟频率和所述第一参考时钟频率的差值;The clock synchronization parameter includes at least one of the following: a difference between a clock value of the first node and a first reference clock value, a difference between a clock value of the second node and the first reference clock value, a difference between a clock frequency of the first node and a first reference clock frequency, and a difference between a clock frequency of the second node and the first reference clock frequency; 其中,所述第一节点执行所述时钟同步算法包括:The first node executing the clock synchronization algorithm includes: 所述第一节点接收来自所述第三节点的所述多个参考报文。The first node receives the multiple reference messages from the third node. 19.一种时钟同步方法,其特征在于,包括:19. A clock synchronization method, comprising: 控制节点接收来自第一节点的订阅请求报文,所述订阅请求报文用于订阅所述第一节点与第二节点的时钟同步服务,所述第二节点是与所述第一节点进行时钟同步的节点;The control node receives a subscription request message from a first node, where the subscription request message is used to subscribe to a clock synchronization service between the first node and a second node, where the second node is a node that performs clock synchronization with the first node; 所述控制节点根据所述订阅请求报文,确定策略下发报文,所述策略下发报文用于确定时钟同步参数,所述时钟同步参数用于所述时钟同步服务。The control node determines a policy delivery message according to the subscription request message, wherein the policy delivery message is used to determine clock synchronization parameters, and the clock synchronization parameters are used for the clock synchronization service. 20.根据权利要求19所述的方法,其特征在于,所述策略下发报文包括时钟同步算法和执行节点的标识,所述方法还包括:20. The method according to claim 19, wherein the policy delivery message includes a clock synchronization algorithm and an identifier of an execution node, and the method further comprises: 所述控制节点向执行节点发送所述策略下发报文,以便于所述执行节点获取执行所述时钟同步算法过程中的时间信息,所述时间信息包括与所述执行节点发送所述同步报文关联的时钟计数器的数值或时间戳,和/或,所述时间信息包括与所述执行节点接收所述同步报文关联的时钟计数器的数值或时间戳。The control node sends the policy delivery message to the execution node so that the execution node obtains the time information during the execution of the clock synchronization algorithm. The time information includes the value or timestamp of the clock counter associated with the execution node sending the synchronization message, and/or the time information includes the value or timestamp of the clock counter associated with the execution node receiving the synchronization message. 21.根据权利要求20所述的方法,其特征在于,21. The method according to claim 20, characterized in that 所述策略下发报文还包括汇聚节点的标识,所述时钟同步参数是所述汇聚节点根据从所述执行节点获取的所述时间信息确定的;The policy delivery message further includes an identifier of a convergence node, and the clock synchronization parameter is determined by the convergence node according to the time information obtained from the execution node; 所述方法还包括:The method further comprises: 所述控制节点向所述汇聚节点发送所述策略下发报文。The control node sends the policy delivery message to the aggregation node. 22.根据权利要求21所述的方法,其特征在于,所述方法还包括:22. The method according to claim 21, characterized in that the method further comprises: 所述控制节点接收来自所述汇聚节点的所述时钟同步参数;The control node receives the clock synchronization parameter from the aggregation node; 所述控制节点向所述第一节点发送参数发布报文,所述参数发布报文包括所述时钟同步参数。The control node sends a parameter publishing message to the first node, where the parameter publishing message includes the clock synchronization parameter. 23.根据权利要求20至22中任一项所述的方法,其特征在于,所述订阅请求报文包括所述第一节点的标识、所述第二节点的标识和时钟同步精度。23. The method according to any one of claims 20 to 22, characterized in that the subscription request message includes the identifier of the first node, the identifier of the second node and clock synchronization accuracy. 24.根据权利要求21至23中任一项所述的方法,其特征在于,所述策略下发报文还包括以下至少一项:24. The method according to any one of claims 21 to 23, wherein the policy delivery message further comprises at least one of the following: 第一时钟同步周期、所述同步报文的类型、所述同步报文传输使用的通信介质、所述同步报文的时间信息标记方式,所述第一时钟同步周期是所述执行节点执行所述时钟同步算法的周期。The first clock synchronization cycle, the type of the synchronization message, the communication medium used for the transmission of the synchronization message, and the time information marking method of the synchronization message. The first clock synchronization cycle is the cycle in which the execution node executes the clock synchronization algorithm. 25.根据权利要求24所述的方法,其特征在于,所述方法还包括:25. The method according to claim 24, characterized in that the method further comprises: 所述控制节点根据所述第一节点的时钟值的置信区间的长度和所述时钟同步精度确定所述第二时钟同步周期,或者,所述控制节点根据所述第二节点的时钟值的置信区间的长度和所述时钟同步精度确定所述第二时钟同步周期,所述第一节点的时钟值的置信区间或所述第二节点的时钟值的置信区间是根据所述时钟同步参数确定的;当所述置信区间的长度与所述时钟同步精度的差值的绝对值小于第一预设阈值时,所述第一时钟同步周期是所述第二时钟同步周期;当所述置信区间与所述时钟同步精度的差值的绝对值大于第一预设阈值且所述置信区间的长度大于所述时钟同步精度时,所述第二时钟同步周期小于所述第一时钟同步周期,当所述置信区间的长度与所述时钟同步精度的差值的绝对值大于第一预设阈值且所述置信区间的长度小于所述时钟同步精度时,所述第二同步周期大于所述第一时钟同步周期。The control node determines the second clock synchronization period according to the length of the confidence interval of the clock value of the first node and the clock synchronization accuracy, or the control node determines the second clock synchronization period according to the length of the confidence interval of the clock value of the second node and the clock synchronization accuracy, and the confidence interval of the clock value of the first node or the confidence interval of the clock value of the second node is determined according to the clock synchronization parameter; when the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is less than a first preset threshold, the first clock synchronization period is the second clock synchronization period; when the absolute value of the difference between the confidence interval and the clock synchronization accuracy is greater than a first preset threshold and the length of the confidence interval is greater than the clock synchronization accuracy, the second clock synchronization period is less than the first clock synchronization period, and when the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is greater than the first preset threshold and the length of the confidence interval is less than the clock synchronization accuracy, the second synchronization period is greater than the first clock synchronization period. 26.一种时钟同步系统,其特征在于,包括:26. A clock synchronization system, comprising: 第一节点,用于向所述控制节点发送订阅请求报文,所述订阅请求报文用于订阅所述第一节点与第二节点的时钟同步服务,所述第二节点是与所述第一节点进行时钟同步的节点;A first node, used to send a subscription request message to the control node, where the subscription request message is used to subscribe to a clock synchronization service between the first node and a second node, where the second node is a node that performs clock synchronization with the first node; 控制节点,用于根据所述订阅请求报文,确定策略下发报文,所述策略下发报文包括时钟同步算法;A control node, configured to determine a policy delivery message according to the subscription request message, wherein the policy delivery message includes a clock synchronization algorithm; 所述第一节点,还用于获取时钟同步参数,所述时钟同步参数用于所述时钟同步服务,所述时钟同步参数是根据所述时钟同步算法确定的。The first node is further used to obtain a clock synchronization parameter, where the clock synchronization parameter is used for the clock synchronization service, and the clock synchronization parameter is determined according to the clock synchronization algorithm. 27.根据权利要求26所述的系统,其特征在于,所述策略下发报文包括执行节点的标识,所述系统还包括执行节点;27. The system according to claim 26, characterized in that the policy delivery message includes an identifier of an execution node, and the system further includes an execution node; 所述控制节点,还用于向所述执行节点发送所述策略下发报文;The control node is further used to send the policy delivery message to the execution node; 所述执行节点用于根据所述策略下发报文,执行所述时钟同步算法,所述时钟同步参数是根据所述执行节点执行所述时钟同步算法发送和/或接收的同步报文的时间信息确定的,所述时间信息包括与所述执行节点发送所述同步报文关联的时钟计数器的数值或者时间戳,和/或,所述时间信息包括与所述执行节点接收所述同步报文关联的时钟计数器的数值或者时间戳。The execution node is used to send messages according to the strategy and execute the clock synchronization algorithm. The clock synchronization parameters are determined based on the time information of the synchronization message sent and/or received by the execution node when executing the clock synchronization algorithm. The time information includes the value or timestamp of the clock counter associated with the execution node sending the synchronization message, and/or the time information includes the value or timestamp of the clock counter associated with the execution node receiving the synchronization message. 28.根据权利要求27所述的系统,其特征在于,所述策略下发报文还包括汇聚节点的标识,所述汇聚节点不是所述第一节点,所述系统还包括汇聚节点;28. The system according to claim 27, characterized in that the policy delivery message further includes an identifier of a sink node, the sink node is not the first node, and the system further includes a sink node; 所述控制节点,还用于向所述汇聚节点发送所述策略下发报文;The control node is further configured to send the policy delivery message to the aggregation node; 所述执行节点,还用于向所述汇聚节点发送时间信息上传报文,所述时间信息上传报文包括所述时间信息;The execution node is further used to send a time information upload message to the aggregation node, wherein the time information upload message includes the time information; 所述汇聚节点,用于:The aggregation node is used to: 根据所述时间信息和所述时钟同步算法确定所述时钟同步参数;Determine the clock synchronization parameter according to the time information and the clock synchronization algorithm; 向所述第一节点发送参数发布报文,所述参数发布报文包括所述时钟同步参数。A parameter publishing message is sent to the first node, where the parameter publishing message includes the clock synchronization parameter. 29.根据权利要求27所述的系统,其特征在于,所述策略下发报文还包括汇聚节点的标识,所述汇聚节点不是所述第一节点,所述系统还包括汇聚节点;29. The system according to claim 27, characterized in that the policy delivery message further includes an identifier of a sink node, the sink node is not the first node, and the system further includes a sink node; 所述控制节点,还用于向所述汇聚节点发送所述策略下发报文;The control node is further configured to send the policy delivery message to the aggregation node; 所述执行节点,还用于向所述汇聚节点发送时间信息上传报文,所述时间信息上传报文包括所述时间信息;The execution node is further used to send a time information upload message to the aggregation node, wherein the time information upload message includes the time information; 所述汇聚节点,用于:The aggregation node is used to: 根据所述时间信息和所述时钟同步算法确定所述时钟同步参数;Determine the clock synchronization parameter according to the time information and the clock synchronization algorithm; 向所述控制节点发送所述时钟同步参数;Sending the clock synchronization parameter to the control node; 所述控制节点,还用于向所述第一节点发送参数发布报文,所述参数发布报文包括所述时钟同步参数。The control node is further used to send a parameter publishing message to the first node, where the parameter publishing message includes the clock synchronization parameter. 30.根据权利要求27所述的系统,其特征在于,所述策略下发报文还包括汇聚节点的标识,所述汇聚节点是所述第一节点;30. The system according to claim 27, wherein the policy delivery message further includes an identifier of a sink node, and the sink node is the first node; 所述执行节点还用于,向所述汇聚节点发送时间信息上传报文,所述时间信息上传报文包括所述时间信息;The execution node is further used to send a time information upload message to the aggregation node, where the time information upload message includes the time information; 所述第一节点具体用于:The first node is specifically used for: 根据所述时间信息,确定所述时钟同步参数。The clock synchronization parameter is determined according to the time information. 31.根据权利要求28至30中任一项所述的系统,其特征在于,所述订阅请求报文包括所述第一节点的标识、所述第二节点的标识和时钟同步精度。31. The system according to any one of claims 28 to 30, characterized in that the subscription request message includes the identifier of the first node, the identifier of the second node and clock synchronization accuracy. 32.根据权利要求31所述的系统,其特征在于,所述策略下发报文还包括以下至少一项:32. The system according to claim 31, wherein the policy delivery message further includes at least one of the following: 第一时钟同步周期、所述同步报文的类型、所述同步报文传输使用的通信介质、所述同步报文的时间信息标记方式,所述第一时钟同步周期是所述执行节点执行所述时钟同步算法的周期。The first clock synchronization cycle, the type of the synchronization message, the communication medium used for the transmission of the synchronization message, and the time information marking method of the synchronization message. The first clock synchronization cycle is the cycle in which the execution node executes the clock synchronization algorithm. 33.根据权利要求32所述的系统,其特征在于,所述控制节点还用于:33. The system according to claim 32, wherein the control node is further used for: 根据所述第一节点的时钟值的置信区间的长度和所述时钟同步精度,确定第二时钟同步周期,或者,根据所述第二节点的时钟值的置信区间的长度和所述时钟同步精度,确定第二时钟同步周期,所述第一节点的时钟值的置信区间或所述第二节点的时钟值的置信区间是所述汇聚节点根据所述时钟同步参数确定的;Determine a second clock synchronization period according to the length of the confidence interval of the clock value of the first node and the clock synchronization accuracy, or determine the second clock synchronization period according to the length of the confidence interval of the clock value of the second node and the clock synchronization accuracy, the confidence interval of the clock value of the first node or the confidence interval of the clock value of the second node being determined by the sink node according to the clock synchronization parameter; 向所述执行节点发送所述第二时钟同步周期;Sending the second clock synchronization cycle to the execution node; 所述执行节点,还用于根据所述第二时钟同步周期,执行所述时钟同步算法;The execution node is further used to execute the clock synchronization algorithm according to the second clock synchronization cycle; 其中,当所述置信区间的长度与所述时钟同步精度的差值的绝对值小于第一预设阈值时,所述第一时钟同步周期是所述第二时钟同步周期;当所述置信区间的长度与所述时钟同步精度的差值大于第一预设阈值且所述置信区间的长度大于所述时钟同步精度时,所述第二时钟同步周期小于所述第一时钟同步周期;当所述置信区间的长度与所述时钟同步精度的差值的绝对值大于第一预设阈值且所述置信区间的长度小于所述时钟同步精度时,所述第二同步周期大于所述第一时钟同步周期。Among them, when the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is less than a first preset threshold, the first clock synchronization period is the second clock synchronization period; when the difference between the length of the confidence interval and the clock synchronization accuracy is greater than the first preset threshold and the length of the confidence interval is greater than the clock synchronization accuracy, the second clock synchronization period is less than the first clock synchronization period; when the absolute value of the difference between the length of the confidence interval and the clock synchronization accuracy is greater than the first preset threshold and the length of the confidence interval is less than the clock synchronization accuracy, the second synchronization period is greater than the first clock synchronization period. 34.根据权利要求28至33中任一项所述的系统,其特征在于,34. A system according to any one of claims 28 to 33, characterized in that 所述执行节点包括所述第一节点和所述第二节点,所述第一节点和所述第二节点位于不同的局域网中,所述时间信息包括第一同步报文的TSF接收时间和所述第一同步报文的TSF发送时间、第二同步报文的TSF接收时间和所述第二同步报文的TSF发送时间;The execution node includes the first node and the second node, the first node and the second node are located in different local area networks, and the time information includes a TSF reception time of a first synchronization message and a TSF transmission time of the first synchronization message, a TSF reception time of a second synchronization message and a TSF transmission time of the second synchronization message; 所述时钟同步参数包括以下至少一项:所述第一节点的TSF时钟值和所述第二节点的TSF时钟值的差值以及所述第一节点的TSF时钟频率和所述第二节点的TSF时钟频率的差值;The clock synchronization parameter includes at least one of the following: a difference between a TSF clock value of the first node and a TSF clock value of the second node and a difference between a TSF clock frequency of the first node and a TSF clock frequency of the second node; 所述第一节点,具体用于:The first node is specifically used for: 将所述第一节点的TSF时钟与所述第一节点的系统时钟对齐;aligning a TSF clock of the first node with a system clock of the first node; 向所述第二节点发送所述第一同步报文;Sending the first synchronization message to the second node; 所述第二节点,具体用于:The second node is specifically used for: 向所述第一节点发送所述第二同步报文;Sending the second synchronization message to the first node; 根据所述时钟同步参数,调节所述第二节点的TSF时钟;adjusting the TSF clock of the second node according to the clock synchronization parameter; 根据调整后的TSF时钟,调节所述第二节点的系统时钟。The system clock of the second node is adjusted according to the adjusted TSF clock. 35.根据权利要求28至33中任一项所述的系统,其特征在于,35. A system according to any one of claims 28 to 33, characterized in that 所述执行节点包括所述第一节点、所述第二节点和第三节点,所述时间信息包括:所述第一节点接收所述多个参考报文的时间和所述第二节点接收所述多个参考报文的时间;The execution nodes include the first node, the second node and the third node, and the time information includes: the time when the first node receives the multiple reference messages and the time when the second node receives the multiple reference messages; 所述时钟同步参数包括以下至少一项:所述第一节点的时钟值和所述第二节点的时钟值的差值以及所述第一节点的时钟频率和所述第二节点的时钟频率的差值;或者,The clock synchronization parameter includes at least one of the following: a difference between a clock value of the first node and a clock value of the second node and a difference between a clock frequency of the first node and a clock frequency of the second node; or, 所述时钟同步参数包括以下至少一项:所述第一节点的时钟值和第一参考时钟值的差值、所述第二节点的时钟值和所述第一参考时钟值的差值、所述第一节点的时钟频率和第一参考时钟频率的差值、所述第二节点的时钟频率和所述第一参考时钟频率的差值;The clock synchronization parameter includes at least one of the following: a difference between a clock value of the first node and a first reference clock value, a difference between a clock value of the second node and the first reference clock value, a difference between a clock frequency of the first node and a first reference clock frequency, and a difference between a clock frequency of the second node and the first reference clock frequency; 其中,所述第三节点,具体用于向所述第一节点和所述第二节点发送所述多个参考报文。The third node is specifically used to send the multiple reference messages to the first node and the second node. 36.根据权利要求27至31中任一项所述的系统,其特征在于,所述执行节点不包括所述第一节点,所述时钟同步参数包括第二参考时钟值和/或第二参考时钟频率,所述第一节点还用于:36. The system according to any one of claims 27 to 31, wherein the execution node does not include the first node, the clock synchronization parameter includes a second reference clock value and/or a second reference clock frequency, and the first node is further used for: 根据所述时钟同步参数,更新所述第一节点的时钟为所述第二参考时钟值和/或所述第二参考时钟频率。According to the clock synchronization parameter, the clock of the first node is updated to the second reference clock value and/or the second reference clock frequency. 37.一种时钟同步装置,其特征在于,包括处理器,所述处理器与存储器耦合,所述存储器用于存储指令,所述指令被所述处理器运行时,37. A clock synchronization device, comprising a processor, the processor being coupled to a memory, the memory being used to store instructions, the instructions being executed by the processor, 使得所述处理器执行如权利要求1至11中任意一项所述的方法,或者causing the processor to execute the method according to any one of claims 1 to 11, or 使得所述处理器执行如权利要求12至18中任意一项所述的方法,或者causing the processor to execute the method according to any one of claims 12 to 18, or 使得所述处理器执行如权利要求19至25中任意一项所述的方法。The processor is caused to execute the method according to any one of claims 19 to 25. 38.一种计算机可读存储介质,其特征在于,存储有计算机可执行指令,当所述计算机可执行指令在计算机上运行时,使得所述计算机执行如权利要求1至11中任一项所述的方法,或使得所述计算机执行如权利要求12至18中任一项所述的方法,或使得所述计算机执行如权利要求19至25中任一项所述的方法。38. A computer-readable storage medium, characterized in that it stores computer-executable instructions, which, when executed on a computer, enable the computer to execute the method as described in any one of claims 1 to 11, or enable the computer to execute the method as described in any one of claims 12 to 18, or enable the computer to execute the method as described in any one of claims 19 to 25. 39.一种计算机程序产品,其特征在于,所述计算机程序产品包括:计算机程序代码,当所述计算机程序代码被运行时,实现如权利要求1至11中任一项所述的方法,或实现如权利要求12至18中任一项所述的方法,或实现如权利要求19至25中任一项所述的方法。39. A computer program product, characterized in that the computer program product comprises: a computer program code, which, when executed, implements the method according to any one of claims 1 to 11, or implements the method according to any one of claims 12 to 18, or implements the method according to any one of claims 19 to 25.
CN202211466808.XA 2022-11-22 2022-11-22 Clock synchronization method, device and system Pending CN118074839A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211466808.XA CN118074839A (en) 2022-11-22 2022-11-22 Clock synchronization method, device and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211466808.XA CN118074839A (en) 2022-11-22 2022-11-22 Clock synchronization method, device and system

Publications (1)

Publication Number Publication Date
CN118074839A true CN118074839A (en) 2024-05-24

Family

ID=91097948

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211466808.XA Pending CN118074839A (en) 2022-11-22 2022-11-22 Clock synchronization method, device and system

Country Status (1)

Country Link
CN (1) CN118074839A (en)

Similar Documents

Publication Publication Date Title
US11564187B2 (en) Method and device for supporting configuration of time synchronization network in mobile communication network
US9515756B2 (en) Adaptive precision timing control in a communication system
CN104170291B (en) Method and network node for processing precision time protocol
CN112511325B (en) Network congestion control method, node, system and storage medium
CN101882990B (en) Method for selecting master clock based on PTP (Picture Transfer Protocol) and link quality, slave clock and system
US10334539B2 (en) Metered interface
US12167353B2 (en) Network entities and methods for a wireless network system for determining time information
CN106550248B (en) Audio and video synchronization method and device
US20180083850A1 (en) Service performance monitoring in a virtualized communication network
US20230199683A1 (en) Clock synchronization mode indication method and communication apparatus
JP2018508157A (en) Real-time transport protocol RTP packet transmission method and apparatus
CN113518037A (en) Congestion information synchronization method and related device
US11909623B2 (en) Device presence method and system for mesh network management
WO2023109267A1 (en) Information measurement method and apparatus
Staglianò et al. D-MQTT: design and implementation of a pub/sub broker for distributed environments
WO2018045518A1 (en) Volte communication method and base station
US20180234934A1 (en) Anchor master am management method and node
US9203934B2 (en) Synchronization of clocks between two communication terminals using TCP/IP
Hu et al. PLI-sync: Prefetch loss-insensitive sync for NDN group streaming
WO2010102565A1 (en) Method, apparatus and system for time synchronization
CN118074839A (en) Clock synchronization method, device and system
CN114501604B (en) Method for acquiring (or providing) clock synchronization information and communication device
CN103259713B (en) Message exchange system and method
US10264513B2 (en) Method of data communication in wireless ad hoc network
CN115277504A (en) Network traffic monitoring method, device and system

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