Transmission control protocol-based remote communication method and related device
By determining the target socket based on the previous communication event in the transmission control protocol, and detecting and packaging the reception and existence of data frames, the problem of packet loss and timeout in remote data transmission in automotive diagnostics is solved, and efficient data transmission is achieved.
Patent Information
- Application Number
- CN202411357271.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-27
- Publication Date
- 2025-12-12
- Estimated Expiration
- 2044-09-27
AI Technical Summary
In automotive diagnostics, high packet loss rates during remote data transmission lead to latency and timeout issues, especially in wireless or wired network connections. Existing TCP communication packet loss retransmission algorithms struggle to address these latency and timeout problems.
By determining the target socket based on the previous communication event in the transmission control protocol, detecting the reception and existence of data frames, and using a preset strategy to judge and package data frames, timely transmission of data frames can be achieved, avoiding retransmission.
Without increasing the number of transmissions and only slightly increasing the amount of data, the probability of timeouts for packet loss and retransmission is reduced, thus improving the efficiency and reliability of data transmission.
Smart Images

Figure CN119363846B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of automobile diagnosis, in particular to a remote communication method based on transmission control protocol and related device. BACKGROUND
[0002] Automobile remote diagnosis needs to transmit data between a diagnosis device and a vehicle through two port devices connected to the diagnosis device and the vehicle respectively. In actual application, the diagnosis device and the vehicle are far apart, even in different cities or countries. The data frame transmitted in automobile diagnosis is small packet data, and the transmission frequency is high. In the network communication process, if a wireless network such as WiFi or 4G is used, the probability of packet loss and retransmission will be very high. If a wired network connection is used, packet loss may also occur. Even if a high-reliability TCP communication is used on the basis of wired or wireless connection, packet loss is inevitable. If the packet loss retransmission algorithm of TCP itself is used, the packet loss retransmission message will be sent to the other party again after more than 200 milliseconds. Vehicle diagnosis has very high requirements for delay, and 100 or 200 milliseconds of delay will usually cause timeout, resulting in diagnosis failure. SUMMARY
[0003] The embodiments of the present application provide a remote communication method based on transmission control protocol and related device, which can reduce the probability of timeout of data frame retransmission without greatly increasing the number of transmissions and the amount of transmitted data.
[0004] In a first aspect, the embodiments of the present application provide a remote communication method based on transmission control protocol, applied to a processor of a transmission port of an automobile diagnosis system. The automobile diagnosis system further includes a bus connected to the transmission port. The method comprises the following steps:
[0005] determining and calling a target socket according to a previous communication event, the target socket being used for data frame transmission and reception of the current communication event;
[0006] detecting the reception of a first data frame and the existence of a second data frame of the target socket according to a detection strategy, the reception including successful reception, the first data frame being a data frame transmitted from the bus, the second data frame being data sent in the previous communication event in the data buffer, and the existence including existence, the detection strategy being a preset strategy;
[0007] performing data transmission through the target socket based on the reception and the existence, wherein when it is detected that the reception is successful reception and the existence of the second data frame is existence, the first data frame and the second data frame are packaged to obtain a first data packet and a second data packet, and the first data packet and the second data packet are transmitted through the target socket.
[0008] In a possible implementation, the target socket includes the first socket or the second socket, and the determining and invoking the target socket according to the previous communication event includes:
[0009] If it is detected that the previous communication event uses the first socket to transmit and receive data, the target socket is determined as the second socket, and the second socket is invoked.
[0010] If it is detected that the previous communication event uses the second socket to transmit and receive data, the target socket is determined as the first socket, and the first socket is invoked.
[0011] In a possible implementation, the presence condition further includes absence, and the detecting the reception condition of the first data frame and the presence condition of the second data frame of the target socket according to the detection strategy includes:
[0012] Detecting the reception condition of the first data frame of the target socket.
[0013] Obtaining time information of the second data frame, the time information representing a time length from a time point when the second data frame is obtained to a current time point.
[0014] Comparing the time information with a timeout threshold, if the time information does not conform to the timeout threshold, determining that the presence condition of the second data frame is absence; or if the time information conforms to the timeout threshold, determining that the presence condition of the second data frame is presence.
[0015] In a possible implementation, the reception condition of the first data frame further includes reception timeout, and the transmitting data through the target socket based on the reception condition and the presence condition further includes:
[0016] When it is detected that the reception condition is the reception timeout and the presence condition of the second data frame is presence, packaging the second data frame to obtain a second data packet, and transmitting the second data packet through the target socket.
[0017] When it is detected that the reception condition is the reception timeout and the presence condition of the second data frame is absence, repeating the steps of detecting the reception condition of the first data frame and the presence condition of the second data frame of the target socket according to the detection strategy.
[0018] In a possible implementation, the transmitting data based on the reception condition and the presence condition further includes:
[0019] When it is detected that the reception condition is reception success and the presence condition is absence, packaging the first data frame to obtain a first data packet, and transmitting the first data packet through the target socket.
[0020] In a possible implementation, after the step of sending the first data packet and the second data packet through the target socket, the method further includes: deleting the second data frame; and repeating the steps of determining and invoking the target socket according to the previous communication event.
[0021] In a possible implementation, the automobile diagnosis system further includes a target vehicle and a diagnosis device, the transmission port includes a first transmission port connected to the target vehicle and a second transmission port connected to the diagnosis device, and the bus includes a first bus for connecting the target vehicle and the first transmission port and a second bus for connecting the diagnosis device and the second transmission port.
[0022] In a second aspect, an embodiment of the present application provides a remote communication device based on a transmission control protocol, applied to a processor of a transmission port of an automobile diagnosis system, the transmission port being bound to a first socket and a second socket, the automobile diagnosis system further including a bus connected to the transmission port, and the method includes:
[0023] a determining module configured to determine and invoke a target socket according to a previous communication event, the target socket being used for data frame transmission and reception of a current communication event;
[0024] a detecting module configured to detect, according to a detection strategy, a reception condition of a first data frame of the target socket and an existence condition of a second data frame, the reception condition including reception success, the first data frame being a data frame transmitted from the bus, the second data frame being data that has been transmitted in the previous communication event in a data buffer, and the existence condition including existence, the detection strategy being a preset strategy;
[0025] a sending module configured to send data through the target socket based on the reception condition and the existence condition, wherein when it is detected that the reception condition is reception success and the existence condition of the second data frame is existence, the first data frame and the second data frame are packed to obtain a first data packet and a second data packet, and the first data packet and the second data packet are sent through the target socket.
[0026] In a third aspect, an embodiment of the present application provides an electronic device, including a processor, a memory, a communication interface, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the processor, and the programs include instructions for executing part or all of the steps described in the first aspect of the embodiments of the present application.
[0027] In a fourth aspect, an embodiment of the present application provides a computer readable storage medium, which stores a computer program, the computer program including program instructions, and the program instructions, when executed by a processor, cause the processor to execute part or all of the steps described in the first aspect.
[0028] In a fifth aspect, an embodiment of the present application provides a computer program product. The computer program product includes a non-transitory computer readable storage medium storing a computer program. The computer program is operable to cause a computer to execute part or all of the steps described in the first aspect of the embodiments of the present application. The computer program product can be a software installation package.
[0029] By implementing the embodiments of the present application, the target socket is determined and invoked according to the previous communication event, and the target socket is used for data frame transceiving of the current communication event; the receiving condition of the first data frame and the existence condition of the second data frame of the target socket are detected according to the detection strategy, the receiving condition includes receiving success, the first data frame is a data frame transmitted from the bus, and the second data frame is the sent data in the previous communication event in the data buffer, the existence condition includes existence, and the detection strategy is a preset strategy; data is sent through the target socket based on the receiving condition and the existence condition, wherein when it is detected that the receiving condition is receiving success and the existence condition of the second data frame is existence, the first data frame and the second data frame are packed to obtain a first data packet and a second data packet, and the first data packet and the second data packet are sent through the target socket. Compared with the mechanism that the existing data frame sending end sends the same data frame to the data receiving end through two data transmission channels at the same time, the embodiments of the present application select the determined and invoked target socket as the sending end point, and determine the specific data to be sent according to the existence condition of the first data frame of the current communication event and the second data frame of the historical communication event, so that the time required for data retransmission is shortened without increasing the sending times and slightly increasing the data amount, which is beneficial to reducing the probability of communication timeout caused by packet loss. BRIEF DESCRIPTION OF DRAWINGS
[0030] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the background art, the drawings needed to be used in the embodiments of the present application or the background art will be described below.
[0031] Figure 1 is a system architecture diagram of an automobile diagnosis system provided by the embodiments of the present application;
[0032] Figure 2 is a flowchart of a remote communication method based on a transmission control protocol provided by the embodiments of the present application;
[0033] Figure 3 is an interaction diagram of a transmission port in a remote communication method based on a transmission control protocol provided by the embodiments of the present application;
[0034] Figure 4 is a flowchart of another remote communication method based on a transmission control protocol provided by the embodiments of the present application;
[0035] Figure 5 This is a schematic diagram of the structure of a remote communication device based on the transmission control protocol proposed in an embodiment of this application;
[0036] Figure 6 This is a schematic diagram of the structure of an electronic device proposed in an embodiment of this application. Detailed Implementation
[0037] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present application.
[0038] The terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish different objects, not to describe a specific order. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or electronic device that includes a series of steps or units is not limited to the listed steps or units, but in an alternative example also includes steps or units not listed, or in an alternative example also includes other steps or units inherent to these processes, methods, products, or electronic devices.
[0039] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0040] The socket mentioned in this article is an abstraction in computer network programming that provides an interface for communication over a network.
[0041] Please see Figure 1 , Figure 1 This is a system architecture diagram of an automotive diagnostic system provided in an embodiment of this application, such as... Figure 1 As shown, the vehicle diagnostic system 100 includes: a target vehicle 110, a diagnostic device 120, a first transmission port 130, and a second transmission port 140.
[0042] The automobile diagnosis system 100 comprises a transmission port, the transmission port comprises a first transmission port 130 and a second transmission port 140, the first transmission port 130 is connected with the target vehicle 110, and the connection mode can be through a CAN bus; the second transmission port 140 is connected with the diagnosis equipment 120, and the connection mode can be through a CAN bus, that is, data transmission can be performed between the target vehicle 110 and the first transmission port 130, and data transmission can be performed between the diagnosis equipment 120 and the second transmission port 140. The first transmission port 130 and the second transmission port 140 can receive and send data through a network.
[0043] The first transmission port 130 and the second transmission port 140 can be an electronic device with a processor, the first transmission port 130 is used for receiving a data frame from a network or from the target vehicle 110 and sending data to the network or the target vehicle 110; and the second transmission port 140 is used for receiving a data frame from a network or from the diagnosis equipment 120 and sending data to the network or the diagnosis equipment 120. The first transmission port 130 and the second transmission port 140 can convert data types, for example, bus data transmitted by the target vehicle 110 or the diagnosis equipment 120 through a bus can be converted into network transparent transmission data, and network transparent transmission data can be converted into bus data that can be transmitted through a bus.
[0044] The diagnosis equipment 120 reads information of the target vehicle 110 through the first transmission port 130 and the second transmission port 140, exchanges data based on a communication protocol, and realizes detection of a state of the target vehicle 110 and diagnosis of a fault, wherein the communication protocol can be a transmission control protocol (TCP).
[0045] The first transmission port 130 and the second transmission port 140 can be wirelessly connected or wiredly connected, which is not limited herein.
[0046] Please refer to Figure 2 , Figure 2 is a flowchart of a remote communication method based on a transmission control protocol provided by the embodiment, the method is applied to a processor of a transmission port of an automobile diagnosis system, the automobile diagnosis system further comprises a bus, the bus is connected with the transmission port, as shown in Figure 2 The method comprises the following steps:
[0047] S210, determining and calling a target socket according to a previous communication event, the target socket is used for data frame receiving and sending of a current communication event.
[0048] The previous communication event refers to an event of sending a previous data frame to be transmitted. The socket is a function level concept and is a communication endpoint, which provides an interface and function required for communication. The target socket can be selected according to a predetermined rule. For example, the target socket of the current communication event can be determined according to the socket used in the previous communication event. The target socket is used for data frame transmission and reception of the current communication event. For data frame transmission, the packaged data frame can be transmitted. For data frame reception, a data packet can be received.
[0049] In a possible embodiment, the target socket includes a first socket or a second socket. The target socket is determined and called according to the previous communication event. If it is detected that the previous communication event uses the first socket for data transmission and reception, the target socket is determined as the second socket, and the second socket is called. If it is detected that the previous communication event uses the second socket for data transmission and reception, the target socket is determined as the first socket, and the first socket is called.
[0050] The processor can include a plurality of sockets, such as a first socket and a second socket. Each socket can be called, and the called socket of the current communication event is used as the target socket. The rule for determining the target socket can determine the socket used in the current communication according to the socket used in the previous communication. Specifically, if the previous communication event uses the first socket, the target socket selects the second socket as the socket of the current communication event. If the previous communication event uses the second socket, the target socket selects the first socket as the socket of the current communication event.
[0051] It can be seen that, in the embodiment, the socket of the current communication event can be selected according to the socket of the previous communication event, which can improve the concurrent processing capability and improve the data transmission efficiency.
[0052] S220, according to the detection strategy, detecting the reception of the first data frame of the target socket and the existence of the second data frame. The reception includes successful reception. The first data frame is a data frame transmitted from the bus. The second data frame is a data frame transmitted in the previous communication event in the data buffer. The existence includes existence. The detection strategy is a preset strategy.
[0053] The transmission port also has a data buffer or a data storage area for temporarily storing received data frames. The processor can check whether the data frame transmitted from the bus is received in the data buffer of the transmission port. The processor can also check whether the data frame transmitted in the previous communication event exists in the data buffer.
[0054] The processor continuously detects whether the data buffer area receives the first data frame and whether the second data frame exists, and obtains the receiving condition of the first data frame and the existence condition of the second data frame. The detection strategy can be a judgment condition for judging whether the second data frame exists, and specifically, can be judging whether the second data frame exists according to the length of time when the second data frame exists. The receiving condition of the first data frame can include successful reception, and can also include receiving timeout, and the existence condition of the second data frame can include existence, and can also include nonexistence.
[0055] The receiving success represents that the first data frame is received within a timeout threshold, and the receiving timeout represents that the first data frame is not received within the timeout threshold; the existence of the existence condition represents that the second data frame meeting the detection strategy is detected, and the nonexistence represents that the second data frame meeting the detection strategy is not detected. The timeout threshold can be a preset length of time, which is used to limit the length of time for waiting to receive the first data frame from the bus.
[0056] In a possible embodiment, the existence condition further includes nonexistence, and detecting the receiving condition of the first data frame and the existence condition of the second data frame of the target socket according to the detection strategy includes:
[0057] 21. detecting the receiving condition of the first data frame of the target socket;
[0058] 22. obtaining time information of the second data frame, the time information representing the length of time from the time when the second data frame is obtained to the current time;
[0059] 23. comparing the time information with a timeout threshold, if the time information does not conform to the timeout threshold, determining that the existence condition of the second data frame is nonexistence, and if the time information conforms to the timeout threshold, determining that the existence condition of the second data frame is existence.
[0060] The judgment of the receiving condition can also be judged according to the timeout threshold, if it is detected that the target socket receives the first data frame within the timeout threshold, the receiving condition of the first data frame is receiving success, and if it is detected that the target socket does not receive the first data frame within the timeout threshold, the receiving condition of the first data frame is receiving timeout. The time information of the second data frame is obtained, which can be obtained according to the time stamp in the second data frame, specifically, a length of time can be obtained by subtracting the current time from the time stamp, and the length of time is the time information. Then, the time information of the second data frame and a preset timeout threshold are compared, if the time information does not conform to the timeout threshold, it is determined that the existence condition of the second data frame is nonexistence, and if the time information conforms to the timeout threshold, it is determined that the existence condition of the second data frame is existence.
[0061] If the second data frame is not detected, it also indicates that the second data frame does not exist.
[0062] In this embodiment, the existence of the second data frame is determined by the time information of the second data frame, and the receiving condition of the first data frame is obtained, so that the first data frame and / or the second data frame can be sent in time, which is beneficial to reduce the data timeout condition.
[0063] In S230, data is sent through the target socket based on the receiving condition and the existence condition. When it is detected that the receiving condition is successful and the existence condition of the second data frame is existence, the first data frame and the second data frame are packaged to obtain a first data packet and a second data packet, and the first data packet and the second data packet are sent through the target socket.
[0064] The receiving condition includes receiving success and receiving timeout, and the existence condition includes existence and nonexistence, and various decision conditions can be obtained by combining them in pairs, and the specific data content of the sending is determined based on the receiving condition and the existence condition.
[0065] If the receiving condition is detected as receiving success and the existence condition of the second data frame is also detected as existence, the first data frame and the second data frame are packaged to obtain a first data packet and a second data packet, and the first data packet and the second data packet are sent through the target socket, and if sent to the network, it can be converted into transparent data that the network can transmit and transmitted through the network.
[0066] In a possible embodiment, the receiving condition of the first data frame further includes receiving timeout, and the data sending through the target socket based on the receiving condition and the existence condition further includes: when it is detected that the receiving condition is receiving timeout and the existence condition of the second data frame is existence, the second data frame is packaged to obtain a second data packet, and the second data packet is sent through the target socket; when it is detected that the receiving condition is receiving timeout and the existence condition of the second data frame is nonexistence, the steps of detecting the receiving condition of the first data frame and the existence condition of the second data frame of the target socket according to the detection strategy are repeated.
[0067] If the receiving condition of the first data frame is detected as receiving timeout and the existence condition of the second data frame is existence, the second data frame is packaged as a second data packet, and the second data packet is sent through the target socket. If the receiving condition of the first data frame is detected as receiving timeout and the existence condition of the second data frame is nonexistence, it indicates that there is no data that can be sent in the data buffer area at this time, and then the first data frame is waited for and the above steps of detecting the receiving condition of the first data frame and the existence condition of the second data frame of the target socket are repeated. Alternatively, the data transmission can also be terminated directly.
[0068] If the receiving condition is detected as successful and the existing condition is detected as non-existing, the first data frame is packed to obtain a first data packet, and the first data packet is sent through the target socket.
[0069] If the receiving condition of the first data frame is detected as successful and the existing condition of the second data frame is detected as non-existing, only the first data frame is packed to obtain a first data packet, and the first data packet is sent through the target socket.
[0070] It can be seen that in the embodiment, the receiving condition of the first data frame and the existing condition of the second data frame are determined to obtain multiple decisions, different data is sent in different condition combinations, the existing data is maximally sent, retransmission data is not separately sent, the time required for data retransmission is shortened without increasing the number of sending times and slightly increasing the amount of data, which is beneficial to reducing the probability of communication timeout caused by packet loss.
[0071] In a possible embodiment, after the step of sending the first data packet and the second data packet through the target socket, the method further comprises: deleting the second data frame; and repeating the steps of determining and calling the target socket according to the previous communication event.
[0072] After the first data packet is sent, or the first data packet and the second data packet are sent, or the second data packet is sent, the previous communication event ends, and the next communication event is prepared to enter, the second data frame of the previous communication event is deleted, the next communication event is entered, and the steps of determining and calling the target socket according to the previous communication event are repeated, at this time, the first data frame becomes the data frame of the previous communication event relative to the next communication event, and the target socket of the next communication event is determined according to the socket of the current communication event.
[0073] For example, if the first socket and the second socket are set, the previous communication event sends data through the first socket, and the current communication event determines the second socket as the target socket. If the current communication event ends, that is, data is sent through the target socket, the flow is transferred to the next communication event, the second data frame of the previous communication event is deleted, the first data frame received in the current communication event is taken as the second data frame of the previous communication event in the next communication event, the first socket is determined as the target socket, and the first data frame transmitted from the bus is received.
[0074] It can be seen that, in the embodiment, the previously transmitted data is taken as the second data frame of the next communication event, and the socket is switched to transmit data, so that the data transmitted through the target socket next time includes the previously transmitted second data frame, and the retransmission data does not need to be separately transmitted, the time required for data retransmission is shortened without increasing the number of transmissions and slightly increasing the data amount, and the probability of communication timeout caused by packet loss is reduced.
[0075] In a possible embodiment, the automobile diagnosis system further includes a target vehicle and a diagnosis device, the transmission port includes a first transmission port connected with the target vehicle and a second transmission port connected with the diagnosis device, and the bus includes a first bus for connecting the target vehicle and the first transmission port and a second bus for connecting the diagnosis device and the second transmission port.
[0076] In the automobile diagnosis system, the target vehicle and the diagnosis device are connected through the bus and the first transmission port and the second transmission port, respectively, and the first transmission port and the second transmission port can transmit and receive data, for example, data can be transparently transmitted between the first transmission port and the second transmission port through a network. The first transmission port and the second transmission port can perform the content described in any one of the above embodiments.
[0077] It should be noted that, if the automobile diagnosis system further includes other transmission ports, the content described in any one of the above embodiments can also be performed, and the number of transmission ports is not limited herein.
[0078] It can be seen that, in the automobile diagnosis system, at least two sockets can be set for each port to alternately transmit data, and each port can perform the content described in the above embodiments, so that the time required for data retransmission is shortened without increasing the number of transmissions and slightly increasing the data amount, and the probability of communication timeout caused by packet loss is reduced.
[0079] For example, referring to Table 1, if the target vehicle sends ten frames of data with sequence numbers 1, 2, 3, 4, 5, 6, 7, 8, 9, and 10 to the first transmission port through the bus, and the interval between sending each frame of data is 10 milliseconds. The first transmission port has set the first socket and the second socket, and first determines the first socket as the target socket, and sets the timeout threshold to 20 milliseconds. According to Table 1, it can be seen that 1 is detected to be received, and at this time, the data buffer area does not have a sent frame of data, so the target socket, that is, the first socket, packs and sends 1; the target socket is switched to the second socket, and the second socket receives 2 after 10 milliseconds, which does not exceed 20 milliseconds, and it is detected whether there is a sent frame of data. At this time, the data buffer area has 1, and according to the time information, it is determined that the time when 1 exists does not exceed 20 milliseconds, so 1 and 2 are packed and sent through the target socket, that is, the second socket; this is repeated until the last frame of data is also sent (9 and 10 are sent together), the target socket is switched to the first socket, the first socket does not receive a frame of data after 20 milliseconds, it is detected whether there is a sent frame of data, at this time, the data buffer area has 10, and according to the time information, it is determined that the time when 10 exists does not exceed 20 milliseconds, so 10 is packed and sent through the target socket, that is, the first socket.
[0080]
[0081] Table 1
[0082] It should be noted that the length of the timeout threshold can be set according to actual conditions, and can be 20 milliseconds, 15 milliseconds, or other lengths, which are not limited in the present application. The timeout threshold may cause the restriction condition to be widened and the timeout probability to be increased, but in the automobile diagnosis scenario, data transmission has the characteristics of small and dense, and as long as the data is very frequent, the timeout situation caused by retransmission is unlikely to occur.
[0083] It should be noted that in vehicle diagnosis, if the bus is a CAN bus, the data length of the data frame transmitted by the CAN bus plus the frame sequence number, time stamp, ID, and other data usually does not exceed 30 bytes. Even if it is a CANFD message, the data length of a frame of data is generally not more than 64 bytes. In this case, each time data is sent with the last sent data, the increased data length is limited, so it will not cause a situation of too much data, and therefore it is almost impossible to cause a situation of higher delay than not sending the last sent data.
[0084] In one possible embodiment, referring to Figure 3 , Figure 3 is a schematic diagram of the interaction of a transmission port in a remote communication method based on the transmission control protocol provided by the embodiments of the present application, as shown in Figure 3As shown, the processor of the first port can invoke the target socket, the processor of the second port can invoke the target socket, and the selection of the target socket is in accordance with Figure 2 The method of the embodiment is described to select a first transmission port to establish a TCP connection with a server, and a second transmission port to establish a TCP connection with the server, so as to achieve the effect of data transmission between the first transmission port and the second transmission port through the target socket and the TCP connection. The server can be the same or different, which is not limited here.
[0085] Optionally, the second transmission port and the first transmission port can also be directly connected through TCP, without going through the TCP connection with the server to achieve the effect of connecting the first transmission port and the second transmission port. The specific situation is determined by the actual situation, which is not limited here.
[0086] It can be seen that in the embodiment, compared with the existing mechanism of sending the same data frame by the data frame sending end through two data transmission channels to the data receiving end, the embodiment selects and invokes the target socket as the sending end point, which shortens the time required for data retransmission without increasing the sending times and slightly increasing the data amount, and is beneficial to reduce the probability of communication timeout caused by packet loss.
[0087] In a possible embodiment, please refer to Figure 4 , Figure 4 is a flowchart of another remote communication method based on the transmission control protocol provided by the embodiment of the application, as Figure 4 shown, the remote communication method based on the transmission control protocol comprises:
[0088] S410, determining and invoking a target socket according to a previous communication event.
[0089] S420, detecting the receiving condition of the first data frame of the target socket as receiving success or receiving timeout.
[0090] S430, detecting the existence condition of the second data frame as existing or not existing.
[0091] If the receiving condition of the first data frame is receiving success, and the existence condition of the second data frame is existing, step S441 is executed; if the receiving condition of the first data frame is receiving success, and the existence condition of the second data frame is not existing, step S442 is executed; if the receiving condition of the first data frame is receiving timeout, and the existence condition of the second data frame is existing, step S443 is executed; if the receiving condition of the first data frame is receiving timeout, and the existence condition of the second data frame is not existing, step S420 is executed.
[0092] S441, pack the first data frame and the second data frame to obtain a first data packet and a second data packet respectively, and send the first data packet and the second data packet through the target socket.
[0093] S442, pack the first data frame to obtain a first data packet, and send the first data packet through the target socket.
[0094] S443, pack the second data frame to obtain a second data packet, and send the second data packet through the target socket.
[0095] S450, delete the second data frame.
[0096] Wherein, after the second data frame is deleted, the step S410 and the following steps are executed cyclically.
[0097] It should be noted that the specific description of the above steps has been described in the Figure 2 embodiment, which will not be repeated in this embodiment. Please refer to the Figure 2 embodiment content.
[0098] It can be seen that, in the present embodiment, the target socket is determined and called according to the previous communication event, and the target socket is used for the data frame transmission and reception of the current communication event; the receiving condition of the first data frame of the target socket and the existence condition of the second data frame are detected according to the detection strategy, the receiving condition includes receiving success, the first data frame is the data frame transmitted from the bus, and the second data frame is the data sent in the previous communication event in the data buffer, the existence condition includes existence, and the detection strategy is a preset strategy; data is sent through the target socket based on the receiving condition and the existence condition, wherein when it is detected that the receiving condition is receiving success and the existence condition of the second data frame is existence, the first data frame and the second data frame are packed to obtain a first data packet and a second data packet respectively, and the first data packet and the second data packet are sent through the target socket. Relative to the mechanism that the existing data frame sending end sends the same data frame to the data receiving end through two data transmission channels at the same time, the present application selects the target socket as the sending end point, and determines the specific data to be sent according to the existence condition of the first data frame of the current communication event and the second data frame of the historical communication event, so as to shorten the time required for data retransmission without increasing the sending times and slightly increasing the data amount, which is conducive to reducing the probability of communication timeout caused by packet loss.
[0099] Please refer to Figure 5 , Figure 5The figure is a structure schematic diagram of a remote communication device based on a transmission control protocol, which is proposed by an embodiment of the present application. The device is applied to a processor of a transmission port of an automobile diagnosis system. The transmission port is bound with a first socket and a second socket. The automobile diagnosis system further comprises a bus, which is connected with the transmission port. The remote communication device based on the transmission control protocol 500 comprises a determining module 510, a detecting module 520 and a sending module 530, wherein:
[0100] The determining module 510 is configured to determine and call a target socket according to a previous communication event, and the target socket is used for data frame transceiving of a current communication event.
[0101] The detecting module 520 is configured to detect a receiving condition of a first data frame and an existing condition of a second data frame of the target socket according to a detection strategy, the receiving condition comprises receiving success, the first data frame is a data frame transmitted from the bus, the second data frame is data that has been sent in the previous communication event in a data buffer, the existing condition comprises existence, and the detection strategy is a preset strategy.
[0102] The sending module 530 is configured to send data through the target socket based on the receiving condition and the existing condition. When it is detected that the receiving condition is receiving success and the existing condition of the second data frame is existence, the first data frame and the second data frame are packed to obtain a first data packet and a second data packet, and the first data packet and the second data packet are sent through the target socket.
[0103] In a possible implementation, the determining module 510, in terms of determining and calling the target socket according to the previous communication event, is specifically configured to:
[0104] If it is detected that the previous communication event uses the first socket for data transceiving, the target socket is determined as the second socket, and the second socket is called.
[0105] If it is detected that the previous communication event uses the second socket for data transceiving, the target socket is determined as the first socket, and the first socket is called.
[0106] In a possible implementation, the detecting module 520, in terms of detecting the receiving condition of the first data frame and the existing condition of the second data frame of the target socket according to the detection strategy, is specifically configured to:
[0107] Detect the receiving condition of the first data frame of the target socket.
[0108] Obtain time information of the second data frame, and the time information represents a time length from a time point when the second data frame is obtained to a current time point.
[0109] Compare the time information with the timeout threshold. If the time information does not meet the timeout threshold, the existence of the second data frame is determined to be non-existent; if the time information meets the timeout threshold, the existence of the second data frame is determined to be present.
[0110] In one possible implementation, the sending module 530, in terms of sending data through the target socket based on the reception status and the presence status, is further configured to:
[0111] When a reception timeout is detected and the second data frame is present, the second data frame is packaged into a second data packet, which is then sent through the target socket.
[0112] If a reception timeout is detected and the second data frame is not present, the steps of detecting the reception status of the first data frame and the presence status of the second data frame of the target socket are repeated according to the detection strategy.
[0113] In one possible implementation, the sending module 530, in terms of sending data through the target socket based on the reception status and the presence status, is further configured to:
[0114] When the reception status is detected as successful and the presence status is detected as non-existent, the first data frame is packaged into the first data packet, and the first data packet is sent through the target socket.
[0115] In one possible implementation, the sending module 530, in its function of sending data through the target socket based on the reception status and the presence status, is further configured to: delete the second data frame.
[0116] It is worth noting that the specific functional implementation of the remote communication device 500 based on the transmission control protocol is described above. Figure 2 The description of the remote communication method based on the transmission control protocol illustrates, for example, the determination module 510's role in implementing the relevant content of S210. The various units or modules in the remote communication device 500 based on the transmission control protocol can be individually or entirely merged into one or more other units or modules, or some of these units or modules can be further divided into multiple functionally smaller units or modules. This achieves the same operation without affecting the technical effects of the embodiments of the present invention. The aforementioned units or modules are based on logical functional division. In practical applications, the function of one unit (or module) is implemented by multiple units (or modules), or the function of multiple units (or modules) is implemented by one unit (or module).
[0117] It can be seen that the remote communication device based on the transmission control protocol described in the embodiment of the application determines and calls the target socket according to the previous communication event, and the target socket is used for data frame transceiving of the current communication event; the detection strategy is used to detect the receiving condition of the first data frame of the target socket and the existence condition of the second data frame, the receiving condition includes receiving success, the first data frame is a data frame transmitted from the bus, and the second data frame is the data sent in the previous communication event in the data buffer, and the existence condition includes existence, and the detection strategy is a preset strategy; data is sent through the target socket based on the receiving condition and the existence condition, wherein when it is detected that the receiving condition is receiving success and the existence condition of the second data frame is existence, the first data frame and the second data frame are packaged to obtain a first data packet and a second data packet, and the first data packet and the second data packet are sent through the target socket. Relative to the mechanism that the existing data frame sending end sends the same data frame to the data receiving end through two data transmission channels at the same time, the application selects the determined and called target socket as the sending end point, and determines the specific data to be sent according to the existence condition of the first data frame of the current communication event and the second data frame of the historical communication event, so that the time required for data retransmission is shortened without increasing the sending times and slightly increasing the data amount, which is beneficial to reducing the probability of communication timeout caused by packet loss.
[0118] Please refer to Figure 6 , Figure 6 is a structural schematic diagram of an electronic device proposed in the embodiment of the application, as shown in the figure, the electronic device 600 includes a processor 610, a memory 620, a communication interface 630 and one or more programs 621, the above-mentioned one or more programs 621 are stored in the above-mentioned memory 620, and are configured to be executed by the above-mentioned processor 610.
[0119] The processor 610, the memory 620 and the communication interface 630 are connected to each other and complete the communication work among them;
[0120] The memory 620 can be a volatile memory such as a dynamic random access memory (DRAM), or a non-volatile memory such as a mechanical hard disk. The memory 620 is used to store a set of executable program codes, and the processor 610 is used to call one or more programs 621 stored in the memory 620, and can execute any part or all of the steps of the remote communication method based on the transmission control protocol as described in the above-mentioned Figure 2 embodiment.
[0121] The electronic device 600 can include a smart phone (such as an Android phone, an iOS phone, a Windows Phone, or the like), a tablet computer, a palm computer, a vehicle event data recorder, a vehicle-mounted electronic device, a server, a notebook computer, a mobile Internet device (MID), or a wearable electronic device (such as a smart watch or a Bluetooth headset), and the like. The above is merely an example and is not exhaustive, and includes but is not limited to the above electronic devices.
[0122] The embodiments of the present application further provide a computer storage medium, which stores a computer program for electronic data exchange, and the computer program causes a computer to execute some or all of the steps of any of the methods described in the above method embodiments. The computer includes an electronic device.
[0123] The embodiments of the present application further provide a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program. The computer program is operable to cause a computer to execute some or all of the steps of any of the methods described in the above method embodiments. The computer program product can be a software installation package, and the computer includes an electronic device.
[0124] It should be noted that, for the above method embodiments, in order to simply describe, each of the above method embodiments is described as a series of action combinations, but those skilled in the art should know that the present application is not limited to the order of actions described, because according to the present application, some steps can be performed in other order or simultaneously. Secondly, those skilled in the art should know that the embodiments described in the specification all belong to preferred embodiments, and the actions and modules involved are not necessarily required by the present application.
[0125] In the above embodiments, the description of each embodiment is focused on, and the part not described in detail in a certain embodiment can be referred to the related description of other embodiments.
[0126] In several embodiments provided in the present application, it should be understood that the disclosed apparatus can be implemented by other means. For example, the apparatus embodiments described above are merely illustrative, for example, the division of the above units is only a logical function division, and actual implementation can have another division manner, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the displayed or discussed units can be indirect coupling or communication connection through some interfaces, apparatuses or units, and can be electrical or other forms.
[0127] The units described as separate components may or may not be physically separate, and the components displayed as units may or may not be physical units, i.e., they may be located in one place, or they may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiment.
[0128] In addition, the functional units in each embodiment of the present application can be integrated in one processing unit, or each unit can exist physically, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of a software functional unit.
[0129] The integrated unit, if realized in the form of a software functional unit and sold or used as an independent product, can be stored in a computer readable memory. Based on this understanding, the technical solutions of the present application essentially or the part that contributes to the prior art or the whole or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a memory and includes a plurality of instructions for causing a computer electronic device (which can be a personal computer, an electronic device or a network electronic device, etc.) to execute all or part of the steps of the above-mentioned method of each embodiment of the present application. The aforementioned memory includes: a U disk, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and various media that can store program codes.
[0130] Those skilled in the art can understand that all or part of the steps of the various methods of the above embodiments can be completed by programs instructing relevant hardware, and the programs can be stored in a computer readable memory, which can include a flash disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0131] The embodiments of the present application are described in detail above, and the principles and implementation modes of the present application are described by applying specific examples. The above description of the embodiments is only to help understand the method of the present application and its core idea; at the same time, for those skilled in the art, according to the idea of the present application, the specific implementation mode and application range will be changed; in conclusion, the content of the specification should not be understood as a limitation of the present application.
Claims
1. A method for remote communication based on the transmission control protocol, characterized in that, The application discloses a processor applied to a transmission port of an automobile diagnosis system, the automobile diagnosis system further comprises a bus connected with the transmission port, and the method comprises the following steps: determining and calling a target socket according to a previous communication event, the target socket being used for data frame transceiving of a current communication event; detecting a receiving condition of a first data frame of the target socket and an existence condition of a second data frame according to a detection strategy, the receiving condition comprising receiving success, the first data frame being a data frame transmitted from the bus, the second data frame being data sent in the previous communication event in a data buffer, and the existence condition comprising existence, the detection strategy being a preset strategy; performing data sending through the target socket based on the receiving condition and the existence condition, wherein when it is detected that the receiving condition is the receiving success and the existence condition of the second data frame is the existence, a first data packet and a second data packet are obtained by packing the first data frame and the second data frame respectively, and the first data packet and the second data packet are sent through the target socket.
2. The method of claim 1, wherein, The target socket comprises a first socket or a second socket, and the step of determining and calling a target socket according to a previous communication event comprises the following steps: if it is detected that the previous communication event uses the first socket for data transceiving, the target socket is determined as the second socket, and the second socket is called; if it is detected that the previous communication event uses the second socket for data transceiving, the target socket is determined as the first socket, and the first socket is called.
3. The method of claim 1, wherein, The existence condition further comprises nonexistence, and the step of detecting a receiving condition of a first data frame of the target socket and an existence condition of a second data frame according to a detection strategy comprises the following steps: detecting the receiving condition of the first data frame of the target socket; obtaining time information of the second data frame, the time information representing a time length from a time point when the second data frame is obtained to a current time point; comparing the time information with a timeout threshold value, if the time information does not conform to the timeout threshold value, judging that the existence condition of the second data frame is the nonexistence, and if the time information conforms to the timeout threshold value, judging that the existence condition of the second data frame is the existence.
4. The method of claim 3, wherein, The receiving condition of the first data frame further comprises receiving timeout, and the step of performing data sending through the target socket based on the receiving condition and the existence condition further comprises the following steps: when it is detected that the receiving condition is the receiving timeout and the existence condition of the second data frame is the existence, packing the second data frame to obtain the second data packet, and sending the second data packet through the target socket; when it is detected that the receiving condition is the receiving timeout and the existence condition of the second data frame is the nonexistence, repeating the step of detecting a receiving condition of a first data frame of the target socket and an existence condition of a second data frame according to a detection strategy.
5. The method of claim 3, wherein, The step of performing data sending based on the receiving condition and the existence condition further comprises the following steps: When it is detected that the receiving condition is receiving success and the existing condition is the existing, the first data frame is packed to obtain the first data packet, and the first data packet is sent through the target socket.
6. The method of claim 2, wherein, After the step of sending the first data packet and the second data packet through the target socket, the method further comprises: deleting the second data frame; and repeating the step of determining and calling a target socket according to a previous communication event.
7. The method according to any one of claims 1 to 6, characterized in that, The automobile diagnosis system further comprises a target vehicle and a diagnosis device, the transmission port comprises a first transmission port connected with the target vehicle and a second transmission port connected with the diagnosis device, and the bus comprises a first bus for connecting the target vehicle and the first transmission port and a second bus for connecting the diagnosis device and the second transmission port.
8. A remote communication apparatus based on a transmission control protocol, characterized by, The processor is applied to a transmission port of an automobile diagnosis system, the transmission port is bound with a first socket and a second socket, the automobile diagnosis system further comprises a bus connected with the transmission port, and the device comprises: A determining module is configured to determine and call a target socket according to a previous communication event, the target socket is used for data frame transceiving of a current communication event; A detecting module is configured to detect a receiving condition of a first data frame of the target socket and an existing condition of a second data frame according to a detection strategy, the receiving condition comprises receiving success, the first data frame is a data frame transmitted from a bus, the second data frame is a data frame that has been sent in the previous communication event in a data buffer, and the existing condition comprises existing, the detection strategy is a preset strategy; A sending module is configured to send data through the target socket based on the receiving condition and the existing condition, wherein when it is detected that the receiving condition is the receiving success and the existing condition of the second data frame is the existing, the first data frame and the second data frame are packed to obtain a first data packet and a second data packet, and the first data packet and the second data packet are sent through the target socket.
9. A computer-readable storage medium, characterized in that, A storage has a remote communication program based on a transmission control protocol, comprising execution instructions, when a processor of an electronic device executes the execution instructions, the processor executes the method in any one of claims 1 to 7.
10. An electronic device, comprising: A memory has execution instructions, the memory stores one or more programs; when a processor executes the execution instructions stored in the memory, the processor executes the method in any one of claims 1 to 7.
Citation Information
Patent Citations
Data transmission method and device, computer readable medium and electronic equipment
CN112953850A
Multi-thread data transmission method and device
CN114237937A