Communication method and electronic device
By introducing logical network cards and physical drivers into lightweight non-Linux kernel devices, seamless switching of communication methods is achieved, solving the problem of low processing efficiency, improving communication efficiency, and reducing power consumption.
Patent Information
- Application Number
- CN202311271179.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-27
- Publication Date
- 2026-02-06
- Estimated Expiration
- 2043-09-27
AI Technical Summary
Lightweight, non-Linux kernel electronic devices require application involvement when switching communication methods, resulting in low processing and communication efficiency and making seamless switching impossible.
By introducing logical network cards and physical drivers into electronic devices, a fixed source IP address is added using the logical network card, and a source MAC address is added using the target physical driver, enabling seamless switching of communication devices and avoiding application involvement in the switching process.
It enables seamless switching of communication modes for lightweight non-Linux kernel devices, improving communication efficiency and client processing efficiency while reducing the power consumption of communication devices.
Smart Images

Figure CN119729679B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of electronic devices, and in particular to a communication method and an electronic device. BACKGROUND
[0002] Most current electronic devices can communicate with other electronic devices through various communication modes (such as a WiFi communication mode, a Bluetooth communication mode, a mobile communication mode, etc.), and can also switch the communication mode used in the communication process. Different communication modes correspond to different communication links, and switching the communication mode is switching the communication link. Currently, lightweight non-linux kernel electronic devices (such as electronic devices using a lightweight internet protocol (Lwip)) need to involve applications when switching the communication mode, which reduces the processing efficiency of the client, leads to poor client experience, and also affects the overall communication efficiency of the electronic device. SUMMARY
[0003] The present application provides a communication method and an electronic device to realize non-susceptible switching of communication modes. The method can be applied to lightweight non-linux kernel electronic devices, thereby improving the communication efficiency of the electronic device.
[0004] In a first aspect, an embodiment of the present application provides a communication method applied to a first electronic device, wherein the first electronic device communicates with a server through a second electronic device, and the first electronic device includes a first application, a logical network card, a first physical driver and a corresponding first communication device, a second physical driver and a corresponding second communication device; wherein the first communication device and the second communication device support different communication modes; the method includes: the first application generates a first packet; the logical network card adds a source Internet Protocol (IP) address to the first packet, and sends a second packet obtained to a selected target physical driver; wherein the source IP address is the IP address of the logical network card; the target physical driver is the first physical driver or the second physical driver; the target physical driver adds a source Media Access Control (MAC) address to the second packet, and drives the corresponding communication device to send a third packet obtained to the second electronic device, so that the second electronic device sends the third packet to the server; wherein the source MAC address is the MAC address of the communication device corresponding to the target physical driver.
[0005] In the method, in the communication process, the first electronic device can add an IP address of a logical interface as a source IP address to a packet to be sent through the logical interface, and the first electronic device adds a source MAC address to the packet to be sent, which is a MAC address of a communication device to be used. Based on this manner, the first electronic device can switch the communication device to be used by switching the source MAC address added to the packet when sending the packet, thereby realizing switching of the communication manner. Meanwhile, the source IP address of the packet is fixed as the IP address of the logical interface configured by the logical interface, so that the first application does not participate in the switching process of the communication manner, the switching of the communication manner does not affect the interaction process between the first application and the logical interface, and the first application only needs to send data to be sent as a packet to the logical interface each time, so that the switching of the communication manner is transparent to the first application, that is, the client. Therefore, based on the above method, the switching of the communication manner can be realized in a transparent manner, thereby improving the communication efficiency. The above method can be applied to the communication manner switching scene in a lightweight electronic device, and the switching of the communication manner on the lightweight device can be realized in a transparent manner without the help of a linux kernel, thereby realizing the same communication manner switching experience as a rich device, for example, an electronic device based on a linux kernel. In addition, in the above method, the physical driver has the function of waking up the corresponding communication device, so that the communication device can remain in a sleep state and be pulled up by the physical driver when needed, so that the power consumption of the communication device is low.
[0006] In a possible design, after the logical network card adds a source Internet Protocol (IP) address to the first packet, before the obtained second packet is sent to the selected target physical driver, the method further includes that the logical network card adds a destination IP address to the first packet; and the destination IP address is an IP address of the server. After the target physical driver adds a source MAC address to the second packet, before the corresponding communication device driven by the target physical driver sends an obtained third packet to the second electronic device, the method further includes that the target physical driver adds a destination MAC address to the second packet; and the destination MAC address is a MAC address of a third communication device of the second electronic device, and the third communication device has the same communication manner as the communication device corresponding to the target physical driver.
[0007] In the method, the logical network card can add a destination IP address to a packet to be sent, and the target physical driver can add a destination MAC address to the packet to be sent, which can further improve the success rate of packet transmission.
[0008] In a possible design, before driving the corresponding communication device to send the obtained third message to the second electronic device, the method further includes: determining that the target physical drive corresponds to a communication device that is communicatively connected to the third communication device. Through the method, it can be ensured that the third message can be successfully transmitted to the second electronic device.
[0009] In a possible design, before sending the obtained second message to the selected target physical drive, the method further includes: selecting a target communication device from the first communication device and the second communication device according to current scene information, where the current scene information includes information used to represent the communication quality of the first communication device and / or information used to represent the communication quality of the second communication device; and taking a physical drive corresponding to the target communication device as the target physical drive. Based on the method, the logical network card can select a suitable physical drive and communication device in the current scene according to the communication quality of different communication devices in the current scene, to send a message, thereby improving the communication quality and efficiency.
[0010] In a possible design, the method further includes: the first application generates a fourth message; when the target physical drive is the first physical drive, the logical network card adds the source IP address to the fourth message, and sends an obtained fifth message to the second physical drive; the second physical drive adds a source MAC address to the fifth message, and drives a second communication device to send an obtained sixth message to the second electronic device, so that the second electronic device sends the sixth message to the server; where the source MAC address added to the fifth message by the second physical drive is a MAC address of the second communication device.
[0011] In the method, the source IP address is fixed, and therefore the selection of the physical drive and the corresponding communication device is independent of the source IP address, so that the logical network card can encapsulate different messages of the same application with the same source IP address and send them to different physical drives and corresponding communication devices for processing, thereby achieving the effect of multi-path concurrency.
[0012] In a possible design, the first electronic device further includes a second application; after driving the corresponding communication device to send the obtained third message to the second electronic device, the method further includes: the second application generates a seventh message; the logical network card adds the source IP address to the seventh message, and sends an obtained eighth message to the target physical drive; the target physical drive adds the source MAC address to the eighth message, and drives the corresponding communication device to send an obtained ninth message to the second electronic device, so that the second electronic device sends the ninth message to the server.
[0013] In the method, the source IP address is fixed, and thus the selection of the physical driver and the corresponding communication device is independent of the source IP address. Therefore, the logical network card can encapsulate different messages of different applications with the same source IP address and then send the messages to the same physical driver and the corresponding communication device for processing, so that the effect of sending messages of different applications through the same communication device can be achieved.
[0014] In a possible design, the first electronic device adopts a lightweight Internet Protocol (Lwip). The above method can achieve seamless switching of the communication mode in the Lwip device, and thus improves the communication efficiency of the Lwip device.
[0015] In a second aspect, the present application provides an electronic device, including a memory and one or more processors; wherein the memory is configured to store computer program codes, the computer program codes including computer instructions; when the computer instructions are executed by the one or more processors, the electronic device performs the method described in the first aspect or any possible design of the first aspect.
[0016] In a third aspect, the present application provides a computer readable storage medium, which stores a computer program; when the computer program is run on an electronic device, the electronic device performs the method described in the first aspect or any possible design of the first aspect.
[0017] In a fourth aspect, the present application provides a computer program product, which includes a computer program or instructions; when the computer program or instructions are run on an electronic device, the electronic device performs the method described in the first aspect or any possible design of the first aspect.
[0018] In a fifth aspect, the present application provides a chip system, which includes a processor and a memory, and the memory stores instructions; when the instructions are executed by the processor, the method described in the first aspect or any possible design of the first aspect is implemented. The chip system can be composed of a chip, or can include a chip and other discrete devices.
[0019] The beneficial effects of the second aspect to the fifth aspect can refer to the beneficial effects of the first aspect, which will not be repeated here. BRIEF DESCRIPTION OF DRAWINGS
[0020] Figure 1 FIG. 1 is a schematic diagram of a system architecture of an electronic device of a Linux kernel;
[0021] Figure 2 FIG. 2 is a schematic diagram of a system architecture of an electronic device based on Lwip;
[0022] Figure 3 A hardware architecture schematic diagram of an electronic device provided by an embodiment of the present application is shown in FIG. 1.
[0023] Figure 4 A software architecture schematic diagram of an electronic device provided by an embodiment of the present application is shown in FIG. 2.
[0024] Figure 5 A schematic diagram of an architecture of a communication system provided by an embodiment of the present application is shown in FIG. 3.
[0025] Figure 6 A schematic diagram of a communication method provided by an embodiment of the present application is shown in FIG. 4.
[0026] Figure 7 A schematic diagram of a communication method provided by an embodiment of the present application is shown in FIG. 5.
[0027] Figure 8 A schematic diagram of a packet address information provided by an embodiment of the present application is shown in FIG. 6.
[0028] Figure 9 A schematic diagram of a communication method provided by an embodiment of the present application is shown in FIG. 7.
[0029] Figure 10 A schematic diagram of a structure of an electronic device provided by an embodiment of the present application is shown in FIG. 8. DETAILED DESCRIPTION
[0030] In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the embodiments of the present application will be further described in detail below with reference to the drawings.
[0031] In the description of the embodiments of the present application, the terms "first", "second" are used only for the purpose of description, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined with "first", "second" can explicitly or implicitly include one or more of the features.
[0032] For the convenience of understanding, exemplary descriptions of related concepts are given for reference.
[0033] 1) Electronic device, which can be a device with communication function. In the embodiments of the present application, the electronic device can also be referred to as terminal or terminal device, etc.
[0034] In some embodiments of the present application, the electronic device can be a portable device, such as a wearable device (e.g., a watch, a bracelet, a helmet, a headset, etc.) with wireless communication function, a smart home device (e.g., a smart speaker, etc.), a plant device, a wireless terminal in industrial control, a wireless terminal in self driving, a wireless terminal in remote medical surgery, a wireless terminal in smart grid, a wireless terminal in transportation safety, a wireless terminal in smart city, a wireless terminal in smart home, a flying device (e.g., a drone), etc.
[0035] In some embodiments of the present application, the wearable device is a portable device that can be directly worn by a user or integrated into a garment or accessory of the user.
[0036] In some embodiments of the present application, the electronic device can also be a portable terminal device that contains other functions. Exemplary embodiments of the portable terminal device include, but are not limited to, a portable terminal device equipped with an Android® operating system or other operating system. The portable terminal device described above can also be another portable terminal device, or can not be a portable terminal device, but can be another device, such as an embedded device, etc. The portable terminal device described above can also be another portable terminal device, or can not be a portable terminal device, but can be another device, such as an embedded device, etc.
[0037] 2) Light weight internet protocol (Lwip), which is a small open source transmission control protocol (TCP) / internet protocol (IP) protocol stack. The focus of Lwip implementation is to reduce the occupation of random access memory (RAM) while maintaining the main functions of TCP protocol, and then to realize a relatively complete TCP / IP protocol stack with small (RAM) resource consumption. Lwip can run with or without operating system support.
[0038] 3) Logical network card, which refers to a virtual network card that can realize data exchange function but does not exist physically and needs to be established by configuration. The logical network card has an IP address.
[0039] It should be understood that in the embodiments of this application, "at least one" means one or more, and "more than one" means two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can represent: a, b, c, a and b, a and c, b and c, or a, b, and c, where a, b, and c can be single or multiple.
[0040] Currently, Linux kernel-based electronic devices can achieve seamless switching of communication modes, meaning the switching occurs without the client being aware of it, resulting in high communication efficiency. This will be explained in detail below.
[0041] Figure 1 This is a schematic diagram of a possible system architecture for a Linux kernel-based electronic device. Figure 1 As shown, an electronic device within the Linux kernel can include applications, logic drivers, logic interfaces, an extended Berkeley packet filter (eBPF), physical driver 1, communication device 1, physical driver 2, and communication device 2. The logic driver drives the logic interface, physical driver 1 drives communication device 1, and physical driver 2 drives communication device 2. Communication device 1 and communication device 2 can communicate with other electronic devices through different communication methods. For example, communication device 1 can communicate with other electronic devices via Bluetooth, and communication device 2 can communicate with other electronic devices via WiFi.
[0042] The electronic device can send the generated message to the logical interface when communicating in the communication mode corresponding to the communication device 1. The logical interface can add a source IP address and a destination IP address to the message, where the source IP address is the IP address of the logical interface, and the destination IP address is the IP address of another electronic device that needs to receive the message. The logical interface can send the processed message to the eBPF. The eBPF can match the corresponding communication device 1 according to the received message, and send the message to the corresponding communication device 1 after adding a source MAC address and a destination MAC address to the message. The source MAC address is the MAC address of the communication device 1, and the destination MAC address is the MAC address of the communication device of another electronic device that needs to receive the message. Since the IP address and the MAC address are bound in the Linux system, the eBPF needs to modify the source IP address in the message to the IP address of the communication device 1 when adding the source MAC address to the message, that is, the source IP address is modified from the IP address of the logical interface 1 to the IP address of the communication device 1. The process of the electronic device communicating in the communication mode corresponding to the communication device 2 can be implemented by referring to the process of the electronic device communicating in the communication mode corresponding to the communication device 1, which will not be described in detail here.
[0043] When the electronic device switches from communicating in the communication mode corresponding to the communication device 1 to communicating in the communication mode corresponding to the communication device 2, the processing method of the application after generating the message does not change, and the message is still sent directly to the logical interface. Therefore, the application can establish a connection based on the logical interface and send messages directly to the logical interface without the need to establish multiple transmission channels. The processing method of the logical interface for the received message does not change, and the logical interface still sends the message to the eBPF after adding the address of the logical interface as the source IP address. The processing of the eBPF for the received message is switched from "modifying the source IP address from the IP address of the logical interface to the IP address of the communication device 1" to "modifying the source IP address from the IP address of the logical interface to the IP address of the communication device 2". The forwarding path of the eBPF for the processed message is switched from "sending to the communication device 1" to "sending to the communication device 2". In the above process, the application does not need to switch the processing method and the communication path, the application is continuously connected with the logical interface, and the application does not freeze during the switching process. Therefore, the switching of the communication mode is transparent to the application (i.e., the client), and does not affect the client experience.
[0044] While the aforementioned Linux kernel-based electronic devices can achieve seamless switching of communication methods, this relies on Linux kernel virtual network interface cards (i.e., the logical interface mentioned above), eBPF, and eBPF's network interface card redirection function (i.e., the function of resetting the network interface card's IP address). Therefore, it is not applicable to lightweight non-Linux kernel electronic devices. Furthermore, in the above method, the logical interface only provides an IP address and does not carry (i.e., does not store) data. Therefore, packets received by the logical interface are directly forwarded to eBPF. Since eBPF does not have the function of waking up the communication device, the communication device needs to remain constantly awake so that it can receive and process packets when eBPF sends them, resulting in high power consumption for the communication device. In the above method, the source IP address set by eBPF for the packet is the IP address of the communication device. eBPF only sends the packet to the communication device corresponding to the source IP address, so only one communication device works at a time, making multi-channel concurrency impossible.
[0045] Some lightweight (or lightweight non-Linux) systems and devices (such as smart speakers and smartwatches) use Lwip for their TCP / IP protocol, and there are currently no other alternatives. These devices can only perform sensor-based switching of communication methods, not seamless switching. This will be explained in detail below.
[0046] Figure 2 This is a schematic diagram of a system architecture for an electronic device using Lwip. For example... Figure 2 As shown, the electronic device may include an application, a physical network interface card (NIC) 1, a physical driver 1, a communication device 1, a physical NIC 2, a physical driver 2, and a communication device 2. Physical NIC 1 corresponds to both physical driver 1 and communication device 1, and physical NIC 2 corresponds to both physical driver 2 and communication device 2. Physical NIC 1 is generated by physical driver 1, and they are paired (or interact) one-to-one. Physical NIC 2 is generated by physical driver 2, and they are paired (or interact) one-to-one. The physical NICs are hardware devices or structures. Physical driver 1 drives communication device 1, and physical driver 2 drives communication device 2. Communication device 1 and communication device 2 can communicate with other electronic devices through different communication methods. For example, communication device 1 can communicate with other electronic devices via Bluetooth, and communication device 2 can communicate with other electronic devices via WiFi.
[0047] When the electronic device communicates in the communication mode corresponding to the communication device 1, the application can send the generated message to the physical network card 1, and the physical network card 1 can add a source IP address and a destination IP address to the received message, wherein the source IP address is the IP address of the communication device 1, and the destination IP address is the IP address of the other device that ultimately needs to receive the message. The physical network card 1 can send the processed message to the physical driver 1. The physical driver 1 can add a source MAC address and a destination MAC address to the received message, wherein the source MAC address is the MAC address of the communication device 1, and the destination MAC address is the MAC address of the communication device of the opposite end electronic device in communication with the electronic device. The physical driver 1 can drive the communication device 1 to send the message to the opposite end electronic device. When the electronic device communicates in the communication mode corresponding to the communication device 2, the application can send the generated message to the physical network card 2, and the physical network card 2 can add a source IP address and a destination IP address to the received message, wherein the source IP address is the IP address of the communication device 2, and the destination IP address is the IP address of the other device that ultimately needs to receive the message. The physical network card 2 can send the processed message to the physical driver 2. The physical driver 2 can add a source MAC address and a destination MAC address to the received message, wherein the source MAC address is the MAC address of the communication device 2, and the destination MAC address is the MAC address of the communication device of the opposite end electronic device. The physical driver 2 can drive the communication device 2 to send the message to the opposite end electronic device.
[0048] When the electronic device switches from the communication mode corresponding to the communication device 1 to the communication mode corresponding to the communication device 2, the application needs to switch the processing of the message after the application generates the message from "sending to the physical network card 1" to "sending to the physical network card 2". Correspondingly, the application needs to switch the channel for sending the message, which requires the application to switch from being connected to the physical network card 1 to being connected to the physical network card 2, and this process will cause the application to lag. Therefore, the switching process of the communication mode is felt by the application (the client). This will reduce the processing efficiency of the client, cause the client to have a poor experience, and also affect the overall communication efficiency.
[0049] In summary, the electronic device using Lwip can perform the perceptible switching of the communication mode according to the above method, but cannot perform the imperceptible switching of the communication mode.
[0050] Based on the above problems, in order to realize the non-sensing switching of the communication mode in the electronic device without the Linux kernel, the embodiment of the application provides a communication method and an electronic device. The scheme can simply and efficiently perform non-sensing switching of the communication mode, thereby improving the client processing efficiency and improving the communication efficiency. Optionally, the scheme provided by the embodiment of the application can be applied to a lightweight electronic device without the Linux kernel, for example, can be applied to a lightweight device based on Lwip. The scheme provided by the application can realize non-sensing switching of the communication mode in such a device, thereby improving the client processing efficiency and the communication efficiency of such a device.
[0051] The following refers to Figure 3 The structure of the electronic device to which the method provided by the embodiment of the application is applicable is introduced.
[0052] As Figure 3 shown, the electronic device 100 can include a processor 110, a memory 120, a display screen 130, a charge management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a wireless communication module 160, an audio module 170, a loudspeaker 170A, a receiver 170B, a microphone 170C, a sensor module 180, a key 190, a motor 191, etc. Optionally, the electronic device 100 can further include a mobile communication module 150, a camera 192, etc.
[0053] The sensor module 180 can include a gyroscope sensor, an acceleration sensor, a proximity light sensor, a touch sensor, a temperature sensor, a pressure sensor, a distance sensor, a magnetic sensor, an ambient light sensor, an air pressure sensor, etc.
[0054] It can be understood that Figure 3 The electronic device 100 shown in the figure is only an example and does not constitute a limitation on the electronic device, and the electronic device can have more or fewer components than those shown in the figure, can combine two or more components, or can have a different component configuration. Figure 3 The various components shown in the figure can be implemented in hardware, software, or a combination of hardware and software including one or more signal processing and / or application specific integrated circuits.
[0055] The processor 110 can include one or more processing units, for example: the processor 110 can include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Among them, different processing units can be independent devices, or can be integrated in one or more processors. Among them, the controller can be the nerve center and command center of the electronic device 100. The controller can generate operation control signals according to instruction operation codes and timing signals, and complete the control of fetching and executing instructions.
[0056] The memory can also be provided in the processor 110, used to store instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory can save instructions or data that the processor 110 has just used or repeatedly uses. If the processor 110 needs to use the instructions or data again, it can be directly called from the memory. Avoiding repeated access reduces the waiting time of the processor 110, thus improving the efficiency of the system.
[0057] The execution of the communication method provided by the embodiments of the present application can be controlled by the processor 110 or other components to complete, such as calling the processing program of the embodiments of the present application stored in the memory 120 to control the wireless communication module 160 to communicate data with other devices, improve the intelligent and convenient degree of the electronic device 100, and improve the user's experience. The processor 110 can include different devices, such as when the CPU and GPU are integrated, the CPU and GPU can cooperate to execute the communication method provided by the embodiments of the present application, such as part of the algorithm in the communication method is executed by the CPU, and another part of the algorithm is executed by the GPU, to obtain faster processing efficiency.
[0058] The display screen 130 is configured to display images, videos, and the like. The display screen 130 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flex light-emitting diode (FLED), a Miniled, a MicroLed, a Micro-oLed, a quantum dot light emitting diodes (QLED), or the like. In some embodiments, the electronic device 100 can include one or N display screens 130, where N is a positive integer greater than 1. The display screen 130 can be configured to display information input by a user or provided to the user, as well as various graphical user interfaces (GUIs).
[0059] In some embodiments, the display screen 130 can be a single flexible display screen, or can be a spliced display screen including two rigid screens and a flexible screen between the two rigid screens.
[0060] The camera 192 (front-facing camera or rear-facing camera, or a camera that can function as both a front-facing camera and a rear-facing camera) is configured to capture still images or videos. Typically, the camera 192 can include a photosensitive element such as a lens group and an image sensor, where the lens group includes multiple lenses (convex lenses or concave lenses) for collecting light signals reflected by an object to be photographed and transmitting the collected light signals to the image sensor. The image sensor generates a raw image of the object to be photographed based on the light signals.
[0061] The memory 120 can be configured to store computer-executable program code including instructions. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the memory 120. The memory 120 can include a program storage area and a data storage area. The program storage area can store an operating system, codes of application programs (such as a communication method), and the like. The data storage area can store data created during use of the electronic device 100, and the like.
[0062] The memory 120 can further store one or more computer programs corresponding to the algorithms of the communication method provided in the embodiments of the present application. The one or more computer programs stored in the memory 120 and configured to be executed by the one or more processors 110 include instructions that can be used to perform the steps in the embodiments.
[0063] In addition, the memory 120 can include a high-speed random access memory, and can further include a non-volatile memory such as at least one magnetic disk storage device, a flash memory device, a universal flash storage (UFS), and the like.
[0064] In some embodiments of the present application, the touch sensor is also referred to as a "touch panel". The touch sensor can be disposed on the display screen 130, and the touch sensor and the display screen 130 form a touch display screen, also referred to as a "touch screen". The touch sensor is used to detect a touch operation acting on or near the touch sensor. The touch sensor can transmit the detected touch operation to the application processor to determine the touch event type. The visual output related to the touch operation can be provided through the display screen 130. In other embodiments, the touch sensor can also be disposed on the surface of the electronic device 100, which is different from the position where the display screen 130 is located.
[0065] The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor, and the baseband processor, and the like.
[0066] The antenna 1 and the antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in the electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be multiplexed to improve the utilization rate of the antennas. For example, the antenna 1 can be multiplexed as a diversity antenna of a wireless local area network. In other embodiments, the antenna can be used in combination with a tuning switch.
[0067] The mobile communication module 150 can provide a solution for wireless communication including 2G / 3G / 4G / 5G, etc. applied to the electronic device 100. The mobile communication module 150 can include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves by the antenna 1, and perform filtering, amplification, etc. on the received electromagnetic waves, and transfer to the modem processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modem processor, and radiate as electromagnetic waves through the antenna 1. In some embodiments, at least part of the function modules of the mobile communication module 150 can be disposed in the processor 110. In some embodiments, at least part of the function modules of the mobile communication module 150 can be disposed in the same device as at least part of the modules of the processor 110. In the embodiments of the present application, the mobile communication module 150 can also be used for information interaction with other devices.
[0068] The modem processor can include a modulator and a demodulator. The modulator is configured to modulate a low-frequency baseband signal to be transmitted into a medium-high frequency signal. The demodulator is configured to demodulate a 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. The low-frequency baseband signal processed by the baseband processor is transmitted to the application processor. The application processor outputs a sound signal through an audio device (not limited to the speaker 170A, the microphone 170B, etc.), or displays an image or a video through the display screen 130. In some embodiments, the modem processor can be a separate device. In other embodiments, the modem processor can be independent of the processor 110, and disposed in the same device as the mobile communication module 150 or other function modules.
[0069] The wireless communication module 160 can provide solutions for wireless communication applications on the electronic device 100, including wireless local area networks (WLANs) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), and infrared (IR) technologies. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via antenna 2, performs frequency modulation and filtering of the electromagnetic wave signals, and sends the processed signal to processor 110. The wireless communication module 160 can also receive signals to be transmitted from processor 110, perform frequency modulation and amplification, and convert them into electromagnetic waves for radiation via antenna 2. In this embodiment, the wireless communication module 160 is used to establish connections with other electronic devices and perform data interaction.
[0070] In addition, the electronic device 100 can implement audio functions through an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, and an application processor, such as music playback and recording. The electronic device 100 can receive key input 190, generating key signal inputs related to user settings and function control. The electronic device 100 can use a motor 191 to generate vibration alerts (such as vibration alerts for incoming calls).
[0071] It should be understood that, in practical applications, electronic device 100 may include more than Figure 3 The number of more or fewer components shown is not limited in the embodiments of this application. The illustrated electronic device 100 is merely an example, and the electronic device 100 may have more or fewer components than shown in the figure, may combine two or more components, or may have different component configurations. The various components shown in the figure may be implemented in hardware, software, or a combination of hardware and software, including one or more signal processing and / or application-specific integrated circuits.
[0072] The software system of electronic device 100 can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. A layered architecture divides the software into several layers, each with a clear role and function. Layers communicate with each other through software interfaces. For example, ... Figure 4As shown, the software architecture can be divided into four layers, from top to bottom, application layer, application framework layer (Framework, FWK), runtime and system library, and (Linux) kernel layer.
[0073] The application layer is the top layer of the operating system, including native applications of the operating system, such as weather, clock, calendar, Bluetooth, music, phone, settings, etc., and can also include third-party applications. The application involved in the embodiments of the present application is referred to as application (application, APP), which is a software program capable of implementing one or more specific functions. Generally, multiple applications can be installed in an electronic device, such as a camera application, a mailbox application, a learning application, etc. The application mentioned below can be a system application installed when the electronic device is shipped, or a third-party application downloaded from the network or obtained from another electronic device during use of the electronic device by the user.
[0074] Of course, for developers, the developer can write an application and install it to this layer. In a possible implementation manner, the application can be developed using Java language, and is completed by calling the application programming interface (application programming interface, API) provided by the application framework layer. The developer can interact with the bottom layer (such as the kernel layer, etc.) of the operating system through the application framework to develop his own application.
[0075] The application framework layer is the API and programming framework of the application layer. The application framework layer can include some pre-defined functions. The application framework layer can include a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, etc.
[0076] The window manager is used to manage the window program. The window manager can obtain the size of the display screen, determine whether there is a status bar, lock the display screen (or screen), intercept the display screen, etc.
[0077] The content provider is used to store and obtain data, and make the data accessible to the application. The data can include files (such as documents, videos, images, audio), text, etc.
[0078] The view system includes visual controls, such as controls for displaying text, pictures, document content, etc. The view system can be used to build an application. The interface in the display window can be composed of one or more views. For example, a display interface including a short message notification icon can include a view for displaying text and a view for displaying pictures.
[0079] The telephony manager is used to provide communication functions of the electronic device. The notification manager enables applications to display notification information in a status bar, which can be used to convey messages of an informative type that can automatically disappear after a brief stay without user interaction.
[0080] The runtime includes a core library and a virtual machine. The runtime is responsible for scheduling and managing the system.
[0081] The core library of the system includes two parts: one part is the function functions that the Java language needs to call, and the other part is the core library of the system. The application layer and the application framework layer run in the virtual machine. Taking Java as an example, the virtual machine executes the Java files of the application layer and the application framework layer into binary files. The virtual machine is used to perform functions such as management of object life cycle, stack management, thread management, security and exception management, and garbage collection.
[0082] The system library can include multiple functional modules. For example: a surface manager, a media library, a three-dimensional graphics processing library (such as OpenGL ES), a two-dimensional graphics engine (such as SGL), an image processing library, etc. The surface manager is used to manage the display subsystem and provides two-dimensional and three-dimensional layer fusion for multiple applications. The media library supports playback and recording of multiple commonly used audio, video formats, and static image files, etc. The media library can support multiple audio and video encoding formats, such as MPEG4, H.564, MP3, AAC, AMR, JPG, PNG, etc. The three-dimensional graphics processing library is used to realize three-dimensional graphics drawing, image rendering, synthesis and layer processing, etc. The two-dimensional graphics engine is a two-dimensional drawing engine.
[0083] The kernel layer provides core system services of the operating system, such as security, memory management, process management, network protocol stack, and driver model, which are implemented based on the kernel layer. The kernel layer also serves as an abstraction layer between hardware and software stacks. This layer has many electronic device-related drivers, including: display drivers; keyboard drivers as input devices; Flash drivers based on memory technology devices; camera drivers; audio drivers; Bluetooth drivers; WiFi drivers, etc.
[0084] It should be understood that the functional services as described above are only examples, and in actual applications, the electronic device can also be divided into more or fewer functional services according to other factors, or the functions of each service can be divided in other ways, or there can be no functional services, but the whole works.
[0085] The scheme provided in the embodiments of the present application can be applied in the scenario of electronic device communication, for example, can be applied in the scenario that the electronic device communicates with a server through another electronic device, or the scenario that the electronic device connects to a network through another electronic device, or the scenario that the electronic device switches the communication mode or the communication link in the communication process with another electronic device. Different communication links correspond to different communication modes. Optionally, the electronic device can be a lightweight non-Linux kernel electronic device, for example, a lightweight sports watch. Optionally, the electronic device can use Lwip.
[0086] For the convenience of description, the communication link switching in the embodiments of the present application is referred to as link switching.
[0087] The method provided in the embodiments of the present application will be described in detail below by taking the scenario that the first electronic device communicates with a server through a second electronic device as an example.
[0088] Optionally, in this scenario, the first electronic device can switch the communication mode (or the communication link) when communicating with the second electronic device in the communication process.
[0089] In some embodiments of the present application, the first electronic device can have far-field communication and / or near-field communication capabilities. For example, the first electronic device can support multiple communication modes such as WiFi communication, Bluetooth communication, mobile communication, universal serial bus (USB) based communication, wireless network card based communication, etc. The link switching of the first electronic device can be the switching between the communication links corresponding to these communication modes, and therefore, the link switching can also be understood as the switching of the communication mode.
[0090] Figure 5 An architecture schematic diagram of a communication system provided in the embodiments of the present application is shown in FIG. 1. As shown in FIG. 1, the communication system at least includes a first electronic device. The communication system can also include at least one other electronic device, for example, a second electronic device as shown in FIG. 2. Figure 5 Figure 5
[0091] The first electronic device can include at least one application, a logic network card, multiple physical drivers, and multiple communication devices. Among the multiple communication devices, different communication devices correspond to different communication modes. Each communication device corresponds to one physical driver in the multiple physical drivers, and the physical drivers corresponding to different communication devices are different. The physical driver corresponding to each communication device is used to drive the communication device. One logic network card can correspond to multiple different physical drivers, and one logic network card can interface with (or interact with) multiple different physical drivers.
[0092] In the communication process, the applications can be used to send data to be sent as a packet to the logical network card. The logical network card can be used to configure a uniform source IP address for the packets from the applications, which is the IP address of the logical network card. The logical network card can send the processed packet to the physical driver. The physical driver can add a source MAC address to the received packet, which is the MAC address of the communication device corresponding to the physical driver. The physical driver can drive the communication device to send the packet processed by the physical driver. When link switching is needed, the first electronic device switches the transmission path of the packet from one physical driver to another physical driver through the logical network card, so as to realize the effect of switching the source MAC address of the packet from the MAC address of one communication device to the MAC address of another communication device, and further realize the effect of switching from the communication mode corresponding to one communication device to the communication mode corresponding to another communication device.
[0093] In one example, as shown in Figure 5 , the first electronic device can include a first application, a logical network card, a first physical driver, a second physical driver, a first communication device and a second communication device. Among them, the first physical driver corresponds to the first communication device, and the first physical driver is used to drive the first communication device. The second physical driver corresponds to the second communication device, and the second physical driver is used to drive the second communication device. The first communication device and the second communication device support different communication modes. For example, the first communication device can support WiFi communication, and the second communication device can support Bluetooth communication. Then the first communication device can be WiFi hardware, and the second communication device can be Bluetooth hardware.
[0094] In some embodiments of the present application, the second electronic device can be any electronic device connected to the first electronic device. As shown in Figure 5 , the second electronic device includes at least a third communication device and a fourth communication device, wherein the third communication device supports the same communication mode as the first communication device, for example, the third communication device and the first communication device can both support WiFi communication mode. Or the third communication device can be the same type of communication device as the first communication device, for example, the third communication device and the first communication device are both WiFi devices. The fourth communication device supports the same communication mode as the second communication device, for example, the fourth communication device and the second communication device can both support Bluetooth communication mode. Or the fourth communication device can be the same type of communication device as the second communication device, for example, the fourth communication device and the second communication device are both Bluetooth devices.
[0095] In the above scenario, the connection method between the first electronic device and the second electronic device is as follows: the first communication device of the first electronic device is connected to the third communication device of the second electronic device, and / or, the second communication device of the first electronic device is connected to the fourth communication device of the second electronic device.
[0096] It should be noted that the communication device described in the embodiments of this application can be a hardware structure capable of realizing far-field or near-field communication functions. The communication device can also be referred to as a physical interface or physical hardware, etc.
[0097] based on Figure 5 The communication system shown, taking a scenario where a first electronic device connects to a server via a second electronic device as an example, provides a communication method that can be referred to in this application embodiment. Figure 6 ,like Figure 6 As shown, the method may include:
[0098] S601: The first application in the first electronic device generates the first message.
[0099] In some embodiments of this application, the first electronic device may employ Lwip.
[0100] The first message includes data that the first application needs to send to the server via the second electronic device.
[0101] S602: The first application sends the first message to the logical network card in the first electronic device.
[0102] In some embodiments of this application, the logical network interface card (NIC) can be generated by any physical driver in the first electronic device. After any physical driver generates the logical NIC, other physical drivers can detect its existence and interface with it (or establish a connection). If the interface is successful, other physical drivers do not generate new NICs and can interact with the existing logical NIC in subsequent processes. For example, the logical NIC can be generated by the first physical driver, and the second physical driver can interface with it. Based on this method, one logical NIC can interface with multiple physical drivers.
[0103] S603: The logical network card adds the source IP address and destination IP address to the first packet to obtain the second packet; where the source IP address is the IP address of the logical network card, and the destination IP address can be the IP address of the server.
[0104] S604: The logical network card sends the second message to the first physical driver in the first electronic device.
[0105] S605: The first physical driver adds a source MAC address and a destination MAC address to the second packet to obtain a third packet; the source MAC address is the MAC address of the first communication device, and the destination MAC address is the MAC address of the third communication device of the second electronic device.
[0106] S606: The first physical driver sends the third packet to the first communication device in the first electronic device.
[0107] S607: The first communication device sends the third packet to the second electronic device.
[0108] The second electronic device can forward the third packet to the server after receiving the third packet.
[0109] The first communication device sends the third packet to the second electronic device, which can be that the first communication device sends the third packet to the third communication device of the second electronic device.
[0110] In some embodiments of the present application, the first electronic device can determine that the first communication device and the third communication device are in a communication connection state before generating the first packet through the first application or before sending the third packet to the second electronic device through the first communication device, so as to ensure that the first communication device can successfully send the third packet to the third communication device.
[0111] In some embodiments of the present application, the second electronic device described above can be an electronic device based on a linux kernel, or a lightweight electronic device without a linux kernel.
[0112] Optionally, when the second electronic device is a lightweight electronic device without a linux kernel, as shown in Figure 5 The second electronic device can include a second application, a logical network card, a third physical driver, a fourth physical driver, the third communication device and the fourth communication device described above. The third physical driver corresponds to the third communication device, and the third physical driver can be used to drive the third communication device. The fourth physical driver corresponds to the fourth communication device, and the fourth physical driver can be used to drive the fourth communication device. In this scenario, the specific structure and function of the second electronic device and the communication method can refer to the description of the specific structure and function of the first electronic device and the communication method above, which will not be described in detail here.
[0113] Example 1, in one example, taking the first electronic device as a smart watch and the second electronic device as a mobile phone as an example, the smart watch and the mobile phone can communicate through WiFi or Bluetooth. The mobile phone can share the network with the smart watch, and the smart watch can access the network through the mobile phone. The smart watch and the mobile phone can interact through WiFi or Bluetooth communication. Figure 7The logic network card of the smart watch can be denoted as D0, as shown in the schematic diagram in (a) of FIG. 1. The first communication device of the smart watch can be a WiFi hardware interface, which can be denoted as Figure 7 WLAN0, as shown in the schematic diagram in (a) of FIG. 1. The second communication device of the smart watch can be a Bluetooth hardware interface, which can be denoted as Figure 7 BT0, as shown in the schematic diagram in (a) of FIG. 1. The mobile phone can be connected to the network side through a network interface. The third communication device of the mobile phone can be a WiFi hardware interface, which can be denoted as Figure 7 WLAN1, as shown in the schematic diagram in (a) of FIG. 1. The fourth communication device of the mobile phone can be a Bluetooth hardware interface, which can be denoted as Figure 7 BT1, as shown in the schematic diagram in (a) of FIG. 1. In this scenario, the smart watch and the mobile phone can establish a communication connection through WLAN0 and WLAN1, and / or the smart watch and the mobile phone can establish a communication connection through BT0 and BT1.
[0114] For example, the IP address of D0 can be 10.0.0.1, and the IP address of the network side can be 1.1.1.1. The MAC address of WLAN0 can be 1:2:3:4, and the MAC address of WLAN1 can be 5:5:5:5. The MAC address of BT0 can be 5:6:7:8, and the MAC address of BT1 can be 9:9:9:9.
[0115] When the smart watch sends a packet to the mobile phone through the first communication device, i.e., the WiFi hardware interface, as shown in (a) of FIG. 1, the first communication device sends the packet in a WiFi manner, in which the source IP address is 10.0.0.1, the destination IP address is 1.1.1.1, the source MAC address is 1:2:3:4, and the destination MAC address is 5:5:5:5. Figure 8
[0116] The second packet and the fourth packet described above can be the same packet or different packets.
[0117] S608: The first application generates a fourth packet.
[0118] The fourth packet includes data that the first application needs to send to the server through the second electronic device.
[0119] S609: The first application sends the fourth packet to the logic network card.
[0120] S610: The logic network card adds a source IP address and a destination IP address to the fourth packet to obtain a fifth packet, in which the source IP address is the IP address of the logic network card, and the destination IP address can be the IP address of the server.
[0121] S611: The logical network card sends the fifth message to the second physical driver.
[0122] S612: The second physical driver adds a source MAC address and a destination MAC address to the fifth message to obtain a sixth message; the source MAC address is the MAC address of the second communication device, and the destination MAC address is the MAC address of the fourth communication device of the second electronic device.
[0123] S613: The second physical driver sends the sixth message to the second communication device.
[0124] S614: The second communication device sends the sixth message to the second electronic device.
[0125] After the second electronic device receives the sixth message, the second electronic device can forward the sixth message to the server.
[0126] The second communication device sends the sixth message to the second electronic device, and specifically, the second communication device sends the sixth message to the fourth communication device of the second electronic device.
[0127] In some embodiments of the present application, before the first electronic device generates the fourth message through the first application or before the second communication device sends the sixth message to the second electronic device, the second communication device and the fourth communication device can be determined to be in a communication connection state, so as to ensure that the second communication device can successfully send the sixth message to the fourth communication device.
[0128] In some embodiments of the present application, the above steps S608-S614 can be executed after the above step S607, or the above steps S608-S614 can be executed before the above step S601, or the above steps S608-S614 can be executed synchronously with the above steps S601-S607. When the above steps S608-S614 are executed synchronously with the above steps S601-S607, the first message and the fourth message can be the same message or different messages. The electronic device can send the same message or different messages of the same application through different communication devices synchronously.
[0129] In the method provided in the above embodiment, the first application, the logical network card, the first physical driver and the first communication device can constitute a first communication link corresponding to a first communication mode (i.e., a communication mode supported by the first communication device), and the first application, the logical network card, the second physical driver and the second communication device can constitute a second communication link corresponding to a second communication mode (i.e., a communication mode supported by the second communication device). When it is needed to switch from the first communication mode to the second communication mode or switch from the first communication link to the second communication link, the electronic device can switch from executing the method corresponding to steps S601-S607 to executing the method corresponding to steps S608-S614.
[0130] In some embodiments of the present application, the first electronic device can determine that the link switching (or the communication mode switching) needs to be performed in a specific scenario or under a specific condition, and then switch from executing the method corresponding to step S601 to executing the method corresponding to step S602. Specifically, during the communication process, the first electronic device can collect at least one piece of information for representing the communication quality of each communication link or communication device, such as the state of each communication link (e.g., the state of the first communication link and the second communication link), the idle bandwidth of each communication device, the throughput percentage, etc., through each physical driver, and determine whether a set switching condition is met according to the collected at least one piece of information. If yes, the link switching is determined to be performed, otherwise, the link switching is not performed. The set switching condition can be pre-configured by the system or pre-configured into the electronic device by the user.
[0131] For example, the set switching condition can be that the idle bandwidth of the first communication device is lower than a set threshold, and the first electronic device can determine to perform the link switching when it is determined that the idle bandwidth of the first communication device is lower than the set threshold. For another example, the set switching condition can be that the idle bandwidth of the first communication device is lower than the idle bandwidth of the second communication device, and the first electronic device can determine to perform the link switching when it is determined that the idle bandwidth of the first communication device is lower than the idle bandwidth of the second communication device. For yet another example, the set switching condition can be that the first communication link is disconnected, and the first electronic device can determine to perform the link switching when it is determined that the first communication link is disconnected (e.g., disconnected due to a fault, etc.).
[0132] Example 2, in the scenario described in the above example 1, the first application in the first electronic device (i.e., the smart watch) has a communication connection with the logical network card, and all data to be sent by the first application can be sent to the logical network card for subsequent processing. For example, Figure 7As shown in diagram (b), when the communication connection between WLAN0 and WLAN1 is broken, WLAN0 cannot send messages to the second electronic device (i.e., the mobile phone), and the communication link corresponding to WLAN0 in the first electronic device is cut off, requiring the first electronic device to switch communication links. However, the communication connection between the first application and the logical network card is not broken, so the first application can still send the messages to be sent to the logical network card for processing.
[0133] Optionally, the first electronic device can switch from sending messages to the second electronic device using the first communication device to sending messages to the second electronic device using the second communication device, thereby switching from the communication link corresponding to the first communication device to the communication link corresponding to the second communication device. For example... Figure 7 As shown in diagram (c), the first electronic device can send a message to BT1 via BT0, and then send the message to the second electronic device. When the first electronic device sends a message to the second electronic device through the second communication device, as shown in the diagram... Figure 8 As shown in the schematic diagram (b), the source IP address in the message sent by the second communication device via Bluetooth is still 10.0.0.1, the destination IP address can still be 1.1.1.1, the source MAC address is 5:6:7:8, and the destination MAC address is 9:9:9:9.
[0134] The above Figure 8 The content shown in diagram (a) is the address information in the message sent by the first electronic device before the link switch. Figure 8 The diagram in (b) shows the address information in the message sent by the first electronic device after the link switch. Before and after the link switch, the source IP address in the message remains unchanged; therefore, the TCP connection established based on the IP address will not be interrupted, and the interaction between the first application and the logical network card is unaffected. Before and after the link switch, the source MAC address in the message changes depending on the communication device being switched. The first or second physical driver only needs to add the source MAC address to the message, match the corresponding communication device based on the source MAC address, and send the message to the corresponding communication device to achieve the switching of the communication device. Matching the source IP address is not required in this process. In summary, based on the above method, by encapsulating the same source IP address and different source MAC addresses in the message, the switching of the communication device can be achieved without the first application's awareness, i.e., seamless link switching, thereby improving the client's processing efficiency and communication efficiency.
[0135] It should be understood that when it is needed to switch from the second communication mode to the first communication mode or from the second communication link to the first communication link, the electronic device can switch from the method corresponding to steps S608-S614 to the method corresponding to steps S601-S607. Details are not described herein again.
[0136] In some embodiments of the present application, the first electronic device can further comprise a second application, and the first application in steps S608-S614 can be replaced by the second application.
[0137] In some embodiments of the present application, after step S607, the first electronic device can further execute the following steps: the second application generates a seventh packet and sends it to the logical network card. The logical network card adds a source IP address and a destination IP address to the seventh packet, and sends an eighth packet obtained to the first physical driver, wherein the source IP address is the IP address of the logical network card, and the destination IP address can be the IP address of the server. The first physical driver adds a source MAC address and a destination MAC address to the eighth packet to obtain a ninth packet, wherein the source MAC address is the MAC address of the first communication device, and the destination MAC address is the MAC address of the third communication device. The first physical driver drives the first communication device to send the ninth packet to the second electronic device, so that the second electronic device sends the ninth packet to the server. Details of the method can be referred to the method of sending the first packet by the first communication device described in the above embodiments, which are not described herein again. Based on the method, the first electronic device can send different packets of different applications through the same communication device.
[0138] The method provided by the above embodiments can achieve link switching without sensing in a lightweight electronic device without the help of the linux kernel, that is, the same source IP address and different source MAC addresses are encapsulated for the same IP packet or different IP packets, and the packets are sent through different communication devices. The method solves the problem that the lightweight device cannot perform link switching without sensing, and achieves the same link switching experience as the rich device (for example, an electronic device based on the linux kernel). In addition, in the above method, the physical driver has the function of waking up the communication device, so the communication device can remain in a sleep state and be pulled up by the physical driver when needed, so the power consumption of the communication device is low. In the above method, the selection of the communication device is independent of the IP address, so the logical network card can encapsulate the same IP address for the same packet or different packets and send them to different communication devices for processing, thereby achieving the effect of multi-path concurrency.
[0139] It should be noted that the source IP address described in the above embodiments of the present application is the IP address of the logical network card of the first electronic device, unless otherwise specified.
[0140] It should be understood that the communication system architecture described above is only an example, and in actual applications, the electronic device can also be divided into more or fewer functional services according to other factors, or the functions of each service can be divided in other ways, or there can be no functional services, but work as a whole. The implementation process provided in the above embodiments is only an example of the method flow applicable to the embodiments of the present application, and the execution order of each step can be adjusted accordingly according to actual needs, and other steps can be added or some steps can be reduced.
[0141] Based on the above embodiments and the same technical concept, the embodiments of the present application also provide a communication method, as shown in Figure 9 The method can include:
[0142] S901: A first application in a first electronic device generates a first packet; wherein the first electronic device communicates with a server through a second electronic device, the first electronic device includes a first application, a logical network card, a first physical driver and a corresponding first communication device, a second physical driver and a corresponding second communication device; wherein the first communication device and the second communication device support different communication modes.
[0143] In some embodiments of the present application, the first electronic device can use a lightweight Internet Protocol (Lwip).
[0144] In some examples, the first electronic device can be the first electronic device described in the foregoing embodiments, and the second electronic device can be the second electronic device described in the foregoing embodiments. The functional structure of the first electronic device and the second electronic device can be referred to the related description in the foregoing embodiments.
[0145] S902: The logical network card in the first electronic device adds a source Internet Protocol (IP) address to the first packet, and sends the obtained second packet to the selected target physical driver; wherein the source IP address is the IP address of the logical network card; and the target physical driver is the first physical driver or the second physical driver.
[0146] In some embodiments of the present application, the logical network card can select the target physical driver based on the current scenario information before sending the obtained second packet to the selected target physical driver. Specifically, the logical network card can select the target communication device from the first communication device and the second communication device according to the current scenario information, and take the physical driver corresponding to the target communication device as the target physical driver; wherein the current scenario information includes information representing the communication quality of the first communication device and / or information representing the communication quality of the second communication device.
[0147] Optionally, the logical network card can select the target communication device according to the current scenario information in the manner described in the foregoing embodiments. For example, the logical network card can determine the target communication device as the communication device after switching when it is determined that the current scenario satisfies the set switching condition according to the method described in the foregoing embodiments.
[0148] For example, the logical network card can determine the first communication device as the target communication device and the first physical driver as the target physical driver when it is determined that the idle bandwidth of the first communication device is higher than a set threshold. For another example, the logical network card can determine the second communication device as the target communication device and the second physical driver as the target physical driver when it is determined that the idle bandwidth of the first communication device is lower than the idle bandwidth of the second communication device. For yet another example, the logical network card can determine the second communication device as the target communication device and the second physical driver as the target physical driver when it is determined that the first communication link corresponding to the first communication device is cut off.
[0149] In some embodiments of the present application, the logical network card can add a destination IP address to the first packet after adding the source IP address to the first packet, and before sending the obtained second packet to the selected target physical driver, wherein the obtained second packet includes the first packet, the source IP address and the destination IP address; wherein the destination IP address is the IP address of the server.
[0150] S903: The target physical driver in the first electronic device adds a source MAC address to the second packet, and drives the corresponding communication device to send the obtained third packet to the second electronic device, so that the second electronic device sends the third packet to the server; wherein the source MAC address is the MAC address of the communication device corresponding to the target physical driver.
[0151] In some embodiments of the present application, after the target physical driver adds the source MAC address to the second packet, the target physical driver can also add a destination MAC address to the second packet before the corresponding communication device of the target physical driver sends the obtained third packet to the second electronic device, wherein the obtained third packet includes the second packet, the source MAC address and the destination MAC address; the destination MAC address is the MAC address of the third communication device of the second electronic device, and the third communication device supports the same communication mode as the communication device corresponding to the target physical driver. In one example, the first electronic device and the second electronic device can be the first electronic device and the second electronic device shown in Figure 5 FIG. 1, respectively, and the target physical driver can be the first physical driver shown in Figure 5 FIG. 1. In this case, the target communication device can be the first communication device shown in Figure 5 FIG. 1, and the third communication device of the second electronic device can be the third communication device shown in Figure 5 FIG. 1. In another example, the first electronic device and the second electronic device can be the first electronic device and the second electronic device shown in Figure 5 FIG. 1, respectively, and the target physical driver can be the second physical driver shown in Figure 5 FIG. 1. In this case, the target communication device can be the second communication device shown in Figure 5 FIG. 1, and the third communication device of the second electronic device can be the fourth communication device shown in Figure 5 FIG. 1.
[0152] In some embodiments of the present application, before the target physical driver sends the obtained third packet to the second electronic device, the target physical driver can first determine whether the corresponding communication device is communicatively connected to the third communication device, so as to ensure that the third packet is successfully sent to the second electronic device.
[0153] In some embodiments of the present application, when the first electronic device executes the method described in steps S901-S903, or after the first electronic device executes the method described in steps S901-S903, the first electronic device can further execute the following method: the first application generates a fourth packet; when the target physical drive is the first physical drive, the logical network card adds a source IP address to the fourth packet, and sends a fifth packet obtained to the second physical drive; the second physical drive adds a source MAC address to the fifth packet, and drives the second communication device to send a sixth packet obtained to the second electronic device, so that the second electronic device sends the sixth packet to the server; wherein the source MAC address added to the fifth packet by the second physical drive is the MAC address of the second communication device. Based on this method, the first electronic device can synchronously send different packets of the first application through the first communication device and the second communication device, or send different packets of the first application in sequence. In some embodiments of the present application, when the target physical drive is the second physical drive, the first electronic device can also drive the second communication device to send the packet of the first application through the second physical drive. For details, refer to the above method implementation, which will not be repeated here. For the specific implementation and extended implementation of the above method, refer to the above method for processing the first packet generated by the first application, which will not be described in detail here.
[0154] In some embodiments of the present application, the first electronic device can further include a second application; after the target physical drive drives the corresponding communication device to send the third packet obtained to the second electronic device, the first electronic device can further execute the following method: the second application generates a seventh packet; the logical network card adds a source IP address to the seventh packet, and sends an eighth packet obtained to the target physical drive; the target physical drive adds a source MAC address to the eighth packet, and drives the corresponding communication device to send a ninth packet obtained to the second electronic device, so that the second electronic device sends the ninth packet to the server. For the specific implementation and extended implementation of this method, refer to the above method for processing the first packet generated by the first application, which will not be described in detail here.
[0155] In the above method, the specific steps performed by the first electronic device and the second electronic device can refer to the related description in the foregoing embodiments, which will not be repeated here.
[0156] Based on the above embodiments and the same technical concept, the present application further provides an electronic device for implementing the communication method provided by the embodiments of the present application. As shown in Figure 10 The electronic device 1000 can include a memory 1001, one or more processors 1002, and one or more computer programs (not shown in the figure). The above devices can be coupled through one or more communication buses 1003. Optionally, the electronic device 1000 can further include a display screen 1004.
[0157] The memory 1001 stores one or more computer programs (codes) including computer instructions, and the one or more processors 1002 invoke the computer instructions stored in the memory 1001 to enable the electronic device 1000 to perform the communication method provided in the embodiments of the present application.
[0158] In specific implementations, the memory 1001 can include a high-speed random access memory, and can also include a non-volatile memory, such as one or more disk storage devices, flash memory devices, or other non-volatile solid-state storage devices. The memory 1001 can store an operating system (hereinafter referred to as a system), such as an ANDROID, IOS, WINDOWS, or LINUX embedded operating system. The memory 1001 can be used to store the implementation program of the embodiments of the present application. The memory 1001 can also store a network communication program, which can be used to communicate with one or more additional devices, one or more user devices, and one or more network devices.
[0159] The one or more processors 1002 can be a general-purpose central processing unit (CPU), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits for controlling the execution of the programs of the present application.
[0160] The display screen 1004 is used to display application interfaces and other related user interfaces.
[0161] It should be noted that, Figure 10 The electronic device 1000 provided in the embodiments of the present application is only one implementation, and in actual applications, the electronic device 1000 can also include more or fewer components. For details, refer to the specific structures and descriptions shown in Figure 3 There is no limitation here.
[0162] Based on the above embodiments and the same technical concept, the embodiments of the present application also provide a computer readable storage medium storing a computer program, when the computer program runs on a computer, the computer program enables the computer to perform the method provided in the above embodiments.
[0163] Based on the above embodiments and the same technical concept, the embodiments of the present application also provide a computer program product including a computer program or instructions, when the computer program or instructions run on a computer, the computer program or instructions enable the computer to perform the method provided in the above embodiments.
[0164] The method provided by the embodiments of the present application can be implemented by software, hardware, firmware or any combination thereof, in whole or in part. When implemented by software, the method can be implemented in the form of a computer program product, in whole or in part. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the whole or part of the process or function according to the embodiments of the present application is generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, a network device, a user equipment or other programmable apparatus. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center through a wired (such as coaxial cable, optical fiber, digital subscriber line (DSL) or wireless (such as infrared, wireless, microwave, etc.)) manner. The computer-readable storage medium can be any available medium accessible by a computer or a data storage device such as a server, data center, etc. integrated with one or more available media sets. The available media can be a magnetic medium (such as a floppy disk, a hard disk, a magnetic tape), an optical medium (such as a digital video disc (DVD), or a semiconductor medium (such as an SSD), etc.
[0165] Obviously, those skilled in the art can make various modifications and variations to the present application without departing from the scope of the present application. Thus, if these modifications and variations of the present application belong to the scope of the claims of the present application and their equivalents, the present application also intends to include these modifications and variations.
Claims
1. A communication method applied to a first electronic device, characterized in that, The first electronic device communicates with the server through a second electronic device. The first electronic device includes a first application, a logical network card, a first physical driver and a corresponding first communication device, a second physical driver and a corresponding second communication device; wherein the first communication device and the second communication device support different communication methods. The method includes: The first application generates the first message; The logical network interface card (NIC) adds the source Internet Protocol (IP) address to the first packet and sends the resulting second packet to the selected target physical driver; wherein, the source IP address is the IP address of the logical NIC; and the target physical driver is either the first physical driver or the second physical driver. The target physical driver adds a source media access control MAC address to the second message and drives the corresponding communication device to send the obtained third message to the second electronic device, so that the second electronic device sends the third message to the server; wherein, the source MAC address is the MAC address of the communication device corresponding to the target physical driver.
2. The method as described in claim 1, characterized in that, After the logical network interface card adds the source Internet Protocol (IP) address to the first packet, and before sending the resulting second packet to the selected target physical driver, the method further includes: The logical network interface card adds a destination IP address to the first packet; wherein, the destination IP address is the IP address of the server; After the target physical driver adds the source MAC address to the second packet, and before the corresponding communication device sends the obtained third packet to the second electronic device, the method further includes: The target physical driver adds a destination MAC address to the second message; wherein the destination MAC address is the MAC address of the third communication device of the second electronic device, and the third communication device supports the same communication method as the communication device corresponding to the target physical driver.
3. The method as described in any one of claims 2, characterized in that, Before driving the corresponding communication device to send the obtained third message to the second electronic device, the method further includes: The communication device corresponding to the target physical drive is determined to be connected to the third communication device.
4. The method according to any one of claims 1 to 3, characterized in that, Before sending the obtained second message to the selected target physical driver, the method further includes: Based on the current scenario information, a target communication device is selected from the first communication device and the second communication device; wherein, the current scenario information includes: information for characterizing the communication quality of the first communication device and / or information for characterizing the communication quality of the second communication device; The physical driver corresponding to the target communication device is used as the target physical driver.
5. The method according to any one of claims 1 to 4, characterized in that, The method further includes: The first application generates the fourth message; When the target physical driver is the first physical driver, the logical network card adds the source IP address to the fourth packet and sends the resulting fifth packet to the second physical driver; The second physical driver adds a source MAC address to the fifth message and drives the second communication device to send the obtained sixth message to the second electronic device, so that the second electronic device sends the sixth message to the server; wherein, the source MAC address added by the second physical driver to the fifth message is the MAC address of the second communication device.
6. The method according to any one of claims 1 to 5, characterized in that, The first electronic device further includes a second application; after driving the corresponding communication device to send the obtained third message to the second electronic device, the method further includes: The second application generates the seventh message; The logical network card adds the source IP address to the seventh packet and sends the resulting eighth packet to the target physical driver; The target physical driver adds the source MAC address to the eighth message and drives the corresponding communication device to send the obtained ninth message to the second electronic device, so that the second electronic device sends the ninth message to the server.
7. The method according to any one of claims 1 to 6, characterized in that, The first electronic device uses the lightweight Internet Protocol Lwip.
8. An electronic device, characterized in that, The electronic device includes a memory and one or more processors; The memory is used to store computer program code, which includes computer instructions; when the computer instructions are executed by the one or more processors, the electronic device performs the method as described in any one of claims 1 to 7.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when run on an electronic device, causes the electronic device to perform the method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Message processing method and device, and storage medium
CN114157684A
Low-resource-overhead TCP / IP (Transmission Control Protocol / Internet Protocol) protocol stack device based on field programmable gate array
CN116708604A