Communication method, device and communication system
By selecting whether to encapsulate the IP header according to needs when communicating within the LAN, the resource waste and delay problems caused by redundant IP headers in TCP/IP are solved, and efficient communication between devices is achieved.
Patent Information
- Application Number
- CN202310576532.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-19
- Publication Date
- 2024-11-22
AI Technical Summary
During communication within the LAN, the data frames in the Transmission Control Protocol/Internet Protocol (TCP/IP) carry redundant IP headers, resulting in large processing overhead, increased latency and wasted resources.
According to the communication service situation, choose whether to encapsulate and decapsulate the network layer. If the network layer does not need to participate, do not carry the IP header to improve the transmission efficiency of data frames; if the network layer is required to participate, carry the IP header to ensure the normal communication.
Maximize the saving of communication resources and processing resources, reduce communication delay, and achieve efficient communication between devices.
Smart Images

Figure CN119011706A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communication technology, and in particular to communication methods, devices and systems. Background Technology
[0002] The Transmission Control Protocol / Internet Protocol (TCP / IP), a protocol suite composed of protocols such as 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 on the same network or different networks.
[0003] When communicating based on TCP / IP, data frames are encapsulated in layers according to the protocol, and each layer has its own responsibilities. For example, the data link layer (layer 2) is usually responsible for communication addressing within a 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 service processes within the same device. The cooperation of multiple layers can complete the communication task.
[0004] However, in some communication scenarios, communication services are limited to the same local area network (LAN). In such cases, the participation of the network layer (Layer 3) is unnecessary, and therefore, network layer (Layer 3) information (such as the IP header) becomes redundant. If the IP header is still carried during LAN communication, the processing overhead will increase significantly, for example, processing the IP header requires additional latency and transmission resource overhead. Summary of the Invention
[0005] This application provides a communication method, device, and system that can adopt an appropriate communication mode to communicate according to the specific circumstances of the communication service, thereby maximizing the saving of communication and processing resources, reducing communication latency, and achieving efficient communication between devices.
[0006] To achieve the above objectives, this application adopts the following technical solution:
[0007] In a first aspect, a communication method is provided, which can be applied to a sending device, such as a first device. The method includes: the first device acquiring application data at the application layer; the first device 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 being a communication mode without network layer encapsulation and decapsulation, and the second mode being a communication mode with network layer encapsulation and decapsulation; and the first device sending application data to the second device based on the determined communication mode.
[0008] For example, network layer communication protocols include the IP protocol, such as, but not limited to, Internet Protocol version 4 (IPv4) and Internet Protocol version 6 (IPv6). The aforementioned network layer encapsulation refers to encapsulating the IP header before the application data; the aforementioned lack of network layer encapsulation refers to not encapsulating the IP header before the application data; the aforementioned network layer decapsulation refers to removing the IP header from the data frame through the network layer; the aforementioned lack of network layer decapsulation refers to not removing the IP header through the network layer.
[0009] In this application, the IP header is sometimes referred to as "IP header" or "IP header" etc., and the specific terminology is not limited in this application embodiment.
[0010] The solution provided in the first aspect allows the first device to adopt an appropriate communication mode based on the specific circumstances of the communication service when it needs to send data. For example, when the communication service does not require network layer participation, the network layer header (such as the IP header) is not included in the data frame. This reduces the processing load and latency caused by the IP header, such as encapsulation, firewall processing, and decapsulation, and significantly increases the effective payload of the data frame, thereby improving the transmission efficiency of the data frame. This maximizes the saving of communication and processing resources while reducing communication latency. Alternatively, when the communication service requires network layer participation, the IP header is included in the data frame to ensure normal communication between devices. This on-demand encapsulation strategy of the network layer header can maximize the saving of communication and processing resources while reducing communication latency, achieving efficient communication between devices.
[0011] As one possible implementation, the communication mode negotiated and determined by the first device and the second device is a first mode. The first device sends application data to the second device based on this determined communication mode, including: the first device encapsulating the application data sequentially through the transport layer and data link layer based on the first mode to obtain first data; and the first device sending the first data to the second device. Based on this, the first device can avoid encapsulating the application data at the network layer when the communication service does not require network layer involvement, i.e., it does not carry a network layer header in the data frame. This reduces the processing load and latency caused by redundant network layer headers, such as encapsulation processing, firewall processing, and decapsulation processing, and significantly increases the effective payload of the data frame, thereby improving the transmission efficiency of the data frame. This maximizes the saving of communication and processing resources while reducing communication latency.
[0012] For example, taking the IP protocol as the network layer communication protocol, the first data mentioned above does not include an IP header because it has not been encapsulated by the network layer. Therefore, the receiving device (i.e., the second device) does not need to perform network layer decapsulation or network layer firewall processing on the first data, reducing processing load and latency, and improving transmission efficiency.
[0013] As one possible implementation, the communication mode negotiated and determined by the first device and the second device is a second mode. The first device sends application data to the second device based on this determined communication mode, including: the first device encapsulating the application data sequentially through the transport layer, network layer, and data link layer according to 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 encapsulate the application data at the network layer when the communication service requires network layer participation, i.e., carrying a network layer header in the data frame, to ensure normal communication between devices.
[0014] For example, taking the IP protocol as the communication protocol of the network layer, the second data mentioned above includes an IP header because it is a data frame encapsulated by the network layer.
[0015] For example, the IP header may include a source IP address to indicate the IP address of the sending device, and a destination 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 successfully transmitted to the receiving device corresponding to the destination IP address, such as the second device.
[0016] As one possible implementation, the first device and the second device negotiate to determine the communication mode when communicating with each other, 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 communicating with each other; 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 communicating with each other.
[0017] For example, the first scenario described above is a communication scenario between devices within the same local area network (LAN), while the second scenario is a communication scenario between devices within different LANs. It can be 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 does. Based on this, the first device decides whether to encapsulate the network layer header as needed according to the actual communication scenario. This can maximize the saving of communication and processing resources while reducing communication latency, thus achieving efficient communication between devices, while ensuring normal communication between them.
[0018] As one 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 the communication scenario as a 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 the communication scenario as a 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 address of the devices, providing a reliable reference for subsequent on-demand encapsulation of the network layer header.
[0019] As one possible implementation, the first device and the second device negotiate and determine the communication mode when communicating, including: the first device instructing the second device to determine the communication mode when communicating; and the first device receiving the identification information of the communication mode determined by the second device. This application does not limit the executing entity for deciding the communication mode; both communicating parties can decide on the specific communication mode based on the actual situation. Therefore, this solution can adapt to multiple communication protocols and has high flexibility.
[0020] As one possible implementation, both the first and second modes described above follow the communication mode of the Smart Flow Control (SFC) protocol. Based on this, the above solution can be adapted to the SFC bearer protocol, which is tailored for the HarmonyOS distributed scenario. Of course, this application does not limit the communication protocol applicable to the above-described on-demand encapsulation of the network layer header; this solution can also be applied to other communication protocols.
[0021] For example, the SFC described above can be a communication protocol within the TCP / IP protocol suite. Of course, this application is not limited to this; for instance, the SFC can also be a communication protocol independent of the TCP / IP protocol suite.
[0022] Secondly, a communication method is provided, which can be applied to a receiving device, such as a second device. The method includes: the second device receiving identification information of a communication mode from a first device; the second device processing data from the first device based on the received identification information and the corresponding communication mode; wherein the communication mode includes a first mode and a second mode, wherein the first mode is a communication mode without network layer encapsulation and decapsulation, and the second mode is a communication mode with network layer encapsulation and decapsulation.
[0023] The solution provided in the second aspect above allows the second device to adopt an appropriate communication mode based on the negotiation results with the first device, according to the specific circumstances of the communication service. For example, when the communication service does not require network layer participation, the network layer header (such as the IP header) is not carried in the data frame. This reduces the processing load and latency caused by the IP header, such as encapsulation processing, firewall processing, and decapsulation processing. Furthermore, it significantly increases the effective payload of the data frame, thereby improving the transmission efficiency of the data frame and minimizing communication latency while maximizing the conservation of communication and processing resources. Alternatively, when the communication service requires network layer participation, the IP header is carried in the data frame to ensure normal communication between devices. This on-demand encapsulation strategy of the network layer header can maximize the conservation of communication and processing resources while reducing communication latency, achieving efficient communication between devices.
[0024] As one possible implementation, the aforementioned identification information is the identification information of the first mode. The second device processes the data from the first device based on the received identification information and the corresponding communication mode, including: the second device decapsulating the first data from the first device sequentially through the data link layer and the transport layer based on the first mode.
[0025] For example, taking the IP protocol as the network layer communication protocol, the first data mentioned above does not include an IP header because it has not been encapsulated by 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, reducing processing load and latency, and improving transmission efficiency.
[0026] For example, when the first device is connected to the second device on the same local area network, it can send identification information of the first mode to the second device. It is understood that communication between devices within the same local area network does not require the involvement of the network layer. Based on this, the first device can avoid encapsulating the network layer header before the application data in communication scenarios between devices within the same local area network. This allows for maximum saving of communication and processing resources while minimizing communication latency, thus achieving efficient communication between devices, while ensuring normal communication between them.
[0027] As one possible implementation, the aforementioned identification information is the identification information of the second mode. The second device processes the data from the first device based on the identification information and the corresponding communication mode, including: the second device decapsulating the second data from the first device sequentially through the data link layer, network layer and transport layer based on the second mode.
[0028] For example, taking the IP protocol as the communication protocol of the network layer, the second data mentioned above includes an IP header because it is a data frame encapsulated by the network layer.
[0029] For example, the first device can send identification information of the second mode to the second device when the second device is 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 can encapsulate the network layer header before the application data in the scenario of communication between devices in different local area networks to ensure the normal operation of communication between devices.
[0030] As one possible implementation, both the first and second modes described above follow the SFC communication mode. Based on this, the above solution can be adapted to the SFC bearer protocol, which is tailored for the HarmonyOS distributed scenario. Of course, this application does not limit the communication protocol applicable to the above-described on-demand encapsulation of the network layer header; this solution can also be applied to other communication protocols.
[0031] For example, the SFC described above can be a communication protocol within the TCP / IP protocol suite. Of course, this application is not limited to this; for instance, the SFC can also be a communication protocol independent of the TCP / IP protocol suite.
[0032] Thirdly, an electronic device is provided, which may be a transmitting device, such as a first device. The electronic device includes: a data acquisition unit for acquiring application data at the 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 being a communication mode without network layer encapsulation and decapsulation, and the second mode being a communication mode with network layer encapsulation and decapsulation; and a transceiver unit for sending application data to the second device based on the determined communication mode.
[0033] For details regarding 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 in the first aspect; further details will not be provided here.
[0034] Fourthly, an electronic device is provided, which may be a receiving device, such as a second device. The electronic device includes: a transceiver unit for receiving identification information of a communication mode from a first device; and a processing unit for processing data from the first device based on the received identification information and the corresponding communication mode. The communication mode includes a first mode and a second mode, wherein the first mode is a communication mode without network layer encapsulation and decapsulation, and the second mode is a communication mode with network layer encapsulation and decapsulation.
[0035] For details regarding 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 in the second aspect; it will not be elaborated here.
[0036] Fifthly, an electronic device is provided, comprising: a transceiver for receiving or transmitting signals; a memory for storing computer program instructions; and a processor for executing the computer program instructions to support the electronic device in implementing the methods of any possible implementation of the first aspect.
[0037] In a sixth aspect, an electronic device is provided, comprising: a transceiver for receiving or transmitting signals; a memory for storing computer program instructions; and a processor for executing the computer program instructions to support the electronic device in implementing the methods of any possible implementation of the second aspect.
[0038] A seventh aspect provides a communication system comprising electronic devices as described in any possible implementation of the third or fifth aspect, and electronic devices as described in any possible implementation of the fourth or sixth aspect.
[0039] Eighthly, a computer-readable storage medium is provided that stores computer program instructions thereon, which, when executed by a processor, implement the method as in any possible implementation of the first or second aspect.
[0040] Ninth aspect, a computer program product containing instructions is provided, which, when run on a computer, causes the computer to implement the method as in any possible implementation of the first or second aspect.
[0041] In a tenth aspect, a chip system is provided, comprising processing circuitry and a storage medium storing computer program instructions; when executed by the processor, the computer program instructions implement the method as described in any possible implementation of the first or second aspect. The chip system may be composed of chips or may include chips and other discrete devices. Attached Figure Description
[0042] Figure 1 Example diagrams of three common TCP / IP layered models provided for embodiments of this application;
[0043] Figure 2 A schematic diagram illustrating the process by which the TCP / IP protocol stack, as provided in this embodiment, encapsulates application data layer by layer.
[0044] Figure 3 This is a schematic diagram of a smart home communication scenario provided in an embodiment of this application;
[0045] Figure 4 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of this application;
[0046] Figure 5 Flowcharts of two communication methods provided in embodiments of this application;
[0047] Figure 6 This application provides a schematic diagram of a data encapsulation and decapsulation process under a first mode.
[0048] Figure 7 This application provides a schematic diagram of a data encapsulation and decapsulation process in a second mode, as illustrated in an embodiment of the present application.
[0049] Figure 8 A schematic diagram of the software architecture of an electronic device provided in an embodiment of this application;
[0050] Figure 9 This application provides schematic diagrams illustrating the structure of data frames under two communication modes in its embodiments.
[0051] Figure 10 This is a schematic diagram of a communication mode negotiation process provided in an embodiment of this application;
[0052] Figure 11 This is a structural block diagram of an electronic device provided in an embodiment of this application. Detailed Implementation
[0053] The technical solutions of the embodiments of this application will be described below with reference to the accompanying drawings. In the description of the embodiments of this application, unless otherwise stated, " / " means "or," for example, A / B can mean A or B; "and / or" in this text is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Furthermore, in the description of the embodiments of this application, "multiple" refers to two or more than two.
[0054] In the following text, the terms "first," "second," etc., are used only to distinguish different descriptive objects and do not limit the position, order, priority, quantity, or content of the described objects. For example, if the described object is a "field," then the ordinal numbers before "field" in "first field" and "second field" do not limit the position or order of the "fields." "First" and "second" do not limit whether the "fields" they modify are in the same message, nor do they restrict the order of "first field" and "second field." Similarly, if the described object is a "level," then the ordinal numbers before "level" in "first level" and "second level" do not limit the priority of the "levels." Furthermore, the quantity of described objects is not limited by ordinal numbers and can be one or more; for example, in "first device," the number of "devices" can be one or more. In addition, objects modified by different prefixes can be the same or different. For example, if the described object is "device," then "first device" and "second device" can be devices of the same type or different types. Similarly, if the described object is "information," then "first information" and "second information" can be information with the same content or information with different content. In summary, the use of ordinal numbers and other prefixes used to distinguish the described objects in the embodiments of this application does not constitute a limitation on the described objects. The description of the described objects is given in the claims or the context of the embodiments, and the use of such prefixes should not constitute an unnecessary limitation.
[0055] Furthermore, in the embodiments of this application, "connection" can be a direct connection or an indirect connection; in addition, it can refer to an electrical connection or a communication connection; for example, the connection of two electrical components A and B can refer to A and B being directly connected, or it can refer to A and B being indirectly connected through other electrical components or connection media, or it can refer to A and B being indirectly connected through other communication devices or communication media, as long as it enables communication between A and B.
[0056] To facilitate understanding, the following is a brief introduction to the TCP / IP layered model.
[0057] For example, please refer to Figure 1 , Figure 1The diagram illustrates three common TCP / IP layered models provided in embodiments of this application. For example... Figure 1 As shown, TCP / IP layered models include the International Organization for Standardization (ISO) seven-layer model, the TCP / IP four-layer model, and the TCP / IP five-layer model.
[0058] The ISO seven-layer model, from top to bottom, includes the application layer, presentation layer, session layer, transport layer, network layer, data link layer, and physical layer. The application layer primarily provides application interfaces and various network services to upper-layer users. The presentation layer primarily provides 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 reliable and transparent end-to-end data transmission services for upper-layer protocols, including error checking and flow control. The network layer is primarily used for routing and addressing, such as transmitting data to a destination address; the IP protocol resides in the network layer. The data link layer is primarily used to establish and manage logical connections between nodes, perform hardware address addressing, and perform error detection. For example, it encapsulates bitstream data from the physical layer into data frame format for transmission to the upper layer, or decapsulates data frames from the upper layer into bitstream data for transmission to the physical layer. The physical layer, as the channel for data transmission, is mainly used to provide a physical connection to the data link layer using transmission media (such as twisted pair, cable, etc.) to achieve transparent transmission of bit streams.
[0059] Both the TCP / IP four-layer and five-layer models 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 functions similarly to the application layer, presentation layer, and session layer in the ISO seven-layer model, and the network interface layer in the TCP / IP four-layer model functions similarly to the data link layer and physical layer in the ISO seven-layer model. Similarly, 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 functions similarly to the application layer, presentation layer, and session layer in the ISO seven-layer model.
[0060] Taking the TCP / IP five-layer model as an example, when an application needs to transmit data, the application sends the application data into the protocol stack. The protocol stack encapsulates the application data layer by layer and then transmits it to the receiving end. The receiving end deconstructs the data layer by layer from the bottom layer until it obtains the application data.
[0061] When the TCP / IP protocol stack encapsulates application data layer by layer, for example, such as Figure 2 As shown, the application layer can add an APP header before the application data, sending the data segment "APP header + application data" down to the transport layer. The transport layer can add a TCP header before the data segment "APP header + application data," sending 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," sending 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," sending the resulting data frame "Ethernet header + IP header + TCP header + APP header + application data" to the receiving end in binary form through the physical layer. Correspondingly, during layer-by-layer decomposition at the receiving end, the receiving end can remove the Ethernet header, IP header, TCP header, and APP header from the data frame layer by layer to ultimately obtain the application data.
[0062] We know that the network layer is typically responsible for addressing between networks. For example, the network layer can support addressing between networks by adding an IP header before data segments. For instance, the IP header may include 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, so that the devices know where the application data comes from and where it is to be sent.
[0063] However, in many communication scenarios, communication services are limited to the same local area network (LAN) and do not involve network addressing. For example, in smart office communication, smart home communication, or smart medical communication scenarios, the communication architecture is typically a distributed architecture within the same LAN, where communication between devices occurs within the same LAN. Figure 3 In the smart home communication scenario shown, smart home devices such as air purifiers, large-screen devices in bedroom 1, air conditioners, speakers, and smart lights in bedroom 1, large-screen devices in bedroom 2, air conditioners in bedroom 2, large-screen devices in the living room, refrigerators, tablets, mobile phones, microwave ovens, bread makers, dishwashers, and robot vacuum cleaners are all within the router's coverage area and are all on the same local area network (LAN). Communication between these smart home devices takes place within this same LAN.
[0064] Therefore, if communication between devices within the same local area network is still handled using the conventional TCP / IP mechanism, the IP header is completely redundant, and the processing overhead of the redundant IP header is very large. For example, the IP header requires additional encapsulation, firewall processing, decapsulation, and many other rule-chain related processes, which will cause additional processing latency. In addition, the IP header consists of at least 20 bytes and can be as large as 60 bytes, thus reducing the effective payload of the data frame and thereby increasing the transmission efficiency of the data frame. If calculated based on a maximum transmission unit (MTU) of 1500 bytes, the transmission bandwidth will decrease by 2% to 4%.
[0065] To address the shortcomings of the TCP / IP mechanism in the aforementioned communication scenarios, this application provides a communication method. Based on this method, devices can adopt appropriate communication modes according to 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 may not be included in the data frame; when the communication service is between devices across networks, the IP header is included in the data frame. This maximizes the saving of communication and processing resources while reducing communication latency, achieving efficient communication between devices.
[0066] The communication method described in this application embodiment can be applied to the communication process between electronic devices, such as the communication process between a first device and a second device.
[0067] The electronic device (such as the first device or the second device) can be a fixed terminal, such as a laptop, desktop computer, or smart home device. The electronic device (such as the first device or the second device) can also be a mobile terminal, such as a mobile phone or tablet. A mobile terminal can also be referred to as User Equipment (UE), access terminal, user unit, user station, mobile station, mobile station, remote station, remote terminal, mobile device, user terminal, terminal, wireless communication equipment, user agent, or user device. Mobile terminals can be stations (STAION, ST) in WLANs, cellular phones, cordless phones, Session Initiation Protocol (SIP) phones, Wireless Local Loop (WLL) stations, Personal Digital Assistant (PDA) devices, handheld devices with wireless communication capabilities, computing devices or other processing devices connected to a wireless modem, in-vehicle devices, vehicle networking terminals, computers, portable multimedia players (PMPs), augmented reality (AR) / virtual reality (VR) devices, cameras, motion-sensing game consoles in human-computer interaction scenarios, laptop computers, handheld communication devices, handheld computing devices, satellite wireless devices, wireless modem cards, set-top boxes (STBs), customer premises equipment (CPEs), and / or other devices used for communication over wireless systems, as well as mobile terminals in next-generation communication systems such as 5G networks or mobile terminals in future evolved Public Land Mobile Network (PLMN) networks. The mobile terminal can also be a wearable device. Wearable devices, also known as wearable smart devices, are a general term for devices that utilize wearable technology to intelligently design and develop everyday wearables, such as glasses, bracelets, gloves, watches, clothing, and shoes. Wearable devices are portable devices that are worn directly on the body or integrated into the user's clothing or accessories. Wearable devices are not merely hardware devices; they achieve powerful functions through software support, data interaction, and cloud interaction. Alternatively, the electronic device can be other types or structures of electronic devices, which are not limited in the embodiments of this application.
[0068] For example, please refer to Figure 4 , Figure 4This illustration shows a hardware structure diagram of an electronic device according to an embodiment of this application. The electronic device can be either a first device or a second device.
[0069] like Figure 4 As shown, 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.
[0070] It is understood that the structures illustrated in the embodiments of the present invention do not constitute a specific limitation on the electronic device. In other embodiments of this application, the electronic device may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0071] 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), etc. Different processing units may be independent devices or integrated into one or more processors.
[0072] The processor 410 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 410 is a cache memory. This memory can store instructions or data that the processor 410 has just used or that are used repeatedly. If the processor 410 needs to use the instruction or data again, it can retrieve it directly from the memory. This avoids repeated accesses, reduces the waiting time of the processor 410, and thus improves the efficiency of the system.
[0073] In some embodiments, the processor 410 may include one or more interfaces. 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, etc.
[0074] It should be understood that the interface connection relationships between the modules illustrated in the embodiments of this application are merely illustrative and do not constitute a limitation on the structure of the electronic device. In other embodiments of this application, the electronic device may also employ different interface connection methods or combinations of multiple interface connection methods as described in the above embodiments.
[0075] The charging management module 440 receives charging input from the charger. The power management module 441 connects to 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 power the processor 410, internal memory 421, universal serial bus (USB) interface 430, mobile communication module 450, wireless communication module 460, audio module 470, display screen 480, etc.
[0076] The wireless communication function of electronic devices can be realized through antenna 1, antenna 2, mobile communication module 450, wireless communication module 460, modem processor and baseband processor, etc.
[0077] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in the electronic device can be used to cover one or more 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 some other embodiments, the antennas can be used in conjunction with a tuning switch.
[0078] The mobile communication module 450 can provide solutions for wireless communication applications including 2G / 3G / 4G / 5G in electronic devices. The mobile communication module 450 may include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc. The mobile communication module 450 can receive electromagnetic waves via antenna 1, and perform filtering, amplification, and other processing on the received electromagnetic waves before transmitting them to a modem processor for demodulation. The mobile communication module 450 can also amplify the signal modulated by the modem processor and convert it into electromagnetic waves for radiation via antenna 1. In some embodiments, at least some functional modules of the mobile communication module 450 may be housed in processor 410. In some embodiments, at least some functional modules of the mobile communication module 450 and at least some modules of the processor 410 may be housed in the same device.
[0079] The modem processor may include a modulator and a demodulator. The modulator modulates the low-frequency baseband signal to be transmitted into a mid-to-high frequency signal. The demodulator demodulates 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 processing by the baseband processor, the low-frequency baseband signal is transmitted to the application processor. The application processor outputs an audio signal through an audio module (not limited to a speaker, receiver, etc.) or displays an image or video through the display screen 480. In some embodiments, the modem processor may be a separate device. In other embodiments, the modem processor may be independent of the processor 410 and housed within the same device as the mobile communication module 450 or other functional modules.
[0080] The wireless communication module 460 can provide solutions for wireless communication applications in electronic devices, including wireless local area networks (WLAN) (such as WiFi), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), and infrared (IR). The wireless communication module 460 can be one or more devices integrating at least one communication processing module. The wireless communication module 460 receives electromagnetic waves via antenna 2, performs frequency modulation and filtering of the electromagnetic wave signal, and sends the processed signal to processor 410. The wireless communication module 460 can also receive signals to be transmitted from processor 410, perform frequency modulation and amplification, and convert them into electromagnetic waves for radiation via antenna 2.
[0081] 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, enabling the electronic device to communicate with networks and other devices via wireless communication technology. The wireless communication technology 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 technologies. 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 Systems (SBAS).
[0082] Electronic devices implement display functions through a GPU, a display screen 480, and an application processor. The GPU is a microprocessor for image processing, connecting the display screen 480 and the application processor. The GPU is used to perform mathematical and geometric calculations and for graphics rendering. The processor 410 may include one or more GPUs, which execute program instructions to generate or modify display information.
[0083] Display screen 480 is used to display images, videos, etc. Display screen 480 includes a display panel. The display panel may 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 minimized display, a microLED, a micro-OLED, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device may include one or N displays 494, where N is a positive integer greater than 1.
[0084] The external storage 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 through the external storage interface 420 to perform data storage functions. For example, images, music, and video files can be saved on the external memory card.
[0085] Internal memory 421 can be used to store computer executable program code. Exemplarily, computer programs may include operating system programs and application programs. The operating system may include, but is not limited to, […]. ( ), ( ), , , ,apple , ( ), ( The processor 410 executes various functional applications and data processing of the electronic device by running instructions stored in the internal memory 421. The internal memory 421 may include a program storage area and a data storage area. The program storage area may store the operating system, applications required for at least one function, etc. The data storage area may store data created during the use of the electronic device. Furthermore, the internal memory 421 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc. The processor 410 executes various functional applications and data processing of the electronic device by running instructions stored in the internal memory 421 and / or instructions stored in memory located within the processor.
[0086] For the specific working principles and functions of other modules, such as audio module 470, please refer to the descriptions in conventional technologies. The embodiments in this application will not be repeated here.
[0087] It is understood that this application Figure 4 The illustrated structure does not constitute a specific limitation on the electronic device. In other embodiments of this application, the electronic device may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. 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 also include one or more hardware modules such as a speaker, receiver, microphone, headphone jack, sensor, button, motor, indicator, and camera.
[0088] The communication method provided in this application will be described in detail below with reference to specific embodiments. This communication method can be applied between any two electronic devices (e.g., a first device and a second device). The first device can be a sender (or client), and the second device can be a receiver (or server); or the first device can be a receiver (or server), and the second device can be a sender (or client). The following embodiments use the first device as the sender and the second device as the receiver to illustrate the communication method provided in this application.
[0089] Please refer to Figure 5 , Figure 5 Flowcharts of two communication methods provided in embodiments of this application are shown. Figure 5 (a) and Figure 5 As shown in (b) of this application embodiment, a communication method includes S501:
[0090] S501: When the first device needs to send data to the second device, it determines whether the second device and the first device are connected to the same local area network.
[0091] The aforementioned data transmission requirement may include, but is not limited to, the requirement to transmit business data (such as application data).
[0092] One possible implementation is that the first device can determine whether the second device and the first device are connected to the same local area network (LAN) by comparing the network layer address (e.g., IP address) of the second device with its own network layer address (e.g., IP address). It can be understood that if the second device and the first device are connected to the same LAN, their IP addresses will be the same; if they are connected to different LANs, their IP addresses will be different. Based on this, the first device can successfully determine whether the second device is connected to the same LAN by comparing its own IP address with that of the second device.
[0093] IP addresses are used to identify different devices in a network in communication protocols. IP addresses can include, but are not limited to, Internet Protocol version 4 (IPv4) addresses and Internet Protocol version 6 (IPv6) addresses.
[0094] As an example, the network layer address (such as IP address) of the second device is obtained from the network side by the application layer when it receives a service request.
[0095] like Figure 5 As shown in (a), if the second device and the first device are connected to the same local area network, the communication method provided in this application embodiment further includes S502a-S507a:
[0096] S502a: The first device sends a communication mode to the second device, which is the first mode.
[0097] For example, the first device can send identification information of the first mode to the second device.
[0098] For the sending end (i.e., the first device), the first mode refers to a communication mode in which the data to be transmitted is not encapsulated at the network layer during communication; for the receiving end (i.e., the second device), the first mode refers to a communication mode in which the received data is not decapsulated at the network layer during communication.
[0099] In this embodiment of the application, the first mode sent by the first device to the second device is used to negotiate with the second device to use the first mode for communication, or to notify the second device that the first device prefers to use the first mode to communicate with the second device, or to instruct the second device that the first device is about to use the first mode to communicate with the second device, or to instruct the second device to use the first mode to communicate with the first device.
[0100] Before the first device executes S502a, the first device may have determined that the second device supports the first mode of communication. 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 use the first mode for communication, or it may be used to notify the second device that the first device is inclined to use the first mode to communicate with the second device, or it may be used to instruct the second device that the first device is about to use the first mode to communicate with the second device, or it may be used to instruct the second device to use the first mode to communicate with the first device.
[0101] Alternatively, before the first device executes S502a, the first device may not know whether the second device supports the first mode of communication. In this case, the first mode sent by the first device to the second device is used to negotiate with the second device to use the first mode for communication. Whether the second device agrees to use the first mode to communicate with the first device depends on the second device's specific capabilities and other factors.
[0102] This application embodiment is not limited to whether the first device knows the communication mode supported by the second device before the first device executes S502a.
[0103] S503a: The second device agrees to communicate with the first device based on the first mode.
[0104] As one possible implementation, the second device may agree to communicate with the first device based on the first mode when it supports the first mode's communication mode.
[0105] S504a: The first device establishes a first-mode communication connection with the second device.
[0106] In this context, after the first device and the second device establish a communication connection in the first mode, based on the communication connection in the first mode, the first device, as the sending end, does not perform network layer encapsulation on the data to be transmitted, that is, it does not encapsulate the IP header. Correspondingly, the second device, as the receiving end, does not perform network layer decapsulation on the received data.
[0107] S505a: The first device encapsulates the payload based on the first mode to obtain first data, wherein the first data does not include the IP header.
[0108] The payload is the most fundamental element of data transmission. Along with the payload, data headers are typically transmitted, such as APP headers, TCP headers, IP headers, and Ethernet headers. These headers assist in the transmission of the payload. For example, the payload might be the business data to be transmitted (such as application data).
[0109] In this embodiment of the 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 when encapsulating the payload based on the first mode does not include the IP header.
[0110] For example, such as Figure 6 As shown, the first device encapsulates the payload based on the first mode by 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.
[0111] S506a: The first device sends first data to the second device without carrying an IP header.
[0112] For example, the first device can send first data without an IP header to the second device in binary form via the physical layer.
[0113] S507a: The second device decapsulates the first data based on the first mode to obtain the payload.
[0114] In this embodiment of the application, the second device does not perform network layer decapsulation when decapsulating the first data based on the first mode.
[0115] For example, such as Figure 6 As shown, the second device decapsulates the first data based on the first mode, including the second device performing data link layer decapsulation to remove the Ethernet header, transport layer decapsulation to remove the TCP header, and application layer decapsulation to remove the APP header, and finally obtains the payload.
[0116] like Figure 5 As shown in (b), if the second device and the first device are not connected to the same local area network, the communication method provided in this application embodiment further includes S502b-S507b:
[0117] S502b: The first device sends a communication mode to the second device, which is the second mode.
[0118] For example, the first device can send identification information of the second mode to the second device.
[0119] For the sending end (i.e., the first device), the second mode refers to the communication mode in which the data to be transmitted is encapsulated at the network layer during communication; for the receiving end (i.e., the second device), the second mode refers to the communication mode in which the received data is decapsulated at the network layer during communication.
[0120] In this embodiment of the application, the second mode sent by the first device to the second device is used to negotiate with the second device to use the second mode for communication, or to notify the second device that the first device is inclined to use the second mode to communicate with the second device, or to instruct the second device that the first device is about to use the second mode to communicate with the second device, or to instruct the second device to use the second mode to communicate with the first device.
[0121] Before the first device executes S502b, the first device may have determined that the second device supports the second mode of communication. 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 use the second mode for communication, or it may be used to notify the second device that the first device is inclined to use the second mode to communicate with the second device, or it may be used to instruct the second device that the first device is about to use the second mode to communicate with the second device, or it may be used to instruct the second device to use the second mode to communicate with the first device.
[0122] Alternatively, before the first device executes S502b, the first device may not know whether the second device supports the second mode of communication. In this case, the second mode sent by the first device to the second device is used to negotiate with the second device to use the second mode for communication. Whether the second device agrees to use the second mode to communicate with the first device depends on the second device's specific capabilities and other factors.
[0123] This application embodiment is not limited to whether the first device knows the communication mode supported by the second device before the first device executes S502b.
[0124] S503b: The second device agrees to communicate with the first device based on the second mode.
[0125] As one possible implementation, the second device may agree to communicate with the first device based on the second mode when it supports the second mode of communication.
[0126] S504b: The first device establishes a second-mode communication connection with the second device.
[0127] In this process, 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 sender, will encapsulate the data to be transmitted at the network layer, that is, it will encapsulate the IP header. Correspondingly, the second device, as the receiver, will decapsulate the received data at the network layer.
[0128] S505b: The first device encapsulates the payload based on the second mode to obtain second data, wherein the second data includes the IP header.
[0129] In this embodiment of the application, when the first device encapsulates the payload based on the second mode, it performs network layer encapsulation. Therefore, the second data obtained by the first device from encapsulating the payload based on the second mode includes the IP header.
[0130] For example, such as Figure 7 As shown, the first device encapsulates the payload based on the second mode by 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 the second data.
[0131] S506b: The first device sends second data carrying the IP header to the second device.
[0132] For example, the first device can send second data carrying an IP header to the second device in binary form via the physical layer.
[0133] S507b: The second device decapsulates the first data based on the second mode to obtain the payload.
[0134] In this embodiment of the application, the second device will perform network layer decapsulation when decapsulating the second data based on the second mode.
[0135] For example, such as Figure 7 As shown, the second device decapsulates the second data based on the second mode, including the second device performing layer-by-layer decapsulation of the data link layer to remove the Ethernet header, network layer to remove the IP header, transport layer to remove the TCP header, and application layer to remove the APP header, ultimately obtaining the payload.
[0136] Understandable, such as Figure 5 As shown in (a), when the receiving end is connected to the same local area network as itself, the sending end can avoid carrying redundant IP headers in the data frame. This reduces the processing load and latency caused by IP headers, such as encapsulation, firewall processing, and decapsulation. Furthermore, it significantly increases the effective payload of the data frame, thereby improving transmission efficiency and minimizing communication latency while maximizing the saving of communication and processing resources. Figure 5As shown in (b), the sending end can handle inter-device communication using standard routing and forwarding methods according to the conventional TCP / IP mechanism when the receiving end is not connected to the same local area network as itself, thereby ensuring normal inter-device communication. The method described above in this application, which uses an appropriate communication mode based on the specific circumstances of the communication service, not only supports data transmission between different local area networks, but also, in scenarios involving inter-device communication within the same local area network, maximizes resource conservation and reduces communication latency while ensuring normal inter-device communication, achieving efficient inter-device communication and improving user experience.
[0137] It's important to note that the sending end does not include redundant IP headers in the data frames. Although this bypasses firewall processing of IP headers, it does not increase security risks. This is because the firewall's processing rules are the same for the same data stream. Once the first packet passes inspection, subsequent data in the same stream can bypass the firewall module. Therefore, the establishment of a communication connection between the sending and receiving ends means that the current connection complies with the firewall's security rules.
[0138] As one possible implementation, the communication method described in this application embodiment can be based on the Smart Flow Control (SFC) protocol. The SFC protocol is a transport protocol tailored for HarmonyOS distributed scenarios. The SFC protocol supports a mechanism for on-demand encapsulation of network headers, providing more efficient transmission while ensuring communication reliability. For example, based on the on-demand encapsulation of network headers provided by the SFC protocol, the sending end can negotiate with the receiving end whether to carry the network header in subsequent data transmissions when establishing a connection. For instance, if the receiving end and the sending end are connected to the same local area network, they can negotiate a communication mode without carrying the network header (i.e., the first mode) to maximize transmission performance; otherwise, they can negotiate a communication mode with the network header (i.e., the second mode) to ensure normal communication between devices.
[0139] For example, please refer to Figure 8 , Figure 8 A schematic diagram of the software architecture of an electronic device is shown. For example... Figure 8 As shown, the software architecture of electronic devices includes the application layer, the Socket application programming interface (Socket API), and the TCP / IP protocol suite.
[0140] The application layer can include a series of applications, such as but not limited to camera, gallery, calendar, call, map, navigation, Bluetooth, music, video, and SMS.
[0141] The Socket API serves as an intermediary layer for communication between the application layer and the TCP / IP protocol suite. It provides a network programming interface through which functions can be programmed for TCP, UDP, or SFC, such as create, listen, connect, accept, send, read, and write. For example, the Socket API represents, but is not limited to, the following information required for network communication: the protocol used for the connection, 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.
[0142] It's understandable that when the application layer communicates with the transport layer, TCP encounters the problem of providing concurrent services to multiple application processes. Multiple TCP connections or multiple application processes may need to transmit data through the same TCP port. The application layer and transport layer can use the Socket API to distinguish communication from different application processes or network connections, thus achieving concurrent data transmission services.
[0143] The TCP / IP protocol suite may include, but is not limited to, Figure 8 The diagram shows protocols such as TCP / UDP, SFC, and IP (e.g., IPv4, IPv6). Among these, the SFC protocol can be understood as a lighter-weight communication protocol within the TCP / IP protocol suite, alongside TCP and UDP.
[0144] In this embodiment of the application, if the receiving end and the sending end are connected to the same local area network, they can negotiate an agreement. Figure 8 The illustrated mode 1 (i.e., the first mode) communicates based on the SFC protocol. For example... Figure 8 As shown, based on Mode 1, the data to be transmitted at the sending end can be encapsulated sequentially through the application layer, transport layer (such as SFC), and data link layer, without encapsulation at the network layer header; correspondingly, the receiving end can decapsulate the data sequentially through the data link layer, transport layer (such as SFC), and application layer. If the receiving end and the sending end are not connected to the same local area network, they can negotiate an agreement. Figure 8 Mode 2 (i.e., the second mode) is shown, based on communication using the SFC and IP protocols. For example... Figure 8 As shown, based on mode 2, the data to be transmitted at the sending end can be encapsulated sequentially through the application layer, transport layer (such as SFC), network layer (such as IPv4 / IPv6), and data link layer; correspondingly, the receiving end can decapsulate the data sequentially through the data link layer, network layer (such as IPv4 / IPv6), transport layer (such as SFC), and application layer. Figure 8As can be seen, compared to mode 2, mode 1 has a shorter call process, and both mode 1 and mode 2 are compatible with existing Socket APIs.
[0145] It should be noted that the embodiments in this application only describe the communication mode between devices within the same local area network (LAN) or different LANs, and do not limit the communication protocols and communication modes used by electronic devices in other communication scenarios. For example, in some conventional scenarios, the sending end and the receiving end can also negotiate to adopt... Figure 8 Communication is performed in mode 3. For example... Figure 8 As shown, based on mode 3 (such as TCP / UDP mode), the data to be transmitted at the sending end can be encapsulated sequentially through the application layer, transport layer (such as TCP / UDP), network layer (such as IPv4 / IPv6), and data link layer to obtain a TCP / UDP Socket frame; correspondingly, the receiving end can decapsulate the data sequentially through the data link layer, network layer (such as IPv4 / IPv6), transport layer (such as TCP / UDP), and application layer.
[0146] As an example, the first mode (or mode 1) described above is also called SFC Over Ether mode. In SFC Over Ether mode, the data frame sent from the sending end to the receiving end is as follows: Figure 9 The image shows an SFC Over Ether Socket frame. The second mode (or mode 2) described above is also called SFC Over IP mode. In SFC Over IP mode, the data frame sent from the sending end to the receiving end is as follows: Figure 9 The SFC Over IP Socket frame shown.
[0147] like Figure 9 As shown, both SFC Over Ether Socket frames and SFC Over IP Socket frames include fields such as Preamble, SFD, DstMAC, SrcMAC, Type, SFC Header, Application Data, and FCS.
[0148] The Preamble field is a preamble code used to enable the receiver's adapter to quickly adjust its clock frequency to match that of the transmitter when receiving data frames. This Preamble field can be 7 bytes long, alternating between 1s and 0s.
[0149] The SFD field is used to characterize the start character of a data frame. The length of the SFD field can be 1 byte. The first 6 bits alternate between 1 and 0, and the last two consecutive 1 bits are used to tell the receiving adapter: "Frame information is coming, prepare to receive".
[0150] The DstMAC field is the destination address, used to identify the MAC address or physical address of the network adapter receiving the data frame. The length of DstMAC can be 6 bytes. Understandably, when the receiving end receives a MAC frame, it first checks if the destination address of the data frame is the same as the physical address of the current adapter. If they are the same, further processing is performed; if they are different, the data frame is discarded.
[0151] The SrcMAC field is the source address, used to represent the MAC address or physical address of the network adapter that sent the data frame. The length of SrcMAC can be 6 bytes.
[0152] The Type field is used to indicate the type of higher-level data carried in the Layer 2 data frame. Since there are many upper-layer protocols, this Type field can be used to indicate which higher-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 indicates that the higher-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 indicates that the higher-level data carried in the Layer 2 data frame is an SFC Over IP Socket frame. It is understood that the above 0xABAB and 0x0800 are merely illustrative examples and do not constitute a limitation on the embodiments of this application. In some embodiments, other values can also be used to indicate SFC Over Ether Socket frames and SFC Over IP Socket frames.
[0153] The SFC header is used to ensure that data frames arrive at the receiver reliably in order, and to assist in calculating round-trip time (RTT) and congestion control. The SFC header field can be 12 bytes long.
[0154] As an example, the SFC header may include, but is not limited to, fields such as version (V), priority (P), transmit index (TI), merge (M), window, optional header(s), type (T), length, checksum, flowlabel, sequence number (SN), and optional header(s).
[0155] The following fields are used to indicate the SFC protocol version number: Version, Priority, Transmission Index, Merge Indicator, Window, and Header. The Transmission Index field indicates whether the data frame is being transmitted for the first time or is a retransmission. The Merge Indicator field indicates whether the data frame needs to be merged with subsequent data frames. The Header Indicator field indicates the size of the receiver's window. The Header Extension Indicator field indicates whether the data frame contains a header. The Type field indicates the data type of the data frame, such as initialization, acknowledgment, data, or end.
[0156] The application data can be 30 bytes long, with a maximum length of 1488 bytes, also known as the maximum transmission unit. If the data is less than 30 bytes, it can be padded to 46 bytes.
[0157] The FCS field is the Frame Detection Sequence, used to detect whether an error has occurred in the data frame. The FCS field can be 4 bytes long. For example, the sender can calculate the cyclic redundancy check (CRC) code of 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 they are different, it indicates that data loss or alteration has occurred during transmission, and the data frame needs to be retransmitted.
[0158] like Figure 9 As shown, SFC Over Ether Socket frames do not include an IP header because they are not encapsulated by the network layer; while SFC Over IP Socket frames include an IP header because they are encapsulated by the network layer.
[0159] 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, so that the device knows where the application data comes from and where it is to be sent.
[0160] As described above, the SFC protocol provides a mechanism for on-demand encapsulation of the network layer header. The sending end can negotiate with the receiving end during connection establishment whether to include the network layer header in subsequent data transmissions. For example, please refer to... Figure 10 , Figure 10 Taking communication between a first device and a second device based on the SFC protocol as an example, a schematic diagram of a communication mode negotiation process provided in an embodiment of this application is shown. Both the first device and the second device support the SFC protocol, and the first device and the second device are protocol-equivalent. Figure 10In the example shown, the first device is the party that initiates the connection request, and is therefore also called the sender (or client), while the second device, as the party being requested, is called the receiver (or server).
[0161] like Figure 10 As shown, when there is a need to send data to the second device, the process of negotiating the communication mode between the first device and the second device mainly includes S1001-S1007:
[0162] S1001: The first device initiates the chain establishment request process.
[0163] For example, the first device can first create a Socket, and then call the connect interface to initiate a connection request process.
[0164] S1002: The first device determines the communication mode.
[0165] As one possible implementation, the first device can determine whether the second device and the first device are connected to the same local area network by judging 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.
[0166] For example, 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 the communication mode as 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 the communication mode as the second mode (such as SFC Over IP mode).
[0167] As one possible implementation, the first device can also determine the communication mode as automatic. Specifically, the first device can initially determine the communication mode as automatic when deciding that the second device will determine the specific communication mode based on the actual situation. Correspondingly, if the second device receives an automatic communication mode from the first device during subsequent communication mode negotiation, the second device can independently determine the communication mode to be used for communication between the two parties.
[0168] S1003: The first device creates a flow table.
[0169] A flow table is a collection of policy entries for a specific flow, responsible for finding and forwarding data frames. A process can include a series of flow entries.
[0170] For example, the process may include, but is not limited to, header fields for packet matching, counters for counting the number of matched data frames, and actions for showing how to process the matched packets.
[0171] The packet header field contains 12 tuples, basically covering 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, and TCP / UDP destination port number. Counters are used to count data traffic-related information, such as the number of currently active entries, packet lookup counts, packet match counts, number of received packets, number of received packet bytes, duration of received data streams, number of sent packets, number of sent packet bytes, and number of errors. The action table instructs the switch how to process a matched packet; each flow table entry can correspond to zero to multiple actions. For a detailed introduction to flow tables, please refer to conventional techniques; this application's embodiments will not elaborate further.
[0172] S1004: The first device and the second device negotiate parameters, including negotiating the communication mode.
[0173] As an example, the first device may send its determined communication mode to the second device for negotiating with the second device to use the first mode for communication, or for notifying the second device that the first device prefers to use the first mode to communicate with the second device, or for instructing the second device that the first device is about to use the first mode to communicate with the second device, or for instructing the second device to use the first mode to communicate with the first device.
[0174] For example, the first device can send its determined communication mode to the second device via an initialization request (such as an INIT message).
[0175] S1005: The second device creates a flow table.
[0176] S1006: The second device determines the connection mode.
[0177] As an example, if the first device sends a communication mode to the second device as either a first mode or a second mode, the second device can determine to use the same communication mode as the first device.
[0178] As an example, if the communication mode sent by the first device to the second device is automatic, the second device can determine the communication mode to be used for communication. For instance, the second device can determine whether it is connected to the same local area network (LAN) by checking if its network layer address (e.g., IP address) is the same as the first device's own network layer address (e.g., IP address), and then determine the communication mode to use based on this. For example, if the second device's IP address is the same as the first device's IP address (meaning they are connected to the same LAN), the first device determines the communication mode to be the first mode (e.g., SFC Over Ether mode); if the second device's IP address is different from the first device's IP address (meaning they are not connected to the same LAN), the first device determines the communication mode to be the second mode (e.g., SFC Over IP mode).
[0179] S1007: The second device establishes a corresponding communication connection with the first device based on the communication mode determined through negotiation.
[0180] As an example, after negotiating and determining the communication mode, 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 and first devices is established. Afterwards, the first and second devices can transmit data based on the negotiated communication mode. For example, the first and second devices can read / receive and write / send data using Read / Recv and Write / Send, encapsulating data according to the negotiated communication mode during transmission and decapsulating it according to the negotiated communication mode during reception.
[0181] 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 peer device. Correspondingly, after receiving the Fin message, the peer device can initiate a disconnect process to break the communication connection between the two.
[0182] It is understood that this application embodiment relies on the SFC protocol's mechanism of on-demand encapsulation of the network layer header, which allows negotiation with the receiving end during connection establishment regarding whether to include 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 (LAN), they can negotiate a communication mode without the network layer header (i.e., the first mode) to maximize transmission performance; otherwise, they can negotiate a communication mode with the network layer header (i.e., the second mode) to ensure normal communication between devices. The method described above in this application embodiment, which uses an appropriate communication mode based on the specific circumstances of the communication service, not only ensures data transmission between different LANs but also, in scenarios involving communication between devices within the same LAN, maximizes resource conservation and reduces communication latency while ensuring normal communication between devices, thereby achieving efficient communication between devices and improving user experience.
[0183] It should be noted that the above embodiments of this application only use the IP protocol, such as IPv4 or IPv6, as an example for the communication protocol of the network layer. However, the embodiments of this application do not limit 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.
[0184] It should be understood that the various solutions in the embodiments of this application can be used in a reasonable combination, and the explanations or descriptions of the various terms appearing in the embodiments can be referenced or explained to each other in the various embodiments, without limitation.
[0185] It should also be understood that, in the various embodiments of this application, the order of the above-mentioned processes does not imply 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 this application.
[0186] It is understood that, in order to implement the functions of any of the above embodiments, electronic devices (such as the first device or the second device) include hardware structures and / or software modules corresponding to the execution of each function. Those skilled in the art should readily recognize that, based on the units and algorithm steps of the examples described in conjunction with the embodiments disclosed herein, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0187] This application embodiment can divide an electronic device (such as a first device or a second device) into functional modules. For example, each function can be divided into its own functional modules, or two or more functions can be integrated into one processing module. The integrated modules can be implemented in hardware or as software functional modules. It should be noted that the module division in this application embodiment is illustrative and only represents one logical functional division; other division methods may be used in actual implementation.
[0188] As an example, such as Figure 11 As shown, an 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 its functional modules. The transceiver unit 1110 is used to send and receive information (such as connection establishment requests, first data, second data, etc.), the processing unit 1120 is used to determine the communication mode, encapsulate data, decapsulate data, allocate resources, 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., and this application embodiment does not specifically limit this.
[0189] It should also be understood that the various modules in an electronic device (such as the first device or the second device) can be implemented in software and / or hardware, without specific limitations. In other words, the electronic device (such as the first device or the second device) is presented in the form of functional modules. Here, "module" can refer to application-specific integrated circuits (ASICs), circuits, processors and memories that execute one or more software or firmware programs, integrated logic circuits, and / or other devices that can provide the above-mentioned functions.
[0190] In an alternative approach, when data transmission is implemented using software, it can be implemented entirely or partially 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, all or part of the processes or functions described in the embodiments of this application are implemented. 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. 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 wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., digital video disk (DVD)), or a semiconductor medium (e.g., solid-state disk (SSD)).
[0191] The steps of the methods or algorithms described in the embodiments of this application can be implemented in hardware or by a processor executing software instructions. The software instructions can consist of corresponding software modules, which can be stored in RAM, flash memory, ROM, EPROM, EEPROM, registers, hard disk, portable hard disk, CD-ROM, or any other form of storage medium known in the art. One exemplary embodiment couples a storage medium to a processor, enabling the processor to read information from and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and storage medium can reside in an ASIC. Alternatively, the ASIC can reside in an electronic device (such as a first device or a second device). Of course, the processor and storage medium can also exist as discrete components.
[0192] Through the above description of the embodiments, those skilled in the art can clearly understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above 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, It is 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, It is 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, It is 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, It is characterized in that The second data includes an Internet Protocol IP header.
5. The method according to any one of claims 1 to 4, It is 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, It is 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, It is 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, It is 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, It is 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, It is characterized in that The SFC is a communication protocol in the TCP / IP protocol suite.
11. A communication method, It is 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, It is 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, It is 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, It is 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, It is characterized in that The second data includes an IP header.
16. The method according to claim 14 or 15, It is 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, It is characterized in that Both the first mode and the second mode are communication modes compliant with SFC.
18. The method according to claim 17, It is characterized in that The SFC is a communication protocol in the TCP / IP protocol suite.
19. An electronic device, It is 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, It is 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, It is 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, It is 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, It is 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, It is 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
Cited By
Data transmission method, data transmission system and electronic equipment
CN120434832A
