Vehicle-mounted network time synchronization method and system
By using the combination of master clock, slave clock, transparent clock and boundary clock module in the vehicle network system, the clock deviation is calculated and adjusted, and the problems of clock synchronization complexity and limited resources in the prior art are solved, achieving high precision and consistency The system debugging and troubleshooting capabilities are improved.
Patent Information
- Application Number
- CN202411756731.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-03
- Publication Date
- 2024-12-31
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
After the existing in-vehicle network systems introduce the clock synchronization mechanism, the system becomes complex and requires additional configuration and maintenance. Embedded systems with limited resources may be affected by the unavailability of external clock resources, affecting the accuracy of timestamps.
Synchronous messages are broadcast periodically to the network, recording the reception and transmission timestamps, calculating network transmission delay and clock deviation from the slave clock, and adjusting its own time to achieve high-precision time synchronization. The system includes a master clock module, a slave clock module, a transparent clock module and a boundary clock module. The transparent clock module is used to compensate for message transmission delay and the boundary clock module reduces time error accumulation.
It realizes time synchronization with high accuracy, consistency and reliability, ensuring time consistency between multiple devices, and facilitates system debugging and troubleshooting.
Smart Images

Figure CN119232307A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communications, and in particular to a vehicle-mounted network time synchronization method and system. Background Art
[0002] In vehicle network systems (such as CAN bus), the accuracy of timestamps is very important for diagnosis, debugging and data analysis. The following are some current developments in this technology area: Modern CAN bus controllers and related hardware devices increasingly support high-precision timestamping, usually in microseconds (µs). This high-precision timestamping allows for more precise sequence of events, especially in high-speed communications and high-frequency data transfer.
[0003] In order to ensure time synchronization between multiple devices, a variety of clock synchronization protocols have been developed in the technical field, such as IEEE1588 Precision Time Protocol (PTP). This synchronization mechanism allows all nodes in the network to share a high-precision global time.
[0004] Many modern CAN controllers integrate hardware timestamping capabilities, which record timestamps immediately when data frames arrive to avoid delays and errors caused by software processing. This approach greatly improves the accuracy of timestamping.
[0005] With the advancement of technology, the resolution of timestamps is getting higher and higher. At present, some high-end CAN devices can already provide nanosecond-level timestamp resolution to meet application scenarios with extremely high requirements for time accuracy.
[0006] In some distributed systems, timestamps record not only the time of a single node, but also the time of different nodes in the network. This method can more comprehensively reflect the time dynamics of the entire system.
[0007] However, after the introduction of clock synchronization mechanism, the system becomes more complex and requires additional configuration and maintenance. The reliance on the synchronization mechanism increases, and if there is a problem with the synchronization mechanism, the timestamp accuracy of the entire system may be affected. The clock synchronization mechanism requires additional computing and network resources, which may increase the burden on the system, especially in embedded systems with limited resources. The clock synchronization mechanism usually relies on the network and external clock sources. If these external resources are unavailable or unreliable, the time synchronization of the system may be affected. Summary of the invention
[0008] The purpose of the present invention is to overcome the deficiencies of the prior art and provide a vehicle network time synchronization method, comprising the following steps: Step 1: The master clock periodically broadcasts synchronization messages to all slave clocks in the network. The synchronization messages contain the current timestamp. Step 2: The slave clock receives a synchronization message and records the receiving time T1; the slave clock sends a delay request message to the master clock and records the sending time T2; Step 3: After receiving the delay request, the master clock sends a delay response message and records the delay request message receiving time T3; the delay response message includes the timestamp T4 when the master clock receives the delay request message; Step 4: The slave clock obtains the network transmission delay and the clock deviation Offset between the slave clock and the master clock according to the time T1, T2, T3, and T4, and the slave clock adjusts the time according to the clock deviation.
[0009] Further, the slave clock receives a synchronization message and records the receiving time T1; the slave clock sends a delay request message to the master clock and records the sending time T2, including: The master clock periodically sends synchronization messages that contain the current timestamp. All slave clock nodes in the network listen to and receive synchronization messages. When the slave clock receives a synchronization message, it records the receiving time T1. If there is a transparent clock in the network, the received timestamp will be corrected to compensate for the transmission delay. The slave clock sends a delay request message to the master clock and records the time T2 when the delay request message is sent.
[0010] Furthermore, if a transparent clock exists in the network, the received timestamp will be corrected to compensate for the transmission delay, including: When a Sync or Delay Request message enters a network device, the device records the timestamp T in After the network device processes the message, it records the timestamp T out , get the internal delay of the device , the network device accumulates the internal delay ΔT into the correction field of the message; if it is a one-step transparent clock, the correction field of the Sync message is directly updated; if it is a two-step transparent clock, the compensation information is sent through the Follow_Up message; if the message passes through multiple transparent clock devices, each device will accumulate its own delay to the correction field; when the message is received from the clock, the correction field contains the accumulated delay of all devices.
[0011] Furthermore, the slave clock obtains the network transmission delay and the clock deviation Offset between the slave clock and the master clock according to the time T1, T2, T3, and T4, and the slave clock adjusts the time according to the clock deviation, including: S1, when the slave clock receives the Sync message, it records the receiving time T2 and waits to obtain the T1 timestamp from the master clock; if there is a transparent clock in the network, the master clock will also send a Follow_Up message carrying the sending time T1; S2, calculate the preliminary offset from the clock PreliminartOffset = T2-T1; S3, the slave clock actively sends a DelayRequest message and records the sending time T3; S4, after receiving the request, the master clock records the receiving time T4 and returns it to the slave clock through the Delay Response message; S5, the slave clock calculates the network delay based on the received timestamp: ; S6, get the actual clock deviation from the clock: ; S7, according to the actual clock offset Offset, adjust the time of the slave clock to: AdjustedTime = CurrentTime + Offset. If the clock offset is a positive number, it means that the slave clock is slower than the master clock and the time needs to be adjusted forward; if it is a negative number, it is adjusted backward.
[0012] An in-vehicle network time synchronization system, applying the in-vehicle network time synchronization method, comprises a master clock module, a slave clock module, a transparent clock module and a boundary clock module; The master clock module is used to provide a time reference; The slave clock module includes clocks of multiple nodes, and the clocks of the multiple nodes are synchronized through the master clock module; The transparent clock module is located in the network device and is used to compensate for message transmission delay; The boundary clock module is used to provide synchronization services at the network boundary, connect different network segments, and reduce the accumulation of time errors in the network layer.
[0013] The beneficial effects of the present invention are: High precision: by using a clock synchronization mechanism such as IEEE1588, the timestamp is ensured to be accurate to the nanosecond level.
[0014] Consistency: Timestamps are processed uniformly during message conversion to ensure uniformity and traceability of time within the system.
[0015] Reliability: The synchronous clock mechanism provides high-precision and high-reliability time synchronization, ensuring time consistency among multiple devices and systems.
[0016] Easy to debug: The time of each message is recorded with a high-precision timestamp, which makes it easy to sort and analyze messages, and helps with system debugging and troubleshooting. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1A flowchart of a vehicle network time synchronization method is shown; Figure 2 It is a schematic diagram of the principle of a vehicle network time synchronization system; Figure 3 Schematic diagram of the calculation process of network delay and clock deviation. DETAILED DESCRIPTION
[0018] The technical solution of the present invention is further described in detail below in conjunction with the accompanying drawings, but the protection scope of the present invention is not limited to the following.
[0019] The features and performance of the present invention are further described in detail below in conjunction with the embodiments.
[0020] like Figure 1 As shown, a vehicle network time synchronization method includes the following steps: Step 1: The master clock periodically broadcasts synchronization messages to all slave clocks in the network. The synchronization messages contain the current timestamp. Step 2: The slave clock receives a synchronization message and records the receiving time T1; the slave clock sends a delay request message to the master clock and records the sending time T2; Step 3: After receiving the delay request, the master clock sends a delay response message and records the delay request message receiving time T3; the delay response message includes the timestamp T4 when the master clock receives the delay request message; Step 4: The slave clock obtains the network transmission delay and the clock deviation Offset between the slave clock and the master clock according to the time T1, T2, T3, and T4, and the slave clock adjusts the time according to the clock deviation.
[0021] The slave clock receives a synchronization message and records the receiving time T1; the slave clock sends a delay request message to the master clock and records the sending time T2, including: The master clock periodically sends synchronization messages that contain the current timestamp. All slave clock nodes in the network listen to and receive synchronization messages. When the slave clock receives a synchronization message, it records the receiving time T1. If there is a transparent clock in the network, the received timestamp will be corrected to compensate for the transmission delay. The slave clock sends a delay request message to the master clock and records the time T2 when the delay request message is sent.
[0022] If a transparent clock exists in the network, the received timestamp will be corrected to compensate for the transmission delay, including: When a Sync or Delay Request message enters a network device, the device records the timestamp T in After the network device processes the message, it records the timestamp T out , get the internal delay of the device , the network device accumulates the internal delay ΔT into the correction field of the message; if it is a one-step transparent clock, the correction field of the current message is directly updated; if it is a two-step transparent clock, the compensation information is sent through the Follow_Up message; if the message passes through multiple transparent clock devices, each device will accumulate its own delay to the correction field; when the message is received from the clock, the correction field contains the accumulated delay of all devices.
[0023] In the network synchronization protocol, Sync and DelayRequest are two key message types used to synchronize the clocks of devices: 1. Sunc News a. Sent from the master clock to the slave clock.
[0024] b. Mainly used to transmit the current time of the master clock to the slave clock to achieve time synchronization c. When a Sync message enters a network device, the device records the timestamp of the message arrival (T in ), and then record the output timestamp (T out ).
[0025] d. The slave clock can use the timestamp of the Sync message to adjust its own clock to keep synchronization with the master clock 2. Delay Request message a. Sent from the slave clock to the master clock to measure the communication delay from the slave clock to the master clock.
[0026] b. When a Delay Request message enters a network device, the device records the entry timestamp (T in ), and record the output timestamp (T out ).
[0027] The slave clock obtains the network transmission delay and the clock deviation Offset between the slave clock and the master clock according to the time T1, T2, T3, and T4, and the slave clock adjusts the time according to the clock deviation, including: S1, when the slave clock receives the Sync message, it records the receiving time T2 and waits to obtain the T1 timestamp from the master clock; if there is a transparent clock in the network, the master clock will also send a Follow_Up message carrying the sending time T1; S2, calculate the preliminary offset from the clock PreliminartOffset = T2-T1; S3, the slave clock actively sends a DelayRequest message and records the sending time T3; S4, after receiving the request, the master clock records the receiving time T4 and returns it to the slave clock through the Delay Response message; S5, the slave clock calculates the network delay based on the received timestamp: ; S6, get the actual clock deviation from the clock: ; S7, according to the actual clock offset Offset, adjust the time of the slave clock to: AdjustedTime = CurrentTime + Offset. If the clock offset is a positive number, it means that the slave clock is slower than the master clock and the time needs to be adjusted forward; if it is a negative number, it is adjusted backward.
[0028] Among them, network delay is a key factor in ensuring the accuracy of clock synchronization between devices. Since there is a delay in message transmission over the network, if these delays are not taken into account, clock deviation will occur. The role of network delay is to provide correction information so that the slave clock can adjust its own time more accurately and achieve precise synchronization.
[0029] like Figure 2 A vehicle network time synchronization system is shown, which applies the vehicle network time synchronization method, and includes a master clock module, a slave clock module, a transparent clock module and a boundary clock module; The master clock module is used to provide a time reference; The slave clock module includes clocks of multiple nodes, and the clocks of the multiple nodes are synchronized through the master clock module; The transparent clock module is located in the network device and is used to compensate for message transmission delay; The boundary clock module is used to provide synchronization services at the network boundary, connect different network segments, and reduce the accumulation of time errors in the network layer.
[0030] Specifically, in the current technical solution, we use a clock synchronization mechanism (such as IEEE 1588) to ensure that all nodes in the system can synchronize time with high precision. This mechanism is applied in our code to process and record the timestamp of CAN bus messages to ensure the accuracy and consistency of data processing.
[0031] System Components Master Clock: Usually the most accurate clock device in the network, providing the time reference.
[0032] Slave Clock: A clock device located at each node that is synchronized with the master clock.
[0033] Transparent Clock: Located in network devices (such as switches) and used to compensate for message transmission delays.
[0034] 1. Message enters the device (switch / router) When a Sync or Delay Request message enters a network device, the device records the timestamp T in .
[0035] 2. The message is processed internally After the network device processes the message, it records the timestamp T out .
[0036] 3. Calculate the internal delay of the device 4. Update the Correction Field of the Message · The device accumulates the internal delay ΔT into the correction field of the message.
[0037] If it is a one-step transparent clock, directly update the correction field of the current message.
[0038] If it is a two-step transparent clock, the compensation information is sent via the Follow_Up message.
[0039] 5. Transparent clock processing multi-hop delay compensation If the message passes through multiple transparent clock devices, each device will add its own delay to the correction field.
[0040] Eventually, when the message is received from the clock, the correction field already contains the accumulated delays of all devices.
[0041] Boundary Clock: A device that provides synchronization services at the network boundary, connecting different network segments. In a complex network environment, the boundary clock plays a key role. Its main functions are: 1. Reduce the accumulation of time errors in the network layer: When time synchronization messages pass through multiple switches, routers and other network devices, the delay accumulation will reduce the synchronization accuracy. Boundary clocks can isolate different network segments to prevent errors from increasing as messages are transmitted.
[0042] 2. Improve synchronization stability: The boundary clock uses the master clock of a network segment as a reference, synchronizes itself, and then acts as a new master clock to provide time services to the downstream network. In this way, if a link fails, the boundary clock can continue to provide a stable synchronization signal to the downstream. 3. Support multiple master clock scenarios: In some applications (such as large industrial networks or wide area networks), multiple master clock sources may be required. The boundary clock can receive synchronization information from different master clocks at the same time and provide a time reference for the network segment it governs. 2.2 Time Synchronization Process 1. Master clock broadcasts synchronization message: The master clock periodically broadcasts synchronization message including the current timestamp to all slave clocks in the network.
[0043] 2. Record the receiving time from the clock: The slave clock receives the synchronization message and records the receiving time.
[0044] The slave clock sends a delay request: The slave clock sends a delay request message to the master clock and records the sending time.
[0045] Detailed explanation of the time synchronization process (based on PTP or NTP mechanism) The master clock broadcasts synchronization messages. The master clock periodically sends synchronization messages (Sync Message), which contain the current timestamp. All slave clock nodes in the network will listen to and receive the message. The slave clock records the reception time. When the slave clock receives the synchronization message, it immediately records the reception time (T1) for subsequent calculations. If there is a transparent clock in the network, the received timestamp will be corrected to compensate for the transmission delay. The slave clock sends a delay request. In order to accurately calculate the network delay, the slave clock actively sends a delay request message (DelayRequest) to the master clock and records the time when the request is sent (T2). The master clock responds to the delay request. After receiving the delay request, the master clock sends a delay response message (Delay Response) and records the message reception time (T3). The delay response message will contain the timestamp when the master clock receives the request (T4). Calculate the network delay and clock deviation. The slave clock calculates the network transmission delay and the clock deviation between itself and the master clock based on the four timestamps (T1, T2, T3, T4).
[0046] Calculation formula (simplified): According to the calculation results, the slave clock adjusts its own time to synchronize with the master clock. The master clock responds to the delay request: After receiving the delay request message, the master clock returns a delay response message and records the receiving time.
[0047] like Figure 3 As shown, the network delay and clock deviation are calculated: the slave clock calculates the network transmission delay and the clock deviation with the master clock through the timestamp of the above message, and makes adjustments.
[0048] Record four key timestamps, T1 (time when the master clock sends a synchronization message (Sync)), T2 (time when the slave clock receives the synchronization message), T3 (time when the slave clock sends a delay request (Delay Request)), and T4 (time when the master clock receives the delay request). The calculation formula is: : ; The first step is to receive the synchronization time and record the time: When the slave clock receives the Sync message, it records the receiving time T2 and waits to obtain the T1 timestamp from the master clock. If it is a two-step mode, the master clock will also send a Follow_Up message carrying the sending time T1; The second step is to calculate the preliminary clock deviation: the slave clock calculates the preliminary deviation PreliminartOffset = T2-T1, which represents the time difference between the slave clock and the master clock, but the network delay is not considered at this time; The third step is to send a delay request and record the time: the slave clock actively sends a DelayRequest message and records the sending time T3. Step 4: The master clock responds to the delay request: After receiving the request, the master clock records the receiving time T4 and returns it to the slave clock through the Delay Response message; Step 5: Calculate network delay: Calculate network delay from the clock based on the received timestamp: This represents the average latency of synchronization messages traveling in both directions across the network.
[0049] The sixth step is to consider the final clock deviation: After considering the network delay, the actual clock deviation is calculated from the clock: , The seventh step is to adjust the slave clock time: According to the calculated offset Offset, the slave clock time is adjusted to: AdjustedTime = CurrentTime + Offset. If the clock offset is a positive number, it means that the slave clock is slower than the master clock and the time needs to be adjusted forward; if it is a negative number, it needs to be adjusted backward. Final synchronization periodic adjustment: Since network delays and clock drift may change over time, the slave clock will periodically exchange synchronization messages with the master clock to dynamically adjust its own time.
[0050] The above is only a preferred embodiment of the present invention. It should be understood that the present invention is not limited to the form disclosed herein, and should not be regarded as excluding other embodiments, but can be used in various other combinations, modifications and environments, and can be modified within the scope of the concept described herein through the above teachings or the technology or knowledge of the relevant field. The changes and modifications made by those skilled in the art shall not deviate from the spirit and scope of the present invention, and shall be within the scope of protection of the claims attached to the present invention.
Claims
1. A vehicle network time synchronization method, characterized in that: The steps include: Step 1: The master clock periodically broadcasts synchronization messages to all slave clocks in the network. The synchronization messages contain the current timestamp. Step 2: Receive the synchronization message from the clock and record the receiving time T1; The slave clock sends a delay request message to the master clock and records the sending time T2; Step 3: After receiving the delay request, the master clock sends a delay response message and records the delay request message receiving time T3; the delay response message includes the timestamp T4 when the master clock receives the delay request message; Step 4: The slave clock obtains the network transmission delay and the clock deviation Offset between the slave clock and the master clock according to the time T1, T2, T3, and T4, and the slave clock adjusts the time according to the clock deviation.
2. A vehicle network time synchronization method according to claim 1, characterized in that: The slave clock receives the synchronization message and records the receiving time T1; The slave clock sends a delay request message to the master clock and records the sending time T2, including: The master clock periodically sends synchronization messages, which contain the current timestamp. All slave clock nodes in the network listen to and receive the synchronization messages. When the slave clock receives the synchronization message, it records the receiving time T1. If a transparent clock exists in the network, the received timestamp will be corrected to compensate for the transmission delay; the slave clock sends a delay request message to the master clock and records the time T2 when the delay request message is sent.
3. A vehicle network time synchronization method according to claim 2, characterized in that: If a transparent clock exists in the network, the received timestamp will be corrected to compensate for the transmission delay, including: When a Sync or Delay Request message enters a network device, the device records the timestamp T in After the network device processes the message, it records the timestamp T out , get the internal delay of the device , the network device accumulates the internal delay ΔT into the correction field of the message; if it is a one-step transparent clock, the correction field of the current Sync message is updated; if it is a two-step transparent clock, the compensation information is sent through the Follow_Up message; if the message passes through multiple transparent clock devices, each device will accumulate its own internal delay to the correction field; when the message is received from the clock, the correction field contains the accumulated delay of all devices.
4. The vehicle network time synchronization method according to claim 1, characterized in that: The slave clock obtains the network transmission delay and the clock deviation Offset between the slave clock and the master clock according to the time T1, T2, T3, and T4, and the slave clock adjusts the time according to the clock deviation, including: S1, when the slave clock receives the Sync message, it records the receiving time T1 and waits to obtain the T1 timestamp from the master clock; if there is a transparent clock in the network, the master clock will also send a Follow_Up message carrying the sending time T2; S2, calculate the preliminary offset from the clock PreliminartOffset = T2-T1; S3, the slave clock actively sends a DelayRequest message and records the delay request message receiving time T3; S4, after receiving the request, the master clock records the timestamp T4 when the clock receives the delay request message, and returns it to the slave clock through the DelayResponse message; S5, the slave clock calculates the network delay based on the received timestamp: ; S6, get the actual clock deviation from the clock: ; S7, according to the actual clock deviation Offset, adjust the time of the slave clock to: AdjustedTime = CurrentTime + Offset. If the clock deviation is a positive number, it means that the slave clock is slower than the master clock and the time needs to be adjusted forward; if it is a negative number, it needs to be adjusted backward; where AdjustedTime is the adjusted time, CurrentTime is the current time, and Offset is the clock deviation.
5. A vehicle network time synchronization system, characterized in that: A vehicle network time synchronization method according to any one of claims 1 to 4 is applied, comprising a master clock module, a slave clock module, a transparent clock module and a boundary clock module; The master clock module is used to provide a time reference; The slave clock module includes clocks of multiple nodes, and the clocks of the multiple nodes are synchronized through the master clock module; The transparent clock module is located in the network device and is used to compensate for message transmission delay; The boundary clock module is used to provide synchronization services at the network boundary, connect different network segments, and reduce the accumulation of time errors in the network layer.
Citation Information
Patent Citations
Method, equipment and system for clock synchronization of access network
CN101631013A
Clock synchronization method and system
CN102546071A
V2X-based time synchronization method
CN112929851A
Cited By
Time calibration method and system for time synchronization network
CN119853845A
Vehicle-mounted time synchronization method and device
CN120602030A
Distributed LED screen cooperative control system based on wireless synchronization protocol
CN120751477A
