Communication enhancement method and system based on CAN bus
By embedding serial numbers in CAN bus communication and introducing a remote frame response mechanism, dynamically adjusting the sliding window, data packet loss and delay problems in CAN bus communication are solved, and data reliability and network efficiency are improved.
Patent Information
- Application Number
- CN202510549072.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-28
- Publication Date
- 2025-08-15
AI Technical Summary
There are problems of data packet loss, delay and high cost consumption in existing CAN bus communications, especially in the absence of response mechanism, inefficient retransmission and lack of serial number management, resulting in poor data integrity and network congestion.
Embed a unique serial number in each CAN data frame and introduced a remote frame response mechanism. The sender dynamically adjusts the window within the set sliding window range, ensuring data reliability and flow control through the serial number and remote frame response mechanism.
It improves the data reliability of CAN communication, reduces unnecessary retransmission times, reduces latency, avoids network congestion, and improves network efficiency and overall performance.
Smart Images

Figure CN120498608A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of CAN communication, and in particular to a communication enhancement method and system based on a CAN bus. Background Art
[0002] CAN (Controller Area Network) communication is widely used in modern automobiles, industrial automation, and other embedded systems due to its efficiency and reliability. Traditional CAN communication protocols use a no-acknowledge mechanism, meaning the sender cannot confirm whether the receiver has successfully received the data after sending a data frame. This makes it difficult to detect and address packet loss, errors, and delays during data transmission.
[0003] To improve data transmission reliability, existing solutions include retransmission mechanisms and CRC checks. However, these solutions often rely on retransmissions at fixed intervals, which can cause network congestion and perform poorly under high loads. Furthermore, existing solutions lack effective sequence number management, making it impossible for receivers to distinguish duplicate or lost data frames, thus compromising the data integrity of the entire system.
[0004] The defects of traditional CAN communication are mainly reflected in the following aspects: No response mechanism: Due to the lack of a response mechanism, the sender cannot confirm whether the data has been successfully delivered to the receiver. This is particularly prominent in application scenarios with high real-time requirements. Low retransmission efficiency: The existing retransmission mechanism is usually based on fixed time intervals for retransmission and cannot be dynamically adjusted according to network conditions, resulting in waste of network resources and increased delays. Poor data integrity: Due to the lack of serial number identification, it is difficult for the receiver to determine whether the data frame is repeated or lost, which makes the system prone to confusion when processing data. Lack of sliding window mechanism: The existing solution fails to effectively utilize the sliding window mechanism for flow control and management, which makes congestion prone to occur under high load conditions. Therefore, there is a need for an efficient data transmission method that can monitor whether the data is successfully sent. Summary of the Invention
[0005] The present invention provides a communication enhancement method and system based on a CAN bus, which are used to solve the problems of data packet loss, delay and high cost in existing CAN bus communications.
[0006] The present invention provides a communication enhancement method based on a CAN bus, comprising: Obtain CAN communication data and embed a unique serial number into each CAN data frame; The sender sends a CAN data frame to the receiver. After receiving the CAN data frame, the receiver sends a remote frame to the sender in response. The sender dynamically moves the window within the set sliding window range according to the received remote frame to complete the CAN bus communication.
[0007] According to a communication enhancement method based on a CAN bus provided by the present invention, the acquisition of CAN communication data and embedding a unique serial number in each CAN data frame specifically include: Embed the serial number in each CAN data frame; The sequence number is generated by the sender and the sequence number value is increased in an incremental manner.
[0008] According to a communication enhancement method based on a CAN bus provided by the present invention, the sender sends a CAN data frame to the receiver, and the receiver sends a remote frame to the sender in response after receiving the CAN data frame, specifically comprising: The sender sends the CAN data frame with the serial number to the receiver; After receiving the CAN data frame, the receiver generates a remote frame and returns it to the sender; When the sender receives the remote frame, it confirms that the data has been sent successfully.
[0009] According to a communication enhancement method based on a CAN bus provided by the present invention, the remote frame includes the same serial number as the CAN data frame, and the remote frame with the serial number serves as a response signal to the sender.
[0010] According to a communication enhancement method based on CAN bus provided by the present invention, a threshold time is set in the process of the sender receiving the remote frame. If the sender receives the corresponding remote frame within the threshold time range, the remote frame is sent successfully; If the sender does not receive the corresponding remote frame within the threshold time range, the remote frame transmission fails.
[0011] According to a communication enhancement method based on a CAN bus provided by the present invention, the sender dynamically moves the window according to the received remote frame within a set sliding window range to complete the CAN bus communication, specifically comprising: The sender maintains multiple data frames to be confirmed simultaneously within the set sliding window range; After the sender receives the remote frame, it moves the window and conducts new data interaction communication.
[0012] The present invention also provides a communication enhancement system based on a CAN bus, the system comprising: The serial number embedding module is used to obtain CAN communication data and embed a unique serial number into each CAN data frame; The response module is used for the sender to send the CAN data frame to the receiver, and the receiver sends a remote frame to the sender in response after receiving the CAN data frame; The sliding window module is used by the sender to dynamically move the window within the set sliding window range according to the received remote frame to complete the CAN bus communication.
[0013] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the communication enhancement method based on the CAN bus as described above is implemented.
[0014] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the communication enhancement method based on the CAN bus as described above is implemented.
[0015] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements any of the above-mentioned communication enhancement methods based on the CAN bus.
[0016] The present invention provides a communication enhancement method and system based on the CAN bus. By introducing a sequence number and a remote frame response mechanism, the data reliability of CAN communication is greatly improved, ensuring that each data can be correctly received and confirmed. Dynamic adjustment of the retransmission strategy and the sliding window mechanism reduces the number of unnecessary retransmissions caused by packet loss, thereby improving network efficiency and reducing latency. The sliding window mechanism enables the system to be flexibly adjusted according to real-time load conditions, effectively avoiding network congestion and improving overall performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the present invention or the prior art, a brief introduction is given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0018] Figure 1 It is a flow chart of the communication enhancement method based on CAN bus provided by the present invention.
[0019] Figure 2 This is a schematic diagram of CAN bus interaction between a sender and a receiver provided by the present invention.
[0020] Figure 3 This is a schematic diagram of module connections of a CAN bus-based communication enhancement system provided by the present invention.
[0021] Figure 4 It is a structural schematic diagram of the electronic device provided by the present invention.
[0022] Reference numerals: 110: serial number embedding module; 120: response module; 130: sliding window module; 410: processor; 420: communication interface; 430: memory; 440: communication bus. DETAILED DESCRIPTION
[0023] To make the objectives, technical solutions, and advantages of the present invention more clear, the technical solutions of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the embodiments described are only some of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts shall fall within the scope of protection of the present invention.
[0024] The following combination Figure 1 The present invention describes a communication enhancement method based on a CAN bus, comprising: Step 100: Acquire CAN communication data and embed a unique serial number into each CAN data frame; Step 200: The sender sends a CAN data frame to the receiver. After receiving the CAN data frame, the receiver sends a remote frame to the sender in response. Step 300: The sender dynamically moves the window within the set sliding window range according to the received remote frame to complete the CAN bus communication.
[0025] This invention improves the data reliability and real-time performance of CAN communication by introducing sequence numbers, remote frame acknowledgement, and a sliding window mechanism. This ensures that every data frame is correctly received and acknowledged, thereby enhancing system data integrity. Furthermore, by dynamically adjusting the retransmission strategy, network resource utilization is increased and latency is reduced. Through flow control, network requirements under varying load conditions can be adapted.
[0026] Obtain CAN communication data and embed a unique serial number in each CAN data frame, including: Embed the serial number in each CAN data frame; The sequence number is generated by the sender and the sequence number value is increased in an incremental manner.
[0027] In the present invention, the sequence number generation rule is as follows: the sender maintains a global increment counter (32-bit unsigned integer) and allocates a unique sequence number each time a data frame is sent.
[0028] The initial value of the counter is 0, it automatically increments after each transmission, and returns to zero after overflow (it needs to be combined with the timestamp to avoid conflicts).
[0029] The serial number is embedded in the extended identifier (29 bits) or reserved bytes of the data field (such as bytes 0-3) of the CAN data frame.
[0030] Sequence number check: The receiver extracts the sequence number by parsing the data frame, records the received sequence number range (such as the maximum continuous sequence number), and discards duplicate or out-of-order frames.
[0031] In the present invention, the sender sends a CAN data frame to the receiver, and the receiver sends a remote frame to the sender in response after receiving the CAN data frame, specifically including: The sender sends the CAN data frame with the serial number to the receiver; After receiving the CAN data frame, the receiver generates a remote frame and returns it to the sender; When the sender receives the remote frame, it confirms that the data has been sent successfully.
[0032] The remote frame contains the same sequence number as the CAN data frame, and the remote frame with the sequence number serves as a response signal to the sender.
[0033] Specifically, the remote frame format shares the same identifier (ID) and sequence number fields as the data frame, and the type identifier is "remote frame" (RTR bit 0 = 1). For example, the remote frame data field is empty and only contains the sequence number response logic.
[0034] After successfully parsing the data frame, the receiver immediately generates and sends a remote frame to ensure a low-latency response (<1ms). The sender starts a timeout timer (the threshold time T is configurable and defaults to 100ms). If no response is received within the timeout, the retransmission mechanism is triggered.
[0035] A threshold time is set during the process of the sender receiving the remote frame. If the sender receives the corresponding remote frame within the threshold time range, the remote frame is sent successfully; If the sender does not receive the corresponding remote frame within the threshold time range, the remote frame transmission fails.
[0036] By introducing the serial number and remote frame response mechanism, the data reliability of CAN communication is greatly improved, ensuring that each data can be correctly received and confirmed.
[0037] The sender dynamically moves the window within the set sliding window range according to the received remote frame to complete the CAN bus communication, specifically including: The sender maintains multiple data frames to be confirmed simultaneously within the set sliding window range; After the sender receives the remote frame, it moves the window and conducts new data interaction communication.
[0038] In the present invention, the window is initialized and adjusted, and the initial window size N (default 5) is dynamically adjusted according to the network load. For example, when the load is low, the window is enlarged (N=8) to improve throughput; when the load is high, the window is reduced (N=3) to avoid congestion.
[0039] Window sliding rule: each time a remote frame is received, the window slides forward one position, releasing the confirmed frame and allowing new frames to be sent.
[0040] Priority queue management: data frames within a window are sorted by priority (e.g., emergency control instructions are sent first), ensuring low-latency transmission of critical data.
[0041] By dynamically adjusting the retransmission strategy and the sliding window mechanism, unnecessary retransmissions due to packet loss are reduced, thereby improving network efficiency and reducing latency. The sliding window mechanism enables the system to flexibly adjust based on real-time load conditions, effectively avoiding network congestion and improving overall performance.
[0042] The sliding window mechanism used in this application improves overall communication efficiency. The sender can maintain multiple data frames to be acknowledged simultaneously, dynamically adjusting the window size to adapt to the current network load. When a remote frame reply is received, the window size is moved accordingly to achieve flow control and management.
[0043] Exception handling and optimization, packet loss retransmission strategy: The upper limit of retransmission times can be configured (such as 3 times). If exceeded, it will be marked as "transmission failure" and trigger an alarm. The retransmission interval uses an exponential backoff algorithm (initial 100ms, doubling each time) to avoid network congestion.
[0044] Serial number conflicts are resolved. After the system restarts, the serial number is read from the non-volatile memory and incremented based on the last maximum value to avoid duplication.
[0045] Network status monitoring, real-time statistics of packet loss rate and delay, dynamic adjustment of window size and timeout threshold, and adaptation to network fluctuations.
[0046] In a specific embodiment, a certain vehicle-mounted control platform is the basic platform of the urban rail transit vehicle control system, and its speed measurement subsystem and IO subsystem use this method. The following is an explanation using the speed measurement subsystem as an example. There are two CPUs inside the speed measurement subsystem, and the data exchange between the two CPUs is carried out through the CAN bus. The amount of data communication is relatively large, and the data communication is required to be reliable. The sliding window size set by both parties of the subsystem communication is 32. When the sender does not receive a response, it sends up to 32 packets of data and waits for the other party to respond. If no response is received within a timeout, it will resend. If a response is received, the sender will continue to send data. Reference Figure 2Before receiving an acknowledgment, the sender has sent at most messages with sequence numbers 1 to 32. At this point, the sliding window maximum is reached and no further messages can be sent. After receiving an acknowledgment for message 1, the number of unacknowledged messages is now 2 to 32, and the total number of unacknowledged messages is 31, which is less than the window value. Therefore, message 33 can be sent. Only after receiving an acknowledgment for message 2 can message 34 be sent. This process continues in this manner until communication is complete.
[0047] A communication enhancement method based on the CAN bus provided by the present invention greatly improves the data reliability of CAN communication by introducing a sequence number and a remote frame response mechanism, ensuring that each data can be correctly received and confirmed; dynamically adjusts the retransmission strategy and the sliding window mechanism to reduce the number of unnecessary retransmissions caused by packet loss, thereby improving network efficiency and reducing latency; the sliding window mechanism enables the system to be flexibly adjusted according to real-time load conditions, effectively avoiding network congestion and improving overall performance.
[0048] refer to Figure 3 The present invention also discloses a communication enhancement system based on a CAN bus, the system comprising: The serial number embedding module 110 is used to obtain CAN communication data and embed a unique serial number into each CAN data frame; The response module 120 is used for the sender to send the CAN data frame to the receiver, and the receiver sends a remote frame to the sender in response after receiving the CAN data frame; The sliding window module 130 is used by the sender to dynamically move the window within a set sliding window range according to the received remote frame to complete the CAN bus communication.
[0049] The process of obtaining CAN communication data and embedding a unique serial number into each CAN data frame includes: Embed the serial number in each CAN data frame; The sequence number is generated by the sender and the sequence number value is increased in an incremental manner.
[0050] The sender sends a CAN data frame to the receiver. After receiving the CAN data frame, the receiver sends a remote frame to the sender in response, which includes: The sender sends the CAN data frame with the serial number to the receiver; After receiving the CAN data frame, the receiver generates a remote frame and returns it to the sender; When the sender receives the remote frame, it confirms that the data has been sent successfully.
[0051] The remote frame contains the same sequence number as the CAN data frame, and the remote frame with the sequence number serves as a response signal to the sender.
[0052] A threshold time is set during the process of the sender receiving the remote frame. If the sender receives the corresponding remote frame within the threshold time range, the remote frame is sent successfully; If the sender does not receive the corresponding remote frame within the threshold time range, the remote frame transmission fails.
[0053] The sender dynamically moves the window within the set sliding window range according to the received remote frame to complete the CAN bus communication, specifically including: The sender maintains multiple data frames to be confirmed simultaneously within the set sliding window range; After the sender receives the remote frame, it moves the window and conducts new data interaction communication.
[0054] The present invention provides a communication enhancement system based on the CAN bus. By introducing the sequence number and remote frame response mechanism, the data reliability of CAN communication is greatly improved, ensuring that each data can be correctly received and confirmed. The dynamic adjustment of the retransmission strategy and the sliding window mechanism reduces the number of unnecessary retransmissions caused by packet loss, thereby improving network efficiency and reducing latency. The sliding window mechanism enables the system to be flexibly adjusted according to the real-time load situation, effectively avoiding network congestion and improving overall performance. It is also compatible with the existing CAN protocol and does not require complex hardware changes, greatly reducing implementation costs and difficulty. Figure 4 An example of a physical structure diagram of an electronic device is shown below. Figure 4 As shown, the electronic device may include: a processor 410, a communications interface 420, a memory 430, and a communications bus 440. The processor 410, the communications interface 420, and the memory 430 communicate with each other via the communications bus 440. The processor 410 may invoke logic instructions in the memory 430 to execute a communication enhancement method based on the CAN bus. The method includes: acquiring CAN communication data and embedding a unique sequence number in each CAN data frame; a sender sending the CAN data frame to a receiver, and the receiver sending a remote frame to the sender in response after receiving the CAN data frame; and the sender dynamically moving the window within a set sliding window range based on the received remote frame to complete CAN bus communication.
[0055] Furthermore, the logic instructions in the aforementioned memory 430 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the portion that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product, stored in a storage medium, includes instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, a mobile hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0056] On the other hand, the present invention also provides a computer program product, which includes a computer program, and the computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute a communication enhancement method based on the CAN bus provided by the above methods, the method including: obtaining CAN communication data and embedding a unique serial number in each CAN data frame; the sender sends the CAN data frame to the receiver, and the receiver sends a remote frame to the sender in response after receiving the CAN data frame; the sender dynamically moves the window within a set sliding window range according to the received remote frame to complete the CAN bus communication.
[0057] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, it is implemented to execute a communication enhancement method based on a CAN bus provided by the above-mentioned methods. The method includes: obtaining CAN communication data and embedding a unique serial number in each CAN data frame; the sender sends the CAN data frame to the receiver, and the receiver sends a remote frame to the sender in response after receiving the CAN data frame; the sender dynamically moves the window within a set sliding window range according to the received remote frame to complete the CAN bus communication.
[0058] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, i.e., they may be located in one location or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of the present embodiment. Persons of ordinary skill in the art will be able to understand and implement the present invention without inventive effort.
[0059] Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented using software plus a necessary general-purpose hardware platform, or of course, hardware. Based on this understanding, the essence of the above technical solution, or the portion that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a magnetic disk, or an optical disk, and includes a number of instructions for causing a computer device (such as a personal computer, server, or network device) to execute the methods described in each embodiment or certain portions of the embodiments.
[0060] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.
Claims
1. A communication enhancement method based on CAN bus, characterized in that: include: Obtain CAN communication data and embed a unique serial number into each CAN data frame; The sender sends a CAN data frame to the receiver. After receiving the CAN data frame, the receiver sends a remote frame to the sender in response. The sender dynamically moves the window within the set sliding window range according to the received remote frame to complete the CAN bus communication.
2. The communication enhancement method based on CAN bus according to claim 1, characterized in that: The method of acquiring CAN communication data and embedding a unique serial number in each CAN data frame specifically includes: Embed the serial number in each CAN data frame; The sequence number is generated by the sender and the sequence number value is increased in an incremental manner.
3. The communication enhancement method based on CAN bus according to claim 1, characterized in that: The sender sends a CAN data frame to the receiver, and the receiver sends a remote frame to the sender in response after receiving the CAN data frame, specifically including: The sender sends the CAN data frame with the serial number to the receiver; After receiving the CAN data frame, the receiver generates a remote frame and returns it to the sender; When the sender receives the remote frame, it confirms that the data has been sent successfully.
4. The communication enhancement method based on CAN bus according to claim 3, characterized in that: The remote frame includes the same sequence number as the CAN data frame, and the remote frame with the sequence number serves as a response signal to the sender.
5. The communication enhancement method based on CAN bus according to claim 1, characterized in that: A threshold time is set in the process of the sender receiving the remote frame. If the sender receives the corresponding remote frame within the threshold time range, the remote frame is sent successfully; If the sender does not receive the corresponding remote frame within the threshold time range, the remote frame transmission fails.
6. The communication enhancement method based on CAN bus according to claim 1, characterized in that: The sender dynamically moves the window according to the received remote frame within the set sliding window range to complete the CAN bus communication, specifically including: The sender maintains multiple data frames to be confirmed simultaneously within the set sliding window range; After the sender receives the remote frame, it moves the window and conducts new data interaction communication.
7. A communication enhancement system based on CAN bus, characterized in that: The system comprises: The serial number embedding module is used to obtain CAN communication data and embed a unique serial number into each CAN data frame; The response module is used for the sender to send the CAN data frame to the receiver, and the receiver sends a remote frame to the sender in response after receiving the CAN data frame; The sliding window module is used by the sender to dynamically move the window within the set sliding window range according to the received remote frame to complete the CAN bus communication.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that: When the processor executes the computer program, the communication enhancement method based on the CAN bus as described in any one of claims 1 to 6 is implemented.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the communication enhancement method based on the CAN bus as claimed in any one of claims 1 to 6 is implemented.
10. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the communication enhancement method based on the CAN bus as claimed in any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
CAN bus data transmission method
CN101764730A
Reliable data transmission method for CAN (control area network)-based measurement and control subsystem
CN102164066A
CAN (Controller Area Network) bus communication method with segmented user-defined identifier
CN115174304A
Application layer protocol design method based on CAN2.0B protocol
CN117914977A
Cited By
Sliding window protocol data receiving and recombining method and device based on CAN bus
CN120956675A