Communication method and electronic equipment
By using logical network cards to add fixed source IP addresses and different source MAC addresses to packets in lightweight non-linux kernel electronic devices, the invisible switching of communication methods is achieved, solving the problem that devices need application participation during switching, and improving communication efficiency and client processing efficiency.
Patent Information
- Application Number
- CN202311271179.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-27
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2043-09-27
AI Technical Summary
Lightweight non-linux kernel electronic devices require application participation when switching communication methods, resulting in reduced client processing efficiency and low communication efficiency.
The logical network card adds fixed source IP addresses and different source MAC addresses to the packets, so as to realize invisible switching of communication methods and avoid applications participating in the switching process.
The invisible switching of communication methods is realized, the communication efficiency of electronic devices is improved, the processing burden of clients is reduced, and the power consumption of communication devices is reduced.
Smart Images

Figure CN119729679A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of electronic equipment, and in particular to a communication method and electronic equipment. Background Art
[0002] Most electronic devices can currently communicate with other electronic devices through a variety of communication methods (such as WiFi communication methods, Bluetooth communication methods, mobile communication methods, etc.), and can also switch the communication methods used during the communication process. Among them, different communication methods correspond to different communication links, and switching the communication method of the electronic device is to switch the communication link. At present, lightweight non-Linux kernel electronic devices (such as electronic devices using lightweight Internet protocol (Lwip)) require application participation when switching communication methods, which will reduce the processing efficiency of the client, resulting in a poor client experience, and will also affect the overall communication efficiency of the electronic device. Summary of the invention
[0003] The present application provides a communication method and an electronic device for realizing seamless switching of communication modes. The method can be applied to lightweight non-Linux kernel electronic devices to improve the communication efficiency of the electronic devices.
[0004] In a first aspect, an embodiment of the present application provides a communication method, which is 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 drive and a corresponding first communication device, a second physical drive 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 message; the logical network card adds a source Internet Protocol IP address to the first message, and sends the obtained second message to the selected target physical drive; wherein the source IP address is the IP address of the logical network card; the target physical drive is the first physical drive or the second physical drive; the target physical drive 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 drive.
[0005] In this method, during the communication process, the first electronic device can use the IP address of the logical interface added to the message to be sent through the logical interface as the source IP address, and the source MAC address added to the message to be sent by the first electronic device is the MAC address of the communication device to be used. Based on this method, when the first electronic device sends a message, it can switch the communication device used by switching the source MAC address added to the message, thereby realizing the switching of the communication mode. At the same time, the source IP address of the message is fixed to 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 mode, and the switching of the communication mode does not affect the interaction process between the first application and the logical interface. The first application only needs to send the required data to the logical interface as a message each time, so the switching of the communication mode is imperceptible to the first application, that is, the client, so based on the above method, the senseless switching of the communication mode can be realized, thereby improving the communication efficiency. The above method can be applied to the communication mode switching scenario in lightweight electronic devices, and can realize the senseless switching of the communication mode on lightweight devices without the help of the Linux kernel, thereby realizing the same communication mode switching experience of lightweight devices and rich devices such as electronic devices based on the Linux kernel. In addition, in the above method, the physical driver has the function of waking up the corresponding communication device, so the communication device can remain in a dormant state and be pulled up by the physical driver when needed, so the power consumption of the communication device is low.
[0006] In one possible design, after the logical network card adds the source Internet Protocol IP address to the first message, before sending the obtained second message to the selected target physical drive, the method further includes: the logical network card adds a destination IP address to the first message; wherein the destination IP address is the IP address of the server; after the target physical drive adds the source MAC address to the second message, before the corresponding communication device of the driver sends the obtained third message to the second electronic device, the method further includes: the target physical drive adds the destination MAC address to the second message; wherein the destination MAC address is the MAC address of a 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 drive.
[0007] In this method, the logical network card can add a destination IP address to the message to be sent, and the target physical driver can add a destination MAC address to the message to be sent, which can further improve the success rate of message transmission.
[0008] In one possible design, before the communication device corresponding to the driver sends the obtained third message to the second electronic device, the method further includes: determining that the communication device corresponding to the target physical driver is in communication connection with the third communication device. This method can ensure that the third message can be successfully transmitted to the second electronic device.
[0009] In one possible design, before sending the obtained second message to the selected target physical driver, the method further includes: selecting a target communication device from the first communication device and the second communication device according to current scene information; wherein the current scene 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; and using the physical driver corresponding to the target communication device as the target physical driver. Based on this method, the logical network card can select the appropriate physical driver and communication device for the current scene to send messages according to the communication quality of different communication devices in the current scene, thereby improving communication quality and efficiency.
[0010] In one possible design, the method also 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 the obtained fifth message to the second physical drive; the second physical drive adds the 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.
[0011] In the above method, the source IP address is fixed, so the selection of the physical driver and the corresponding communication device does not depend on the source IP address. Therefore, the logical network card can encapsulate different messages of the same application with the same source IP address and send them to different physical drivers and corresponding communication devices for processing, thereby achieving a multi-channel concurrent effect.
[0012] In one possible design, the first electronic device also includes a second application; after driving the corresponding communication device to send the obtained third message to the second electronic device, the method also includes: the second application generates a seventh message; the logical network card adds the source IP address to the seventh message, and sends the 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 the obtained ninth message to the second electronic device, so that the second electronic device sends the ninth message to the server.
[0013] In the above method, the source IP address is fixed, so the selection of the physical driver and the corresponding communication device does not depend on the source IP address. Therefore, the logical network card can encapsulate different messages of different applications with the same source IP address and send them to the same physical driver and the corresponding communication device for processing, thereby achieving the effect of sending messages of different applications through the same communication device.
[0014] In a possible design, the first electronic device uses a lightweight Internet protocol Lwip. Based on the above method, it is possible to realize a seamless switching of the communication mode in the Lwip device, thereby improving the communication efficiency of the Lwip device.
[0015] In a second aspect, the present application provides an electronic device, comprising a memory and one or more processors; wherein the memory is used to store computer program code, and the computer program code comprises computer instructions; when the computer instructions are executed by the one or more processors, the electronic device executes the method described in the above-mentioned 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 runs on an electronic device, the electronic device executes 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 executes 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, wherein instructions are stored in the memory; 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 it can include a chip and other discrete devices.
[0019] The beneficial effects of the second to fifth aspects mentioned above can be referred to the beneficial effects of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 A schematic diagram of the system architecture of an electronic device with a Linux kernel;
[0021] Figure 2 A schematic diagram of the system architecture of an electronic device based on Lwip;
[0022] Figure 3 A schematic diagram of the hardware architecture of an electronic device provided in an embodiment of the present application;
[0023] Figure 4 A schematic diagram of a software architecture of an electronic device provided in an embodiment of the present application;
[0024] Figure 5 A schematic diagram of the architecture of a communication system provided in an embodiment of the present application;
[0025] Figure 6 A schematic diagram of a communication method provided in an embodiment of the present application;
[0026] Figure 7 A schematic diagram of a communication method provided in an embodiment of the present application;
[0027] Figure 8 A schematic diagram of message address information provided in an embodiment of the present application;
[0028] Fig. 9 A schematic diagram of a communication method provided in an embodiment of the present application;
[0029] Fig.10 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. 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 accompanying drawings.
[0031] In the description of the embodiments of the present application, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features.
[0032] To facilitate understanding, exemplary descriptions of concepts related to the present application are provided for reference.
[0033] 1) Electronic equipment, which may be equipment with communication functions. In the embodiments of the present application, the electronic equipment may also be referred to as a terminal or a terminal device.
[0034] In some embodiments of the present application, the electronic device may be a portable device, such as a wearable device with a wireless communication function (for example, a watch, a bracelet, a helmet, a headset, etc.), a smart home device (for example, a smart speaker, etc.), a workshop equipment, a wireless terminal in industrial control, a wireless terminal in self driving, a wireless terminal in remote medical surgery, a wireless terminal in a smart grid, a wireless terminal in transportation safety, a wireless terminal in a smart city, or a wireless terminal in a smart home, a flying device (for example, a drone), etc.
[0035] Among them, a wearable device is a portable device that a user can wear directly on the body or integrate into the user's clothes or accessories.
[0036] In some embodiments of the present application, the electronic device may also be a portable terminal device that also includes other functions. Exemplary embodiments of the portable terminal device include but are not limited to: Or a portable terminal device of other operating systems. The portable terminal device may also be other portable terminal devices, or may not be a portable terminal device but other devices such as embedded devices.
[0037] 2) Lightweight Internet Protocol (Lwip) is a small open source transmission control protocol (TCP) / internet protocol (IP) protocol stack. The focus of Lwip is to reduce the use of random access memory (RAM) while maintaining the main functions of the TCP protocol, and then use a small amount of (RAM) resources to achieve a relatively complete TCP / IP protocol stack. Lwip can run with or without operating system support.
[0038] 3) Logical network card refers to a virtual network card that can realize data exchange functions but does not exist physically and needs to be established through configuration. The logical network card has an IP address.
[0039] It should be understood that in the embodiments of the present application, "at least one" refers to one or more, and "plurality" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the associated objects before and after are in an "or" relationship. "At least one of the following" or similar expressions refers 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, c can be single or multiple.
[0040] Currently, electronic devices using the Linux kernel can achieve a senseless switch when switching the communication mode, that is, the communication mode is switched without the client being aware of the switch, so the communication efficiency is relatively high. Detailed description is given below.
[0041] Figure 1 The following is a possible system architecture diagram of an electronic device with a Linux kernel. Figure 1 As shown in, the electronic device of the Linux kernel may include an application, a logical driver, a logical interface, an extended Berkeley packet filter (eBPF), a physical driver 1, a communication device 1, a physical driver 2, and a communication device 2. Among them, the logical driver is used to drive the logical interface, the physical driver 1 is used to drive the communication device 1, and the physical driver 2 is used to drive the communication device 2. The communication device 1 and the communication device 2 can communicate with other electronic devices through different communication methods. For example, the communication device 1 can communicate with other electronic devices through a Bluetooth communication method, and the communication device 2 can communicate with other electronic devices through a WiFi communication method.
[0042] When the electronic device uses the communication method corresponding to the communication device 1 for communication, the message generated by the application can be sent to the logical interface, and the logical interface can add the source IP address and the destination IP address to the message, wherein the source IP address is the IP address of the logical interface, and the destination IP address is the IP address of other electronic devices that need 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 the source media access control (MAC) address and the destination MAC address to the message. Among them, 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 other electronic devices that need to receive the message. Among them, since the IP address and the MAC address are bound in the Linux system, when the eBPF adds the source MAC address to the message, it is necessary to modify the source IP address in the message to the IP address of the communication device 1 at the same time, that is, to modify the source IP address 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 using the communication method corresponding to the communication device 2 can be implemented by referring to the process of the electronic device communicating using the communication method corresponding to the communication device 1, which will not be described in detail here.
[0043] When the electronic device switches from using the communication method corresponding to communication device 1 to using the communication method corresponding to communication device 2 for communication, the processing method after the application generates 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 establishing multiple transmission channels. The processing method of the logical interface for the received message has not changed either. It still adds the address of the logical interface as the source IP address to the message and sends the message to eBPF. The processing of the received message by eBPF is switched from "changing the source IP address from the IP address of the logical interface to the IP address of communication device 1" to "changing the source IP address from the IP address of the logical interface to the IP address of communication device 2", and the forwarding path of the processed message by eBPF is switched from "sending to communication device 1" to "sending to communication device 2". In the above process, the application does not need to switch the processing method and communication path, the application is continuously connected to the logical interface, and the application does not freeze during the switching process. Therefore, the switching of the communication method is imperceptible to the application (i.e., the client) and does not affect the client experience.
[0044] Although the above-mentioned electronic device based on the Linux kernel can realize the senseless switching of the communication mode, it needs to rely on the virtual network card of the Linux kernel (i.e. the above-mentioned logical interface), eBPF and other structures, and relies on the network card redirection function of eBPF (i.e. the function of resetting the network card IP address) to achieve, so it cannot be applied to lightweight non-Linux kernel electronic devices. In addition, in the above method, the logical interface only provides an IP address and does not carry (i.e., does not save) data, so the message received by the logical interface will be directly forwarded to eBPF, and eBPF does not have the function of waking up the communication device, so the communication device needs to always remain awake, so that when eBPF sends the message to the communication device, the communication device can receive and process the message, so the power consumption of the communication device is large. In the above method, the source IP address set by eBPF for the message is the IP address of the communication device, and eBPF only sends the message to a communication device corresponding to the source IP address, so only one communication device works at the same time, and multi-channel concurrency cannot be achieved.
[0045] The TCP / IP protocol of some lightweight (or light-weight) non-Linux systems and devices (such as smart speakers, smart watches, etc.) is provided by Lwip, and there is no other alternative. In such devices, only the communication mode can be switched with sense, and the communication mode cannot be switched without sense. The following is a detailed description.
[0046] Figure 2 FIG. 1 is a schematic diagram of a system architecture of an electronic device using Lwip. Figure 2 As shown in , the electronic device may include an application, a physical network card 1, a physical driver 1, a communication device 1, a physical network card 2, a physical driver 2, and a communication device 2. Among them, the physical network card 1 corresponds to the physical driver 1 and the communication device 1, and the physical network card 2 corresponds to the physical driver 2 and the communication device 2. The physical network card 1 is generated by the physical driver 1, and the physical network card 1 is connected (or interacts) with the physical driver 1 one-to-one. The physical network card 2 is generated by the physical driver 2, and the physical network card 2 is connected (or interacts) with the physical driver 2 one-to-one. The physical network card is a hardware device or structure. The physical driver 1 is used to drive the communication device 1, and the physical driver 2 is used to drive the communication device 2. The communication device 1 and the communication device 2 can communicate with other electronic devices through different communication methods. For example, the communication device 1 can communicate with other electronic devices through the Bluetooth communication method, and the communication device 2 can communicate with other electronic devices through the WiFi communication method.
[0047] When the electronic device uses the communication method corresponding to the communication device 1 for communication, the application can send the generated message to the physical network card 1, and the physical network card 1 can add the source IP address and the 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 other devices that ultimately need 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 the source MAC address and the 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 electronic device that communicates with the electronic device. The physical driver 1 can drive the communication device 1 to send the message to the opposite electronic device. When the electronic device uses the communication method corresponding to the communication device 2 for communication, the application can send the generated message to the physical network card 2, and the physical network card 2 can add the source IP address and the 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 other devices that ultimately need 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 electronic device. The physical driver 2 can drive the communication device 2 to send the message to the opposite electronic device.
[0048] When an electronic device switches from using the communication method corresponding to communication device 1 to using the communication method corresponding to communication device 2 for communication, the processing of the message after the application generates the message needs to be switched from "sending to physical network card 1" to "sending to physical network card 2". Correspondingly, the application needs to switch the channel for sending messages, which requires the application to switch from connecting to physical network card 1 to connecting to physical network card 2. This process will cause the application to freeze. Therefore, the switching process of the communication method is perceptible to the application (client). This will reduce the processing efficiency of the client, resulting in a poor client experience, and will also affect the overall communication efficiency.
[0049] In summary, currently electronic devices using Lwip can perform sensed switching of communication modes according to the above method, but cannot achieve senseless switching of communication modes.
[0050] Based on the above problems, in order to realize the senseless switching of communication modes in non-Linux kernel electronic devices, the embodiments of the present application provide a communication method and electronic device, which can easily and efficiently perform senseless switching of communication modes, thereby improving client processing efficiency and communication efficiency. Optionally, the solution provided by the embodiments of the present application can be applied to lightweight non-Linux kernel electronic devices, for example, it can be applied to lightweight devices based on Lwip. The solution provided by the present application can realize the senseless switching of communication modes in such devices, thereby improving the client processing efficiency and communication efficiency of such devices.
[0051] See below Figure 3 , the structure of the electronic device to which the method provided in the embodiments of the present application is applicable is introduced.
[0052] like Figure 3 As shown, the electronic device 100 may include a processor 110, a memory 120, a display screen 130, a charging 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 speaker 170A, a receiver 170B, a microphone 170C, a sensor module 180, a button 190, a motor 191, etc. Optionally, the electronic device 100 may also include a mobile communication module 150, a camera 192, etc.
[0053] The sensor module 180 may 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, and the like.
[0054] Understandably, Figure 3 The electronic device 100 shown is merely an example and does not constitute a limitation on the electronic device, and the electronic device may have more or fewer components than those shown in the figure, may combine two or more components, or may have a different component configuration. Figure 3 The various components shown in the drawings 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.
[0055] The processor 110 may include one or more processing units, for example: the processor 110 may include an application processor (application processor, AP), a modem processor, a graphics processor (graphics processing unit, GPU), an image signal processor (image signal processor, ISP), a controller, a memory, a video codec, a digital signal processor (digital signal processor, DSP), a baseband processor, and / or a neural network processor (Neural-network Processing Unit, NPU), etc. Among them, different processing units can be independent devices or 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 an operation control signal according to the instruction opcode and the timing signal to complete the control of fetching and executing instructions.
[0056] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0057] The execution of the communication method provided in the embodiment of the present application can be controlled by the processor 110 or completed by calling other components, such as calling the processing program of the embodiment of the present application stored in the memory 120 to control the wireless communication module 160 to communicate data with other devices, thereby improving the intelligence and convenience of the electronic device 100 and enhancing the user experience. The processor 110 may include different devices, such as when the CPU and GPU are integrated, the CPU and GPU can cooperate to execute the communication method provided in the embodiment 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, so as to obtain faster processing efficiency.
[0058] The display screen 130 is used to display images, videos, etc. 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 or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include 1 or N display screens 130, where N is a positive integer greater than 1. The display screen 130 can be used to display information input by a user or information provided to a user and various graphical user interfaces (GUI).
[0059] In some embodiments, the display screen 130 may be an integrated flexible display screen, or a spliced display screen consisting of two rigid screens and a flexible screen located between the two rigid screens.
[0060] The camera 192 (a front camera or a rear camera, or one camera can be used as both a front camera and a rear camera) is used to capture still images or videos. Generally, the camera 192 may include a photosensitive element such as a lens group and an image sensor, wherein the lens group includes a plurality of lenses (convex lenses or concave lenses) for collecting light signals reflected by the object to be photographed and transmitting the collected light signals to the image sensor. The image sensor generates an original image of the object to be photographed based on the light signal.
[0061] The memory 120 can be used to store computer executable program codes, and the executable program codes include 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 may include a program storage area and a data storage area. Among them, the program storage area may store codes of an operating system, an application program (such as a function of a communication method, etc.), etc. The data storage area may store data created during the use of the electronic device 100, etc.
[0062] The memory 120 may also store one or more computer programs corresponding to the algorithm of the communication method provided in the embodiment of the present application. The one or more computer programs are stored in the above-mentioned memory 120 and are configured to be executed by one or more processors 110. The one or more computer programs include instructions, and the above-mentioned instructions can be used to execute each step in the following embodiments.
[0063] In addition, the memory 120 may include a high-speed random access memory and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc.
[0064] In some embodiments of the present application, a touch sensor is also referred to as a "touch panel". The touch sensor may be disposed on the display screen 130, and the touch display screen composed of the touch sensor and the display screen 130 is also referred to as a "touch screen". The touch sensor is used to detect touch operations acting on or near it. The touch sensor may transmit the detected touch operation to an application processor to determine the type of touch event. Visual output related to the touch operation may be provided through the display screen 130. In other embodiments, the touch sensor may also be disposed on the surface of the electronic device 100, which is different from the position of the display screen 130.
[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.
[0066] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of antennas. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.
[0067] The mobile communication module 150 can provide solutions for wireless communications including 2G / 3G / 4G / 5G applied to the electronic device 100. The mobile communication module 150 may 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 from the antenna 1, and filter, amplify, and process the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the processor 110. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the same device as at least some of the modules of the processor 110. In an embodiment of the present application, the mobile communication module 150 can also be used to interact with other devices for information.
[0068] The modem processor may include a modulator and a demodulator. Among them, the modulator is used to modulate the low-frequency baseband signal to be sent into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After the low-frequency baseband signal is processed by the baseband processor, it is passed to the application processor. The application processor outputs a sound signal through an audio device (not limited to a speaker 170A, a receiver 170B, etc.), or displays an image or video through a display screen 130. In some embodiments, the modem processor may be an independent device. In other embodiments, the modem processor may be independent of the processor 110 and be set in the same device as the mobile communication module 150 or other functional modules.
[0069] The wireless communication module 160 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to the electronic device 100. 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 the antenna 2, modulates the frequency of the electromagnetic wave signal and performs filtering processing, and sends the processed signal to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, modulate the frequency of the signal, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2. In the embodiment of the present application, the wireless communication module 160 is used to establish a connection with other electronic devices for data interaction.
[0070] In addition, the electronic device 100 can implement audio functions through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, and the application processor, etc. For example, music playing, recording, etc. The electronic device 100 can receive input from the key 190 and generate key signal input related to the user settings and function control of the electronic device 100. The electronic device 100 can use the motor 191 to generate a vibration prompt (such as an incoming call vibration prompt).
[0071] It should be understood that in practical applications, the electronic device 100 may include Figure 3 The embodiments of the present application are not limited to the more or fewer components shown. The illustrated electronic device 100 is only an example, and the electronic device 100 may have more or fewer components than those 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 the electronic device 100 may adopt a layered architecture, an event-driven architecture, a microkernel architecture, a microservice architecture, or a cloud architecture. The layered architecture divides the software into several layers, each with a clear role and division of labor. The 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, namely the application layer, the application framework layer (Framework, FWK), the runtime and system library, and the (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 may also include third-party applications. The application involved in the embodiment of the present application is referred to as application (APP), which is a software program that can implement one or more specific functions. Typically, 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 may be a system application installed when the electronic device leaves the factory, or it may be a third-party application downloaded from the Internet or obtained from other electronic devices by the user while using the electronic device.
[0074] Of course, for developers, developers can write applications and install them in this layer. In a possible implementation, applications can be developed using the Java language by calling the application programming interface (API) provided by the application framework layer. Developers can interact with the bottom layer of the operating system (such as the kernel layer) through the application framework to develop their own applications.
[0075] The application framework layer is the API and programming framework of the application layer. The application framework layer may include some predefined functions. The application framework layer may 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 window programs. The window manager can obtain the display screen size, determine whether there is a status bar, lock the display screen (or screen), capture the display screen, etc.
[0077] Content providers are used to store and retrieve data and make these data accessible to applications. The data may include files (such as documents, videos, images, audio), text and other information.
[0078] The view system includes visual controls, such as controls for displaying text, images, documents, etc. The view system can be used to build applications. The interface in the display window can be composed of one or more views. For example, the display interface including the SMS notification icon can include a view for displaying text and a view for displaying images.
[0079] The phone manager is used to provide communication functions for electronic devices. The notification manager enables applications to display notification information in the status bar, which can be used to convey notification-type messages and can disappear automatically after a short stay without user interaction.
[0080] The runtime includes the core library and the virtual machine. The runtime is responsible for the scheduling and management of the system.
[0081] The core library of the system consists of two parts: one is the function that the Java language needs to call, and the other 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 as binary files. The virtual machine is used to perform object life cycle management, stack management, thread management, security and exception management, and garbage collection.
[0082] The system library can include multiple functional modules. For example: surface manager, media library, 3D graphics processing library (for example: OpenGL ES), 2D graphics engine (for example: SGL), image processing library, etc. The surface manager is used to manage the display subsystem and provide the fusion of 2D and 3D layers for multiple applications. The media library supports a variety of commonly used audio and video format playback and recording, as well as static image files, etc. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.564, MP3, AAC, AMR, JPG, PNG, etc. The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, synthesis and layer processing, etc. The 2D graphics engine is a drawing engine for 2D drawing.
[0083] The kernel layer provides the core system services of the operating system, such as security, memory management, process management, network protocol stack and driver model, which are all implemented based on the kernel layer. The kernel layer also serves as an abstraction layer between the hardware and software stacks. This layer has many drivers related to electronic devices, the main drivers are: display driver; keyboard driver as input device; Flash driver based on memory technology device; camera driver; audio driver; Bluetooth driver; WiFi driver, etc.
[0084] It should be understood that the functional services described above are only examples, and in actual applications, electronic devices may also be divided into more or fewer functional services according to other factors, or the functions of each service may be divided in other ways, or the functional services may not be divided but work as a whole.
[0085] The solution provided in the embodiment of the present application can be applied in the scenario of electronic device communication, for example, it can be applied to the scenario in which the electronic device communicates with the server through other electronic devices, or the scenario in which the electronic device is connected to the network through other electronic devices, or it can be applied to the scenario in which the electronic device switches the communication mode or the communication link during the communication process with other electronic devices. Among them, different communication links correspond to different communication modes. Optionally, the electronic device can be a lightweight non-Linux kernel electronic device, such as a lightweight sports watch. Optionally, the electronic device can use Lwip.
[0086] For ease of explanation, in the embodiments of the present application, communication link switching is referred to as link switching.
[0087] The method provided in the embodiment of the present application is described in detail below by taking the scenario in which a first electronic device communicates with a server through a second electronic device as an example.
[0088] Optionally, in this scenario, the first electronic device may switch the communication mode (or communication link) when communicating with the second electronic device during the communication process.
[0089] In some embodiments of the present application, the first electronic device may have far-field communication and / or near-field communication capabilities. For example, the first electronic device may support multiple communication methods such as WiFi communication, Bluetooth communication, mobile communication, communication based on universal serial bus (USB), and communication based on wireless network card. The link switching performed by the first electronic device may be switching between communication links corresponding to these communication methods, and therefore, link switching may also be understood as switching of communication methods.
[0090] Figure 5 The following is a schematic diagram of the architecture of a communication system provided in an embodiment of the present application. Figure 5 As shown in , the communication system includes at least a first electronic device. The communication system may also include at least one other electronic device, which may be, for example, Figure 5 The second electronic device shown in .
[0091] The first electronic device may include at least one application, a logical 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 a physical driver among multiple physical drivers, and different communication devices correspond to different physical drivers. The physical driver corresponding to each communication device is used to drive the communication device. A logical network card can correspond to multiple different physical drivers, and a logical network card can be connected (or interacted) with multiple different physical drivers.
[0092] During the communication process, the application can be used to send the data to be sent as a message to the logical network card. The logical network card can be used to configure a unified source IP address for the messages from each application, and the source IP address is the IP address of the logical network card. The logical network card can send the processed message to the physical drive. The physical driver can add a source MAC address to the received message, and the source MAC address is the MAC address of the communication device corresponding to the physical driver. The physical driver can drive the communication device to send out the message processed by the physical driver. When link switching is required, the first electronic device switches the transmission path of the message from one physical drive to another physical drive through the logical network card, which can achieve the effect of switching the source MAC address of the message from the MAC address of one communication device to the MAC address of another communication device, and then achieve the effect of switching the communication mode corresponding to one communication device to the communication mode corresponding to another communication device.
[0093] In one example, if Figure 5 As shown in , the first electronic device may 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 communication mode supported by the first communication device may be WiFi communication, and the communication mode supported by the second communication device may be Bluetooth communication. Then the first communication device may be WiFi hardware, and the second communication device may be Bluetooth hardware.
[0094] In some embodiments of the present application, the second electronic device may be any electronic device connected to the first electronic device. Figure 5 As shown in , 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 a communication device of the same type 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 a communication device of the same type 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 specifically: 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 the present application may be a hardware structure capable of realizing far-field or near-field communication functions, and the communication device may also be referred to as a physical interface or physical hardware, etc.
[0097] based on Figure 5 The communication system shown in FIG. 1 takes the scenario where the first electronic device is connected to the server through the second electronic device as an example. A communication method provided in an embodiment of the present application can refer to Figure 6 ,like Figure 6 As shown in , the method may include:
[0098] S601: A first application in a first electronic device generates a first message.
[0099] In some embodiments of the present application, the first electronic device may use Lwip.
[0100] The first message includes data that the first application needs to send to the server through the second electronic device.
[0101] S602: The first application sends a first message to a logical network card in a first electronic device.
[0102] In some embodiments of the present application, a logical network card can be generated by any physical driver in the first electronic device. After any physical driver generates a logical network card, other physical drivers can detect the existence of the logical network card and dock (or establish a connection) with the logical network card. If the docking is successful (or the connection is successful), the other physical drivers do not generate a new network card and can interact with the existing logical network card in the subsequent process. For example, a logical network card can be generated by a first physical driver, and a second physical driver can dock with the logical network card. Based on this method, a logical network card can dock with multiple physical drivers.
[0103] S603: The logical network card adds a source IP address and a destination IP address to the first message to obtain a second message; wherein the source IP address is the IP address of the logical network card, and the destination IP address may 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 message to obtain a third message, 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 of the second electronic device.
[0106] S606: The first physical driver sends the third message to the first communication device in the first electronic device.
[0107] S607: The first communication device sends the third message to the second electronic device.
[0108] After receiving the third message, the second electronic device may forward the third message to the server.
[0109] The first communication device sends the third message to the second electronic device, which may specifically be the first communication device sending the third message to the third communication device of the second electronic device.
[0110] In some embodiments of the present application, before the first electronic device generates a first message through the first application or before sending a third message to the second electronic device through the first communication device, it can first determine that the first communication device and the third communication device are in a communication connection state, thereby ensuring that the first communication device can successfully send the third message to the third communication device.
[0111] In some embodiments of the present application, the second electronic device may be a Linux kernel-based electronic device or a lightweight non-Linux kernel-based electronic device.
[0112] Optionally, when the second electronic device is a lightweight non-Linux kernel electronic device, such as Figure 5 As shown in , the second electronic device may 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. Among them, 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 function and communication method of the second electronic device can refer to the above description of the specific structure function and communication method of the first electronic device, which will not be described in detail here.
[0113] Example 1: In one example, the first electronic device is a smart watch, the second electronic device is a mobile phone, and the first electronic device and the second electronic device can communicate via WiFi or Bluetooth. The mobile phone can share the network with the smart watch, and the smart watch can access the Internet with the help of the mobile phone. The smart watch and the mobile phone can interact via WiFi or Bluetooth. Figure 7As shown in the schematic diagram (a) in FIG. 1 , the logical network card of the smart watch can be denoted as D0. The first communication device of the smart watch can be a WiFi hardware interface, which can be denoted as Figure 7 The second communication device of the smart watch can be a Bluetooth hardware interface, which can be recorded as Figure 7 The mobile phone can be connected to the network side through the network interface. The third communication device of the mobile phone can be a WiFi hardware interface, which can be recorded as Figure 7 The fourth communication device of the mobile phone may be a Bluetooth hardware interface, which may be denoted as Figure 7 BT1 shown in the schematic diagram (a) in FIG. 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 may be 10.0.0.1, and the IP address of the network side may be 1.1.1.1. The MAC address of WLAN0 may be 1:2:3:4, and the MAC address of WLAN1 may be 5:5:5:5. The MAC address of BT0 may be 5:6:7:8, and the MAC address of BT1 may be 9:9:9:9.
[0115] When the smart watch sends a message to the mobile phone through the first communication device, that is, the WiFi hardware interface, Figure 8 As shown in schematic diagram (a), the source IP address in the message sent by the first communication device in WiFi mode 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.
[0116] The second message and the fourth message mentioned above may be the same message or different messages.
[0117] S608: The first application generates a fourth message.
[0118] The fourth message 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 message to the logical network card.
[0120] S610: The logical network card adds a source IP address and a destination IP address to the fourth message to obtain a fifth message; wherein the source IP address is the IP address of the logical network card, and the destination IP address may 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, wherein 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 receiving the sixth message, the second electronic device may 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 sending the sixth message to the second electronic device through the second communication device, it can first determine that the second communication device and the fourth communication device are in a communication connection state, thereby ensuring 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 to S614 may be performed after the above step S607, or the above steps S608 to S614 may be performed before the above step S601, or the above steps S608 to S614 may be performed synchronously with the above steps S601 to S607. When the above steps S608 to S614 are performed synchronously with the above steps S601 to S607, the above first message and the above fourth message may be the same message or different messages. Then the electronic device may synchronously send the same message or different messages of the same application through different communication devices.
[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 the first communication mode (i.e., the 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 the second communication mode (i.e., the communication mode supported by the second communication device). When it is necessary to switch from the first communication mode to the second communication mode or to switch from the first communication link to the second communication link, the electronic device can switch from executing the method corresponding to the above steps S601 to S607 to executing the method corresponding to the above steps S608 to S614.
[0130] In some embodiments of the present application, the first electronic device may determine that the above-mentioned link switching (or communication mode switching) needs to be performed in a specific scenario or under specific conditions, and then switch from executing the method corresponding to the above-mentioned step S601 to executing the method corresponding to the above-mentioned step S602. Specifically, during the communication process, the first electronic device may collect the link status corresponding to each current communication device (such as the status of the first communication link and the second communication link mentioned above), the idle bandwidth of each communication device, the throughput percentage, etc., which are used to characterize at least one piece of information of the communication quality of each communication link or communication device through each physical driver, and determine whether the set switching condition is met based on the at least one piece of information collected. If so, it can be determined to perform the link switching, otherwise the link switching may not be performed. Among them, the set switching condition may be pre-configured by the system or may be pre-configured by the user in the electronic device.
[0131] For example, the set switching condition may be that the idle bandwidth of the first communication device is lower than a set threshold value. Then, when the first electronic device determines that the idle bandwidth of the first communication device is lower than the set threshold value, it can determine to perform a link switch. For another example, the set switching condition may be that the idle bandwidth of the first communication device is lower than the idle bandwidth of the second communication device. Then, when the first electronic device determines that the idle bandwidth of the first communication device is lower than the idle bandwidth of the second communication device, it can determine to perform a link switch. For another example, the set switching condition may be that the first communication link is disconnected. Then, when the first electronic device determines that the first communication link is cut off (for example, due to a malfunction or other reasons), it can determine to perform a link switch.
[0132] Example 2: In the scenario described in Example 1 above, there is a communication connection between the first application and the logical network card in the first electronic device (i.e., smart watch), and all data that the first application needs to send can be sent to the logical network card for subsequent processing. Figure 7As shown in the schematic diagram (b) in FIG, when the communication connection between WLAN0 and WLAN1 is disconnected, WLAN0 cannot send messages to the second electronic device (i.e., the mobile phone), the communication link corresponding to WLAN0 in the first electronic device is cut off, and the first electronic device needs to switch the communication link. However, the communication connection between the first application and the logical network card is not disconnected, so the first application can still send the message to be sent to the logical network card for processing.
[0133] Optionally, the first electronic device may switch from using the first communication device to send a message to the second electronic device to using the second communication device to send a message to the second electronic device, thereby switching from the communication link corresponding to the first communication device to the communication link corresponding to the second communication device. Figure 7 As shown in the schematic diagram (c) in FIG. 1 , the first electronic device can send a message to BT1 through 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 FIG. Figure 8 As shown in 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] Above Figure 8 The content shown in the schematic diagram (a) in FIG. 1 is the address information in the message sent by the first electronic device before the link switching. Figure 8 The content shown in the schematic diagram (b) is the address information in the message sent by the first electronic device after the link switching. Among them, before and after the link switching, the source IP address in the message does not change, so the TCP connection established based on the IP address will not be disconnected, and the interaction between the first application and the logical network card will not be affected. Before and after the link switching, the source MAC address in the message changes according to the switched communication device. The first physical driver or the second physical driver only needs to add the source MAC address to the message, match the corresponding communication device according to the source MAC address, and send the message to the corresponding communication device to achieve the switching of the communication device. The source IP address does not need to be matched 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 being aware of it, that is, a senseless link switching can be achieved, thereby improving the processing efficiency of the client and improving the communication efficiency.
[0135] It should be understood that when it is necessary to switch from the second communication mode to the first communication mode or when it is necessary to switch from the second communication link to the first communication link, the electronic device can switch from communicating according to the method corresponding to the above steps S608 to S614 to communicating according to the method corresponding to the above steps S601 to S607. The specific implementation process will not be described in detail in the embodiments of the present application.
[0136] In some embodiments of the present application, the first electronic device may further include a second application, and the first application described in the above steps S608 to S614 may also be replaced by the second application.
[0137] In some embodiments of the present application, after executing the above step S607, the first electronic device may further perform the following steps: the second application generates a seventh message and sends it to the logical network card. The logical network card adds the source IP address and the destination IP address to the seventh message, and sends the obtained eighth message to the first physical driver, wherein the source IP address is the IP address of the logical network card, and the destination IP address may be the IP address of the server. The first physical driver adds the source MAC address and the destination MAC address to the eighth message to obtain the ninth message, 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 message to the second electronic device, so that the second electronic device sends the ninth message to the server. The specific implementation of the method can refer to the method for sending the first message through the first communication device described in the above embodiment, which will not be described in detail here. Based on this method, the first electronic device can send different messages of different applications through the same communication device.
[0138] The method provided in the above embodiment can realize senseless link switching in lightweight electronic devices without the help of the Linux kernel, that is, encapsulate the same source IP address and different source MAC addresses for the same IP message or different IP messages, and send messages through different communication devices. This method solves the problem that senseless link switching cannot be performed on lightweight devices, and realizes the same link switching experience of lightweight devices and rich devices (such as electronic devices 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 dormant 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 does not depend on the IP address, so the logical network card can encapsulate the same message or different messages with the same IP address and send them to different communication devices for processing, thereby achieving the effect of multi-channel concurrency.
[0139] It should be noted that, unless otherwise specified, the source IP addresses described in the above embodiments of the present application are all IP addresses of the logical network card of the first electronic device.
[0140] It should be understood that the communication system architecture described above is only an example. In actual applications, electronic devices may also be divided into more or fewer functional services according to other factors, or the functions of each service may be divided in other ways, or the functional services may not be divided, but work as a whole. The implementation process provided in the above embodiment is only an example of the method process applicable to the embodiment of the present application, wherein the execution order of each step may be adjusted accordingly according to actual needs, and other steps may be added, or some steps may be reduced.
[0141] Based on the above embodiments and the same technical concept, the present application embodiment also provides a communication method, such as Fig. 9 As shown in , the method may include:
[0142] S901: A first application in a first electronic device generates a first message; 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.
[0143] In some embodiments of the present application, the first electronic device may adopt the lightweight Internet protocol Lwip.
[0144] In some examples, the first electronic device may be the first electronic device described in the foregoing embodiment, and the second electronic device may be the second electronic device described in the foregoing embodiment. For the functional structures of the first electronic device and the second electronic device, reference may be made to the relevant descriptions in the foregoing embodiment.
[0145] S902: The logical network card in the first electronic device adds a source Internet Protocol IP address to the first message, and sends the obtained second message to the selected target physical drive; wherein the source IP address is the IP address of the logical network card; the target physical drive is the first physical drive or the second physical drive.
[0146] In some embodiments of the present application, before sending the obtained second message to the selected target physical driver, the logical network card can select a target physical driver based on the current scene information. Specifically, the logical network card can select a target communication device from the first communication device and the second communication device based on the current scene information, and use the physical driver corresponding to the target communication device as the target physical driver; wherein the current scene information includes: information used to characterize the communication quality of the first communication device and / or information used to characterize the communication quality of the second communication device.
[0147] Optionally, the way in which the logical network card selects the target communication device according to the current scene information can be implemented by referring to the switching conditions described in the above embodiments. Exemplarily, the logical network card can use the determined switched communication device as the target communication device when it is determined that the current scene meets the set switching conditions according to the method described in the above embodiments.
[0148] For example, the logical network card may determine that the first communication device is a target communication device and the first physical drive is a target physical drive 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 may determine that the second communication device is a target communication device and the second physical drive is a target physical drive 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 another example, the logical network card may determine that the second communication device is a target communication device and the second physical drive is a target physical drive 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, after the logical network card adds a source Internet Protocol IP address to the first message, before sending the obtained second message to the selected target physical drive, the logical network card can also add a destination IP address to the first message, then the above-mentioned second message includes the first message, 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 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.
[0151] In some embodiments of the present application, after the target physical driver adds the source MAC address to the second message, before the communication device corresponding to the driver sends the obtained third message to the second electronic device, the target physical driver can also add the destination MAC address to the second message, then the obtained third message includes the second message, the source MAC address and the destination MAC address; 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 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 respectively Figure 5 The first electronic device and the second electronic device shown in FIG. 1 , when the target physical drive is Figure 5 When the first physical drive is shown in Figure 5 The first communication device shown in FIG. 1 and the third communication device of the second electronic device may be Figure 5 In another example, the first electronic device and the second electronic device may be respectively Figure 5 The first electronic device and the second electronic device shown in FIG. 1 , when the target physical drive is Figure 5 When the second physical drive is shown in , the target communication device can be Figure 5 The second communication device shown in , the third communication device of the second electronic device can be Figure 5 The fourth communication device shown in .
[0152] In some embodiments of the present application, before the target physical driver drives the corresponding communication device to send the obtained third message to the second electronic device, it can first determine that the corresponding communication device is communicatively connected with the third communication device, thereby ensuring that the third message 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 to S903 above, or after the first electronic device executes the method described in steps S901 to S903 above, it can also execute the following method: the first application generates a fourth message; when the target physical drive is the first physical drive, the logical network card adds a source IP address to the fourth message, and sends the obtained fifth message to the second physical drive; the second physical drive 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 drive to the fifth message is the MAC address of the second communication device. Based on this method, the first electronic device can send different messages of the first application synchronously or successively through the first communication device and the second communication device. 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 message of the first application through the second physical drive. The specific implementation can be referred to the above method, which will not be repeated here. The specific implementation and extended implementation of the above method can be implemented by referring to the above method for processing the first message 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 may further include a second application; after the target physical driver drives the corresponding communication device to send the obtained third message to the second electronic device, the first electronic device may further perform the following method: the second application generates a seventh message; the logical network card adds a source IP address to the seventh message, and sends the obtained eighth message to the target physical driver; the target physical driver adds a 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. The specific implementation and extended implementation of the method can be implemented with reference to the above-mentioned method for processing the first message generated by the first application, which will not be described in detail here.
[0155] In the above method, the specific steps executed by the first electronic device and the second electronic device can refer to the relevant introduction in the above embodiments, which will not be described in detail here.
[0156] Based on the above embodiments and the same technical concept, the embodiments of the present application also provide an electronic device, which is used to implement the communication method provided in the embodiments of the present application. Fig.10 As shown in the figure, the electronic device 1000 may include: a memory 1001, one or more processors 1002, and one or more computer programs (not shown in the figure). The above-mentioned components may be coupled via one or more communication buses 1003. Optionally, the electronic device 1000 may also include a display screen 1004.
[0157] Among them, one or more computer programs (codes) are stored in the memory 1001, and the one or more computer programs include computer instructions; one or more processors 1002 call the computer instructions stored in the memory 1001, so that the electronic device 1000 executes the communication method provided in the above-mentioned embodiment of the present application.
[0158] In a specific implementation, the memory 1001 may include a high-speed random access memory, and may 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 may store an operating system (hereinafter referred to as system), such as ANDROID, IOS, WINDOWS, or an embedded operating system such as LINUX. The memory 1001 may be used to store an implementation program of an embodiment of the present application. The memory 1001 may also store a network communication program, which may be used to communicate with one or more additional devices, one or more user devices, or one or more network devices.
[0159] The one or more processors 1002 may 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 program of the present application.
[0160] Display screen 1004 is used to display application interface and other related user interfaces.
[0161] It should be noted that Fig.10 This is only one implementation of the electronic device 1000 provided in the embodiment of the present application. In actual applications, the electronic device 1000 may also include more or fewer components. For details, please refer to Figure 3 The specific structure and description shown are not limited 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, which stores a computer program. When the computer program runs on a computer, the computer executes 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, which includes a computer program or instructions. When the computer program or instructions are executed on a computer, the computer executes the method provided in the above embodiments.
[0164] The method provided in the embodiment of the present application can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function according to the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, a network device, a user device or other programmable device. 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, computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center via wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. Computer-readable storage media can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more available media integrated. Available media can be magnetic media (e.g., floppy disks, hard disks, tapes), optical media (e.g., digital video discs (DVDs), or semiconductor media (e.g., SSDs), etc.
[0165] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended 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 the 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; The method comprises: The first application generates a first message; The logical network card adds a source Internet Protocol IP address to the first message, and sends the obtained second message to the selected target physical drive; wherein the source IP address is the IP address of the logical network card; the target physical drive is the first physical drive or the second physical drive; 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 according to claim 1, characterized in that After the logical network card adds a source Internet Protocol IP address to the first message, and before sending the obtained second message to the selected target physical drive, the method further includes: The logical network card adds a destination IP address to the first message; 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 message, and before driving the corresponding communication device to send the obtained third message 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 a 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.
3. The method according to any one of claim 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: Determine that the communication device corresponding to the target physical drive is communicatively 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 drive, the method further includes: Selecting a target communication device from the first communication device and the second communication device according to current scenario information; 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 comprises: 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 the obtained fifth message to the second physical drive; 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 a seventh message; The logical network card adds the source IP address to the seventh message, and sends the obtained eighth message to the target physical drive; 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 adopts 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 codes, and the computer program codes include computer instructions; when the computer instructions are executed by the one or more processors, the electronic device executes the method according to 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, and when the computer program is executed on an electronic device, the electronic device executes the method according to 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
Route determining method, network configuration method and related device
WO2017113300A1