Data transmission method and device

By introducing heartbeat packets to generate challenging data and dynamic encryption algorithms in vehicle data transmission, the problem of data transmission security risks in the prior art is solved, and the accuracy of vehicle fault diagnosis and data transmission security is achieved.

CN119182532APending Publication Date: 2024-12-24CHONGQING SELIS PHOENIX INTELLIGENT INNOVATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411153173.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-21
Publication Date
2024-12-24

AI Technical Summary

Technical Problem

The existing vehicle data transmission methods have security risks and cannot guarantee the safe transmission of data, resulting in the inability to accurately diagnose vehicle failures and are vulnerable to replay attacks and man-in-the-middle attacks.

Method used

After the data transmission is completed, challenge data is generated through the heartbeat packet, a two-way challenge response mechanism is implemented, and encryption algorithms are dynamically selected to verify the connection status and identity, ensuring the security and integrity of data transmission.

Benefits of technology

Through the two-way challenge response mechanism and dynamic encryption algorithm selection, the security of data transmission is improved, the playback attacks and man-in-the-middle attacks are prevented, the security and integrity of data during transmission is ensured, and the accuracy of vehicle fault diagnosis is ensured. .

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119182532A_ABST
    Figure CN119182532A_ABST
Patent Text Reader

Abstract

The invention relates to a data transmission method and device, the method is applied to a first device, and the method comprises the steps: sending a heartbeat packet to a second device under the condition that data transmission with the second device is completed, so that the second device generates challenge data according to the heartbeat packet, and sends the challenge data to the first device, the second equipment is different from the first equipment; receiving challenge data sent by the second device, and generating response data corresponding to the challenge data; and sending the response data to the second equipment, so that the second equipment keeps connection with the first equipment under the condition that the second equipment determines that a preset connection condition is met currently according to the response data so as to continue data transmission with the first equipment. Therefore, the security of data transmission can be improved, replay attacks and man-in-the-middle attacks are prevented, and the security and integrity of the data in the transmission process are ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of vehicle technology, and in particular to a data transmission method and device. Background Art

[0002] With the popularization and development of vehicles, vehicles are prone to various fault conditions. For the analysis of vehicle fault conditions, the on-board automatic diagnostic system can generally interact with the vehicle's controller to determine the vehicle's fault based on the vehicle's operating data.

[0003] In actual applications, when the on-board automatic diagnostic system transmits data with the vehicle controller, it generally uses a heartbeat packet to maintain the connection between the two after the data transmission is completed.

[0004] However, the above traditional heartbeat mechanism is usually only used to monitor the connection status, which is easily threatened by replay attacks and man-in-the-middle attacks during the monitoring process. Therefore, the existing data transmission method has certain security risks, which makes it impossible to ensure the safe transmission of data and thus make it impossible to accurately diagnose vehicle faults. Summary of the invention

[0005] The present application provides a data transmission method and device to solve the technical problem that the data transmission method in the prior art has certain safety hazards, resulting in the inability to ensure the safe transmission of data and thus the inability to accurately diagnose vehicle faults.

[0006] In a first aspect, the present application provides a data transmission method, which is applied to a first device, and the method includes:

[0007] When data transmission with a second device is completed, sending a heartbeat packet to the second device, so that the second device generates challenge data according to the heartbeat packet, and sends the challenge data to the first device, where the second device is a device different from the first device;

[0008] receiving the challenge data sent by the second device, and generating response data corresponding to the challenge data;

[0009] The response data is sent to the second device, so that the second device maintains connection with the first device when determining according to the response data that a preset connection condition is currently met, so as to continue data transmission with the first device.

[0010] As a possible implementation manner, data transmission is performed with the second device in the following manner:

[0011] Acquire network parameters for data transmission between the second device;

[0012] Determining a target encryption algorithm from a plurality of preset encryption algorithms according to the network parameters;

[0013] Data is transmitted with the second device based on the target encryption algorithm.

[0014] As a possible implementation, determining the target encryption algorithm from a plurality of preset encryption algorithms according to the network parameters includes:

[0015] Determining, based on the network parameters, network performance currently performing data transmission with the second device;

[0016] According to the network performance, a target encryption algorithm corresponding to the network performance is determined from a preset correspondence relationship between the network performance and the encryption algorithm.

[0017] As a possible implementation manner, the performing data transmission with the second device based on the target encryption algorithm includes:

[0018] Encrypting the first data to be transmitted by using the target encryption algorithm to obtain first encrypted data;

[0019] The first encrypted data and the target encryption algorithm are sent to the second device, the second device is used to receive the first encrypted data and the target encryption algorithm, and use the target encryption algorithm to decrypt the first encrypted data to obtain first target data, and use the target encryption algorithm to encrypt second data to be transmitted corresponding to the first target data to obtain second encrypted data, and send the second encrypted data to the first device;

[0020] The second encrypted data sent by the second device is received, and the second encrypted data is decrypted using the target encryption algorithm to obtain second target data corresponding to the second encrypted data.

[0021] As a possible implementation, in the process of data transmission based on the target encryption algorithm, the following is also included:

[0022] Upon receiving a new target encryption algorithm sent by a second device, data transmission is performed based on the new target encryption algorithm, wherein the second device detects new network parameters for data transmission with the first device in real time or periodically, determines a new target encryption algorithm based on the new network parameters, and sends the new target encryption algorithm to the first device.

[0023] As a possible implementation manner, the receiving the challenge data sent by the second device and generating response data corresponding to the challenge data includes:

[0024] Determine the target function, wherein the second device, after receiving the heartbeat packet sent by the first device, obtains the heartbeat packet data of the heartbeat packet, and calculates the heartbeat packet data using the target function to obtain the challenge data;

[0025] Calculating the challenge data using the objective function to obtain response data corresponding to the challenge data;

[0026] The second device determines that the preset connection condition is currently satisfied according to the response data in the following manner:

[0027] Calculating the challenge data using the objective function to obtain target response data;

[0028] When it is compared that the response data is consistent with the target response data, it is determined that the preset connection condition is currently met.

[0029] As a possible implementation manner, the second device calculates the heartbeat packet data using the objective function to obtain challenge data, including:

[0030] Get the current timestamp;

[0031] Calculating the heartbeat packet data and the timestamp using the objective function to obtain the challenge data;

[0032] The second device sending the challenge data to the first device includes:

[0033] The challenge data and the timestamp are sent to the first device.

[0034] As a possible implementation, the using the objective function to calculate the challenge data to obtain the response data corresponding to the challenge data includes:

[0035] Obtain the challenge data, the timestamp, and the target heartbeat packet data of the previous heartbeat packet currently recorded;

[0036] Calculating the challenge data, the timestamp, and the target heartbeat packet data using the objective function to obtain the response data;

[0037] The second device calculates the challenge data using the target function to obtain target response data, including:

[0038] Obtain the heartbeat packet data and timestamp for generating the challenge data;

[0039] The target function is used to calculate the heartbeat packet data, the timestamp, and the challenge data to obtain the target response data.

[0040] As a possible implementation manner, before the second device generates the challenge data according to the heartbeat packet, the second device further includes:

[0041] Determine the number of the heartbeat packets currently received;

[0042] Determining whether the quantity is greater than a preset quantity threshold;

[0043] In case it is determined that the number is greater than the number threshold, the step of generating challenge data according to the heartbeat packet is performed.

[0044] In a second aspect, the present application provides a data transmission device, applied to a first device, the device comprising:

[0045] a first sending module, configured to send a heartbeat packet to a second device when data transmission with the second device is completed, so that the second device generates challenge data according to the heartbeat packet and sends the challenge data to the first device, wherein the second device is a device different from the first device;

[0046] A receiving module, configured to receive the challenge data sent by the second device and generate response data corresponding to the challenge data;

[0047] The second sending module is used to send the response data to the second device, so that the second device maintains the connection with the first device when determining that the preset connection condition is currently met according to the response data, so as to continue to transmit data with the first device.

[0048] In a third aspect, the present application provides a vehicle, comprising: a processor and a memory, wherein the processor is used to execute a data transmission program stored in the memory to implement the data transmission method described in any one of the first aspects.

[0049] In a fourth aspect, the present application provides a storage medium storing one or more programs, wherein the one or more programs can be executed by one or more processors to implement the data transmission method described in any one of the first aspects.

[0050] The technical solution provided by the embodiment of the present application is to send a heartbeat packet to the second device when data transmission is completed with the second device, so that the second device generates challenge data according to the heartbeat packet and sends the challenge data to the first device. The second device is a device different from the first device, receives the challenge data sent by the second device, generates response data corresponding to the challenge data, and sends the response data to the second device, so that the second device maintains the connection with the first device when it determines that the preset connection conditions are currently met according to the response data, so as to continue to transmit data with the first device. This technical solution realizes a two-way challenge response mechanism between the two devices by generating challenge data according to the heartbeat packet when the connection status is monitored through the heartbeat packet when the first device and the second device complete the data transmission, so that not only the activity of the verification connection can be maintained, but also the identity and integrity of the communicating parties can be verified, so as to improve the security of data transmission, prevent replay attacks and man-in-the-middle attacks, and ensure the security and integrity of data during transmission. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0052] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings required for use in the embodiments or the prior art texts are briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0053] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.

[0054] Figure 1 A flowchart of an embodiment of a data transmission method provided in an embodiment of the present application;

[0055] Figure 2 A schematic diagram of a flow chart of data transmission between a vehicle diagnostic device and a vehicle controller in the prior art provided in an embodiment of the present application;

[0056] Figure 3 A flowchart of another data transmission method provided in an embodiment of the present application;

[0057] Figure 4 A flowchart of another data transmission method provided in an embodiment of the present application;

[0058] Figure 5 A flowchart of another data transmission method provided in the present application;

[0059] Figure 6 A block diagram of an embodiment of a data transmission device provided in an embodiment of the present application;

[0060] Figure 7 A schematic diagram of the structure of a vehicle provided in an embodiment of the present application. DETAILED DESCRIPTION

[0061] In order to make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described in conjunction with the drawings in the embodiments of the present application. Obviously, the embodiments described in the text are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0062] The disclosure below provides many different embodiments or examples to realize the different structures of the present application. In order to simplify the disclosure of the present application, the parts and settings of specific examples are described in detail below. Of course, they are only examples, and the purpose is not to limit the present application. In addition, the present application can repeat reference numbers and / or letters in different examples. This repetition is for the purpose of simplification and clarity, and does not itself indicate the relationship between the various embodiments and / or settings discussed.

[0063] In order to solve the technical problem that the data transmission method in the prior art has certain security risks, which makes it impossible to ensure the safe transmission of data and thus cannot accurately diagnose the vehicle fault, the present application provides a data transmission method and device, which can achieve a two-way challenge response mechanism between the two devices by generating challenge data according to the heartbeat packet when the connection status is monitored through the heartbeat packet when the first device and the second device complete the data transmission, thereby not only maintaining the activity of the verification connection, but also verifying the identity and integrity of the communicating parties, thereby improving the security of data transmission, preventing replay attacks and man-in-the-middle attacks, and ensuring the security and integrity of data during transmission.

[0064] The data transmission method provided by the present application is further explained below with reference to specific embodiments in conjunction with the accompanying drawings. The embodiments do not constitute a limitation on the embodiments of the present application.

[0065] See also Figure 1 , is a flow chart of an embodiment of a data transmission method provided in an embodiment of the present application. As an embodiment, Figure 1 The process shown can be applied to the first device. Figure 1 As shown, the process may include the following steps:

[0066] Step 101: When data transmission with a second device is completed, a heartbeat packet is sent to the second device, so that the second device generates challenge data according to the heartbeat packet and sends the challenge data to the first device, where the second device is a device different from the first device.

[0067] The above-mentioned first device refers to a device that needs to transmit data, which can be a client (it can be a diagnostic device in a vehicle diagnostic system) or a server (it can be a vehicle controller in a vehicle diagnostic system). The embodiment of the present application does not impose any restrictions on this.

[0068] In practical applications, the first device and the second device generally need to perform data transmission according to business requirements, and after the data transmission is completed, the connection between the two needs to be monitored and maintained through a heartbeat mechanism. For example, in a vehicle diagnostic system, the vehicle diagnostic device (such as the vehicle OBD (OnBoard Diagnostics)) needs to perform data transmission with the vehicle controller to obtain the vehicle's operating data, so as to diagnose the vehicle fault in time, and after the diagnosis is completed, the diagnostic device and the controller maintain a connection through a heartbeat packet.

[0069] For example, see Figure 2 , is a schematic diagram of a flow chart of data transmission between a vehicle diagnostic device and a vehicle controller in the prior art provided by an embodiment of the present application. Figure 2 As shown, data transmission between the vehicle OBD and the vehicle controller may include three parts: access authentication, data transmission, and heartbeat connection.

[0070] Among them, access authentication realizes the first line of defense for vehicle diagnosis. After OBD design, gateways and other ECUs (electronic control units) have two modes, user mode and engineering mode. In user mode, before OBD access authentication is passed, the ECU will not execute or forward UDS instructions (except authentication instructions and data required by regulations); after OBD access authentication, the ECU enters engineering mode, and the ECU executes or forwards diagnostic instructions input from the OBD port. After passing the authentication, the diagnostic instrument and ECU also need to maintain the heartbeat packet.

[0071] Furthermore, the diagnostic device authenticates the ECU device by sending an authentication request (ie, first request data), and after the ECU device successfully authenticates the diagnostic device, it may send authentication response data (ie, first response data) to the diagnostic device to notify the diagnostic device that the authentication is successful.

[0072] After that, when the diagnostic device and the ECU device are authenticated, the diagnostic device can start to transmit data with the ECU device and use a fixed encryption method (such as CMAC (Cipher-Based Message Authentication Code) algorithm) for encryption. For example, when transmitting data, the diagnostic device uses the CMAC algorithm to encrypt the data to be transmitted randc using the key key to obtain the authentication code rands, and sends the CMAC algorithm, key key, the data to be transmitted randc, and the authentication code rands to the ECU device.

[0073] Afterwards, the ECU device encrypts the data to be transmitted randc using the key key according to the CMAC algorithm, obtains a new authentication code, and sends the new authentication code to the diagnostic device. When the diagnostic device compares the new authentication code with the authentication code rands and finds that they are consistent, it means that the data is complete and has not been tampered with.

[0074] Finally, after completing data transmission with the WCU device, the diagnostic device can maintain the connection status between the two through heartbeat packets.

[0075] However, the existing heartbeat mechanism is usually only used to monitor the connection status between two devices, and it cannot authenticate the identity between the two devices. This makes it vulnerable to replay attacks and man-in-the-middle attacks during the monitoring process, thereby failing to guarantee the secure transmission of data. Furthermore, in the application process of the vehicle diagnostic system, it is impossible to accurately diagnose the vehicle's faults.

[0076] In this regard, after completing data transmission with the second device, the first device can send a heartbeat packet to the second device, and after receiving the heartbeat packet, the second device can generate challenge data according to the heartbeat packet and send the challenge data to the first device, so that the first device can be authenticated. The second device is a device different from the first device, for example, if the first device is a client, then the second device can be a server, and for another example, if the first device is a server, then the second device can be a client.

[0077] As a possible implementation manner, the first device may use the preset data as the heartbeat packet data, and send a heartbeat packet including the above heartbeat packet data to the second device.

[0078] As another possible implementation, the second device may randomly generate data, and use the generated random data as heartbeat packet data, and send a heartbeat packet containing the heartbeat packet data to the second device.

[0079] Based on this, after receiving the heartbeat packet sent by the first device, the second device can first obtain the heartbeat packet data corresponding to the received heartbeat packet, and use the target function to calculate the above heartbeat packet data to obtain the challenge data. The above target function can be a hash function (such as SHA256) or other functions, which is not limited in the embodiments of the present application.

[0080] As an optional implementation manner, the second device may randomly select a function from a plurality of pre-stored functions as a target function, and use the target function to calculate the heartbeat packet data to obtain challenge data.

[0081] As another optional implementation, the second device may pre-store a function input by the user, and use the function as a target function to calculate the heartbeat packet data to obtain challenge data.

[0082] As for how to use the objective function to calculate the heartbeat packet data and obtain the challenge data, it can be seen in the following Figure 3 The process shown is explained and will not be described in detail here.

[0083] In one embodiment, in an environment where extreme security measures are not required, in order to reduce computing and communication overhead, in an embodiment of the present application, interval conditions may be set for heartbeat packet challenges, such as generating a heartbeat packet challenge every preset number (e.g., 6) of heartbeat packets, or generating a heartbeat packet challenge every preset time period.

[0084] As an optional implementation, before generating challenge data according to the heartbeat packet, the second device may determine the number of heartbeat packets currently received, and determine whether the number is greater than a preset number threshold.

[0085] Optionally, when it is determined that the number is greater than the number threshold, it means that the above interval condition is currently met, and therefore, the step of generating challenge data according to the heartbeat packet can be executed.

[0086] On the contrary, when it is determined that the number is less than or equal to the number threshold, it means that the above interval condition is not met at present. Therefore, a heartbeat packet can be responded to the first device according to the normal heartbeat mechanism to maintain the connection with the first device.

[0087] As another optional implementation, before generating challenge data according to the heartbeat packet, the second device may determine the time interval from the current time to the last time the challenge data was generated, and determine whether the time interval is greater than a preset time interval threshold.

[0088] Optionally, when it is determined that the time interval is greater than the time interval threshold, it indicates that the above interval condition is currently met, and therefore, the step of generating challenge data according to the heartbeat packet may be executed.

[0089] On the contrary, when it is determined that the time interval is less than or equal to the time interval threshold, it means that the above interval condition is not met currently. Therefore, a heartbeat packet can be responded to the first device according to the normal heartbeat mechanism to maintain the connection with the first device.

[0090] In addition, in order to further ensure the security and efficiency of data transmission between the first device and the second device, in an embodiment of the present application, the first device and the second device can dynamically select an encryption algorithm when performing data transmission.

[0091] As for how the first device and the second device dynamically select encryption algorithms for data transmission, it can be seen in the following Figure 4 The process shown is explained and will not be described in detail here.

[0092] Step 102: Receive challenge data sent by the second device, and generate response data corresponding to the challenge data.

[0093] Step 103: Send the response data to the second device, so that the second device maintains connection with the first device when determining that the preset connection condition is currently met according to the response data, so as to continue data transmission with the first device.

[0094] The following is a unified description of step 102 and step 103:

[0095] From the above description, it can be seen that in order to further authenticate the first device, after receiving the heartbeat packet, the second device can use the heartbeat packet data to generate challenge data, and send the challenge data to the first device. Based on this, after receiving the challenge data, the first device can generate corresponding response data according to the challenge data to complete the challenge and verify the accuracy of the identity.

[0096] As an optional implementation method, it can be seen from the description in step 101 that the second device uses the objective function to calculate the heartbeat packet data to obtain the challenge data. Based on this, the first device can determine the objective function of the second device to generate the challenge data, and use the objective function to calculate the challenge data to obtain the response data corresponding to the challenge data.

[0097] As for how to use the objective function to calculate the challenge data and obtain the response data corresponding to the challenge data, it can be seen in the following Figure 3 The process shown is described.

[0098] After the first device generates response data corresponding to the challenge data, the response data can be sent to the second device. Based on this, after receiving the response data sent by the first device, the second device can determine whether the preset connection conditions are currently met according to the above response data, and if it is determined that the preset connection conditions are currently met, maintain the connection with the first device, thereby continuing to transmit data with the first device.

[0099] As an optional implementation, when the second device generates challenge data using the objective function, and the first device generates response data corresponding to the challenge data using the objective function, the second device may continue to recalculate the challenge data using the objective function to obtain target response data.

[0100] Afterwards, the second device may compare the target response data with the response data received from the first device.

[0101] Optionally, when the received response data is compared and found to be consistent with the target response data, it means that the response data generated by the first device to the challenge data meets the response standard of the second device to the challenge data, and the first device is a legitimate device for data transmission with the second device. Therefore, it can be determined that the preset connection conditions are currently met.

[0102] As for how to use the objective function to recalculate the challenge data and obtain the target response data, it can be seen in the following Figure 3 The process shown is explained and will not be described in detail here.

[0103] The technical solution provided by the embodiment of the present application is to send a heartbeat packet to the second device when data transmission is completed with the second device, so that the second device generates challenge data according to the heartbeat packet and sends the challenge data to the first device. The second device is a device different from the first device, receives the challenge data sent by the second device, generates response data corresponding to the challenge data, and sends the response data to the second device, so that the second device maintains the connection with the first device when it determines that the preset connection conditions are currently met according to the response data, so as to continue to transmit data with the first device. This technical solution realizes a two-way challenge response mechanism between the two devices by generating challenge data according to the heartbeat packet when the connection status is monitored through the heartbeat packet when the first device and the second device complete the data transmission, so that not only the activity of the verification connection can be maintained, but also the identity and integrity of the communicating parties can be verified, so as to improve the security of data transmission, prevent replay attacks and man-in-the-middle attacks, and ensure the security and integrity of data during transmission.

[0104] See also Figure 3 , is a flow chart of another embodiment of a data transmission method provided in an embodiment of the present application. Figure 1 As shown, the process may include the following steps:

[0105] Step 301: When the first device completes data transmission with the second device, the first device sends a heartbeat packet to the second device.

[0106] For a detailed description of step 301, please refer to the description of step 101, which will not be repeated here.

[0107] Step 302: When receiving the heartbeat packet, the second device obtains the heartbeat packet data and the current timestamp of the heartbeat packet.

[0108] Step 303: The second device calculates the heartbeat packet data and the timestamp using the objective function to obtain challenge data.

[0109] Step 304: The second device sends the challenge data and timestamp to the first device.

[0110] The following is a unified description of steps 302 to 304:

[0111] In an embodiment of the present application, when the second device receives a heartbeat packet sent by the first device and generates challenge data based on the heartbeat packet, in order to ensure the uniqueness of the generated challenge data, it can obtain the timestamp of the current system and use a determined objective function to calculate the heartbeat packet data and timestamp of the heartbeat packet, thereby generating challenge data.

[0112] As an exemplary implementation, the target function may be a hash function (such as SHA256), and the heartbeat packet data may be a random number generated by the first device. Based on this, the second device may use the hash function to calculate the hash value of the random number and the timestamp, and determine the hash value as the challenge data.

[0113] Step 305: The first device determines the target function and obtains the challenge data, timestamp, and target heartbeat packet data of the previous heartbeat packet currently recorded.

[0114] Step 306: The first device calculates the challenge data, the timestamp, and the target heartbeat packet data using the target function to obtain response data, and sends the response data to the second device.

[0115] The following is a unified description of step 305 and step 306:

[0116] The target heartbeat packet data refers to the heartbeat packet data corresponding to the most recently sent heartbeat packet sent by the first device, that is, the heartbeat packet data used by the second device to generate challenge data.

[0117] In an embodiment of the present application, each time the first device sends a heartbeat packet to the second device, it can record the sending time and heartbeat packet data of the heartbeat packet. Based on this, when the first device receives the challenge data sent by the second device, it can obtain the target heartbeat packet data last sent to the second device, and use the determined objective function to calculate the target heartbeat packet data, the received challenge data, and the received timestamp to obtain the response data corresponding to the challenge data.

[0118] As an exemplary implementation, the above-mentioned target function may be a hash function (such as SHA256), and the above-mentioned heartbeat packet data may be a random number generated by the first device. Based on this, the first device may use the above-mentioned hash function to calculate the hash value of the above-mentioned random number, timestamp, and challenge data (that is, the hash value of the random number and timestamp), and determine the hash value as the response data of the challenge data.

[0119] Step 307: When receiving the response data, the second device obtains the heartbeat packet data and timestamp for generating the challenge data.

[0120] Step 308: The second device uses the target function to calculate the heartbeat packet data, the timestamp, and the challenge data to obtain target response data.

[0121] Step 309: When the second device finds that the target response data is consistent with the received response data, the second device maintains the connection with the first device to continue data transmission with the first device.

[0122] The following is a unified description of steps 307 to 309:

[0123] In the embodiment of the present application, after receiving the response data of the first device to the challenge data, the second device can use the target function to calculate the heartbeat packet data, timestamp and challenge data again to verify whether the response data is accurate, so as to obtain the target response data. Afterwards, the target response data and the received response data can be compared to see if they are consistent. Since the above heartbeat packet data only has the first device and the second device, if the comparison shows that the target response data and the response data are consistent, it means that the first device is a legitimate device, so the connection with the first device can be maintained to continue data transmission with the first device.

[0124] Optionally, if the comparison shows that the target response data and the response data are inconsistent, it means that the first device is not a legitimate device for data transmission with the second device, and thus the connection with the first device can be disconnected.

[0125] As an optional implementation method, when the second device receives the response data, it can first obtain the heartbeat packet data and timestamp for generating the challenge data, and then use the target function to calculate the heartbeat packet data, timestamp, and challenge data to obtain the target response data.

[0126] As an exemplary implementation, the above-mentioned target function may be a hash function (such as SHA256), and the above-mentioned heartbeat packet data may be a random number generated by the first device. Based on this, the second device may use the above-mentioned hash function to calculate the hash value of the above-mentioned random number, timestamp, and challenge data (that is, the hash value of the random number and timestamp), and determine the hash value as the target response data.

[0127] It should be noted that the objective function used by the first device and the second device is a unified function, and the embodiments of the present application do not limit the specific content of the objective function.

[0128] The technical solution provided by the embodiment of the present application is that the first device sends a heartbeat packet to the second device when the data transmission with the second device is completed. When the second device receives the heartbeat packet, it obtains the heartbeat packet data and the current timestamp of the heartbeat packet. The second device calculates the heartbeat packet data and the timestamp using the target function to obtain the challenge data. The second device sends the challenge data and the timestamp to the first device. The first device determines the target function and obtains the challenge data, the timestamp, and the target heartbeat packet data of the previous heartbeat packet currently recorded. The first device calculates the challenge data, the timestamp, and the target heartbeat packet data using the target function to obtain the response data, and sends the response data to the second device. When the second device receives the response data, it obtains the heartbeat packet data and the timestamp for generating the challenge data. The second device calculates the heartbeat packet data, the timestamp, and the challenge data using the target function to obtain the target response data. When the second device compares that the target response data is consistent with the received response data, it maintains the connection with the first device to continue the data transmission with the first device. This technical solution uses the target function to calculate the challenge data on the heartbeat packet data and timestamp by the second device, so that the first device also uses the target function to calculate the heartbeat packet data, timestamp, and challenge data based on the heartbeat packet data and timestamp to obtain the corresponding response data. After that, the first device calculates the target response data in the same way, and the heartbeat packet data can only be obtained by the first device and the second device. Then, when it is determined that the response data is consistent with the target response data, it means that the first device is a legitimate device, so the connection can be maintained, and efficient and accurate challenge verification between the first device and the second device is achieved, thereby verifying the identity and integrity of the communicating parties, improving the security of data transmission, preventing replay attacks and man-in-the-middle attacks, and ensuring the security and integrity of data during transmission.

[0129] See also Figure 4 , which is a flow chart of another embodiment of a data transmission method provided in an embodiment of the present application. Figure 4 The process shown in Figure 1 Based on the process shown, it is described how the first device specifically completes data transmission with the second device. Figure 4 As shown, the process may include the following steps:

[0130] Step 401: Acquire network parameters for data transmission with a second device.

[0131] Step 402: Determine a target encryption algorithm from a plurality of preset encryption algorithms according to network parameters.

[0132] The following is a unified description of step 401 and step 402:

[0133] The above network parameters are used to characterize the network performance of data transmission between the first device and the second device through the network, wherein the higher the network performance, the faster the rate of data transmission through the network and the higher the quality. The above network parameters may include but are not limited to: network bandwidth, network delay, and data packet loss rate, etc.

[0134] In an embodiment of the present application, when the first device transmits data with the second device through a network, the first device can obtain current network parameters and determine a target encryption algorithm from a plurality of preset encryption algorithms based on the network parameters.

[0135] As an optional implementation method, the correspondence between network performance and encryption algorithm can be pre-stored in the first device. Based on this, the first device can determine the network performance for data transmission between the current first device and the second device according to the above-mentioned network parameters, and determine the target encryption algorithm from the correspondence between the above-mentioned network performance and encryption algorithm according to the network performance.

[0136] As an exemplary implementation, the above-mentioned network parameter may be network delay. Furthermore, when the first device and the second device transmit data, if the network delay exceeds a certain threshold (for example, 100 milliseconds), it means that the network performance transmission at this time is slow, so you can switch to a lighter encryption algorithm, such as ChaCha20, to reduce data processing time; if the network delay does not exceed the threshold, it means that the network performance transmission at this time is fast, so you can choose an encryption algorithm with a higher encryption level, such as AES128.

[0137] As another exemplary embodiment, the above-mentioned network parameter may be a data packet loss rate. Furthermore, when the data packet loss rate exceeds a preset threshold (for example, 5%), it indicates that the network performance is unstable at this time, and therefore an encryption algorithm with stronger error recovery capability may be selected; when the data packet loss rate does not exceed the above-mentioned preset threshold, it indicates that the network performance is relatively stable at this time, and therefore an encryption algorithm with a higher encryption level may be selected, such as AES128.

[0138] As another exemplary embodiment, the above-mentioned network parameter may be the network bandwidth. Furthermore, if the detected network bandwidth is lower than a preset threshold (for example, below 1 Mbps), it means that the network performance at this time is characterized by a low data transmission volume. Therefore, an encryption algorithm with a lower computational complexity can be used to reduce the data transmission volume; if the detected network bandwidth is higher than or equal to the preset threshold, it means that the network performance at this time is characterized by a high data transmission volume. Therefore, an encryption algorithm with a higher encryption level can be selected, such as AES128.

[0139] Furthermore, the above encryption algorithms may include but are not limited to the following encryption algorithms: lightweight encryption algorithms: AES128, SPECK, ChaCha20; strong recovery encryption algorithms: RSA, ReedSolomon encoding; computationally complex low encryption algorithms: XXTEA, Salsa20 / ChaCha, etc.

[0140] Step 403: Transmit data with the second device based on the target encryption algorithm.

[0141] It can be seen from the above description that the first device can determine the target encryption algorithm from a plurality of preset encryption algorithms according to the network parameters for data transmission with the second device.

[0142] Based on this, after determining the target encryption algorithm, the first device can transmit data with the second device based on the target encryption algorithm.

[0143] As an optional implementation, the first data to be transmitted may be encrypted using a target encryption algorithm to obtain first encrypted data. The first data to be transmitted refers to data to be transmitted from the first device to the second device.

[0144] Afterwards, the first encrypted data and the target encryption algorithm can be sent to the second device. Based on this, after receiving the first encrypted data and the target encryption algorithm, the second device can use the target encryption algorithm to decrypt the first encrypted data to obtain the first target data, and use the target encryption algorithm to encrypt the second data to be transmitted corresponding to the first target data to obtain the second encrypted data. Afterwards, the second encrypted data can be sent to the first device. The second data to be transmitted is the data to be transmitted by the second device to the first device.

[0145] Thereafter, after receiving the second encrypted data sent by the second device, the first device may use the above-mentioned target encryption algorithm to decrypt the second encrypted data to obtain second target data corresponding to the second encrypted data.

[0146] In addition, for the above process of determining the target encryption algorithm, since the network environment for data transmission is constantly changing, the determination of the target encryption algorithm can be determined by both the first device and the second device. That is, when the first device determines the target encryption algorithm and performs data transmission based on the target encryption algorithm, the second device can also detect the new network parameters for data transmission with the first device in real time or at regular intervals, and determine the new target encryption algorithm based on the above new network parameters. For the determination of the target encryption algorithm, please refer to the above steps 401 and 402, which will not be repeated here.

[0147] Afterwards, the second device may send the determined new target encryption algorithm to the first device. Based on this, when the first device receives the new target encryption algorithm sent by the second device, it may perform data transmission with the second device based on the new target encryption algorithm.

[0148] The technical solution provided in the embodiment of the present application obtains the network parameters for data transmission between the second device, determines the target encryption algorithm from multiple preset encryption algorithms according to the network parameters, and transmits data with the second device based on the target encryption algorithm. This technical solution dynamically selects the most suitable encryption algorithm according to the real-time network parameters to optimize security and communication efficiency, and can ensure that efficient and secure data transmission can be maintained in different network environments. For example, a high-security algorithm is used when the network is stable, and a more efficient algorithm is switched when the network is unstable, thereby optimizing resource usage and reducing delays, and achieving efficient and secure data transmission.

[0149] See also Figure 5 , which is a flow chart of an embodiment of another data transmission method provided in an embodiment of the present application. Figure 5 The process shown takes the first device as a vehicle diagnostic device and the second device as a vehicle ECU device as an example to illustrate the data transmission method provided in the embodiment of the present application. Figure 5 As shown, the process may include the following steps:

[0150] (1) ECU generates a challenge. In the heartbeat packet, the ECU not only returns a simple response, but also requires the next heartbeat packet to contain a response to a challenge (such as a hash or encryption result based on the previous heartbeat packet data). In an embodiment of the present application, the challenge can be generated based on the content of the previous heartbeat packet plus a timestamp. After receiving the heartbeat packet, the ECU uses the received heartbeat packet content (for example, the random number `rande` sent by the diagnostic device) together with the timestamp of the current server time to generate a challenge through a hash function (such as SHA256).

[0151] Among them, the challenge can be generated by the following code:

[0152] Python

[0153] import hashlib

[0154] import time

[0155] def generate_challenge(data):

[0156] timestamp = str(int(time.time())).encode('utf8')#Get the current timestamp and encode it into bytes;

[0157] challenge=hashlib.sha256(data+timestamp).digest();

[0158] return challenge, timestamp.

[0159] (2) ECU sends a challenge

[0160] The ECU sends the challenge together with a timestamp to the diagnostic device, which needs this information to calculate the response.

[0161] (3) The diagnostic device responds to the challenge. The diagnostic device receives a data packet containing the challenge and a data stamp.

[0162] (4) The diagnostic device calculates the response. The client uses the same hash function, combining the received challenge and timestamp, plus the random number of the last heartbeat packet saved by itself, to calculate the response.

[0163] Among them, the response can be generated by the following code:

[0164] Python

[0165] def respond_to_challenge(challenge,timestamp,last_rande):

[0166] response=hashlib.sha256(challenge+timestamp+last_rande).digest()

[0167] return response.

[0168] (5) The diagnostic device sends the calculated response back to the server for verification.

[0169] (6) The server recalculates the expected response using the same method and then compares it with the response sent by the client. If they match, the client is considered legitimate and the connection is maintained; if they do not match, the connection may be terminated or other security measures may be taken.

[0170] The challenge mechanism of the heartbeat packet has a flexible challenge interval: for environments that do not require extreme security measures, the challenge interval can be set, such as a challenge every 5 heartbeat packets, to reduce computing and communication overhead.

[0171] The technical solution provided in the embodiment of the present application, through heartbeat verification based on a two-way challenge response mechanism, not only verifies the activity of the connection, but also verifies the identity and data integrity of the communicating parties, thereby improving the security of the system, preventing replay attacks and man-in-the-middle attacks, and ensuring the security and integrity of data during transmission.

[0172] See also Figure 6 , is a block diagram of an embodiment of a data transmission device provided in an embodiment of the present application. As an embodiment, Figure 6 The process shown can be applied to the first device. Figure 6 As shown, the process may include:

[0173] A first sending module 61 is used to send a heartbeat packet to a second device when data transmission with the second device is completed, so that the second device generates challenge data according to the heartbeat packet and sends the challenge data to the first device, where the second device is a device different from the first device;

[0174] The receiving module 62 is used to receive the challenge data sent by the second device and generate response data corresponding to the challenge data;

[0175] The second sending module 63 is used to send the response data to the second device, so that the second device maintains the connection with the first device when determining that the preset connection condition is currently met according to the response data, so as to continue data transmission with the first device.

[0176] like Figure 7 As shown, it is a schematic diagram of the structure of a vehicle provided in an embodiment of the present application, including a processor 71, a communication interface 72, a memory 73 and a communication bus 74, wherein the processor 71, the communication interface 72, and the memory 73 communicate with each other through the communication bus 74.

[0177] A memory 73, for storing computer programs;

[0178] In one embodiment of the present application, the processor 71 is used to execute the program stored in the memory 73 to implement the data transmission method provided by any of the above method embodiments, including:

[0179] When data transmission with a second device is completed, sending a heartbeat packet to the second device, so that the second device generates challenge data according to the heartbeat packet, and sends the challenge data to the first device, where the second device is a device different from the first device;

[0180] receiving the challenge data sent by the second device, and generating response data corresponding to the challenge data;

[0181] The response data is sent to the second device, so that the second device maintains connection with the first device when determining according to the response data that a preset connection condition is currently met, so as to continue data transmission with the first device.

[0182] An embodiment of the present application further provides a storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the data transmission method provided in any of the aforementioned method embodiments are implemented.

[0183] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment.

[0184] Through the text of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a general hardware platform, and of course, by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a second device, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiment.

[0185] It should be understood that the terms used in the text are only for the purpose of the specific example implementation of the text, and are not intended to be limited. Unless the context clearly indicates otherwise, the singular forms "one", "an" and "said" as used in the text can also be represented to include plural forms. The terms "include", "comprise", "contain", and "have" are inclusive, and therefore specify the existence of the stated features, steps, operations, elements and / or parts, but do not exclude the existence or addition of one or more other features, steps, operations, elements, parts, and / or their combinations. The method steps, processes, and operations of the text in the text are not interpreted as necessarily requiring them to be performed in the specific order of the text or description, unless the execution order is clearly indicated. It should also be understood that additional or alternative steps can be used.

[0186] The above description is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest range consistent with the principles and novel features applied for herein.

Claims

1. A data transmission method, characterized in that: Applied to a first device, the method includes: When data transmission with a second device is completed, sending a heartbeat packet to the second device, so that the second device generates challenge data according to the heartbeat packet, and sends the challenge data to the first device, where the second device is a device different from the first device; receiving the challenge data sent by the second device, and generating response data corresponding to the challenge data; The response data is sent to the second device, so that the second device maintains connection with the first device when determining according to the response data that a preset connection condition is currently met, so as to continue data transmission with the first device.

2. The method according to claim 1, characterized in that Data is transmitted to the second device in the following manner: Acquire network parameters for data transmission between the second device; Determining a target encryption algorithm from a plurality of preset encryption algorithms according to the network parameters; Data is transmitted with the second device based on the target encryption algorithm.

3. The method according to claim 2, characterized in that Determining a target encryption algorithm from a plurality of preset encryption algorithms according to the network parameters includes: Determining, based on the network parameters, network performance currently performing data transmission with the second device; According to the network performance, a target encryption algorithm corresponding to the network performance is determined from a preset correspondence relationship between the network performance and the encryption algorithm.

4. The method according to claim 2, characterized in that: The performing data transmission with the second device based on the target encryption algorithm includes: Encrypting the first data to be transmitted by using the target encryption algorithm to obtain first encrypted data; The first encrypted data and the target encryption algorithm are sent to the second device, the second device is used to receive the first encrypted data and the target encryption algorithm, and use the target encryption algorithm to decrypt the first encrypted data to obtain first target data, and use the target encryption algorithm to encrypt second data to be transmitted corresponding to the first target data to obtain second encrypted data, and send the second encrypted data to the first device; The second encrypted data sent by the second device is received, and the second encrypted data is decrypted using the target encryption algorithm to obtain second target data corresponding to the second encrypted data.

5. The method according to claim 2, characterized in that: In the process of performing data transmission based on the target encryption algorithm, the following is also included: Upon receiving a new target encryption algorithm sent by a second device, data transmission is performed based on the new target encryption algorithm, wherein the second device detects new network parameters for data transmission with the first device in real time or periodically, determines a new target encryption algorithm based on the new network parameters, and sends the new target encryption algorithm to the first device.

6. The method according to claim 1, characterized in that The receiving the challenge data sent by the second device and generating response data corresponding to the challenge data includes: Determine the target function, wherein the second device, after receiving the heartbeat packet sent by the first device, obtains the heartbeat packet data of the heartbeat packet, and calculates the heartbeat packet data using the target function to obtain the challenge data; Calculating the challenge data using the objective function to obtain response data corresponding to the challenge data; The second device determines that the preset connection condition is currently satisfied according to the response data in the following manner: Calculating the challenge data using the objective function to obtain target response data; When it is compared that the response data is consistent with the target response data, it is determined that the preset connection condition is currently met.

7. The method according to claim 6, characterized in that The second device calculates the heartbeat packet data using the objective function to obtain challenge data, including: Get the current timestamp; Calculating the heartbeat packet data and the timestamp using the objective function to obtain the challenge data; The second device sending the challenge data to the first device includes: The challenge data and the timestamp are sent to the first device.

8. The method according to claim 7, characterized in that The step of calculating the challenge data using the objective function to obtain response data corresponding to the challenge data includes: Obtain the challenge data, the timestamp, and the target heartbeat packet data of the previous heartbeat packet currently recorded; Calculating the challenge data, the timestamp, and the target heartbeat packet data using the objective function to obtain the response data; The second device calculates the challenge data using the target function to obtain target response data, including: Obtain the heartbeat packet data and timestamp for generating the challenge data; The target function is used to calculate the heartbeat packet data, the timestamp, and the challenge data to obtain the target response data.

9. The method according to claim 1, characterized in that: Before generating the challenge data according to the heartbeat packet, the second device further includes: Determine the number of the heartbeat packets currently received; Determining whether the quantity is greater than a preset quantity threshold; In case it is determined that the number is greater than the number threshold, the step of generating challenge data according to the heartbeat packet is performed.

10. A data transmission device, characterized in that: Applied to a first device, the apparatus comprises: a first sending module, configured to send a heartbeat packet to a second device when data transmission with the second device is completed, so that the second device generates challenge data according to the heartbeat packet and sends the challenge data to the first device, wherein the second device is a device different from the first device; A receiving module, configured to receive the challenge data sent by the second device and generate response data corresponding to the challenge data; The second sending module is used to send the response data to the second device, so that the second device maintains the connection with the first device when determining that the preset connection condition is currently met according to the response data, so as to continue to transmit data with the first device.