Method, apparatus and device for supporting high-precision clock service

By installing a smart network interface card that supports a high-precision clock synchronization protocol on the virtualization device and adding timestamps to business packets using hardware flow tables, the problem of high-precision clocks that ordinary x86 servers cannot achieve is solved, thus realizing high-precision clock synchronization and reducing costs.

CN115632736BActive Publication Date: 2026-06-05NEW H3C TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
NEW H3C TECH CO LTD
Filing Date
2022-09-09
Publication Date
2026-06-05

AI Technical Summary

Technical Problem

Ordinary x86 servers are not equipped with high-precision clock hardware chips, and virtual machines cannot perceive the hardware clock, resulting in the inability to achieve high-precision clock synchronization. Dedicated clock server equipment is expensive and cannot meet the high-precision clock requirements of industrial internet and rail transportation.

Method used

Installing a smart network interface card (NIC) that supports a high-precision clock synchronization protocol on a virtualization device, and adding send and receive timestamps to service packets through hardware flow tables, enables synchronization between the smart NIC and a high-precision clock source, thereby reducing costs.

Benefits of technology

Deploying high-precision clock services on servers that do not support high-precision clocks reduces deployment costs and meets the high-precision clock requirements of industrial internet, rail transit, and other applications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115632736B_ABST
    Figure CN115632736B_ABST
Patent Text Reader

Abstract

The application provides a method, device and equipment supporting high-precision clock service. The application installs an intelligent network card supporting a high-precision clock synchronization protocol on a virtualization device, starts the high-precision clock synchronization function of the intelligent network card to realize clock synchronization between the intelligent network card and a high-precision clock source. A hardware flow table for a service requiring high-precision clock is issued to the intelligent network card, and when the intelligent network card forwards a service packet of a specified service outward, the hardware flow table adds a sending timestamp to the service packet based on the high-precision clock on the intelligent network card; and when the intelligent network card forwards the service packet of the specified service inward, the hardware flow table adds a receiving timestamp to the service packet based on the high-precision clock on the intelligent network card. The application can support deployment of high-precision clock service on a server not supporting high-precision clock, and reduces the deployment cost of high-precision clock service.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of communication and cloud computing technologies, and in particular to a method, apparatus, and device for supporting high-precision clock services. Background Technology

[0002] Smart NICs can offload virtual switch functionality from the central processing unit (CPU) on the server motherboard to the network card, freeing up the expensive computing power of the server CPU to be used by applications, thereby better expanding the functionality of the network card and providing higher performance.

[0003] The core idea of ​​a smart network interface card (NIC) is to use a field-programmable gate array (FPGA) to assist the CPU in handling network load and program network interface functions. Smart NICs have the following characteristics:

[0004] (1) Support for data plane and control plane function customization through FPGA local programming, assisting the CPU in handling network load;

[0005] (2) It typically includes multiple ports and an internal switch, which quickly forwards data and intelligently maps it to relevant applications based on network packets, application sockets, etc.

[0006] (3) Detect and manage network traffic.

[0007] Smart NICs enhance application and virtualization performance, leveraging the advantages of Software-Defined Networking (SDN) and Network Function Virtualization (NFV). They remove network virtualization, load balancing, and other low-level functions from the server CPU, ensuring maximum processing power for applications. Simultaneously, smart NICs provide distributed computing resources, enabling users to develop their own software or provide access services, thereby accelerating specific applications.

[0008] Currently, there are generally two solutions for supporting high-precision clocks in business application systems:

[0009] The first method is the Global Positioning System (GPS) clock synchronization method. This method uses the synchronization satellite signals of satellite positioning systems such as BeiDou and GPS to receive 1pps and serial port time information, and synchronizes the local clock with the clock of the satellite positioning system.

[0010] The second method is time synchronization protocol clock synchronization, which uses time synchronization protocols such as Precision Time Protocol (PTP) to achieve high-precision clock synchronization between devices. PTP clock synchronization accuracy can reach the sub-microsecond level.

[0011] Because satellite positioning system clock synchronization solutions are costly, most companies in the industry use clock synchronization protocol solutions.

[0012] PTP protocol standards, or PTP profiles, are standards that implement different PTP functionalities. PTP protocol standards include the following types:

[0013] IEEE 1588 version 2 (abbreviated as 1588v2) is a standard that defines the principles and message exchange processing specifications for high-precision clock synchronization in networks. Originally designed for industrial automation, it is now primarily used for bridging local area networks (LANs). IEEE 1588 does not impose strict requirements on the network environment, making it widely applicable. The standard can be customized to enhance or remove specific functions for different application environments. The latest version is V2, or 1588v2.

[0014] IEEE 802.1AS: Abbreviated as 802.1AS. 802.1AS is a protocol standard based on IEEE 1588, refining the implementation of IEEE 1588 in bridged local area networks. The BMC (Best Master Clock) algorithm supported by 802.1AS differs slightly from IEEE 1588, referencing the implementation of MSTP (Multiple Spanning Tree Protocol). 802.1AS supports only point-to-point full-duplex Ethernet links, IEEE 802.11 links, and IEEE 802.3EPON links.

[0015] A network that uses the PTP protocol is called a PTP domain. A PTP domain has one and only one clock source, and all devices within the domain are synchronized with that clock.

[0016] Nodes within the PTP domain are called clock nodes, and the interfaces on clock nodes that run the PTP protocol are called PTP interfaces. The IEEE 1588 version 2 and IEEE 802.1AS protocol standards define the following types of basic clock nodes:

[0017] Ordinary Clock (OC) Nodes: These clock nodes participate in time synchronization within the same PTP domain using only one PTP interface, and synchronize time from upstream clock nodes through this interface. Furthermore, when a clock node acts as a clock source, it can publish time to downstream clock nodes using only one PTP interface.

[0018] Boundary Clock (BC) Nodes: These clock nodes have multiple PTP interfaces within the same PTP domain for time synchronization. They synchronize time from an upstream clock node through one of these interfaces and publish time to downstream clock nodes through the others. Furthermore, when a clock node acts as a clock source, it can publish time to downstream clock nodes through multiple PTP interfaces.

[0019] Transparent Clock (TC) Nodes: These clock nodes have multiple PTP interfaces, but they only forward PTP protocol messages and perform forwarding delay corrections between these interfaces; they do not synchronize time through any single interface. Compared to BC / OC, which requires synchronization with other clock nodes, TC does not.

[0020] TC nodes include the following two types:

[0021] End-to-End Transparent Clock (E2ETC): This type of node directly forwards non-P2P (Peer-to-Peer) PTP protocol messages in the network and participates in calculating the delay of the entire link.

[0022] Peer-to-Peer Transparent Clock (P2PTC): This type of node only forwards Sync, Follow_Up, and Announce messages directly, while terminating other PTP protocol messages and participating in the calculation of the delay of each segment of the entire link.

[0023] Figure 1 This diagram illustrates the location of the basic PTP clock node within the PTP domain and the PTP interfaces. Besides the basic clock nodes, there are also hybrid clock nodes, such as TC+OC, which combines the characteristics of TC and OC. It has multiple PTP interfaces within the same PTP domain, one of which is of type OC, while the others are of type TC. On one hand, it forwards PTP protocol messages and performs forwarding delay correction through the TC-type interface; on the other hand, it synchronizes time through the OC-type interface. Similar to the classification of TC, TC+OC also includes two types: E2ETC+OC and P2PTC+OC.

[0024] The protocol standard defines parameters such as time precision, time class, time attributes, and clock skew measurement to describe the quality of the PTP clock source signal. Users have customized and supplemented the protocol standard according to their own network conditions, forming their own technical standards. Currently, there are three technical standards: the default technical standard, the OAM technical standard, and the Unicom technical standard. Different technical standards have different default values ​​for these parameters. Using different technical standards in the same network may result in different clock sources being elected, and different technical standards will also handle PTP packets differently.

[0025] The master-slave relationship between clock nodes is relative. For a pair of clock nodes that are synchronized with each other, the master-slave relationship exists as follows:

[0026] Master / Slave Nodes: The clock node that publishes the synchronization time is called the master node, while the clock node that receives the synchronization time is called the slave node.

[0027] Master / Slave Clock: The clock on the master node is called the master clock, while the clock on the slave node is called the slave clock.

[0028] Master / Slave / Passive Interfaces: The PTP interface on a clock node that publishes synchronization time is called the master interface (MasterPort), while the PTP interface that receives synchronization time is called the slave interface (SlavePort). Both master and slave interfaces can exist on either the clock node (BC) or the clock node (OC). A PTP interface that neither publishes nor receives synchronization time is called a passive interface (PassivePort).

[0029] The clock node supports the following two clock sources:

[0030] Local clock source: A 38.88MHz clock signal generated by the crystal oscillator inside the clock monitoring module.

[0031] External clock source (ToD clock source): Generated by an external clock device and transmitted and received through a dedicated interface on the main control board (i.e., 1PPS / ToD interface), hence it is also called a ToD clock source.

[0032] like Figure 1For example, all clock nodes within a PTP domain are organized hierarchically, and the reference time for the entire domain is the Grandmaster Clock (GM), which is the highest-level clock. Clock nodes exchange PTP protocol messages and, based on information such as clock priority, time class, and clock precision carried in the PTP protocol messages, elect the Grandmaster Clock for the entire PTP domain. The Grandmaster Clock's time is ultimately synchronized throughout the entire PTP domain, hence it is also called the PTP domain's clock source.

[0033] Currently, in scenarios such as the Industrial Internet and rail transportation, high-precision clocks are required to meet the requirements of signal systems. These scenarios typically employ dedicated equipment, such as dedicated clock servers, to implement high-precision clock technology. However, dedicated clock servers and similar equipment are expensive, requiring users to utilize more widely available ordinary x86 servers in conjunction with virtualization technology to reduce costs. Currently, ordinary x86 servers do not have the stable crystal oscillators and other hardware chips required for high-precision clocks. Furthermore, virtual machines cannot perceive hardware clocks and can only synchronize with the clock source using timed synchronization mechanisms, making it impossible to meet the high-precision clock requirements. Summary of the Invention

[0034] In view of this, the present invention provides a method, apparatus and device for supporting high-precision clock services, which solves the technical problem that virtualized devices do not support high-precision clock services.

[0035] According to one aspect of an embodiment of the present invention, the present invention provides a method for supporting high-precision clock services. The method is applied to a first server (server A), the first server having a first smart network interface card (smart network interface card A) installed thereon, the first smart network interface card supporting a high-precision clock synchronization protocol, and a first virtual machine (virtual machine A1) running on the first server, on which a high-precision clock service application runs. The method includes:

[0036] The first smart network card receives the first service message of the high-precision clock service sent by the first virtual machine on the first server.

[0037] After the first service packet is timestamped by the first hardware flow table on the first smart network card, it is forwarded outward.

[0038] The matching field of the first hardware flow table is used to match the IP address of the first virtual machine and the specified port number of the high-precision clock service; the action field is used to add the high-precision timestamp of the first smart network card to the first service packet as the sending timestamp of the first service packet.

[0039] Furthermore, the method also includes:

[0040] The first smart network card receives the second service message of the high-precision clock service (the service message sent by smart network card B) from the outside; the second service message carries the sending timestamp of the second service message stamped by the peer (smart network card B);

[0041] After the second service packet is timestamped by the second hardware flow table on the first smart network card, it is forwarded to the high-precision clock service application on the first virtual machine.

[0042] The matching field of the second hardware flow table is used to match the IP address of the first virtual machine and the specified port number of the high-precision clock service; the action field is used to add the high-precision timestamp of the first smart network card to the second service packet as the receiving timestamp of the second service packet.

[0043] Furthermore, the method also includes:

[0044] The high-precision clock service application obtains the receiving timestamp from the received second service message and uses the receiving timestamp from the second service message as the receiving time when the high-precision clock service application receives the second service message.

[0045] Furthermore, the method also includes:

[0046] The first smart network interface card (NIC) receives an acknowledgment message for the first service message from an external source. The acknowledgment message carries a sending timestamp (ta1) added by the first smart network interface card to the first service message and a receiving timestamp (tb1) added by the peer (smart network interface card B) to indicate that the first service message was received.

[0047] Furthermore, the first smart network card synchronizes a high-precision clock from an external high-precision clock source through a high-precision clock synchronization protocol, thereby synchronizing the core clock of the first smart network card with the external high-precision clock source.

[0048] Furthermore, the first service message and the second service message are TCP protocol type service messages; the timestamp option field in the TCP protocol type service message carries the sending timestamp and receiving timestamp.

[0049] According to another aspect of an embodiment of the present invention, the present invention also provides an apparatus for supporting high-precision clock services, the apparatus being applied to a first server (server A), the apparatus comprising:

[0050] The first virtual machine (virtual machine A1) runs a high-precision clock service application.

[0051] The first smart network card (smart network card A) supports a high-precision clock synchronization protocol;

[0052] The first smart network interface card is used to receive the first service message of high-precision clock service sent by the first virtual machine; and to forward the first service message after stamping it with a sending timestamp through the first hardware flow table on the first smart network interface card.

[0053] The matching field of the first hardware flow table is used to match the IP address of the first virtual machine and the specified port number of the high-precision clock service; the action field is used to add the high-precision timestamp of the first smart network card to the first service packet as the sending timestamp of the first service packet.

[0054] Furthermore, the first smart network card is also used to receive the second service message of the high-precision clock service (the service message sent by smart network card B) from the outside; the second service message carries the transmission timestamp of the second service message stamped by the peer (smart network card B);

[0055] The first smart network interface card is also used to forward the second service message to the high-precision clock service application on the first virtual machine after stamping the second service message with a receiving timestamp using the second hardware flow table on the first smart network interface card.

[0056] The matching field of the second hardware flow table is used to match the IP address of the first virtual machine and the specified port number of the high-precision clock service; the action field is used to add the high-precision timestamp of the first smart network card to the second service packet as the receiving timestamp of the second service packet.

[0057] Furthermore, the first smart network card is also used to synchronize a high-precision clock from an external high-precision clock source through a high-precision clock synchronization protocol, so that the kernel clock of the first smart network card is synchronized with the external high-precision clock source.

[0058] According to another aspect of an embodiment of the present invention, the present invention also provides an electronic device, including a processor, a communication interface, a storage medium and a communication bus, wherein the processor, the communication interface and the storage medium communicate with each other through the communication bus;

[0059] Storage medium used to store computer programs;

[0060] When a processor executes a computer program stored on a storage medium, it performs the steps of the above method.

[0061] According to another aspect of an embodiment of the present invention, the present invention also provides a storage medium having a computer program stored thereon, the computer program performing the steps described above when executed by a processor. Attached Figure Description

[0062] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments of the present invention or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present invention. For those skilled in the art, other drawings can be obtained from these drawings of the embodiments of the present invention.

[0063] Figure 1 A schematic diagram showing the location of the PTP basic clock node within the PTP domain and the PTP interface;

[0064] Figure 2 This is a schematic diagram of the network structure of a virtualized system supporting high-precision clock services provided by the present invention in one embodiment of the present invention;

[0065] Figure 3 A schematic diagram illustrating the process of measuring transmission delay in two-step mode of the PTP protocol;

[0066] Figure 4 This is a flowchart illustrating the steps of a method for supporting high-precision clock services according to an embodiment of the present invention.

[0067] Figure 5 This is a schematic diagram of an electronic device structure for implementing a method to support high-precision clock services, according to an embodiment of the present invention. Detailed Implementation

[0068] The terminology used in this embodiment of the invention is for the purpose of describing particular embodiments only and is not intended to limit the embodiments of the invention. The singular forms “a,” “the,” and “the” as used in this embodiment are also intended to include the plural forms unless the context clearly indicates otherwise. The term “and / or” as used in this invention refers to any or all possible combinations comprising one or more of the associated listed items.

[0069] It should be understood that although the terms first, second, third, etc., may be used to describe various information in embodiments of the present invention, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, without departing from the scope of embodiments of the present invention, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" may also be interpreted as "when," "when," or "in response to a determination."

[0070] In some application scenarios that require support for high-precision clocks, such as the Industrial Internet, rail transit, and autonomous driving, in order to utilize existing server resources or reduce system costs, server resources that do not support high-precision clocks may be used, and virtual machines may be deployed on these servers to provide business services for these scenarios. However, since the servers hosting the virtual machines do not support high-precision clocks, the virtual machines on them cannot obtain high-precision hardware clocks from the servers. As a result, the business services on the virtual machines that require high-precision clocks cannot meet their business needs because they cannot obtain local high-precision clocks.

[0071] Based on the aforementioned technical problems, the objective of this invention is to provide a method for supporting high-precision clock services. The basic idea of ​​this method is to install a smart network interface card (NIC) supporting a high-precision clock synchronization protocol on a virtualization device (e.g., a server, host machine, personal computer, mobile terminal device, etc. that supports virtualization), and enable the high-precision clock synchronization function of the smart NIC to achieve clock synchronization between the smart NIC and a high-precision clock source. A hardware flow table is issued to the smart NIC for services requiring high-precision clocks. When the smart NIC forwards service packets for a specified service, a sending timestamp based on the high-precision clock on the smart NIC is added to the service packet using the hardware flow table; similarly, when the smart NIC forwards service packets for a specified service internally, a receiving timestamp based on the high-precision clock on the smart NIC is added to the service packet. This invention, through the hardware flow table, enables high-precision clock services on virtual machines to directly obtain the high-precision clock from the smart NIC's high-precision clock from the service packet, thereby allowing the deployment of high-precision clock services even on servers that do not support high-precision clocks, reducing the deployment cost of high-precision clock services.

[0072] Figure 2 This diagram illustrates a network structure of a virtualized system supporting high-precision clock services, as provided by this invention, in one embodiment of the invention. In this example, virtual machines A1 and A2 and virtual machines B1 and B2 are deployed on servers A and B, respectively. Virtual machines A1 and B1 host services requiring high-precision clocks, but servers A and B do not support high-precision clocks. Server A has a smart network interface card (NIC) A, and server B has a smart NIC B. NICs A and B, along with physical forwarding devices (such as switches or routers), support high-precision clock synchronization protocols (e.g., PTP protocol).

[0073] The slave clock ports on smart NICs A and B synchronize a high-precision clock with the master clock port on the connected physical forwarding device. Users can configure the smart NICs through the out-of-band management port, enable the PTP function of the smart NICs, and set smart NICs A and B as slave clock nodes. Similarly, the forwarding device can be configured as the master clock node through the management interface on the forwarding device, the port on the smart NIC connected to the forwarding device can be set as the slave clock port, and the port on the forwarding device connected to the smart NIC can be set as the master clock port.

[0074] After enabling PTP functionality, the CPU of the smart network interface card (NIC) can exchange PTP protocol messages with the forwarding device according to the PTP protocol requirements to synchronize a high-precision clock. The forwarding device will also synchronize its clock with an external high-precision clock source via the PTP protocol. The smart NIC can match PTP messages using a hardware flow table and write the receive or send time into the timestamp field of the message, thus enabling the smart NIC to implement high-precision clock functionality.

[0075] To aid understanding, the basic principles of PTP protocol clock synchronization are explained below:

[0076] After confirming the master-slave relationship between the clocks, the master and slave clocks exchange PTP protocol messages and record the message transmission and reception times. The total round-trip delay between the master and slave clocks is calculated by calculating the round-trip time difference of the PTP protocol messages. If the transmission delays in both directions are the same, then half of the total round-trip delay is the one-way delay. The slave clock calculates the time deviation based on this one-way delay and the time difference between the sending time of the Sync message on the master clock and the receiving time of the Sync message on the slave clock. The slave clock adjusts its local time according to this time deviation, thus achieving synchronization between the slave and master clocks.

[0077] The PTP protocol defines two transmission delay measurement mechanisms: the request-response mechanism and the peer delay mechanism, both of which are based on network symmetry.

[0078] In one embodiment of the present invention, a request-response mechanism can be selected to synchronize a high-precision clock between the smart network card and the physical switching device, and the end delay mechanism can be implemented with reference to the implementation principle of the request-response mechanism.

[0079] Under the request-response mechanism, the master clock and slave clock calculate the average path delay between them based on the PTP protocol messages sent and received. If there is a TC between the master clock and slave clock, the TC does not calculate the average path delay, but only transmits the received PTP protocol messages and passes the residence time of the synchronization message (Sync message) on the TC to the slave clock.

[0080] Depending on whether a Follow_Up message needs to be sent, the request-response mechanism is divided into two types: two-step mode and one-step mode.

[0081] Figure 3 This is a schematic diagram illustrating the transmission delay measurement method in two-step mode of the PTP protocol. In two-step mode, the transmission timestamp t1 of the Sync message is carried by the Follow_Up message. In single-step mode, the transmission timestamp t1 of the Sync message is carried by the Sync message, and no Follow_Up message is sent.

[0082] refer to Figure 3 The following example uses the two-step pattern to illustrate the implementation process of the request-response mechanism:

[0083] (1) The master clock node sends a Sync message to the slave clock node and records the sending time t1; after the slave clock node receives the message, it records the receiving time t2.

[0084] (2) After the master clock node sends the Sync message, it immediately sends a Follow_Up message carrying t1.

[0085] (3) Send a delay request message, namely Delay_Req message, from the clock node to the master clock node to initiate the calculation of the delay for the reverse transmission and record the sending time t3; after the master clock node receives the message, it records the receiving time t4.

[0086] (4) After receiving the Delay_Req message, the master clock node replies with a Delay_Resp message carrying a delay request message t4.

[0087] At this point, the clock node has four timestamps from t1 to t4, from which the following can be calculated:

[0088] Total round-trip delay between master and slave clock nodes = (t2 – t1) + (t4 – t3)

[0089] One-way delay between master and slave clock nodes = [(t2–t1)+(t4–t3)] / 2

[0090] Clock offset from the master clock node: Offset = (t2–t1)–[(t2–t1)+(t4–t3)] / 2 = [(t2–t1)–(t4–t3)] / 2

[0091] Smart NIC A on server A and smart NIC B on server B obtain high-precision clocks from the physical forwarding device through a high-precision clock synchronization protocol, thus enabling the virtual machines on servers A and B to support high-precision clock services. The high-precision clock service described in this embodiment refers to services with high real-time requirements that rely on high-precision clocks, such as industrial internet, rail transit, and autonomous driving services.

[0092] Figure 4 This is a flowchart illustrating the steps of a method for supporting high-precision clock services according to an embodiment of the present invention. For ease of description, Figure 4 The example is based on Figure 2 The network structure is used to describe this invention, but the implementation of the technical solution of this invention is not limited to this. Figure 2 The simple network structure shown in the example is also applicable to more complex network structures in real-world business scenarios.

[0093] Servers A and B themselves lack a high-precision clock source in their hardware. However, the services running on virtual machines A1 on server A and B1 on server B require high-precision clock support. To enable servers A and B to support high-precision clock services in this scenario, this invention installs smart network interface cards (NICs) A and B, respectively, on servers A and B, which support high-precision clock synchronization. The hardware flow tables on smart NICs A and B then add a high-precision timestamp to the forwarded high-precision clock service packets, thereby enabling servers A and B to support high-precision clock services.

[0094] To achieve the above objectives, when creating virtual machines A1 and B on the virtualization platform, it is necessary to select a virtual machine image file that supports high-precision clock services and configure a specified port number for the high-precision clock service. Assuming that virtual machines A and B exchange high-precision clock service packets via TCP protocol, the TCP port number 1234 is configured on both virtual machines A and B as the specified port number for this high-precision clock service, and this specified port number needs to be communicated to the virtualization platform. The network controller at the management layer of the virtualization platform (e.g., a software-defined networking (SDN) controller) issues hardware flow tables to smart NICs A and B based on the IP addresses and specified port numbers of virtual machines A and B, and uses these hardware flow tables to add high-precision timestamps to the forwarded high-precision clock service packets.

[0095] The following combination Figure 4 The method steps for supporting high-precision clock services in this embodiment are described below:

[0096] Step 401. Virtual machine A1 on server A sends a high-precision clock service message to virtual machine B1 on server B. The service message is forwarded outward through smart network card A on virtual machine A1.

[0097] Step 402. Smart NIC A, acting as a high-precision clock node, after receiving a service packet, matches the first hardware flow table and adds a sending timestamp (ta1) to the service packet using the first hardware flow table; the matching field of the first hardware flow table is used to match the IP address of virtual machine A1 and the specified port number (e.g., 1234) of the high-precision clock service; the action field is used to add the high-precision timestamp of smart NIC A to the service packet as the sending timestamp (ta1) of the service packet.

[0098] Taking the high-precision clock service message as an example of a TCP protocol message, the TCP protocol reserves a timestamp option field in the TCP options field. The timestamp option field (occupying 10 bytes) includes: a type field kind (1 byte), a length field length (1 byte), and an info field info (8 bytes). The info field can be composed of two parts: a timestamp field timestamp (4 bytes) and a timestamp echo field timestamp echo (4 bytes).

[0099] The matching field key of the first hardware flow table issued by the virtualization platform to smart NIC A includes the IP address of virtual machine A and the specified port number of the high-precision clock service (i.e., the source IP address and the source port number). The action field action is to write the current timestamp (ta1) of the kernel clock synchronized by smart NIC A through the high-precision clock synchronization protocol into the timestamp field of the service packet. ta1 serves as the sending timestamp of the service packet sent from the sending end.

[0100] Step 403. Smart NIC A forwards the service message with the sending timestamp (ta1) to Smart NIC B;

[0101] When the service message is a protocol message for a high-precision clock service, this embodiment further includes the step of sending back an acknowledgment message for the service message (steps 4031 to 4032). For data messages, it is not necessary to send back an acknowledgment message; whether or not to send back an acknowledgment message depends on the actual service requirements.

[0102] Step 4031. When the smart network interface card B receives the service message, it sends an acknowledgment message (ack) back to the smart network interface card A. The timestamp field of the acknowledgment message is filled with the time (tb1) when the smart network interface card B received the service message, and the timestamp echo field is filled with the sending timestamp (ta1) of the service message.

[0103] Step 4032. After receiving the acknowledgment message, Smart NIC A can calculate the round-trip time (RTT) of the message between Smart NIC A and Smart NIC B using the values ​​in the timestamp field and the timestamp echo field.

[0104] Step 404. Smart NIC B, acting as a high-precision clock node, after receiving a service packet, matches the second hardware flow table and adds a receiving timestamp (tb1) to the service packet using the second hardware flow table. The matching field of the service hardware flow table is used to match the IP address of virtual machine B1 and the specified port number of the high-precision clock service (i.e., match the destination IP address and destination port number). The action field is used to add the high-precision timestamp of smart NIC B to the service packet as the receiving timestamp (tb1) of the service packet.

[0105] For example, smart network card B adds a receiving timestamp (tb1) to the timestamp echo of the TCP protocol service message, and then forwards the service message to virtual machine B1.

[0106] Step 405. Smart NIC B sends a service message carrying a send timestamp (ta1) and a receive timestamp (tb1) to virtual machine B1 on server B.

[0107] After receiving a TCP protocol service packet, the high-precision clock service application on virtual machine B1 extracts the sending timestamp (ta1) from the timestamp as the accurate time when virtual machine A1 sent the service packet, and extracts the receiving timestamp (tb1) from the timestamp echo as the accurate time when virtual machine B1 received the service packet. The high-precision clock service on virtual machine B1 can use these accurate times to perform its own industrial internet or rail transit business logic, etc. The specific business processing logic is not within the scope of protection of this invention, and therefore will not be elaborated.

[0108] Since the way the timestamps of business messages are obtained on virtual machines A1 and B1 is different from that of existing physical devices, high-precision clock service applications can add configuration items to select whether the current running environment is a virtual machine or a physical device. Different timestamp acquisition processes are performed according to the selection. If it is a virtual machine, the timestamp is obtained from the business message; if it is a physical device, the system time is directly taken.

[0109] Since TCP is a highly reliable protocol, the application of high-precision clocks in this embodiment of the invention preferably uses TCP packets. If unreliable transmission protocols such as UDP are used, a timestamp option field similar to that in the UDP protocol or a new field can be added to write the timestamp. This invention will not elaborate on this.

[0110] Figure 5 This is a schematic diagram of an electronic device 500 for implementing a method supporting high-precision clock services according to an embodiment of the present invention. The device 500 includes a processor 510, such as a central processing unit (CPU), a communication bus 520, a communication interface 540, and a storage medium 530. The processor 510 and the storage medium 530 can communicate with each other via the communication bus 520. The storage medium 530 stores a computer program, which, when executed by the processor 510, implements one or more steps of the method supporting high-precision clock services provided by the present invention.

[0111] The storage medium may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. Alternatively, the storage medium may be at least one storage device located remotely from the aforementioned processor. The processor may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0112] It should be recognized that embodiments of the present invention can be implemented or carried out by computer hardware, a combination of hardware and software, or by computer instructions stored in non-transitory memory. The methods can be implemented using standard programming techniques, including a non-transitory storage medium configured with a computer program within the computer program, wherein such a storage medium causes the computer to operate in a specific and predefined manner. Each program can be implemented in a high-level procedural or object-oriented programming language to communicate with the computer system. However, if desired, the program can be implemented in assembly or machine language. In any case, the language can be a compiled or interpreted language. Furthermore, for this purpose, the program can run on a programmed application-specific integrated circuit. Moreover, the operations of the processes described in this invention can be performed in any suitable order unless otherwise indicated by the invention or otherwise clearly contradicted by the context. The processes (or variations and / or combinations thereof) described in this invention can be executed under the control of one or more computer systems configured with executable instructions and can be implemented by hardware or a combination thereof as code (e.g., executable instructions, one or more computer programs, or one or more applications) that commonly executes on one or more processors. The computer program includes a plurality of instructions executable by one or more processors.

[0113] Furthermore, the method can be implemented in any suitable type of computing platform, including but not limited to personal computers, minicomputers, mainframes, workstations, networked or distributed computing environments, standalone or integrated computer platforms, or in communication with charged particle tools or other imaging devices. Aspects of the invention can be implemented as machine-readable code stored on a non-transitory storage medium or device, whether removable or integrated into a computing platform, such as a hard disk, optical read and / or write storage medium, RAM, ROM, etc., such that it is readable by a programmable computer, and when the storage medium or device is read by the computer, it can be used to configure and operate the computer to perform the processes described herein. Furthermore, the machine-readable code, or portions thereof, can be transmitted via wired or wireless networks. The invention includes these and other different types of non-transitory computer-readable storage media when such media comprises instructions or programs that implement the steps described above in conjunction with a microprocessor or other data processor. When programmed according to the methods and techniques described in the invention, the invention also includes the computer itself.

[0114] The above description is merely an embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principle of the present invention should be included within the scope of protection of the present invention.

Claims

1. A method for supporting high-precision clock services, characterized in that, This method is applied to a first server, which is equipped with a first smart network interface card (NIC) that supports a high-precision clock synchronization protocol. The first server also runs a first virtual machine, which in turn runs a high-precision clock service application. The method includes: The first smart network card receives the first service message of the high-precision clock service sent by the first virtual machine on the first server. After the first service packet is timestamped by the first hardware flow table on the first smart network card, it is forwarded outward. The matching field of the first hardware flow table is used to match the IP address of the first virtual machine and the specified port number of the high-precision clock service; the action field is used to add the high-precision timestamp of the first smart network card to the first service packet as the sending timestamp of the first service packet.

2. The method according to claim 1, characterized in that, The method further includes: The first smart network card receives the second service message of the high-precision clock service from the outside; the second service message carries the transmission timestamp of the second service message stamped by the peer end; After the second service packet is timestamped by the second hardware flow table on the first smart network card, it is forwarded to the high-precision clock service application on the first virtual machine. The matching field of the second hardware flow table is used to match the IP address of the first virtual machine and the specified port number of the high-precision clock service; the action field is used to add the high-precision timestamp of the first smart network card to the second service packet as the receiving timestamp of the second service packet.

3. The method according to claim 2, characterized in that, The method further includes: The high-precision clock service application obtains the receiving timestamp from the received second service message and uses the receiving timestamp from the second service message as the receiving time when the high-precision clock service application receives the second service message.

4. The method according to claim 1, characterized in that, The method further includes: The first smart network interface card (NIC) receives an acknowledgment message for the first service message from an external source. The acknowledgment message carries a sending timestamp added by the first smart network interface card to the first service message and a receiving timestamp added by the peer to indicate that the first service message was received.

5. The method according to claim 1, characterized in that, The first smart network card synchronizes a high-precision clock from an external high-precision clock source through a high-precision clock synchronization protocol, thereby synchronizing the core clock of the first smart network card with the external high-precision clock source.

6. The method according to claim 2, characterized in that, The first service message and the second service message are service messages of TCP protocol type; The timestamp option field in a TCP protocol type business message carries the sending timestamp and receiving timestamp.

7. A device supporting high-precision clock services, characterized in that, The device is used in a first server, and the device includes: The first virtual machine runs a high-precision clock service application. The first smart network interface card (NIC) supports a high-precision clock synchronization protocol. The first smart network interface card is used to receive the first service message of high-precision clock service sent by the first virtual machine; and to forward the first service message after stamping it with a sending timestamp through the first hardware flow table on the first smart network interface card. The matching field of the first hardware flow table is used to match the IP address of the first virtual machine and the specified port number of the high-precision clock service; the action field is used to add the high-precision timestamp of the first smart network card to the first service packet as the sending timestamp of the first service packet.

8. The apparatus according to claim 7, characterized in that, The first smart network interface card is also used to receive a second service message of the high-precision clock service from an external source; the second service message carries a transmission timestamp of the second service message stamped by the peer end; The first smart network interface card is also used to forward the second service message to the high-precision clock service application on the first virtual machine after stamping the second service message with a receiving timestamp using the second hardware flow table on the first smart network interface card. The matching field of the second hardware flow table is used to match the IP address of the first virtual machine and the specified port number of the high-precision clock service; the action field is used to add the high-precision timestamp of the first smart network card to the second service packet as the receiving timestamp of the second service packet.

9. The apparatus according to claim 7, characterized in that, The first smart network card is also used to synchronize a high-precision clock from an external high-precision clock source through a high-precision clock synchronization protocol, so that the kernel clock of the first smart network card is synchronized with the external high-precision clock source.

10. An electronic device, characterized in that, It includes a processor, a communication interface, a storage medium, and a communication bus, wherein the processor, the communication interface, and the storage medium communicate with each other through the communication bus; Storage medium used to store computer programs; A processor, when executing a computer program stored on a storage medium, performs the method steps of any one of claims 1-6.

11. A storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it performs the method as described in any one of claims 1 to 6.