Communication method, device, and communication system

By negotiating the communication mode in the communication scenario within the LAN, avoiding the carrying of redundant IP headers, the problem of large overhead in the traditional TCP/IP mechanism is solved, and efficient inter-device communication is achieved.

WO2024239687A1PCT designated stage expired Publication Date: 2024-11-28HUAWEI TECH CO LTD

Patent Information

Application Number
PCT/CN2024/073217
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-05-19
Filing Date
2024-01-19
Publication Date
2024-11-28

AI Technical Summary

Technical Problem

In communication scenarios within the LAN, the redundant IP headers in the traditional TCP/IP mechanism lead to large processing overhead, increasing communication delay and resource consumption.

Method used

By negotiating the communication mode between the sending end and the receiving end, it is decided whether to carry the network layer header in the data frame according to the specific situation of the communication service, and on-demand packaging and de-encapsulation are realized to avoid redundant IP header processing.

Benefits of technology

Maximize the saving of communication resources and processing resources, reduce communication delay, improve the transmission efficiency of data frames, and realize efficient communication between devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024073217_28112024_PF_FP_ABST
    Figure CN2024073217_28112024_PF_FP_ABST
Patent Text Reader

Abstract

Disclosed in the present application are a communication method, a device, and a communication system, which relate to the technical field of communications and can save communication resources and processing resources to the maximum extent, while reducing the communication delay, to realize efficient communication between devices. On the basis of this solution, an electronic device can perform communication by means of adopting a proper communication mode according to a specific condition of a communication service. For example, when the communication service is a communication service between devices in the same local area network, a network layer header does not need to be carried in a data frame, such that the processing load and processing delay resulted from encapsulation processing, firewall processing, decapsulation processing, etc., brought by the network layer header are reduced in one aspect, and a payload of the data frame can be greatly improved in the other aspect, thereby improving the transmission efficiency of the data frame, and saving the communication resources and processing resources to the maximum extent while reducing the communication delay. Alternatively, when the communication service is a communication service between devices across networks, the network layer header is carried in the data frame to ensure a normal communication between devices.
Need to check novelty before this filing date? Find Prior Art

Description

Communication method, device and communication system

[0001] This application claims priority to the Chinese patent application filed with the State Intellectual Property Office on May 19, 2023, with application number 202310576532.9 and application name “Communication Method, Device and Communication System”, the entire contents of which are incorporated by reference into this application. Technical Field

[0002] The present application relates to the field of communication technologies, and in particular to communication methods, devices, and communication systems. Background Art

[0003] Transmission Control Protocol / Internet Protocol (TCP / IP), a protocol suite consisting of File Transfer Protocol (FTP), Simple Mail Transfer Protocol (SMTP), Transmission Control Protocol (TCP), User Datagram Protocol (UDP), and Internet Protocol (IP), can be widely used for communication between devices in the same network or between different networks.

[0004] When communicating based on TCP / IP, data frames are encapsulated in layers according to the protocol, and each layer has corresponding responsibilities; for example, the data link layer (layer 2) is usually responsible for communication addressing within the local area network, the network layer (layer 3) is usually responsible for addressing between networks, and the transport layer (layer 4) is usually responsible for addressing different business processes in the same device. Multi-layer collaboration can complete communication tasks.

[0005] However, in some communication scenarios, services are limited to the same local area network (LAN). In such cases, the network layer (Layer 3) is not required, so network layer (Layer 3) information (such as the IP header) is redundant. If the IP header is still carried during intra-LAN communication, processing overhead will increase significantly, for example, processing the IP header requires additional latency and transmission resources.

[0006] Summary of the Invention

[0007] The present application provides a communication method, device and communication system, which can adopt an appropriate communication mode for communication according to the specific circumstances of the communication business, maximize the conservation of communication resources and processing resources, while reducing communication delays and achieving efficient communication between devices.

[0008] To achieve the above objectives, this application adopts the following technical solutions:

[0009] In a first aspect, a communication method is provided, which can be applied to a sending device, such as a first device, and the method includes: the first device obtains application data of the application layer; the first device negotiates with the second device to determine a communication mode when the first device communicates with the second device, wherein the communication mode includes a first mode and a second mode, the first mode is a communication mode that does not perform network layer encapsulation and decapsulation, and the second mode is a communication mode that performs network layer encapsulation and decapsulation; the first device sends application data to the second device based on the determined communication mode.

[0010] Illustratively, the communication protocol of the network layer is, for example, an IP protocol, including but not limited to Internet Protocol version 4 (IPv4) and Internet Protocol version 6 (IPv6). The aforementioned network layer encapsulation refers to encapsulating an IP header before application data, the aforementioned non-network layer encapsulation refers to not encapsulating an IP header before application data, the aforementioned network layer decapsulation refers to removing the IP header in the data frame through the network layer, and the aforementioned non-network layer decapsulation refers to not removing the IP header through the network layer.

[0011] Among them, the IP header described in this application is also called "IP header", "IP head" and so on in some cases, and the embodiments of this application do not limit the specific name.

[0012] According to the solution provided by the first aspect above, when the first device has a demand for data transmission, it can adopt an appropriate communication mode for communication according to the specific circumstances of the communication service. For example, when the communication service does not require the participation of the network layer, the network layer header (such as the IP header) is not carried in the data frame. On the one hand, it reduces the processing load and processing delay of the encapsulation processing, firewall processing, decapsulation processing, etc. brought by the IP header. On the other hand, it can greatly increase the effective load of the data frame, thereby improving the transmission efficiency of the data frame, and reducing the communication delay while saving communication resources and processing resources to the maximum extent. Alternatively, when the communication service requires the participation of the network layer, the IP header is carried in the data frame to ensure the normal communication between devices. This strategy of encapsulating the network layer header on demand can save communication resources and processing resources to the maximum extent, while reducing communication delay and achieving efficient communication between devices.

[0013] As a possible implementation, the communication mode determined by negotiation between the first device and the second device is the first mode, and the first device sends application data to the second device based on the determined communication mode, including: the first device encapsulates the application data through the transport layer and the data link layer in sequence based on the first mode to obtain the first data; and the first device sends the first data to the second device. Based on this, the first device can avoid network layer encapsulation of the application data when the communication service does not require the participation of the network layer, that is, it does not carry the network layer header in the data frame, reducing the processing load and processing delay caused by redundant network layer headers such as encapsulation processing, firewall processing, and decapsulation processing, and greatly increasing the effective load of the data frame, thereby improving the transmission efficiency of the data frame, while minimizing communication resources and processing resources while reducing communication delay.

[0014] For example, if the network layer communication protocol is IP, the first data does not include an IP header because it has not been encapsulated at the network layer. Therefore, the receiving device (i.e., the second device) does not need to perform network layer decapsulation and firewall processing on the first data, thereby reducing processing load and latency and improving transmission efficiency.

[0015] As a possible implementation, the communication mode determined by negotiation between the first device and the second device is the second mode, and the first device sends application data to the second device based on the determined communication mode, including: the first device encapsulating the application data through the transport layer, network layer, and data link layer based on the second mode to obtain second data; and the first device sending the second data to the second device. Based on this, the first device can perform network layer encapsulation on the application data when the communication service requires network layer participation, that is, carry a network layer header in the data frame to ensure normal communication between the devices.

[0016] For example, taking the communication protocol of the network layer as the IP protocol, the second data includes an IP header because the second data is a data frame encapsulated by the network layer.

[0017] Exemplarily, the IP header may include a source IP address to indicate the IP address of the sending device, and a target IP address to indicate the IP address of the receiving device, so that the first device can know where the application data comes from and where it is to be sent, so that it can be smoothly transmitted to the receiving device corresponding to the target IP address, such as the second device.

[0018] As a possible implementation method, the above-mentioned first device and the second device negotiate to determine the communication mode when the first device communicates with the second device, including: when the communication scenario is the first scenario, the first device sends identification information of the first mode to the second device to negotiate with the second device to adopt the first mode when the first device communicates with the second device; or, when the communication scenario is the second scenario, the first device sends identification information of the second mode to the second device to negotiate with the second device to adopt the second mode when the first device communicates with the second device.

[0019] For example, the first scenario is for communication between devices within the same local area network (LAN), and the second scenario is for communication between devices within different LANs. It is understood that communication between devices within the same LAN does not require the involvement of the network layer, while communication between devices within different LANs requires the involvement of the network layer. Based on this, the first device can decide on demand whether to encapsulate the network layer header based on the actual communication scenario. This can maximize the savings in communication and processing resources, while minimizing communication latency and achieving efficient communication between devices, while ensuring normal communication between devices.

[0020] As a possible implementation, the method further includes: when the network layer address of the second device is the same as the network layer address of the first device, the first device determines that the communication scenario is the first scenario; or, when the network layer address of the second device is different from the network layer address of the first device, the first device determines that the communication scenario is the second scenario. Based on this, the first device can determine whether the first device and the second device are connected to the same local area network based on the network layer addresses of the devices, providing a reliable reference for subsequent on-demand encapsulation of the network layer header.

[0021] As a possible implementation, the first device and the second device negotiate to determine the communication mode for communication between the first and second devices, including: the first device instructing the second device to determine the communication mode for communication between the first and second devices; and the first device receiving identification information of the communication mode determined by the second device. This application does not limit the execution entity of the communication mode decision; both communicating parties can decide on a specific communication mode based on actual circumstances. Therefore, this solution can adapt to multiple communication protocols and is highly flexible.

[0022] As a possible implementation method, the above-mentioned first mode and second mode are both communication modes that follow the smart flow control protocol (SFC). Based on this, the above-mentioned solution of this application can be adapted to the bearer protocol SFC tailored for Hongmeng distributed scenarios. Of course, this application does not limit the communication protocol applicable to the above-mentioned on-demand encapsulation of network layer headers, and the solution can also be applied to other communication protocols.

[0023] For example, the SFC may be a communication protocol in the TCP / IP protocol suite. Of course, the present application is not limited thereto. For example, the SFC may also be a communication protocol independent of the TCP / IP protocol suite.

[0024] According to a second aspect, a communication method is provided, which can be applied to a receiving device, such as a second device, and the method includes: the second device receives identification information of a communication mode from a first device; the second device processes data from the first device based on the corresponding communication mode according to the received identification information; wherein the above-mentioned communication mode includes a first mode and a second mode, wherein the first mode is a communication mode that does not perform network layer encapsulation and decapsulation, and the second mode is a communication mode that performs network layer encapsulation and decapsulation.

[0025] According to the solution provided by the second aspect above, the second device can adopt an appropriate communication mode for communication based on the negotiation result of the communication mode with the first device and according to the specific circumstances of the communication service. For example, when the communication service does not require the participation of the network layer, the network layer header (such as the IP header) is not carried in the data frame. On the one hand, it reduces the processing load and processing delay of the encapsulation processing, firewall processing, decapsulation processing, etc. brought by the IP header. On the other hand, it can greatly improve the effective load of the data frame, thereby improving the transmission efficiency of the data frame, and reducing the communication delay while saving communication resources and processing resources to the maximum extent. Alternatively, when the communication service requires the participation of the network layer, the IP header is carried in the data frame to ensure the normal communication between devices. This strategy of encapsulating the network layer header on demand can save communication resources and processing resources to the maximum extent, while reducing communication delay and achieving efficient communication between devices.

[0026] As a possible implementation method, the above-mentioned identification information is the identification information of the first mode, and the above-mentioned second device processes the data from the first device based on the corresponding communication mode according to the received identification information, including: the second device decapsulates the first data from the first device through the data link layer and the transport layer in sequence based on the first mode.

[0027] For example, if the network layer communication protocol is IP, the first data does not include an IP header because it has not been encapsulated at the network layer. Therefore, the receiving device (i.e., the second device) does not need to perform network layer decapsulation or other processing on the first data, thereby reducing processing load and latency and improving transmission efficiency.

[0028] For example, the first device may send identification information of the first mode to the second device when the first device is connected to the same local area network as the second device. It is understood that the scenario of communication between devices within the same local area network does not require the participation of the network layer. Based on this, the first device may not encapsulate the network layer header before the application data in the scenario of communication between devices within the same local area network. This can maximize the conservation of communication resources and processing resources while ensuring the normal communication between devices, while reducing communication latency and achieving efficient communication between devices.

[0029] As a possible implementation method, the above-mentioned identification information is the identification information of the second mode, and the above-mentioned second device processes the data from the first device based on the corresponding communication mode according to the identification information, including: the second device decapsulates the second data from the first device through the data link layer, network layer and transport layer in sequence based on the second mode.

[0030] For example, taking the communication protocol of the network layer as the IP protocol, the second data includes an IP header because the second data is a data frame encapsulated by the network layer.

[0031] For example, the first device may send identification information of the second mode to the second device when the first device and the second device are not connected to the same local area network. It is understood that communication between devices in different local area networks requires the participation of the network layer. Based on this, the first device may encapsulate the network layer header before the application data in the communication between devices in different local area networks to ensure normal communication between the devices.

[0032] As a possible implementation method, the above-mentioned first mode and second mode are both communication modes that follow SFC. Based on this, the above-mentioned solution of this application can be adapted to the bearer protocol SFC tailored for Hongmeng distributed scenarios. Of course, this application does not limit the communication protocol applicable to the above-mentioned on-demand encapsulation of network layer headers, and the solution can also be applied to other communication protocols.

[0033] For example, the SFC may be a communication protocol in the TCP / IP protocol suite. Of course, the present application is not limited thereto. For example, the SFC may also be a communication protocol independent of the TCP / IP protocol suite.

[0034] According to a third aspect, an electronic device is provided, which may be a sending device, such as a first device, and includes: a data acquisition unit for acquiring application data of an application layer; a processing unit for negotiating with a second device to determine a communication mode when the first device communicates with the second device, wherein the communication mode includes a first mode and a second mode, the first mode is a communication mode in which network layer encapsulation and decapsulation are not performed, and the second mode is a communication mode in which network layer encapsulation and decapsulation are performed; and a transceiver unit for sending application data to the second device based on the determined communication mode.

[0035] For the specific functions of each module of the first device, the specific implementation process of each function and the corresponding technical effects, please refer to the introduction of any possible implementation method of the first aspect, which will not be repeated here.

[0036] In a fourth aspect, an electronic device is provided, which may be a receiving device, such as a second device, and the electronic device includes: a transceiver unit for receiving identification information of a communication mode from a first device; a processing unit for processing data from the first device based on the corresponding communication mode according to the received identification information; wherein the above-mentioned communication mode includes a first mode and a second mode, wherein the first mode is a communication mode in which network layer encapsulation and decapsulation are not performed, and the second mode is a communication mode in which network layer encapsulation and decapsulation are performed.

[0037] For the specific functions of each module of the second device, the specific implementation process of each function and the corresponding technical effects, please refer to the introduction of any possible implementation method of the second aspect, which will not be repeated here.

[0038] In a fifth aspect, an electronic device is provided, comprising: a transceiver for receiving or sending signals; a memory for storing computer program instructions; and a processor for executing the computer program instructions to support the electronic device in implementing a method as in any possible implementation of the first aspect.

[0039] In a sixth aspect, an electronic device is provided, comprising: a transceiver for receiving or sending signals; a memory for storing computer program instructions; and a processor for executing the computer program instructions to support the electronic device in implementing a method as in any possible implementation of the second aspect.

[0040] In a seventh aspect, a communication system is provided, which includes an electronic device in any possible implementation of the third aspect or the fifth aspect, and an electronic device in any possible implementation of the fourth aspect or the sixth aspect.

[0041] In an eighth aspect, a computer-readable storage medium is provided, on which computer program instructions are stored. When the computer program instructions are executed by a processor, the method in any possible implementation of the first aspect or the second aspect is implemented.

[0042] In a ninth aspect, a computer program product comprising instructions is provided, which, when executed on a computer, enables the computer to implement the method in any possible implementation of the first aspect or the second aspect.

[0043] In a tenth aspect, a chip system is provided, comprising a processing circuit and a storage medium storing computer program instructions; when the computer program instructions are executed by the processor, the method of any possible implementation of the first or second aspect is implemented. The chip system may be composed of a chip alone or may include a chip and other discrete components. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] FIG1 is an example diagram of three common TCP / IP layered models provided in an embodiment of the present application;

[0045] FIG2 is a schematic diagram of a process of layer-by-layer encapsulation of application data by a TCP / IP protocol stack according to an embodiment of the present application;

[0046] FIG3 is a schematic diagram of a smart home communication scenario provided by an embodiment of the present application;

[0047] FIG4 is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application;

[0048] FIG5 is a flow chart of two communication methods provided in an embodiment of the present application;

[0049] FIG6 is a schematic diagram of a data encapsulation and decapsulation process in a first mode provided by an embodiment of the present application;

[0050] FIG7 is a schematic diagram of a data encapsulation and decapsulation process in a second mode provided by an embodiment of the present application;

[0051] FIG8 is a schematic diagram of a software architecture of an electronic device provided in an embodiment of the present application;

[0052] FIG9 is a schematic diagram of the structures of data frames in two communication modes provided by an embodiment of the present application;

[0053] FIG10 is a schematic diagram of a communication mode negotiation process provided in an embodiment of the present application;

[0054] FIG11 is a structural block diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0055] The technical solutions in the embodiments of the present application will be described below in conjunction with the accompanying drawings in the embodiments of the present application. In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in this article is merely a description of the association relationship of associated objects, indicating that three relationships can exist, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "multiple" means two or more than two.

[0056] Hereinafter, the terms "first," "second," and so on are used solely to distinguish different descriptive objects and have no limiting effect on the position, order, priority, quantity, or content of the described objects. For example, if the described object is a "field," the ordinal number preceding the "field" in "first field" and "second field" does not define the position or order of the "fields." "First" and "second" do not define whether the modified "fields" are in the same message, nor do they restrict the order of the "first field" and "second field." For another example, if the described object is a "level," the ordinal number preceding the "level" in "first level" and "second level" does not define the priority of the "levels." For another example, the number of described objects is not limited by the ordinal number and can be one or more. For example, in the case of "first device," the number of "devices" can be one or more. Furthermore, the objects modified by different prefixes can be the same or different. For example, if the described object is a "device," the "first device" and "second device" can be the same type of device or different types of devices. For another example, if the described object is "information," the "first information" and "second information" can be information of the same content or different contents. In short, the use of prefixes such as ordinal numbers to distinguish the described objects in the embodiments of the present application does not constitute a restriction on the described objects. For the statement of the described objects, please refer to the description in the context of the claims or embodiments, and no unnecessary restrictions should be constituted due to the use of such prefixes.

[0057] Furthermore, in the embodiments of the present application, "connection" may be a direct connection or an indirect connection; in addition, it may refer to an electrical connection or a communication connection; for example, the connection between two electrical components A and B may refer to a direct connection between A and B, or may refer to an indirect connection between A and B through other electrical components or connection media, or may refer to an indirect connection between A and B through other communication devices or communication media, as long as communication between A and B can be achieved.

[0058] To facilitate understanding, the following first briefly introduces the TCP / IP layered model.

[0059] For example, please refer to Figure 1, which shows three common TCP / IP layered models provided in embodiments of the present application. As shown in Figure 1, the TCP / IP layered model includes the International Standardization Organization (ISO) seven-layer model, the TCP / IP four-layer model, and the TCP / IP five-layer model.

[0060] The ISO seven-layer model consists of, from top to bottom, the application layer, presentation layer, session layer, transport layer, network layer, data link layer, and physical layer. The application layer primarily provides application interfaces for upper-layer users and offers various network services. The presentation layer primarily provides various encoding and conversion functions for application-layer data, ensuring that data sent by the application layer of one system can be recognized by the application layer of another system. The session layer primarily establishes, manages, and terminates communication sessions between presentation-layer entities, such as organizing and coordinating communication between two session processes and managing data exchange. The transport layer primarily provides end-to-end reliable and transparent data transmission services for upper-layer protocols, including error checking and flow control. The network layer primarily handles routing and addressing, such as transmitting data to the destination address. The IP protocol resides in the network layer. The data link layer primarily establishes and manages logical connections between nodes, performs hardware addressing, and performs error detection. For example, it encapsulates bit stream data from the physical layer into data frames for transmission to the upper layer, or disassembles data frames from the upper layer into bit stream data for transmission to the physical layer. As a channel for data transmission, the physical layer is mainly used to use transmission media (such as twisted pair, cable, etc.) to provide physical connection for the data link layer to achieve transparent transmission of bit streams.

[0061] Both the TCP / IP four-layer model and the TCP / IP five-layer model are simplifications of the ISO seven-layer model. For example, the TCP / IP four-layer model includes the application layer, transport layer, network layer, and network interface layer. The application layer in the TCP / IP four-layer model plays a similar role to the application layer, presentation layer, and session layer in the ISO seven-layer model, while the network interface layer in the TCP / IP four-layer model plays a similar role to the data link layer and physical layer in the ISO seven-layer model. The TCP / IP five-layer model includes the application layer, transport layer, network layer, data link layer, and physical layer. The application layer in the TCP / IP five-layer model plays a similar role to the application layer, presentation layer, and session layer in the ISO seven-layer model.

[0062] Taking the TCP / IP five-layer model as an example, when an application has data to transmit, the application will send the application data into the protocol stack. The protocol stack will encapsulate the application data layer by layer and transmit it to the receiving end. The receiving end will disassemble it layer by layer starting from the bottom layer until it obtains the application data.

[0063] When the TCP / IP protocol stack encapsulates application data layer by layer, for example, as shown in Figure 2, the application layer can add an APP header before the application data and send the data (APP header + application data) down to the transport layer. The transport layer can add a TCP header before the data (APP header + application data) and send the resulting data segment (TCP header + APP header + application data) down to the network layer. The network layer can add an IP header before the data segment (TCP header + APP header + application data) and send the resulting data packet (IP header + TCP header + APP header + application data) down to the data link layer. The data link layer can add an Ethernet header before the data packet (IP header + TCP header + APP header + application data) and send the resulting data frame (Ethernet header + IP header + TCP header + APP header + application data) in binary form through the physical layer to the receiver. Correspondingly, during layer-by-layer disassembly at the receiver, the Ethernet header, IP header, TCP header, and APP header in the data frame can be removed layer by layer to ultimately obtain the application data.

[0064] As we know, the network layer is generally responsible for addressing between networks. For example, the network layer can support addressing between networks by adding an IP header before the data segment. For example, the IP header includes a 32-bit source IP address to indicate the IP address of the sending device and a 32-bit destination IP address to indicate the IP address of the receiving device. This allows devices to know where the application data comes from and where it is destined.

[0065] However, in many communication scenarios, communication services are limited to the same local area network and do not involve addressing between networks. For example, in communication scenarios such as smart office communication scenarios, smart home communication scenarios, or smart medical communication scenarios, the communication architecture is usually a distributed architecture within the same local area network, and the communication between devices under this distributed architecture is carried out within the same local area network. For example, in the smart home communication scenario shown in Figure 3, smart home devices such as air purifiers, large-screen devices in bedroom 1, air conditioners in bedroom 1, speakers, smart lights, large-screen devices in bedroom 2, air conditioners in bedroom 2, large-screen devices in the living room, refrigerators, tablet computers, mobile phones, microwave ovens, bread machines, dishwashers, sweeping robots, etc. are all within the coverage range of the router and are all in the same local area network. The communication between the above-mentioned smart home devices is carried out within the same local area network.

[0066] Therefore, if conventional TCP / IP mechanisms are still used to handle communications between devices within the same LAN, the IP header is completely redundant, and the processing overhead of redundant IP headers is very high. For example, the IP header must undergo additional encapsulation, firewall processing, decapsulation, and other rule chain-related processes, which incurs additional processing delays. Furthermore, the IP header consists of at least 20 bytes and can be up to 60 bytes. Therefore, the IP header reduces the payload of the data frame, thereby improving the transmission efficiency of the data frame. For example, based on a maximum transmission unit (MTU) of 1500 bytes, the transmission bandwidth will decrease by 2% to 4%.

[0067] To address the shortcomings of the TCP / IP mechanism in the aforementioned communication scenarios, embodiments of the present application provide a communication method based on which devices can adopt appropriate communication modes for communication based on the specific circumstances of the communication service. For example, when the communication service is between devices within the same local area network, the IP header can be omitted from the data frame; when the communication service is between devices across different networks, the IP header can be included in the data frame. This maximizes the savings in communication and processing resources, while reducing communication latency and achieving efficient communication between devices.

[0068] Among them, the communication method described in the embodiments of the present application can be applied to the communication process between electronic devices, such as the communication process between a first device and a second device.

[0069] The electronic device (such as the first device or the second device) may be a fixed terminal, such as a laptop computer, a desktop computer, a smart home device, etc. The electronic device (such as the first device or the second device) may also be a mobile terminal, such as a mobile phone, a tablet, etc. A mobile terminal may also be referred to as user equipment (UE), access terminal, subscriber unit, subscriber station, mobile station, mobile station, remote station, remote terminal, mobile device, user terminal, terminal, wireless communication device, user agent, or user device. The mobile terminal may be a station (STAION, ST) in a WLAN, a cellular phone, a cordless phone, a Session Initiation Protocol (SIP) phone, a Wireless Local Loop (WLL) station, a Personal Digital Assistant (PDA) device, a handheld device with wireless communication capabilities, a computing device or other processing device connected to a wireless modem, an in-vehicle device, an Internet of Vehicles terminal, a computer, a portable multimedia player (PMP), an augmented reality (AR) / virtual reality (VR) device, a camera, a somatosensory game console in a human-computer interaction scenario, a laptop computer, a handheld communication device, a handheld computing device, a satellite wireless device, a wireless modem card, a TV set-top box (STB), customer premise equipment (CPE) and / or other devices used to communicate on a wireless system, as well as next-generation communication systems, such as mobile terminals in a 5G network or mobile terminals in a future evolved Public Land Mobile Network (PLMN) network. The mobile terminal can also be a wearable device. Wearable devices can also be called wearable smart devices, which are a general term for wearable devices that use wearable technology to intelligently design and develop wearable devices for daily wear, such as glasses, bracelets, gloves, watches, clothing and shoes. A wearable device is a portable device that is worn directly on the body or integrated into the user's clothes or accessories. Wearable devices are not only hardware devices, but also achieve powerful functions through software support, data interaction, and cloud interaction. Alternatively, the electronic device can also be an electronic device of other types or structures, which is not limited in the embodiments of the present application.

[0070] For example, please refer to Figure 4, which shows a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application. The electronic device can be a first device or a second device.

[0071] As shown in Figure 4, the electronic device may include a processor 410, a memory (including an external memory interface 420 and an internal memory 421), a universal serial bus (USB) interface 430, a charging management module 440, a power management module 441, a battery 442, an antenna 1, an antenna 2, a mobile communication module 450, a wireless communication module 460, an audio module 470, a display screen 480, etc.

[0072] It is understood that the structures illustrated in the embodiments of the present invention do not constitute specific limitations on the electronic device. In other embodiments of the present application, the electronic device may include more or fewer components than shown, or may combine or separate certain components, or arrange the components differently. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0073] Processor 410 may include one or more processing units. For example, processor 410 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a flight controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU). The different processing units may be independent devices or integrated into one or more processors.

[0074] Processor 410 may also include a memory for storing instructions and data. In some embodiments, the memory in processor 410 is a cache memory. This memory can store instructions or data that have just been used or are being recycled by processor 410. If processor 410 needs to use the same instruction or data again, it can directly access the memory. This avoids duplicate accesses, reduces processor 410 latency, and thus improves system efficiency.

[0075] In some embodiments, the processor 410 may include one or more interfaces. The interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface.

[0076] It should be understood that the interface connection relationship between the modules illustrated in the embodiments of the present application is only for illustrative purposes and does not constitute a structural limitation on the electronic device. In other embodiments of the present application, the electronic device may also adopt different interface connection methods from the above embodiments, or a combination of multiple interface connection methods.

[0077] The charging management module 440 is configured to receive charging input from a charger. The power management module 441 is configured to connect the battery 442, the charging management module 440, and the processor 410. The power management module 441 receives input from the battery 442 and / or the charging management module 440 to provide power to the processor 410, the internal memory 421, the universal serial bus (USB) interface 430, the mobile communication module 450, the wireless communication module 460, the audio module 470, the display screen 480, and the like.

[0078] The wireless communication function of the electronic device can be implemented through antenna 1, antenna 2, mobile communication module 450, wireless communication module 460, modem processor and baseband processor.

[0079] Antenna 1 and Antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in an electronic device can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve antenna utilization. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In other embodiments, the antennas can be used in conjunction with a tuning switch.

[0080] The mobile communication module 450 can provide solutions for wireless communications including 2G / 3G / 4G / 5G applied to electronic devices. The mobile communication module 450 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 450 can receive electromagnetic waves from the antenna 1, and filter, amplify, and process the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 450 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1. In some embodiments, at least some of the functional modules of the mobile communication module 450 can be set in the processor 410. In some embodiments, at least some of the functional modules of the mobile communication module 450 can be set in the same device as at least some of the modules of the processor 410.

[0081] The modem processor may include a modulator and a demodulator. The modulator is used to modulate the low-frequency baseband signal to be transmitted into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After being processed by the baseband processor, the low-frequency baseband signal is passed to the application processor. The application processor outputs a sound signal through an audio module (not limited to a speaker, a receiver, etc.) or displays an image or video through the display screen 480. In some embodiments, the modem processor may be an independent device. In other embodiments, the modem processor may be independent of the processor 410 and be provided in the same device as the mobile communication module 450 or other functional modules.

[0082] The wireless communication module 460 can provide wireless communication solutions for electronic devices, including wireless local area networks (WLAN) (such as WiFi networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared technology (IR), etc. The wireless communication module 460 can be one or more devices that integrate at least one communication processing module. The wireless communication module 460 receives electromagnetic waves via the antenna 2, frequency modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 410. The wireless communication module 460 can also receive the signal to be sent from the processor 410, frequency modulate it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.

[0083] In some embodiments, antenna 1 of the electronic device is coupled to mobile communication module 450, and antenna 2 is coupled to wireless communication module 460, so that the electronic device can communicate with a network and other devices via wireless communication technologies. The wireless communication technologies may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), time-division code division multiple access (TD-SCDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technology. The GNSS may include global positioning system (GPS), global navigation satellite system (GLONASS), Beidou navigation satellite system (BDS), quasi-zenith satellite system (QZSS) and / or satellite-based augmentation system (SBAS).

[0084] The electronic device implements display functionality through a GPU, display screen 480, and an application processor. The GPU is a microprocessor for image processing that connects the display screen 480 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 410 may include one or more GPUs, which execute program instructions to generate or modify display information.

[0085] Display screen 480 is used to display images, videos, and the like. Display screen 480 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a MiniLED, a MicroLED, a Micro-OLED, or a quantum dot light-emitting diode (QLED). In some embodiments, the electronic device can include one or N display screens 494, where N is a positive integer greater than one.

[0086] The external memory interface 420 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device. The external memory card communicates with the processor 410 via the external memory interface 420 to implement data storage functions. For example, files such as pictures, music, and videos can be stored on the external memory card.

[0087] Internal memory 421 can be used to store computer executable program code. For example, computer programs can include operating system programs and application programs. The operating system can include but is not limited to OS and other operating systems. Among them, the executable program code includes instructions. The processor 410 executes various functional applications and data processing of the electronic device by running the instructions stored in the internal memory 421. The internal memory 421 may include a program storage area and a data storage area. Among them, the program storage area can store the operating system, at least one application required for a function, etc. The data storage area can store data created during the use of the electronic device, etc. In addition, the internal memory 421 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc. The processor 410 executes various functional applications and data processing of the electronic device by running the instructions stored in the internal memory 421, and / or the instructions stored in the memory provided in the processor.

[0088] Regarding the specific working principles and functions of other modules, such as the audio module 470, please refer to the introduction in conventional technology, and the embodiments of this application will not be repeated.

[0089] It is understood that the structure illustrated in FIG4 of the present application does not constitute a specific limitation on the electronic device. In other embodiments of the present application, the electronic device may include more or fewer components than shown in the figure, or combine certain components, or split certain components, or arrange the components differently. The illustrated components may be implemented in hardware, software, or a combination of software and hardware. For example, in some embodiments, the electronic device may further include one or more hardware modules such as a speaker, a receiver, a microphone, a headphone jack, a sensor, a button, a motor, an indicator, and a camera.

[0090] The following will be combined with specific embodiments to specifically introduce the communication method provided in the embodiments of the present application. The communication method can be applied between any two electronic devices (for example, a first device and a second device). The first device can be a transmitting end (or a client (Client)), and the second device can be a receiving end (or a server (Server)); or the first device can be a receiving end (or a server (Server)), and the second device can be a transmitting end (or a client (Client)). The following embodiments take the first device as the transmitting end and the second device as the receiving end as an example to introduce the communication method provided in the embodiments of the present application.

[0091] Please refer to Figure 5, which shows a flow chart of two communication methods provided in an embodiment of the present application. As shown in Figure 5 (a) and Figure 5 (b), a communication method provided in an embodiment of the present application includes S501:

[0092] S501: When a first device needs to send data to a second device, the first device determines whether the second device and the first device are connected to the same local area network.

[0093] The above-mentioned demand for sending data may include but is not limited to the demand for sending business data (such as application data).

[0094] As a possible implementation, the first device can determine whether the second device and the first device are connected to the same local area network by determining whether the network layer address (such as IP address) of the second device is the same as the network layer address (such as IP address) of the first device itself. It can be understood that if the second device and the first device are connected to the same local area network, the IP addresses of the first device and the second device are the same; if the second device and the first device are connected to different local area networks, the IP addresses of the first device and the second device are different. Based on this, the first device can successfully determine whether the second device is connected to the same local area network as itself by comparing the IP address of the second device with its own.

[0095] An IP address is used to identify different devices on a network in a communication protocol. An IP address may include, but is not limited to, an Internet Protocol version 4 (IPv4) address and an Internet Protocol version 6 (IPv6) address.

[0096] As an example, the network layer address (such as IP address) of the second device is obtained by the application layer from the network side when receiving a service request.

[0097] As shown in (a) of FIG. 5 , if the second device and the first device are connected to the same local area network, the communication method provided in the embodiment of the present application further includes S502a-S507a:

[0098] S502a: The first device sends a communication mode to the second device, where the communication mode is a first mode.

[0099] For example, the first device may send identification information of the first mode to the second device.

[0100] Among them, for the sending end (i.e., the first device), the first mode refers to a communication mode in which the network layer encapsulation of the transmitted data is not performed during communication; for the receiving end (i.e., the second device), the first mode refers to a communication mode in which the network layer decapsulation of the received data is not performed during communication.

[0101] In an embodiment of the present application, the first mode sent by the first device to the second device is used to negotiate with the second device to communicate in the first mode, or to notify the second device that the first device tends to communicate with the second device in the first mode, or to indicate to the second device that the first device is about to communicate with the second device in the first mode, or to indicate to the second device that the first device is about to communicate with the second device in the first mode.

[0102] Among them, before the first device executes S502a, the first device may have determined that the second device supports the communication mode of the first mode. In this case, the first mode sent by the first device to the second device may be used to negotiate with the second device to communicate in the first mode, or may be used to notify the second device that the first device tends to communicate with the second device in the first mode, or may be used to indicate to the second device that the first device is about to communicate with the second device in the first mode, or may be used to indicate to the second device that the first device is about to communicate with the second device in the first mode.

[0103] Alternatively, before the first device executes S502a, the first device may not know whether the second device supports the communication mode of the first mode. In this case, the first mode sent by the first device to the second device is used to negotiate with the second device to communicate in the first mode. Whether the second device specifically agrees to communicate with the first device in the first mode depends on factors such as its specific capabilities.

[0104] The embodiment of the present application does not limit whether the first device knows the communication mode supported by the second device before the first device executes S502a.

[0105] S503a: The second device agrees to communicate with the first device based on the first mode.

[0106] As a possible implementation manner, the second device may agree to communicate with the first device based on the first mode when the second device supports the communication mode of the first mode.

[0107] S504a: The first device establishes a communication connection in a first mode with the second device.

[0108] Among them, after the first device and the second device establish a first mode communication connection, based on the first mode communication connection, the first device as the sending end does not perform network layer encapsulation on the transmitted data, that is, does not encapsulate the IP header. Correspondingly, the second device as the receiving end does not perform network layer decapsulation on the received data.

[0109] S505a: The first device encapsulates the payload based on the first mode to obtain first data, wherein the first data does not include an IP header.

[0110] The payload is the most basic purpose of data transmission. The data transmitted along with the payload usually also includes a data header, such as an APP header, TCP header, IP header, Ethernet header, etc. The data header is used to assist in the transmission of the payload. For example, the payload is the business data to be transmitted (such as application data).

[0111] In an embodiment of the present application, the first device does not perform network layer encapsulation when encapsulating the payload based on the first mode, that is, it does not encapsulate the IP header. Therefore, the first data obtained by the first device based on the first mode encapsulation of the payload does not include the IP header.

[0112] Exemplarily, as shown in FIG6 , the first device encapsulates the payload based on the first mode, including the first device performing application layer encapsulation (i.e., adding an APP header before the payload), transport layer encapsulation (i.e., adding a TCP header before the APP header), and data link layer encapsulation (i.e., adding an Ethernet header before the TCP header) on the payload layer by layer to obtain the first data.

[0113] S506a: The first device sends first data without an IP header to the second device.

[0114] Exemplarily, the first device may send the first data without an IP header to the second device in binary form through the physical layer.

[0115] S507a: The second device decapsulates the first data based on the first mode to obtain a payload.

[0116] In an embodiment of the present application, the second device does not perform network layer decapsulation when decapsulating the first data based on the first mode.

[0117] Exemplarily, as shown in Figure 6, the second device decapsulates the first data based on the first mode, including the second device performing data link layer decapsulation layer by layer to remove the Ethernet header, transport layer decapsulation to remove the TCP header, and application layer decapsulation to remove the APP header, and finally obtaining the payload.

[0118] As shown in (b) of FIG5 , if the second device and the first device are not connected to the same local area network, the communication method provided in the embodiment of the present application further includes S502b-S507b:

[0119] S502b: The first device sends a communication mode to the second device, where the communication mode is the second mode.

[0120] For example, the first device may send identification information of the second mode to the second device.

[0121] Among them, for the sending end (i.e., the first device), the second mode refers to a communication mode in which the network layer encapsulation of the data to be transmitted is performed during communication; for the receiving end (i.e., the second device), the second mode refers to a communication mode in which the network layer decapsulation of the received data is performed during communication.

[0122] In an embodiment of the present application, the second mode sent by the first device to the second device is used to negotiate with the second device to communicate in the second mode, or to notify the second device that the first device tends to communicate with the second device in the second mode, or to indicate to the second device that the first device is about to communicate with the second device in the second mode, or to indicate to the second device that the second device is about to communicate with the first device in the second mode.

[0123] Among them, before the first device executes S502b, the first device may have determined that the second device supports the communication mode of the second mode. In this case, the second mode sent by the first device to the second device may be used to negotiate with the second device to communicate in the second mode, or may be used to notify the second device that the first device tends to communicate with the second device in the second mode, or may be used to indicate to the second device that the first device is about to communicate with the second device in the second mode, or may be used to indicate to the second device that the second device is about to communicate with the second device in the second mode.

[0124] Alternatively, before the first device executes S502b, the first device may not know whether the second device supports the communication mode of the second mode. In this case, the second mode sent by the first device to the second device is used to negotiate with the second device to communicate in the second mode. Whether the second device specifically agrees to communicate with the first device in the second mode depends on factors such as its specific capabilities.

[0125] The embodiment of the present application does not limit whether the first device knows the communication mode supported by the second device before the first device executes S502b.

[0126] S503b: The second device agrees to communicate with the first device based on the second mode.

[0127] As a possible implementation manner, the second device may agree to communicate with the first device based on the second mode when it supports the communication mode of the second mode.

[0128] S504b: The first device establishes a communication connection in a second mode with the second device.

[0129] Among them, after the first device and the second device establish a second mode communication connection, based on the second mode communication connection, the first device as the sending end will perform network layer encapsulation on the data to be transmitted, that is, it will encapsulate the IP header. Correspondingly, the second device as the receiving end will decapsulate the received data at the network layer.

[0130] S505b: The first device encapsulates the payload based on the second mode to obtain second data, wherein the second data includes an IP header.

[0131] In the embodiment of the present application, the first device performs network layer encapsulation when encapsulating the payload based on the second mode. Therefore, the second data obtained by the first device based on the second mode encapsulating the payload includes an IP header.

[0132] Exemplarily, as shown in FIG7 , the first device encapsulates the payload based on the second mode, including the first device performing application layer encapsulation (i.e., adding an APP header before the payload), transport layer encapsulation (i.e., adding a TCP header before the APP header), network layer encapsulation (i.e., adding an IP header before the TCP header), and data link layer encapsulation (i.e., adding an Ethernet header before the IP header) on the payload layer by layer to obtain second data.

[0133] S506b: The first device sends the second data carrying the IP header to the second device.

[0134] Exemplarily, the first device may send the second data carrying the IP header to the second device in binary form through the physical layer.

[0135] S507b: The second device decapsulates the first data based on the second mode to obtain a payload.

[0136] In an embodiment of the present application, the second device performs network layer decapsulation when decapsulating the second data based on the second mode.

[0137] Exemplarily, as shown in Figure 7, the second device decapsulates the second data based on the second mode, including the second device performing data link layer decapsulation layer by layer to remove the Ethernet header, network layer decapsulation to remove the IP header, transport layer decapsulation to remove the TCP header, and application layer decapsulation to remove the APP header, and finally obtaining the payload.

[0138] It can be understood that, as shown in (a) in Figure 5, the sending end can not carry redundant IP headers in the data frame when the receiving end is connected to the same local area network as itself. On the one hand, it reduces the processing load and processing delay of the encapsulation processing, firewall processing, decapsulation processing, etc. brought by the IP header. On the other hand, it can greatly improve the effective load of the data frame, thereby improving the transmission efficiency of the data frame, while maximally saving communication resources and processing resources and reducing communication delay. As shown in (b) in Figure 5, the sending end can process the communication between devices in accordance with the conventional TCP / IP mechanism through the standard routing addressing forwarding method when the receiving end is not connected to the same local area network as itself, so as to ensure the normal communication between devices. The above-mentioned method of communicating by adopting an appropriate communication mode according to the specific circumstances of the communication business in the embodiment of the present application can not only be compatible with data transmission between different local area networks, but also can be used in the communication scenario between devices in the same local area network. While ensuring the normal communication between devices, it can save resources to the maximum extent, reduce communication delay, achieve efficient communication between devices, and improve user experience.

[0139] It's important to note that the sender doesn't include redundant IP headers in data frames. Although firewall processing of the IP header is skipped, this doesn't increase security risks. This is because the firewall's processing rules for the same data stream are the same. Once the first packet passes inspection, subsequent data in the same stream can skip the firewall module. Therefore, the establishment of a communication connection between the sender and receiver means that the current connection complies with the firewall's security rules.

[0140] As a possible implementation method, the communication method described in the embodiment of the present application can be implemented based on the smart flow control protocol (SFC). The SFC protocol is a bearer protocol tailored for Hongmeng distributed scenarios. The SFC protocol supports the mechanism of on-demand encapsulation of network layer headers, providing more efficient transmission while ensuring communication reliability. Exemplarily, based on the on-demand encapsulation of network layer headers provided by the SFC protocol, the sending end can negotiate with the receiving end when establishing a connection whether to carry the network layer header in subsequent data transmission. For example, if the receiving end and the sending end are connected to the same local area network, the two parties can negotiate to a communication mode that does not carry a network layer header (i.e., the first mode) to maximize transmission performance; otherwise, the two parties can negotiate to a communication mode that carries a network layer header (i.e., the second mode) to ensure normal communication between devices.

[0141] For example, please refer to Figure 8, which shows a schematic diagram of the software architecture of an electronic device. As shown in Figure 8, the software architecture of the electronic device includes an application layer, a Socket application programming interface (Socket API), and a TCP / IP protocol suite.

[0142] The application layer may include a series of applications, such as but not limited to camera, gallery, calendar, call, map, navigation, Bluetooth, music, video, short message, etc.

[0143] The Socket API is the middle layer between the application layer and the TCP / IP protocol suite. It provides a network programming interface that enables the programming of functions for TCP, UDP, or SFC. Examples of these functions include create, listen, connect, accept, send, read, and write. Specifically, the Socket API represents, but is not limited to, the following information required for network communication: the connection protocol, the IP address of the sending device, the protocol port of the local process, the IP address of the target device, and the protocol port of the target process.

[0144] Understandably, when the application layer communicates data through the transport layer, TCP faces the challenge of providing concurrent services to multiple application processes. Multiple TCP connections or multiple application processes may need to transmit data through the same TCP protocol port. The application and transport layers use the Socket API to distinguish communications from different application processes or network connections, enabling concurrent data transmission.

[0145] The TCP / IP protocol suite may include, but is not limited to, TCP / UDP, SFC, and IP (such as IPv4, IPv6) as shown in Figure 8. The SFC protocol can be understood as a more lightweight communication protocol in the TCP / IP protocol suite, alongside TCP and UDP.

[0146] In an embodiment of the present application, if the receiving end and the sending end are connected to the same local area network, the two parties can negotiate to form mode 1 (i.e., the first mode) as shown in Figure 8, based on the SFC protocol communication. As shown in Figure 8, based on mode 1, the data to be transmitted by the sending end can be encapsulated by the application layer, transport layer (such as SFC) and data link layer in sequence, without encapsulating the network layer header; correspondingly, the receiving end can decapsulate the data by the data link layer, transport layer (such as SFC) and application layer in sequence. If the receiving end and the sending end are not connected to the same local area network, the two parties can negotiate to form mode 2 (i.e., the second mode) as shown in Figure 8, based on the SFC protocol and IP protocol communication. As shown in Figure 8, based on mode 2, the data to be transmitted by the sending end can be encapsulated by the application layer, transport layer (such as SFC), network layer (such as IPv4 / IPv6) and data link layer in sequence; correspondingly, the receiving end can decapsulate the data by the data link layer, network layer (such as IPv4 / IPv6), transport layer (such as SFC) and application layer in sequence. As can be seen from Figure 8, compared with Mode 2, the calling process of Mode 1 is shorter, and both Mode 1 and Mode 2 are compatible with the existing Socket API.

[0147] It should be noted that the embodiments of the present application only introduce the communication mode between devices in the same local area network or different local area networks, and do not limit the communication protocol and the communication mode adopted by the electronic device in other communication scenarios. For example, in some conventional scenarios, the sender and the receiver can also negotiate to use mode 3 in Figure 8 for communication. As shown in Figure 8, based on mode 3 (such as TCP / UDP mode), the data to be transmitted by the sender can be encapsulated in the application layer, transport layer (such as TCP / UDP), network layer (such as IPv4 / IPv6) and data link layer in sequence to obtain a TCP / UDP Socket frame; correspondingly, the receiver can decapsulate the data in the data link layer, network layer (such as IPv4 / IPv6), transport layer (such as TCP / UDP) and application layer in sequence.

[0148] As an example, the first mode (or Mode 1) is also called the SFC Over Ether mode. In SFC Over Ether mode, the data frame sent from the transmitter to the receiver is an SFC Over Ether Socket frame, as shown in Figure 9. The second mode (or Mode 2) is also called the SFC Over IP mode. In SFC Over IP mode, the data frame sent from the transmitter to the receiver is an SFC Over IP Socket frame, as shown in Figure 9.

[0149] As shown in Figure 9, both the SFC Over Ether Socket frame and the SFC Over IP Socket frame include fields such as Preamble, SFD, DstMAC, SrcMAC, Type, SFC header, application data, and FCS.

[0150] The Preamble field is a preamble code that enables the receiving adapter to quickly adjust the clock frequency when receiving data frames to match the frequency of the transmitting end. The Preamble field can be 7 bytes long, alternating between 1s and 0s.

[0151] The SFD field is used to represent the start character of the data frame. The length of the SFD field can be 1 byte. The first 6 bits are alternating between 1 and 0, and the last two consecutive bits are 1 to inform the receiving adapter: "Frame information is coming, prepare to receive it."

[0152] The DstMAC field is the destination address, representing the MAC address or physical address of the network adapter receiving the data frame. The DstMAC field can be 6 bytes long. It is understood that when the receiving end receives a MAC frame, it first checks whether the destination address of the data frame is the same as the physical address of the current adapter. If so, it is processed further; if not, the data frame is discarded.

[0153] The SrcMAC field is the source address, which is used to represent the MAC address or physical address of the network adapter that sends the data frame. The length of the SrcMAC can be 6 bytes.

[0154] The Type field is used to indicate the type of high-level data carried in the Layer 2 data frame. Due to the numerous upper-layer protocols, the Type field can be used to indicate which high-level protocol the data is delivered to for processing. The Type field can be 2 bytes long. For example, if the value of the Type field is 0xABAB, it can indicate that the high-level data carried in the Layer 2 data frame is an SFC Over Ether Socket frame. If the value of the Type field is 0x0800, it can indicate that the high-level data carried in the Layer 2 data frame is an SFC Over IP Socket frame. It will be understood that the above-mentioned 0xABAB and 0x0800 are merely exemplary and do not constitute a limitation of the embodiments of the present application. In some embodiments, other values ​​can also be used to indicate SFC Over Ether Socket frames and SFC Over IP Socket frames.

[0155] The SFC header is used to ensure that data frames can arrive at the receiving end reliably and in order, and is used to assist in calculating the round-trip time (RTT) and assist in congestion control, etc. The length of the SFC header field can be 12 bytes.

[0156] As an example, the SFC header may include but is not limited to fields such as version (version, V), priority (priority, P), transmit index (transmit index, TI), merge indication (merge, M), window (Window), extended header indication (optional, O), type (type, T), length (length), checksum indication (checksum), flow label (flow label), sequence number (sequence number, SN) and extended header (optional header(s)).

[0157] The version field indicates the SFC protocol version number. The priority field indicates the priority of the data frame. The transmission index field indicates whether the data frame is being sent for the first time or as a retransmission. The merge indication field indicates whether the data frame needs to be merged with subsequent data frames. The window field indicates the size of the receiving window. The extension header indication field indicates whether the data frame contains an extension header. The type field indicates the data type of the data frame, such as initialization, response, data, or end.

[0158] The length of application data can be 30 bytes, with a maximum of 1488 bytes, also known as the Maximum Transmission Unit (MTU). If the length is less than 30 bytes, it can be padded to 46 bytes.

[0159] The FCS field is a frame check sequence, used to detect errors in the data frame. The FCS field can be 4 bytes long. For example, the transmitter can calculate a cyclic redundancy check (CRC) for the data frame and write it into the FCS field. The receiver recalculates the CRC and compares it with the CRC value in the FCS field. If the two differ, data loss or alteration occurred during transmission, and the data frame needs to be retransmitted.

[0160] As shown in Figure 9, the SFC Over Ether Socket frame does not include an IP header because it is not encapsulated at the network layer; while the SFC Over IP Socket frame does include an IP header because it is encapsulated at the network layer.

[0161] The IP header is used to support addressing between networks. For example, the IP header may include a 20-bit source IP address to indicate the IP address of the sending device, and a 402-bit destination IP address to indicate the IP address of the receiving device. This allows devices to know where the application data comes from and where it is to be sent.

[0162] As mentioned above, the SFC protocol provides a mechanism for encapsulating the network layer header on demand, and the sending end can negotiate with the receiving end when establishing a connection whether to carry the network layer header in subsequent data transmission. For example, please refer to Figure 10, which takes the communication between the first device and the second device based on the SFC protocol as an example, and shows a schematic diagram of a communication mode negotiation process provided by an embodiment of the present application. Among them, both the first device and the second device support the SFC protocol, and the first device and the second device are equal in the protocol. In the example shown in Figure 10, the first device is the party that initiates the link establishment request, and is therefore also called the sending end (or client (Client)), and the second device as the requested party is called the receiving end (or server (Server)).

[0163] As shown in FIG10 , when there is a need to send data to a second device, the process of the first device and the second device negotiating a communication mode mainly includes S1001 to S1007:

[0164] S1001: The first device initiates a link establishment request process.

[0165] Exemplarily, the first device may first create a Socket, and then call a connect interface to initiate a link establishment request process.

[0166] S1002: The first device determines a communication mode.

[0167] As a possible implementation method, the first device can determine whether the second device and the first device are connected to the same local area network by determining whether the network layer address (such as IP address) of the second device is the same as the network layer address (such as IP address) of the first device itself, and determine the communication mode to be used based on whether the second device and the first device are connected to the same local area network.

[0168] Exemplarily, if the IP address of the second device is the same as the IP address of the first device, that is, the second device and the first device are connected to the same local area network, the first device determines that the communication mode is the first mode (such as SFC Over Ether mode); if the IP address of the second device is different from the IP address of the first device, that is, the second device and the first device are not connected to the same local area network, the first device determines that the communication mode is the second mode (such as SFC Over IP mode).

[0169] As a possible implementation, the first device may also determine that the communication mode is automatic mode. Specifically, the first device may preliminarily determine that the communication mode is automatic mode when deciding to have the second device determine the specific communication mode based on actual circumstances. Accordingly, if, during a subsequent communication mode negotiation, the second device receives from the first device that the communication mode is automatic mode, the second device may independently determine the communication mode to be used for communication between the two devices.

[0170] S1003: The first device creates a flow table.

[0171] A flow table is a collection of policy entries for a specific flow, responsible for searching and forwarding data frames. A process can include a series of flow entries.

[0172] Exemplarily, the process may include but is not limited to header fields for data packet matching, counters for counting the number of matching data frames, and actions for showing how matching data packets are processed.

[0173] Among them, the packet header field contains 12 tuples, which basically cover layers 1-4 of the OSI model. For example, the packet header field may include ingress port, source MAC address, destination MAC address, VLAN tag, VLAN priority, source IP, destination IP, IP protocol field, IP service type, SFC source port number, SFC destination port number, TCP / UDP source port number, TCP / UDP destination port number. The counter is used to count statistical traffic-related information, such as the number of currently active table entries, the number of packet lookups, the number of packet matches, the number of received packets, the number of received packet bytes, the duration of the received data flow, the number of sent packets, the number of sent packet bytes, the number of errors, etc. The action table is used to instruct the switch how to process the matching data packet after receiving it. Each flow table entry can correspond to zero to multiple actions. For a detailed introduction to the flow table, please refer to conventional technology, and the embodiments of this application will not be repeated.

[0174] S1004: The first device negotiates parameters with the second device, including negotiating a communication mode.

[0175] As an example, the first device may send its determined communication mode to the second device for negotiation with the second device to communicate in the first mode, or for notifying the second device that the first device prefers to communicate with the second device in the first mode, or for indicating to the second device that the first device is about to communicate with the second device in the first mode, or for indicating to the second device that the first device is about to communicate with the second device in the first mode.

[0176] Exemplarily, the first device may send the communication mode determined by it to the second device via an initialization request (such as an INIT message).

[0177] S1005: The second device creates a flow table.

[0178] S1006: The second device determines a connection mode.

[0179] As an example, the communication mode sent by the first device to the second device is the first mode or the second mode. In this case, the second device may determine to adopt the communication mode consistent with that sent by the first device.

[0180] As an example, the communication mode sent by the first device to the second device is the automatic mode. In this case, the second device can determine the communication mode to be adopted by the two parties for communication. For example, the second device can determine whether the second device and the first device are connected to the same local area network by determining whether the network layer address (such as IP address) of the second device and the network layer address (such as IP address) of the first device itself are the same, and determine the communication mode to be used based on whether the second device and the first device are connected to the same local area network. Exemplarily, if the IP address of the second device is the same as the IP address of the first device, that is, the second device and the first device are connected to the same local area network, the first device determines that the communication mode is the first mode (such as SFC Over Ether mode); if the IP address of the second device is different from the IP address of the first device, that is, the second device and the first device are not connected to the same local area network, the first device determines that the communication mode is the second mode (such as SFC Over IP mode).

[0181] S1007: The second device establishes a corresponding communication connection with the first device based on the communication mode determined through negotiation.

[0182] As an example, after the communication mode is determined through negotiation, the second device can send a synchronize sequence numbers (SYN) message to the first device; correspondingly, after receiving the SYN message, the first device can reply with an acknowledgment message (ACK message) to the second device. At this point, the communication connection between the second device and the first device is established. Afterwards, the first device and the second device can transmit data based on the communication mode determined through negotiation. For example, the first device and the second device can read / receive and write / send data through Read / Recv and Write / Send, and encapsulate the data according to the negotiated communication mode when sending, and decapsulate the data according to the negotiated communication mode when receiving.

[0183] As an example, after the first device and the second device end communication, the first device or the second device can call the close interface to trigger the sending of a Fin message to the other device. Correspondingly, the other device can initiate a link removal process after receiving the Fin message to disconnect the communication connection between the two.

[0184] It can be understood that the embodiment of the present application relies on the mechanism of the SFC protocol to encapsulate the network layer header on demand, and can negotiate with the receiving end whether to carry the network layer header in subsequent data transmission when establishing a connection. For example, if the receiving end and the sending end are connected to the same local area network, the two parties can negotiate to a communication mode that does not carry the network layer header (i.e., the first mode) to maximize the transmission performance; otherwise, the two parties can negotiate to a communication mode that carries the network layer header (i.e., the second mode) to ensure the normal communication between devices. The above-mentioned method of the embodiment of the present application, which adopts a suitable communication mode for communication according to the specific circumstances of the communication business, is not only compatible with data transmission between different local area networks, but also can be used in the communication scenario between devices in the same local area network. While ensuring the normal communication between devices, it can save resources to the maximum extent, reduce communication delays, achieve efficient communication between devices, and improve user experience.

[0185] It should be noted that the above embodiments of the present application only take the communication protocol of the network layer as the IP protocol, such as IPv4 or IPv6, as an example, but the embodiments of the present application are not limited to the specific protocol of the network layer. For example, the communication protocol of the network layer may also be other three-layer protocols that may continue to evolve in the future.

[0186] It should be understood that the various schemes of the embodiments of the present application can be reasonably combined and used, and the explanations or descriptions of the various terms appearing in the embodiments can be referenced or explained with each other in the various embodiments, without limitation to this.

[0187] It should also be understood that in the various embodiments of the present application, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0188] It is understandable that, in order to implement the functions of any of the above-mentioned embodiments, the electronic device (such as the first device or the second device) includes a hardware structure and / or software module corresponding to the execution of each function. It should be easily appreciated by those skilled in the art that, in combination with the units and algorithm steps of each example described in the embodiments disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0189] The embodiment of the present application can divide the electronic device (such as the first device or the second device) into functional modules. For example, each functional module can be divided corresponding to each function, or two or more functions can be integrated into one processing module. The above-mentioned integrated module can be implemented in the form of hardware or in the form of software functional modules. It should be noted that the division of modules in the embodiment of the present application is schematic and is only a logical functional division. There may be other division methods in actual implementation.

[0190] As an example, as shown in Figure 11, the electronic device (such as the first device or the second device) may include a transceiver unit 1110, a processing unit 1120, and a storage unit 1130 according to the division of functional modules. Among them, the transceiver unit 1110 is used to send and receive information (such as a link establishment request, first data, second data, etc.), the processing unit 1120 is used to determine the communication mode, data encapsulation, data decapsulation, resource allocation, etc., and the storage unit 1130 is used to store computer program instructions, data created during the use of the electronic device, etc. Of course, in some examples, the electronic device may also include other units, such as a display unit, etc., which are not specifically limited in the embodiments of the present application.

[0191] It should also be understood that each module in an electronic device (such as the first device or the second device) can be implemented in software and / or hardware, without specific limitation. In other words, the electronic device (such as the first device or the second device) is presented in the form of functional modules. The "module" here can refer to an application-specific integrated circuit (ASIC), a circuit, a processor and memory that executes one or more software or firmware programs, an integrated logic circuit, and / or other devices that can provide the above-mentioned functions.

[0192] In an optional manner, when data transmission is implemented using software, it can be implemented in whole or in part in the form of a computer program product. 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 application is implemented 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 can be accessed by a computer or a data storage device such as a server or data center that includes one or more available media. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a digital video disk (DVD)), or a semiconductor medium (e.g., a solid state disk (SSD)).

[0193] The steps of the method or algorithm described in conjunction with the embodiments of the present application can be implemented in hardware or by a processor executing software instructions. The software instructions can be composed of corresponding software modules, and the software modules can be stored in RAM memory, flash memory, ROM memory, EPROM memory, EEPROM memory, registers, hard disk, mobile hard disk, CD-ROM or any other form of storage medium well known in the art. An exemplary storage medium is coupled to the processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be an integral part of the processor. The processor and the storage medium can be located in an ASIC. In addition, the ASIC can be located in an electronic device (such as the first device or the second device). Of course, the processor and the storage medium can also exist as discrete components.

[0194] Through the description of the above implementation methods, technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

Claims

1. A communication method, characterized in that: Applied to a first device, the method includes: Get application data of the application layer; Negotiate with the second device to determine a communication mode when the first device communicates with the second device, the communication mode comprising a first mode and a second mode, wherein the first mode is a communication mode in which network layer encapsulation and decapsulation are not performed, and the second mode is a communication mode in which network layer encapsulation and decapsulation are performed; The application data is sent to the second device based on the determined communication mode.

2. The method according to claim 1, characterized in that The communication mode determined through negotiation with the second device is the first mode, and sending the application data to the second device based on the determined communication mode includes: Based on the first mode, the application data is encapsulated in turn through the transport layer and the data link layer to obtain first data; The first data is sent to the second device.

3. The method according to claim 1, characterized in that The communication mode determined through negotiation with the second device is the second mode, and sending the application data to the second device based on the determined communication mode includes: Based on the second mode, the application data is encapsulated through the transport layer, the network layer and the data link layer in sequence to obtain second data; The second data is sent to the second device.

4. The method according to claim 3, characterized in that The second data includes an Internet Protocol IP header.

5. The method according to any one of claims 1 to 4, characterized in that The negotiating with the second device to determine a communication mode when the first device communicates with the second device includes: When the communication scenario is the first scenario, sending identification information of the first mode to the second device to negotiate with the second device that the first device uses the first mode when communicating with the second device; or, When the communication scenario is the second scenario, identification information of the second mode is sent to the second device, so as to negotiate with the second device that the second mode is adopted when the first device communicates with the second device.

6. The method according to claim 5, characterized in that The first scenario is a scenario of communication between devices in the same local area network, and the second scenario is a scenario of communication between devices in different local area networks.

7. The method according to claim 5 or 6, characterized in that: The method further comprises: When the network layer address of the second device is the same as the network layer address of the first device, determining that the communication scenario is the first scenario; or, When the network layer address of the second device is different from the network layer address of the first device, the communication scenario is determined to be the second scenario.

8. The method according to any one of claims 1 to 4, characterized in that The negotiating with the second device to determine a communication mode when the first device communicates with the second device includes: instructing the second device to determine a communication mode when the first device communicates with the second device; Receive identification information of the communication mode determined by the second device.

9. The method according to any one of claims 1 to 8, characterized in that Both the first mode and the second mode are communication modes that comply with the smart flow control protocol SFC.

10. The method according to claim 9, characterized in that The SFC is a communication protocol in the TCP / IP protocol suite.

11. A communication method, characterized in that: Applied to the second device, the method includes: receiving identification information of a communication mode from a first device; According to the identification information, processing the data from the first device based on the corresponding communication mode; The communication mode includes a first mode and a second mode, wherein the first mode is a communication mode in which network layer encapsulation and decapsulation are not performed, and the second mode is a communication mode in which network layer encapsulation and decapsulation are performed.

12. The method according to claim 11, characterized in that The identification information is identification information of the first mode, and the processing of data from the first device based on the corresponding communication mode according to the identification information includes: The first data from the first device is decapsulated sequentially through the data link layer and the transport layer based on the first mode.

13. The method according to claim 12, characterized in that The second device and the first device are connected to the same local area network.

14. The method according to claim 11, characterized in that The identification information is identification information of the second mode, and processing the data from the first device based on the corresponding communication mode according to the identification information includes: The second data from the first device is decapsulated sequentially through the data link layer, the network layer and the transport layer based on the second mode.

15. The method according to claim 14, characterized in that The second data includes an IP header.

16. The method according to claim 14 or 15, characterized in that The second device and the first device are connected to different local area networks.

17. The method according to any one of claims 11 to 16, characterized in that Both the first mode and the second mode are communication modes compliant with SFC.

18. The method according to claim 17, characterized in that The SFC is a communication protocol in the TCP / IP protocol suite.

19. An electronic device, characterized in that: The electronic device comprises: transceiver, used to receive or send signals; a memory for storing computer program instructions; A processor, configured to execute the computer program instructions so that the electronic device implements the communication method as described in any one of claims 1 to 10.

20. An electronic device, characterized in that: The electronic device comprises: transceiver, used to receive or send signals; a memory for storing computer program instructions; A processor is used to run the computer program instructions so that the electronic device implements the communication method as described in any one of claims 11-18.

21. A communication system, characterized in that: The communication system comprises: the electronic device according to claim 19 and the electronic device according to claim 20.

22. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer program instructions, and when the computer program instructions are executed by the processing circuit, the method according to any one of claims 1-10 or 11-18 is implemented.

23. A computer program product comprising instructions, characterized in that When the computer program product is run on a computer, the computer is caused to execute the method according to any one of claims 1 to 10 or 11 to 18.

24. A chip system, characterized in that: The chip system includes a processing circuit and a storage medium, wherein the storage medium stores computer program instructions; when the computer program instructions are executed by the processing circuit, the method as described in any one of claims 1-10 or 11-18 is implemented.

Citation Information

Patent Citations

  • Method and device for sending data and method and device for receiving data

    CN101557386A

  • System keep-alive method based on Ethernet multicast

    CN102098218A

  • Data transmission method and device

    CN108111523A

  • Network data processing method and device, and computer readable storage medium

    CN109218388A

  • A service data forwarding method based on an SFC and an Overlay system

    CN109922002A

Cited By

  • Communication system and method based on hybrid networking, communication node and electronic equipment

    CN120416857A