Data communication method, communication device, system and readable storage medium
By matching the required cache space of data frames in the system layer buffer of the OTA upgrade agent, the problems of inefficiency of traditional TCP communication methods and insufficient big data transmission capabilities in the OTA upgrade scenario are solved, and more efficient communication and multi-customer big data transmission are achieved.
Patent Information
- Application Number
- CN202510112149.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-24
- Publication Date
- 2025-04-18
- Estimated Expiration
- 2045-01-24
AI Technical Summary
In the OTA upgrade scenario, traditional TCP communication methods are expensive, have low efficiency, and cannot meet the requirements of multi-customer big data transmission.
By setting the system layer buffer in the OTA upgrade agent, the data frames sent by the OTA upgrade master are obtained, and the cache space is matched with the remaining space of the system layer buffer according to the requirements. If space is insufficient or a window probe request is detected, a first reply message is returned to avoid frequent interactions.
The improved TCP communication method reduces the interaction overhead of the traditional 'one question and one answer' method, improves communication efficiency, and can meet the needs of multi-customer big data transmission.
Smart Images

Figure CN119561980B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communications, and in particular to a data communication method, communication equipment, system and readable storage medium. Background Art
[0002] In the related technology, in the OTA (Over the Air Technology) upgrade scenario, during the data communication (such as TCP (Transmission Control Protocol) communication) between devices in the OTA architecture, in order to ensure the reliability of communication, after the sender (such as the OTA upgrade master) sends the data, it waits for the confirmation response from the server (such as the OTA upgrade agent). If there is a response, it means that the other party has successfully received it, otherwise it is considered that the data is likely to be lost. This "question-and-answer" communication method leads to high communication overhead and low efficiency.
[0003] In addition, when the data load is large and the window (system buffer) provided by the OTA upgrade agent is exhausted, the OTA upgrade master cannot transmit data and needs to wait for the user to read before releasing the window. The OTA upgrade master constantly tests the window space, and the communication transmission efficiency is low, which cannot meet the large data transmission requirements of multiple customers. Summary of the invention
[0004] In view of this, the embodiments of the present application provide a data communication method, communication equipment, system and readable storage medium to solve the problem that the traditional TCP communication method between devices in the OTA architecture in the OTA upgrade scenario has high overhead, low efficiency, and cannot meet the requirements of multi-client large data transmission.
[0005] In a first aspect of an embodiment of the present application, a data communication method is provided, which is applied to an OTA upgrade agent, wherein the OTA upgrade agent includes a system layer buffer;
[0006] The method comprises the following steps:
[0007] Obtain the current data frame sent by the OTA upgrade master and determine the required cache space for the current data frame;
[0008] If the required buffer space of the current data frame is less than the current remaining buffer space of the system layer buffer, the current data frame is cached in the system layer buffer;
[0009] If the required cache space of the current data frame is greater than or equal to the current remaining cache space of the system layer buffer, or a window detection request initiated by the OTA upgrade master is detected, a first response message is returned to the OTA upgrade master, and the first response message includes at least the current remaining cache space of the system layer buffer.
[0010] A second aspect of an embodiment of the present application provides a data communication method, which is applied to OTA upgrade of a main control, and the method includes:
[0011] Send the current data frame to the OTA upgrade agent;
[0012] If no response message returned by the OTA upgrade agent for the current data frame is detected, continue to send the next data frame to the OTA upgrade agent;
[0013] If a second response message or a third response message returned by the OTA upgrade agent for the current data frame is detected, determining that the data frame needs to be retransmitted based on the second response message or the third response message;
[0014] Send a retransmission request data frame to the OTA upgrade agent.
[0015] According to a third aspect of an embodiment of the present application, a data communication system is provided, including: a first device, a second device, and at least one electronic control unit, wherein the first device is communicatively connected with the second device and each electronic control unit, and the second device is communicatively connected with each electronic control unit;
[0016] The first device is provided with an OTA upgrade agent, the second device is provided with an OTA upgrade master control, and each electronic control unit is provided with an OTA upgrade slave control;
[0017] The OTA upgrade master control includes a socket client, and the socket client includes at least one sub-client;
[0018] The OTA upgrade agent includes a socket server;
[0019] The socket clients are connected to the socket servers; the socket servers are connected to the OTA upgrade slaves;
[0020] The OTA upgrade master is used to implement the data communication method of the second aspect to send the current data frame to the OTA upgrade agent;
[0021] The OTA upgrade agent is used to implement the data communication method of the first aspect to send the current data frame to the corresponding OTA upgrade slave controller.
[0022] According to a fourth aspect of an embodiment of the present application, a communication device is provided, which includes a system layer buffer; the communication device is configured to implement the data communication method of the first aspect.
[0023] According to a fifth aspect of an embodiment of the present application, another communication device is provided, which is configured to implement the data communication method of the second aspect.
[0024] In a sixth aspect of an embodiment of the present application, a readable storage medium is provided, which stores a computer program, and when the computer program is executed by a processor, the steps of the above method are implemented.
[0025] Compared with the prior art, the beneficial effects of the embodiment of the present application include at least: when the current data frame sent by the OTA upgrade master is obtained, the required cache space of the current data frame is first determined. If the required cache space of the current data frame is less than the current remaining cache space of the system layer buffer, the current data frame is cached to the system layer buffer; if the required cache space of the current data frame is greater than or equal to the current remaining cache space of the system layer buffer, it indicates that the current remaining cache space of the system layer buffer is not enough to cache the current data frame or is in a "zero window" state, and the first response message is returned to the OTA upgrade master at this time; in addition, when the window detection request initiated by the OTA upgrade master is detected, the first response message is returned to the OTA upgrade master. The improved TCP communication method in the embodiment of the present application no longer adopts the traditional "one question and one answer" method, which saves the interaction overhead caused by the "one question and one answer", improves communication efficiency, and can meet the large data transmission requirements of multiple customers. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0027] Figure 1 It is a schematic diagram of an application scenario of an embodiment of the present application;
[0028] Figure 2 It is a schematic diagram of the traditional response interaction between devices in the OTA architecture in the OTA upgrade scenario;
[0029] Figure 3 It is a flowchart of the traditional TCP communication method between devices in the OTA architecture in the OTA upgrade scenario;
[0030] Figure 4 It is a flowchart of a data communication method provided by an embodiment of the present application;
[0031] Figure 5 It is a flow chart of the first communication mode in the data communication method provided in the embodiment of the present application;
[0032] Figure 6 It is a schematic diagram of a mapping relationship between a system layer buffer and an application layer buffer in a data communication method provided in an embodiment of the present application;
[0033] Figure 7 It is a schematic diagram of another mapping relationship between a system layer buffer and an application layer buffer in a data communication method provided in an embodiment of the present application;
[0034] Figure 8 This is a schematic diagram of an Ethernet message format of a current data frame provided in an embodiment of the present application;
[0035] Fig. 9 It is a flow chart of the second communication mode in the data communication method provided in the embodiment of the present application;
[0036] Fig.10 It is a flowchart of another data communication method provided by an embodiment of the present application;
[0037] Fig.11 It is a flow chart of the third communication mode in the data communication method provided in the embodiment of the present application;
[0038] Fig.12 It is a flowchart of a fourth data communication method in the data communication method provided in an embodiment of the present application;
[0039] Fig.13 It is a schematic diagram of the architecture of a data communication system provided by an embodiment of the present application;
[0040] Fig.14 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0041] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0042] A data communication method and system according to an embodiment of the present application will be described in detail below with reference to the accompanying drawings.
[0043] Figure 1 1 is a schematic diagram of an application scenario of an embodiment of the present application. The application scenario may include a first device 101 (also referred to as a server or a receiver) and a second device 102 (also referred to as a client or a sender). As an example, see Figure 1The first device 101 can be a vehicle integrated gateway (VGW) or a vehicle information unit (VIU). The second device 102 can be a cockpit domain controller (CDC), a mobile data center (MDC), or a vehicle dynamics control (VDC). The first device 101 and the second device 102 can be connected via 100M Ethernet (ETH). The first device 101 can be connected to one or more ECUs (electronic control units); the first device 101 can be connected to each ECU under it via a CAN (Controller Area Network) bus or an ETH bus. The second device 102 can be connected to the OTA cloud platform via a 4G / 5G network.
[0044] The application scenario of the embodiment of the present application may specifically be an OTA upgrade scenario. In the OTA upgrade scenario, the processing technology of OTA download and OTA upgrade is generally applied. The processing technology usually involves the OTA architecture. The OTA architecture mainly includes the OTA upgrade master control (Upgrade master control, referred to as "UMC"), the OTA upgrade agent (Upgrade Agent, referred to as "UA") and the OTA upgrade slave control (Upgrade slave control, referred to as "US"). Among them, UMC is mainly used to download OTA upgrade files from the OTA cloud platform and transmit them to UA or US; UA is mainly used to receive OTA upgrade files transmitted by UMC and forward them to US; US is mainly used to upgrade and flash the ECU according to the OTA upgrade files transmitted by UMC or UA.
[0045] As an example, the UMC may be set in the second device 102; the UA may be set in the first device 101; and the US may be set in the electronic control unit.
[0046] The specific type, quantity and combination of the first device 101 and the second device 102 can be adjusted according to the actual needs of the application scenario, and the embodiment of the present application does not limit this.
[0047] Figure 2 This is a diagram of the traditional response interaction between devices in the OTA architecture in the OTA upgrade scenario. Figure 2In the OTA upgrade scenario, when the data sent by the OTA upgrade master reaches the OTA upgrade agent or ECU, the OTA upgrade agent or ECU will return a notification of the received message (i.e., confirmation response ACK), which identifies the starting message sequence number of the next frame message. The communication transmission is carried out in a "question-and-answer" manner. TCP achieves reliable data transmission through positive confirmation response ACK. After the OTA upgrade master sends the data, it waits for the confirmation response of the OTA upgrade agent or ECU. If there is a response, it means that the OTA upgrade agent or ECU has successfully received it. If the OTA upgrade agent or ECU fails to receive it, it does not respond to ACK and adopts a timeout mechanism. For example, when the OTA upgrade master sends the 100th to 199th bytes of data, it waits for the confirmation response of the OTA upgrade agent or ECU; if the response ACK of the OTA upgrade agent or ECU is received, the 200th to 299th bytes of data are sent; if the response ACK of the OTA upgrade agent or ECU is not received, the timeout mechanism is adopted. However, this "question-and-answer" communication method causes too much TCP communication overhead and low communication efficiency.
[0048] In addition, when the OTA upgrade master communicates with the OTA upgrade agent, when the data load is large and the window (system buffer) provided by the OTA upgrade agent is exhausted, the OTA upgrade master cannot transmit data and needs to wait for the user to read it before releasing the window. The OTA upgrade master constantly tests the window space, and the communication transmission efficiency is low, which cannot meet the large data transmission requirements of multiple customers.
[0049] Figure 3 This is a flowchart of the traditional TCP communication method between devices in the OTA architecture in the OTA upgrade scenario. Figure 3In the OTA upgrade scenario, TCP communication is performed between devices in the OTA architecture to transmit data packets. The maximum amount of data that the OTA upgrade master can receive at one time is usually determined by the size of its system layer buffer, such as WINDOWN (buffer). For example, the maximum capacity of the system layer buffer is 3000 bytes, so the OTA upgrade agent can receive a maximum of 3000 bytes of data at one time. Every time the OTA upgrade agent receives a frame of data packet (such as the data packet of the 1st to 500 bytes), its system layer buffer will reduce the length of the frame of data (corresponding to a reduction of 500 bytes), until the system layer buffer of the OTA upgrade agent is full, it returns "WND: 0" (zero window, that is, the system layer buffer is full and can no longer receive data) to the OTA upgrade master. At this time, the OTA upgrade master can no longer send data to the OTA upgrade agent. It needs to wait until the OTA upgrade agent copies the data in its system layer buffer to the application layer buffer and the user reads the data before releasing the system layer buffer. The OTA upgrade master constantly tests the window space, and the communication transmission efficiency is low, which cannot meet the large data transmission requirements of multiple OTA upgrade masters.
[0050] In view of this, an embodiment of the present application provides a data communication method, which improves the traditional TCP communication method between devices in the OTA architecture in the OTA upgrade scenario. It no longer uses the traditional "question-and-answer" method for interaction. Instead, when the current data frame sent by the OTA upgrade master is obtained, the required cache space of the current data frame is first determined. If the required cache space of the current data frame is less than the current remaining cache space of the system layer buffer, the current data frame is cached to the system layer buffer; if the required cache space of the current data frame is greater than or equal to the current remaining cache space of the system layer buffer, it indicates that the current remaining cache space of the system layer buffer is not sufficient. It is sufficient to cache the current data frame or it is in a "zero window" state after caching the current data frame, and at this time, a first response message is returned to the OTA upgrade master control; or, when a window detection request initiated by the OTA upgrade master control is detected, a first response message is returned to the OTA upgrade master control, and the first response message includes the current remaining cache space of the system layer buffer, so that the OTA upgrade master control can determine whether it can continue to send data to the OTA upgrade agent based on the first response message, without the need for the OTA upgrade master control to constantly test the window space, thereby improving communication efficiency, meeting the large data transmission requirements of multiple customers, and saving the interaction overhead due to "question and answer".
[0051] Figure 4 is a flow chart of a data communication method provided by an embodiment of the present application. The data communication method of the embodiment of the present application can be Figure 1 Execute it using the OTA upgrade agent in .
[0052] The OTA upgrade agent includes a system layer buffer, which can be understood as a cache window of the system layer of the TCP server, such as a WINDOWN buffer.
[0053] See also Figure 4 The data communication method of the embodiment of the present application comprises the following steps:
[0054] Step S401, obtaining the current data frame sent by the OTA upgrade master control, and determining the required cache space of the current data frame.
[0055] The required buffer space refers to the data length of the current data frame.
[0056] As an example, in the OTA upgrade scenario, assume that the target ECU is ECU1-1 that supports Ethernet. The OTA upgrade master can download and cache the upgrade data packet from the OTA cloud platform, and then process the upgrade data packet to obtain multiple data frames to be transmitted. The OTA upgrade agent creates a socket server (SOCKET SERVER) and establishes a TCP communication connection between the socket server (SOCKET SERVER) and the socket client (SOCKET CLIENT) created by the OTA upgrade master. The OTA upgrade master sends the current data frame (which can be one or more frames of the data frame to be transmitted) to the socket server (SOCKET SERVER) through the socket client (SOCKET CLIENT). In this way, the OTA upgrade agent can obtain the current data frame sent by the OTA upgrade master.
[0057] Step S402: If the required buffer space of the current data frame is smaller than the current remaining buffer space of the system layer buffer, the current data frame is buffered in the system layer buffer.
[0058] The current remaining cache space indicates how much data the system-level buffer can currently store.
[0059] If the system layer buffer has not started to cache data, the current remaining cache space is equal to the total cache space of the system layer buffer. If the system layer buffer has already cached some data, the current remaining cache space is the difference between the total cache space of the system layer buffer and the length of the data that has been cached in the system layer buffer. For example, if the total cache space of the system layer buffer is 3000 bytes and the length of the data that has been cached in the system layer buffer is 500 bytes (such as the data from bytes 1 to 500), then the current remaining cache space is 2500 bytes.
[0060] If the required cache space of the current data frame received by the OTA upgrade agent is less than the current remaining cache space of the system layer buffer, it indicates that the system layer buffer can cache the current data frame. At this time, the current data frame can be cached in the system layer buffer.
[0061] Step S403, if the required cache space of the current data frame is greater than or equal to the current remaining cache space of the system layer buffer, or a window detection request initiated by the OTA upgrade master is detected, a first response message is returned to the OTA upgrade master, and the first response message includes at least the current remaining cache space of the system layer buffer.
[0062] The technical solution provided in the embodiment of the present application improves the traditional TCP communication method between devices in the OTA architecture in the OTA upgrade scenario. It no longer uses the traditional "question-and-answer" method for interaction. Instead, when the current data frame sent by the OTA upgrade master is obtained, the required cache space of the current data frame is first determined. If the required cache space of the current data frame is less than the current remaining cache space of the system layer buffer, the current data frame is cached to the system layer buffer; if the required cache space of the current data frame is greater than or equal to the current remaining cache space of the system layer buffer, it indicates that the current remaining cache space of the system layer buffer is not enough. It is sufficient to cache the current data frame or it is in a "zero window" state after caching the current data frame, and at this time, a first response message is returned to the OTA upgrade master control; or, when a window detection request initiated by the OTA upgrade master control is detected, a first response message is returned to the OTA upgrade master control, and the first response message includes the current remaining cache space of the system layer buffer, so that the OTA upgrade master control can determine whether it can continue to send data to the OTA upgrade agent based on the first response message without constantly testing the window space, thereby improving communication efficiency, meeting the large data transmission requirements of multiple customers, and saving the interaction overhead due to "question and answer".
[0063] Figure 5 This is a flow chart of the first communication mode in the data communication method provided in the embodiment of the present application. Figure 5Compared with the traditional TCP communication method between devices in the OTA architecture in the OTA upgrade scenario, the first communication method provided by the embodiment of the present application is that the OTA upgrade agent or ECU returns a confirmation response message (ACK) to the OTA upgrade master only when the current reception time of the received current data frame reaches the set time interval (such as 500 milliseconds) or the system layer buffer is in the "zero window" state (WND: 0). In this way, the OTA upgrade master can send data messages to the OTA upgrade agent or ECU to the maximum extent possible, and the transmission efficiency is very high. Secondly, the size of the system layer buffer can be dynamically adjusted according to the size of the data message. If the data message is large, the total length of the system layer buffer can be increased accordingly according to the data load status of the OTA upgrade agent or ECU to meet the large data transmission requirements. If the data message is small, the total length of the system layer buffer can be adjusted to be smaller accordingly to save memory resources. Finally, by establishing a cache mapping relationship between the system layer buffer and the user layer buffer (the data message written into the system layer buffer is actually equivalent to writing into the user layer buffer, so that "zero copy" can be achieved), the communication application layer can directly read the data in the system layer buffer, thereby realizing efficient writing and reading of data. In addition, this method basically does not have a "zero window" state, which can ensure real-time and efficient processing of large data messages.
[0064] In some embodiments, the OTA upgrade agent further includes an application layer buffer, which can be understood as a user buffer of the application layer of the TCP server (specifically, it can be a user application ring buffer).
[0065] See also Figure 3 In the OTA upgrade scenario, the window size of the system layer buffer of the traditional TCP communication method between devices in the OTA architecture is a fixed value, and the data in the system layer buffer needs to be copied to the application layer buffer first, and then the system layer buffer can be released after the communication application layer reads the data. The efficiency of data reading and releasing the occupied window is low, the communication efficiency is low, and it is difficult to achieve real-time and efficient processing of data (especially when the amount of data transmitted is large).
[0066] In some embodiments, the data communication method provided in the embodiments of the present application may further include:
[0067] Establish a cache mapping relationship between the system layer buffer and the application layer buffer;
[0068] Alternatively, the current data frame is synchronously written into the application layer buffer. When all the current data frames have been written into the application layer buffer, the current data frame cached in the system layer buffer is cleared, and a cache mapping relationship between the system layer buffer and the application layer buffer is established;
[0069] Alternatively, the current data frame is synchronously written into the application layer buffer, and a cache mapping relationship between the system layer buffer and the application layer buffer is established.
[0070] In the first case, when the OTA upgrade agent caches the current data frame to the system layer buffer, it establishes a cache mapping relationship between the system layer buffer and the application layer buffer (such as Figure 6 as shown).
[0071] Through the above method, the process of copying the current data frame to the application layer buffer can be omitted, realizing "zero copy", thereby improving the efficiency of reading data at the communication application layer and releasing the efficiency of occupied windows, improving communication efficiency, and realizing real-time and efficient processing of data (especially when the amount of data transmitted is large).
[0072] In the second case, the OTA upgrade agent caches the current data frame to the system layer buffer and synchronously writes the current data frame to the application layer buffer. After that, when the current data frame has been written to the application layer buffer, the current data frame cached in the system layer buffer is cleared and a cache mapping relationship between the system layer buffer and the application layer buffer is established (such as Figure 6 as shown).
[0073] Through the above method, the process of copying the current data frame to the application layer buffer can be omitted, and "zero copy" can be achieved, thereby improving the efficiency of the communication application layer in reading data and releasing the occupied window, improving communication efficiency, and realizing real-time and efficient processing of data (especially in the case of large amounts of transmitted data). Secondly, after the communication system layer confirms that the current data frame has been fully written to the application layer buffer, it promptly clears the current data frame in the system layer buffer, so that the system layer buffer can maintain the "non-zero window" state for a long time, so that it can continuously receive data sent by the second device, which can further improve data communication efficiency.
[0074] In the third case, the OTA upgrade agent caches the current data frame to the system layer buffer and synchronously writes the current data frame to the application layer buffer, and establishes a cache mapping relationship between the system layer buffer and the application layer buffer (such as Figure 6 as shown).
[0075] Through the above method, the process of copying the current data frame to the application layer buffer can be omitted, realizing "zero copy", thereby improving the efficiency of reading data at the communication application layer and releasing the efficiency of occupied windows, improving communication efficiency, and realizing real-time and efficient processing of data (especially when the amount of data transmitted is large).
[0076] In some embodiments, after the second situation described above, the following may also be included:
[0077] If a first read operation of the user on the current data frame is detected, a first cache space corresponding to the current data frame is determined, wherein the first cache space is located in the application layer buffer;
[0078] After confirming that the first read operation is completed, the first cache space is released, and the cache mapping relationship between the system layer buffer and the application layer buffer is refreshed.
[0079] See also Figure 7 As an example, assume that the system layer buffer includes m cache spaces, namely sys_1, sys_2, ..., sys_m; the application layer buffer includes m cache spaces, namely app_1, app_2, ..., app_m. Among them, sys_1 corresponds to app_1, sys_2 corresponds to app_2, ..., sys_m corresponds to app_m. When the user's first read operation for the current data frame is monitored, the query determines the first cache space (for example, app_1) corresponding to the current data frame. When it is confirmed that the first read operation is completed, the current data frame in the first cache space (for example, app_1) is cleared, and the cache mapping relationship between the system layer buffer and the application layer buffer is refreshed, that is, the corresponding relationship between sys_1 and app_1 is refreshed.
[0080] By adopting the above method, after the current data frame is read, the cache space occupied by the current data frame in the application layer buffer can be released in time, thereby improving the cache space utilization rate of the application layer buffer.
[0081] In some embodiments, after the third situation described above, the method further includes:
[0082] If a second read operation of the user on the current data frame is detected, a first cache space and a second cache space corresponding to the current data frame are determined, wherein the first cache space is located in the application layer buffer and the second cache space is located in the system layer buffer;
[0083] After confirming that the second read operation is completed, the first cache space and the second cache space are released, and the cache mapping relationship between the system layer buffer and the application layer buffer is refreshed.
[0084] See also Figure 7As an example, when a second read operation of the user for the current data frame is detected, the first cache space (for example, app_1) and the second cache space (for example, sys_1) corresponding to the current data frame are queried and determined. When it is confirmed that the second read operation is completed, the current data frame in the first cache space (for example, app_1) and the current data frame in the second cache space (for example, sys_1) are cleared to release the first cache space and the second cache space, and the cache mapping relationship between the system layer buffer and the application layer buffer is refreshed, that is, the corresponding relationship between sys_1 and app_1 is refreshed.
[0085] By adopting the above method, after the current data frame is read, the cache space occupied by the current data frame in the application layer buffer and the system layer buffer can be released in time, thereby improving the cache space utilization of the system layer buffer and the application layer buffer.
[0086] In some embodiments, the system layer buffer includes a data cache area and a data reserved area, and the cache space size of the data cache area is larger than the cache space size of the data reserved area.
[0087] Cache the current data frame to the system layer buffer, including:
[0088] If the required cache space of the current data frame exceeds the cache space size of the data cache area and does not exceed the total cache space size of the system layer buffer, the current data frame is split into first data and second data, and the first data is cached in the data cache area, and the second data is cached in the data reserved area, wherein the space occupied by the first data is equal to the cache space size of the data cache area;
[0089] Synchronously write the current data frame into the application layer buffer, and establish a cache mapping relationship between the system layer buffer and the application layer buffer, including:
[0090] The first data and the second data are synchronously written into the application layer buffer, and a cache mapping relationship between the system layer buffer and the application layer buffer is established. After confirming that the first data and the second data have all been written into the application layer buffer, the data reserved area is released.
[0091] As an example, assuming that the required cache space corresponding to the current data frame received by the OTA upgrade agent is q kilobytes, the cache space size of the data cache area is a kilobytes, and q≤a, the current data frame is cached in the data cache area.
[0092] As an example, assume that the total cache space size of the system layer buffer is c kilobytes, the cache space size of the data cache area is a kilobytes, and the cache space size of the data reserved area is b kilobytes, where c=a+b. If the required cache space corresponding to the current data frame received by the OTA upgrade agent is q kilobytes, where a<q≤c, then the current data frame is split into the first data (data volume size is a kilobytes) and the second data (data volume size is w=qa), and the first data is cached in the data cache area, and the second data is cached in the data reserved area. At the same time, the above-mentioned first data and second data are synchronously written into the application layer buffer, and a cache mapping relationship between the system layer buffer and the application layer buffer is established. Afterwards, after confirming that the first data and the second data have all been written to the application layer buffer, the cache space of the data reserved area is released.
[0093] By setting a data cache area and a data reserved area in the system layer buffer, and caching the current data frame received from the OTA upgrade master control in the data cache area first, when the data size of the current data frame exceeds the cache space size of the data cache area, but does not exceed the total cache space size of the system layer buffer, the current data frame is split and then cached in the data cache area and the data reserved area respectively, and the split data is synchronously written to the application layer buffer, and a cache mapping relationship between the system layer buffer and the application layer buffer is established, and after confirming that the first data and the second data have all been written to the application layer buffer, the data reserved area is released in time, so that the system layer buffer can maintain a "non-zero window" state, thereby ensuring that the OTA upgrade agent can continue to receive data sent by the OTA upgrade master control, thereby improving data communication efficiency. At the same time, users can directly read the first data and the second data based on the cache mapping relationship between the system layer buffer and the application layer buffer, thereby improving the efficiency of data reading.
[0094] In some embodiments, if the required buffer space of the current data frame is greater than or equal to the current remaining buffer space of the system layer buffer, the current remaining buffer space of the system layer buffer is dynamically adjusted based on the current data load state so that the adjusted current remaining buffer space is greater than the required buffer space of the current data frame;
[0095] Cache the current data frame into the adjusted current remaining cache space.
[0096] Among them, the current data load state can be specifically determined according to the current transmission bandwidth and memory resource allocation of the OTA upgrade agent. Generally, if the current transmission bandwidth of the OTA upgrade agent is large and there are more unallocated memory resources, then its current data load state is small data load; conversely, if the current transmission bandwidth of the OTA upgrade agent is small and there are fewer unallocated memory resources, then its current data load state is large data load.
[0097] As an example, assuming that the required cache space of the current data frame is d kilobytes, and the current remaining cache space of the system layer buffer is r kilobytes, where d>r, then the current data load state of the OTA upgrade agent can be determined based on the current transmission bandwidth and memory resource allocation of the OTA upgrade agent, and then the adjustable cache space size corresponding to the current data load state is determined by querying the pre-designed correspondence table between the data load rate and the adjustable cache space size, and then the size of the current remaining cache space is dynamically adjusted according to the adjustable cache space size, so that the adjusted current remaining cache space is larger than the required cache space. For example, assuming that the data load rate corresponding to the current data load state is x %, and the corresponding adjustable cache space size is y kilobytes, then the current remaining cache space of the system layer buffer can be dynamically adjusted from r kilobytes to r+t kilobytes, where t≤y and r+t≥d.
[0098] The above technical solution can dynamically adjust the current remaining cache space of the system layer buffer according to the current data load status of the OTA upgrade agent, so as to more fully and reasonably utilize the memory resources of the OTA upgrade agent, improve the ability of the OTA upgrade agent to receive data, and thus improve the efficiency of data communication.
[0099] In some embodiments, after obtaining the current data frame sent by the OTA upgrade master control, the method further includes:
[0100] Determine a current frame identifier in a current data frame;
[0101] If the current data frame is determined to be the last frame based on the current frame identifier, a second response message is returned to the OTA upgrade master control. The second response message includes the frame serial number and data frame message of the next data frame. The data frame message indicates all data frames that have been successfully received.
[0102] Figure 8 This is a schematic diagram of the Ethernet message format of a current data frame provided in an embodiment of the present application.
[0103] See also Figure 8The Ethernet message format of the current data frame includes a 20-byte fixed header, which includes source port (2 bytes), destination port (2 bytes), sequence number (4 bytes), confirmation number (4 bytes), data offset (4 bits), reserved (4 bits), CWR (1 bit), ECE (1 bit), URG (1 bit), ACK (1 bit), PSH (1 bit), RST (1 bit), SYN (1 bit), FIN (1 bit), window (2 bytes), checksum (2 bytes) and urgent pointer (2 bytes). The maximum length of options and padding is 4 Byte×10=40 Byte.
[0104] In some implementations, the current frame identifier of the current data frame may be filled in the "Reserved" field in the Ethernet message format. The current frame identifier is CF (indicating a continuous frame) or FF (indicating a first frame) or EF (indicating an end frame). The preset time interval may be filled in the "Options" field in the Ethernet message format. The preset time interval may be flexibly set according to actual conditions, for example, it may be set to 500 milliseconds, 1 second, 2 seconds, etc.
[0105] After receiving the current data frame sent by the OTA upgrade master, the OTA upgrade agent can identify whether the current data frame is the first frame, continuous frame or last frame by extracting the current frame identifier filled with "reserved" in the Ethernet message format of the current data frame.
[0106] In some embodiments, after determining the current frame identifier in the current data frame, the method further includes:
[0107] If the current data frame is determined to be the first frame or a continuous frame based on the current frame identifier, then the current receiving time of the current data frame is determined;
[0108] If the current receiving time reaches the set time interval, a third response message is returned to the OTA upgrade master control. The third response message includes the frame serial number of the next data frame and a data frame message. The data frame message indicates all data frames that have been successfully received.
[0109] Fig. 9 It is a flow chart of the second communication mode in the data communication method provided in the embodiment of the present application.
[0110] As an example, see Fig. 9, assuming that the time interval is set to 500 milliseconds, when the OTA upgrade agent receives the current data frame sent by the OTA upgrade master (such as the "100-199" data frame, indicating the data of the 100th-199th bytes), and determines that it is the first frame based on the current frame identifier of the current data frame, the timer starts to count down for 500 milliseconds. During the countdown of 500 milliseconds, the OTA upgrade agent continues to receive the data message sent by the OTA upgrade master. If the current data frame (such as the "400-499" data frame) received by the OTA upgrade agent is a continuous frame, and the current reception time of the current data frame has reached the preset time interval (500 milliseconds), a third response message (such as "ACK: 500") is returned to the OTA upgrade master, and the third response message includes the frame serial number of the next data frame (indicating the starting message sequence number of the next message).
[0111] Then, the timer continues to count, and the OTA upgrade master continues to send the next data frame (such as the "500-599" data frame, indicating the data of bytes 500-599) to the OTA upgrade agent based on the third response message, until the preset time interval is reached again, and the third response message is returned to the OTA upgrade master. If the current data frame is the last frame, regardless of whether the set time interval is reached, the second response message is returned to the OTA upgrade master, and the second response message includes the frame serial number of the next data frame (indicating the starting message number of the next message).
[0112] The technical solution provided by the embodiment of the present application, during the message transmission process, if the preset time interval is reached, the response result (ACK) is returned to the OTA upgrade master control. If the message is the last frame, it means that the entire data message transmission is completed. Regardless of whether the preset time interval is reached, the ACK is immediately returned to the OTA upgrade master control. This method saves the overhead of responding to the OTA upgrade master control for each transmitted frame and improves the transmission efficiency.
[0113] Fig.10 is a flow chart of another data communication method provided by an embodiment of the present application. Fig.10 The data communication method of the embodiment of the present application can be executed by an OTA upgrade master control, and the method includes the following steps:
[0114] Step S1001, sending the current data frame to the OTA upgrade agent;
[0115] Step S1002: If no response message returned by the OTA upgrade agent for the current data frame is detected, continue to send the next data frame to the OTA upgrade agent;
[0116] Step S1003: if a second response message or a third response message returned by the OTA upgrade agent for the current data frame is detected, determining that the data frame needs to be retransmitted based on the second response message or the third response message;
[0117] Step S1004: sending a retransmission request data frame to the OTA upgrade agent.
[0118] Fig.11 It is a flow chart of the third communication mode in the data communication method provided in the embodiment of the present application.
[0119] As an example, see Fig.11 In the process of the OTA upgrade master sending data messages to the OTA upgrade agent, the OTA upgrade agent can return the confirmation response message (ACK) and the selective confirmation response message (SACK) of the data messages that have been currently received to the OTA upgrade master; in this way, the OTA upgrade master can determine which data messages have been successfully received by the OTA upgrade agent and which data messages have been lost according to the confirmation response message (ACK) and the selective confirmation response message (SACK), and retransmit the lost data messages to the OTA upgrade agent or ECU. For example, when the OTA upgrade agent or ECU returns the confirmation response message of ACK=200 and the selective confirmation response message of SACK=300-500 to the OTA upgrade master, the OTA upgrade master can determine that the data message "200-299" is lost. When the confirmation response message of ACK=200 and the selective confirmation response message of SACK=300-500 are received three times cumulatively, the retransmission mechanism is triggered to retransmit the data message "200-299" to the OTA upgrade agent.
[0120] The above communication method can quickly find the lost data packets and retransmit them, but there is a disadvantage, that is, the OTA upgrade master controller needs to receive the same confirmation message ("confirmation response message and selective confirmation response message") returned by the OTA upgrade agent three times in total before triggering the retransmission mechanism. In this way, when there are many lost data packets, the OTA upgrade agent needs to send confirmation messages to the OTA upgrade master controller multiple times, resulting in large communication overhead and affecting the communication transmission bandwidth.
[0121] In view of this, an embodiment of the present application proposes a fourth data communication method, in which a response message is returned to the OTA upgrade master controller only after it is determined that the current data frame is the tail frame and / or the current reception time of the current data frame has reached the preset time interval. In this way, the problem that the OTA upgrade agent needs to frequently send response messages to the OTA upgrade master controller, resulting in low transmission efficiency and excessive network load can be effectively solved.
[0122] Fig.12It is a flow chart of the fourth data communication mode in the data communication method provided in the embodiment of the present application.
[0123] See also Fig.12 Compared with the third data communication method mentioned above, the fourth data communication method returns a response message to the second device only when it is determined that the current data frame is the end frame (EF), and / or the current reception time of the current data frame has reached the set time interval (such as 500 milliseconds). For example, when the current reception time of the current data frame has reached the preset time interval of 500 milliseconds, a response message (ACK: 300, SACK: 400-500) is returned to the OTA upgrade master. For another example, if the current data frame is determined to be the end frame (EF) based on the current frame identifier, a response message (ACK: 600) is returned to the second device.
[0124] In some embodiments, the above method further includes:
[0125] If a first response message returned by the OTA upgrade agent for the current data frame is detected, and the first response message includes at least the current remaining cache space of the system layer buffer of the OTA upgrade agent, then determining the data length of the next data frame to be sent;
[0126] If the data length of the next data frame is greater than or equal to the current remaining buffer space, a window detection request is sent to the OTA upgrade agent.
[0127] As an example, when the OTA upgrade master receives the first response message returned by the OTA upgrade agent for the current data frame, it determines the data length of the next data frame to be sent, and compares the data length of the next data frame with the size of the current remaining cache space. If the data length of the next data frame is less than the current remaining cache space, it indicates that the current remaining cache space can cache the next data frame; if the data length of the next data frame is greater than or equal to the current remaining cache space, it indicates that the current remaining cache space is insufficient to cache the next data frame, or it is in a "zero window" state after caching the next data frame. At this time, the OTA upgrade master can send a window detection request to the OTA upgrade agent. The window detection request includes the data length of the next data frame. After receiving the window detection request, the OTA upgrade agent can dynamically adjust the current remaining cache space of the system layer buffer according to the data length of the next data frame to meet the needs of the OTA upgrade master to send the next data frame, thereby improving data transmission efficiency.
[0128] All the above optional technical solutions can be arbitrarily combined to form optional embodiments of the present application, which will not be described one by one here.
[0129] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0130] The embodiment of the present application further provides a communication device, the communication device comprising a system layer buffer; the communication device is configured to implement the data communication method of the first aspect. Exemplarily, the communication device may be the second communication device 102.
[0131] The embodiment of the present application further provides another communication device, which is configured to implement the data communication method of the second aspect. Exemplarily, the communication device may be the first communication device 101.
[0132] Fig.13 is a schematic diagram of the architecture of a data communication system provided in an embodiment of the present application. Fig.13 , the data communication system includes a first device 101, a second device 102 and at least one electronic control unit; the first device 101 is connected to the second device 102 and each electronic control unit in communication, and the second device 102 is connected to each electronic control unit in communication; the first device 101 is provided with an OTA upgrade agent, the second device 102 is provided with an OTA upgrade master, and each of the electronic control units is provided with an OTA upgrade slave. The OTA upgrade agent includes a socket server (SOCKET SERVER). The socket client (SOCKET CLIENT) and the socket server (SOCKET SERVER) can be connected via TCP communication; the socket server (SOCKET SERVER) is connected to each OTA upgrade slave. The OTA upgrade master is used to implement the data communication method in the above-mentioned implementation mode to send the current data frame to the OTA upgrade agent. The OTA upgrade agent is used to implement the data communication method in the above-mentioned implementation mode to send the current data frame to the corresponding OTA upgrade slave.
[0133] The OTA upgrade master controller includes a socket client (SOCKET CLIENT), which can include sub-client 1 (CLIENT1), sub-client 2 (CLIENT2), ..., sub-client n (CLIENTn). Generally, one sub-client corresponds to one OTA upgrade slave controller. In other words, the OTA upgrade master controller creates as many sub-clients as the number of ECUs that need to be upgraded.
[0134] In some embodiments, in the scenario where the OTA upgrade master performs upgrade and flashing on the target ECU (such as ECU1-1, ECU1-2, ..., ECU1-n), the OTA upgrade master can create a socket client (SOCKET CLIENT), and create sub-client 1 (CLIENT1), sub-client 2 (CLIENT2), ..., sub-client n (CLIENTn) in the socket client (SOCKET CLIENT), corresponding to the upgrade data transmission of ECU1-1, ECU1-2, ..., ECU1-n respectively. Since ECU1-1, ECU1-2, ..., ECU1-n all support Ethernet (ETH), the link layer (i.e., layer 2) transparent transmission can be performed between the OTA upgrade master and the target ECU (such as ECU1-1, ECU1-2, ..., ECU1-n) through the OTA upgrade agent to establish a TCP communication connection between the OTA upgrade master and the target ECU, and the DOIP protocol is used for data communication transmission and upgrade flashing.
[0135] In other embodiments, in the scenario where the OTA master controller upgrades and flashes the target ECU (such as ECU2-1, ECU2-2, ..., ECU2-n), the OTA upgrade master controller (UMC) can create a socket client (SOCKET CLIENT), and create sub-client 1 (CLIENT1), sub-client 2 (CLIENT2), ..., sub-client n (CLIENTn) in the socket client (SOCKET CLIENT), corresponding to the upgrade data transmission of ECU2-1, ECU2-2, ..., ECU2-n respectively. Since ECU2-1, ECU2-2, ..., ECU2-n do not support Ethernet, the OTA upgrade master controller can establish a TCP communication connection with the OTA upgrade agent, and the OTA upgrade agent receives and parses the ECU target address in the ETH message (Ethernet message) sent by the OTA upgrade master controller, and converts the ETH message into a UDS (Unified diagnostic services) message, and then forwards the UDS message to the target ECU for data communication and upgrade flashing.
[0136] Fig.14 Schematic diagram of an electronic device 14 provided in an embodiment of the present application. Fig.14As shown, the electronic device 14 of this embodiment includes: a processor 1401, a memory 1402, and a computer program 1403 stored in the memory 1402 and executable on the processor 1401. When the processor 1401 executes the computer program 1403, the steps in the above-mentioned method embodiments are implemented. Alternatively, when the processor 1401 executes the computer program 1403, the functions of the modules / units in the above-mentioned device embodiments are implemented.
[0137] The electronic device 14 may be a desktop computer, a notebook, a PDA, a cloud server, or other electronic device. The electronic device 14 may include, but is not limited to, a processor 1401 and a memory 1402. Those skilled in the art will appreciate that Fig.14 The electronic device 14 is merely an example and does not limit the electronic device 14 , and may include more or less components than those shown in the figure, or different components.
[0138] The processor 1401 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
[0139] The memory 1402 may be an internal storage unit of the electronic device 14, for example, a hard disk or memory of the electronic device 14. The memory 1402 may also be an external storage device of the electronic device 14, for example, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card (FlashCard), etc. equipped on the electronic device 14. The memory 1402 may also include both an internal storage unit of the electronic device 14 and an external storage device. The memory 1402 is used to store computer programs and other programs and data required by the electronic device.
[0140] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units.
[0141] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium (such as a computer-readable storage medium). Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. The computer program may include computer program code, which may be in source code form, object code form, executable file or some intermediate form. The computer-readable storage medium may include: any entity or device capable of carrying computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc.
[0142] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application 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. 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 embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A data communication method, characterized in that: Applied to an OTA upgrade agent, the OTA upgrade agent includes a system layer buffer; The method comprises the following steps: Obtain a current data frame sent by the OTA upgrade master, and determine a required cache space for the current data frame; If the required buffer space of the current data frame is less than the current remaining buffer space of the system layer buffer, the current data frame is cached in the system layer buffer; If the required buffer space of the current data frame is greater than or equal to the current remaining buffer space of the system layer buffer, or a window detection request initiated by the OTA upgrade master controller is detected, a first response message is returned to the OTA upgrade master controller, where the first response message includes at least the current remaining buffer space of the system layer buffer; After obtaining the current data frame sent by the OTA upgrade master, it also includes: Determining a current frame identifier in the current data frame; If the current data frame is determined to be the last frame based on the current frame identifier, a second response message is returned to the OTA upgrade master control, wherein the second response message includes the frame serial number of the next data frame and a data frame message, and the data frame message indicates all data frames that have been successfully received.
2. The method according to claim 1, characterized in that The OTA upgrade agent also includes an application layer buffer; the method further includes: Establishing a cache mapping relationship between the system layer buffer and the application layer buffer; the system layer buffer refers to the window buffer, and the application layer buffer refers to the user application ring buffer; Alternatively, the current data frame is synchronously written into the application layer buffer, and when all the current data frames have been written into the application layer buffer, the current data frame cached in the system layer buffer is cleared, and a cache mapping relationship between the system layer buffer and the application layer buffer is established; Alternatively, the current data frame is synchronously written into the application layer buffer, and a cache mapping relationship between the system layer buffer and the application layer buffer is established.
3. The method according to claim 1, characterized in that After determining the current frame identifier in the current data frame, the method further includes: Determining a current reception time of the current data frame; If the current receiving time reaches the set time interval, a third response message is returned to the OTA upgrade master control, wherein the third response message includes the frame serial number of the next data frame and a data frame message, and the data frame message indicates all data frames that have been successfully received.
4. A data communication method, characterized in that: Applied to OTA upgrade of main control, the method includes: Send the current data frame to the OTA upgrade agent; If no response message returned by the OTA upgrade agent for the current data frame is detected, continue to send the next data frame to the OTA upgrade agent; If a second response message or a third response message returned by the OTA upgrade agent for the current data frame is detected, determining that the data frame needs to be retransmitted based on the second response message or the third response message; Sending the required retransmission data frame to the OTA upgrade agent; If a first response message returned by the OTA upgrade agent for the current data frame is detected, determining a data length of a next data frame to be sent, the first response message including at least a current remaining cache space of a system layer buffer of the OTA upgrade agent; If the data length of the next data frame is greater than or equal to the current remaining buffer space, a window detection request is sent to the OTA upgrade agent.
5. A data communication system, characterized in that: include: A first device, a second device and at least one electronic control unit; the first device is communicatively connected with the second device and each electronic control unit, and the second device is communicatively connected with each electronic control unit; The first device is provided with an OTA upgrade agent, the second device is provided with an OTA upgrade master control, and each of the electronic control units is provided with an OTA upgrade slave control; The OTA upgrade master control includes a socket client, and the socket client includes at least one sub-client; The OTA upgrade agent includes a socket server; The socket client is connected in communication with the socket server; the socket server is connected in communication with each of the OTA upgrade slave controllers; The OTA upgrade master is used to implement the data communication method according to claim 4 to send the current data frame to the OTA upgrade agent; The OTA upgrade agent is used to implement the data communication method of any one of claims 1 to 3 to send the current data frame to the corresponding OTA upgrade slave controller.
6. A communication device, characterized in that: The communication device comprises a system layer buffer; the communication device is configured to implement the data communication method according to any one of claims 1 to 3.
7. A communication device, characterized in that: The communication device is configured to implement the data communication method according to claim 4.
8. A readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 4 are implemented.
Citation Information
Patent Citations
CAN bus data transmission method
CN101764730A
Vehicle body controller firmware upgrading method, terminal and system
CN110377307A
Method and system for improving data transmission reliability, equipment and storage medium
CN113852445A