Vehicle-mounted network time synchronization method and device, storage medium and electronic equipment

By pre-specifying the main clock and backup clock in the on-board network, the main clock node selection and switching process is simplified, and the problem of the on-board time-sensitive system starting time is solved when the Grandmaster node is abnormal is solved, and rapid response and failure paralysis time is achieved.

CN119583000APending Publication Date: 2025-03-07CHINA AUTOMOTIVE INNOVATION CORP
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411792302.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-06
Publication Date
2025-03-07

AI Technical Summary

Technical Problem

In an on-vehicle network, when an exception occurs in the Grandmaster node, the network needs to reselect the new Grandmaster node through complex algorithms, resulting in the time-consuming process of selecting and switching the main clock node, which significantly extends the startup time of the on-vehicle time-sensitive system.

Method used

By periodically sending first time synchronization messages to the pre-specified master clock, ensuring that each slave clock is synchronized with the master clock, and when the master clock is abnormal, the detection message is sent through the backup clock, and automatically determine the backup clock as the new master clock, simplifying the switching process of the master/support clock.

Benefits of technology

It shortens the response time of the on-board network when the main clock fails, reduces the failure time caused by the main clock failure, and improves the startup speed of the on-board sensitive system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119583000A_ABST
    Figure CN119583000A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a vehicle-mounted network time synchronization method and device, a storage medium and electronic equipment, and the method comprises the steps: carrying out the synchronization processing of each first slave clock according to a first time synchronization message periodically issued by a master clock, so as to achieve the time synchronization between each first slave clock and the master clock; the main clock is a pre-specified clock node in a time domain; under the condition that the master clock is abnormal, a standby clock is determined as a new master clock, and the standby clock is a pre-specified clock node in a plurality of first slave clocks except the master clock in a time domain; and according to a second time synchronization message periodically issued by the new master clock, performing synchronization processing on each second slave clock, so that time synchronization between each second slave clock and the new master clock is realized. The problem that the starting time of a vehicle-mounted sensitive system is long due to the fact that the new master clock node selection and switching process consumes long time in the related technology is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present application relate to the field of vehicle network technology, and more specifically, to a vehicle network time synchronization method, device, storage medium, and electronic device. Background Art

[0002] With the rapid development of automotive electronic technology, the number of electronic devices and sensors in modern vehicles has increased dramatically, and in-vehicle networks are facing increasingly complex challenges in connection and data interaction. The emergence of time-sensitive networking (TSN) technology provides a new solution for in-vehicle networks. TSN technology not only follows the standard Ethernet architecture, but also gives in-vehicle networks precise traffic management and scheduling capabilities, ensuring that multiple business flows including control signals and sensor data share the network while ensuring latency and bandwidth, thereby reducing system complexity and cost, and becoming an important evolution direction for in-vehicle network technology.

[0003] In TSN technology, achieving precise time synchronization of each node in the vehicle network is the key to ensuring the accurate execution of the automatic control function. Usually, TSN networks use gPTP (General Precision Time Protocol) for time synchronization, in which a high-performance node is designated as the Grandmaster (GM, master clock) node, which is responsible for distributing calibration time information to the entire network domain.

[0004] However, when an abnormality occurs in a GM node, the network needs to reselect a new GM node through a set of complex algorithms to maintain the stability of time synchronization. The selection and switching process takes a long time, which significantly prolongs the startup time of the vehicle's time-sensitive system under abnormal circumstances. Summary of the invention

[0005] The embodiments of the present application provide a vehicle network time synchronization method, device, storage medium and electronic device to at least solve the problem in the related art that the new master clock node selection and switching process takes a long time, resulting in a long startup time for the vehicle-mounted sensitive system.

[0006] According to one aspect of an embodiment of the present application, a vehicle network time synchronization method is provided, comprising: according to a first time synchronization message periodically sent by a master clock, synchronizing each first slave clock so that each first slave clock is synchronized with the master clock; the master clock is a pre-designated clock node in a time domain; each first slave clock is each clock node in the time domain except the master clock; in the case where the first time synchronization message sent by the master clock is not received for more than a preset period of time, sending a detection message to the master clock through a backup clock; the backup clock is a pre-designated clock node among multiple first slave clocks in the time domain except the master clock; in the case where the backup clock does not receive a reply message from the master clock to the detection message within a preset time range, determining that the master clock is abnormal, determining the backup clock as a new master clock, and according to a second time synchronization message periodically sent by the new master clock, synchronizing each second slave clock so that each second slave clock is synchronized with the new master clock; each second slave clock is each clock node in the time domain except the new master clock.

[0007] According to another aspect of the embodiment of the present application, a vehicle network time synchronization device is provided, including: a master clock synchronization module, used to synchronize each first slave clock according to a first time synchronization message periodically sent by the master clock, so as to synchronize the time between each first slave clock and the master clock; the master clock is a pre-specified clock node in the time domain; each first slave clock is each clock node in the time domain except the master clock; a master clock monitoring module, used to send a detection message to the master clock through a backup clock if the first time synchronization message sent by the master clock is not received within a preset cycle time. ; The backup clock is a pre-designated clock node among multiple first slave clocks other than the master clock in the time domain; a backup clock synchronization module is used to determine that the master clock is abnormal when the backup clock does not receive a reply message from the master clock to the detection message within a preset time range, determine the backup clock as the new master clock, and synchronize each second slave clock according to the second time synchronization message periodically sent by the new master clock, so that each second slave clock is synchronized with the new master clock; each second slave clock is each clock node in the time domain except the new master clock.

[0008] According to another aspect of an embodiment of the present application, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the above-mentioned vehicle network time synchronization method when running.

[0009] According to another aspect of an embodiment of the present application, an electronic device is also provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the vehicle network time synchronization method through the computer program.

[0010] According to another aspect of the embodiments of the present application, a computer program product is also provided, including a computer program, which, when executed by a processor, implements the steps in any of the above-mentioned vehicle network time synchronization method embodiments.

[0011] Through the embodiments of the present application, a pre-specified master clock periodically sends a first time synchronization message to ensure that each first slave clock can synchronize time with the master clock in time, wherein the master clock is pre-specified and the first time synchronization message is periodically sent, and the synchronization processing of all first slave clocks can be completed in a shorter time. When the first time synchronization message sent by the master clock is not received within the preset cycle time, the backup clock can quickly send a detection message to the master clock. When the backup clock does not receive a reply message from the master clock, the backup clock is automatically determined as the new master clock. The master clock and the backup clock are pre-specified by static configuration, which avoids the complex selection process of the master / backup clock and shortens the switching process of the backup clock. The vehicle network can respond quickly when the master clock fails, reducing the paralysis time caused by the failure of the master clock, and continues to send the second time synchronization message for synchronization processing, shortening the startup time of the vehicle-mounted sensitive system, and solving the problem of the long startup time of the vehicle-mounted sensitive system caused by the long selection and switching process of the new master clock node in the related technology. BRIEF DESCRIPTION OF THE DRAWINGS

[0012] Figure 1 It is a hardware structure block diagram of an optional vehicle network time synchronization method according to an embodiment of the present application;

[0013] Figure 2 is a flow chart of an optional vehicle network time synchronization method according to an embodiment of the present application;

[0014] Figure 3 is a structural diagram of an optional first time synchronization tree and a second time synchronization tree according to an embodiment of the present application;

[0015] Figure 4 is a flow chart of an optional master / slave clock switching according to an embodiment of the present application;

[0016] Figure 5 is a schematic diagram of an optional time synchronization process according to an embodiment of the present application;

[0017] Figure 6is an optional flow chart of measuring a first path delay and a first clock frequency ratio according to an embodiment of the present application;

[0018] Figure 7 is a structural block diagram of an optional vehicle network time synchronization device according to an embodiment of the present application;

[0019] Figure 8 It is a structural block diagram of an optional electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0020] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.

[0021] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0022] Initially, in-vehicle networks used proprietary communication protocols, which made it difficult to integrate different systems and devices. As technology continued to develop, the introduction of standard protocols such as CAN (Controller Area Network) and LIN (Local Interconnect Network) solved some of the problems, but there are still some limitations. For example, these protocols are not suitable for long-distance communication and have limited bandwidth. In recent years, newer protocols such as Ethernet (TCP / IP) have been introduced to address some of the limitations of CAN and LIN. Ethernet has the advantages of mature technology, high standardization, high bandwidth and low cost. With the rapid development of automotive electronics in recent years, the number of in-vehicle electronic products has increased year by year, and the complexity of connection and intercommunication has increased. The technical advantages of Ethernet can well meet the needs of automakers for in-vehicle network connections.

[0023] In order to achieve more accurate automatic control functions, it is necessary to collect and process sensor data in real time, especially the fusion of multi-sensor raw data, which poses new challenges to network delay, jitter, bandwidth, reliability, etc. As a new generation of switching network technology, time-sensitive network (TSN) technology, because it complies with the standard Ethernet architecture and has accurate traffic scheduling capabilities, can ensure the high-quality transmission of multiple business traffic on the same network, and has both technical and cost advantages. It is called one of the important evolution directions of vehicle network technology. Among them, the time synchronization standard 802.1AS in TSN technology can achieve nanosecond network delay and can be used for control signal transmission with ultra-low delay and ultra-low jitter requirements. In TSN technology, achieving precise time synchronization of each node in the vehicle network is the key to ensure the accurate execution of the automatic control function. Usually, TSN networks use gPTP (General Precision Time Protocol) for time synchronization, in which a high-performance node is designated as the Grandmaster (GM, master clock) node, which is responsible for distributing calibration time information to the entire network domain.

[0024] However, when an abnormality occurs in a GM node, the network needs to reselect a new GM node through a set of complex algorithms to maintain the stability of time synchronization. The selection and switching process takes a long time, which significantly prolongs the startup time of the vehicle's time-sensitive system under abnormal circumstances.

[0025] Therefore, in order to solve the above problem, according to one aspect of an embodiment of the present application, a vehicle network time synchronization method is provided. Optionally, in this embodiment, the vehicle network time synchronization method can be applied to Figure 1 In the hardware environment composed of the vehicle terminal 102 and the server 104 shown in FIG. Figure 1 As shown, the server 104 is connected to the vehicle-mounted terminal 102 via a network, and can be used to provide services (such as application services, etc.) for the terminal or a client installed on the terminal. A database can be set up on the server or independently of the server to provide data storage services for the server 104. Cloud computing and / or edge computing services can be configured on the server or independently of the server to provide data computing services for the server 104.

[0026] The above network may include but is not limited to at least one of the following: wired network, wireless network. The above wired network may include but is not limited to at least one of the following: wide area network, metropolitan area network, local area network, and the above wireless network may include but is not limited to at least one of the following: WIFI, Bluetooth. The vehicle terminal 102 may not be limited to a PC, a mobile phone, a tablet computer, or other devices.

[0027] The vehicle network time synchronization method of the embodiment of the present application can be executed by the vehicle terminal 102, or can be executed by the server 104 and the vehicle terminal 102 together. Taking the vehicle network time synchronization method of the embodiment executed by the vehicle terminal 102 as an example, Figure 2 is a flow chart of an optional vehicle network time synchronization method according to an embodiment of the present application, such as Figure 2 As shown, the process of the method may include the following steps:

[0028] Step S202, according to the first time synchronization message periodically sent by the master clock, each first slave clock is synchronized to synchronize the time between each first slave clock and the master clock; the master clock is a pre-designated clock node in the time domain; each first slave clock is each clock node in the time domain except the master clock.

[0029] The Grandmaster (GM node) refers to a high-performance node that is pre-designated as a time synchronization benchmark in a time-sensitive network (TSN). The Grandmaster is responsible for periodically distributing calibration time information (i.e., the first time synchronization message) to the entire network domain to ensure that all slave clock nodes maintain time synchronization with it.

[0030] The first time synchronization message refers to the time synchronization message periodically sent by the master clock. The first time synchronization message carries key information for time synchronization, such as the original timestamp of the master clock, the ratio of the master clock frequency to the local clock frequency, etc., and is used to achieve time synchronization between each first slave clock and the master clock.

[0031] The first slave clock refers to each clock node except the master clock in the time domain. The first slave clock node maintains time synchronization with the master clock by receiving the first time synchronization message of the master clock.

[0032] Optionally, the vehicle terminal pre-specifies a clock node with the first clock performance in the time domain as the master clock, and constructs a first time synchronization tree with the master clock node as the root node. At the same time, the vehicle terminal pre-specifies a clock node with the second clock performance in the time domain as the backup clock, and constructs a second time synchronization tree with the backup clock node as the root node. The vehicle terminal periodically sends the first time synchronization message through the master clock node, and transmits the first time synchronization message containing the key information of time synchronization to each first slave clock node in the domain step by step through the generated first time synchronization tree. The vehicle terminal listens to and receives the first time synchronization message from the master clock in the network through each first slave clock, verifies the first time synchronization message, extracts the current timestamp of the master clock and other key information of time synchronization from the first time synchronization message that passes the verification, and according to the extracted key information of time synchronization, the first slave clock calculates the deviation between its own time and the master clock time, and obtains the time deviation value by comparing the current time of the first slave clock with the timestamp of the master clock. According to the calculated time deviation value, the time of the first slave clock is adjusted to achieve time synchronization with the master clock.

[0033] Figure 3 FIG. 4 is a structural diagram of a first time synchronization tree and a second time synchronization tree in an embodiment. Figure 3 As shown, each clock node in the same domain has four ports: MasterPort, SlavePort, PassivePort and DisablePort. MasterPort is the master port of the node, used to send time synchronization messages; SlavePort is the slave port of the node, used to receive time synchronization messages; PassivePort is the passive port of the node, which is not related to time synchronization; DisabledPort is any port of the time-aware system, indicating that this port is unavailable. When the master clock is normal, the master clock periodically sends the first time synchronization message through the MasterPort port, which is received by the SlavePort port of each first slave clock node on the first time synchronization tree, and forwarded by the MasterPort port of each first slave clock, so as to achieve time synchronization of the entire domain.

[0034] Step S204, when the first time synchronization message sent by the master clock is not received within a preset period of time, a detection message is sent to the master clock through a backup clock; the backup clock is a pre-specified clock node among multiple first slave clocks other than the master clock in the time domain.

[0035] Among them, the backup clock refers to a pre-designated clock node in the vehicle network that can take over the work of the main clock when an abnormality occurs in the main clock. The backup clock is usually selected as the backup clock from multiple first slave clocks with better performance. When the main clock is abnormal or can no longer send time synchronization messages, the backup clock will send a detection message to the main clock. If the reply message from the main clock is not received within the preset time range, the backup clock will be upgraded to a new master clock and start sending a second time synchronization message to maintain the time synchronization of the network. In the embodiment of the present application, the gPTP domain T0 is set as the main domain, and the node with the first clock performance in the network node is selected as the main clock node. At the same time, the gPTP domain T1 is set as the redundant domain, and the node with the second clock performance in the network node is selected as the backup clock node. Among them, gPTP domain T0 and gPTP domain T1 are both part of the time domain.

[0036] In the prior art, the selection of master / backup clock nodes often relies on a set of complex algorithms. These algorithms usually consider multiple factors, such as node performance, load, network conditions, etc., and determine the optimal master / backup node combination through complex calculations. However, this method has problems such as large amount of calculation, long selection time, and high consumption of system resources. In the embodiment of the present application, during the configuration stage, it is pre-determined which nodes will serve as master clock nodes and which nodes will serve as backup clock nodes based on actual needs and expected scenarios. By pre-specifying the master / backup clock nodes, the selection process is simplified, and the amount of calculation and selection time are reduced.

[0037] Optionally, the vehicle terminal sets a timer inside the backup clock to monitor the time interval since the last time the first time synchronization message sent by the main clock was received. When the time interval recorded by the timer exceeds the preset cycle time, it is judged as a timeout. The vehicle terminal sends a detection message to the main clock through the backup clock.

[0038] Step S206, when the backup clock does not receive a reply message from the master clock to the detection message within a preset time range, it is determined that the master clock is abnormal, the backup clock is determined as the new master clock, and each second slave clock is synchronized according to the second time synchronization message periodically sent by the new master clock, so that each second slave clock is synchronized with the new master clock; each second slave clock is each clock node in the time domain except the new master clock.

[0039] The second time synchronization message refers to the time synchronization message periodically sent by the new master clock after the standby clock is upgraded to the new master clock. The second time synchronization message has a similar structure and function to the first time synchronization message. The second time synchronization message is used to achieve time synchronization between each second slave clock and the new master clock.

[0040] The second slave clock refers to each clock node in the time domain except the new master clock, which is called the second slave clock. It can be understood that when switching to the new master clock, the original master clock will be downgraded to an abnormal second slave clock node. When the original master clock switches from an abnormal state to a normal state, it can be switched back to the original master clock, or the original master clock can be used as a backup clock. When the new master clock is abnormal, the original master clock is used to replace the new master clock to continue time synchronization. The second slave clock receives the second time synchronization message sent by the new master clock and performs time correction according to the second time synchronization message. Similar to the first slave clock, the second slave clock also maintains time synchronization with the new master clock by receiving the time synchronization message of the new master clock.

[0041] Optionally, Figure 4 FIG. 1 is a flowchart of a master / slave clock switching in one embodiment. Figure 4 As shown, after the vehicle terminal sends a detection message to the master clock through the backup clock, it continues to wait for the master clock's reply message to the previously sent detection message within a preset time range (such as within a timeout threshold). If the backup clock does not receive a reply message from the master clock within the preset time range, it is determined that the master clock may be in an abnormal state. At this time, the vehicle terminal determines the backup clock as the new master clock. The vehicle terminal starts to generate and send a second time synchronization message to each second slave clock according to a preset period through the new master clock (i.e., the original backup clock). Each second slave clock receives the second time synchronization message from the new master clock, and adjusts the time according to the time information in the second time synchronization message. Each second slave clock calculates the deviation between its own time and the new master clock time, and adjusts the time according to the deviation value to achieve time synchronization with the new master clock.

[0042] like Figure 3 As shown, when the master clock is normal, the standby clock node also performs clock synchronization through the first time synchronization message sent by the master clock node. In order to reduce the number of message interactions between nodes, during the normal operation of the master clock node, the standby clock node only performs time synchronization according to the first time synchronization message sent by the master clock node, and does not periodically send the second clock synchronization message in the second time synchronization tree of domain 1. In the case of an abnormality in the master clock, the standby clock generates a second time synchronization message and transmits it to each second slave clock node step by step through the second time synchronization tree.

[0043] It should be noted that the difference between the process of synchronizing the first slave clock with the master clock and the process of synchronizing the second slave clock with the new master clock is only that the reference objects for time synchronization are different, and the rest of the synchronization process is the same. The process of synchronizing the second slave clock with the new master clock will not be repeated here.

[0044] Through the above steps S202 to S206, the first time synchronization message is periodically sent by the pre-designated master clock to ensure that each first slave clock can synchronize with the master clock in time, wherein the master clock is pre-designated and the first time synchronization message is periodically sent, and the synchronization processing of all first slave clocks can be completed in a shorter time. When the first time synchronization message sent by the master clock is not received within the preset cycle time, the backup clock can quickly send a detection message to the master clock. When the backup clock does not receive a reply message from the master clock, the backup clock is automatically determined as the new master clock. The master clock and the backup clock are pre-designated in a static configuration manner, which avoids the complex selection process of the master / backup clock and shortens the switching process of the backup clock, so that the vehicle network can respond quickly when the master clock fails, reducing the paralysis time caused by the failure of the master clock, and continuing to send the second time synchronization message for synchronization processing, shortening the startup time of the vehicle-mounted sensitive system, and solving the problem of the long startup time of the vehicle-mounted sensitive system caused by the long time-consuming selection and switching process of the new master clock node in the related technology.

[0045] In an exemplary embodiment, according to the first time synchronization message periodically sent by the master clock, each first slave clock is synchronized, so that each first slave clock is synchronized with the master clock in time. In the process, each first slave clock is used as the current first slave clock, and the following synchronization operations are performed to synchronize each first slave clock with the master clock:

[0046] 1. The first time synchronization message is periodically sent through the master clock, and the third time synchronization message sent by the upstream node of the current first slave clock is received through the current first slave clock; the upstream node of the current first slave clock refers to the clock node that is directly connected to the current first slave clock and is upstream of the current first slave clock; the third time synchronization message is generated by the upstream node of the current first slave clock according to the first time synchronization message.

[0047] The current first slave clock refers to a slave clock node that is currently performing time synchronization processing during the time synchronization process.

[0048] An upstream node refers to a clock node that is directly connected to a clock node and is upstream of the clock node (ie, the front end of the time flow).

[0049] The third time synchronization message refers to a time synchronization message generated by the upstream node of the current first slave clock according to the first time synchronization message and sent to the current first slave clock. The third time synchronization message has a similar structure and function to the first time synchronization message and the second time synchronization message. The third time synchronization message is used to achieve time synchronization between the upstream node of the current first slave clock and the master clock.

[0050] Optionally, the vehicle terminal uses each first slave clock as the current first slave clock, and periodically sends the first time synchronization message through the master clock. After the upstream node of the current first slave clock receives the first time synchronization message sent by the master clock, the vehicle terminal extracts the time synchronization key information in the first time synchronization message, and performs time synchronization based on the time synchronization key information; after the time synchronization between the upstream node of the current first slave clock and the master clock, the vehicle terminal generates a third time synchronization message through the upstream node of the current first slave clock, and sends the third time synchronization message to the current first slave clock. The vehicle terminal receives the third time synchronization message sent by the upstream node of the current first slave clock through the current first slave clock.

[0051] 2. Through the current first slave clock, time synchronization processing is performed on the current first slave clock according to the third time synchronization message, the pre-stored first path delay, the pre-stored first residence delay, and the pre-stored first clock frequency ratio to obtain the transmission delay of the current first slave clock relative to the master clock; the first path delay refers to the total delay time experienced when the third time synchronization message is transmitted between the upstream node of the current first slave clock and the current first slave clock; the first path delay is aligned with the current first slave clock; the first residence delay refers to the time that the third time synchronization message stays on the current first slave clock; the first residence delay is aligned with the current first slave clock; the first clock frequency ratio refers to the clock frequency ratio between the upstream node of the current first slave clock and the current first slave clock; the transmission delay is aligned with the master clock.

[0052] The first clock frequency ratio is a parameter used to describe the relative speed of the clock frequency between the upstream node of the current first slave clock and the current first slave clock. In this embodiment, the first clock frequency bit refers to the clock frequency difference between the upstream node of the current first slave clock and the current first slave clock.

[0053] Transmission delay refers to the total delay time from when the master clock sends the first time synchronization message to when the current first slave clock receives the message and adjusts its own time accordingly. For example, the transmission delay can be the sum of the first path delay and the first residence delay aligned with the master clock.

[0054] Optionally, the vehicle terminal receives a third time synchronization message from its upstream node through the current first slave clock. The vehicle terminal reads the first path delay, the first residence delay and the first clock frequency ratio from the local storage of the current first slave clock through the current first slave clock, and determines the scaling factor of the first path delay and the first residence delay according to the first clock frequency ratio and the time synchronization key information in the third time synchronization message, and performs time synchronization processing on the first path delay and the first residence delay according to the determined scaling factor to obtain the transmission delay of the current first slave clock relative to the master clock.

[0055] 3. Generate a fourth time synchronization message through the current first slave clock according to the transmission delay, and send the fourth time synchronization message to the downstream node of the current first slave clock, so that the downstream node of the current first slave clock is synchronized with the master clock according to the fourth time synchronization message; the downstream node of the current first slave clock refers to a clock node that is directly connected to the current first slave clock and is downstream of the current first slave clock.

[0056] Among them, the fourth time synchronization message refers to a message generated by the current first slave clock according to the transmission delay and its own time information, and is used to transmit to its downstream node for time synchronization. The fourth time synchronization message contains the key information of the time synchronization of the current first slave clock relative to the master clock. The fourth time synchronization message has a similar structure and function to the first time synchronization message, the second time synchronization message and the third time synchronization message. The fourth time synchronization message is used to achieve time synchronization between the downstream node of the current first slave clock and the master clock.

[0057] It should be noted that: the first time synchronization message is periodically sent by the master clock, is the starting signal of the time synchronization process, and provides a time reference for other clock nodes. The second time synchronization message is periodically sent by the backup clock, and is a signal that the backup clock continues the time synchronization process as the new master clock when the master clock is abnormal, and provides a time reference for other clock nodes. The third time synchronization message is generated by the upstream node of the current first slave clock based on the received first time synchronization message, and is sent to the node of the current first slave clock. The fourth time synchronization message is generated by the current first slave clock based on the received third time synchronization message, and is sent to the downstream node of the current first slave clock. In the time synchronization process, with the switching of the clock node currently being processed, after the current first slave clock is synchronized, the current first slave clock will switch to the upstream node of the current first slave clock in the next round of processing, and the fourth time synchronization message sent by the current first slave clock will also be changed to the third time synchronization message, and so on, until the last slave clock is synchronized.

[0058] Optionally, the vehicle terminal calculates the transmission delay compensation amount that needs to be applied to the time synchronization message based on the calculated transmission delay through the current first slave clock. The transmission delay compensation amount is used to ensure that the downstream node of the current first slave clock can accurately adjust according to the time of the master clock after receiving the fourth time synchronization message. The vehicle terminal generates a fourth time synchronization message through the current first slave clock based on its own time information and the calculated transmission delay compensation amount. The fourth time synchronization message contains the timestamp of the current first slave clock relative to the master clock (transmission delay compensation has been considered), as well as necessary synchronization parameters (such as clock frequency ratio, etc.). The vehicle terminal sends the generated fourth time synchronization message to its downstream node through the communication network through the current first slave clock. After the downstream node of the current first slave clock receives the fourth time synchronization message, the vehicle terminal adjusts its own time through the downstream node of the current first slave clock according to the timestamp and synchronization parameters in the message to keep the time synchronization with the master clock.

[0059] Through this embodiment, the first path delay, the first residence delay and the first clock frequency ratio are pre-stored, and the current first slave clock can quickly use the first path delay, the first residence delay and the first clock frequency ratio to perform time synchronization processing without re-measuring or calculating each time synchronization, which greatly reduces the delay in the time synchronization process, thereby accelerating the startup time of the vehicle-mounted sensitive system.

[0060] In an exemplary embodiment, the third time synchronization message includes a second clock frequency ratio; the second clock frequency ratio refers to a clock frequency ratio between the master clock and an upstream node of the current first slave clock.

[0061] Among them, the second clock frequency ratio is a parameter used to describe the relative speed of the clock frequency between the master clock and the upstream node of the current first slave clock. In this embodiment, the second clock frequency bit refers to the clock frequency difference between the master clock and the upstream node of the current first slave clock. The second clock frequency ratio is calculated by the upstream node of the current first slave clock and is attached to the third time synchronization message. When the current first slave clock receives the third time synchronization message, the current first slave clock can use the second clock frequency ratio to quickly and accurately determine the clock frequency difference between the master clock and the current first slave clock, and adjust its own clock to achieve synchronization with the master clock.

[0062] In one embodiment, time synchronization processing is performed on the current first slave clock according to a third time synchronization message, a pre-stored first path delay, a pre-stored first residence delay, and a pre-stored first clock frequency ratio through the current first slave clock to obtain a transmission delay of the current first slave clock relative to the master clock, including:

[0063] 1. Determine a third clock frequency ratio through the current first slave clock according to the first clock frequency ratio and the second clock frequency ratio; the third clock frequency ratio refers to the clock frequency ratio between the master clock and the current first slave clock.

[0064] Among them, the third clock frequency ratio is a parameter used to describe the relative speed of the clock frequency between the master clock and the current first slave clock. In this embodiment, the third clock frequency bit refers to the clock frequency difference between the master clock and the current first slave clock. It can be understood that the third clock frequency ratio can be used as a scaling factor for the first path delay and the first residence delay. According to the third clock frequency ratio, the first path delay and the first residence delay can be scaled so that the scaled first path delay and the first residence delay are aligned with the master clock.

[0065] Optionally, the vehicle terminal determines the third clock frequency ratio between the master clock and the current first slave clock by multiplying the product of the first clock frequency ratio and the second clock frequency ratio through the current first slave clock.

[0066] For example, Figure 5 FIG. 1 is a schematic diagram of a time synchronization process in an embodiment. Figure 5 As shown, since the structures of the first time synchronization message, the second time synchronization message, the third time synchronization message and the fourth time synchronization message are similar, in this embodiment, the first time synchronization message, the second time synchronization message, the third time synchronization message and the fourth time synchronization message all include Sync messages and Follow_Up messages. Among them, the Follow_Up message carries the first field, the second field and the third field, wherein the specific value of the first field represents the original timestamp of the master clock sending Sync; the specific value of the second field represents the ratio of the master clock frequency to the local clock frequency (i.e., the second clock frequency ratio); the specific value of the third field represents the difference between the timestamp of the local sending Sync message based on the master clock frequency and the original timestamp of the master clock sending Sync (i.e., the transmission delay).

[0067] Node A is the master clock, and node B is the current first slave clock. The MasterPort of node A sends a Sync message to the SlavePort of its downstream node B, and records the sending timestamp t s,A Node A then sends a message with timestamp t s,AThe Follow_Up message carries the first field, the second field, and the third field. Since node A is both the master clock and the upstream node of the current first slave clock B, the Sync and Follow_Up messages sent by node A are both the first time synchronization message and the third time synchronization message. Since node A itself is the master clock, the specific value of the second field in the Follow_Up message sent by node A is t s,A (marked as first field_A), the specific value of the second field is 1 (marked as second field_A), and the specific value of the third field is 0 (marked as third field_A).

[0068] After the SlavePort of the current first slave clock B receives the Sync message and Follow_Up message sent by node A, it first generates the timestamp t when the Sync message is received. r,B , the product of the previously stored first clock frequency ratio of the upstream node to the local node (that is, the clock frequency of node A / the clock frequency of node B) and the second field _A in the Follow_Up message sent by node A (that is, the ratio of the master clock frequency / the second clock frequency of upstream node A) is determined to be the third clock frequency ratio of the master clock frequency to the local clock frequency (that is, the master clock frequency / the clock frequency of the current first slave clock B).

[0069] 2. Perform clock conversion on the pre-stored first path delay according to the third clock frequency ratio through the current first slave clock to obtain the second path delay; the second path delay is aligned with the master clock.

[0070] The second path delay refers to the path delay of the first path delay after clock conversion and aligned with the master clock. The second path delay has been adjusted according to the third clock frequency ratio and is consistent with the clock of the master clock.

[0071] It should be noted that the first path delay refers to the total delay time experienced by the third time synchronization message when it is transmitted between the upstream node of the current first slave clock and the current first slave clock. The first path delay is relative to the clock of the current first slave clock. Both the first path delay and the second path delay are used to describe the total delay time experienced by the third time synchronization message during transmission. The first path delay is relative to the clock of the current first slave clock, while the second path delay is the delay time for alignment with the master clock after clock conversion.

[0072] Optionally, the vehicle terminal performs clock conversion on the pre-stored first path delay according to the third clock frequency ratio through the current first slave clock, specifically: the product of the third clock frequency ratio and the pre-stored first path delay is determined as the second path delay.

[0073] 3. Perform clock conversion on the pre-stored first dwell delay according to the third clock frequency ratio by using the current first slave clock to obtain the second dwell delay; the second dwell delay is aligned with the master clock.

[0074] The second resident delay refers to the resident delay of the first resident delay after clock conversion and is aligned with the master clock. The second resident delay is the result obtained after converting the first resident delay from the clock domain of the current first slave clock to the clock domain of the master clock.

[0075] It should be noted that the first residence delay and the second residence delay are both used to describe the time delay experienced by the third time synchronization message during transmission and processing. The first residence delay is relative to the clock of the current first slave clock, which indicates the length of time the third time synchronization message stays on the current first slave clock node. The second residence delay is the residence delay aligned with the master clock after clock conversion, which reflects the residence time of the message in the time domain relative to the master clock.

[0076] Optionally, the vehicle terminal performs clock conversion on the pre-stored first residence delay according to the third clock frequency ratio through the current first slave clock, specifically: the product of the third clock frequency ratio and the pre-stored first residence delay is determined as the second residence delay.

[0077] Fourth, through the current first slave clock, the sum of the second path delay and the second residence delay is determined as the transmission delay of the current first slave clock relative to the master clock.

[0078] Through this embodiment, the third time synchronization message includes a second clock frequency ratio, which describes the clock frequency difference between the master clock and the upstream node of the current first slave clock. At the same time, according to the second clock frequency ratio and the pre-stored first clock frequency ratio (the clock frequency ratio between the master clock and the upstream node of the current first slave clock), the third clock frequency ratio between the master clock and the current first slave clock is determined. Then, according to this third clock frequency ratio, the pre-stored first path delay and the first resident delay are clock-converted to obtain the second path delay and the second resident delay aligned with the master clock, respectively. Since the second path delay and the second resident delay have been aligned with the master clock, they can more accurately reflect the actual time synchronization situation. Finally, the sum of the second path delay and the second resident delay is determined as the transmission delay of the current first slave clock relative to the master clock, and a more accurate transmission delay parameter can be obtained, thereby reducing the time consumption in the time synchronization process.

[0079] In an exemplary embodiment, the third time synchronization message further includes an original timestamp when the master clock sends the first time synchronization message; and the original timestamp is aligned with the master clock.

[0080] The original timestamp refers to the time point recorded by the master clock when sending the first time synchronization message, which is aligned with the clock domain of the master clock. The original timestamp is used to identify the sending time of the first time synchronization message and is an important basis for subsequent time synchronization calculations.

[0081] In one embodiment, generating a fourth time synchronization message according to the transmission delay by using the current first slave clock includes:

[0082] A fourth time synchronization message is generated by the current first slave clock according to the third clock frequency ratio, the transmission delay and the original timestamp.

[0083] Optionally, the vehicle-mounted terminal uses the current first slave clock to take the original timestamp as the specific value of the first field in the fourth time synchronization message, the third clock frequency ratio as the specific value of the second field in the fourth time synchronization message, and the transmission delay as the specific value of the third field in the fourth time synchronization message, thereby obtaining the fourth time synchronization message.

[0084] For example, Figure 5 As shown, node A acts as the master clock, node B acts as the current first slave clock, and node A sends the first time synchronization message (such as Sync message and Follow_Up message) to its downstream node B (since node A is both the master clock and the upstream node of the current first slave clock B, the Sync and Follow_Up messages sent by node A are both the first time synchronization message and the third time synchronization message).

[0085] First, the downstream node B obtains the specific value of the first field carried in the Follow_Up message sent by node A (that is, the original timestamp of the first time synchronization message sent by the master clock, marked as the first field_A), and uses the original timestamp as the specific value of the first field in the fourth time synchronization message generated by node B (marked as the first field_B). It can be understood that the first field_A is equal to the first field_B.

[0086] Secondly, the downstream node B obtains the specific value of the second field carried in the Follow_Up message sent by node A (i.e., the second clock frequency ratio, marked as the second field_A), and determines the third clock frequency ratio based on the product of the second field_A (i.e., the second clock frequency ratio) and the first clock frequency ratio pre-stored by the downstream node B, and uses the third clock frequency ratio as the specific value of the second field in the fourth time synchronization message generated by node B (marked as the second field_B).

[0087] Finally, when node B sends a Sync message to its downstream node C, the timestamp t of sending the Sync message is recorded. s,BThe sending timestamp of node B based on the master clock should be the sum of the original timestamp of Sync sent by the master clock, the second path delay based on the master clock, and the second residence delay based on the master clock. The difference between the sending timestamp of node B based on the master clock and the original timestamp of the first time synchronization message sent by the master clock (i.e., the transmission delay) is used as the specific value of the third field in the fourth time synchronization message generated by node B (marked as the third field_B). Node B adds the first field_B, the second field_B, and the third field_B to the Follow_Up message sent by node B to its downstream node C. In addition, the Follow_Up message sent by node B to its downstream node C also carries the timestamp t when node B sends the Sync message. s,B , forming a fourth time synchronization message.

[0088] After receiving the fourth time synchronization message (Sync and Follow_Up messages) sent by node B, the downstream node C records the timestamp t of receiving the Sync message. r,C Similarly, the clock frequency ratio between the master clock frequency and the node C can be obtained according to the second field _B in the Follow_Up sent by node B, and the previously stored transmission delay (i.e., the sum of the path delay and the residence delay) is converted into the transmission delay based on the master clock. Then, according to the first field _B in the Follow_Up sent by node B and the transmission delay of node C based on the master clock, the receiving timestamp of the Sync message based on the master clock of the downstream node C is obtained, and the time synchronization of node C and the master clock is completed.

[0089] Through this embodiment, the original timestamp of the first time synchronization message sent by the master clock is introduced into the third time synchronization message, and the fourth time synchronization message sent to the downstream node of the current first slave clock is generated through the current first slave clock according to the third clock frequency ratio, transmission delay and original timestamp, so that the fourth time synchronization message also carries the original timestamp of the first time synchronization message sent by the master clock and the transmission delay relative to the master clock, so that the downstream node of the current first slave clock can calibrate its own time more quickly based on the information carried in the fourth time synchronization message, thereby directly shortening the startup time of the vehicle-mounted sensitive system.

[0090] In an exemplary embodiment, before the current first slave clock performs a synchronization operation, the vehicle network time synchronization method further includes:

[0091] 1. Sending a first delay measurement request to an upstream node of the current first slave clock through the current first slave clock; the first delay measurement request includes a first timestamp of sending the first delay measurement request.

[0092] The first delay measurement request refers to a request message sent by the current first slave clock to its upstream node for measuring network transmission delay. The first delay measurement request usually includes timestamp information of sending the request.

[0093] The first timestamp refers to the specific time when the current first slave clock sends the first delay measurement request, wherein the first timestamp is aligned with the current first slave clock.

[0094] Optionally, the vehicle terminal generates a first delay measurement request through the current first slave clock, and the first delay measurement request carries a first timestamp when the current first slave clock sends the first delay measurement request. The current first slave clock transmits the first delay measurement request to an upstream node of the current first slave clock.

[0095] 2. Receive, through the current first slave clock, a first response message of the upstream node of the current first slave clock to the first delay measurement request; the first response message includes a second timestamp of the upstream node of the current first slave clock receiving the first delay measurement request, and a third timestamp of sending the first response message.

[0096] The second timestamp refers to the time recorded when the upstream node of the current first slave clock receives the first delay measurement request.

[0097] The third timestamp refers to the time recorded when the upstream node of the current first slave clock sends the first response message.

[0098] The first response message refers to the message that the upstream node of the current first slave clock replies to the current first slave clock after receiving the first delay measurement request. The first response message carries the timestamp (second timestamp) when the upstream node of the current first slave clock receives the first delay measurement request and the timestamp (third timestamp) when the first response message is sent.

[0099] Optionally, after the vehicle terminal generates a first delay measurement request to the upstream node of the current first slave clock through the current first slave clock, the current first slave clock enters a listening state. After the upstream node of the current first slave clock receives the first delay measurement request, the second timestamp of receiving the first delay measurement request is recorded, and the second timestamp and the third timestamp of sending the first response message are written into the first response message, and the first response message is sent to the current first slave clock at the same time.

[0100] 3. Record the fourth timestamp of receiving the first response message through the current first slave clock, determine the first path delay according to the first timestamp, the second timestamp, the third timestamp and the fourth timestamp, and store the first path delay in the current first slave clock.

[0101] The fourth timestamp refers to the time when the current first slave clock receives the first response message.

[0102] Optionally, the vehicle terminal records the fourth timestamp of receiving the first response message through the current first slave clock, calculates the first path delay according to the following formula, and stores the calculated first path delay in the local storage of the current first slave clock:

[0103] Pdelay=(t4-t3+t2-t1) / 2;

[0104] Among them, t1 represents the first timestamp, t2 represents the second timestamp, t3 represents the third timestamp, and t4 represents the fourth timestamp.

[0105] For example, Figure 6 FIG. 1 is a flow chart of measuring a first path delay and a first clock frequency ratio in one embodiment. Figure 6 As shown, the current first slave clock B sends a first delay measurement request (such as a Pdelay_Req event message) to the upstream node A, and records the first timestamp t1 when the first delay measurement request leaves. The upstream node A receives the Pdelay_Req message and records the second timestamp t2 of receiving the Pdelay_Req message. The upstream node A packages the second timestamp t2 into the event message Pdelay_Resp, sends it to node B, and generates a third timestamp t3 when the Pdelay_Resp message leaves. The upstream node A sends a normal message Pdelay_Resp_Follow_Up with timestamp t3 to the current first slave clock B. The current first slave clock B records the fourth timestamp t4 of receiving the Pdelay_Resp message sent by node A. The current first slave clock calculates the first path delay according to the formula: Pdelay = (t4-t3+t2-t1) / 2.

[0106] It should be noted that: general path delay measurement does not limit the master and slave ports, and both the master port (MasterPort) and the slave port (SlavePort) can initiate delay measurement. Figure 6 As shown, in this embodiment, the first delay measurement request is initiated from the port, that is, the current first slave clock B sends the first delay measurement request through its own SlavePort port, and the current first slave clock B receives the first delay measurement request to the upstream node A through its own MasterPort.

[0107] Through this embodiment, before network transmission, the first path delay between the current first slave clock and the upstream node of the current first slave clock is measured, and after the current first slave clock calculates the first path delay, the first path delay is powered off and saved, so that the first path delay is stored in the local storage of the current first slave clock. After the vehicle network is powered on, the current first slave clock uses the saved first path delay as the initial value to participate in the time synchronization process, which is convenient for accelerating the time synchronization speed, thereby shortening the startup time of the vehicle sensitive network.

[0108] In an exemplary embodiment, after determining the first path delay, the vehicle network time synchronization method further includes:

[0109] 1. Sending a second delay measurement request to an upstream node of the current first slave clock through the current first slave clock.

[0110] The second delay measurement request refers to a request message sent by the current first slave clock to its upstream node for measuring the frequency ratio of the first clock. The second delay measurement request usually includes timestamp information for sending the request. Unlike the first delay measurement request, the sending timestamp of the second delay measurement request is different from the sending timestamp of the first delay measurement request (i.e., the first timestamp).

[0111] It should be noted that: general path delay measurement does not limit the master and slave ports, and both the master port (MasterPort) and the slave port (SlavePort) can initiate delay measurement. Figure 6 As shown, in this embodiment, the second delay measurement request is initiated from the port, that is, the current first slave clock B sends the second delay measurement request through its own SlavePort port, and the current first slave clock B receives the second delay measurement request to the upstream node A through its own MasterPort.

[0112] 2. Receive, through the current first slave clock, a second response message of the upstream node of the current first slave clock to the second delay measurement request; the second response message includes a fifth timestamp when the upstream node of the current first slave clock sends the second response message.

[0113] The fifth timestamp refers to the time recorded when the upstream node of the current first slave clock sends the second response message.

[0114] The second response message refers to the message that the upstream node of the current first slave clock replies to the current first slave clock after receiving the second delay measurement request. The second response message carries the timestamp of when the upstream node of the current first slave clock receives the second delay measurement request and the timestamp of when the second response message is sent (i.e., the fifth timestamp).

[0115] Optionally, after the vehicle terminal generates a second delay measurement request to the upstream node of the current first slave clock through the current first slave clock, the current first slave clock enters a listening state. After the upstream node of the current first slave clock receives the second delay measurement request, the timestamp of receiving the second delay measurement request is recorded, and the timestamp of receiving the second delay measurement request and the fifth timestamp of sending the second response message are written into the second response message, and the second response message is sent to the current first slave clock at the same time.

[0116] 3. Record the sixth timestamp of receiving the second response message through the current first slave clock, determine the first difference between the fifth timestamp and the third timestamp, and the second difference between the sixth timestamp and the fourth timestamp, determine the ratio between the first difference and the second difference as the first clock frequency ratio, and store the first clock frequency ratio in the current first slave clock.

[0117] The sixth timestamp refers to the time when the current first slave clock receives the second response message.

[0118] Optionally, the vehicle-mounted terminal records the sixth timestamp of receiving the second response message through the current first slave clock, and determines the first difference between the fifth timestamp of the second response message sent by the upstream node of the current first slave clock and the third timestamp of the first response message sent by the upstream node of the current first slave clock, and determines the second difference between the sixth timestamp of the second response message received by the current first slave clock and the fourth timestamp of the first response message received by the current first slave clock, determines the ratio between the first difference and the second difference as the first clock frequency ratio, and stores the first clock frequency ratio in the local storage of the current first slave clock.

[0119] For example, Figure 6 As shown, the current first slave clock B sends a second delay measurement request (such as a Pdelay_Req event message) to the upstream node A, and records the timestamp t5 when the second delay measurement request leaves. The upstream node A receives the Pdelay_Req message and records the timestamp t6 of receiving the Pdelay_Req message. The upstream node A packs the timestamp t6 into the event message Pdelay_Resp, sends it to the node B, and generates the fifth timestamp t7 when the Pdelay_Resp message leaves. The upstream node A sends the ordinary message Pdelay_Resp_Follow_Up with the fifth timestamp t7 to the current first slave clock B. The current first slave clock B records the sixth timestamp t8 of the Pdelay_Resp message sent by the node A. The first difference between the fifth timestamp t7 and the first timestamp t1, and the second difference between the sixth timestamp t8 and the fourth timestamp t4 are calculated. According to the ratio between the first difference and the second difference, the first clock frequency ratio is determined.

[0120] Through this embodiment, before network transmission, after measuring the first path delay, a path delay measurement process is performed again, that is, through two path delay measurement processes, the first clock frequency ratio between the upstream node of the current first slave clock and the current first slave clock can be obtained, and after the current first slave clock calculates the first clock frequency ratio, the first clock frequency ratio is powered off and saved, so that the first clock frequency ratio is stored in the local storage of the current first slave clock. After the vehicle network is powered on, the current first slave clock uses the saved first clock frequency ratio as the initial value to participate in the time synchronization process, which is convenient for accelerating the time synchronization speed, thereby shortening the startup time of the vehicle sensitive network.

[0121] In an exemplary embodiment, after determining that the master clock is abnormal, the vehicle network time synchronization method further includes:

[0122] The last first time synchronization message sent by the master clock before the abnormality occurs is transmitted to each first slave clock through the downstream node of the master clock, so that each first slave clock is synchronized with the master clock before the abnormality occurs.

[0123] Among them, before the master clock is abnormal, the first time synchronization message sent by the master clock will be passed to its downstream node, and the first slave clock node below the master clock will perform time synchronization based on the last first time synchronization message sent before the abnormality. After switching to the new master clock, after the second slave clock receives the second time synchronization message sent by the new master clock node, other second slave clocks stop sending the third time synchronization message themselves, and instead use the new master clock node for time synchronization.

[0124] For example, the master clock is node A, the downstream node of node A is node B, and the downstream node of node B is node C. Before the master clock A is abnormal, the master clock A sends the last first time synchronization message to its downstream node B. The downstream node B will generate a third time synchronization message based on the last first time synchronization message, and continue to send the third time synchronization message to its downstream node C. Node C generates a fourth time synchronization message based on the received third time synchronization message, and sends the fourth time synchronization message as a new third time synchronization message to its downstream node D. The downstream node D generates a new fourth time synchronization message based on the new third time synchronization message, and sends the new fourth time synchronization message to its downstream nodes, and the cycle continues until the last first slave clock is synchronized with the master clock. After the master clock A becomes abnormal, it switches to a new master clock (for example, node B). The new master clock generates a second time synchronization message and sends the second time synchronization message to the downstream node C of the new master clock. The downstream node C generates a third time synchronization message based on the new second time synchronization message and sends the third time synchronization message to its downstream node D. This cycle continues until the last second slave clock is synchronized with the new master clock.

[0125] Optionally, the on-board terminal monitors the operating status of the master clock in real time. When an abnormality of the master clock (such as failure, shutdown, etc.) is detected, the last first time synchronization message sent before the abnormality of the master clock is transmitted to its downstream node through the downstream node of the master clock. The downstream node generates a third time synchronization message based on the last first time synchronization message, and sends the third time synchronization message to its downstream node, and the cycle is repeated in sequence until each first slave clock can be synchronized with the time of the master clock before the abnormality.

[0126] Through this embodiment, in the event of a master clock abnormality, the last first time synchronization message before the master clock abnormality is quickly transmitted through the downstream nodes, thereby ensuring that each first slave clock can quickly maintain time synchronization with the master clock (in the state before the abnormality), and ensuring that the on-board sensitive system can immediately obtain accurate time information when starting up, thereby shortening the overall startup time of the system.

[0127] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.

[0128] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware server, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM (Read-Only Memory) / RAM (Random Access Memory), a disk, or an optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods of each embodiment of the present application.

[0129] According to another aspect of the embodiments of the present application, a vehicle network time synchronization device is also provided, which is used to implement the vehicle network time synchronization method provided in the above embodiments, and will not be repeated hereafter. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.

[0130] Figure 7 is a structural block diagram of an optional vehicle network time synchronization device according to an embodiment of the present application, such as Figure 7 As shown, the device may include:

[0131] The master clock synchronization module 701 is used to perform synchronization processing on each first slave clock according to the first time synchronization message periodically sent by the master clock, so as to synchronize the time between each first slave clock and the master clock; the master clock is a pre-specified clock node in the time domain; each first slave clock is each clock node in the time domain except the master clock;

[0132] The master clock monitoring module 702 is used to send a detection message to the master clock through a backup clock when the first time synchronization message sent by the master clock is not received within a preset period of time; the backup clock is a pre-specified clock node among multiple first slave clocks other than the master clock in the time domain;

[0133] The backup clock synchronization module 703 is used to determine that the master clock is abnormal when the backup clock does not receive a reply message from the master clock to the detection message within a preset time range, determine the backup clock as the new master clock, and synchronize each second slave clock according to the second time synchronization message periodically sent by the new master clock to synchronize the time between each second slave clock and the new master clock; each second slave clock is each clock node in the time domain except the new master clock.

[0134] In an exemplary embodiment, the master clock synchronization module 701 is also used to use each first slave clock as the current first slave clock and perform the following synchronization operations to synchronize the time between each first slave clock and the master clock: the master clock periodically sends a first time synchronization message, and receives a third time synchronization message sent by the upstream node of the current first slave clock through the current first slave clock; the upstream node of the current first slave clock refers to a clock node that is directly connected to the current first slave clock and is upstream of the current first slave clock; the third time synchronization message is generated by the upstream node of the current first slave clock according to the first time synchronization message; through the current first slave clock, according to the third time synchronization message, the pre-stored first path delay, the pre-stored first residence delay, and the pre-stored first clock frequency ratio, the current first slave clock is time synchronized to obtain the current first slave clock relative to the master clock. Transmission delay; the first path delay refers to the total delay time experienced when the third time synchronization message is transmitted between the upstream node of the current first slave clock and the current first slave clock; the first path delay is aligned with the current first slave clock; the first residence delay refers to the time that the third time synchronization message stays on the current first slave clock; the first residence delay is aligned with the current first slave clock; the first clock frequency ratio refers to the clock frequency ratio between the upstream node of the current first slave clock and the current first slave clock; the transmission delay is aligned with the master clock; through the current first slave clock, according to the transmission delay, a fourth time synchronization message is generated, and the fourth time synchronization message is sent to the downstream node of the current first slave clock, so that the downstream node of the current first slave clock is synchronized with the master clock according to the fourth time synchronization message; the downstream node of the current first slave clock refers to a clock node that is directly connected to the current first slave clock and is downstream of the current first slave clock.

[0135] In an exemplary embodiment, the third time synchronization message includes a second clock frequency ratio; the second clock frequency ratio refers to the clock frequency ratio between the master clock and the upstream node of the current first slave clock; the master clock synchronization module 701 is also used to determine the third clock frequency ratio through the current first slave clock according to the first clock frequency ratio and the second clock frequency ratio; the third clock frequency ratio refers to the clock frequency ratio between the master clock and the current first slave clock; through the current first slave clock, according to the third clock frequency ratio, the pre-stored first path delay is clock-converted to obtain the second path delay; the second path delay is aligned with the master clock; through the current first slave clock, according to the third clock frequency ratio, the pre-stored first residence delay is clock-converted to obtain the second residence delay; the second residence delay is aligned with the master clock; through the current first slave clock, the sum of the second path delay and the second residence delay is determined as the transmission delay of the current first slave clock relative to the master clock.

[0136] In an exemplary embodiment, the third time synchronization message also includes the original timestamp of the first time synchronization message sent by the master clock; the original timestamp is aligned with the master clock; the master clock synchronization module 701 is also used to generate a fourth time synchronization message through the current first slave clock according to the third clock frequency ratio, transmission delay and original timestamp.

[0137] In an exemplary embodiment, the master clock synchronization module 701 is also used to send a first delay measurement request to the upstream node of the current first slave clock through the current first slave clock; the first delay measurement request includes a first timestamp for sending the first delay measurement request; a first response message to the first delay measurement request from the upstream node of the current first slave clock is received through the current first slave clock; the first response message includes a second timestamp for the upstream node of the current first slave clock to receive the first delay measurement request, and a third timestamp for sending the first response message; a fourth timestamp for receiving the first response message is recorded through the current first slave clock, and a first path delay is determined based on the first timestamp, the second timestamp, the third timestamp and the fourth timestamp, and the first path delay is stored in the current first slave clock.

[0138] In an exemplary embodiment, the master clock synchronization module 701 is also used to send a second delay measurement request to the upstream node of the current first slave clock through the current first slave clock; receive a second response message from the upstream node of the current first slave clock to the second delay measurement request through the current first slave clock; the second response message includes a fifth timestamp when the upstream node of the current first slave clock sends the second response message; record the sixth timestamp of receiving the second response message through the current first slave clock, determine a first difference between the fifth timestamp and the third timestamp, and a second difference between the sixth timestamp and the fourth timestamp, determine the ratio between the first difference and the second difference as a first clock frequency ratio, and store the first clock frequency ratio in the current first slave clock.

[0139] In an exemplary embodiment, the backup clock synchronization module 703 is also used to transmit the last first time synchronization message sent by the master clock before the abnormality to each first slave clock through the downstream node of the master clock, so as to synchronize the time between each first slave clock and the master clock before the abnormality.

[0140] It should be noted that the examples and application scenarios implemented by the above modules and corresponding steps are the same, but are not limited to the contents disclosed in the above embodiments. It should be noted that the above modules as part of the device can be run in Figure 1 In the hardware environment shown, it can be implemented by software or by hardware, wherein the hardware environment includes a network environment.

[0141] According to another aspect of the embodiments of the present application, a storage medium is further provided. Optionally, in this embodiment, the storage medium can be used to execute the program code of any of the above-mentioned vehicle network time synchronization methods in the embodiments of the present application.

[0142] Optionally, in this embodiment, the storage medium may be located on at least one network device among a plurality of network devices in the network shown in the above embodiment.

[0143] Optionally, in this embodiment, the storage medium is configured to store a program code for executing any of the above-mentioned vehicle network time synchronization methods.

[0144] Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments, which will not be described in detail in this embodiment.

[0145] Optionally, in this embodiment, the storage medium may include, but is not limited to, various media that can store program codes, such as a USB flash drive, a ROM, a RAM, a mobile hard disk, a magnetic disk, or an optical disk.

[0146] According to another aspect of the embodiments of the present application, a computer program product or a computer program is also provided. Optionally, in this embodiment, the computer program product or the computer program includes a computer instruction, and the processor of the computer device reads the computer instruction from the computer readable storage medium, and the processor executes the computer instruction, so that the computer device performs the steps in any of the above method embodiments.

[0147] Optionally, in this embodiment, the computer program product or computer program may be located on at least one network device among a plurality of network devices in the network shown in the above embodiment.

[0148] Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments, which will not be described in detail in this embodiment.

[0149] According to another aspect of an embodiment of the present application, an electronic device for implementing the above-mentioned vehicle network time synchronization method is also provided. The electronic device may be a smart device, a server, a terminal, or a combination thereof.

[0150] Figure 8 is a structural block diagram of an optional electronic device according to an embodiment of the present application, such as Figure 8 As shown, it includes a processor 802, a communication interface 804, a memory 806 and a communication bus 808, wherein the processor 802, the communication interface 804 and the memory 806 communicate with each other through the communication bus 808, wherein,

[0151] Memory 806, used for storing computer programs;

[0152] The processor 802 is used to implement the program code of any of the above-mentioned vehicle network time synchronization methods when executing the computer program stored in the memory 806.

[0153] Optionally, the communication bus may be a PCI (Peripheral Component Interconnect) bus, or an EISA (Extended Industry Standard Architecture) bus, etc. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 8 The communication interface is used for communication between the above electronic device and other devices.

[0154] The memory may include RAM, or may include non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.

[0155] As an example, the memory 806 may include but is not limited to each module in the vehicle network time synchronization device. In addition, it may also include but is not limited to other module units in the vehicle network time synchronization device, which will not be repeated in this example.

[0156] The above-mentioned processor can be a general-purpose processor, which can include but not be limited to: CPU (Central Processing Unit), NP (Network Processor), etc.; it can also be DSP (Digital Signal Processing), ASIC (Application Specific Integrated Circuit), FPGA (Field-Programmable Gate Array) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0157] Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments, and this embodiment will not be described in detail here.

[0158] It can be understood by those skilled in the art that Figure 8 The structure shown is for illustration only. The device for implementing the above-mentioned vehicle network time synchronization method may be a terminal device, which may be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a PDA, a mobile Internet device (Mobile Internet Devices, MID), a PAD, and other terminal devices. Figure 8 The structure of the electronic device is not limited. Figure 8 More or fewer components (such as network interfaces, display devices, etc.) shown in, or having Figure 8 Different configurations shown.

[0159] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps in any of the above method embodiments are implemented.

[0160] An embodiment of the present application further provides another computer program product, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in any of the above method embodiments are implemented.

[0161] The embodiments of the present application also provide a computer program, which includes computer instructions, which are stored in a computer-readable storage medium; a processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the steps in any one of the above method embodiments.

[0162] A person of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the hardware related to the terminal device through a program, and the program can be stored in a computer-readable storage medium, which can include: a flash drive, ROM, RAM, a magnetic disk or an optical disk, etc.

[0163] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.

[0164] If the integrated units in the above embodiments are implemented in the form of software functional units and sold or used as independent products, they can be stored in the above computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling one or more computer devices (which may be personal computers, servers, or network devices, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application.

[0165] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.

[0166] In the several embodiments provided in the present application, it should be understood that the disclosed client can be implemented in other ways. Among them, 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. For example, 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 units or modules, which can be electrical or other forms.

[0167] 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 provided in this embodiment.

[0168] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, each unit may exist physically separately, or at least two units may be integrated into one unit. The above integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0169] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.

Claims

1. A vehicle network time synchronization method, characterized in that: include: According to the first time synchronization message periodically sent by the master clock, each first slave clock is synchronized to achieve time synchronization between each first slave clock and the master clock; The master clock is a pre-specified clock node in the time domain; each of the first slave clocks is each clock node in the time domain except the master clock; When the first time synchronization message sent by the master clock is not received within a preset period of time, sending a detection message to the master clock through the backup clock; The backup clock is a pre-specified clock node among a plurality of first slave clocks other than the master clock in the time domain; In the case that the standby clock does not receive a reply message from the master clock to the detection message within a preset time range, it is determined that the master clock is abnormal, the standby clock is determined as a new master clock, and each second slave clock is synchronized according to the second time synchronization message periodically sent by the new master clock, so that each second slave clock is synchronized with the new master clock; Each of the second slave clocks is each clock node in the time domain except the new master clock.

2. The method according to claim 1, characterized in that: The step of performing synchronization processing on each first slave clock according to the first time synchronization message periodically sent by the master clock so as to synchronize the time between each first slave clock and the master clock includes: Taking each of the first slave clocks as the current first slave clock, performing the following synchronization operation to synchronize the time between each of the first slave clocks and the master clock: The first time synchronization message is periodically sent through the master clock, and the third time synchronization message sent by the upstream node of the current first slave clock is received through the current first slave clock; the upstream node of the current first slave clock refers to a clock node that is directly connected to the current first slave clock and is upstream of the current first slave clock; the third time synchronization message is generated by the upstream node of the current first slave clock according to the first time synchronization message; Through the current first slave clock, time synchronization processing is performed on the current first slave clock according to the third time synchronization message, the pre-stored first path delay, the pre-stored first residence delay, and the pre-stored first clock frequency ratio, to obtain the transmission delay of the current first slave clock relative to the master clock; the first path delay refers to the total delay time experienced when the third time synchronization message is transmitted between the upstream node of the current first slave clock and the current first slave clock; the first path delay is aligned with the current first slave clock; the first residence delay refers to the time when the third time synchronization message stays on the current first slave clock; the first residence delay is aligned with the current first slave clock; the first clock frequency ratio refers to the clock frequency ratio between the upstream node of the current first slave clock and the current first slave clock; the transmission delay is aligned with the master clock; A fourth time synchronization message is generated through the current first slave clock according to the transmission delay, and the fourth time synchronization message is sent to the downstream node of the current first slave clock, so that the downstream node of the current first slave clock is synchronized with the master clock according to the fourth time synchronization message; the downstream node of the current first slave clock refers to a clock node that is directly connected to the current first slave clock and is downstream of the current first slave clock.

3. The method according to claim 2, characterized in that The third time synchronization message includes a second clock frequency ratio; the second clock frequency ratio refers to a clock frequency ratio between the master clock and an upstream node of the current first slave clock; The step of performing time synchronization processing on the current first slave clock according to the third time synchronization message, the pre-stored first path delay, the pre-stored first residence delay, and the pre-stored first clock frequency ratio through the current first slave clock to obtain the transmission delay of the current first slave clock relative to the master clock includes: Determine a third clock frequency ratio by using the current first slave clock and according to the first clock frequency ratio and the second clock frequency ratio; the third clock frequency ratio refers to the clock frequency ratio between the master clock and the current first slave clock; By using the current first slave clock, according to the third clock frequency ratio, clock conversion is performed on the pre-stored first path delay to obtain a second path delay; the second path delay is aligned with the master clock; By using the current first slave clock and according to the third clock frequency ratio, clock conversion is performed on the pre-stored first residence delay to obtain a second residence delay; the second residence delay is aligned with the master clock; The sum of the second path delay and the second residence delay is determined as the transmission delay of the current first slave clock relative to the master clock through the current first slave clock.

4. The method according to claim 3, characterized in that The third time synchronization message also includes an original timestamp when the master clock sends the first time synchronization message; the original timestamp is aligned with the master clock; The generating a fourth time synchronization message according to the transmission delay by using the current first slave clock includes: A fourth time synchronization message is generated by the current first slave clock according to the third clock frequency ratio, the transmission delay and the original timestamp.

5. The method according to any one of claims 2 to 4, characterized in that Before the current first slave clock performs a synchronization operation, the method further includes: Sending a first delay measurement request to an upstream node of the current first slave clock through the current first slave clock; the first delay measurement request includes a first timestamp for sending the first delay measurement request; Receiving, by means of the current first slave clock, a first response message of an upstream node of the current first slave clock to the first delay measurement request; the first response message includes a second timestamp of when the upstream node of the current first slave clock receives the first delay measurement request, and a third timestamp of when the first response message is sent; The fourth timestamp of receiving the first response message is recorded through the current first slave clock, and the first path delay is determined according to the first timestamp, the second timestamp, the third timestamp and the fourth timestamp, and the first path delay is stored in the current first slave clock.

6. The method according to claim 5, characterized in that After determining the first path delay, the method further includes: Sending a second delay measurement request to an upstream node of the current first slave clock through the current first slave clock; Receiving, by means of the current first slave clock, a second response message of an upstream node of the current first slave clock to the second delay measurement request; the second response message includes a fifth timestamp at which the upstream node of the current first slave clock sends the second response message; The sixth timestamp of receiving the second response message is recorded through the current first slave clock, a first difference between the fifth timestamp and the third timestamp, and a second difference between the sixth timestamp and the fourth timestamp are determined, a ratio between the first difference and the second difference is determined as the first clock frequency ratio, and the first clock frequency ratio is stored in the current first slave clock.

7. The method according to claim 1, characterized in that After determining that the master clock is abnormal, the method further includes: The last first time synchronization message sent by the master clock before the abnormality occurs is transmitted to each first slave clock through the downstream node of the master clock, so that each first slave clock is synchronized with the master clock before the abnormality occurs.

8. A vehicle network time synchronization device, characterized in that: include: A master clock synchronization module, used for performing synchronization processing on each first slave clock according to a first time synchronization message periodically sent by the master clock, so as to synchronize the time between each first slave clock and the master clock; The master clock is a pre-specified clock node in the time domain; each of the first slave clocks is each clock node in the time domain except the master clock; A master clock monitoring module, configured to send a detection message to the master clock through a backup clock if the first time synchronization message sent by the master clock is not received within a preset period of time; the backup clock is a pre-specified clock node among a plurality of first slave clocks other than the master clock in the time domain; A standby clock synchronization module is used to determine that the master clock is abnormal when the standby clock does not receive a reply message from the master clock to the detection message within a preset time range, determine the standby clock as a new master clock, and synchronize each second slave clock according to a second time synchronization message periodically sent by the new master clock, so that each second slave clock is synchronized with the new master clock; Each of the second slave clocks is each clock node in the time domain except the new master clock.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program implements the steps of any one of the methods of claims 1 to 7 when executed by a processor.

10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Cited By

  • Vehicle-mounted gPTP clock redundancy system and method

    CN120639235A