A TCP keep-alive method, device and system
Broadcasting TCP connection keep-alive messages through Bluetooth solves the resource consumption problem of TCP connections between smart devices when WLAN is disconnected or dormant, and realizes TCP connection management with low power consumption and quick recovery.
Patent Information
- Application Number
- CN202011194476.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-10-30
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2040-10-30
AI Technical Summary
In the data interaction between smart devices, when the terminal device is disconnected from the WLAN physical layer or goes to sleep with the screen turned off, the TCP connection is destroyed and needs to be rebuilt after recovery, resulting in large resource consumption and affecting device performance.
Broadcast TCP connection keep-alive messages through Bluetooth to keep TCP connections alive for whitelist services, avoid frequent destruction and reconstruction operations, and reduce equipment overhead.
It effectively reduces the energy consumption and recovery time of terminal equipment, implements low-power TCP connection keep-alive, and reduces equipment overhead.
Smart Images

Figure CN114531497B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of communication technology, and in particular to a TCP keep-alive method, device and system. Background Art
[0002] With the popularization of smart devices, various smart devices have entered thousands of households, data interaction between services across devices has become more and more common, and the number of Transmission Control Protocol (TCP) connections between devices has greatly increased.
[0003] When the terminal device goes into sleep mode or the wireless local area network (WLAN) physical layer is disconnected, the TCP connections established by various services on the terminal device will be destroyed. When the screen is subsequently turned on to wake up or the WLAN physical layer connection is restored, a lot of time and resources will be required to establish TCP connections and service connections for various services, resulting in high overhead for the terminal device. Summary of the invention
[0004] The embodiments of the present application provide a TCP keep-alive method, device and system for reducing the energy consumption of terminal equipment.
[0005] In a first aspect, an embodiment of the present application provides a TCP keep-alive method, which is applied to a coprocessor, and includes: receiving a first request, the first request carrying an identifier of a first service and an identifier of a first TCP connection, the first request being used to request keep-alive of the first TCP connection of the first service, the first TCP connection being a connection between a first device and a second device; obtaining a first TCP connection keep-alive message according to the identifier of the first service and the identifier of the first TCP connection; and broadcasting the first TCP connection keep-alive message via Bluetooth.
[0006] Based on the above scheme, when the WLAN physical layer link of the first device is disconnected or the screen is turned off and the device is in sleep mode, the first device does not destroy the whitelist service in the first device, but generates a TCP connection keep-alive message for the whitelist service, and then broadcasts the TCP connection keep-alive message via Bluetooth, thereby enabling the TCP connection keep-alive of the service, without the need to frequently destroy and reestablish the TCP connection of the service, and thus reducing device overhead. In addition, the TCP connection keep-alive message is broadcasted via Bluetooth, and the power consumption is relatively low, thereby achieving low-power TCP connection keep-alive.
[0007] As an implementation method, the first request carries an identifier of the first service and an identifier of the first TCP connection, including: the first request carries an identifier of the first service and keepalive information of the first TCP connection, and the keepalive information of the first TCP connection includes the identifier of the first TCP connection. The keepalive information of the first TCP connection may also be referred to as the first TCP connection keepalive information or keepalive information (KAInfo).
[0008] As a possible implementation method, a broadcast message is received via Bluetooth, and the broadcast message carries a second TCP connection keep-alive message; it is determined that the service identifier carried by the second TCP connection keep-alive message is the identifier of the first service and the identifier of the TCP connection carried is the identifier of the first TCP connection, then the mapping relationship between the identifier of the first service and the identifier of the first TCP connection is saved, and a timeout period is set.
[0009] As a possible implementation method, if it is determined that the second TCP connection keep-alive message is not received again within the timeout period, the mapping relationship is deleted; or, if it is determined that the second TCP connection keep-alive message is received again within the timeout period, the mapping relationship is not deleted.
[0010] Based on the above scheme, a timeout period is set, and when a TCP connection keep-alive message is received within the timeout period, the TCP connection is maintained, otherwise the TCP connection is determined to have timed out, and the TCP connection is no longer maintained. In this way, the energy consumption of the device can be reduced.
[0011] As a possible implementation method, it is determined that the application processor of the first device is in a sleep state and has not received the second TCP connection keep-alive message within a timeout period, then the application processor is woken up; an indication message is sent to the application processor, where the indication message is used to notify that the physical layer link between the first device and the second device is disconnected.
[0012] Based on the above solution, the application processor is awakened only when the physical layer link between the first device and the second device is disconnected, and the application processor is in a dormant state at other times, which can save energy consumption of the application processor.
[0013] As a possible implementation method, a broadcast message is received via Bluetooth, the broadcast message carrying a third TCP connection keep-alive message, the third TCP connection keep-alive message carrying an identifier of the second service and an identifier of the second TCP connection; if it is determined that the second service is not a whitelist service, the third TCP connection keep-alive message is discarded.
[0014] Based on this solution, TCP connection keep-alive is not performed for non-whitelist services, which can reduce energy consumption.
[0015] As a possible implementation method, if it is determined that a response message is received for the first TCP connection keep-alive message, the application processor is not notified to release the first TCP connection, that is, it is determined that the first TCP connection is kept alive successfully; or, if it is determined that N consecutively sent first TCP connection keep-alive messages have not received corresponding response messages, the application processor is notified to release the first TCP connection, that is, it is determined that the first TCP connection keeps alive fails, where N is a positive integer.
[0016] In the second aspect, an embodiment of the present application provides a TCP keep-alive method, which is applied to an application processor, including: obtaining an identifier of a first TCP connection and an identifier of a first service, the first TCP connection being a connection between a first device and a second device corresponding to the first service; determining that the first service corresponding to the first TCP connection is a whitelist service, then sending a first request to a coprocessor of the first device, the first request carrying an identifier of the first service and an identifier of the first TCP connection, the first request being used to request that the first TCP connection of the first service be keep-alive.
[0017] Based on the above solution, TCP connection keepalive can be implemented for whitelist services, without frequent destruction and reconstruction of the TCP connection of the service, which can reduce equipment overhead. In addition, TCP connection keepalive messages are broadcasted via Bluetooth, which consumes relatively low power, thus realizing low-power TCP connection keepalive.
[0018] As a possible implementation method, the first request also carries the file description information of the first service, and the mapping relationship between the identifier of the first TCP connection and the file description information is saved; and the mapping relationship between the identifier of the first service and the file description information is saved.
[0019] As a possible implementation method, when it is determined that the WLAN physical layer link between the first device and the second device is disconnected, a second request is sent to the coprocessor, where the second request carries an identifier of the first service, and the second request is used to request to obtain an identifier of the first TCP connection corresponding to the identifier of the first service; notification information is received from the coprocessor, where the notification information is used to notify that the identifier of the first TCP connection corresponding to the identifier of the first service is not found; and the first TCP connection is released.
[0020] Based on this solution, the TCP connection is released when the WLAN physical layer link between the first device and the second device is disconnected, thereby reducing device energy consumption.
[0021] As a possible implementation method, it is determined that the WLAN physical layer link between the first device and the second device is disconnected, then a second request is sent to the coprocessor, the second request carrying an identifier of the first service, and the second request is used to request to obtain an identifier of the first TCP connection corresponding to the identifier of the first service; the identifier of the first TCP connection corresponding to the identifier of the first service is received from the coprocessor; and it is determined not to release the first TCP connection.
[0022] As a possible implementation method, indication information is received from the coprocessor, where the indication information is used to notify that the physical layer link between the first device and the second device is disconnected, and the indication information carries an identifier of the first TCP connection; and the first TCP connection is released.
[0023] In the third aspect, an embodiment of the present application provides a TCP keep-alive method, which is applied to a first device, including: obtaining an identifier of a first TCP connection and an identifier of a first service, the first TCP connection being a connection between the first device and the second device corresponding to the first service; determining that the first service corresponding to the first TCP connection is a whitelist service, then obtaining a first TCP connection keep-alive message according to the identifier of the first service and the identifier of the first TCP connection; and broadcasting the first TCP connection keep-alive message via Bluetooth.
[0024] Based on the above solution, TCP connection keepalive can be implemented for whitelist services, without frequent destruction and reconstruction of the TCP connection of the service, which can reduce equipment overhead. In addition, TCP connection keepalive messages are broadcasted via Bluetooth, which consumes relatively low power, thus realizing low-power TCP connection keepalive.
[0025] As a possible implementation method, a mapping relationship between the identifier of the first TCP connection and the file description information corresponding to the first TCP connection is saved; and a mapping relationship between the identifier of the first service and the file description information is saved.
[0026] As a possible implementation method, it is determined that the WLAN physical layer link between the first device and the second device is disconnected, and it is determined that the second TCP connection keep-alive message is not received from the second device within the timeout period, then the TCP connection of the first service is released, and the second TCP connection keep-alive message carries the identifier of the first service and the identifier of the first TCP connection.
[0027] Based on this solution, the TCP connection is released when the WLAN physical layer link between the first device and the second device is disconnected, thereby reducing device energy consumption.
[0028] As a possible implementation method, it is determined that the WLAN physical layer link between the first device and the second device is disconnected, and it is determined that a second TCP connection keep-alive message is received from the second device within a timeout period, then it is determined not to release the first TCP connection, and the second TCP connection keep-alive message carries an identifier of the first service and an identifier of the first TCP connection.
[0029] As a possible implementation method, a broadcast message is received via Bluetooth, and the broadcast message carries a second TCP connection keep-alive message; it is determined that the service identifier carried by the second TCP connection keep-alive message is the identifier of the first service and the identifier of the TCP connection carried is the identifier of the first TCP connection, then the mapping relationship between the identifier of the first service and the identifier of the first TCP connection is saved, and a timeout period is set.
[0030] As a possible implementation method, if it is determined that the second TCP connection keep-alive message is not received again within the timeout period, the mapping relationship is deleted; or, if it is determined that the second TCP connection keep-alive message is received again within the timeout period, the mapping relationship is not deleted.
[0031] Based on the above scheme, a timeout period is set, and when a TCP connection keep-alive message is received within the timeout period, the TCP connection is maintained, otherwise the TCP connection is determined to have timed out, and the TCP connection is no longer maintained. In this way, the energy consumption of the device can be reduced.
[0032] As a possible implementation method, a broadcast message is received via Bluetooth, the broadcast message carrying a third TCP connection keep-alive message, the third TCP connection keep-alive message carrying an identifier of the second service and an identifier of the second TCP connection; if it is determined that the second service is not a whitelist service, the third TCP connection keep-alive message is discarded.
[0033] Based on this solution, TCP connection keep-alive is not performed for non-whitelist services, which can reduce energy consumption.
[0034] As a possible implementation method, if it is determined that a response message is received for the first TCP connection keep-alive message, the application processor is not notified to release the first TCP connection, that is, it is determined that the first TCP connection is kept alive successfully; or, if it is determined that N consecutively sent first TCP connection keep-alive messages have not received corresponding response messages, the application processor is notified to release the first TCP connection, that is, it is determined that the first TCP connection keeps alive fails, where N is a positive integer.
[0035] In a fourth aspect, an embodiment of the present application provides a TCP keep-alive method, which is applied to a first device, wherein the first device includes a coprocessor and an application processor, and the method includes: the application processor determines that the first service is a whitelist service, and sends a first request to the coprocessor, wherein the first request carries an identifier of the first service and an identifier of a first TCP connection, and the first request is used to request that the first TCP connection corresponding to the first service be kept alive, wherein the first TCP connection is a connection between the first device and a second device corresponding to the first service; the coprocessor receives the first request from the application processor, and obtains a first TCP connection keep-alive message according to the identifier of the first service and the identifier of the first TCP connection; the coprocessor broadcasts and sends the first TCP connection keep-alive message via Bluetooth. This solution can realize TCP connection keep-alive for the whitelist, without frequently performing destruction and reconstruction operations on the TCP connection of the service, and can reduce device overhead. In addition, the TCP connection keep-alive message is broadcast and sent via Bluetooth, and the power consumption is relatively low, thereby realizing low-power TCP connection keep-alive.
[0036] As a possible implementation method, the first request also carries file description information of the first service; the application processor saves the mapping relationship between the identifier of the first TCP connection and the file description information corresponding to the first TCP connection; and the application processor saves the mapping relationship between the identifier of the first service and the file description information corresponding to the first TCP connection.
[0037] As a possible implementation method, when the application processor determines that the WLAN physical layer link between the first device and the second device is disconnected, the application processor sends a second request to the coprocessor, the second request carries the identifier of the first service, and the second request is used to request to obtain the identifier of the first TCP connection corresponding to the identifier of the first service; the coprocessor sends notification information to the application processor, the notification information is used to notify that the identifier of the first TCP connection corresponding to the identifier of the first service is not found; the application processor releases the first TCP connection. Based on this solution, the TCP connection is released when the WLAN physical layer link between the first device and the second device is disconnected, which can reduce device energy consumption.
[0038] As a possible implementation method, the coprocessor receives a broadcast message via Bluetooth, and the broadcast message carries a second TCP connection keep-alive message; the coprocessor determines that the service identifier carried by the second TCP connection keep-alive message is the identifier of the first service and the identifier of the TCP connection carried is the identifier of the first TCP connection, then saves the mapping relationship between the identifier of the first service and the identifier of the first TCP connection, and sets a timeout period.
[0039] As a possible implementation method, the coprocessor determines that the second TCP connection keep-alive message is not received again within the timeout period, and deletes the mapping relationship; or, determines that the second TCP connection keep-alive message is received again within the timeout period, and does not delete the mapping relationship.
[0040] Based on the above scheme, a timeout period is set, and when a TCP connection keep-alive message is received within the timeout period, the TCP connection is maintained, otherwise the TCP connection is determined to have timed out, and the TCP connection is no longer maintained. In this way, the energy consumption of the device can be reduced.
[0041] As a possible implementation method, the coprocessor determines that the application processor is in a sleep state and has not received the second TCP connection keep-alive message within the timeout period, then wakes up the application processor; the coprocessor sends indication information to the application processor, where the indication information is used to notify that the physical layer link between the first device and the second device is disconnected; and the coprocessor releases the first TCP connection.
[0042] As a possible implementation method, the application processor determines that the WLAN physical layer link between the first device and the second device is disconnected, then sends a second request to the coprocessor, the second request carries the identifier of the first service, and the second request is used to request to obtain the identifier of the first TCP connection corresponding to the identifier of the first service; the coprocessor sends the identifier of the first TCP connection corresponding to the identifier of the first service to the application processor; the application processor determines that the identifier of the first TCP connection is received, and determines not to release the first TCP connection.
[0043] As a possible implementation method, the coprocessor receives a broadcast message via Bluetooth, the broadcast message carries a third TCP connection keep-alive message, the third TCP connection keep-alive message carries an identifier of the second service and an identifier of the second TCP connection; if the coprocessor determines that the second service is not a whitelist service, the third TCP connection keep-alive message is discarded. Based on this solution, TCP connection keep-alive is not performed for non-whitelist services, which can reduce energy consumption.
[0044] As a possible implementation method, if the coprocessor determines that a response message has been received for the first TCP connection keep-alive message, the coprocessor does not notify the application processor to release the first TCP connection, that is, it determines that the first TCP connection is kept alive successfully; or, if the coprocessor determines that no corresponding response messages have been received for N consecutively sent keep-alive messages of the first TCP connection, the coprocessor notifies the application processor to release the first TCP connection, that is, it determines that the keep-alive of the first TCP connection has failed, where N is a positive integer.
[0045] As a possible implementation method, after the application processor sends the first request to the coprocessor, the method further includes: the application processor entering a sleep state.
[0046] In a fifth aspect, an embodiment of the present application provides a communication device, which may be a coprocessor. The device has the function of implementing each implementation method of the first aspect above. The function may be implemented by hardware, or by hardware executing corresponding software implementation. The hardware or software includes one or more modules corresponding to the above functions.
[0047] In a sixth aspect, an embodiment of the present application provides a communication device, which may be an application processor. The device has the function of implementing each implementation method of the second aspect above. The function may be implemented by hardware, or by hardware executing corresponding software implementation. The hardware or software includes one or more modules corresponding to the above functions.
[0048] In a seventh aspect, an embodiment of the present application provides a communication device, which may be a first device or a chip for a first device. The device has the function of implementing the various implementation methods of the third aspect or the various implementation methods of the fourth aspect. The function may be implemented by hardware, or may be implemented by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above functions.
[0049] In an eighth aspect, an embodiment of the present application provides a communication device, including a processor, the processor is coupled to a memory, the memory is used to store programs or instructions, and when the programs or instructions are executed by the processor, the device implements any implementation method of the first to fourth aspects above. The memory can be located inside the device or outside the device. And the processor includes one or more.
[0050] In a ninth aspect, an embodiment of the present application provides a communication device, comprising a unit or means for executing each step of any implementation method of the first to fourth aspects above.
[0051] In a tenth aspect, an embodiment of the present application provides a communication device, including a processor and an interface circuit, wherein the processor is used to control the interface circuit to communicate with other devices and execute any implementation method of the first to fourth aspects above. The processor includes one or more.
[0052] In the eleventh aspect, an embodiment of the present application further provides a computer-readable storage medium, comprising instructions, which, when executed on a computer, enables the computer to execute any implementation method of the first to fourth aspects above.
[0053] In the twelfth aspect, the embodiments of the present application also provide a computer program product, which, when executed on a computer, enables the computer to execute any implementation method of the first to fourth aspects above.
[0054] In a thirteenth aspect, an embodiment of the present application further provides a chip system, including a processor, the processor is coupled to a memory, the memory is used to store programs or instructions, and when the programs or instructions are executed by the processor, the chip system implements any implementation method of the first to fourth aspects above. The memory can be located inside the chip system or outside the chip system. And the processor includes one or more.
[0055] In a fourteenth aspect, an embodiment of the present application further provides a communication system, comprising a coprocessor for executing any implementation method of the above-mentioned first aspect, and an application processor for executing any implementation method of the above-mentioned second aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] Figure 1 This is a schematic diagram of the TCP connection disconnection process in the WLAN physical layer disconnection scenario;
[0057] Figure 2 This is a schematic diagram of the TCP connection disconnection process in the terminal device screen-off sleep scenario;
[0058] Figure 3 A schematic diagram of a framework structure applicable to an embodiment of the present application;
[0059] Figure 4 A schematic diagram of the structure of the keep-alive service module provided in the embodiment of the present application;
[0060] Figure 5 A schematic diagram of the structure of the keep-alive application module provided in the embodiment of the present application;
[0061] Figure 6 A schematic diagram of the whitelist update process provided in an embodiment of the present application;
[0062] Figure 7 A schematic diagram of a keep-alive process for a non-whitelist service provided in an embodiment of the present application;
[0063] Figure 8 A schematic diagram of a keep-alive process for a whitelist service provided in an embodiment of the present application;
[0064] Fig. 9 A schematic diagram of a keep-alive process for receiving non-whitelist services provided in an embodiment of the present application;
[0065] Fig.10 A schematic diagram of a whitelist service receiving keep-alive process provided in an embodiment of the present application;
[0066] Fig.11 A schematic diagram of a process in which a service is not kept alive after a WLAN physical layer is disconnected provided in an embodiment of the present application;
[0067] Fig.12 A schematic diagram of a service keep-alive process after a WLAN physical layer is disconnected provided in an embodiment of the present application;
[0068] Fig.13 A schematic diagram of a process for not keeping services alive after a terminal device turns off its screen and goes to sleep, provided in an embodiment of the present application;
[0069] Fig.14 A schematic diagram of a successful TCP connection keep-alive process provided in an embodiment of the present application;
[0070] Fig.15 A schematic diagram of a process for determining a TCP connection keep-alive failure provided in an embodiment of the present application;
[0071] Fig.16 An example diagram of the structure of a TCP connection keep-alive message or a TCP connection keep-alive Ack message provided in an embodiment of the present application;
[0072] Fig.17 A schematic diagram of a TCP keep-alive method provided in an embodiment of the present application;
[0073] Fig.18 A schematic diagram of another TCP keep-alive method provided in an embodiment of the present application;
[0074] Fig.19 It is a schematic diagram of the structure of a mobile phone;
[0075] Fig. 20 A schematic diagram of a communication device provided in an embodiment of the present application;
[0076] Fig.21 A schematic diagram of the structure of a terminal device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0077] In order to make the purpose, technical solution and advantages of the present application clearer, the present application will be further described in detail below with reference to the accompanying drawings. The specific operation method in the method embodiment can also be applied to the device embodiment or the system embodiment. In the description of the present application, unless otherwise specified, the meaning of "multiple" is two or more.
[0078] To reduce the overhead of establishing TCP connections for various services, the current solution is that the Android system will keep certain TCP connections alive after the WLAN physical layer is disconnected or the terminal device goes into sleep mode with the screen off. The following describes the two scenarios of WLAN physical layer disconnection and terminal device sleep mode with the screen off.
[0079] Scenario 1: WLAN physical layer disconnection scenario
[0080] like Figure 1 The figure shows the TCP connection disconnection process in the WLAN physical layer disconnection scenario. When the WLAN physical layer of the terminal device is disconnected from the peer device (such as a car computer, speaker, headset, watch / bracelet, tablet, large screen, personal computer, virtual reality (VR) / augmented reality (AR)), the WLAN driver layer (WLAN driver) in the application processor (AP) of the terminal device will notify the hardware abstraction layer (HAL), framework layer (Framework) and application layer (APP) respectively, and the user-mode protocol stack module (InProcessNetworkStack) of the application layer will destroy all TCP connections on the WLAN physical layer through the network management daemon (Netd).
[0081] When the WLAN physical layer connection is restored, all previous TCP connections need to be re-established, and the service recovery time is relatively long.
[0082] Scenario 2: Terminal device screen off and sleep scenario
[0083] like Figure 2 The figure below is a schematic diagram of the TCP connection disconnection process in the scenario where the terminal device turns off the screen and goes to sleep. When the terminal device turns off the screen and goes to sleep, the power management service system (PowerManagerService) will notify the power saving module (HAware) of the application layer, and HAware will eventually destroy the TCP connection of non-whitelist services through Netd, while the TCP connection of whitelist services can be kept alive.
[0084] When the terminal device wakes up with the screen on, the TCP connection of the whitelisted services is kept alive, and TCP data communication can be carried out directly. Non-whitelisted services need to re-establish TCP connections and service connections, and the service recovery time is relatively long.
[0085] In the above scheme, the user-mode protocol stack of the Android system will destroy all TCP connections on the physical layer after the WLAN physical layer is disconnected. The power-saving module of the Android system will destroy the TCP connections of non-whitelist services after the terminal device turns off the screen and goes into sleep mode. These destroyed connections will take a lot of time to re-establish the connection after the WLAN physical layer connection is restored or the terminal device turns on the screen and wakes up, resulting in high overhead.
[0086] To solve the above problems, an embodiment of the present application provides a TCP keep-alive method, which implements TCP connection keep-alive on the SensorHub side through the Bluetooth Low Energy (BLE) scanning and BLE broadcast mechanism in the SensorHub, without waking up the application processor (AP), thereby realizing low-power TCP keep-alive technology. It should be noted that the SensorHub in the embodiment of the present application is a microprocessor or coprocessor, and the AP is an application processor. The SensorHub and the AP are two independent processors that can work in coordination with each other.
[0087] like Figure 3 As shown in FIG. 1 , a schematic diagram of a framework structure applicable to an embodiment of the present application is shown. The framework structure includes an application (APP) layer, a framework (Framework) layer, a hardware abstraction layer (HAL) and a kernel (Kernel) layer. Some functional modules included in each layer are as follows: Figure 3 As shown. Among them, Figure 3 The functions of each functional module shown are as follows:
[0088] 1) Third-party APP module: After the third-party APP module establishes a TCP connection, it calls the keepalive interface provided by the KeepAliveService module to keep the TCP connection alive.
[0089] 2) Power saving module (HAware): When the terminal device turns off the screen and goes into sleep mode, HAware calls KeepAliveService to obtain the keep-alive result of the TCP connection. If the keep-alive is successful, the TCP connection is not destroyed. Otherwise, the corresponding TCP connection is destroyed.
[0090] 3) User-mode protocol stack module (InProcessNetworkStack): When the WLAN physical layer is disconnected, InProcessNetworkStack calls KeepAliveService to obtain the keep-alive result of the TCP connection. If the keep-alive is successful, the TCP connection is not destroyed, otherwise the corresponding TCP connection is destroyed.
[0091] 4) Push Service Module (PushService): The push service function module of the Framework is responsible for receiving the updated whitelist pushed by the server, and finally updating the whitelist data to KeepAliveService and KeepAliveAPP.
[0092] 5) Interface Controller: When the WLAN physical layer is disconnected, the user-mode protocol stack module destroys all TCP connections on the WLAN physical layer through the Interface Controller.
[0093] 6) Network Management Service Module (NetworkManagementService): When the terminal device is in sleep mode with the screen off, the power saving module eliminates the TCP connection of non-whitelist services through the NetworkManagementService.
[0094] 7) Network Management Daemon (Netd): Provides a bridge for the Framework to control the kernel TCP / IP stack.
[0095] 8) KeepAlive Service Module: The AP implementation part of the TCP connection keepalive solution, which provides the TCP connection keepalive capability to third-party applications, provides TCP connection keepalive result query and other functions to the user-mode protocol stack module and power saving module, and provides keepalive failure callback to SensorHub. When the TCP connection keepalive fails, the TCP connection is destroyed. In addition, it can also receive whitelist update requests from the server.
[0096] 9) KeepAlive application module (KeepAliveAPP): The SensorHub implementation part of the TCP keepalive solution provides the AP with functions such as TCP connection keepalive, TCP connection keepalive result query and whitelist update, and uses the SensorHub's BLE broadcast mechanism to send TCP connection keepalive packets and uses the SensorHub's BLE scanning mechanism to receive TCP connection keepalive packets. Keepalive packet caching is implemented in the SensorHub. If the cache is valid, it means that the TCP connection is kept alive successfully. If the cache is invalid, it means that the TCP connection fails to be kept alive and the corresponding TCP connection needs to be destroyed. In addition, it can wake up the AP after the keepalive fails, and call back the invalidation result to the KeepAliveService of the AP.
[0097] 10)SensorHAL: Sensor hardware abstraction layer.
[0098] 11)SensorDriver: Sensor driver layer.
[0099] like Figure 4 FIG. 1 is a schematic diagram of the structure of the keepalive service module (KeepAliveService) provided in the embodiment of the present application. The keepalive service module includes the following functional modules:
[0100] 1) Wrapper module: This module provides an interface to third-party APP and Framework system modules for enabling TCP connection keepalive, querying TCP connection keepalive results, and other functions.
[0101] 2) Whitelist module (WhiteList): This module is responsible for saving the TCP connection keep-alive whitelist (can be referred to as keep-alive whitelist or whitelist for short). It can receive the updated whitelist sent by the server through PushService, and can also provide the wrapper with the whitelist query function. The whitelist module stores the package name (package name) and the service identifier (service id), and there is a mapping relationship between the package name and the service id. The package name is used to uniquely identify an application, and the service id is used to uniquely identify a service.
[0102] 3) Mapping module (KAMap): stores the mapping relationship between keepalive information (KAInfo) and file description information (Socket file description, skfd), as well as the mapping relationship between service identifier (service id) and skfd. Among them, KAInfo contains a four-tuple information consisting of source IP, source port, destination IP and destination port. This four-tuple information can uniquely identify a TCP connection, and one KAInfo corresponds to one skfd. Wrapper and Notify can query the skfd corresponding to the TCP connection based on KAInfo. Among them, service id is used to uniquely identify a service, and one service id can correspond to one or more skfd. Wrapper and Notify can query the skfd of all TCP connections contained in the entire service based on the service id.
[0103] 4) Notification module (Notify): When the terminal device is in sleep mode, the SensorHub detects that the peer device has been away for a long time, and considers that the TCP connection established between the terminal device and the peer device does not need to be kept alive. The SensorHub sends the KAInfo of the TCP connection that does not need to be kept alive to the AP through the notification module. The AP queries the skfd corresponding to the KAMap from the KAInfo, and then destroys the TCP connection through the Netd module.
[0104] like Figure 5 , which is a schematic diagram of the structure of the keep-alive application module (KeepAliveAPP) provided in an embodiment of the present application.
[0105] Among them, the keep-alive application module includes the following functional modules:
[0106] 1) Wrapper module: This module provides an interface to the KeepAliveService on the AP side, which is used to enable TCP connection keepalive, query TCP connection keepalive results, update the keepalive whitelist in the SensorHub, and notify the KeepAliveService on the AP side that a TCP connection keepalive fails.
[0107] 2) Builder: used to encapsulate the TCP connection keep-alive parameters passed down by the KeepAliveService on the AP side. For example, the TCP connection parameters include the service identifier (service id) and KAInfo, which are encapsulated into KAMsg.
[0108] 3) The first parsing module (RecvCacheParser): is used to parse the TCP connection keep-alive message KAMsg sent by the peer device scanned by the BLE scanning module, traverse and parse KAMsg, and determine whether the service of KAMsg is in the keep-alive whitelist through WhiteListSH. If it is not in the keep-alive whitelist, it will be discarded directly. If it is in the keep-alive whitelist, it will be added to KACache, and KAMsg Ack will be replied to the peer device to notify the peer device that the TCP connection keep-alive is successful.
[0109] 4) The second parsing module (RecvAckParser): used to parse the response message (called KAMsg Ack) for the TCP connection keep-alive message replied by the peer device scanned by the BLE scanning module. If the KAMsg Ack of the TCP connection can be continuously received, it means that the TCP connection corresponding to the KAMsg is kept alive successfully, and the KAMsg can be sent regularly for keep-alive. If the corresponding KAMsg Ack is not received after N consecutive KAMsgs are sent, it means that the TCP connection keep-alive fails, then the KAMsg is cleared from the KAMsg list of the processing module, and the wrapper callback onDisconnect is sent to the AP layer (if the AP is asleep, it needs to wake up the AP first).
[0110] 5) Processor: Aggregate the TCP connection keep-alive request sent by the KeepAliveService on the AP side downward, and periodically send TCP connection keep-alive packets through a scheduled task. When there are many TCP connections that need to be kept alive, the length of the TCP connection keep-alive packet will exceed the maximum length that a single BLE broadcast can carry. The processing module will fragment the TCP connection keep-alive packet before sending it. Receive the TCP connection keep-alive packet scanned by the BLE scanning module upward. If the connection keep-alive packet is a fragment of a series of TCP connection keep-alive packets, the processing module is responsible for reassembling the fragments of this series of TCP connection keep-alive packets, and after reassembly, the complete TCP connection keep-alive packet will be handed over to RecvCacheParser for processing.
[0111] 6) BLE scanning module: used to scan the TCP connection keep-alive packets sent by the peer device via BLE broadcast.
[0112] 7) BLE broadcast module: used to broadcast TCP connection keep-alive packets to the peer device through the Bluetooth chip (BlueTooth Chip, BL Chip).
[0113] 8) Keep-alive cache module (KACache): used to record the service identifier and KAInfo scanned periodically by the BLE scanning module, and set the timeout period. When the same service identifier and KAInfo are not received after the timeout period, the TCP connection corresponding to the KAInfo is judged to have timed out, and the recorded service identifier and KAInfo are cleared in KACache.
[0114] 9) Whitelist module (WhiteListSH): The whitelist module in SensorHub is responsible for saving the TCP connection keep-alive whitelist (can be referred to as keep-alive whitelist or whitelist for short). It can receive the updated whitelist sent by the server through Wrapper, and can also provide whitelist query function to wrapper and RecvCacheParser. The whitelist module saves the package name (package name) and service identifier (service id), and there is a mapping relationship between the package name and the service id. The package name is used to uniquely identify an application, and the service id is used to uniquely identify a service.
[0115] The following is combined with the above Figure 3 , Figure 4 and Figure 5 The structure shown introduces the specific implementation of the low-power TCP keep-alive method provided in the embodiment of the present application.
[0116] like Figure 6 As shown, a schematic diagram of a whitelist update process provided in an embodiment of the present application includes the following steps:
[0117] Step 601: The server sends whitelist configuration information to PushService. Accordingly, PushService receives the whitelist configuration information.
[0118] The whitelist configuration information carries an updated keep-alive whitelist, or carries a keep-alive whitelist that needs to be added, or carries a keep-alive whitelist that needs to be deleted, and so on.
[0119] Step 602: PushService sends whitelist configuration information to WhiteList. Accordingly, WhiteList receives the whitelist configuration information.
[0120] Step 603: WhiteList updates the keep-alive whitelist according to the whitelist configuration information.
[0121] Through the above steps 601 to 603, the update of the keep-alive whitelist stored in the WhiteList is achieved.
[0122] Step 604: WhiteList sends whitelist configuration information to Wrapper. Correspondingly, Wrapper receives the whitelist configuration information.
[0123] The whitelist configuration information carries an updated keep-alive whitelist, or carries a keep-alive whitelist that needs to be added, or carries a keep-alive whitelist that needs to be deleted, and so on.
[0124] The whitelist configuration information here may be the same as the whitelist configuration information in step 601 , or may be obtained based on the whitelist configuration information in step 601 .
[0125] Step 605: Wrapper sends whitelist configuration information to WhiteListSH. Accordingly, WhiteListSH receives the whitelist configuration information.
[0126] Step 606: WhiteListSH updates the keep-alive whitelist according to the whitelist configuration information.
[0127] Through the above steps 604 to 606, PushService receives the whitelist configuration information from the server, and then sends the whitelist configuration information to WhiteList, thereby updating the whitelist stored in WhiteList, and WhiteList sends the whitelist configuration information to WhiteListSH through Wrapper, thereby updating the keep-alive whitelist stored in WhiteListSH.
[0128] In the embodiment of the present application, the keep-alive whitelist has the following functions:
[0129] 1) Before the SensorHub broadcasts the TCP connection keep-alive packet (also called the TCP connection keep-alive message) through the BLE broadcast module, it determines whether the service is in the keep-alive whitelist. If it is not in the keep-alive whitelist, the TCP connection keep-alive packet will not be broadcasted. If it is in the keep-alive whitelist, the TCP connection keep-alive packet will be broadcasted.
[0130] 2) After the SensorHub scans the TCP connection keep-alive packet sent by the peer device through the BLE scanning module, it determines whether the service id in the TCP connection keep-alive packet is in the keep-alive whitelist. If it is in the keep-alive whitelist, it indicates that the terminal device matches the keep-alive whitelist of the peer device and the TCP connection needs to be kept alive. If it is not in the keep-alive whitelist, it indicates that the terminal device does not match the keep-alive whitelist of the peer device and the TCP connection does not need to be kept alive.
[0131] 3) TCP connection keepalive requires knowing which TCP connection of which specific service to keep alive. If the services are distinguished directly by package name, it will take up too many BLE broadcast bytes. Therefore, there is a mapping relationship from package name to service id in the keepalive whitelist. When broadcasting, the service id is carried in the TCP connection keepalive packet to reduce overhead.
[0132] like Figure 7 As shown, a schematic diagram of a keep-alive process for a non-whitelist service provided in an embodiment of the present application includes the following steps:
[0133] Step 701, the ThirdParty APP sends KAInfo and skfd to the AP's Wrapper. Correspondingly, the Wrapper receives KAInfo and skfd.
[0134] After the ThirdParty APP creates a socket for the service, it sends KAInfo and skfd to the Wrapper to request to keep the TCP connection alive. One socket corresponds to one TCP connection. KAInfo contains a four-tuple consisting of source IP, source port, destination IP and destination port. This four-tuple information can uniquely identify a TCP connection. One KAInfo corresponds to one skfd, which is the file description information.
[0135] Step 702: Wrapper obtains the package name.
[0136] For example, the ThirdParty APP calls the Wrapper and sends KAInfo and skfd to the Wrapper, thereby triggering the Wrapper to obtain the package name corresponding to the KAInfo.
[0137] A package name uniquely identifies an application. An application contains one or more services, and each service can have a service ID.
[0138] The package name obtained in step 702 corresponds to the KAInfo in step 701. Specifically, a TCP connection indicated by the KAInfo is established on a service in the application indicated by the package name.
[0139] Step 703: Wrapper sends the package name to WhiteList, and WhiteList receives the package name accordingly.
[0140] Step 704: WhiteList determines that the package name is not in the keep-alive whitelist.
[0141] Step 705: WhiteList sends notification information to Wrapper. Correspondingly, Wrapper receives the notification information.
[0142] This notification message is used to notify that the package name is not in the keep-alive whitelist.
[0143] Since the packet name is not in the keep-alive whitelist, the TCP connection indicated by KAInfo is not kept alive.
[0144] Based on the above solution, when WhiteList determines that the packet name is not in the keep-alive whitelist, it notifies Wrapper that the packet name is not in the keep-alive whitelist, thereby triggering no keep-alive for the TCP connection indicated by KAInfo, that is, no keep-alive for non-whitelist services, which can reduce the keep-alive overhead.
[0145] like Figure 8 As shown, a schematic diagram of a whitelist service sending keep-alive process provided in an embodiment of the present application includes the following steps:
[0146] Step 801, the ThirdParty APP sends KAInfo and skfd to the Wrapper of the AP. Correspondingly, the Wrapper receives KAInfo and skfd.
[0147] After the ThirdParty APP creates a socket for the service, it sends KAInfo and skfd to the Wrapper to request to keep the TCP connection alive. One socket corresponds to one TCP connection. KAInfo contains a four-tuple consisting of source IP, source port, destination IP and destination port. This four-tuple information can uniquely identify a TCP connection. One KAInfo corresponds to one skfd, which is the file description information.
[0148] Step 802: Wrapper obtains the package name.
[0149] For example, the ThirdParty APP calls the Wrapper and sends KAInfo and skfd to the Wrapper, thereby triggering the Wrapper to obtain the package name corresponding to the KAInfo.
[0150] A package name uniquely identifies an application. An application contains one or more services, and each service can have a service ID.
[0151] The package name obtained in step 802 corresponds to the KAInfo in the above step 801. Specifically, a TCP connection indicated by the KAInfo is established on a service in the application indicated by the package name.
[0152] Step 803: Wrapper sends the package name to WhiteList, and WhiteList receives the package name accordingly.
[0153] Step 804: WhiteList determines that the package name is in the keep-alive whitelist, and obtains the service ID corresponding to the package name.
[0154] Step 805: WhiteList sends the service identifier to Wrapper. Correspondingly, Wrapper receives the service identifier.
[0155] Since the packet name is in the keep-alive whitelist, the TCP connection indicated by KAInfo is kept alive.
[0156] Step 806: Wrapper sends the service identifier, KAInfo and skfd to the Builder of SensorHub. Correspondingly, the Builder receives the service identifier, KAInfo and skfd.
[0157] Step 807, Builder saves the mapping relationship between the business identifier and skfd, and the mapping relationship between KAInfo and skfd.
[0158] Step 808: Wrapper sends a registerKAConnection request to Builder. Accordingly, Builder receives the registerKAConnection request.
[0159] The registerKAConnection request is used to request to keep the TCP connection indicated by KAInfo alive.
[0160] The registerKAConnection request carries the service identifier and KAInfo.
[0161] Step 809: Builder sends a registerKAConnection response to the ThirdParty APP. Accordingly, the ThirdParty APP receives the registerKAConnection response.
[0162] The registerKAConnection response is used to indicate the completion of the heartbeat registration of the TCP connection on the SensorHub.
[0163] Step 810: Builder encapsulates KAMsg according to the service identifier and KAInfo.
[0164] That is, KAMsg includes the service identifier and KAInfo.
[0165] Step 811, Builder sends KAMsg to Prosessor of SensorHub. Correspondingly, Prosessor receives KAMsg.
[0166] Step 812, Prosessor periodically obtains the cached KAMsg, and then broadcasts it through the BLE broadcast module.
[0167] In the embodiment of the present application, the Prosessor may periodically notify the BLE broadcast module to broadcast KAMsg externally, and each broadcast may send a KAMsg list, which may contain one or more KAMsgs.
[0168] Based on the above solution, for whitelist services, low-power TCP keep-alive is implemented for whitelist services through the BLE broadcast module of the terminal device, which can reduce the overhead caused by releasing and reestablishing TCP connections.
[0169] like Fig. 9 As shown, a schematic diagram of a non-whitelist service receiving keep-alive process provided in an embodiment of the present application includes the following steps:
[0170] Step 901, the BLE scanning module of the SensorHub sends KAMsg to the processing module (Processor). Correspondingly, the Processor receives KAMsg.
[0171] After receiving one or more KAMsgs sent by the peer device, the BLE scanning module sends the scanned KAMsg to the Processor. As an implementation method, the peer device sends in the form of a KAMsg list, and the BLE scanning module receives the KAMsg list.
[0172] Step 902: Processor sends KAMsg to the first parsing module (RecvCacheParser). Correspondingly, RecvCacheParser receives KAMsg.
[0173] Step 903: RecvCacheParser parses the service identifier and KAInfo from KAMsg.
[0174] Step 904: RecvCacheParser sends the service identifier to WhiteListSH. Accordingly, WhiteListSH receives the service identifier.
[0175] Step 905: WhiteListSH determines that the service identifier is not in the keep-alive whitelist.
[0176] Step 906: WhiteListSH sends notification information to RecvCacheParser. Correspondingly, RecvCacheParser receives the notification information.
[0177] This notification information is used to notify that the service identifier is not in the keep-alive whitelist. RecvCacheParser can discard the parsed KAInfo.
[0178] Since the service identifier is not in the keep-alive whitelist, the TCP connection indicated by KAInfo is not kept alive.
[0179] Based on the above solution, when the BLE scanning module receives KAMsg from the peer device and WhiteListSH determines that the KAMsg terminal service identifier is not in the keep-alive whitelist, it triggers RecvCacheParser to discard the parsed KAInfo, that is, non-whitelist services are not kept alive, which can reduce the keep-alive overhead.
[0180] like Fig.10 As shown, a schematic diagram of a whitelist service receiving keep-alive process provided in an embodiment of the present application includes the following steps:
[0181] Step 1001, the BLE scanning module of the SensorHub sends KAMsg to the processing module (Processor). Correspondingly, the Processor receives KAMsg.
[0182] After receiving one or more KAMsgs sent by the peer device, the BLE scanning module sends the scanned KAMsg to the Processor. As an implementation method, the peer device sends in the form of a KAMsg list, and the BLE scanning module receives the KAMsg list.
[0183] Step 1002: Processor sends KAMsg to the first parsing module (RecvCacheParser). Correspondingly, RecvCacheParser receives KAMsg.
[0184] Step 1003, RecvCacheParser parses the service identifier and KAInfo from KAMsg.
[0185] Step 1004: RecvCacheParser sends the service identifier to WhiteListSH. Accordingly, WhiteListSH receives the service identifier.
[0186] Step 1005: WhiteListSH determines that the service identifier is in the keep-alive whitelist.
[0187] Step 1006: WhiteListSH sends notification information to RecvCacheParser. Correspondingly, RecvCacheParser receives the notification information.
[0188] The notification information is used to notify that the service identifier is in the keep-alive whitelist.
[0189] Since the service identifier is in the keep-alive whitelist, the TCP connection indicated by KAInfo needs to be kept alive.
[0190] Step 1007: RecvCacheParser sends the service identifier and KAInfo to KACache. Correspondingly, KACache receives the service identifier and KAInfo.
[0191] Step 1008, KACache saves the mapping relationship between the service identifier and KAInfo, and sets a timeout period.
[0192] When the TCP connection between the terminal device and the peer device remains normally connected, the BLE scanning module of the terminal device can periodically obtain the KAMsg corresponding to the TCP connection, so that KACache can periodically obtain the service identifier and KAInfo corresponding to the TCP connection. As long as the time interval between KACache's acquisition of the service identifier and KAInfo corresponding to the TCP connection this time and the last acquisition of the service identifier and KAInfo corresponding to the TCP connection does not exceed the preset timeout period, it indicates that the TCP connection is valid and can continue to be kept alive, and there is no need to release the TCP connection. If the time interval between KACache's acquisition of the service identifier and KAInfo corresponding to the TCP connection this time and the last acquisition of the service identifier and KAInfo corresponding to the TCP connection exceeds the preset timeout period, or KAInfo does not obtain the service identifier and KAInfo within the set time after the last acquisition of the service identifier and KAInfo, it indicates that the TCP connection is invalid and does not need to be kept alive, so the TCP connection needs to be released.
[0193] As an example, for TCP connection 1, the TCP connection 1 corresponds to service identifier-1 and KAInfo-1. KACache receives service identifier-1 and KAInfo-1 at time T1, and then receives service identifier-1 and KAInfo-1 at time T2. If the difference between T2 and T1 is not greater than the preset timeout period, KACache does not notify KeepAliveService to release the TCP connection 1. Then, KACache receives service identifier-1 and KAInfo-1 at time T3. If the difference between T3 and T2 is greater than the preset timeout period, KACache notifies KeepAliveService to release the TCP connection 1. Alternatively, if KACache does not receive service identifier-1 and KAInfo-1 within the timeout period after time T2, KACache also notifies KeepAliveService to release the TCP connection 1.
[0194] Step 1009, RecvCacheParser sends KAMsg Ack via the BLE broadcast module.
[0195] Specifically, if the time interval between the service identifier and KAInfo corresponding to the TCP connection obtained by KACache this time and the last time the service identifier and KAInfo corresponding to the TCP connection was obtained does not exceed the preset timeout period, RecvCacheParser sends a KAMsg Ack through the BLE broadcast module. The KAMsg Ack is used to notify the peer device that the TCP connection corresponding to the KAMsg has been kept alive successfully.
[0196] Based on the above solution, for whitelist services, low-power TCP keep-alive can be implemented for whitelist services through the BLE scanning module of the terminal device, which can reduce the overhead caused by releasing and reestablishing TCP connections.
[0197] like Fig.11 As shown, it is a schematic diagram of the process of not keeping the service alive after the WLAN physical layer is disconnected provided in an embodiment of the present application. The scenario targeted by this solution is: the other device connected to the terminal device leaves the terminal device, resulting in the disconnection of the WLAN physical layer connection between the terminal device and the other device, and the Bluetooth connection is also disconnected, so that the BLE scanning module of the terminal device cannot scan the KAMsg sent by the other device, thereby triggering the release of all TCP connections between the terminal device and the other device.
[0198] The method comprises the following steps:
[0199] Step 1101, InProcessNetworkStack sends notification information to the AP's Wrapper. Correspondingly, the Wrapper receives the notification information.
[0200] If InProcessNetworkStack determines that the WLAN physical layer connection between the terminal device and the peer device has been disconnected, it sends a notification message to the AP's Wrapper, where the notification message is used to notify that the WLAN physical layer connection has been disconnected.
[0201] Step 1102, Wrapper obtains the package name.
[0202] For example, InProcessNetworkStack calls Wrapper, which triggers Wrapper to obtain all package names.
[0203] A package name uniquely identifies an application. An application contains one or more services, and each service can have a service ID.
[0204] Step 1103: Wrapper sends the package name to WhiteList, and WhiteList receives the package name accordingly.
[0205] Step 1104, WhiteList determines that the package name is in the keep-alive whitelist, and obtains the service ID corresponding to the package name.
[0206] Step 1105: WhiteList sends the service identifier to Wrapper. Correspondingly, Wrapper receives the service identifier.
[0207] Since the packet name is in the keep-alive whitelist, the TCP connection indicated by KAInfo is kept alive.
[0208] Among them, the TCP connection in the service corresponding to the service identifier needs to be kept alive. However, since TCP connection keep-alive is bidirectional, that is, only when the other end device of the TCP connection also needs to keep the TCP connection alive, the terminal device will keep the TCP connection alive. Therefore, the following step 1106 needs to be executed.
[0209] Step 1106, Wrapper sends getKAInfosById to KACache of SensorHub. Correspondingly, KACache receives getKAInfosById.
[0210] The getKAInfosById carries the business identifier and is used to request to obtain the KAInfo corresponding to the business identifier.
[0211] Step 1107, KACache determines that there is no KAInfo corresponding to the service identifier in KACache.
[0212] This embodiment is aimed at the application scenario where the peer device leaves the terminal device, so the WLAN physical layer connection between the terminal device and the peer device is disconnected and the Bluetooth connection is also disconnected. Therefore, KACache will receive the service identifier and KAInfo timeout, and KACache will clear the service identifier and KAInfo.
[0213] Step 1108: KACache sends a notification message to Wrapper, and Wrapper receives the notification message accordingly.
[0214] This notification information is used to notify that the KAInfo corresponding to the service identifier is not found.
[0215] Step 1109: Wrapper sends the service identifier and indication information to KAMap. Correspondingly, KAMap receives the service identifier and indication information.
[0216] Based on the service identifier, the Wrapper requests KAMap to obtain the skfd corresponding to the service identifier, and generates the indication information based on the notification information, where the indication information is used to indicate the release of the TCP connection corresponding to the skfd.
[0217] Step 1110, KAMap obtains the skfd corresponding to the business identifier.
[0218] The obtained skfd may be all or part of the skfd corresponding to the service identifier.
[0219] Step 1111, KAMap sends skfd and indication information to InProcessNetworkStack. Correspondingly, InProcessNetworkStack receives skfd and indication information.
[0220] The indication information of step 1111 may be the same as the indication information of step 1109, or may be generated according to the indication information of step 1109. The indication information is used to indicate the release of the TCP connection corresponding to the skfd.
[0221] Step 1112, InProcessNetworkStack releases the TCP connection corresponding to skfd according to the instruction information.
[0222] Based on the above solution, when the peer device connected to the terminal device moves away from the terminal device, causing the WLAN physical layer connection between the terminal device and the peer device to be disconnected and the Bluetooth connection to be disconnected, the terminal device is triggered to release all TCP connections, thereby saving signaling overhead.
[0223] like Fig.12 As shown, it is a schematic diagram of the service keeping-alive process after the WLAN physical layer is disconnected provided in an embodiment of the present application. The scenario targeted by this solution is: the WLAN physical layer connection between the terminal device and the opposite device is disconnected, but the Bluetooth connection is not disconnected. The BLE scanning module of the terminal device can scan the KAMsg sent by the opposite device, so there is no need to release the TCP connection between the terminal device and the opposite device, that is, to keep the TCP connection alive.
[0224] The method comprises the following steps:
[0225] Step 1201, InProcessNetworkStack sends notification information to the Wrapper of the AP. Correspondingly, the Wrapper receives the notification information.
[0226] If InProcessNetworkStack determines that the WLAN physical layer connection between the terminal device and the peer device has been disconnected, it sends a notification message to the AP's Wrapper, where the notification message is used to notify that the WLAN physical layer connection has been disconnected.
[0227] Step 1202, Wrapper obtains the package name.
[0228] For example, InProcessNetworkStack calls Wrapper, which triggers Wrapper to obtain all package names.
[0229] A package name uniquely identifies an application. An application contains one or more services, and each service can have a service ID.
[0230] Step 1203: Wrapper sends the package name to WhiteList, and WhiteList receives the package name accordingly.
[0231] Step 1204, WhiteList determines that the package name is in the keep-alive whitelist, and obtains the service ID corresponding to the package name.
[0232] Step 1205: WhiteList sends the service identifier to Wrapper. Correspondingly, Wrapper receives the service identifier.
[0233] Since the packet name is in the keep-alive whitelist, the TCP connection indicated by KAInfo is kept alive.
[0234] Among them, the TCP connection in the service corresponding to the service identifier needs to be kept alive. However, since TCP connection keep-alive is bidirectional, that is, only when the other end device of the TCP connection also needs to keep the TCP connection alive, the terminal device will keep the TCP connection alive. Therefore, the following step 1206 needs to be executed.
[0235] Step 1206: Wrapper sends getKAInfosById to KACache of SensorHub. Correspondingly, KACache receives getKAInfosById.
[0236] The getKAInfosById carries the business identifier and is used to request to obtain the KAInfo corresponding to the business identifier.
[0237] Step 1207, KACache obtains KAInfo corresponding to the service identifier.
[0238] This embodiment targets a situation where the WLAN physical layer connection between the terminal device and the peer device is disconnected, but the Bluetooth connection is not disconnected. KACache can receive the service identifier and KAInfo sent by the peer device through BLE broadcast, that is, KACache's reception of the service identifier and KAInfo will not timeout, and therefore KACache will not clear the service identifier and KAInfo, that is, the service identifier and KAInfo are stored in KACache.
[0239] Step 1208: KACache sends KAInfo to Wrapper, and Wrapper receives KAInfo accordingly.
[0240] The KAInfo sent by KACache to Wrapper may be all or part of the KAInfo corresponding to the service identifier.
[0241] Step 1209: Wrapper sends KAInfo and indication information to KAMap. Correspondingly, KAMap receives KAInfo and indication information.
[0242] Based on the KAInfo, the Wrapper requests KAMap to obtain the skfd corresponding to the KAInfo, and generates indication information based on the KAInfo, where the indication information is used to indicate that the TCP connection corresponding to the skfd should not be released.
[0243] Step 1210, KAMap obtains the skfd corresponding to KAInfo.
[0244] Step 1211, KAMap sends skfd and indication information to InProcessNetworkStack. Correspondingly, InProcessNetworkStack receives skfd and indication information.
[0245] The indication information of step 1211 may be the same as the indication information of step 1209, or may be generated according to the indication information of step 1209. The indication information is used to indicate that the TCP connection corresponding to the skfd is not to be released. Step 1212: InProcessNetworkStack determines not to release the TCP connection corresponding to the skfd according to the indication information.
[0246] Based on the above solution, when the WLAN physical layer connection between the terminal device and the peer device is disconnected but the Bluetooth connection is not disconnected, low-power TCP keep-alive can be performed between the terminal device and the peer device for the whitelist service, which can reduce the overhead caused by releasing and reestablishing the TCP connection.
[0247] like Fig.13 As shown, it is a schematic diagram of the process of not keeping the service alive after the terminal device turns off the screen and goes into sleep mode, which is provided in an embodiment of the present application. The scenario targeted by this solution is: after the terminal device enters the screen-off sleep state, the opposite device that is connected to the terminal device leaves the terminal device, causing the Bluetooth connection between the terminal device and the opposite device to be disconnected, so that the BLE scanning module of the terminal device cannot scan the KAMsg sent by the opposite device, thereby triggering the release of all TCP connections between the terminal device and the opposite device.
[0248] The method comprises the following steps:
[0249] Step 1301, KACache sends indication information to Notify, and accordingly, Notify receives the indication information.
[0250] The indication information is used to indicate that the BLE physical layer link is unavailable. The BLE physical layer link is unavailable here, for example, the Bluetooth connection between the terminal device and the opposite device is disconnected.
[0251] The indication information carries KAInfo, and the KAInfo is the KAInfo of reception timeout.
[0252] It should be noted that, in this embodiment, the BLE scanning module of the SensorHub is unable to scan the KAInfo broadcasted by the peer device for a long time, resulting in a timeout for KACache to receive KAInfo, so that KACache wakes up the AP through other modules of the SensorHub, and then the KACache of the SensorHub sends an indication message to the notification module (Notify) of the AP to inform the AP that the BLE physical layer link between the terminal device and the peer device is unavailable.
[0253] As an implementation method, the indication information may be a BLE disconnection event (onDisconnect).
[0254] Step 1302, Notify sends KAInfo to KAMap, and KAMap receives KAInfo accordingly.
[0255] Step 1303. KAMap obtains the skfd corresponding to KAInfo.
[0256] Step 1304, KAMap sends skfd to Notify, and Notify receives skfd accordingly.
[0257] Step 1305: Notify sends notification information to KAMap, and KAMap receives the notification information accordingly.
[0258] The notification information carries skfd, and is used to indicate the release of the TCP connection corresponding to the sdfd.
[0259] Based on the above solution, when the peer device connected to the terminal device moves away from the terminal device, causing the BLE physical layer connection between the terminal device and the peer device to be unavailable, the terminal device is triggered to release all TCP connections, thereby saving signaling overhead.
[0260] like Fig.14 As shown, a schematic diagram of a successful TCP connection keep-alive process provided in an embodiment of the present application includes the following steps:
[0261] Step 1401, the BLE scanning module of the SensorHub sends a KAMsg Ack to the processing module (Processor). Correspondingly, the Processor receives the KAMsg Ack.
[0262] After the BLE scanning module receives the KAMsg Ack sent by the peer device, it sends the scanned KAMsgAck to the Processor.
[0263] Step 1402: Processor sends KAMsg Ack to the second parsing module (RecvAckParser). Correspondingly, RecvAckParser receives KAMsg Ack.
[0264] Step 1403, RecvAckParser determines that the TCP connection corresponding to KAMsg Ack is kept alive successfully.
[0265] Since the confirmation response to KAMsg sent by the peer device is received, it is determined that the TCP connection is kept alive successfully, and there is no need to delete the KAMsg corresponding to the KAMsg Ack stored in the Processor.
[0266] Based on the above solution, the KAMsg Ack sent by the peer device is received through the BLE broadcast scanning module, so that the RecvAckParser can determine that the TCP connection keep-alive is successful, realizing the low-power TCP connection keep-alive function.
[0267] like Fig.15 As shown, a schematic diagram of a process for determining a TCP connection keep-alive failure provided in an embodiment of the present application includes the following steps:
[0268] Step 1501, the second parsing module (RecvAckParser) determines that N consecutive KAMsgs are sent without receiving a KAMsg Ack from the peer device.
[0269] When RecvAckParser determines that N consecutive KAMsgs have not received a KAMsg Ack from the peer device, it determines that the TCP connection keep-alive corresponding to the KAMsg Ack has failed.
[0270] Step 1502, RecvAckParser sends a KAMsg deletion instruction to the processing module (Processor). Accordingly, the Processor receives the KAMsg deletion instruction.
[0271] The KAMsg deletion indication is used to indicate the deletion of KAMsg, that is, to delete the KAMsg corresponding to the KAMsg Ack.
[0272] Step 1503, Processor deletes KAMsg.
[0273] Subsequently, the Processor no longer notifies the BLE broadcast module to broadcast the KAMsg to the peer device.
[0274] Step 1504: Processor sends indication information to Notify, and Notify receives the indication information accordingly.
[0275] This indication information is used to indicate that the TCP connection keep-alive fails. Subsequently, Notify can delete or release the TCP connection by notifying the AP.
[0276] As an implementation method, the indication information may be a disconnection event (onDisconnect).
[0277] Based on the above solution, the BLE broadcast scanning module can determine that the TCP connection keep-alive failure has occurred, and then delete the KAMsg, and the KAMsg will no longer be broadcast and sent subsequently, which helps to reduce the overhead of TCP connection keep-alive.
[0278] In summary, in the above embodiments of the present application, when the WLAN physical layer is disconnected or the terminal device is in sleep mode with the screen off, but the Bluetooth connection is not disconnected, the TCP connection is not directly destroyed, but the BLE broadcast module and BLE scanning module of the SensorHub are used to keep the TCP connection alive with low power consumption. Within the specified timeout period, if the WLAN physical layer is restored to establish the link or the terminal device is awakened with the screen on, there is no need to re-establish the TCP connection and the service connection. Through the BLE scanning and BLE broadcasting mechanisms in the SensorHub, the TCP keep-alive packets are cached at the SensorHub, and the TCP connection is kept alive on the SensorHub side without waking up the AP. When the device is off the network, the TCP keep-alive packet becomes invalid, and the AP is awakened again and the corresponding TCP connection is destroyed. Compared with the prior art, it meets both high performance (after the physical layer connection is restored / the terminal device is awakened with the screen on, there is no need to spend a lot of time to establish the TCP connection and the service connection) and low power consumption (the SensorHub sends a TCP keep-alive packet without waking up the AP).
[0279] like Fig.16 As shown, it is an example diagram of the structure of a TCP connection keep-alive message or a TCP connection keep-alive Ack message provided in an embodiment of the present application. A TCP connection keep-alive message or a TCP connection keep-alive Ack message may include TCP connection keep-alive information of one or more services. One service may include one or more TCP connections.
[0280] BLE preamble: The filter of the BLE scanning module can filter out uninteresting BLE broadcast signals based on the BLE preamble.
[0281] Device ID: The unique identifier of each terminal device.
[0282] Message type (Type): For example, Type=0 is a TCP connection keep-alive message, and Type=1 is a TCP connection keep-alive Ack message.
[0283] Service ID: A unique identifier for each service.
[0284] Count: Indicates the number of TCP connections that need to be kept alive for a service.
[0285] Four-tuple information: Four-tuple information is used to uniquely identify a TCP connection. The four-tuple information includes source IP (Source IP), destination IP (Destination IP), source port (Source Port) and destination port (Destination Port).
[0286] like Fig.17 As shown, it is a schematic diagram of a TCP keep-alive method provided in an embodiment of the present application. The method is executed by a first device or a chip of the first device. The following description will take the execution of the method by the first device as an example.
[0287] The method comprises the following steps:
[0288] Step 1701: The first device obtains an identifier of a first TCP connection and an identifier of a first service.
[0289] Optionally, file description information corresponding to the first TCP connection is also obtained.
[0290] The first TCP connection is a connection corresponding to the first service between the first device and the second device.
[0291] Step 1702: The first device determines that the first service corresponding to the first TCP connection is a whitelist service, and obtains a first TCP connection keep-alive message according to an identifier of the first service and an identifier of the first TCP connection.
[0292] Optionally, the first device further saves a mapping relationship between the identifier of the first TCP connection and the file description information, and saves a mapping relationship between the identifier of the first service and the file description information.
[0293] Step 1703: The first device broadcasts a first TCP connection keep-alive message via Bluetooth.
[0294] Based on the above scheme, when the WLAN physical layer link of the first device is disconnected or the screen is turned off and the device is in sleep mode, the first device does not destroy the whitelist service in the first device, but generates a TCP connection keep-alive message for the whitelist service, and then broadcasts the TCP connection keep-alive message via Bluetooth, thereby enabling TCP connection keep-alive for the whitelist service, without the need to frequently destroy and reestablish the TCP connection of the service, and thus reducing device overhead. In addition, the TCP connection keep-alive message is broadcasted via Bluetooth, which consumes relatively low power, thereby realizing low-power TCP connection keep-alive.
[0295] As an implementation method, when the first device determines that the WLAN physical layer link between the first device and the second device is disconnected, and determines that the second TCP connection keep-alive message is not received from the second device within the timeout period, the TCP connection of the first service is released, and the second TCP connection keep-alive message carries the identifier of the first service and the identifier of the first TCP connection. That is, TCP connection keep-alive is bidirectional. For the first service, the first device can broadcast the first TCP connection keep-alive message to the second device, and the second device also broadcasts the second TCP connection keep-alive message to the first device. When the first device determines that the second TCP connection keep-alive message is not received from the second device within the timeout period, it is determined that the TCP connection keep-alive corresponding to the first service has failed, and thus the TCP connection of the first service is released. When the first device determines that the WLAN physical layer link between the first device and the second device is disconnected, and determines that the second TCP connection keep-alive message is received from the second device within the timeout period, it is determined not to release the first TCP connection. In this way, the overhead of the device can be reduced.
[0296] Optionally, the first device may receive a broadcast message via Bluetooth, the broadcast message carrying a second TCP connection keep-alive message. When the first device determines that the service identifier carried by the second TCP connection keep-alive message is the identifier of the first service and the identifier of the TCP connection carried is the identifier of the first TCP connection, the mapping relationship between the identifier of the first service and the identifier of the first TCP connection is saved, and a timeout period is set; wherein, when the second TCP connection keep-alive message is not received again within the timeout period, the mapping relationship is deleted, and when the second TCP connection keep-alive message is received again within the timeout period, the mapping relationship is not deleted. When the first device determines that the first service is not a whitelist service, the second TCP connection keep-alive message is discarded.
[0297] Optionally, the first device can receive a broadcast message via Bluetooth, the broadcast message carries a third TCP connection keep-alive message, and the third TCP connection keep-alive message carries an identifier of the second service and an identifier of the second TCP connection. When the first device determines that the second service is not a whitelist service, the third TCP connection keep-alive message is discarded.
[0298] As an implementation method, if the first device determines that a response message is received for the first TCP connection keep-alive message, the first device does not notify the application processor to release the first TCP connection, that is, it is determined that the first TCP connection keep-alive is successful. Or if the first device determines that N consecutively sent first TCP connection keep-alive messages have not received corresponding response messages, the first device notifies the application processor to release the first TCP connection, that is, it is determined that the first TCP connection keep-alive fails, where N is a positive integer.
[0299] like Fig.18As shown, a TCP keep-alive method is provided in an embodiment of the present application, and the method is executed by an application processor AP and a coprocessor SensorHub of a first device.
[0300] The method comprises the following steps:
[0301] Step 1801: The application processor obtains an identifier of a first TCP connection and an identifier of a first service, where the first TCP connection is a connection between a first device and a second device corresponding to the first service.
[0302] Step 1802: The application processor determines that the first service corresponding to the TCP connection is a whitelist service, and then sends a first request to the coprocessor. Accordingly, the coprocessor receives the first request.
[0303] The first request carries an identifier of the first service and an identifier of the first TCP connection, and the first request is used to request to keep the first TCP connection of the first service alive.
[0304] Optionally, the application processor further determines file description information corresponding to the first TCP connection.
[0305] Optionally, the application processor saves a mapping relationship between the identifier of the first TCP connection and the file description information, and saves a mapping relationship between the identifier of the first service and the file description information.
[0306] Step 1803: The coprocessor obtains a first TCP connection keep-alive message according to the identifier of the first service and the identifier of the first TCP connection.
[0307] The first TCP connection keep-alive message carries the identifier of the first service and the identifier of the first TCP connection.
[0308] Step 1804: The coprocessor broadcasts a first TCP connection keep-alive message via Bluetooth.
[0309] Based on the above scheme, when the WLAN physical layer link of the first device is disconnected or the screen is turned off and the device is in sleep mode, the first device does not destroy the whitelist service in the first device, but generates a TCP connection keep-alive message for the whitelist service, and then broadcasts the TCP connection keep-alive message via Bluetooth, thereby enabling TCP connection keep-alive for the whitelist service, without the need to frequently destroy and reestablish the TCP connection of the service, and thus reducing device overhead. In addition, the TCP connection keep-alive message is broadcasted via Bluetooth, which consumes relatively low power, thereby realizing low-power TCP connection keep-alive.
[0310] As an implementation method, when the application processor determines that the WLAN physical layer link between the first device and the second device is disconnected, a second request is sent to the coprocessor, the second request carries the identifier of the first service, and the second request is used to request to obtain the identifier of the first TCP connection corresponding to the identifier of the first service. If the coprocessor sends a notification message to the application processor, the notification message is used to notify that the identifier of the first TCP connection corresponding to the identifier of the first service is not found, then the application processor releases the first TCP connection of the first service. If the coprocessor sends the identifier of the first TCP connection corresponding to the identifier of the first service to the application processor, then the application processor determines not to release the first TCP connection of the first service.
[0311] As an implementation method, the coprocessor determines that the application processor is in a dormant state and does not receive the second TCP connection keep-alive message within a timeout period, then wakes up the application processor, and then sends indication information to the application processor, the indication information carries the identifier of the first TCP connection, and the indication information is used to notify the first device and the second device that the physical layer link is disconnected. When the application processor receives the indication information from the coprocessor, the application processor releases the first TCP connection.
[0312] As an implementation method, the coprocessor can receive a broadcast message via Bluetooth, and the broadcast message carries a second TCP connection keep-alive message. If the coprocessor determines that the service identifier carried by the second TCP connection keep-alive message is the identifier of the first service and the identifier of the TCP connection carried is the identifier of the first TCP connection, then the mapping relationship between the identifier of the first service and the identifier of the first TCP connection is saved, and a timeout period is set. Among them, when the second TCP connection keep-alive message is not received again within the timeout period, the mapping relationship is deleted, and when the second TCP connection keep-alive message is received again within the timeout period, the mapping relationship is not deleted. That is, the coprocessor can determine whether the first service needs to be kept alive, and if it needs to be kept alive, the mapping relationship is saved.
[0313] As an implementation method, the coprocessor can receive a broadcast message via Bluetooth, the broadcast message carries a third TCP connection keep-alive message, the third TCP connection keep-alive message carries an identifier of the second service and an identifier of the second TCP connection, and if the coprocessor determines that the second service is not a whitelist service, the third TCP connection keep-alive message is discarded. That is, the coprocessor only keeps alive the TCP connection corresponding to the whitelist service.
[0314] As an implementation method, if the coprocessor determines that a response message is received for the first TCP connection keep-alive message, the application processor is not notified to release the first TCP connection, that is, it is determined that the first TCP connection is kept alive successfully; or if the coprocessor determines that N first TCP connection keep-alive messages sent continuously have not received corresponding response messages, the application processor is notified to release the first TCP connection, that is, it is determined that the first TCP connection keeps alive fails, where N is a positive integer.
[0315] In the embodiment of the present application, the terminal device is a device with wireless transceiver function, which can be deployed on land, including indoors or outdoors, handheld or vehicle-mounted; it can also be deployed on the water surface (such as ships, etc.); it can also be deployed in the air (for example, on airplanes, balloons and satellites, etc.). The terminal device also includes user equipment (UE). Exemplarily, the terminal device can be a mobile phone, a tablet computer (pad), a computer with wireless transceiver function, a virtual reality (VR) terminal, an augmented reality (AR) terminal, a wireless terminal in industrial control, a wireless terminal in self-driving, a wireless terminal in remote medical, a wireless terminal in smart grid, a wireless terminal in transportation safety, a wireless terminal in smart city, a wireless terminal in smart home, etc.
[0316] Take the mobile phone as an example. Fig.19The structure diagram of the mobile phone 1900 is shown. The mobile phone 1900 may include a processor 1910, an external memory interface 1920, an internal memory 1921, a USB interface 1930, a charging management module 1940, a power management module 1941, a battery 1942, an antenna 1, an antenna 2, a mobile communication module 1951, a wireless communication module 1952, an audio module 1970, a speaker 1970A, a receiver 1970B, a microphone 1970C, an earphone interface 1970D, a sensor module 1980, a button 1990, a motor 1991, an indicator 1992, a camera 1993, a display screen 1994, and a SIM card interface 1995, etc. The sensor module 1980 may include a gyroscope sensor 1980A, an acceleration sensor 1980B, a proximity light sensor 1980G, a fingerprint sensor 1980H, and a touch sensor 1980K (of course, the mobile phone 1900 may also include other sensors, such as a temperature sensor, a pressure sensor, a distance sensor, a magnetic sensor, an ambient light sensor, an air pressure sensor, a bone conduction sensor, etc., which are not shown in the figure).
[0317] It is to be understood that the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the mobile phone 1900. In other embodiments of the present application, the mobile phone 1900 may include more or fewer components than those shown in the figure, or combine some components, or separate some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0318] The processor 1910 may include one or more processing units, for example: the processor 1910 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 mobile phone 1900. 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.
[0319] The processor 1910 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 1910 is a cache memory. The memory may store instructions or data that the processor 1910 has just used or cyclically used. If the processor 1910 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 1910, and thus improves the efficiency of the system.
[0320] The processor 1910 can run the audio output method provided in the embodiment of the present application to reduce the user's operation complexity, improve the intelligence of the terminal device, and enhance the user experience. The processor 1910 can include different devices. For example, when the CPU and GPU are integrated, the CPU and GPU can cooperate to execute the audio output method provided in the embodiment of the present application. For example, part of the algorithm in the audio output method is executed by the CPU, and another part of the algorithm is executed by the GPU to obtain faster processing efficiency.
[0321] The display screen 1994 is used to display images, videos, etc. The display screen 1994 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 mobile phone 1900 may include 1 or N display screens 1994, where N is a positive integer greater than 1. The display screen 1994 can be used to display information input by a user or information provided to a user and various graphical user interfaces (GUI). For example, the display screen 1994 can display photos, videos, web pages, or files, etc. For another example, the display screen 1994 can display a graphical user interface. Among them, the graphical user interface includes a status bar, a hidden navigation bar, a time and weather widget, and application icons, such as a browser icon. The status bar includes the operator name (such as China Mobile), the mobile network (such as 4G), the time, and the remaining power. The navigation bar includes a back key icon, a home key icon, and a forward key icon. In addition, it can be understood that in some embodiments, the status bar may also include a Bluetooth icon, a Wi-Fi icon, an external device icon, etc. It can also be understood that in other embodiments, the graphical user interface may also include a Dock bar, and the Dock bar may include commonly used application icons, etc. When the processor 1910 detects a touch event of a user's finger (or a stylus, etc.) for a certain application icon, in response to the touch event, the user interface of the application corresponding to the application icon is opened, and the user interface of the application is displayed on the display screen 1994.
[0322] In the embodiment of the present application, the display screen 1994 can 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. After the processor 1910 runs the audio output method provided in the embodiment of the present application, the processor 1910 can control the external audio output device to switch the output audio signal.
[0323] The camera 1993 (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 1993 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.
[0324] The internal memory 1921 can be used to store computer executable program codes, which include instructions. The processor 1910 executes various functional applications and data processing of the mobile phone 1900 by running the instructions stored in the internal memory 1921. The internal memory 1921 may include a program storage area and a data storage area. Among them, the program storage area may store codes of operating systems, applications (such as camera applications, WeChat applications, etc.), etc. The data storage area may store data created during the use of the mobile phone 1900 (such as images and videos collected by camera applications, etc.), etc.
[0325] The internal memory 1921 may also store one or more computer programs corresponding to the audio output algorithm provided in the embodiment of the present application. The one or more computer programs are stored in the above-mentioned memory 1921 and are configured to be executed by the one or more processors 1910. The one or more computer programs include instructions, and the above-mentioned instructions can be used to execute such as Figures 6 to 13 In each step of the corresponding embodiment, the computer program may include an account verification module 19211 and a priority comparison module 19212. The account verification module 19211 is used to authenticate the system authentication account of other terminal devices in the local area network; the priority comparison module 19212 can be used to compare the priority of the audio output request service and the priority of the current output service of the audio output device. The state synchronization module 19213 can be used to synchronize the device state of the audio output device currently connected to the terminal device to other terminal devices, or synchronize the device state of the audio output device currently connected to the opposite device to the local. When the code of the audio output algorithm stored in the internal memory 1921 is executed by the processor 1910, the processor 1910 can control the audio output device to switch the output audio signal.
[0326] In addition, the internal memory 1921 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.
[0327] Of course, the code of the audio output algorithm provided in the embodiment of the present application can also be stored in an external memory. In this case, the processor 1910 can run the code of the audio output algorithm stored in the external memory through the external memory interface 1920, and the processor 1910 can control the audio output device to switch the output audio signal.
[0328] The functions of the sensor module 1980 are described below.
[0329] The gyroscope sensor 1980A can be used to determine the motion posture of the mobile phone 1900. In some embodiments, the angular velocity of the mobile phone 1900 around three axes (i.e., x, y, and z axes) can be determined by the gyroscope sensor 1980A. That is, the gyroscope sensor 1980A can be used to detect the current motion state of the mobile phone 1900, such as shaking or stillness.
[0330] When the display screen in the embodiment of the present application is a foldable screen, the gyroscope sensor 1980A can be used to detect a folding or unfolding operation on the display screen 1994. The gyroscope sensor 1980A can report the detected folding operation or unfolding operation as an event to the processor 1910 to determine the folded state or unfolded state of the display screen 1994.
[0331] The acceleration sensor 1980B can detect the magnitude of the acceleration of the mobile phone 1900 in various directions (generally three axes). That is, the gyroscope sensor 1980A can be used to detect the current motion state of the mobile phone 1900, such as shaking or stillness. When the display screen in the embodiment of the present application is a foldable screen, the acceleration sensor 1980B can be used to detect the folding or unfolding operation acting on the display screen 1994. The acceleration sensor 1980B can report the detected folding operation or unfolding operation as an event to the processor 1910 to determine the folding state or unfolding state of the display screen 1994.
[0332] The proximity light sensor 1980G may include, for example, a light emitting diode (LED) and a light detector, such as a photodiode. The light emitting diode may be an infrared light emitting diode. The mobile phone emits infrared light outward through the light emitting diode. The mobile phone uses a photodiode to detect infrared reflected light from nearby objects. When sufficient reflected light is detected, it can be determined that there is an object near the mobile phone. When insufficient reflected light is detected, the mobile phone can determine that there is no object near the mobile phone. When the display screen in the embodiment of the present application is a foldable screen, the proximity light sensor 1980G can be set on the first screen of the foldable display screen 1994, and the proximity light sensor 1980G can detect the size of the folding angle or unfolding angle between the first screen and the second screen based on the optical path difference of the infrared signal.
[0333] The gyroscope sensor 1980A (or the acceleration sensor 1980B) can send the detected motion state information (such as angular velocity) to the processor 1910. The processor 1910 determines whether the current state is handheld or tripod based on the motion state information (for example, when the angular velocity is not 0, it means that the mobile phone 1900 is in the handheld state).
[0334] The fingerprint sensor 1980H is used to collect fingerprints. The mobile phone 1900 can use the collected fingerprint characteristics to achieve fingerprint unlocking, access application locks, fingerprint photography, fingerprint call answering, etc.
[0335] The touch sensor 1980K is also called a "touch panel". The touch sensor 1980K can be set on the display screen 1994, and the touch sensor 1980K and the display screen 1994 form a touch screen, also called a "touch screen". The touch sensor 1980K is used to detect touch operations acting on or near it. The touch sensor can pass the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through the display screen 1994. In other embodiments, the touch sensor 1980K can also be set on the surface of the mobile phone 1900, which is different from the position of the display screen 1994.
[0336] Exemplarily, the display screen 1994 of the mobile phone 1900 displays a main interface, which includes icons of multiple applications (such as a camera application, a WeChat application, etc.). The user clicks the icon of the camera application in the main interface through the touch sensor 1980K, triggering the processor 1910 to start the camera application and open the camera 1993. The display screen 1994 displays the interface of the camera application, such as a viewfinder interface.
[0337] The wireless communication function of the mobile phone 1900 can be realized through antenna 1, antenna 2, mobile communication module 1951, wireless communication module 1952, modem processor and baseband processor.
[0338] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in mobile phone 1900 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization rate of the 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.
[0339] The mobile communication module 1951 can provide a solution for wireless communication including 2G / 3G / 4G / 5G applied to the mobile phone 1900. The mobile communication module 1951 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 1951 can receive electromagnetic waves from the antenna 1, filter, amplify and process the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 1951 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 1951 can be set in the processor 1910. In some embodiments, at least some of the functional modules of the mobile communication module 1951 can be set in the same device as at least some of the modules of the processor 1910. In an embodiment of the present application, the mobile communication module 1951 can also be used to interact with other terminal devices, that is, to send an audio output request to other terminal devices, or the mobile communication module 1951 can be used to receive an audio output request and encapsulate the received audio output request into a message of a specified format.
[0340] 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 1970A, a receiver 1970B, etc.), or displays an image or video through a display screen 1994. In some embodiments, the modem processor may be an independent device. In other embodiments, the modem processor may be independent of the processor 1910 and be set in the same device as the mobile communication module 1951 or other functional modules.
[0341] The wireless communication module 1952 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 mobile phone 1900. The wireless communication module 1952 can be one or more devices integrating at least one communication processing module. The wireless communication module 1952 receives electromagnetic waves via antenna 2, modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 1910. The wireless communication module 1952 can also receive the signal to be sent from the processor 1910, modulate the frequency, 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 1952 is used to establish a connection with an audio output device and output a voice signal through the audio output device. Or the wireless communication module 1952 can be used to access the access point device, send a message corresponding to the audio output request to other terminal devices, or receive a message corresponding to the audio output request sent from other terminal devices. Optionally, the wireless communication module 1952 can also be used to receive voice data from other terminal devices.
[0342] In addition, the mobile phone 1900 can implement audio functions through the audio module 1970, the speaker 1970A, the receiver 1970B, the microphone 1970C, the headphone interface 1970D, and the application processor. For example, music playback, recording, etc. The mobile phone 1900 can receive input from the key 1990 and generate key signal input related to the user settings and function control of the mobile phone 1900. The mobile phone 1900 can use the motor 1991 to generate a vibration prompt (such as a vibration prompt for an incoming call). The indicator 1992 in the mobile phone 1900 can be an indicator light, which can be used to indicate the charging status, power changes, and can also be used to indicate messages, missed calls, notifications, etc. The SIM card interface 1995 in the mobile phone 1900 is used to connect the SIM card. The SIM card can be inserted into the SIM card interface 1995, or pulled out from the SIM card interface 1995, to achieve contact and separation with the mobile phone 1900.
[0343] It should be understood that in actual applications, the mobile phone 1900 may include Fig.19The embodiments of the present application are not limited to the more or fewer components shown. The illustrated mobile phone 1900 is only an example, and the mobile phone 1900 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.
[0344] refer to Fig. 20 , is a schematic diagram of a communication device provided in an embodiment of the present application. The communication device is used to implement each step corresponding to the coprocessor, or the application processor, or the first device in the above embodiments, and the communication device 2000 includes a transceiver unit 2010 and a processing unit 2020.
[0345] In the first embodiment, the communication device is used to implement the steps corresponding to the coprocessor in the above embodiments:
[0346] The transceiver unit 2010 is used to receive a first request, the first request carries an identifier of a first service and an identifier of a first TCP connection, the first request is used to request to keep the first TCP connection of the first service alive, the first TCP connection is a connection between a first device and a second device; and broadcast the first TCP connection keep-alive message via Bluetooth. The processing unit 2020 is used to obtain the first TCP connection keep-alive message according to the identifier of the first service and the identifier of the first TCP connection.
[0347] As a possible implementation method, the transceiver unit 2010 is also used to receive a broadcast message via Bluetooth, which broadcast message carries a second TCP connection keep-alive message; the processing unit 2020 is also used to determine that the service identifier carried by the second TCP connection keep-alive message is the identifier of the first service and the identifier of the TCP connection carried is the identifier of the first TCP connection, then save the mapping relationship between the identifier of the first service and the identifier of the first TCP connection, and set a timeout period.
[0348] As a possible implementation method, the processing unit 2020 is also used to determine that if the second TCP connection keep-alive message is not received again within the timeout period, then delete the mapping relationship; or, if it is determined that the second TCP connection keep-alive message is received again within the timeout period, then do not delete the mapping relationship.
[0349] As a possible implementation method, the processing unit 2020 is also used to determine that the application processor of the first device is in a sleep state and has not received the second TCP connection keep-alive message within the timeout period, and then wake up the application processor; the transceiver unit 2010 is also used to send indication information to the application processor, and the indication information is used to notify the first device that the physical layer link between the second device is disconnected.
[0350] As a possible implementation method, the transceiver unit 2010 is also used to receive a broadcast message via Bluetooth, the broadcast message carrying a third TCP connection keep-alive message, the third TCP connection keep-alive message carrying an identifier of the second service and an identifier of the second TCP connection; the processing unit 2020 is also used to determine that the second service is not a whitelist service, and then discard the third TCP connection keep-alive message.
[0351] As a possible implementation method, the processing unit 2020 is also used to determine that if a response message is received for the first TCP connection keep-alive message, the application processor is not notified to release the first TCP connection; or, if it is determined that no corresponding response messages are received for N consecutively sent first TCP connection keep-alive messages, the application processor is notified to release the first TCP connection.
[0352] In a second embodiment, the communication device is used to implement the steps corresponding to the application processor in the above embodiments:
[0353] The transceiver unit 2010 is used to obtain the identifier of the first TCP connection and the identifier of the first service, where the first TCP connection is a connection between the first device and the second device corresponding to the first service; when the processing unit 2020 determines that the first service corresponding to the first TCP connection is a whitelist service, a first request is sent to the coprocessor of the first device, where the first request carries the identifier of the first service and the identifier of the first TCP connection, and the first request is used to request that the first TCP connection of the first service be kept alive. The processing unit 2020 is used to determine that the first service corresponding to the first TCP connection is a whitelist service.
[0354] As a possible implementation method, the processing unit 2020 is configured to save the mapping relationship between the identifier of the first TCP connection and the file description information; and save the mapping relationship between the identifier of the first service and the file description information.
[0355] As a possible implementation method, the processing unit 2020 is used to determine that the WLAN physical layer link between the first device and the second device is disconnected. The transceiver unit 2010 is used to send a second request to the coprocessor when the processing unit 2020 determines that the WLAN physical layer link between the first device and the second device is disconnected, the second request carries the identifier of the first service, and the second request is used to request to obtain the identifier of the first TCP connection corresponding to the identifier of the first service; receive notification information from the coprocessor, and the notification information is used to notify that the identifier of the first TCP connection corresponding to the identifier of the first service is not found; and release the first TCP connection.
[0356] As a possible implementation method, the processing unit 2020 is used to determine that the WLAN physical layer link between the first device and the second device is disconnected, and the transceiver unit 2010 is used to send a second request to the coprocessor when the processing unit 2020 determines that the WLAN physical layer link between the first device and the second device is disconnected. The second request carries an identifier of the first service, and the second request is used to request to obtain an identifier of the first TCP connection corresponding to the identifier of the first service; receive an identifier of the first TCP connection corresponding to the identifier of the first service from the coprocessor; and determine not to release the first TCP connection.
[0357] As a possible implementation method, the transceiver unit 2010 is used to receive indication information from the coprocessor, where the indication information is used to notify the first device and the second device that the physical layer link is disconnected, and the indication information carries the identifier of the first TCP connection; the processing unit 2020 is used to release the first TCP connection.
[0358] In a third embodiment, the communication device is used to implement the steps corresponding to the first device in the above embodiments:
[0359] The transceiver unit 2010 is used to obtain the identifier of the first TCP connection and the identifier of the first service, where the first TCP connection is a connection between the first device and the second device corresponding to the first service; and broadcast the keep-alive message of the first TCP connection via Bluetooth. The processing unit 2020 is used to determine that the first service corresponding to the first TCP connection is a whitelist service, and then obtain the keep-alive message of the first TCP connection according to the identifier of the first service and the identifier of the first TCP connection.
[0360] As a possible implementation method, the processing unit 2020 is used to save the mapping relationship between the identifier of the first TCP connection and the file description information corresponding to the first service; and save the mapping relationship between the identifier of the first service and the file description information.
[0361] As a possible implementation method, the processing unit 2020 is used to determine that the WLAN physical layer link between the first device and the second device is disconnected, and determines that the second TCP connection keep-alive message is not received from the second device within the timeout period, and then releases the TCP connection of the first service, and the second TCP connection keep-alive message carries the identifier of the first service and the identifier of the first TCP connection.
[0362] As a possible implementation method, the processing unit 2020 is used to determine that the WLAN physical layer link between the first device and the second device is disconnected, and determines that a second TCP connection keep-alive message is received from the second device within a timeout period, and then determines not to release the first TCP connection, and the second TCP connection keep-alive message carries an identifier of the first service and an identifier of the first TCP connection.
[0363] As a possible implementation method, the transceiver unit 2010 is used to receive a broadcast message via Bluetooth, where the broadcast message carries a second TCP connection keep-alive message; the processing unit 2020 is used to determine that the service identifier carried by the second TCP connection keep-alive message is the identifier of the first service and the identifier of the TCP connection carried is the identifier of the first TCP connection, then save the mapping relationship between the identifier of the first service and the identifier of the first TCP connection, and set a timeout period.
[0364] As a possible implementation method, the processing unit 2020 is used to determine that if the second TCP connection keep-alive message is not received again within the timeout period, then delete the mapping relationship; or, if it is determined that the second TCP connection keep-alive message is received again within the timeout period, then do not delete the mapping relationship.
[0365] As a possible implementation method, the transceiver unit 2010 is used to receive a broadcast message via Bluetooth, where the broadcast message carries a third TCP connection keep-alive message, where the third TCP connection keep-alive message carries an identifier of the second service and an identifier of the second TCP connection; the processing unit 2020 is used to determine that the second service is not a whitelist service, and then discard the third TCP connection keep-alive message.
[0366] As a possible implementation method, the processing unit 2020 is used to determine that if a response message is received for the first TCP connection keep-alive message, the application processor is not notified to release the first TCP connection, that is, it is determined that the first TCP connection is kept alive successfully; or, if it is determined that N first TCP connection keep-alive messages sent continuously have not received corresponding response messages, the application processor is notified to release the first TCP connection, that is, it is determined that the first TCP connection fails to be kept alive, where N is a positive integer.
[0367] Optionally, the communication device may further include a storage unit for storing data or instructions (also referred to as code or program), and each of the above units may interact or couple with the storage unit to implement the corresponding method or function. For example, the processing unit 2020 may read the data or instructions in the storage unit so that the communication device implements the method in the above embodiment.
[0368] It should be understood that the division of the units in the above communication device is only a division of logical functions. In actual implementation, they can be fully or partially integrated into one physical entity, or they can be physically separated. And the units in the communication device can all be implemented in the form of software calling through processing elements; they can also be all implemented in the form of hardware; some units can also be implemented in the form of software calling through processing elements, and some units can be implemented in the form of hardware. For example, each unit can be a separately established processing element, or it can be integrated in a chip of the communication device. In addition, it can also be stored in a memory in the form of a program, and called and executed by a processing element of the communication device. The function of the unit. In addition, all or part of these units can be integrated together, or they can be implemented independently. The processing element described here can also be a processor, which can be an integrated circuit with signal processing capabilities. In the implementation process, each step of the above method or each unit above can be implemented by an integrated logic circuit of hardware in the processor element or in the form of software calling through a processing element.
[0369] In one example, the unit in any of the above communication devices may be one or more integrated circuits configured to implement the above method, such as: one or more application specific integrated circuits (ASIC), or one or more microprocessors (digital singnal processors, DSP), or one or more field programmable gate arrays (FPGA), or a combination of at least two of these integrated circuit forms. For another example, when the unit in the communication device can be implemented in the form of a processing element scheduler, the processing element can be a general-purpose processor, such as a central processing unit (CPU) or other processor that can call a program. For another example, these units can be integrated together and implemented in the form of a system-on-a-chip (SOC).
[0370] Fig.21 A schematic diagram of the structure of a terminal device is provided. For ease of explanation, Fig.21 Only the main components of the terminal device are shown. Fig.21As shown, the terminal device 2100 includes a processor, a memory, a control circuit, an antenna, and an input-output device. The processor is mainly used to process the communication protocol and communication data, and to control the entire terminal, execute the software program, and process the data of the software program. The memory is mainly used to store the software program and data. The control circuit is mainly used for converting the baseband signal and the radio frequency signal and processing the radio frequency signal. The antenna is mainly used to send and receive radio frequency signals in the form of electromagnetic waves. The input-output device, such as a touch screen, a display screen, a keyboard, etc., is mainly used to receive data input by the user and output data to the user.
[0371] When the terminal device is turned on, the processor can read the software program in the storage unit, parse and execute the instructions of the software program, and process the data of the software program. When data needs to be sent wirelessly, the processor performs baseband processing on the data to be sent, and outputs the baseband signal to the control circuit. The control circuit processes the baseband signal to obtain a radio frequency signal and sends the radio frequency signal outward through the antenna in the form of electromagnetic waves. When data is sent to the terminal device, the control circuit receives the radio frequency signal through the antenna, and the radio frequency signal is further converted into a baseband signal, and the baseband signal is output to the processor, and the processor converts the baseband signal into data and processes the data.
[0372] For ease of explanation, Fig.21 Only one memory and processor are shown. In an actual terminal device, there may be multiple processors and memories. The memory may also be referred to as a storage medium or a storage device, etc., which is not limited in the embodiment of the present invention.
[0373] As an optional implementation, the processor may include a baseband processor and a central processing unit. The baseband processor is mainly used to process the communication protocol and communication data, and the central processing unit is mainly used to control the entire terminal device, execute software programs, and process software program data. Fig.21 The processor in integrates the functions of the baseband processor and the central processing unit. Those skilled in the art will understand that the baseband processor and the central processing unit may also be independent processors, which are interconnected through technologies such as buses. Those skilled in the art will understand that the terminal device may include multiple baseband processors to adapt to different network standards, and the terminal device may include multiple central processing units to enhance its processing capabilities. The various components of the terminal device may be connected through various buses. The baseband processor may also be described as a baseband processing circuit or a baseband processing chip. The central processing unit may also be described as a central processing circuit or a central processing chip. The function of processing the communication protocol and communication data may be built into the processor, or may be stored in the storage unit in the form of a software program, and the processor executes the software program to implement the baseband processing function.
[0374] In one example, the antenna and control circuit having transceiver functions may be regarded as the transceiver unit 2111 of the terminal device 2100, and the processor having a processing function may be regarded as the processing unit 2112 of the terminal device 2100. Fig.21 As shown, the terminal device 2100 includes a transceiver unit 2111 and a processing unit 2112. The transceiver unit may also be referred to as a transceiver, a transceiver, a transceiver device, etc. Optionally, the device used to implement the receiving function in the transceiver unit 2111 may be regarded as a receiving unit, and the device used to implement the sending function in the transceiver unit 2111 may be regarded as a sending unit, that is, the transceiver unit 2111 includes a receiving unit and a sending unit. Exemplarily, the receiving unit may also be referred to as a receiver, a receiver, a receiving circuit, etc., and the sending unit may be referred to as a transmitter, a transmitter, or a transmitting circuit, etc. Optionally, the above-mentioned receiving unit and the sending unit may be one integrated unit, or may be multiple independent units. The above-mentioned receiving unit and the sending unit may be located in one geographical location, or may be dispersed in multiple geographical locations.
[0375] Those of ordinary skill in the art will appreciate that the various digital numbers such as the first and second involved in this application are only for the convenience of description, and are not used to limit the scope of the embodiments of this application, and also represent the order of precedence. "And / or" describes the association relationship of the associated objects, indicating that there may be three relationships, for example, A and / or B, which can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects before and after are in an "or" relationship. "At least one" refers to one or more. At least two refers to two or more. "At least one", "any one" or similar expressions refer to any combination of these items, including any combination of single items (individuals) or plural items (individuals). For example, at least one item (individuals, kinds) of a, b, or c can represent: a, b, c, ab, ac, bc, or abc, where a, b, c can be single or multiple. "Multiple" refers to two or more, and other quantifiers are similar.
[0376] It should be understood that in various embodiments of the present application, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0377] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0378] In the above embodiments, it 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 described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid state disk (SSD)), etc.
[0379] The various illustrative logic units and circuits described in the embodiments of the present application can be implemented or operated by a general-purpose processor, a digital signal processor, an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic device, a discrete gate or transistor logic, a discrete hardware component, or the design of any combination of the above functions. The general-purpose processor can be a microprocessor, and optionally, the general-purpose processor can also be any traditional processor, controller, microcontroller or state machine. The processor can also be implemented by a combination of computing devices, such as a digital signal processor and a microprocessor, a plurality of microprocessors, one or more microprocessors in conjunction with a digital signal processor core, or any other similar configuration to implement.
[0380] The steps of the method or algorithm described in the embodiments of the present application can be directly embedded in the software unit executed by the hardware, processor, or a combination of the two. The software unit can be stored in a random access memory (Random Access Memory, RAM), flash memory, read-only memory (Read-Only Memory, ROM), EPROM memory, EEPROM memory, register, hard disk, removable disk, CD-ROM or other storage media of any form in the art. Exemplarily, the storage medium can be connected to the processor so that the processor can read information from the storage medium and can write information to the storage medium. Optionally, the storage medium can also be integrated into the processor. The processor and the storage medium can be arranged in an ASIC.
[0381] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0382] In one or more exemplary designs, the above functions described in this application can be implemented in hardware, software, firmware, or any combination of the three. If implemented in software, these functions can be stored on a computer-readable medium, or transmitted in the form of one or more instructions or codes on a computer-readable medium. Computer-readable media include computer storage media and communication media that facilitate the transfer of computer programs from one place to another. The storage medium can be any available medium that can be accessed by any general or special computer. For example, such computer-readable media can include but are not limited to RAM, ROM, EEPROM, CD-ROM or other optical disk storage, disk storage or other magnetic storage devices, or any other medium that can be used to carry or store program codes in the form of instructions or data structures and other forms that can be read by general or special computers, or general or special processors. In addition, any connection can be appropriately defined as a computer-readable medium, for example, if the software is transmitted from a website site, server or other remote resource through a coaxial cable, fiber optic computer, twisted pair, digital subscriber line (DSL) or wirelessly, such as infrared, wireless and microwave, it is also included in the defined computer-readable medium. The disk and disc include compact disk, laser disk, optical disk, digital versatile disc (DVD), floppy disk and blue-ray disc. Disks usually copy data magnetically, while discs usually copy data optically with lasers. The above combinations can also be included in computer readable media.
[0383] Those skilled in the art should be aware that in one or more of the above examples, the functions described in this application can be implemented using hardware, software, firmware, or any combination thereof. When implemented using software, these functions can be stored in a computer-readable medium or transmitted as one or more instructions or codes on a computer-readable medium. Computer-readable media include computer storage media and communication media, wherein communication media include any media that facilitates the transmission of a computer program from one place to another. The storage medium can be any available medium that a general or special-purpose computer can access.
[0384] The specific implementation methods described above further describe the purpose, technical solutions and beneficial effects of the present application in detail. It should be understood that the above description is only the specific implementation methods of the present application and is not intended to limit the protection scope of the present application. Any modifications, equivalent substitutions, improvements, etc. made on the basis of the technical solutions of the present application should be included in the protection scope of the present application. The above description of the specification of the present application can make any technical field in the art use or implement the content of the present application. Any modification based on the disclosed content should be considered obvious in the art. The basic principles described in the present application can be applied to other variations without departing from the inventive essence and scope of the present application. Therefore, the content disclosed in the present application is not limited to the described embodiments and designs, but can also be extended to the maximum scope consistent with the principles of the present application and the disclosed new features.
[0385] Although the present application has been described in conjunction with specific features and embodiments thereof, it is obvious that various modifications and combinations may be made thereto without departing from the spirit and scope of the present application. Accordingly, this specification and the drawings are merely exemplary illustrations of the present application as defined by the appended claims, and are deemed to have covered any and all modifications, variations, combinations or equivalents within the scope of the present application. Obviously, a person skilled in the art may make various modifications and variations to the present application without departing from the scope of the present application. Thus, if these modifications and variations of the present application 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 transmission control protocol TCP keep-alive method, applied to a first device, wherein the first device includes a coprocessor and an application processor, characterized in that: include: When the WLAN physical layer link between the first device and the second device is disconnected or the first device is in sleep mode with the screen turned off, the application processor determines that the first service is a whitelist service, and sends a first request to the coprocessor, where the first request carries an identifier of the first service and an identifier of a first TCP connection, and the first request is used to request that the first TCP connection corresponding to the first service be kept alive, where the first TCP connection is a connection between the first device and the second device corresponding to the first service; The coprocessor receives the first request from the application processor, and obtains a first TCP connection keep-alive message according to the identifier of the first service and the identifier of the first TCP connection; The coprocessor broadcasts the first TCP connection keep-alive message via Bluetooth.
2. The method according to claim 1, characterized in that The first request also carries file description information of the first service; and the method further includes: The application processor stores a mapping relationship between the identifier of the first TCP connection and the file description information corresponding to the first TCP connection; and The application processor stores a mapping relationship between the identifier of the first service and the file description information corresponding to the first TCP connection.
3. The method according to claim 1 or 2, characterized in that Also includes: When the application processor determines that the WLAN physical layer link between the first device and the second device is disconnected, the application processor sends a second request to the coprocessor, where the second request carries an identifier of the first service, and the second request is used to request to obtain an identifier of the first TCP connection corresponding to the identifier of the first service; The coprocessor sends notification information to the application processor, where the notification information is used to notify that the identifier of the first TCP connection corresponding to the identifier of the first service is not found; The application processor releases the first TCP connection.
4. The method according to claim 3, characterized in that Also includes: The coprocessor receives a broadcast message via Bluetooth, where the broadcast message carries a second TCP connection keep-alive message; The coprocessor determines that the service identifier carried by the second TCP connection keep-alive message is the identifier of the first service and the identifier of the carried TCP connection is the identifier of the first TCP connection, then saves the mapping relationship between the identifier of the first service and the identifier of the first TCP connection, and sets a timeout period.
5. The method according to claim 4, characterized in that Also includes: The coprocessor determines that the second TCP connection keep-alive message is not received again within the timeout period, and deletes the mapping relationship; or, If it is determined that the second TCP connection keep-alive message is received again within the timeout period, the mapping relationship is not deleted.
6. The method according to claim 4 or 5, characterized in that Also includes: When the coprocessor determines that the application processor is in a dormant state and does not receive the second TCP connection keep-alive message within the timeout period, the coprocessor wakes up the application processor; The coprocessor sends indication information to the application processor, where the indication information is used to notify that a physical layer link between the first device and the second device is disconnected; The coprocessor releases the first TCP connection.
7. The method according to claim 1 or 2, characterized in that: Also includes: When the application processor determines that the WLAN physical layer link between the first device and the second device is disconnected, the application processor sends a second request to the coprocessor, where the second request carries an identifier of the first service, and the second request is used to request to obtain an identifier of the first TCP connection corresponding to the identifier of the first service; The coprocessor sends, to the application processor, an identifier of the first TCP connection corresponding to the identifier of the first service; The application processor determines that the identifier of the first TCP connection is received and determines not to release the first TCP connection.
8. The method according to claim 1 or 2, characterized in that: Also includes: The coprocessor receives a broadcast message via Bluetooth, where the broadcast message carries a third TCP connection keep-alive message, and the third TCP connection keep-alive message carries an identifier of the second service and an identifier of the second TCP connection; The coprocessor determines that the second service is not a whitelist service and discards the third TCP connection keep-alive message.
9. The method according to any one of claims 1-2, 4-5, characterized in that: Also includes: The coprocessor determines that a response message to the first TCP connection keep-alive message is received, and then does not notify the application processor to release the first TCP connection; or, The coprocessor determines that no corresponding response message has been received for N consecutively sent keep-alive messages of the first TCP connection, and then notifies the application processor to release the first TCP connection, where N is a positive integer.
10. The method according to any one of claims 1-2, 4-5, characterized in that: After the application processor sends the first request to the coprocessor, the method further includes: The application processor enters a sleep state.
11. A transmission control protocol TCP keep-alive method, applied to a coprocessor of a first device, the coprocessor being connected to an application processor of the first device, characterized in that: include: In a case where the WLAN physical layer link between the first device and the second device is disconnected or the first device is in screen-off sleep mode, receiving a first request from the application processor, where the first request carries an identifier of a first service and an identifier of a first TCP connection, and the first request is used to request that the first TCP connection of the first service be kept alive, where the first TCP connection is a connection between the first device and the second device; Obtaining a first TCP connection keep-alive message according to the identifier of the first service and the identifier of the first TCP connection; The first TCP connection keep-alive message is broadcasted via Bluetooth.
12. The method according to claim 11, characterized in that Also includes: Receiving a broadcast message via Bluetooth, wherein the broadcast message carries a second TCP connection keep-alive message; Determine that the service identifier carried by the second TCP connection keep-alive message is the identifier of the first service and the identifier of the carried TCP connection is the identifier of the first TCP connection, then save the mapping relationship between the identifier of the first service and the identifier of the first TCP connection, and set a timeout period.
13. The method according to claim 12, characterized in that Also includes: Determining that the second TCP connection keep-alive message is not received again within the timeout period, deleting the mapping relationship; or, If it is determined that the second TCP connection keep-alive message is received again within the timeout period, the mapping relationship is not deleted.
14. The method according to claim 12 or 13, characterized in that Also includes: Determining that the application processor is in a dormant state and has not received the second TCP connection keep-alive message within a timeout period, waking up the application processor; Send indication information to the application processor, where the indication information is used to notify that a physical layer link between the first device and the second device is disconnected.
15. The method according to claim 11, characterized in that Also includes: receiving a broadcast message via Bluetooth, where the broadcast message carries a third TCP connection keep-alive message, where the third TCP connection keep-alive message carries an identifier of the second service and an identifier of the second TCP connection; If it is determined that the second service is not a whitelist service, the third TCP connection keep-alive message is discarded.
16. The method according to claim 11, characterized in that Also includes: determining that a response message to the first TCP connection keep-alive message is received, then not notifying the application processor to release the first TCP connection; or, If it is determined that no corresponding response message is received for N consecutively sent keep-alive messages of the first TCP connection, the application processor is notified to release the first TCP connection, where N is a positive integer.
17. A transmission control protocol TCP keep-alive method, applied to an application processor of a first device, the application processor being connected to a coprocessor of the first device, characterized in that: include: When the WLAN physical layer link between the first device and the second device is disconnected or the first device is in sleep mode with the screen turned off, an identifier of a first TCP connection and an identifier of a first service are obtained, where the first TCP connection is a connection between the first device and the second device corresponding to the first service; If it is determined that the first service is a whitelist service, a first request is sent to the coprocessor, where the first request carries an identifier of the first service and an identifier of the first TCP connection, and the first request is used to request to keep the first TCP connection of the first service alive.
18. The method according to claim 17, characterized in that The first request also carries file description information of the first service; and the method further includes: saving a mapping relationship between the identifier of the first TCP connection and the file description information; and, A mapping relationship between the identifier of the first service and the file description information is saved.
19. The method according to claim 17 or 18, characterized in that Also includes: If it is determined that the WLAN physical layer link between the first device and the second device is disconnected, a second request is sent to the coprocessor, where the second request carries an identifier of the first service, and the second request is used to request to obtain an identifier of a first TCP connection corresponding to the identifier of the first service; receiving notification information from the coprocessor, where the notification information is used to notify that an identifier of the first TCP connection corresponding to the identifier of the first service is not found; Release the first TCP connection.
20. The method according to claim 17 or 18, characterized in that Also includes: If it is determined that the WLAN physical layer link between the first device and the second device is disconnected, a second request is sent to the coprocessor, where the second request carries an identifier of the first service, and the second request is used to request to obtain an identifier of a first TCP connection corresponding to the identifier of the first service; receiving, from the coprocessor, an identifier of the first TCP connection corresponding to the identifier of the first service; Determine not to release the first TCP connection.
21. The method according to claim 17 or 18, characterized in that Also includes: receiving indication information from the coprocessor, where the indication information is used to notify that a physical layer link between the first device and the second device is disconnected, and the indication information carries an identifier of the first TCP connection; Release the first TCP connection.
22. The method according to claim 17 or 18, characterized in that After sending the first request to the coprocessor, the method further includes: Enter hibernation mode.
23. A communication device, characterized in that: The method comprises a processor, wherein the processor is used to execute the method according to any one of claims 1 to 10.
24. A coprocessor, characterized in that: Used to execute the method according to any one of claims 11 to 16.
25. An application processor, characterized in that: Used to execute the method according to any one of claims 17 to 22.
26. A communication system, characterized in that: It comprises a coprocessor for executing the method according to any one of claims 11 to 16, and an application processor for executing the method according to any one of claims 17 to 22.
27. A computer program product comprising instructions, characterized in that When the method is run on a computer, the method according to any one of claims 1 to 22 is executed.
28. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, and when the instructions are executed on a computer, the method according to any one of claims 1 to 22 is executed.
Citation Information
Patent Citations
Terminal device broadcast processing method and device, terminal device and memory medium
CN107968881A
application program keep-alive method and device, computer equipment and storage medium
CN109992310A
