Data sending device, data receiving device, and data transmission system and method
By sending relevant information about data frames using connectionless communication before TCP data transmission, the sticking and unpacking problems caused by frame size in TCP are solved, and accurate analysis of data frames and improved data transmission efficiency are achieved.
Patent Information
- Application Number
- CN202411144409.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-20
- Publication Date
- 2025-06-20
- Estimated Expiration
- 2044-08-20
AI Technical Summary
In communication using the Transmission Control Protocol (TCP), since TCP is connected and has no data boundary, it may cause problems of sticking or unpacking of data frames due to frame size, resulting in the data receiving device being unable to accurately parse the received data frames.
By sending information related to the data frame to be sent using a connectionless communication method (such as UDP, serial port, SPI, IIC) before data transmission is used to transmit data, the data receiving device can more accurately analyze the data frame based on this information.
By pre-sending data information, the data receiving device can accurately analyze data frames according to the frame size, solve the problems of sticking and unpacking, and improve the efficiency of data transmission.
Smart Images

Figure CN118890379B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communications, and more particularly to a data sending device, a data receiving device, and a data transmission system and method. Background Art
[0002] In communications using the Transmission Control Protocol (TCP), since TCP is connection-oriented and has no data boundaries, when transmitting data through TCP, data frames may have the problem of packet adhesion or packet splitting due to the size of the frames. For example, if the data frame is small, it is prone to packet adhesion, that is, two data frames are spliced together for transmission, or, if the data frame is too large to exceed the buffer size, it is prone to packet splitting, that is, a data frame is split into two or more frames for transmission. Both packet adhesion and packet splitting will cause the data receiving device to be unable to accurately parse the received data frames. Summary of the Invention
[0003] It should be understood that the above general description and the following detailed description of the present invention are both exemplary and explanatory, and are intended to provide further explanation of the present invention as claimed.
[0004] According to a first aspect of the present invention, there is provided a data sending device, including: a sending interface configured to send information to a data receiving device; a receiving interface configured to receive information from the data receiving device; and a processing unit configured to: perform an initialization operation to determine the Internet Protocol (IP) address and port number of the data sending device; cause the sending interface to send data information to the data receiving device by a connectionless communication method, the data information including the IP address and port number of the data sending device and the frame size of the data frame to be sent; cause the receiving interface to receive a connection request from the data receiving device to establish a connection using the Transmission Control Protocol (TCP) with the data receiving device; cause the receiving interface to receive an acknowledgment response from the data receiving device by the connectionless communication method; and in response to receiving the acknowledgment response and the completion of connection establishment, cause the sending interface to send a data stream to the data receiving device through the TCP, and the data frames in the data stream can be parsed based on the frame size.
[0005] In the above data sending device, the connectionless communication method uses one of the following: User Datagram Protocol (UDP), serial port, Serial Peripheral Interface (SPI), Inter-Integrated Circuit (IIC).
[0006] In the above data sending device, the data information further includes the header information and trailer information of the data frame to be sent.
[0007] In the above data sending device, the data information further includes the special position information of the data frame to be sent, and the special position information is used to indicate the position of specific information in the data frame.
[0008] According to a second aspect of the present invention, there is provided a data receiving device, including: a sending interface configured to send information to a data sending device; a receiving interface configured to receive information from the data sending device; and a processing unit configured to: enable the receiving interface to receive data information from the data sending device through a connectionless communication method, the data information including the Internet Protocol (IP) address and port number of the data sending device, and the frame size of the data frame to be sent; perform an initialization operation to parse the data information and record the IP address and port number of the data sending device in the data information, and the frame size of the data frame to be sent; enable the sending interface to send a connection request to the data sending device based on the IP address and port number of the data sending device in the data information to establish a connection using the Transmission Control Protocol (TCP) with the data sending device; enable the sending interface to send an acknowledgment response to the data sending device through the connectionless communication method; enable the receiving interface to receive a data stream from the data sending device through the TCP; and parse the data frame in the data stream based on the frame size.
[0009] In the above data receiving device, the connectionless communication method uses one of the following: User Datagram Protocol (UDP), serial port, Serial Peripheral Interface (SPI), Inter-Integrated Circuit (IIC).
[0010] In the above data receiving device, the processing unit being configured to parse the data frame in the data stream based on the frame size includes being configured to: determine whether the data frame is independent based on the frame size; and if the data frame is not independent, split or splice the data stream based on the frame size.
[0011] In the above data receiving device, the data information further includes the header information and trailer information of the data frame to be sent, and the processing unit being configured to parse the data frame in the data stream based on the frame size includes being configured to: determine whether the data frame is independent based on the frame size; and if the data frame is not independent, split or splice the data stream based on the frame size, the frame header information, and the frame trailer information.
[0012] In the above data receiving device, the data information further includes special position information of the data frame to be sent, where the special position information is used to indicate the position of specific information in the data frame, and the processing unit is configured to parse the data frame in the data stream based on the frame size and further includes being configured to: parse the specific information in the data frame based on the special position information.
[0013] In the above data receiving device, the processing unit is configured to perform an initialization operation and further includes being configured to: apply for a buffer according to the frame size.
[0014] In the above data receiving device, the processing unit is configured to perform an initialization operation and further includes being configured to: create an additional receiving thread to receive and parse the data stream.
[0015] In the above data receiving device, the processing unit is further configured to: create a callback function for the additional receiving thread to call the parsed data frame.
[0016] According to a third aspect of the present invention, there is provided a data transmission system, the system including: any one of the data sending devices as described in the above data sending device; and any one of the data receiving devices as described in the above data receiving device.
[0017] According to a fourth aspect of the present invention, there is provided a data transmission method executed by a data sending device, the method including: performing an initialization operation to determine the Internet Protocol (IP) address and port number of the data sending device; sending data information to a data receiving device by a connectionless communication method, where the data information includes the IP address and port number of the data sending device, and the frame size of the data frame to be sent; receiving a connection request from the data receiving device to establish a connection with the data receiving device using the Transmission Control Protocol (TCP); receiving an acknowledgment response from the data receiving device by the connectionless communication method; and in response to receiving the acknowledgment response and the connection establishment being completed, sending a data stream to the data receiving device through the TCP, where the data frames in the data stream can be parsed based on the frame size.
[0018] According to a fifth aspect of the present invention, there is provided a data transmission method performed by a data receiving device, the method comprising: receiving data information from a data sending device by means of connectionless communication, the data information including the Internet Protocol (IP) address and port number of the data sending device, and the frame size of a data frame to be sent; performing an initialization operation to parse the data information and record the IP address and port number of the data sending device in the data information, and the frame size of the data frame to be sent; sending a connection request to the data sending device based on the IP address and port number of the data sending device in the data information to establish a connection with the data sending device using the Transmission Control Protocol (TCP); sending an acknowledgement response to the data sending device by means of the connectionless communication; receiving a data stream from the data sending device through the TCP; and parsing the data frames in the data stream based on the frame size.
[0019] According to a sixth aspect of the present invention, there is provided a data transmission method performed by a data transmission system, comprising: the data sending device performing an initialization operation to determine the Internet Protocol (IP) address and port number of the data sending device; the data sending device sending data information to a data receiving device by means of connectionless communication, the data information including the IP address and port number of the data sending device, and the frame size of a data frame to be sent; the data receiving device performing an initialization operation to parse the data information and record the IP address and port number of the data sending device in the data information, and the frame size of the data frame to be sent; the data receiving device sending a connection request to the data sending device based on the IP address and port number of the data sending device in the data information to establish a connection with the data sending device using the Transmission Control Protocol (TCP); the data receiving device sending an acknowledgement response to the data sending device by means of the connectionless communication; the data sending device, in response to receiving the acknowledgement response and completion of connection establishment, sending a data stream to the data receiving device through the TCP; and the data receiving device parsing the data frames in the data stream based on the frame size. Description of the Drawings
[0020] The accompanying drawings are included to provide a further understanding of the present invention, and are incorporated in and constitute a part of this application. The drawings illustrate embodiments of the present invention and, together with the description, serve to explain the principles of the present invention. In the drawings:
[0021] Figure 1 A schematic diagram of a data sending device according to an embodiment of the present invention is shown;
[0022] Figure 2Shows a schematic diagram of a data receiving device according to an embodiment of the present invention;
[0023] Figure 3 Shows a schematic diagram of a data transmission system according to an embodiment of the present invention;
[0024] Figure 4 Shows an interaction schematic diagram of a data sending device and a data receiving device according to an embodiment of the present invention;
[0025] Figure 5 Shows a flowchart of a data transmission method executed by a data sending device according to an embodiment of the present invention;
[0026] Figure 6 Shows a flowchart of a data transmission method executed by a data receiving device according to an embodiment of the present invention; and
[0027] Figure 7 Shows a flowchart of a data transmission method executed by a data transmission system according to an embodiment of the present invention. Detailed Embodiments
[0028] Embodiments of the present invention will now be described in detail with reference to the accompanying drawings, but the present invention is not limited thereto and is only defined by the claims. In the drawings, for illustrative purposes, the dimensions of some of the elements may be enlarged and not drawn to scale. Whenever possible, the same reference numerals will be used throughout the drawings to represent the same or similar parts.
[0029] Although the terms used in the present invention are selected from well-known and commonly used terms, some of the terms mentioned in the description of the present invention may be selected by the applicant according to his or her judgment, and their detailed meanings are described in the relevant parts of the description herein. In addition, it is required to understand the present invention not only through the actual terms used, but also through the meaning implied by each term.
[0030] In the description provided herein, numerous specific details are set forth. However, it should be understood that embodiments of the present invention may be practiced without these specific details. In other instances, well-known methods, structures, and technologies have not been shown in detail so as not to obscure the understanding of the present invention.
[0031] To solve the foregoing technical problems, the present application proposes a data sending device, a data receiving device, and a data transmission system and method.
[0032] Figure 1A schematic diagram of a data sending device 110 according to an embodiment of the present invention is shown. In one embodiment, the data sending device 110 may be a board card or a client device, and is used to send the collected or received data stream to the data receiving device 120. When the data sending device 110 has a data stream to be sent to the data receiving device 120, a connection may be established between the data sending device 110 and the data receiving device 120 to use TCP to transmit the data stream. The data sending device 110 may include a sending interface 112, a receiving interface 114, and a processing unit 116. The sending interface 112 may be configured to send information to the data receiving device 120. The receiving interface 114 may be configured to receive information from the data receiving device 120. The processing unit 116 may be configured to control the sending interface 112, the receiving interface 114, and perform other processing operations.
[0033] In traditional communication methods, the data sending device and the data receiving device only use TCP to perform data transmission. Since TCP is connection-oriented and has no data boundary, when transmitting data through TCP, data frames may have the problem of packet adhesion or packet splitting due to the frame size. For example, if the data frame is small, it is easy to cause packet adhesion, that is, two data frames are spliced and transmitted in one data stream, or, if the data frame is too large to exceed the buffer size, it is easy to cause packet splitting, that is, one data frame is split into two or more data streams and then transmitted. Both packet adhesion and packet splitting will cause the data receiving device to be unable to accurately parse the data frames in the received data stream. Therefore, the present application innovatively proposes that before using TCP to transmit data, information related to the data frames to be sent is sent to the data receiving device through another communication method, so that the data receiving device can more accurately parse the data frames based on this information.
[0034] First, the processing unit 116 may be configured to perform an initialization operation to determine the Internet Protocol (IP) address and port number of the data sending device 110. The IP address and port number may be used to establish a TCP connection.
[0035] After performing the initialization operation, the processing unit 116 may be configured to cause the sending interface 112 to send data information to the data receiving device 120 through a connectionless communication method. The connectionless communication method refers to a communication method in which data can be transmitted between the data sending device 110 and the data receiving device 120 without establishing a connection. The connectionless communication method may use communication methods such as the User Datagram Protocol (UDP), serial port, Serial Peripheral Interface (SPI), or Inter-Integrated Circuit (IIC). Since the amount of data in the data information is very small, by using the connectionless communication method, the data sending device 110 can simply and quickly send the data information to the data receiving device 120 without the complex process of establishing a connection, thereby improving the efficiency of transmitting the data information.
[0036] The data information may include the IP address and port number of the data sending device 110, which are determined during the initialization operation of the data sending device 110. The data information may also include the frame size of the data frame to be sent. When the data frame sent by the data sending device 110 to the data receiving device 120 has a fixed format, the data sending device 110 may pre-determine the frame size of the data frame. For example, when the data frame to be sent by the data sending device 110 contains sensor data, the amount of data collected by the sensor each time may be fixed, so the frame size of the data frame can be pre-determined. Another example is that when the data frame to be sent by the data sending device 110 contains image information, each image may have the same size, so the frame size of the data frame can be pre-determined. Since the frame size of the data frame is fixed, the data information only needs to be sent once before the actual data stream is transmitted and can then be used for parsing multiple data streams. In one embodiment, when the connectionless communication method uses UDP, the data information may be transmitted as a UDP datagram. In one embodiment, when the connectionless communication method uses a hardware device such as a serial port, the data information may be directly transmitted through the serial port.
[0037] Then, the processing unit 116 can be configured to enable the receiving interface 114 to receive a connection request from the data receiving device 120 to establish a TCP-based connection with the data receiving device 120. The process of establishing a TCP-based connection between the data sending device 110 and the data receiving device 120 can be the three-way handshake process of TCP communication. For example, in the first handshake, the data receiving device 120 sends a TCP connection request to the data sending device 110 to request the establishment of a connection; in the second handshake, after receiving the request, the data sending device 110 sends a TCP connection request confirmation to the data receiving device 120, indicating agreement to establish a connection and entering the synchronized received state; in the third handshake, after receiving the TCP connection request confirmation, the data receiving device 120 sends a TCP acknowledgment to the data sending device 110 to confirm the establishment of the connection.
[0038] In addition, the processing unit 116 can be configured to enable the receiving interface 114 to receive an acknowledgment response from the data receiving device 120 in a connectionless communication manner. The acknowledgment response can be used to indicate that the data receiving device 120 has completed the reception preparation. It should be understood that the process of establishing a TCP-based connection between the data sending device 110 and the data receiving device 120 has no sequential relationship with the process of the data sending device 110 receiving an acknowledgment response from the data receiving device 120 in a connectionless communication manner, and they can be executed in parallel. In one embodiment, when the connectionless communication manner uses UDP, the acknowledgment response can be transmitted as a UDP datagram. In one embodiment, when the connectionless communication manner uses a serial port, the acknowledgment response can be directly transmitted through the serial port.
[0039] Since both UDP and TCP methods transmit data through the network interface, while the serial port is an independent transmission method from the network interface, when using the serial port as the connectionless communication manner, additional information can still be transmitted using the serial port while transmitting the data stream through TCP in the network interface to assist in the transmission and parsing of the data stream. For example, if the data receiving device 120 discovers an error in the data frame or a frame loss situation, the data receiving device 120 can send information through the serial port while receiving the data stream through TCP to notify the data sending device 110 to retransmit the data frame or solve such problems in other ways, without interrupting the data transmission process through TCP and without waiting for the end of the data transmission process through TCP, thereby improving the transmission efficiency.
[0040] Next, in response to receiving the acknowledgment response and the completion of the connection establishment, the processing unit 116 can be configured to enable the sending interface 112 to send a data stream to the data receiving device 120 through TCP, and the data frames in the data stream can be parsed based on the frame size in the data information.
[0041] In one embodiment, the data information may further include the header information and trailer information of the data frame to be sent. Compared with parsing the data frame using only the frame size, the header information and trailer information can help more accurately determine how to split or splice the data stream.
[0042] In one embodiment, the data information may further include the special position information of the data frame to be sent, and the special position information is used to indicate the position of specific information in the data frame. For example, when the data frame contains image information, assuming there is a red dot for marking in the image, the special position information can be used to indicate the position of the red dot in the frame.
[0043] Figure 2 FIG. shows a schematic diagram of a data receiving device 220 according to an embodiment of the present invention. In one embodiment, the data receiving device 220 may be a host computer or a server device, and is used to receive the data stream from the data sending device 210 for further processing. When the data sending device 210 has a data stream to be sent to the data receiving device 220, a connection may be established between the data sending device 210 and the data receiving device 220 to use TCP to transmit the data stream. The data receiving device 220 may include a sending interface 222, a receiving interface 224, and a processing unit 226. The sending interface 222 may be configured to send information to the data sending device 210. The receiving interface 224 may be configured to receive information from the data sending device 210. The processing unit 226 may be configured to control the sending interface 222, the receiving interface 224, and perform other processing operations.
[0044] After the data sending device 210 sends the data information to the data receiving device 220 through a connectionless communication method, the processing unit 226 may be configured to cause the receiving interface 224 to receive the data information from the data sending device 210 through a connectionless communication method. The connectionless communication method refers to a communication method in which data can be transmitted between the data sending device 210 and the data receiving device 220 without establishing a connection. The connectionless communication method may use communication methods such as the User Datagram Protocol (UDP), serial port, Serial Peripheral Interface (SPI), or Inter-Integrated Circuit (IIC). Since the data volume of the data information is very small, by using the connectionless communication method, the data receiving device 220 can directly receive the data information from the data sending device 210 without the complex process of establishing a connection, thereby improving the efficiency of transmitting the data information.
[0045] The data information may include the IP address and port number of the data sending device 210, as well as the frame size of the data frame to be sent. When the data frame sent by the data sending device 210 to the data receiving device 220 has a fixed format, the frame size of the data frame can be pre-determined by the data sending device 210. For example, when the data frame to be sent by the data sending device 210 contains sensor data, the amount of data collected by the sensor each time may be fixed, so the frame size of the data frame can be pre-determined. Another example is that when the data frame to be sent by the data sending device 210 contains image information, each image may have the same size, so the frame size of the data frame can be pre-determined. Since the frame size of the data frame is fixed, the data information only needs to be sent once before the actual data stream transmission and can then be used for the parsing of multiple data streams. In one embodiment, when the connectionless communication mode uses UDP, the data information can be transmitted as a UDP datagram. In one embodiment, when the connectionless communication mode uses a hardware device such as a serial port, the data information can be directly transmitted through the serial port.
[0046] Then, the processing unit 226 can be configured to perform an initialization operation for preparing to establish a TCP connection and receive a data stream. The processing unit 226 can be configured to parse the data information and record the IP address and port number of the data sending device 210 in the data information, as well as the frame size of the data frame to be sent. The IP address and port number of the data sending device 210 can be used to establish a TCP connection, and the frame size of the data frame to be sent can be used for the parsing of the data stream.
[0047] In one embodiment, the processing unit 226 being configured to perform the initialization operation may further include being configured to apply for a buffer according to the frame size in the data information. In traditional TCP communication, a buffer can be automatically allocated for the data receiving device 220. However, when the frame size of the data frame is too large, if the buffer is relatively small, the data receiving device 220 may not have enough time to process the received data frame, and the buffer can only store part of the data, resulting in an overflow, which may cause the loss of the data frame, that is, packet loss. Since the data receiving device 220 has received the data information through the connectionless communication mode before the actual TCP communication, the data receiving device 220 can apply for a buffer according to the frame size in the data information. By applying for a buffer according to the frame size in the data information, even if the data frame is very large, the data receiving device 220 can store the data frame in the buffer for subsequent processing, thereby avoiding the situation of packet loss.
[0048] In one embodiment, the processing unit 226 configured to perform the initialization operation may further include being configured to create additional receiving threads to receive and parse data streams. By using dedicated receiving threads to receive and parse data frames, the parsing efficiency can be improved, the timeliness of data parsing can be ensured, and thus the situation of packet loss can be avoided.
[0049] Next, the processing unit 226 may be configured to cause the sending interface 222 to send a connection request to the data sending device 210 based on the IP address and port number of the data sending device 210 in the data information, so as to establish a TCP-based connection with the data sending device 210. The process of establishing a TCP-based connection between the data sending device 210 and the data receiving device 220 may be a three-way handshake process. For example, in the first handshake, the data receiving device 220 sends a TCP connection request to the data sending device 210, requesting to establish a connection; in the second handshake, after receiving the request, the data sending device 210 sends a TCP connection request confirmation to the data receiving device 220, indicating agreement to establish a connection and entering the synchronized received state; in the third handshake, after receiving the TCP connection request confirmation, the data receiving device 220 sends a TCP confirmation to the data sending device 210 to confirm the establishment of the connection.
[0050] In addition, the processing unit 226 may be configured to cause the sending interface 222 to send an acknowledgment response to the data sending device 210 in a connectionless communication manner. The acknowledgment response may be used to indicate that the data receiving device 220 has completed the reception preparation. It should be understood that the process of establishing a TCP-based connection between the data sending device 210 and the data receiving device 220 and the process of the data receiving device 220 sending an acknowledgment response to the data sending device 210 in a connectionless communication manner have no sequence relationship and may be executed in parallel. In one embodiment, when the connectionless communication manner uses UDP, the acknowledgment response may be transmitted as a UDP datagram. In one embodiment, when the connectionless communication manner uses a serial port, the acknowledgment response may be directly transmitted through the serial port.
[0051] Since both UDP and TCP methods transmit data through the network interface, while the serial port is an independent transmission method from the network interface, when using the serial port as the connectionless communication manner, additional information can still be transmitted using the serial port while transmitting the data stream through TCP in the network interface, so as to assist in the transmission and parsing of the data stream. For example, if the data receiving device 220 finds that there is an error in the data frame or there is a situation of frame loss, the data receiving device 220 can send information through the serial port while receiving the data stream through TCP, so as to notify the data sending device 210 to retransmit the data frame or solve such problems in other ways, without interrupting the data transmission process through TCP and without waiting for the end of the data transmission process through TCP, thereby improving the transmission efficiency.
[0052] Subsequently, the processing unit 226 can be configured to cause the receiving interface 224 to receive a data stream from the data sending device 210 via TCP.
[0053] Subsequently, the processing unit 226 can be configured to parse data frames in the data stream based on the frame size.
[0054] In one embodiment, the processing unit 226 being configured to parse data frames in the data stream based on the frame size may include being configured to: determine whether a data frame is independent based on the frame size. Whether a data frame is independent means whether the received data stream contains only one data frame. For example, when there is a case of packet adhesion, a data stream may include multiple data frames, and when there is a case of packet splitting, a data frame may be split into multiple data streams. Therefore, in these cases, the data stream does not include only one data frame, that is, the data frame is not independent.
[0055] If the data frame is not independent, the processing unit 226 can be configured to split or splice the data stream based on the frame size. For example, if the size of the data stream is greater than the frame size, that is, the data stream contains more than one data frame and there is a case of packet adhesion, the data stream can be split into multiple data frames according to the frame size. For example, if the size of the data stream is less than the frame size, that is, the data stream contains only a part of the data frame and there is a case of packet splitting, multiple data streams can be spliced into one data frame according to the frame size.
[0056] Since the frame size has been transmitted through the connectionless communication method, the processing unit 226 can quickly determine whether a data frame is independent according to the frame size. Therefore, the problems of packet adhesion and packet splitting can be solved based on the frame size.
[0057] In one embodiment, the data information may further include the header information and the trailer information of the data frame to be transmitted. The processing unit 226 is configured to parse the data frames in the data stream based on the frame size, which may include being configured to: determine whether a data frame is independent based on the frame size. If the data frame is not independent, the processing unit 226 may be configured to split or splice the data stream based on the frame size, the header information, and the trailer information. For example, if the size of the data stream is greater than the frame size, that is, the data stream contains more than one data frame and there is a situation of packet sticking, the data stream may be split into multiple data frames according to the frame size, the header information, and the trailer information. For example, if the size of the data stream is less than the frame size, that is, the data stream only contains a part of the data frame and there is a situation of unpacking, multiple data streams may be spliced into one data frame according to the frame size, the header information, and the trailer information. Compared with using only the frame size to split or splice the data stream, the header information and the trailer information can provide double guarantees to ensure the accuracy of splitting and splicing.
[0058] In one embodiment, the data information may further include the special position information of the data frame to be transmitted, and the special position information is used to indicate the position of specific information in the data frame. For example, when the data frame contains image information, assuming there is a red dot for marking in the image, the special position information may be used to indicate the position of the red dot in the frame. The processing unit 226 is configured to parse the data frames in the data stream based on the frame size, which may further include being configured to: parse the specific information in the data frame based on the special position information. For example, when the data frame contains image information, it may be parsed based on the special position information to find out at which position in the frame the red dot in the image can be found.
[0059] In one embodiment, the processing unit 226 may further be configured to create a callback function for an additional receiving thread to call the parsed data frame. After the receiving thread receives and parses the data frame, the processing thread of the data receiving device 220 may directly call the parsed data frame by using the callback function, thereby improving the processing efficiency.
[0060] Figure 3FIG. 0 shows a schematic diagram of a data transmission system 300 according to an embodiment of the present invention. The data transmission system 300 may include a data sending device 310 and a data receiving device 320. In one embodiment, the data sending device 310 may be a board card or a client device, and the data receiving device 320 may be a host computer or a server device. The data sending device 310 may include a sending interface 312, a receiving interface 314, and a processing unit 316. The sending interface 312 may be configured to send information to the data receiving device 320. The receiving interface 314 may be configured to receive information from the data receiving device 320. The processing unit 316 may be configured to control the sending interface 312, the receiving interface 314, and perform other processing operations. The data receiving device 320 may include a sending interface 322, a receiving interface 324, and a processing unit 326. The sending interface 322 may be configured to send information to the data sending device 310. The receiving interface 324 may be configured to receive information from the data sending device 310. The processing unit 326 may be configured to control the sending interface 322, the receiving interface 324, and perform other processing operations.
[0061] The data sending device 310 may be the data sending device 110 described in conjunction with Figure 1 description, and the data receiving device 320 may be the data receiving device 220 described in conjunction with Figure 2 description. For the sake of clarity, details regarding the data sending device 310 and the data receiving device 320 are not elaborated herein.
[0062] Figure 4 FIG. 11 shows an interaction schematic diagram between a data sending device 402 and a data receiving device 404 according to an embodiment of the present invention. In one embodiment, the data sending device 402 may be a board card or a client device, and is used to send the collected or received data stream to the data receiving device 404. The data receiving device 404 may be a host computer or a server device, and is used to receive the data stream from the data sending device 402 for further processing. When the data sending device 402 has a data stream to be sent to the data receiving device 404, a connection may be established between the data sending device 402 and the data receiving device 404 to use TCP to transmit the data stream.
[0063] At (1), the data sending device 402 may perform an initialization operation to determine the Internet Protocol (IP) address and port number of the data sending device 402. The IP address and port number may be used to establish a TCP connection.
[0064] After the data sending device 402 performs the initialization operation, at (2), the data sending device 402 can send data information to the data receiving device 404 through a connectionless communication method. The connectionless communication method refers to a communication method in which data can be transmitted between the data sending device 402 and the data receiving device 404 without establishing a connection. The connectionless communication method can be a communication method such as the User Datagram Protocol (UDP), serial port, Serial Peripheral Interface (SPI), Inter-Integrated Circuit (IIC), etc. Since the amount of data of the data information is very small, by using the connectionless communication method, the data sending device 402 can simply and quickly send the data information to the data receiving device 404 without the complex process of establishing a connection, thereby improving the efficiency of transmitting the data information.
[0065] The data information may include the IP address and port number of the data sending device 402, which are determined during the initialization operation of the data sending device 402. The data information may also include the frame size of the data frame to be sent. When the data frame sent by the data sending device 402 has a fixed format, the data sending device 402 can pre-determine the frame size of the data frame. For example, when the data frame to be sent by the data sending device 402 contains sensor data, the amount of data collected by the sensor each time may be fixed, so the frame size of the data frame can be pre-determined. Another example is that when the data frame to be sent by the data sending device 402 contains image information, each image may have the same size, so the frame size of the data frame can be pre-determined. Since the frame size of the data frame is fixed, the data information only needs to be sent once before the actual data stream is transmitted and can then be used for the parsing of multiple data streams. In one embodiment, when the connectionless communication method uses UDP, the data information can be transmitted as a UDP datagram. In one embodiment, when the connectionless communication method uses a hardware device such as a serial port, the data information can be directly transmitted through the serial port.
[0066] Then, after receiving the data information from the data sending device 402, at (3), the data receiving device 404 can perform an initialization operation to prepare for establishing a TCP connection and receiving the data stream. The data receiving device 404 can parse the data information and record the IP address and port number of the data sending device 402 in the data information, as well as the frame size of the data frame to be sent. The IP address and port number of the data sending device 402 can be used to establish a TCP connection, and the frame size of the data frame to be sent can be used for the parsing of the data stream.
[0067] In one embodiment, the data receiving device 404 performing the initialization operation may further include applying for a buffer according to the frame size in the data information. In traditional TCP communication, a buffer can be automatically allocated for the data receiving device 404. However, when the frame size of the data frame is too large, the data receiving device 404 may not have enough time to process the received data frame. If the buffer is relatively small, the buffer can only store part of the data, resulting in an overflow, which may cause the loss of the data frame, that is, packet loss. Since the data receiving device 404 has received the data information through a connectionless communication method before the actual TCP communication, the data receiving device 404 can apply for a buffer according to the frame size in the data information. By applying for a buffer according to the frame size in the data information, even if the data frame is very large, the data receiving device 404 can store the data frame in the buffer for subsequent processing, thereby avoiding the situation of packet loss.
[0068] In one embodiment, the data receiving device 404 performing the initialization operation may further include creating an additional receiving thread to receive and parse the data stream. By using a dedicated receiving thread to receive and parse the data frame, the parsing efficiency can be improved, ensuring the timeliness of data parsing, and thus also avoiding the situation of packet loss.
[0069] Next, at (4), the data receiving device 404 may send a connection request to the data sending device 402 based on the IP address and port number of the data sending device 402 in the data information to establish a TCP connection with the data sending device 402. The process of establishing a TCP connection between the data sending device 402 and the data receiving device 404 may be a three-way handshake process. For example, in the first handshake, the data receiving device 404 sends a TCP connection request to the data sending device 402, requesting to establish a connection; in the second handshake, after receiving the request, the data sending device 402 sends a TCP connection request confirmation to the data receiving device 404, indicating agreement to establish a connection and entering the synchronized received state; in the third handshake, after receiving the TCP connection request confirmation, the data receiving device 404 sends a TCP confirmation to the data sending device 402, confirming the establishment of the connection.
[0070] In addition, at (5), the data receiving device 404 may send an acknowledgment response to the data sending device 402 by means of connectionless communication. The acknowledgment response may be used to indicate that the data receiving device 404 has completed the reception preparation. It should be understood that the process of establishing a connection using TCP between the data sending device 402 and the data receiving device 404 at (4) and the process of the data receiving device 404 sending an acknowledgment response to the data sending device 402 by means of connectionless communication at (5) have no sequential relationship and may be executed in parallel. In one embodiment, when the connectionless communication uses UDP, the acknowledgment response may be transmitted as a UDP datagram. In one embodiment, when the connectionless communication uses a serial port, the acknowledgment response may be directly transmitted through the serial port.
[0071] Since both UDP and TCP methods transmit data through the network interface, information cannot be transmitted simultaneously by UDP and TCP methods. However, the serial port is an independent transmission method from the network interface. Therefore, when using the serial port as the connectionless communication method, additional information can still be transmitted using the serial port while transmitting the data stream through TCP in the network interface to assist in the transmission and parsing of the data stream. For example, if the data receiving device 404 discovers an error in the data frame or a frame loss situation, the data receiving device 404 can send information through the serial port while receiving the data stream through TCP to notify the data sending device 402 to retransmit the data frame or resolve such problems in other ways, without interrupting the data transmission process through TCP and without waiting for the end of the data transmission process through TCP, thereby improving the transmission efficiency.
[0072] Next, at (6), in response to receiving the acknowledgment response and the completion of the connection establishment, the data sending device 402 may send a data stream to the data receiving device 404 through TCP.
[0073] Subsequently, at (7), the data receiving device 404 may parse the data frames in the data stream based on the frame size.
[0074] In one embodiment, the data receiving device 404 parsing the data frames in the data stream based on the frame size may include: determining whether the data frame is independent based on the frame size. Whether the data frame is independent means whether the received data stream contains only one data frame. For example, in the case of packet adhesion, a data stream may include multiple data frames, and in the case of packet splitting, a data frame may be split into multiple data streams. Therefore, in these cases, the data stream does not include only one data frame, that is, the data frame is not independent.
[0075] If the data frame is not independent, the data receiving device 404 can split or splice the data stream based on the frame size. For example, if the size of the data stream is greater than the frame size, that is, the data stream contains more than one data frame and there is a situation of packet sticking, the data stream can be split into multiple data frames according to the frame size. For example, if the size of the data stream is less than the frame size, that is, the data stream only contains a part of the data frame and there is a situation of packet unpacking, multiple data streams can be spliced into one data frame according to the frame size.
[0076] Since the frame size has been transmitted through the connectionless communication method, the data receiving device 404 can quickly determine whether the data frame is independent according to the frame size, so the problems of packet sticking and unpacking can be solved based on the frame size.
[0077] In one embodiment, the data information may further include the frame header information and frame tail information of the data frame to be transmitted. The data receiving device 404 parsing the data frame in the data stream based on the frame size may include: judging whether the data frame is independent based on the frame size. If the data frame is not independent, the data receiving device 404 can split or splice the data frame in the data stream based on the frame size, frame header information and frame tail information. For example, if the size of the data stream is greater than the frame size, that is, the data stream contains more than one data frame and there is a situation of packet sticking, the data stream can be split into multiple data frames according to the frame size, frame header information and frame tail information. For example, if the size of the data stream is less than the frame size, that is, the data stream only contains a part of the data frame and there is a situation of packet unpacking, multiple data streams can be spliced into one data frame according to the frame size, frame header information and frame tail information. Compared with using only the frame size to split or splice the data stream, the frame header information and frame tail information can provide double guarantees to ensure the accuracy of splitting and splicing.
[0078] In one embodiment, the data information may further include the special position information of the data frame to be transmitted, and the special position information is used to indicate the position of specific information in the data frame. For example, when the data frame contains image information, assuming there is a red dot for marking in the image, the special position information can be used to indicate the position of the red dot in the frame. The data receiving device 404 parsing the data frame in the data stream based on the frame size may include: parsing the specific information in the data frame based on the special position information. For example, when the data frame contains image information, the position where the red dot in the image can be found in the frame can be parsed based on the special position information.
[0079] In one embodiment, the data receiving device 404 can also create a callback function for an additional receiving thread to be used to call the parsed data frame. After the receiving thread receives and parses the data frame, the processing thread of the data receiving device 404 can directly call the parsed data frame by using the callback function, thereby improving the processing efficiency.
[0080] Figure 5 The flowchart of data transmission method 500 executed by a data sending device according to an embodiment of the present invention is shown.
[0081] At step 502, the data sending device may perform an initialization operation to determine the Internet Protocol (IP) address and port number of the data sending device.
[0082] At step 504, the data sending device may send data information to the data receiving device through a connectionless communication method. The data information includes the IP address and port number of the data sending device, and the frame size of the data frame to be sent. In one embodiment, the connectionless communication method may use one of the following: User Datagram Protocol (UDP), serial port, Serial Peripheral Interface (SPI), Inter-Integrated Circuit (IIC). In one embodiment, the data information may further include the frame header information and frame tail information of the data frame to be sent. In one embodiment, the data information may further include the special position information of the data frame to be sent, and the special position information is used to indicate the position of specific information in the data frame.
[0083] At step 506, the data sending device may receive a connection request from the data receiving device to establish a connection with the data receiving device using the Transmission Control Protocol (TCP).
[0084] At step 508, the data sending device may receive an acknowledgement response from the data receiving device through a connectionless communication method.
[0085] At step 510, in response to receiving the acknowledgement response and the completion of connection establishment, the data sending device may send a data stream to the data receiving device through TCP, and the data frames in the data stream can be parsed based on the frame size.
[0086] Figure 6 The flowchart of data transmission method 600 executed by a data receiving device according to an embodiment of the present invention is shown.
[0087] At step 602, the data receiving device may receive data information from the data sending device through a connectionless communication method. The data information may include the Internet Protocol (IP) address and port number of the data sending device, and the frame size of the data frame to be sent. In one embodiment, the connectionless communication method may use one of the following: User Datagram Protocol (UDP), serial port, Serial Peripheral Interface (SPI), Inter-Integrated Circuit (IIC).
[0088] At step 604, the data receiving device may perform an initialization operation to parse the data information and record the IP address and port number of the data sending device in the data information, as well as the frame size of the data frame to be sent.
[0089] In one embodiment, performing the initialization operation may further include: the data receiving device applying for a buffer according to the frame size in the data information.
[0090] In one embodiment, performing the initialization operation may further include: the data receiving device creating an additional receiving thread to receive and parse the data stream.
[0091] At step 606, the data receiving device may send a connection request to the data sending device based on the IP address and port number of the data sending device in the data information to establish a connection with the data sending device using the Transmission Control Protocol (TCP).
[0092] At step 608, the data receiving device may send an acknowledgement response to the data sending device by means of connectionless communication.
[0093] At step 610, the data receiving device may receive the data stream from the data sending device via TCP.
[0094] At step 612, the data receiving device may parse the data frame in the data stream based on the frame size.
[0095] In one embodiment, the data receiving device parsing the data frame in the data stream based on the frame size may include: judging whether the data frame is independent based on the frame size; and if the data frame is not independent, splitting or splicing the data stream based on the frame size.
[0096] In one embodiment, the data information may further include the frame header information and frame tail information of the data frame to be sent, and the data receiving device parsing the data frame in the data stream based on the frame size may include: judging whether the data frame is independent based on the frame size; and if the data frame is not independent, splitting or splicing the data stream based on the frame size, frame header information and frame tail information.
[0097] In one embodiment, the data information may further include the special position information of the data frame to be sent, and the special position information is used to indicate the position of specific information in the data frame, and the data receiving device parsing the data frame in the data stream based on the frame size may further include: parsing the specific information in the data frame based on the special position information.
[0098] In one embodiment, method 600 may further include: creating a callback function for the additional receiving thread to be used to call the parsed data frame.
[0099] Figure 7 FIG. 1 shows a flowchart of a data transmission method 700 performed by a data transmission system according to an embodiment of the present invention. The data transmission system may include a data sending device and a data receiving device.
[0100] At step 702, the data sending device may perform an initialization operation to determine the Internet Protocol (IP) address and port number of the data sending device.
[0101] At step 704, the data sending device may send data information to the data receiving device through a connectionless communication mode. The data information includes the IP address and port number of the data sending device, and the frame size of the data frame to be sent. In one embodiment, the connectionless communication mode may use one of the following: User Datagram Protocol (UDP), serial port, Serial Peripheral Interface (SPI), Inter-Integrated Circuit (IIC).
[0102] At step 706, the data receiving device may perform an initialization operation to parse the data information and record the IP address and port number of the data sending device in the data information, and the frame size of the data frame to be sent.
[0103] In one embodiment, performing the initialization operation may further include: the data receiving device applying for a buffer according to the frame size in the data information.
[0104] In one embodiment, performing the initialization operation may further include: the data receiving device creating an additional receiving thread to receive and parse the data stream.
[0105] At step 708, the data receiving device may send a connection request to the data sending device based on the IP address and port number of the data sending device in the data information to establish a connection using the Transmission Control Protocol (TCP) with the data sending device.
[0106] At step 710, the data receiving device may send an acknowledgment response to the data sending device through a connectionless communication mode.
[0107] At step 712, the data sending device may send a data stream to the data receiving device through TCP in response to receiving the acknowledgment response and the connection establishment being completed.
[0108] At step 714, the data receiving device may parse the data frame in the data stream based on the frame size.
[0109] In one embodiment, the data receiving device parsing the data frame in the data stream based on the frame size may include: determining whether the data frame is independent based on the frame size; and if the data frame is not independent, splitting or splicing the data stream based on the frame size.
[0110] In one embodiment, the data information may further include the header information and trailer information of the data frame to be sent, and the data receiving device parsing the data frame in the data stream based on the frame size may include: determining whether the data frame is independent based on the frame size; and if the data frame is not independent, splitting or splicing the data stream based on the frame size, the header information, and the trailer information.
[0111] In one embodiment, the data information may further include the special position information of the data frame to be sent, where the special position information is used to indicate the position of specific information in the data frame, and the data receiving device parsing the data frame in the data stream based on the frame size may further include: parsing the specific information in the data frame based on the special position information.
[0112] In one embodiment, method 700 may further include: the data receiving device creating a callback function for an additional receiving thread to be used to call the parsed data frame.
[0113] By pre-sending the data information, the present application enables the data receiving device to accurately parse the data frame according to the frame size in the data information, thereby solving the problem of packet adhesion and / or packet splitting. By using a connectionless communication method, the data information can be directly transmitted without establishing a connection, thereby improving the transmission efficiency.
[0114] References to "one embodiment" or "an embodiment" throughout this specification mean that a particular feature, structure, or characteristic described in connection with the embodiment is included in at least one embodiment of the present invention. Thus, the phrases "in one embodiment" or "in an embodiment" appearing throughout this specification do not necessarily all refer to the same embodiment, but may refer to the same embodiment. Additionally, in one or more embodiments, as will be apparent to those of ordinary skill in the art from this disclosure, the particular features, structures, or characteristics may be combined in any suitable manner.
[0115] It will be apparent to those skilled in the art that various modifications and variations can be made to the above exemplary embodiments of the present invention without departing from the spirit and scope of the present invention. Accordingly, it is intended that the present invention cover modifications and variations that fall within the scope of the appended claims and their equivalent technical solutions.
Claims
1. A data sending device, comprising: a sending interface, the sending interface being configured to send information to a data receiving device; a receiving interface, the receiving interface being configured to receive information from the data receiving device; as well as A processing unit configured to: Performing an initialization operation to determine an Internet Protocol (IP) address and a port number of the data sending device, the data sending device including a board or a client device; The sending interface sends data information to the data receiving device in a connectionless communication mode, wherein the data information includes an IP address and a port number of the data sending device and a frame size of a data frame to be sent, wherein if the data frame has a fixed format, the data information is sent only once before the actual data stream is transmitted; causing the receiving interface to receive a connection request from the data receiving device to establish a connection with the data receiving device using a transmission control protocol (TCP); causing the receiving interface to receive a confirmation response from the data receiving device through the connectionless communication method; and In response to receiving the confirmation response and completing the connection establishment, the sending interface sends a data stream to the data receiving device through the TCP in the network port, and uses the serial port to transmit additional information to assist in the transmission and parsing of the data stream. The data frames in the data stream can be parsed based on the frame size.
2. The data transmission device according to claim 1, wherein: The data information also includes frame header information and frame tail information of the data frame to be sent.
3. The data transmission device according to claim 1, wherein: The data information also includes special position information of the data frame to be sent, and the special position information is used to indicate the position of specific information in the data frame.
4. A data receiving device, comprising: A sending interface, the sending interface is configured to send information to a data sending device, the data sending device includes a board or a client device; a receiving interface, the receiving interface being configured to receive information from the data sending device; as well as A processing unit configured to: The receiving interface receives data information from the data sending device in a connectionless communication mode, wherein the data information includes an Internet Protocol (IP) address and a port number of the data sending device and a frame size of a data frame to be sent, wherein if the data frame has a fixed format, the data information is sent only once before the transmission of an actual data stream; Performing an initialization operation to parse the data information and record the IP address and port number of the data sending device and the frame size of the data frame to be sent in the data information; The sending interface sends a connection request to the data sending device based on the IP address and port number of the data sending device in the data information to establish a connection with the data sending device using a transmission control protocol (TCP); causing the sending interface to send a confirmation response to the data sending device through the connectionless communication mode; enabling the receiving interface to receive the data stream from the data sending device through the TCP in the network port, and using the serial port to transmit additional information to assist in the transmission and analysis of the data stream; and Data frames in the data stream are parsed based on the frame size.
5. The data receiving device according to claim 4, wherein: The processing unit is configured to parse the data frames in the data stream based on the frame size, including being configured to: determining whether the data frames are independent based on the frame size; as well as If the data frames are not independent, the data stream is split or spliced based on the frame size.
6. The data receiving device according to claim 4, wherein: The data information further includes frame header information and frame tail information of a data frame to be sent, and the processing unit is configured to parse the data frame in the data stream based on the frame size, including being configured to: determining whether the data frames are independent based on the frame size; as well as If the data frames are not independent, the data stream is split or spliced based on the frame size, the frame header information and the frame tail information.
7. The data receiving device according to claim 5 or 6, wherein: The data information further includes special position information of the data frame to be sent, the special position information being used to indicate the position of specific information in the data frame, and the processing unit being configured to parse the data frame in the data stream based on the frame size further includes being configured to: Specific information in the data frame is parsed based on the special position information.
8. The data receiving device according to claim 4, wherein: The processing unit is configured to perform an initialization operation and further configured to: A buffer is requested according to the frame size.
9. The data receiving device according to claim 4, wherein: The processing unit is configured to perform an initialization operation and further configured to: An additional receive thread is created to receive and parse the data stream.
10. The data receiving device according to claim 9, wherein: The processing unit is further configured to: A callback function is created for the additional receiving thread to be used for calling the parsed data frame.
11. A data transmission system, the system comprising: The data sending device according to any one of claims 1 to 3; as well as A data receiving device as claimed in any one of claims 4 to 10.
12. A data transmission method performed by a data sending device, the method comprising: Performing an initialization operation to determine an Internet Protocol (IP) address and a port number of a data transmission device, the data transmission device including a board or a client device; Sending data information to a data receiving device in a connectionless communication mode, the data information including an IP address and a port number of the data sending device and a frame size of a data frame to be sent, wherein if the data frame has a fixed format, the data information is sent only once before transmission of an actual data stream; receiving a connection request from the data receiving device to establish a connection with the data receiving device using a transmission control protocol (TCP); receiving a confirmation response from the data receiving device via the connectionless communication method; and In response to receiving the confirmation response and completing the connection establishment, a data stream is sent to the data receiving device through the TCP in the network port, and additional information is transmitted using the serial port to assist in the transmission and parsing of the data stream. The data frames in the data stream can be parsed based on the frame size.
13. A data transmission method performed by a data receiving device, the method comprising: Receiving data information from a data sending device in a connectionless communication mode, the data information including an Internet Protocol (IP) address and a port number of the data sending device and a frame size of a data frame to be sent, the data sending device including a board or a client device; Performing an initialization operation to parse the data information and record the IP address and port number of the data sending device and the frame size of the data frame to be sent in the data information, wherein if the data frame has a fixed format, the data information is sent only once before the transmission of the actual data stream; Sending a connection request to the data sending device based on the IP address and port number of the data sending device in the data information to establish a connection with the data sending device using a transmission control protocol (TCP); Sending a confirmation response to the data sending device via the connectionless communication method; receiving a data stream from the data sending device through the TCP in the network port, and using the serial port to transmit additional information to assist in the transmission and analysis of the data stream; and Data frames in the data stream are parsed based on the frame size.
14. A data transmission method performed by a data transmission system, comprising: The data sending device performs an initialization operation to determine an Internet Protocol (IP) address and a port number of the data sending device, the data sending device comprising a board or a client device; The data sending device sends data information to the data receiving device in a connectionless communication mode, wherein the data information includes an IP address and a port number of the data sending device and a frame size of a data frame to be sent, wherein if the data frame has a fixed format, the data information is sent only once before the transmission of an actual data stream; The data receiving device performs an initialization operation to parse the data information and record the IP address and port number of the data sending device in the data information, and the frame size of the data frame to be sent; The data receiving device sends a connection request to the data sending device based on the IP address and port number of the data sending device in the data information to establish a connection with the data sending device using a transmission control protocol (TCP); The data receiving device sends a confirmation response to the data sending device via the connectionless communication method; In response to receiving the confirmation response and completing the connection establishment, the data sending device sends a data stream to the data receiving device through the TCP in the network port, and uses the serial port to transmit additional information to assist in the transmission and analysis of the data stream; and The data receiving device parses the data frames in the data stream based on the frame size.
Citation Information
Patent Citations
TCP packet splicing handling method, server and system
CN107040549A
Synchronous communication method and synchronous communication system among virtual reality devices
CN107612947A