A time synchronization method and system for vehicle-mounted multi-network card system
By using the upper-layer protocol stack in the vehicle multi-network card system for time synchronization, and using the IEEE802.1AS protocol and periodic calculation compensation, high-precision time synchronization between multi-network card systems is achieved, solving the problem of time out-of-synchronization in vehicle-mounted Ethernet communication, and improving the flexibility of software development and hardware performance utilization.
Patent Information
- Application Number
- CN202310296512.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-23
- Publication Date
- 2025-08-12
- Estimated Expiration
- 2043-03-23
AI Technical Summary
In vehicle-mounted Ethernet communication, the time out of synchronization between hardware makes it difficult to confirm the sensor fusion frames and sampling points, which can easily lead to misjudgment and misjudgment. The existing technology relies on software to modify the underlying modifications, making it difficult to adapt to complex time synchronization needs.
The upper-layer protocol stack is used to realize time synchronization in a multi-network card system, and the first network card and the second network card are used as master and slave nodes respectively to perform time synchronization. The IEEE802.1AS protocol is used to ensure the time synchronization standard, and periodically calculate and compensate through the upper-layer synchronization protocol stack to achieve stable synchronization between network cards.
It realizes high-precision time synchronization between multiple network card systems, solves the problem of inflexible software modification, meets the time synchronization role requirements of different network cards, and improves the flexibility of software development and hardware performance utilization.
Smart Images

Figure CN116318513B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of time synchronization, and more particularly to a time synchronization method and system for a vehicle-mounted multi-network card system. Background Art
[0002] Ethernet, with its advantages of high bandwidth, protocol diversity, and mature applications, is increasingly being adopted as the backbone for in-vehicle communications. Driven by the growing demand for automated, intelligent, and autonomous vehicles, in-vehicle Ethernet communications place high demands on real-time performance. Active braking, assisted driving, and future autonomous driving in smart cars place stringent requirements on the synchronization and real-time performance of clocks across all domain controllers and sensors in the vehicle. This is because if different hardware components all use built-in hardware clocks, significant time errors can easily occur between them. Furthermore, the sampling frequencies of various sensors vary. Current typical sampling frequencies for lidar are 10Hz, image acquisition 30Hz, and high-precision integrated navigation 100Hz. Time misalignment makes it difficult to confirm sensor fusion frames and sampling points. These conditions can easily lead to misjudgments by decision-makers, potentially leading to accidents. Furthermore, various aspects of the vehicle that interact with the driver and passengers, such as real-time navigation, fatigue monitoring, streaming rearview mirrors, and in-car audio and video, require high-precision time synchronization across all domains, thus driving the need for time synchronization.
[0003] In the telecommunications field, for vehicle Ethernet time synchronization application scenarios, the IEEE802.1AS protocol is often used to ensure accurate and reliable time synchronization. Existing technologies mainly rely on obtaining a first clock, a second clock, and a local clock for comparison to obtain the most accurate clock for time synchronization;
[0004] Application scenarios can present situations where chips have excess computing power while hardware interfaces are fully connected, or configurations need to be changed to meet specific requirements. Adapting different versions of the same hardware requires selecting the configuration based on the highest cost requirements, leaving room for optimization in cost control. Furthermore, in the field of time synchronization applications, the aforementioned single hardware system places higher demands on software development to cope with complex time synchronization scenarios. Summary of the Invention
[0005] The present invention provides a time synchronization method for a vehicle-mounted multi-network card system, which implements different time synchronization roles for different network ports, and ensures lightweight software while coping with complex time synchronization application scenarios.
[0006] In order to solve the above technical problems, the technical solutions of the present invention are as follows:
[0007] A method for synchronizing a time of a vehicle-mounted multi-network card system, characterized in that the time of a system where an external master clock is located is synchronized with the time of the multi-network card system and the system where an external slave clock is located, comprising the following steps:
[0008] The multi-NIC system obtains the time of the external master clock and completes time synchronization between the external master clock and a first NIC of the multi-NIC system, where the first NIC is a NIC of the multi-NIC system and is connected to the system where the external master clock is located;
[0009] An upper-layer synchronization protocol stack is deployed in the multi-network card system, and the upper-layer synchronization protocol stack is used to implement: the first network card serves as a slave node to receive and synchronize with an external master clock, the second network card serves as a master node to output synchronization time to the external slave clock, and the first network card and the second network card serve as inter-network card time synchronization, respectively serving as a time synchronization master node and a time synchronization slave node, wherein the second network card is a network card of the multi-network card system and is a network card connected to the system where the external slave clock is located;
[0010] The multi-network card system calls the upper-layer synchronization protocol stack to complete time synchronization between the first network card and the second network card;
[0011] The multi-network card system completes time synchronization between the second network card and the system where the external slave clock is located.
[0012] The first network card and the second network card in the above solution are two network cards in a multi-network card system, and the multi-network card system may also have other network cards.
[0013] Preferably, when synchronizing the time of the system where the external master clock is located and the system where the external slave clock is located, the time synchronization standard between the transmitting and receiving terminals is ensured based on the IEEE802.1AS generalized precision clock protocol.
[0014] Preferably, after the external master clock is synchronized with the time of the first network card of the multi-network card system, the upper-layer synchronization protocol stack is required to confirm that the synchronization is stable.
[0015] Preferably, the upper-layer synchronization protocol stack confirms that synchronization is stable, specifically:
[0016] The synchronization protocol stack reads the time periodicity of the first network card, calculates the offset, performs status comparison, and confirms that the time synchronization status of the first network card and the system where the external master clock is located is stable.
[0017] Preferably, the calling of the upper-layer synchronization protocol stack to complete the time synchronization between the first network card and the second network card is specifically as follows:
[0018] The upper-layer synchronization protocol stack calls an interface for obtaining network card time and an interface for writing back network card time, uses the interface for obtaining network card time to obtain the time of the first network card and the second network card, and performs periodic calculations within the upper-layer synchronization protocol stack and compares the times with the previous states. After confirming that the synchronization between the first network card and the second network card is stable, the upper-layer synchronization protocol stack calculates the compensation, and writes the compensation back using the interface for writing back network card time, thereby completing the time synchronization between the first network card and the second network card.
[0019] Preferably, the step of confirming that the first network card and the second network card are synchronously and stably performed is as follows:
[0020] The upper-layer synchronization protocol stack periodically calculates and compares the offset between the first network card and the second network card. If the offset is less than a specified value for a certain number of consecutive times, it is confirmed that the synchronization between the first network card and the second network card is stable.
[0021] Preferably, after the synchronization between the first network card and the second network card is stable, the time synchronization between the second network card and the system where the external slave clock is located is completed.
[0022] The present invention further provides a time synchronization system for an on-vehicle multi-network card system, the system applying the above-mentioned time synchronization method for an on-vehicle multi-network card system, the system comprising:
[0023] a first synchronization module, which obtains the time of the external master clock and synchronizes the time of the external master clock with a first network card of the multi-network card system, where the first network card is a network card of the multi-network card system and is connected to the system where the external master clock is located;
[0024] An upper-layer synchronization protocol stack deployment module, wherein the upper-layer synchronization protocol stack deployment module deploys an upper-layer synchronization protocol stack in a multi-network card system, wherein the upper-layer synchronization protocol stack is used to implement: the first network card functions as a slave node to receive and synchronize with an external master clock, the second network card functions as a master node to output synchronization time to an external slave clock, and the first network card and the second network card respectively function as inter-network card time synchronization, wherein the first network card and the second network card respectively function as a time synchronization master node and a time synchronization slave node, wherein the second network card is a network card of the multi-network card system and is a connection network card to the system where the external slave clock is located;
[0025] a second synchronization module, wherein the second synchronization module calls the upper-layer synchronization protocol stack to complete time synchronization between the first network card and the second network card;
[0026] A third synchronization module is used to complete time synchronization between the second network card and the system where the external slave clock is located.
[0027] The present invention further provides an electronic device, comprising:
[0028] Memory for storing computer programs;
[0029] The processor is configured to implement the above-mentioned time synchronization method for the vehicle-mounted multi-network card system when executing the computer program stored in the memory.
[0030] The present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the time synchronization method of the vehicle-mounted multi-network card system described above is implemented.
[0031] Compared with the prior art, the beneficial effects of the technical solution of the present invention are:
[0032] The present invention synchronizes the time of multiple network cards in a single system by calling writeback on the upper protocol stack. The present invention can implement different time synchronization roles for different network cards, solving the need for a single system to act as both a slave clock and a master clock on a time synchronization link. At the same time, the method is implemented at the protocol stack level rather than the software bottom layer, solving the problem of inflexible software modification, thereby ensuring that developers can flexibly optimize software without relying on the underlying software provider. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Figure 1 Schematic diagram of the method of the present invention.
[0034] Figure 2 This is a schematic diagram of the connection between the multi-network card system provided in the embodiment and the external system.
[0035] Figure 3 A schematic diagram of the time synchronization process provided in an embodiment.
[0036] Figure 4 Schematic diagram of the system module of the present invention.
[0037] Figure 5 Schematic diagram of an electronic device of the present invention. DETAILED DESCRIPTION
[0038] The accompanying drawings are for illustrative purposes only and are not to be construed as limiting this patent;
[0039] In order to better illustrate this embodiment, some parts in the drawings may be omitted, enlarged, or reduced, and do not represent the actual product size;
[0040] It is understandable to those skilled in the art that some well-known structures and descriptions thereof may be omitted in the drawings.
[0041] The technical solution of the present invention is further described below with reference to the accompanying drawings and embodiments.
[0042] Example 1
[0043] This embodiment provides a time synchronization method for a vehicle-mounted multi-network card system. Figure 1 As shown, synchronizing the time of the system where the external master clock is located with the multi-network card system and the system where the external slave clock is located includes the following steps:
[0044] The multi-NIC system obtains the time of the external master clock and completes time synchronization between the external master clock and a first NIC of the multi-NIC system, where the first NIC is a NIC of the multi-NIC system and is connected to the system where the external master clock is located;
[0045] An upper-layer synchronization protocol stack is deployed in the multi-network card system, and the upper-layer synchronization protocol stack is used to implement: the first network card serves as a slave node to receive and synchronize with an external master clock, the second network card serves as a master node to output synchronization time to the external slave clock, and the first network card and the second network card serve as inter-network card time synchronization, respectively serving as a time synchronization master node and a time synchronization slave node, wherein the second network card is a network card of the multi-network card system and is a network card connected to the system where the external slave clock is located;
[0046] The multi-network card system calls the upper-layer synchronization protocol stack to complete time synchronization between the first network card and the second network card;
[0047] The multi-network card system completes time synchronization between the second network card and the system where the external slave clock is located.
[0048] In the in-vehicle Ethernet system, this embodiment uses only a single system through an integrated protocol stack to complete the communication and time synchronization functions between the system where the external time synchronization master clock is located and the multi-network card system, as well as the system where the external time synchronization slave clock is located. This solves the problem of insufficient physical connection sockets when multiple systems are converted to a single system even though they are in the same network segment. It also fully utilizes hardware performance and provides more possibilities for chip selection, providing a solution for OEMs to meet the needs of achieving different configurations for the same product.
[0049] Example 2
[0050] This embodiment, based on the first embodiment, further discloses the following contents:
[0051] When synchronizing the time of the system where the external master clock is located and the system where the external slave clock is located, the time synchronization standard between the transmitting and receiving terminals is ensured based on the IEEE802.1AS generalized precise clock protocol.
[0052] After the external master clock is synchronized with the time of the first network card of the multi-network card system, the upper-layer synchronization protocol stack needs to confirm that the synchronization is stable.
[0053] The upper-layer synchronization protocol stack confirms that synchronization is stable, specifically:
[0054] The synchronization protocol stack reads the time periodicity of the first network card, calculates the offset, performs status comparison, and confirms that the time synchronization status of the first network card and the system where the external master clock is located is stable.
[0055] The calling of the upper-layer synchronization protocol stack to complete the time synchronization between the first network card and the second network card is specifically as follows:
[0056] The upper-layer synchronization protocol stack calls an interface for obtaining network card time and an interface for writing back network card time, uses the interface for obtaining network card time to obtain the time of the first network card and the second network card, and performs periodic calculations within the upper-layer synchronization protocol stack and compares the times with the previous states. After confirming that the synchronization between the first network card and the second network card is stable, the upper-layer synchronization protocol stack calculates the compensation, and writes the compensation back using the interface for writing back network card time, thereby completing the time synchronization between the first network card and the second network card.
[0057] In this embodiment, the synchronization between the master node network card and the slave node network card of the multi-network card system does not adopt the method of obtaining time by sending and receiving messages. The present invention obtains the time of the network card of the master node and the network card of the slave node by calling an interface for reading the network card clock in the upper protocol stack deployed by the system node, and calls an interface that can write the network card time to write back the time of the network card of the master node and the network card of the slave node. By calling the above interface, the periodic time is obtained in the upper protocol stack, and the relatively most accurate clock error is obtained by performing periodic error calculation and judging the result, and then the error is compensated and written back, thereby achieving high-precision time synchronization. The confirmation of stable synchronization between the first network card and the second network card is specifically as follows:
[0058] The upper-layer synchronization protocol stack periodically calculates and compares the offset between the first network card and the second network card. If the offset is less than a specified value for a certain number of consecutive times, it is confirmed that the synchronization between the first network card and the second network card is stable.
[0059] After the synchronization between the first network card and the second network card is stable, the time synchronization between the second network card and the system where the external slave clock is located is completed.
[0060] Through actual testing on a test bench, the time synchronization accuracy between network cards can reach the microsecond level. Modifying the inter-NIC time synchronization algorithm allows for periodic testing and optimization of metrics such as the accuracy of time synchronization between multiple network cards, significantly enhancing the autonomy of OEM software development.
[0061] In a specific embodiment, Figure 2As shown in the figure, the connection relationship between the system where the external master clock is located, the multi-network card system, and the system where the external slave clock is located is shown. The system where the external master clock is located is connected to the first network card of the multi-network card system through a switch. The system where the external slave clock is located is a radar, which can be any other sensor system. The second network card of the multi-network card system is connected to the radar. At the same time, the upper-layer synchronization protocol stack is deployed in the multi-network card system. The time synchronization process is roughly as follows: the system where the external master clock is located synchronizes the time to the multi-network card system as the time synchronization slave node, and the multi-network card system then synchronizes the time to the radar as the external slave clock system as the time synchronization master node. At this point, from the system level, the multi-network card system simultaneously synchronizes the time with the time synchronization master node as the time synchronization slave node. The specific process is as follows: Figure 3 As shown:
[0062] The external master clock acts as the time synchronization master node to synchronize the time of the switches deployed in the multi-NIC system. In this case, the switches act as time synchronization slave nodes.
[0063] After the switch completes synchronization with the external time synchronization master clock, it acts as the time synchronization master clock to synchronize the time of the first network card in the multi-network card system. At this time, the first network card acts as the time synchronization slave node. After the upper-layer synchronization protocol stack deployed on the first network card confirms that the synchronization is stable, the following operations are performed;
[0064] The upper-layer synchronization protocol stack deployed in a multi-network card system reads the time of the first network card and periodically calculates the offset to perform a status comparison to confirm that the time synchronization status of the first network card as a time synchronization slave node and the switch as a time synchronization master node is stable. Then, the interface for obtaining the network card time and writing back the network card time is called to obtain the time of the two network cards. After periodic calculations and comparisons with the previous status within the upper-layer synchronization protocol stack to confirm that the synchronization between the first and second network cards is stable, the compensation is calculated and written back after compensation to complete the time synchronization between the two network cards. At this time, the first network card serves as the time synchronization master node in a broad sense, and the second network card serves as the time synchronization slave node in a broad sense. However, communication and time synchronization are not achieved through message interaction. Instead, the time synchronization is achieved by adding the compensation to the time of the first network card and writing it to the second network card through the built-in algorithm of the protocol stack.
[0065] In the above time synchronization system, the two network cards work as the master and slave in time synchronization. Specifically:
[0066] When the first network card synchronizes with an external clock, it acts as a time synchronization slave. However, when synchronizing with the second network card, the first network card acts as the time synchronization master. When synchronizing with the first network card, the second network card acts as a time synchronization slave. When synchronizing with an external clock, the second network card acts as the time synchronization master. This means that the two network cards function as both master and slave in the entire system, satisfying the design requirement of a single network card serving multiple time synchronization roles.
[0067] The upper-layer synchronization protocol stack deployed in a multi-NIC system periodically calculates and compares the offset between the first and second NICs. Once the offset is confirmed to be less than a specified value a certain number of times, the second NIC is activated as the time synchronization master and synchronized with the external radar serving as the time synchronization slave. This completes time synchronization for the entire system.
[0068] Example 3
[0069] This embodiment provides a time synchronization system for a vehicle-mounted multi-network card system. The system applies the time synchronization method for a vehicle-mounted multi-network card system described in embodiments 1 to 2. Figure 4 As shown, the system includes:
[0070] a first synchronization module, which obtains the time of the external master clock and synchronizes the time of the external master clock with a first network card of the multi-network card system, where the first network card is a network card of the multi-network card system and is connected to the system where the external master clock is located;
[0071] An upper-layer synchronization protocol stack deployment module, wherein the upper-layer synchronization protocol stack deployment module deploys an upper-layer synchronization protocol stack in a multi-network card system, wherein the upper-layer synchronization protocol stack is used to implement: the first network card functions as a slave node to receive and synchronize with an external master clock, the second network card functions as a master node to output synchronization time to an external slave clock, and the first network card and the second network card respectively function as inter-network card time synchronization, wherein the first network card and the second network card respectively function as a time synchronization master node and a time synchronization slave node, wherein the second network card is a network card of the multi-network card system and is a connection network card to the system where the external slave clock is located;
[0072] a second synchronization module, wherein the second synchronization module calls the upper-layer synchronization protocol stack to complete time synchronization between the first network card and the second network card;
[0073] A third synchronization module is used to complete time synchronization between the second network card and the system where the external slave clock is located.
[0074] Example 4
[0075] This embodiment provides an electronic device, such as Figure 5 Shown, including:
[0076] Memory for storing computer programs;
[0077] The processor is configured to implement the time synchronization method of the vehicle-mounted multi-network card system described in Example 1 and Example 2 when executing the computer program stored in the memory.
[0078] Example 5
[0079] This embodiment provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the time synchronization method of the vehicle-mounted multi-network card system described in Embodiments 1 and 2 is implemented.
[0080] The same or similar reference numerals correspond to the same or similar components;
[0081] The terms used in the drawings to describe positional relationships are for illustrative purposes only and should not be construed as limiting this patent;
[0082] Obviously, the above embodiments of the present invention are merely examples for the purpose of clearly illustrating the present invention, and are not intended to limit the embodiments of the present invention. Those skilled in the art will appreciate that other variations or modifications can be made based on the above description. It is not necessary and impossible to enumerate all embodiments here. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention shall be included within the scope of protection of the claims of the present invention.
Claims
1. A time synchronization method for a vehicle-mounted multi-network card system, characterized in that: Synchronize the time of the system with the external master clock, the system with multiple network cards, and the system with the external slave clocks. This includes the following steps: The multi-NIC system obtains the time of the external master clock and completes time synchronization between the external master clock and a first NIC of the multi-NIC system, where the first NIC is a NIC of the multi-NIC system and is connected to the system where the external master clock is located; An upper-layer synchronization protocol stack is deployed in the multi-network card system, and the upper-layer synchronization protocol stack is used to implement: the first network card serves as a slave node to receive and synchronize with an external master clock, the second network card serves as a master node to output synchronization time to the external slave clock, and the first network card and the second network card serve as inter-network card time synchronization, respectively serving as a time synchronization master node and a time synchronization slave node, wherein the second network card is a network card of the multi-network card system and is a network card connected to the system where the external slave clock is located; The multi-network card system calls the upper-layer synchronization protocol stack to complete time synchronization between the first network card and the second network card; The multi-network card system completes time synchronization between the second network card and the system where the external slave clock is located.
2. The time synchronization method of the vehicle-mounted multi-network card system according to claim 1, characterized in that: When synchronizing the time of the system where the external master clock is located and the system where the external slave clock is located, the time synchronization standard between the transmitting and receiving terminals is ensured based on the IEEE802.1AS generalized precise clock protocol.
3. The time synchronization method of the vehicle-mounted multi-network card system according to claim 1, characterized in that: After the external master clock is synchronized with the time of the first network card of the multi-network card system, the upper-layer synchronization protocol stack needs to confirm that the synchronization is stable.
4. The time synchronization method of the vehicle-mounted multi-network card system according to claim 3, characterized in that: The upper-layer synchronization protocol stack confirms that synchronization is stable, specifically: The synchronization protocol stack reads the time periodicity of the first network card, calculates the offset, performs status comparison, and confirms that the time synchronization status of the first network card and the system where the external master clock is located is stable.
5. The time synchronization method of a vehicle-mounted multi-network card system according to claim 1, characterized in that: The calling of the upper-layer synchronization protocol stack to complete the time synchronization between the first network card and the second network card is specifically as follows: The upper-layer synchronization protocol stack calls an interface for obtaining network card time and an interface for writing back network card time, uses the interface for obtaining network card time to obtain the time of the first network card and the second network card, and performs periodic calculations within the upper-layer synchronization protocol stack and compares the times with the previous states. After confirming that the synchronization between the first network card and the second network card is stable, the upper-layer synchronization protocol stack calculates the compensation, and writes the compensation back using the interface for writing back network card time, thereby completing the time synchronization between the first network card and the second network card.
6. The time synchronization method of the vehicle-mounted multi-network card system according to claim 5, characterized in that: The confirmation that the first network card and the second network card are synchronized and stable is specifically as follows: The upper-layer synchronization protocol stack periodically calculates and compares the offset between the first network card and the second network card. If the offset is less than a specified value for a certain number of consecutive times, it is confirmed that the synchronization between the first network card and the second network card is stable.
7. The time synchronization method of a vehicle-mounted multi-network card system according to claim 5, characterized in that: After the synchronization between the first network card and the second network card is stable, the time synchronization between the second network card and the system where the external slave clock is located is completed.
8. A time synchronization system for a vehicle-mounted multi-network card system, characterized in that: The system applies the time synchronization method of the vehicle-mounted multi-network card system according to any one of claims 1 to 7, and the system includes: a first synchronization module, which obtains the time of the external master clock and synchronizes the time of the external master clock with a first network card of the multi-network card system, where the first network card is a network card of the multi-network card system and is connected to the system where the external master clock is located; An upper-layer synchronization protocol stack deployment module, wherein the upper-layer synchronization protocol stack deployment module deploys an upper-layer synchronization protocol stack in a multi-network card system, wherein the upper-layer synchronization protocol stack is used to implement: the first network card functions as a slave node to receive and synchronize with an external master clock, the second network card functions as a master node to output synchronization time to an external slave clock, and the first network card and the second network card respectively function as inter-network card time synchronization, wherein the first network card and the second network card respectively function as a time synchronization master node and a time synchronization slave node, wherein the second network card is a network card of the multi-network card system and is a connection network card to the system where the external slave clock is located; a second synchronization module, wherein the second synchronization module calls the upper-layer synchronization protocol stack to complete time synchronization between the first network card and the second network card; A third synchronization module is used to complete time synchronization between the second network card and the system where the external slave clock is located.
9. An electronic device, characterized in that: include: Memory for storing computer programs; The processor is configured to implement the time synchronization method for the vehicle-mounted multi-network card system according to any one of claims 1 to 7 when executing the computer program stored in the memory.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by the processor, the time synchronization method of the vehicle-mounted multi-network card system according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Real-time communication platform based on processor nucleus dividing and virtual machine
CN103957233A
System and method of clock synchronization in a computer network
CN107769879A