Data transmission method and related device
Patent Information
- Application Number
- CN202280098924.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-22
- Publication Date
- 2025-03-18
AI Technical Summary
In a simple communication scenario, part of the header content in the messages exchanged between communication devices does not play a role in the transmission process, resulting in an increase in redundant content, reduced data transmission efficiency, and increased power consumption of the communication device.
In the case of a connection that does not forward through the network layer, the message structure is simplified, only the transport layer header and the data link layer header are retained, the network layer header is omitted, and the communication connection is realized through the MAC address and port number.
The message overhead is reduced, the data transmission efficiency is improved, the power consumption of the communication device is reduced, and the reliability of short-distance communication is ensured.
Smart Images

Figure CN119654855A_ABST
Abstract
Description
A data transmission method and related device Technical Field
[0001] The present application relates to the field of computer network technology, and in particular to a data transmission method and related devices. Background Art
[0002] In the field of network communications, two communicating devices often need to construct messages according to a predefined transmission protocol and exchange messages to achieve data communication. The messages exchanged between the communication devices include the valid data to be transmitted between the communication devices and some parameters specified in the transmission protocol.
[0003] Currently, the most widely used transmission protocol is the Transmission Control Protocol (TCP) / Internet Protocol (IP) suite. Messages constructed by communication devices based on the TCP / IP suite often include payload data, a TCP header, an IP header, and a link-layer header. These headers, such as the TCP header, IP header, and link-layer header, are responsible for enabling message transmission between communication devices.
[0004] However, in some simple communication scenarios, for messages exchanged between communication devices, some header content may not be used during the actual transmission of the message, that is, this part of the message content is redundant. Therefore, if each message exchanged between communication devices contains redundant content, the amount of data transmitted between the communication devices will increase, thereby reducing data transmission latency and increasing the power consumption of the communication devices.
[0005] Summary of the Invention
[0006] The present application provides a data transmission method. When the communication connection established between two communication devices is a connection that does not require data forwarding through the network layer, the message structure exchanged between the communication devices is simplified, and the network layer header is not carried in the message. Only the transport layer header and data link layer header used to realize message transmission are retained, thereby reducing message overhead, improving data transmission efficiency and reducing power consumption of the communication device.
[0007] The first aspect of the present application provides a data transmission method, which is applied to a first communication device. The method includes: based on the communication connection between the first communication device and the second communication device being a connection that does not forward data through the network layer, the first communication device generates a first message, the first message including a payload, a transport layer header, and a data link layer header, and the first message does not include a network layer header. Among them, the connection that does not forward data through the network layer can specifically be a (peer-to-peer, P2P) point-to-point connection or a star connection.
[0008] When the communication connection between the first communication device and the second communication device is a connection that does not forward data through the network layer, the messages exchanged between the first communication device and the second communication device no longer need to be forwarded through the IP address in the network layer header.
[0009] The first communication device then sends the first message to the second communication device via the aforementioned communication connection. Because the communication connection between the first and second communication devices does not forward data via the network layer, message transmission can be achieved even if the first message does not include a network layer header, that is, does not include the IP addresses of the first and second communication devices.
[0010] In this solution, when the communication connection established between two communication devices is a connection that does not require data forwarding through the network layer, the message structure exchanged between the communication devices is simplified, and the network layer header is not carried in the message. Only the transport layer header and data link layer header used to implement message transmission are retained, thereby reducing message overhead, improving data transmission efficiency and reducing power consumption of the communication device.
[0011] In a possible implementation, the transport layer header includes the following multiple fields: version number, header length, source port, destination port, sequence number, confirmation sequence number, and total message length.
[0012] In this solution, by retaining some existing fields in the transport layer header, reliable transmission of the message can be effectively guaranteed.
[0013] In one possible implementation, the data link layer header includes the following multiple fields: upper layer protocol type, source Media Access Control (MAC) address, and destination MAC address; wherein the upper layer protocol type is used to indicate the protocol type corresponding to the transport layer header.
[0014] In this solution, by carrying the upper-layer protocol type in the data link layer header to indicate the protocol corresponding to the transport layer header, the receiving communication device can select the corresponding protocol processing module to process the message based on the upper-layer protocol type, thereby ensuring the normal transmission, reception and processing of the message.
[0015] In a possible implementation, the header in the first message does not include the following fields: source Internet Protocol (IP) address, destination IP address, checksum, and time to live (TTL).
[0016] Specifically, since the forwarding of the first message does not need to pass through multiple intermediate devices, the forwarding of the first message no longer depends on the source IP address and the destination IP address. In addition, since the connection between the first communication device and the second communication device is usually a short-distance communication, the reliability of the first message during transmission can be guaranteed, so the first message does not need to carry a checksum to verify the accuracy of the first message. At the same time, since there is no intermediate device or only one intermediate device between the first communication device and the second communication device, the first message does not need to carry a TTL to avoid the message from being sent and received cyclically in the network.
[0017] In a possible implementation, the communication connection between the first communication device and the second communication device is identified by the MAC address and port number of the first communication device and the MAC address and port number of the second communication device.
[0018] In this solution, the connection between communication devices is identified by the MAC address and port number of the communication device, which can replace the IP address, so that the normal establishment of the communication connection can be guaranteed even when the IP address is not used for communication.
[0019] In one possible implementation, a first communication device generates a first message, including: a first transport layer module in the first communication device generates a payload based on the data to be transmitted, and the first transport layer module is a protocol processing module corresponding to the transport layer header; the first transport layer module encapsulates the transport layer header and the data link layer header outside the payload according to the communication connection to obtain the first message.
[0020] In this solution, the first transport layer module is responsible for encapsulating both the transport layer header and the data link layer header, thereby bypassing the data link layer, reducing the program processing flow, and ultimately reducing the data transmission delay and the processing resource overhead of the communication device.
[0021] In one possible implementation, the method further includes: based on the fact that the network type of the interface in the first communication device for establishing the above-mentioned communication connection with the second communication device is a point-to-point connection, the first communication device determines that the communication connection between the first communication device and the second communication device is a connection that does not forward data through the network layer.
[0022] In one possible implementation, the method further includes: based on the IP address of the first communication device and the IP address of the second communication device being in the same broadcast domain, the first communication device determines that the communication connection between the first communication device and the second communication device is a connection that does not forward data through the network layer.
[0023] In this solution, the communication device selects a simplified protocol based on the current business scenario to implement message transmission, which can effectively reduce message overhead, improve data transmission efficiency and reduce power consumption of the communication device.
[0024] A second aspect of the present application provides a data transmission method, including: when the communication connection between a first communication device and a second communication device is a connection that does not forward data through a network layer, the second communication device receives a first message sent by the first communication device through the communication connection, the first message including a payload, a transport layer header, and a data link layer header, and the first message does not include a network layer header; the second communication device processes the first message to obtain the payload in the first message.
[0025] In a possible implementation, the transport layer header includes the following multiple fields: version number, header length, source port, destination port, sequence number, confirmation sequence number, and total message length.
[0026] In a possible implementation, the data link layer header includes the following multiple fields: an upper layer protocol type, a source MAC address, and a destination MAC address; wherein the upper layer protocol type is used to indicate the protocol type corresponding to the transport layer header.
[0027] In a possible implementation, the header in the first message does not include the following fields: source IP address, destination IP address, checksum, and TTL.
[0028] In a possible implementation, the communication connection between the first communication device and the second communication device is identified by the MAC address and port number of the first communication device and the MAC address and port number of the second communication device.
[0029] In one possible implementation, the second communication device processes the first message, specifically including: the data link layer module in the second communication device transmits the first message to the second transport layer module in the second communication device according to the upper layer protocol type indicated by the data link layer header, and the second protocol module is the protocol processing module corresponding to the transport layer header; the second transport layer module decapsulates the first message to obtain the payload.
[0030] In one possible implementation, the communication connection between the first communication device and the second communication device is a connection that does not forward data through the network layer, specifically including: the network type of the interface in the first communication device connected to the second communication device is a point-to-point connection.
[0031] In a possible implementation, the communication connection between the first communication device and the second communication device is a connection that does not forward data through the network layer, specifically including: the IP address of the first communication device and the IP address of the second communication device are in the same broadcast domain.
[0032] A third aspect of the present application provides a communication device, which is a first communication device, including:
[0033] A processing module, configured to generate a first message, the first message including a payload, a transport layer header, and a data link layer header, and the first message does not include a network layer header;
[0034] The transceiver module is used to send a first message to the second communication device via a communication connection, where the communication connection is a connection that does not forward data through the network layer.
[0035] In a possible implementation, the transport layer header includes the following multiple fields: version number, header length, source port, destination port, sequence number, confirmation sequence number, and total message length.
[0036] In a possible implementation, the data link layer header includes the following multiple fields: upper layer protocol type, source media access control MAC address, and destination MAC address; wherein the upper layer protocol type is used to indicate the protocol type corresponding to the transport layer header.
[0037] In a possible implementation, the header in the first message does not include the following fields: source IP address, destination IP address, checksum, and time to live value TTL.
[0038] In a possible implementation, the communication connection between the first communication device and the second communication device is identified by the MAC address and port number of the first communication device and the MAC address and port number of the second communication device.
[0039] In one possible implementation, the processing module is specifically used to: generate a payload through a first transport layer module in a first communication device, where the first transport layer module is a protocol processing module corresponding to the transport layer header; and encapsulate the transport layer header and the data link layer header outside the payload according to the communication connection through the first transport layer module to obtain a first message.
[0040] In one possible implementation, the processing module is further used to: based on the network type of the interface in the first communication device connected to the second communication device being a point-to-point connection, the first communication device determines that the communication connection between the first communication device and the second communication device is a connection that does not forward data through the network layer.
[0041] In one possible implementation, the processing module is further used to: based on the IP address of the first communication device and the IP address of the second communication device being in the same broadcast domain, the first communication device determines that the communication connection between the first communication device and the second communication device is a connection that does not forward data through the network layer.
[0042] A fourth aspect of the present application provides a communication device, which is a second communication device, including:
[0043] a transceiver module, configured to receive, through a communication connection between the first communication device and the second communication device, a first message sent by the first communication device, when the communication connection between the first communication device and the second communication device is a connection that does not forward data through the network layer, the first message including a payload, a transport layer header, and a data link layer header, and the first message does not include a network layer header;
[0044] The processing module is used to process the first message to obtain the payload in the first message.
[0045] In a possible implementation, the transport layer header includes the following multiple fields: version number, header length, source port, destination port, sequence number, confirmation sequence number, and total message length.
[0046] In a possible implementation, the data link layer header includes the following multiple fields: an upper layer protocol type, a source MAC address, and a destination MAC address; wherein the upper layer protocol type is used to indicate the protocol type corresponding to the transport layer header.
[0047] In a possible implementation, the header in the first message does not include the following fields: source IP address, destination IP address, checksum, and TTL.
[0048] In a possible implementation, the communication connection between the first communication device and the second communication device is identified by the MAC address and port number of the first communication device and the MAC address and port number of the second communication device.
[0049] In one possible implementation, the processing module is specifically used to: transmit the first message to the second transport layer module in the second communication device through the data link layer module in the second communication device according to the upper layer protocol type indicated by the data link layer header, and the second protocol module is the protocol processing module corresponding to the transport layer header; decapsulate the first message through the second transport layer module to obtain the payload.
[0050] In a possible implementation, the network type of the interface in the first communication device connected to the second communication device is a point-to-point connection.
[0051] In a possible implementation, the IP address of the first communication device and the IP address of the second communication device are located in the same broadcast domain.
[0052] In a fifth aspect, the present application provides a communication device comprising: a memory and a processor; the memory stores code, and the processor is configured to execute the code. When the code is executed, the communication device executes a method as implemented in any one of the first and second aspects.
[0053] In a sixth aspect, the present application provides a computer-readable storage medium, which stores a computer program. When the computer-readable storage medium is run on a computer, the computer executes a method as implemented in any one of the first and second aspects.
[0054] In a seventh aspect, the present application provides a computer program product, which, when executed on a computer, enables the computer to execute a method as implemented in any one of the first and second aspects.
[0055] In an eighth aspect, the present application provides a chip comprising one or more processors, wherein some or all of the processors are configured to read and execute a computer program stored in a memory to perform the method in any one of the implementations of the first or second aspects.
[0056] Optionally, the chip includes a memory, and the memory is connected to the processor via a circuit or wire. Optionally, the chip also includes a communication interface, and the processor is connected to the communication interface. The communication interface is used to receive data and / or information to be processed, and the processor obtains the data and / or information from the communication interface, processes the data and / or information, and outputs the processing results through the communication interface. The communication interface can be an input / output interface. The method provided in this application can be implemented by a single chip or by multiple chips working together.
[0057] Among them, the technical effects brought about by any design method in the second to eighth aspects can refer to the technical effects brought about by different implementation methods in the above-mentioned first aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] FIG1 is a system architecture diagram of a TCP / IP protocol suite provided in an embodiment of the present application;
[0059] FIG2 is a schematic diagram of the structure of a message generated based on the TCP / IP protocol suite provided in an embodiment of the present application;
[0060] FIG3 is a schematic diagram of message transmission and parsing provided in an embodiment of the present application;
[0061] FIG4 is a schematic structural diagram of a communication device 101 provided in an embodiment of the present application;
[0062] FIG5 is a flow chart of a data transmission method provided in an embodiment of the present application;
[0063] FIG6 is a schematic diagram of the structure of a first message provided in an embodiment of the present application;
[0064] FIG7 is a schematic diagram of the structure of a transport layer header provided in an embodiment of the present application;
[0065] FIG8 is a schematic diagram of the structure of another transport layer header provided in an embodiment of the present application;
[0066] FIG9 is a schematic diagram of the structure of a data link layer header provided in an embodiment of the present application;
[0067] FIG10 is a schematic diagram of a system architecture provided in an embodiment of the present application;
[0068] FIG11 is a schematic diagram of an implementation architecture provided in an embodiment of the present application;
[0069] FIG12 is a schematic diagram of registering the MinTP protocol in the kernel according to an embodiment of the present application;
[0070] FIG13 is a schematic diagram of a general process of data transmission provided by an embodiment of the present application;
[0071] FIG14 is a schematic diagram of a process for establishing a connection based on different protocols provided by a communication device according to an embodiment of the present application;
[0072] FIG15 is a schematic diagram of a process for establishing a connection based on the MinTP protocol provided in an embodiment of the present application;
[0073] FIG16 is a schematic diagram of a process for establishing a connection between a client and a server by exchanging handshake messages according to an embodiment of the present application;
[0074] FIG17 is a schematic diagram of a flow chart of message interaction between a client and a server according to an embodiment of the present application;
[0075] FIG18 is another schematic diagram of a process for exchanging data between a client and a server according to an embodiment of the present application;
[0076] FIG19 is a schematic structural diagram of a first communication device provided in an embodiment of the present application;
[0077] FIG20 is a schematic structural diagram of a second communication device provided in an embodiment of the present application;
[0078] FIG21 is a schematic diagram of a structure of an execution device provided in an embodiment of the present application;
[0079] FIG22 is a schematic diagram of the structure of a computer-readable storage medium provided in an embodiment of the present application. DETAILED DESCRIPTION
[0080] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments.
[0081] The terms "first," "second," "third," "fourth," and the like (if any) in the specification and claims of this application and in the accompanying drawings are used to distinguish similar objects and are not necessarily used to describe a particular order or sequential sequence. It should be understood that the terms used in this manner are interchangeable where appropriate so that the embodiments described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "including" and "having," and any variations thereof, are intended to cover non-exclusive inclusions, e.g., a process, method, system, product, or apparatus comprising a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0082] To facilitate understanding, some technical terms involved in the embodiments of this application are first introduced below.
[0083] (1) Open System Interconnection Reference Model (OSI model)
[0084] The OSI model is a conceptual model proposed by the International Organization for Standardization. It is essentially a standard framework designed to interconnect various computers worldwide into a network. The OSI divides computer network architecture into seven layers: physical layer, data link layer, network layer, transport layer, session layer, presentation layer, and application layer. The functions of these seven layers are described below.
[0085] Physical layer: Converts data into electronic signals that can be transmitted through physical media, equivalent to the porters in the post office.
[0086] Data Link Layer: Determines how the network medium is accessed. Data is typically framed and flow control is handled at the Data Link Layer. The Data Link Layer specifies the topology and provides hardware addressing, similar to the post office's box loader.
[0087] Network layer: Routes data through large networks, acting like a sorting worker in a post office.
[0088] Transport layer: provides reliable end-to-end connections, equivalent to the postman in the company.
[0089] Session layer: allows users to establish connections using simple and easy-to-remember names, which is equivalent to a secretary in a company who receives and sends letters, writes envelopes, and opens envelopes.
[0090] Presentation layer: negotiates data exchange formats, equivalent to the assistant who briefs the boss and writes letters for the boss in the company.
[0091] Application layer: The interface between the user's application and the network.
[0092] (2) TCP
[0093] TCP is a connection-oriented, reliable, byte-stream-based transport layer communication protocol. Specifically, TCP is a transmission protocol designed to provide reliable end-to-end byte streams over unreliable internet networks.
[0094] (3)IP
[0095] IP is the network layer protocol in the TCP / IP architecture. Its purpose is to improve network scalability: first, to solve Internet problems and enable interconnection among large-scale, heterogeneous networks; second, to decouple top-level network applications from underlying network technologies, facilitating their independent development. Based on end-to-end design principles, IP provides only a connectionless, unreliable, best-effort data packet transmission service for hosts.
[0096] (4) TCP / IP protocol suite
[0097] The TCP / IP protocol suite is actually a collection of protocols, such as TCP at the transport layer and IP at the network layer. In the TCP / IP protocol suite, each protocol is responsible for a part of network data transmission, providing a specific service for data transmission on the network.
[0098] The TCP / IP protocol suite was developed based on the OSI model, and the layered structure defined by the TCP / IP protocol suite differs from the OSI model. Specifically, the layered structure defined by the TCP / IP protocol suite includes the application layer, transport layer, network layer, data link layer, and physical layer. The application layer defined by the TCP / IP protocol suite is equivalent to unifying the application layer, presentation layer, and session layer in the OSI model into a single application layer, thereby more closely integrating functions such as data format representation and session establishment with application software.
[0099] (5) Message header
[0100] The message header is usually also referred to as the message header. It refers to some information segments encapsulated in the head of the message to indicate some information required for the message during transmission.
[0101] (6) Checksum
[0102] The checksum is a field in the network layer header that is calculated based on the data content in the message and is used to ensure data integrity and accuracy in long-distance communications.
[0103] (7) Time To Live (TTL)
[0104] The TTL field in the network layer header specifies the maximum number of network segments a packet is allowed to pass through before being discarded by a router. The TTL prevents packets from looping endlessly on the network.
[0105] (8) User Datagram Protocol (UDP)
[0106] UDP is a connectionless transport layer protocol in the OSI model, providing simple, transaction-oriented, unreliable information delivery services. Like TCP, UDP handles data packets. In the OSI model, both reside in the transport layer, above the network layer. UDP has the disadvantage of not providing packet grouping, reassembly, or sequencing. This means that once a message is sent, it is impossible to determine whether it has arrived safely and intact. UDP is used to support network applications that require data transmission between computers. Many client / server network applications, including online video conferencing systems, rely on UDP. Currently, many applications, such as multimedia data streams, exclusively support UDP, generating no additional data and refusing to retransmit known corrupted packets. UDP is the best choice when transmission performance is prioritized over integrity, such as in audio and multimedia applications. UDP is also a good choice when data transmission is so short that the preceding connection process constitutes the bulk of the traffic.
[0107] (9) Media Access Control (MAC) address
[0108] Each device on the network has a unique network identifier, which is usually called a MAC address or network card address and is written inside the hardware when the network device manufacturer produces it.
[0109] (10) Socket
[0110] A socket is an abstraction for bidirectional communication endpoints between application processes on different hosts on a network. A socket is one end point for communication between processes on a network, providing a mechanism for application-layer processes to exchange data using network protocols. In terms of its position, a socket connects the application process above and the network protocol stack below. It is the interface through which applications communicate using network protocols and the interface between applications and the network protocol stack.
[0111] (11)cookie
[0112] A cookie is a piece of data stored on a user's local computer. Generally speaking, a cookie is data (usually encrypted) that some websites store on a user's local computer for the purpose of identifying the user and tracking their session. It is information that is temporarily or permanently stored on the user's client computer.
[0113] Currently, in some simple communication scenarios, for messages exchanged between communication devices, some header content may not be used during the actual transmission of the message, that is, this part of the message content is redundant. Therefore, if each message exchanged between communication devices carries redundant content, the amount of data transmitted between the communication devices will increase, thereby reducing data transmission latency and increasing the power consumption of the communication devices.
[0114] For example, please refer to Figure 1, which is a system architecture diagram of a TCP / IP protocol suite provided in an embodiment of the present application. As shown in Figure 1, the communication device includes software and hardware, where the software includes an application, a TCP layer, an IP layer, a data link layer, and a driver. The application corresponds to the application layer in the TCP / IP protocol suite, the TCP layer is the transport layer that uses TCP as the protocol, and the IP layer is the network layer that uses IP as the protocol. The hardware includes a central processing unit (CPU), memory, and a network card.
[0115] Please refer to Figures 2 and 3. Figure 2 is a schematic diagram of the structure of a message generated based on the TCP / IP protocol suite provided in an embodiment of the present application; Figure 3 is a schematic diagram of the transmission and parsing of a message provided in an embodiment of the present application. As shown in Figures 2 and 3, during the process of a communication device generating a message, the application calls the protocol stack interface to pass data to the TCP layer. The TCP layer divides the data passed by the application into multiple blocks, each of which serves as the payload in a message, and encapsulates a TCP layer header before the payload. The IP layer further encapsulates an IP layer header before the TCP header, which includes the source IP address and the destination IP address. The data link layer further encapsulates a data link layer header before the IP layer header, which includes the source MAC address and the destination MAC address, ultimately obtaining a message that needs to be sent to another communication device. The data link layer then passes the encapsulated message to the driver, which passes the encapsulated message to the network card. The network card sends the encapsulated message to another communication device as the receiving end via a physical link.
[0116] After the communication device at the receiving end receives the message, the driver first passes the received message to the data link layer, and then the data link layer parses the data link layer header in the message to obtain the source MAC address and destination MAC address in the data link layer header; secondly, the IP layer continues to parse the IP layer header in the message to obtain the source IP address and destination IP address in the IP layer header; finally, the TCP layer continues to parse the TCP layer header in the message and passes the final payload to the application.
[0117] As described above, in addition to the payload, the message generated by the current TCP / IP protocol suite also includes a TCP layer header, an IP layer header, and a data link layer header. The IP layer header primarily includes the source IP address (i.e., the IP address of the sender) and the destination IP address (i.e., the IP address of the receiver). If there are other transit nodes between two communication devices, the transit node needs to implement message transmission based on the source IP address and destination IP address in the IP layer header, thereby transmitting the message to the communication device serving as the receiver.
[0118] However, in some simple communication scenarios, such as when two communication devices are connected point-to-point, there is no transit node between the two communication devices, so the two communication devices may not need to use source and destination IP addresses to transmit messages. In this case, if the messages exchanged between the two communication devices still carry IP layer headers, they will carry redundant content that has no effect on message transmission. On the basis of the unchanged amount of valid data transmitted between the communication devices, the total amount of data transmitted between the communication devices will increase, thereby reducing the data transmission delay and increasing the power consumption of the communication devices.
[0119] In view of this, an embodiment of the present application provides a data transmission method. When the communication connection established between two communication devices is a connection that does not require data forwarding through the network layer, the message structure exchanged between the communication devices is simplified, and the network layer header is not carried in the message. Only the transport layer header and data link layer header used to realize message transmission are retained, thereby reducing message overhead, improving data transmission efficiency and reducing power consumption of the communication device.
[0120] The data transmission method provided in the embodiments of the present application can be applied to a communication device. For example, the communication device can be a server, a mobile phone, a personal computer (PC), a laptop, a tablet computer, a smart TV, a mobile internet device (MID), a wearable device, a virtual reality (VR) device, an augmented reality (AR) device, a wireless communication device in industrial control, a wireless communication device in self-driving, a wireless communication device in remote medical surgery, a wireless communication device in a smart grid, a wireless communication device in transportation safety, a wireless communication device in a smart city, a wireless communication device in a smart home, etc.
[0121] Please refer to Figure 4, which is a schematic diagram of the structure of a communication device 101 provided in an embodiment of the present application. As shown in Figure 4, the communication device 101 includes a processor 103, which is coupled to a system bus 105. The processor 103 can be one or more processors, each of which can include one or more processor cores. A display adapter (video adapter) 107 can drive a display 109, which is coupled to the system bus 105. The system bus 105 is coupled to an input / output (I / O) bus via a bus bridge 111. An I / O interface 115 is coupled to the I / O bus. The I / O interface 115 communicates with various I / O devices, such as an input device 117 (e.g., a touch screen), an external memory 121 (e.g., a hard disk, floppy disk, optical disk, or USB flash drive), a multimedia interface, etc., a transceiver 123 (capable of sending and / or receiving radio communication signals), a camera 155 (capable of capturing still and dynamic digital video images), and an external USB port 125. Optionally, the interface connected to the I / O interface 115 may be a USB interface.
[0122] The processor 103 may be any conventional processor, including a reduced instruction set computing (RISC) processor, a complex instruction set computing (CISC) processor, or a combination thereof. Alternatively, the processor may be a dedicated device such as an ASIC.
[0123] Communication device 101 can communicate with software deployment server 149 via network interface 129. Exemplarily, network interface 129 is a hardware network interface, such as a network card. Network 127 can be an external network, such as the Internet, or an internal network, such as Ethernet or a virtual private network (VPN). Alternatively, network 127 can be a wireless network, such as a WiFi network or a cellular network.
[0124] The hard drive interface 131 is coupled to the system bus 105. The hard drive interface is connected to the hard drive 133. The internal memory 135 is coupled to the system bus 105. The data running in the internal memory 135 may include the operating system (OS) 137 of the communication device 101, the application program 143, and the scheduler.
[0125] The operating system consists of a shell 139 and a kernel 141. Shell 139 is an interface between the user and the operating system's kernel. The shell is the outermost layer of the operating system. The shell manages the interaction between the user and the operating system: it waits for user input, interprets user input to the operating system, and processes various operating system output.
[0126] The kernel 141 consists of the parts of the operating system that manage memory, files, peripherals, and system resources. The kernel 141 directly interacts with the hardware. The operating system kernel typically runs processes and provides inter-process communication, CPU time slice management, interrupts, memory management, and I / O management.
[0127] For example, when the communication device 101 is a smart phone, the application 143 includes an instant messaging-related program. In one embodiment, when the application 143 needs to be executed, the communication device 101 can download the application 143 from the software deployment server 149 .
[0128] Please refer to Figure 5, which is a flow chart of a data transmission method provided by an embodiment of the present application. As shown in Figure 5, the data transmission method includes the following steps 501-503.
[0129] In step 501, based on the fact that the communication connection between the first communication device and the second communication device is a connection that does not forward data through the network layer, the first communication device generates a first message, the first message includes a payload, a transport layer header, and a data link layer header, and the first message does not include a network layer header.
[0130] In this embodiment, the connection without forwarding data through the network layer can specifically be a peer-to-peer (P2P) point-to-point connection or a star connection. A point-to-point connection refers to a direct connection between two communication devices without any other intermediary devices. For example, a smartphone can be directly connected to a laptop via Wi-Fi without going through an intermediary device such as a router or switch; or two smartphones can be directly connected via Near Field Communication (NFC) technology, Bluetooth technology, ZigBee technology, infrared technology, or Wi-Fi.
[0131] A star connection is when two communication devices are connected to the same intermediate device, which forwards data based on the MAC addresses of the two devices. For example, two servers are connected to the same Layer 2 switch, or two smartphones are connected to the same wireless router.
[0132] In general, when the communication connection between the first communication device and the second communication device is a connection that does not forward data through the network layer, the messages exchanged between the first communication device and the second communication device no longer need to be forwarded through the IP address in the network layer header.
[0133] In this case, the first message generated by the first communication device includes only the payload, the transport layer header, and the data link layer header, and does not include a network layer header. Specifically, please refer to Figure 6, which is a schematic diagram of the structure of a first message provided in an embodiment of the present application. As shown in Figure 6, the first message includes only two message headers: the transport layer header and the data link layer header, and no longer includes a network layer header.
[0134] Specifically, since the first message only includes a transport layer header and a data link layer header but not a network layer header, the first message does not include fields in the network layer header such as the source IP address, destination IP address, checksum, and TTL. Specifically, the forwarding of the first message no longer depends on the source IP address and the destination IP address. Moreover, since the connection between the first communication device and the second communication device is usually a short-distance communication, the reliability of the first message during the transmission process can be guaranteed, so the first message does not need to carry a checksum to verify the accuracy of the first message. At the same time, since there is no intermediate device or only one intermediate device between the first communication device and the second communication device, the first message does not need to carry a TTL to avoid the message from being cyclically sent and received in the network.
[0135] Optionally, the first communication device may determine in a variety of ways whether the connection between it and the second communication device is a connection that does not forward data through the network layer.
[0136] In a possible implementation, the first communication device may determine whether the connection between the first communication device and the second communication device is a connection that does not forward data through the network layer by determining the network type of the interface to which the first communication device and the second communication device are connected.
[0137] For example, based on the network type of the interface of the first communication device connected to the second communication device being a point-to-point connection, the first communication device determines that the communication connection between the first communication device and the second communication device is a connection that does not forward data through the network layer. The interface of the first communication device connected to the second communication device can be, for example, a physical interface or a logical interface.
[0138] In another possible implementation, the first communication device may determine whether the connection between the two is a connection that does not forward data through the network layer by determining the relationship between its own IP address and the IP address of the second communication device.
[0139] Exemplarily, based on the fact that the IP address of the first communication device and the IP address of the second communication device are located in the same broadcast domain, the first communication device determines that the communication connection between the first communication device and the second communication device is a connection that does not forward data through the network layer. It is understandable that when the IP address of the first communication device and the IP address of the second communication device are located in the same broadcast domain, the first communication device and the second communication device are actually in the same local area network (for example, the first communication device and the second communication device are connected to the same wireless router), and data forwarding can be achieved between the first communication device and the second communication device through the MAC address, without the need to forward data through the network layer.
[0140] The above introduces various ways for the first communication device to determine the type of connection. In actual applications, the first communication device may also use other methods to determine whether the connection between it and the second communication device is a connection that does not forward data through the network layer. This embodiment does not make specific limitations on this.
[0141] Step 502: The first communication device sends a first message to the second communication device through the communication connection.
[0142] Since the communication connection between the first communication device and the second communication device is a connection that does not forward data through the network layer, even if the first message does not include a network layer header, that is, does not include the IP addresses of the first communication device and the second communication device, the message can be transmitted.
[0143] That is, when the first message does not include a network layer header, the first communication device can also normally send the first message to the second communication device, and the second communication device can normally receive the first message sent by the first communication device.
[0144] Step 503: The second communication device processes the first message to obtain a payload in the first message.
[0145] After the second communication device receives the first message, the second communication device can parse the data link layer header and transport layer header in the first message in sequence, and finally obtain the payload in the first message, and pass the payload in the first message to the application in the second communication device that interacts with the first communication device for data.
[0146] In this embodiment, when the communication connection established between two communication devices is a connection that does not require data forwarding through the network layer, the message structure exchanged between the communication devices is simplified, and the network layer header is not carried in the message. Only the transport layer header and data link layer header used to implement message transmission are retained, thereby reducing message overhead, improving data transmission efficiency and reducing power consumption of the communication device.
[0147] For ease of understanding, the structure of the first message will be specifically introduced below.
[0148] For example, please refer to Figure 7, which is a schematic diagram of the structure of a transport layer header provided in an embodiment of the present application. As shown in Figure 7, the transport layer header in the first message includes the following multiple fields: version number, header length, source port, destination port, sequence number (seq), acknowledgment number (ack), total message length, and options. The functions of each field in the transport layer header are as follows.
[0149] Version number: This field is used to represent the evolution of the protocol version. Different versions of the protocol have different formats. Devices can use the version number field to negotiate a mutually supported protocol version. For example, the version number can be 0, 1, 2, ...
[0150] Header Length: Since the transport layer header includes a fixed-length header field and a variable-length option field, the header length can be the total length of the fixed-length portion and the variable-length portion. The header length minus the length of the fixed portion is the length of the option, and the option length can be 0. For example, assuming the fixed portion of the transport layer header is 16 bytes, a message with a header length of 16 bytes indicates no option field, while a message with a header length of 20 bytes indicates a 4-byte option field.
[0151] Source Port: Source port number. Similar to the TCP / UDP port number, it is used to allow multiple applications on the same communication device to communicate simultaneously using the same protocol.
[0152] Destination Port: Destination port number. Similar to TCP / UDP port numbers, this allows multiple applications on the same communication device to communicate simultaneously using the same protocol. Generally, when a communication device sends data, the source port is the port number of the device itself, and the destination port is the port number of the peer device.
[0153] Seq: Data sequence number. The communication device that sends data numbers each byte of data. The seq in a message is the number of the first byte of the payload. If there is no payload in the message, the seq remains the seq number of the last payload byte of the previous message.
[0154] For example, after a first communication device establishes a connection with a second communication device, the first communication device sets the initial seq to 1000. The first communication device sends the first message with a payload length of 100 bytes to the second communication device. The seq in this message is 1000, indicating that the seq of the first byte in the payload is 1000. Then, the first communication device sends the second message with a payload length of 0 to the second communication device. The seq in this message is 1100, indicating the byte number of the last payload in the previous message. This message (the second message) has no new payload, so the seq does not increase.
[0155] Ack: The data confirmation number. When a communication device serving as the data receiver receives the payload sent by the sender, it sends an acknowledgment message, using ack to indicate that all data before the ack number has been successfully received.
[0156] For example, after the first communication device and the second communication device establish a connection, the second communication device receives a message sent by the first communication device, the seq in the message is 1000, and the payload length of the message is 100, then the second communication device replies with a message carrying ack 1101, indicating that all data before seq 1101 has been received.
[0157] Total message length: indicates the total length of the current message header and message payload.
[0158] Options: The options field is a reserved field for subsequent extensions.
[0159] For example, please refer to Figure 8, which is a schematic diagram of the structure of another transport layer header provided in an embodiment of the present application. As shown in Figure 8, compared with the transport layer header shown in Figure 7, in the embodiment corresponding to Figure 8, the transport layer header also includes the following two fields: a mark bit and a window size. Among them, the mark bit is used to indicate the mark used by the two communication devices in the connection establishment or disconnection stage, such as a handshake mark and a wave mark. A message with a handshake mark is used to initiate a connection, and a message with a wave mark is used to disconnect a connection. The window size is used to notify the opposite communication device of the size of the receiving buffer on this side, in KB.
[0160] In the transport layer header, the seq, ack, and window size fields are used to achieve reliable transmission. Specifically, seq is used by the sender to mark the data being sent, and ack is used by the receiver to confirm successful receipt of the data. If the sender fails to receive the ack, data retransmission is triggered to ensure successful data reception. The window size is used by the receiver to notify the sender of the size of the receive buffer, preventing the sender from sending too much data and causing the receiver to be unable to process it. The window size field is optional and is included only to reduce the possibility of the receiver discarding packets due to insufficient buffer space.
[0161] In addition, FIG8 also provides an example of the length of each field in the transport layer header, as follows.
[0162] Version number: 4 bits, representing a version number from 0 to 15.
[0163] Header length: 4 bits, ranging from 0 to 15, indicating how many 4-byte header lengths there are. For example, if the header length value is 15, it means that the header length is 15*4=60 bytes.
[0164] Marker bit: 8 bits. Available marker bits include handshake marker and wave marker, each of which occupies a fixed bit. For example, the handshake marker is fixed in the first bit of the 8-bit field, and the wave marker is fixed in the second bit. If the first bit is 1, the message has a handshake marker; otherwise, the message does not have a handshake marker.
[0165] Source port: 8 bits, representing the port number from 0 to 255.
[0166] Destination port: 8 bits, representing the port number from 0 to 255.
[0167] Seq: 32 bits. 32 bits can represent 4GB of data and prevent seq from being reversed in a short time.
[0168] Ack: 32 bits, the same length as seq.
[0169] Total message length: 16 bits. The theoretical value range is 0-65535. The actual value will not be less than 16.
[0170] Window size: 16 bits, ranging from 0 to 65535. It is used to inform the other party of the size of the local receive buffer. The unit is KB. For example, if the window size value is 500, it means that the local receive buffer size is 500KB.
[0171] For example, please refer to Figure 9, which is a schematic diagram of the structure of a data link layer header provided in an embodiment of the present application. As shown in Figure 9, in the first message, the data link layer header includes the following multiple fields: upper layer protocol type, source MAC address, and destination MAC address. The upper layer protocol type is used to indicate the protocol type corresponding to the transport layer header.
[0172] In this embodiment, a new transport layer protocol is used to replace both TCP and IP. This new transport layer protocol is used to generate the transport layer header described above. For the sake of convenience, this new transport layer protocol proposed in this embodiment is named Minimalist Transfer Protocol (MinTP). Specifically, for the upper layer protocol type field in the data link layer header, the IP protocol corresponds to a type value of 0x0800, while the MinTP protocol corresponds to a type value of 0xa85a.
[0173] The above describes the structure of messages generated based on the new transport layer protocol (MinTP). To facilitate understanding, the following details how to deploy and apply MinTP in a communication device.
[0174] For example, please refer to Figure 10, which is a schematic diagram of a system architecture provided by an embodiment of the present application. As shown in Figure 10, this embodiment adds MinTP to the existing protocol stack. Accordingly, the MinTP layer belongs to the transport layer, but at the protocol level, the MinTP layer can assume the responsibilities of the existing TCP layer and IP layer. In other words, the MinTP layer is responsible for dividing large blocks of application data into messages, transmitting them to the destination, and ensuring the reliability of the transmission process.
[0175] For example, please refer to Figure 11, which is a schematic diagram of an implementation architecture provided in an embodiment of the present application. As shown in Figure 11, to implement the MinTP proposed in an embodiment of the present application in a device, the embodiment of the present application adds a protocol selection module to the application program and a MinTP protocol module to the protocol stack. The MinTP protocol module is a transport layer module, for example, the protocol processing module corresponding to the transport layer header in the first message described above.
[0176] The protocol selection module in the application is responsible for selecting a transport layer protocol and establishing a data transmission connection based on the current business scenario. Specifically, if the current scenario involves point-to-point data transmission, such as a scenario that does not require data forwarding at the network layer, the protocol selection module selects MinTP and establishes a MinTP connection. Otherwise, it selects TCP or UDP and establishes a TCP connection or UDP transmission channel. After selecting MinTP, the application transmits data to the MinTP protocol module, which then generates a message based on the data transmitted by the application.
[0177] Specifically, the software implementation of this embodiment involves writing a kernel module to implement the MinTP protocol. Taking the Linux operating system as an example, the Linux operating system provides a mechanism for writing kernel modules. This can be a static kernel module or a dynamic kernel module. The following embodiment will describe how to write a dynamic kernel module.
[0178] First, write the module initialization and deinitialization functions according to the Linux kernel module framework. Then, compile the source file into a dynamically loadable kernel module in the same way as compiling a kernel module. After the kernel module is written, you can use the insmod command to load the compiled kernel module. When the kernel module is no longer needed, use the rmmod command to unload the loaded module.
[0179] Secondly, add the MinTP protocol stack framework to the above kernel module. The specific method is to call the kernel interface to register the AF_MINTP protocol family (which belongs to the same level as the AF_INET protocol family of TCP / IP) in the kernel socket framework, and call the kernel interface to register the new protocol type ETH_MINTP in the kernel protocol list.
[0180] For example, please refer to Figure 12, which is a schematic diagram of registering the MinTP protocol in the kernel according to an embodiment of the present application. As shown in Figure 12, registering the MinTP protocol in the kernel uses the existing kernel mechanism, which is also used by other protocols in the kernel for registration.
[0181] After registering the AF_MINTP protocol with the socket framework, you can create an AF_MINTP socket using the standard socket interface. Operations performed on AF_MINTP sockets will also be directed to the MinTP module in the kernel. After registering the ETH_MINTP protocol, the kernel will send ETH_MINTP type messages (the corresponding type value in this example is 0xa85a) to the MinTP module for processing.
[0182] After completing the above steps, the MinTP protocol can be deployed in the device. That is, the kernel module framework corresponding to the MinTP protocol is written, providing a standard socket programming interface to the upper layer and handling the processing of ETH_MINTP type messages to the lower layer.
[0183] The specific process of data transmission based on the MinTP protocol is introduced in detail below.
[0184] Please refer to Figure 13, which is a schematic diagram of the overall process of data transmission provided by an embodiment of the present application. As shown in Figure 13, before a communication device performs data transmission, a connection needs to be established between the two communication devices; after the two communication devices successfully establish a connection, data can be sent or received (i.e., one communication device sends data and the other communication device receives data). The process of sending or receiving data between the communication devices can be repeated multiple times. If there is no longer a need to send or receive data between the two communication devices, the connection is closed.
[0185] Please refer to Figure 14, which is a schematic diagram of a process for establishing a connection based on different protocols in a communication device according to an embodiment of the present application. As shown in Figure 14, before establishing a connection, the protocol selection module in the application can determine whether the current business scenario does not require data forwarding through the network layer and select a protocol type based on the current business scenario.
[0186] If the current business scenario does not require data forwarding through the network layer, the MinTP protocol is selected for data transmission. Specifically, when using the MinTP protocol to transmit data, a MinTP-type socket can be first created, and then the source MAC address, destination MAC address, source port, and destination port can be used to establish a connection. In other words, after the first communication device and the second communication device establish a connection using the MinTP protocol, the communication connection between the first communication device and the second communication device can be identified by the source MAC address, destination MAC address, source port, and destination port.
[0187] If the current business scenario requires data forwarding through the network layer, choose to transmit data through the TCP / IP protocol. When using the TCP / IP protocol to transmit data, you can first create an INET type socket and then use the source IP address, destination IP address, source port, and destination port to establish a connection.
[0188] For example, please refer to Figure 15, which is a schematic diagram of a process for establishing a connection based on the MinTP protocol, provided in an embodiment of the present application. Figure 15 illustrates the operational flow of establishing a MinTP connection by a user-mode program. The party initiating the connection is the client, and the party waiting for the connection is the server. The specific process illustrated in Figure 15 is described below.
[0189] (1) The client application and the server application each call the socket() interface to create an AF_MINTP type socket, and the MinTP protocol kernel module in the client and the MinTP protocol kernel module in the server create the corresponding data structure for the socket.
[0190] (2) The server application calls the bind() interface to bind the socket to the local MAC address and port. The MinTP protocol kernel module in the server associates the socket data structure with the MAC address and port.
[0191] (3) The server application calls the listen() interface and starts listening for new connection requests. The MinTP protocol kernel module on the server side switches the socket state to the listen state and can accept messages with handshake requests.
[0192] (4) The client application calls the connect() interface to try to connect to the server and determines the server's location through the MAC address and port. In addition, the MinTP protocol kernel module on the client side starts sending handshake messages to establish a connection with the server through message interaction.
[0193] (5) After the MinTP protocol kernel module on the client side completes the handshake message interaction, the client application completes the connection establishment.
[0194] (6) The server application calls the accept() interface to receive the connection request from the client. If the server-side MinTP protocol kernel module already has a connection that has completed the handshake message exchange, the connection information is returned to the application. In other words, the accept() function will return the established connection. If there is no established connection, the accept() function will never return.
[0195] The following describes in detail the process of establishing a connection between the client and the server through the exchange of handshake messages.
[0196] For example, please refer to Figure 16, which is a schematic diagram of a process of establishing a connection between a client and a server by exchanging handshake messages according to an embodiment of the present application. The process shown in Figure 16 includes the following three steps.
[0197] In step 1, the client sends a handshake message to the server. This message is a MinTP message with a handshake flag and a payload length of 0. In this message, the source port can be a random, unoccupied local port, the destination port is the server's listening port, the seq value is a random value, the ack value is 0, the total message length is 16, and the window size is the receive buffer size allocated by the local MinTP protocol kernel module for this socket, for example, 1024KB.
[0198] Step 2: After receiving the handshake message, the server calculates a 32-bit cookie based on the source MAC address, destination MAC address, source port, destination port, and a local key. The local key is a long-term random number. Specifically, cookie = encryption algorithm (source MAC address, destination MAC address, source port, destination port, local key).
[0199] In addition, the server uses the above cookie as the seq value of the message to construct a handshake+cookie message (that is, a handshake message carrying the cookie). The message sets the handshake mark, the source port is the local listening port, the destination port is the source port in the handshake message received in step 1, the ack is the seq+1 of the handshake message received in step 1, the total length of the message is 16, and the window size is the size of the receive buffer that the local MinTP protocol kernel module prepares to open for the socket, for example, 1024KB.
[0200] In step 3, the client receives the handshake message carrying the cookie from the server and responds with a cookie confirmation message. The payload length of the cookie confirmation message is also 0, the ack value is cookie+1, the seq value is the same as the seq of the handshake message in step 1, and the setting principles of other fields are the same as those of the handshake message in step 1.
[0201] In this way, after receiving the cookie confirmation message, the server will verify whether the cookie is correct based on the source MAC address, destination MAC address, source port, destination port, and local key in the message. In other words, it will determine whether the seq-1 in the message is equal to the cookie it calculated. If the seq-1 in the message is equal to the cookie it calculated, the cookie verification is successful, the connection is successfully established, and a receive buffer is allocated for the new connection. If the seq-1 in the message is not equal to the cookie it calculated, the cookie verification fails, the message is directly discarded, and no new connection is established.
[0202] After the client and server establish a connection, they can transmit data to each other based on the established connection.
[0203] For example, please refer to Figure 17, which is a schematic diagram of a message flow between a client and a server provided in an embodiment of the present application. As shown in Figure 17, the application in the client can first send data to the MinTP protocol module in the client, and then the MinTP protocol module performs MinTP encapsulation (i.e., encapsulation of the transport layer message header) and MAC address encapsulation (i.e., encapsulation of the data link layer message header) on the obtained data, and sends the encapsulated message to the driver. Finally, the driver transmits the encapsulated message to the server's network card through the network card.
[0204] On the server side, the driver in the server sends the message received by the network card to the data link layer module. The data link layer module parses the data link layer header in the message and determines that the protocol type corresponding to the current message is MinTP based on the upper-layer protocol type field in the data link layer header. Therefore, the link layer module passes the message to the MinTP protocol module. The MinTP protocol module parses the transport layer header in the message, extracts the data in the payload, and then returns the data in the payload to the application.
[0205] As shown in Figure 17, when the client, acting as the data transmitter, encapsulates the message, the MinTP protocol module is responsible for encapsulating both the transport layer header and the data link layer header, thereby bypassing the data link layer, reducing the program processing flow, and ultimately reducing the data transmission delay and the processing resource overhead of the communication device.
[0206] Specifically, since the data link layer header actually encapsulates the upper layer protocol type, source MAC address, and destination MAC address, and the MinTP protocol module can obtain the source MAC address and destination MAC address when establishing a connection, the MinTP protocol module can complete the encapsulation of the data link layer header on behalf of the data link layer.
[0207] Specifically, please refer to Figure 18, which is another schematic diagram of a process for exchanging data between a client and a server according to an embodiment of the present application. Figure 18 details the process of exchanging data between the client and the server through the interaction between the client application and the MinTP protocol module, and the server application and the MinTP protocol module.
[0208] For the client application, the client calls the send() interface to send data. The function returns after the data is copied to the kernel cache. Because MinTP is a reliable transport protocol, the client's MinTP protocol module is responsible for reliably delivering the data after the data is copied to the kernel cache. Therefore, the client application considers the data sent successfully after it is copied to the kernel cache.
[0209] For the client's MinTP protocol module, the client's MinTP protocol module is responsible for performing the following steps.
[0210] Step 1: After the application calls send(), the MinTP protocol module copies the data from the application's buffer to the kernel buffer.
[0211] Step 2: The MinTP protocol module cuts the data in the kernel buffer into blocks according to the message size and adds a MinTP protocol header (i.e., a transport layer header) to each block.
[0212] In step 3, the MinTP protocol module continues to add a MAC header (i.e., a data link layer header) to each block of data. The MAC header contains the source MAC address, destination MAC address, and upper-layer protocol type. The source MAC address and destination MAC address come from the addresses bound when the connection is created. The protocol type is the MinTP protocol number, which is 0xa85a in this embodiment.
[0213] Step 4: After the message is encapsulated, the MinTP protocol module directly calls the driver interface to send the message, thereby bypassing the data link layer.
[0214] In step 5, since MinTP is a reliable transport protocol, a timer on the sending end is used to ensure retransmission after a timeout. Therefore, the MinTP protocol module expects an explicit acknowledgment for each payload it sends. If no ACK is received within the set timeout, the unacknowledged data is resent. For example, a client sends three messages with seq values 1-100, 101-200, and 201-300, respectively. The maximum ACK value among the messages received from the server is 201, indicating that all data with seq values 1-200 has been received. If the client does not receive ACK 301, it resends message 3 with a payload with seq values 201-300.
[0215] In step 6, the client also needs to process the ACK in the message sent by the server. Specifically, if the client receives an ACK, it can release the cached data. It is important to note that the client has cached the data to be sent. After calling the driver interface to send the message in step 4, the cached data is not released immediately because data may be lost during transmission. The cached data corresponding to the ACK is not released until the ACK is received from the server. For example, in the above example, after receiving ACK 201, the server can release the cached data with sequence numbers 1-200. In addition, the server may proactively issue a retransmission request. After discovering a discontinuous sequence, the server can use information such as the timestamp to determine whether packet loss has occurred. If the server believes that packet loss has occurred, it will proactively send a retransmission request. The retransmission request means: Please retransmit the data with sequence numbers xxx to xxx. After receiving the retransmission request, the client will retransmit the corresponding data.
[0216] For the server application, the server application calls the recv() interface to receive data. If the server's MinTP protocol module does not receive the data, the application is blocked and put into sleep mode. If the server's MinTP protocol module receives the data, it copies the data to the application's buffer and wakes up the application, at which point the recv() interface returns.
[0217] For the server's MinTP protocol module, the server's MinTP protocol module is responsible for executing the following steps.
[0218] Step 1: After the server's user-mode program calls recv(), the server's MinTP protocol module checks to see if there is any data that has not been received by the application. If so, the data is copied to the application's buffer, causing recv() to return immediately. If there is no data that has not been received by the application, recv() is blocked, causing the application to sleep and wait for data.
[0219] Step 2: After the server's data link layer receives the message, if it is a MinTP type message, the data link layer will hand the message over to the MinTP protocol module for processing.
[0220] In step 3, the server's MinTP protocol module parses the message and finds the corresponding socket based on the source MAC address, destination MAC address, source port, and destination port. Because multiple applications may simultaneously create sockets and send and receive data, the MinTP protocol module must route different messages to different applications based on the socket.
[0221] In step 4, after parsing the message, the MinTP protocol module can infer whether packet loss has occurred based on the continuity of the SEQ and other information. If packet loss is suspected, a retransmission request is sent. In addition, regardless of whether packet loss has occurred, an ACK is sent. Both the packet loss request and the ACK can be sent in the same message.
[0222] Step 5: The MinTP protocol module extracts the payload from the message and reassembles the payload in seq order.
[0223] Step 6: The MinTP protocol module copies the reassembled payload from the kernel to the application's buffer.
[0224] Step 7: The MinTP protocol module wakes up the application, and the application returns from the recv() call, thereby obtaining the payload reassembled by the MinTP protocol module.
[0225] The above embodiments introduce the data transmission method provided in the embodiments of the present application. The following will introduce the device that executes the above data transmission method.
[0226] Please refer to Figure 19, which is a schematic diagram of the structure of a first communication device provided in an embodiment of the present application. As shown in Figure 19, the first communication device includes:
[0227] The processing module 1901 is configured to generate a first message, where the first message includes a payload, a transport layer header, and a data link layer header, but does not include a network layer header.
[0228] The transceiver module 1902 is configured to send a first message to a second communication device via a communication connection, where the communication connection is a connection that does not forward data via a network layer.
[0229] In a possible implementation, the transport layer header includes the following multiple fields: version number, header length, source port, destination port, sequence number, confirmation sequence number, and total message length.
[0230] In a possible implementation, the data link layer header includes the following multiple fields: upper layer protocol type, source media access control MAC address, and destination MAC address; wherein the upper layer protocol type is used to indicate the protocol type corresponding to the transport layer header.
[0231] In a possible implementation, the header in the first message does not include the following fields: source IP address, destination IP address, checksum, and time to live value TTL.
[0232] In a possible implementation, the communication connection between the first communication device and the second communication device is identified by the MAC address and port number of the first communication device and the MAC address and port number of the second communication device.
[0233] In one possible implementation, the processing module 1901 is specifically used to: generate a payload through the first transport layer module in the first communication device, where the first transport layer module is the protocol processing module 1901 corresponding to the transport layer header; and encapsulate the transport layer header and the data link layer header outside the payload according to the communication connection through the first transport layer module to obtain a first message.
[0234] In one possible implementation, the processing module 1901 is further used to: based on the network type of the interface in the first communication device connected to the second communication device being a point-to-point connection, the first communication device determines that the communication connection between the first communication device and the second communication device is a connection that does not forward data through the network layer.
[0235] In one possible implementation, the processing module 1901 is further used to: based on the IP address of the first communication device and the IP address of the second communication device being in the same broadcast domain, the first communication device determines that the communication connection between the first communication device and the second communication device is a connection that does not forward data through the network layer.
[0236] Please refer to Figure 20, which is a schematic diagram of the structure of a second communication device provided in an embodiment of the present application. As shown in Figure 20, the second communication device includes:
[0237] a transceiver module 2001, configured to receive, through a communication connection between a first communication device and a second communication device, a first message sent by the first communication device, when the communication connection between the first communication device and the second communication device is a connection that does not forward data through the network layer, the first message including a payload, a transport layer header, and a data link layer header, and not including a network layer header;
[0238] The processing module 2002 is configured to process the first message to obtain a payload in the first message.
[0239] In a possible implementation, the transport layer header includes the following multiple fields: version number, header length, source port, destination port, sequence number, confirmation sequence number, and total message length.
[0240] In a possible implementation, the data link layer header includes the following multiple fields: an upper layer protocol type, a source MAC address, and a destination MAC address; wherein the upper layer protocol type is used to indicate the protocol type corresponding to the transport layer header.
[0241] In a possible implementation, the header in the first message does not include the following fields: source IP address, destination IP address, checksum, and TTL.
[0242] In a possible implementation, the communication connection between the first communication device and the second communication device is identified by the MAC address and port number of the first communication device and the MAC address and port number of the second communication device.
[0243] In one possible implementation, the processing module 2002 is specifically used to: transmit the first message to the second transport layer module in the second communication device through the data link layer module in the second communication device according to the upper layer protocol type indicated by the data link layer header, and the second protocol module is the protocol processing module 2002 corresponding to the transport layer header; decapsulate the first message through the second transport layer module to obtain the payload.
[0244] In a possible implementation, the network type of the interface in the first communication device connected to the second communication device is a point-to-point connection.
[0245] In a possible implementation, the IP address of the first communication device and the IP address of the second communication device are located in the same broadcast domain.
[0246] Next, an execution device provided in an embodiment of the present application is introduced. Please refer to Figure 21. Figure 21 is a structural schematic diagram of an execution device provided in an embodiment of the present application. The execution device 2100 can be specifically manifested as a mobile phone, a tablet, a laptop computer, a smart wearable device, a server, etc., which is not limited here. Specifically, the execution device 2100 includes: a receiver 2101, a transmitter 2102, a processor 2103 and a memory 2104 (wherein the number of processors 2103 in the execution device 2100 can be one or more, and Figure 21 takes one processor as an example), wherein the processor 2103 may include an application processor 21031 and a communication processor 21032. In some embodiments of the present application, the receiver 2101, the transmitter 2102, the processor 2103 and the memory 2104 may be connected via a bus or other means.
[0247] The memory 2104 may include a read-only memory and a random access memory, and provides instructions and data to the processor 2103. A portion of the memory 2104 may also include non-volatile random access memory (NVRAM). The memory 2104 stores processor and operation instructions, executable modules, or data structures, or subsets or extended sets thereof. The operation instructions may include various operation instructions for implementing various operations.
[0248] Processor 2103 controls the operation of the execution device. In specific applications, the various components of the execution device are coupled together via a bus system. In addition to a data bus, the bus system may also include a power bus, a control bus, and a status signal bus. However, for clarity, all of these buses are referred to as a bus system in the figure.
[0249] The methods disclosed in the above embodiments of the present application can be applied to or implemented by the processor 2103. The processor 2103 can be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method can be completed by hardware integrated logic circuits in the processor 2103 or by software instructions. The above processor 2103 can be a general-purpose processor, a digital signal processor (DSP), a microprocessor, or a microcontroller, and can further include an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. The processor 2103 can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in conjunction with the embodiments of the present application can be directly implemented as being executed by a hardware decoding processor, or can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium well-known in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, etc. The storage medium is located in memory 2104, and processor 2103 reads information from memory 2104 and, in conjunction with its hardware, completes the steps of the above method.
[0250] Receiver 2101 can be used to receive input digital or character information and generate signal input related to executing device-related settings and function control. Transmitter 2102 can be used to output digital or character information through the first interface. Transmitter 2102 can also be used to send instructions to the disk pack through the first interface to modify data in the disk pack. Transmitter 2102 can also include a display device such as a display screen.
[0251] In an embodiment of the present application, in one case, the processor 2103 is used to execute the method in the embodiment corresponding to Figure 5.
[0252] The electronic device provided in the embodiment of the present application may specifically be a chip, and the chip includes: a processing unit and a communication unit, wherein the processing unit may be, for example, a processor, and the communication unit may be, for example, an input / output interface, a pin or a circuit, etc. The processing unit may execute the computer execution instructions stored in the storage unit so that the chip in the execution device executes the rendering method described in the above embodiment. Optionally, the storage unit is a storage unit in the chip, such as a register, a cache, etc. The storage unit may also be a storage unit located outside the chip in the wireless access device, such as a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM), etc.
[0253] Please refer to Figure 22, which is a schematic diagram of the structure of a computer-readable storage medium provided in an embodiment of the present application. The present application also provides a computer-readable storage medium. In some embodiments, the method disclosed in Figure 5 above can be implemented as computer program instructions encoded in a machine-readable format on a computer-readable storage medium or on other non-transitory media or products.
[0254] 22 schematically illustrates a conceptual partial view of an example computer-readable storage medium including a computer program for executing a computer process on a computing device, arranged in accordance with at least some embodiments presented herein.
[0255] In one embodiment, computer-readable storage medium 2200 is provided using signal-bearing medium 2201. Signal-bearing medium 2201 may include one or more program instructions 2202 that, when executed by one or more processors, may provide the functionality or portions of the functionality described above with respect to FIG5. Furthermore, program instructions 2202 in FIG22 also depict example instructions.
[0256] In some examples, the signal bearing medium 2201 may include a computer readable medium 2203 such as, but not limited to, a hard drive, a compact disk (CD), a digital video disk (DVD), a digital tape, memory, ROM or RAM, and the like.
[0257] In some embodiments, the signal-bearing medium 2201 may include a computer-recordable medium 2204, such as, but not limited to, a memory, a read / write (R / W) CD, a R / W DVD, or the like. In some embodiments, the signal-bearing medium 2201 may include a communication medium 2205, such as, but not limited to, a digital and / or analog communication medium (e.g., a fiber optic cable, a waveguide, a wired communication link, a wireless communication link, or the like). Thus, for example, the signal-bearing medium 2201 may be communicated via a wireless form of the communication medium 2205 (e.g., a wireless communication medium conforming to the IEEE 802 standard or other transmission protocol).
[0258] The one or more program instructions 2202 may be, for example, computer-executable instructions or logic-implemented instructions. In some examples, the computing device may be configured to provide various operations, functions, or actions in response to the program instructions 2202 communicated to the computing device via one or more of computer-readable media 2203, computer-recordable media 2204, and / or communication media 2205.
[0259] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware, or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.
[0260] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium can be any available medium that a computer can store or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)).
[0261] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0262] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0263] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0264] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0265] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0266] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the above embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the above embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A data transmission method, characterized in that: include: The first communication device generates a first message, wherein the first message includes a payload, a transport layer header, and a data link layer header, and the first message does not include a network layer header; The first communication device sends the first message to the second communication device via a communication connection, where the communication connection is a connection that does not forward data through a network layer.
2. The method according to claim 1, characterized in that The transport layer header includes the following fields: version number, header length, source port, destination port, sequence number, confirmation sequence number and total message length.
3. The method according to claim 1 or 2, characterized in that The data link layer header includes the following fields: upper layer protocol type, source media access control MAC address and destination MAC address; The upper layer protocol type is used to indicate the protocol type corresponding to the transport layer header.
4. The method according to any one of claims 1 to 3, characterized in that The header in the first message does not include the following fields: source Internet Protocol IP address, destination IP address, checksum, and time to live value TTL.
5. The method according to any one of claims 1 to 4, characterized in that The communication connection is identified by the MAC address and port number of the first communication device and the MAC address and port number of the second communication device.
6. The method according to any one of claims 1 to 5, characterized in that The first communication device generates a first message, including: A first transport layer module in the first communication device generates the payload, the first transport layer module being a protocol processing module corresponding to the transport layer header; The first transport layer module encapsulates the transport layer header and the data link layer header outside the payload according to the communication connection to obtain the first message.
7. The method according to any one of claims 1 to 6, characterized in that The network type of the interface in the first communication device that establishes the communication connection with the second communication device is a point-to-point connection.
8. The method according to any one of claims 1 to 6, characterized in that: The IP address of the first communication device and the IP address of the second communication device are located in the same broadcast domain.
9. A data transmission method, characterized in that: include: When the communication connection between the first communication device and the second communication device is a connection that does not forward data through the network layer, the second communication device receives a first message sent by the first communication device through the communication connection, where the first message includes a payload, a transport layer header, and a data link layer header, and the first message does not include a network layer header; The second communication device processes the first message to obtain the payload in the first message.
10. The method according to claim 9, characterized in that The transport layer header includes the following fields: version number, header length, source port, destination port, sequence number, confirmation sequence number and total message length.
11. The method according to claim 9 or 10, characterized in that The data link layer header includes the following multiple fields: upper layer protocol type, source MAC address and destination MAC address; The upper layer protocol type is used to indicate the protocol type corresponding to the transport layer header.
12. The method according to any one of claims 9 to 11, characterized in that: The header in the first message does not include the following fields: source IP address, destination IP address, checksum, and TTL.
13. The method according to any one of claims 9 to 12, characterized in that: The communication connection between the first communication device and the second communication device is identified by the MAC address and port number of the first communication device and the MAC address and port number of the second communication device.
14. The method according to any one of claims 9 to 13, characterized in that: The second communication device processes the first message, including: The data link layer module in the second communication device transmits the first message to the second transport layer module in the second communication device according to the upper layer protocol type indicated by the data link layer header, and the second protocol module is a protocol processing module corresponding to the transport layer header; The second transport layer module decapsulates the first message to obtain the payload.
15. The method according to any one of claims 9 to 14, characterized in that: The communication connection between the first communication device and the second communication device is a connection that does not forward data through the network layer, specifically including: The network type of the interface in the first communication device connected to the second communication device is a point-to-point connection.
16. The method according to any one of claims 9 to 14, characterized in that: The communication connection between the first communication device and the second communication device is a connection that does not forward data through the network layer, specifically including: The IP address of the first communication device and the IP address of the second communication device are located in the same broadcast domain.
17. A communication device, characterized in that: The communication device is a first communication device, comprising: A processing module, configured to generate a first message, wherein the first message includes a payload, a transport layer header, and a data link layer header, and the first message does not include a network layer header; The transceiver module is used to send the first message to the second communication device via a communication connection, where the communication connection is a connection that does not forward data through the network layer.
18. The device according to claim 17, characterized in that The transport layer header includes the following fields: version number, header length, source port, destination port, sequence number, confirmation sequence number and total message length.
19. The device according to claim 17 or 18, characterized in that The data link layer header includes the following fields: upper layer protocol type, source media access control MAC address and destination MAC address; The upper layer protocol type is used to indicate the protocol type corresponding to the transport layer header.
20. The device according to any one of claims 17 to 19, characterized in that The header in the first message does not include the following fields: source IP address, destination IP address, checksum, and time to live value TTL.
21. The device according to any one of claims 17 to 20, characterized in that The communication connection is identified by the MAC address and port number of the first communication device and the MAC address and port number of the second communication device.
22. The device according to any one of claims 17 to 21, characterized in that The processing module is specifically used to: Generate the payload by a first transport layer module in the first communication device, where the first transport layer module is a protocol processing module corresponding to the transport layer header; The first message is obtained by encapsulating the transport layer header and the data link layer header outside the payload according to the communication connection through the first transport layer module.
23. The device according to any one of claims 17 to 22, characterized in that The network type of the interface in the first communication device that establishes the communication connection with the second communication device is a point-to-point connection.
24. The device according to any one of claims 17 to 22, characterized in that The IP address of the first communication device and the IP address of the second communication device are located in the same broadcast domain.
25. A communication device, characterized in that: The communication device is a second communication device, comprising: a transceiver module, configured to receive, through the communication connection between the first communication device and the second communication device, a first message sent by the first communication device, when the communication connection between the first communication device and the second communication device is a connection that does not forward data through the network layer, the first message including a payload, a transport layer header, and a data link layer header, and the first message does not include a network layer header; A processing module is used to process the first message to obtain the payload in the first message.
26. The device according to claim 25, characterized in that The transport layer header includes the following fields: version number, header length, source port, destination port, sequence number, confirmation sequence number and total message length.
27. The device according to claim 25 or 26, characterized in that The data link layer header includes the following multiple fields: upper layer protocol type, source MAC address and destination MAC address; The upper layer protocol type is used to indicate the protocol type corresponding to the transport layer header.
28. The device according to any one of claims 25 to 27, characterized in that The header in the first message does not include the following fields: source IP address, destination IP address, checksum, and TTL.
29. The device according to any one of claims 25 to 28, characterized in that The communication connection between the first communication device and the second communication device is identified by the MAC address and port number of the first communication device and the MAC address and port number of the second communication device.
30. The device according to any one of claims 25 to 29, characterized in that The processing module is specifically used to: delivering the first message to a second transport layer module in the second communication device according to the upper layer protocol type indicated by the data link layer header through a data link layer module in the second communication device, where the second protocol module is a protocol processing module corresponding to the transport layer header; The first message is decapsulated by the second transport layer module to obtain the payload.
31. The device according to any one of claims 25 to 30, characterized in that The network type of the interface in the first communication device connected to the second communication device is a point-to-point connection.
32. The device according to any one of claims 25 to 30, characterized in that The IP address of the first communication device and the IP address of the second communication device are located in the same broadcast domain.
33. A communication device, characterized in that: The device comprises a memory and a processor; the memory stores codes, the processor is configured to execute the codes, and when the codes are executed, the device executes the method according to any one of claims 1 to 16.
34. A computer storage medium, characterized in that The computer storage medium stores instructions, which, when executed by a computer, cause the computer to implement the method according to any one of claims 1 to 16.
35. A computer program product, characterized in that The computer program product stores instructions, which, when executed by a computer, cause the computer to implement the method according to any one of claims 1 to 16.