Heartbeat packet sending method and device, medium and chip
By monitoring TCP long connection data packet information during the pre-configured heartbeat cycle and sending heartbeat packets when conditions are met by the target hardware, the high power consumption problem caused by AP wake-up when the terminal device is in standby mode is solved, and the stability and battery life of TCP connections are optimized.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-27
- Publication Date
- 2026-03-27
AI Technical Summary
In existing technologies, when terminal devices are in standby or hibernation at night, they send heartbeat packets through the kernel TCP/IP protocol stack or application layer to maintain TCP long connections, which causes the application processor to wake up, increases standby current, and reduces battery life.
By monitoring the data packet information of TCP long connections in the pre-configured managed heartbeat cycle of the target hardware, and sending heartbeat data packets when preset conditions are met, the heartbeat data packets are sent in place of the kernel TCP/IP protocol stack or application layer, thereby realizing hardware management of heartbeat data packets and avoiding AP wake-up.
By keeping TCP connections alive without waking up the application processor, power consumption is reduced, the battery life problem caused by AP wake-up is solved, and the stability and battery life of TCP long connections are improved.
Smart Images

Figure CN121750708A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the technical field of communication, and particularly relates to a heartbeat packet sending method and device, medium and chip. BACKGROUND
[0002] In order to realize normal communication between a client (such as a terminal device) and a server, the client and the server need to maintain a Transmission Control Protocol (TCP) long connection to realize communication between the two ends. In order to maintain and verify whether the TCP long connection is valid, a heartbeat packet is usually sent to refresh the TCP connection state to avoid the connection being closed by an intermediate device or the server due to idling.
[0003] At present, the TCP long connection is generally implemented by a kernel TCP / IP protocol stack KeepAlive mechanism on the client side or is implemented by an application layer on the client side. However, both of the two ways are accompanied by kernel activities, which will cause an Application Processor (AP) to wake up. In the night standby, sleep and other scenarios of a terminal such as a mobile phone or an electric vehicle, the AP wake-up will cause the standby current to increase, and the wake-up of the AP of the vehicle machine will further pull up the power-on of related peripherals, thereby reducing the endurance time of the terminal device side. SUMMARY
[0004] To overcome the problems in the related art, the present disclosure provides a heartbeat packet sending method, device, medium and chip to solve the technical problems of waking up the AP and reducing the endurance time in the related art.
[0005] According to a first aspect of an embodiment of the present disclosure, a heartbeat packet sending method is provided, applied to a target hardware, and the method comprises: monitoring TCP data packet information transmitted on a TCP long connection in a provisioned managed heartbeat period, the TCP long connection being a long connection established between a terminal device and a server; when the TCP data packet information meets a preset condition, sending a heartbeat data packet to the server, the preset condition being associated with the TCP data packet information.
[0006] In some embodiments, when the TCP data packet information includes a TCP data packet sending density, the preset condition includes that the TCP data packet sending density is less than a preset density threshold; and / or, when the TCP data packet information includes a TCP data packet quantity, the preset condition includes that the TCP data packet quantity is less than a preset quantity threshold.
[0007] In some embodiments, the method further comprises: when the TCP packet information does not satisfy the preset condition, skipping the hosting heartbeat period, updating a corresponding skip number, and waiting for a next hosting heartbeat period to repeat the monitoring of the TCP packet information transmitted on the TCP long connection in the preset hosting heartbeat period.
[0008] In some embodiments, the method further comprises: when the skip number is greater than or equal to a preset number threshold, forcibly sending a heartbeat packet to the server, and clearing the skip number.
[0009] In some embodiments, the method further comprises: calling a preset interrupt processing function to obtain latest packet information, the latest packet information including a latest sequence number of the heartbeat packet and / or a latest acknowledgement sequence number of an acknowledgement packet returned by the server based on the heartbeat packet; calling a preset TCP updating function to transmit the latest packet information to a kernel TCP / IP protocol stack of the terminal device to synchronously update the latest packet information.
[0010] In some embodiments, the calling of the preset interrupt processing function to obtain the latest packet information comprises: after the heartbeat packet is sent to the server, and / or after the acknowledgement packet returned by the server based on the heartbeat packet is received, calling the preset interrupt processing function to obtain the latest packet information.
[0011] In some embodiments, the method further comprises: receiving updating acknowledgement information of the kernel TCP / IP protocol stack, the updating acknowledgement information being used to indicate that the kernel TCP / IP protocol stack completes updating of the latest packet information; synchronizing the latest packet information between a target hardware of the terminal device and the kernel TCP / IP protocol stack.
[0012] In some embodiments, the synchronizing of the latest packet information between the target hardware of the terminal device and the kernel TCP / IP protocol stack comprises: the kernel TCP / IP protocol stack receiving the latest packet information; the kernel TCP / IP protocol stack performing information synchronization based on the latest sequence number of the heartbeat packet and / or the latest acknowledgement sequence number of the acknowledgement packet in the latest packet information.
[0013] In some embodiments, the latest data packet information further comprises a socket descriptor, and the information synchronization based on the latest sequence number of the heartbeat data packet and / or the latest acknowledgement sequence number of the acknowledgement data packet in the latest data packet information comprises: determining, based on the socket descriptor, a TCP socket corresponding to the socket descriptor; updating, based on the latest sequence number of the heartbeat data packet and / or the latest acknowledgement sequence number of the acknowledgement data packet in the latest data packet information, a sequence number of a heartbeat data packet and / or an acknowledgement sequence number of an acknowledgement data packet in the TCP socket.
[0014] In some embodiments, the method further comprises: updating parameter information related to the latest data packet information, the parameter information at least comprising a flow control parameter determined based on the latest sequence number of the heartbeat data packet and / or the latest acknowledgement sequence number of the acknowledgement data packet in the latest data packet information.
[0015] In some embodiments, the TCP data packet information is obtained by monitoring through an observation window after the observation window is opened, wherein a length of the observation window is determined according to the hosting heartbeat period.
[0016] According to a second aspect of the embodiments of the present disclosure, a heartbeat packet sending device is provided, the device comprising: a processing module configured to monitor TCP data packet information transmitted on a TCP long connection in a pre-configured hosting heartbeat period, the TCP long connection being a long connection established between a terminal device and a server; a transceiving module configured to send a heartbeat data packet to the server when the TCP data packet information satisfies a preset condition, the preset condition being associated with the TCP data packet information.
[0017] As to the contents not introduced or described in the embodiments of the present disclosure, reference can be made to the related introduction in the foregoing method embodiments, and the embodiments of the present disclosure are not limited.
[0018] According to a third aspect of the embodiments of the present disclosure, a communication device is provided, comprising a processor, a memory for storing processor executable instructions, wherein the processor is configured to execute the executable instructions to implement the steps of the heartbeat packet sending method described above.
[0019] According to a fourth aspect of the embodiments of the present disclosure, a computer readable storage medium is provided, which stores computer program instructions, the program instructions being executed by a processor to implement the steps of the heartbeat packet sending method provided in the first aspect of the present disclosure.
[0020] According to a fifth aspect of the embodiments of the present disclosure, a chip is provided, comprising a processor and an interface; the processor is configured to read instructions to perform the steps of the heartbeat packet sending method described above.
[0021] The technical solutions provided by the embodiments of the present disclosure can have the following beneficial effects: the target hardware monitors TCP packet information transmitted on a TCP long connection in a provisioning managed heartbeat period, the TCP long connection being a long connection established between a terminal device and a server; when the TCP packet information meets a preset condition, a heartbeat packet is sent to the server, the preset condition being associated with the TCP packet information. In this way, by optimizing the target hardware to send heartbeat packets of the TCP long connection, the present disclosure can replace the kernel TCP / IP protocol stack or the application layer to send heartbeat packets without waking up the application processor (AP), which is conducive to reducing power consumption; both TCP keep-alive and power consumption caused by AP wake-up are avoided, and the technical problems of waking up the AP and reducing the endurance time in the related art are also solved.
[0022] It should be understood that the foregoing general description and the following detailed description are only exemplary and explanatory, and cannot limit the present disclosure. BRIEF DESCRIPTION OF DRAWINGS
[0023] The accompanying drawings, which are incorporated into and form part of the specification, illustrate embodiments consistent with the present disclosure and, together with the specification, serve to explain the principles of the present disclosure.
[0024] Figure 1 is an application scenario diagram according to an exemplary embodiment.
[0025] Figure 2 is a system structure diagram corresponding to a target hardware according to an exemplary embodiment.
[0026] Figure 3 is a flow diagram of a heartbeat packet sending method according to an exemplary embodiment.
[0027] Figure 4 is a flow diagram of an information synchronization method according to an exemplary embodiment.
[0028] Figure 5 is a flow diagram of an information synchronization method according to an exemplary embodiment.
[0029] Figure 6 is a structure diagram of a heartbeat packet sending device according to an exemplary embodiment.
[0030] Figure 7 is a structure diagram of an information synchronization device according to an exemplary embodiment.
[0031] Figure 8 is a structural schematic diagram of a communication device according to an exemplary embodiment.
[0032] Figure 9 is a structural schematic diagram of a chip according to an exemplary embodiment. DETAILED DESCRIPTION
[0033] The exemplary embodiments will be described in detail herein with reference to the attached drawings. The following description is made with reference to the accompanying drawings in which like reference numerals refer to like elements, unless the context of use indicates otherwise. The following description of exemplary embodiments is not representative of all embodiments consistent with the present disclosure. Rather, it is merely an example of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0034] It should be noted that all actions of acquiring signals, information or data in the present disclosure are performed with the authorization of the corresponding device owner.
[0035] Many scenarios that require long-term maintenance of TCP connections, such as Secure Shell (SSH) connections, remote desktop connections, Virtual Private Network (VPN) connections, mobile phone push services, Electric Vehicle (EV) whole vehicle control and status monitoring, etc., need to maintain the survival state of TCP connections as much as possible to avoid accidental disconnection due to network reasons; they also need to send heartbeat packets to refresh the TCP connection state to avoid being closed by intermediate devices or servers due to idleness. TCP long connections are generally implemented by the kernel TCP / IP protocol stack KeepAlive mechanism or by the application layer itself, and the difference between them can be seen in the following Table 1: Table 1
[0036] In practice, it is found that the above two TCP keep-alive methods are directly accompanied by kernel activity, causing the application processor AP to wake up. For example, in scenarios such as mobile phone night standby, electric vehicle parked sleep, etc., AP wake-up will cause the standby current to increase, and the AP wake-up of the vehicle machine will also pull up the power-on of related peripherals, reducing the endurance capability.
[0037] Currently, high-end mobile platform System on a Chip (SoC) supports hardware hosting TCP long connection heartbeat, but no Original Equipment Manufacturer (OEM) has commercially used this function on a large scale. In addition, high-end mobile platform SoC (such as Qualcomm Snapdragon series, MediaTek Dimensity series, etc.) target hardware modem supports hardware hosting TCP heartbeat packet function, but its processing method needs to know the Seq and Ack sequence numbers of the last interaction packet on the TCP link. In the process of high-density TCP packet transmission, frequent data packet transmission will interfere with the normal heartbeat packet sequence order, causing unexpected retransmission to lead to connection reset, affecting overall stability. And real-time monitoring of the link will cause performance loss in the high-density data packet environment. To solve the above problems, the present disclosure proposes a hardware hosting-based TCP long connection technology that can send heartbeat packets on a specific TCP connection instead of the kernel TCP / IP protocol stack or the application layer without waking up the AP, which can achieve TCP keep-alive and avoid the power consumption caused by AP wake-up.
[0038] First, some embodiments applicable to the present disclosure are introduced.
[0039] Please refer to Figure 1 is a schematic diagram of an application scenario according to an exemplary embodiment. As shown in the application scenario can include a client (such as a terminal device) 100 and a server 200. Wherein, the terminal device 100 can include an application (application, APP) layer 101, a system layer 102 and a hardware layer 103. Figure 1
[0040] The application layer 101 described above can start the heartbeat hardware hosting function, and after starting the heartbeat hardware hosting function, the corresponding hardware heartbeat (regist Hardware Heartbeat, HB HW) function can be registered in the system layer 102. After registration, the hardware layer 103 can start hardware hosting of HB HW, for example, sending ping and other heartbeat data packets to the server 200, which will be described in detail below, and will not be described here. Correspondingly, the server 200 can receive the corresponding heartbeat data packet. As shown, the hardware layer 103 can periodically send ping heartbeat data packets every 3 minutes.
[0041] Before starting the heartbeat hardware hosting function described above, the application layer 101 described above can also send a ping and other heartbeat data packets to wake up the application processor AP in the system layer 102. For example, the application layer 101 in the figure periodically sends a ping data packet to the system layer 102 every 60 minutes. After sending the ping data packet, the application layer 101 can start the heartbeat hardware hosting function. After waking up the application processor AP, the system layer 102 can send a corresponding data packet to the hardware layer 103 (specifically, to the target hardware in the hardware layer). After receiving the corresponding data, the hardware layer 103 can forward the ping data packet to the server 200. Accordingly, the server 200 can receive the ping data packet.
[0042] The hardware layer 103 described above can include the target hardware related to the present disclosure below, which can include but is not limited to, for example, a modem or other hardware with hardware hosting capabilities to implement TCP long connection monitoring, etc.
[0043] Based on Figure 1 As shown in the application scenario, when the upper system or application APP layer sets the hardware hosting TCP long connection, the subsequent sending of heartbeat data packets is hosted by the hardware layer (specifically, by the target hardware in the hardware layer), and the system can normally sleep to reduce standby functions. However, it is also found in practice that: When the hosting time of the target hardware (such as a modem) is reached, when a large number of normal message interactions (for example, a large number of uplink data packets and / or downlink data packets on the TCP long connection link) appear on the hosting link, the TCP message sequence number (Sequence, Seq) and the acknowledgment sequence number (Acknowledgment, Ack) change rapidly, causing the Seq and Ack sequence numbers of the hosted heartbeat packet to be updated not in time. Similarly, when the target hardware (such as a modem) hosts the heartbeat data packet carrying a load, the kernel TCP / IP protocol stack cannot perceive the Seq / Ack change value accumulated on the TCP long connection link during the hosting of the modem, and continues to send TCP data packets in the previous Seq / Ack order.
[0044] Both of the above situations can cause disordered message sequence numbers reported on the TCP link, leading to abnormal situations such as message retransmission and TCP connection reset (RST), and in severe cases, affecting the stability of TCP long connections. Furthermore, to achieve Seq / Ack sequence number synchronization between the target hardware and the kernel TCP / IP protocol stack, the target hardware needs to monitor changes in message sequence numbers on the TCP long connection in real time. However, in scenarios involving large data packet transmissions, such real-time monitoring can put significant pressure on the data processing performance of the target hardware. Balancing performance and synchronization is a pressing problem that needs to be solved. Therefore, the embodiments disclosed in this disclosure aim to improve the stability of hardware-managed TCP long connections and optimize system power consumption to better meet the needs of efficient, stable, and secure communication.
[0045] Please see Figure 2 This is a schematic diagram of a system architecture corresponding to a target hardware according to an exemplary embodiment. For example... Figure 2 The system shown may include: a physical layer 201 (PHY), an access layer 202 (AS), a non-access layer 203 (NAS), a protocol stack processing unit 204, and a radio interface layer 205 (RIL). Wherein: The physical layer 201 is primarily responsible for transmitting data bit streams, transferring data from the sender to the receiver, and controlling physical devices such as fiber optic cables, network cables, and radios. Its main functions include providing data channels, transmitting data, and performing physical layer management tasks.
[0046] Access layer 202 is primarily responsible for communication between user equipment and the access network. Its main functions include Medium Access Control (MAC), Radio Link Control (RLC), Packet Data Convergence Protocol (PDCP), and Radio Resource Control (RRC). Access layer 202 ensures that user equipment can communicate through the wireless access network.
[0047] The Non-Access Layer 203 exists in the wireless communication protocol stack of the Universal Mobile Telephony System (UMTS) as a functional layer between the core network and user equipment. It is primarily responsible for the transmission of signaling and user data, ensuring that user equipment can register, attach, and perform session management within the network.
[0048] The protocol stack processing unit 204 includes a heartbeat packet management unit 2041 (Heartbeat Manger, HM), a transport layer processing unit 2044 (Transport Layer Processing), and a network protocol processing unit 2045 (IP Processing). Among them, the heartbeat packet management unit 2041 can be subdivided according to functions to include, for example, an observation window sub-unit 2042 (Observation Window) and a synchronization control sub-unit 2043 (Seq / Ack Sync-Controller). The following describes each unit / sub-unit.
[0049] The heartbeat packet management unit 2041 (Heartbeat Manger, HM) is mainly responsible for the management of the hardware-hosted heartbeat data packet, such as controlling the observation window sub-unit 2042 and the synchronization control sub-unit 2043. In a specific implementation, when the target hardware registers the hosting of the TCP long connection, the heartbeat packet management unit 2041 can also obtain the information of the four-tuple of the TCP long connection, the hosting heartbeat period (which can also be referred to as the heartbeat period T), and the like. The four-tuple information can include the destination network protocol (IP) address, the destination port, the source IP address, and the source port. At the beginning of the hosting, the heartbeat packet management unit 2041 can control the observation window sub-unit 2042 to open an observation window, and the like. During the hosting process, the heartbeat packet management unit 2041 can control the synchronization control sub-unit 2043 to synchronize the corresponding information, such as the synchronization of Seq / Ack, and the like, which is described in detail below in the present disclosure, and thus is not described here.
[0050] The observation window sub-unit 2042 (Observation Window) is mainly responsible for opening an observation window to observe or monitor the TCP data packet information on the TCP long connection in real time. The TCP data packet information can include, but is not limited to, for example, the TCP data packet sending density, the TCP data packet quantity, or other custom information, and the like.
[0051] The synchronization control sub-unit 2043 (Seq / Ack Sync-Controller) is mainly responsible for managing the interrupt processing function added or provisioned in the target hardware driver to call the interrupt processing function to obtain the latest data packet information, such as the latest Seq / Ack sequence number information, and the like, so as to facilitate subsequent other operations.
[0052] The transport layer processing unit 2044 (Transport Layer Processing) is mainly responsible for providing end-to-end communication services to ensure the reliability and orderliness of data transmission. It mainly processes the transport layer protocols such as the TCP protocol and the User Datagram Protocol (UDP) protocol.
[0053] The network protocol processing unit 2045 (IP Processing) is mainly responsible for the communication between computers, and mainly processes IP protocols, such as processing the route forwarding of IP datagrams, etc., to ensure that data can be efficiently and accurately transmitted from the source IP address to the destination IP address.
[0054] The radio interface layer 205 can be located between the operating system and the target hardware, and is responsible for providing a standardized interface to enable the operating system to communicate with different wireless communication hardware.
[0055] Based on the foregoing embodiments, please refer to Figure 3 is a flowchart of a heartbeat packet sending method according to an exemplary embodiment. As Figure 3 indicated, the method can be applied to Figure 2 indicated target hardware, and the method can include: S301, monitoring TCP packet information transmitted on a TCP long connection in a pre-configured managed heartbeat period, the TCP long connection being a long connection established between a terminal device and a server.
[0056] The above-mentioned managed heartbeat period in the present disclosure can refer to a heartbeat period / time for maintaining contact between a client (such as a terminal device) and a server, and specifically can refer to an interval time for sending and receiving heartbeat packets between the client and the server at regular intervals. The managed heartbeat period can be pre-configured by the system according to actual needs. The above-mentioned TCP packet information can refer to information about the data packets transmitted on the TCP long connection, which can include but is not limited to, for example, TCP packet sending density, TCP packet quantity, or other data packet information used for heartbeat packet hardware hosting, etc.
[0057] In a specific implementation, at the beginning of target hardware hosting, the heartbeat packet management unit 2041 (HM) can control the observation window sub-unit 2042 to open an observation window to monitor the TCP packet information transmitted on the TCP long connection in real time or periodically through the observation window.
[0058] In some embodiments, the length of the above-mentioned observation window is related to the above-mentioned managed heartbeat period, and specifically can be determined according to the above-mentioned managed heartbeat period, for example, the length of the observation window can be one fourth of the above-mentioned managed heartbeat period, or can be one half of the above-mentioned managed heartbeat period, etc., which will not be limited and described in detail in the present disclosure.
[0059] S302, when the TCP packet information meets a preset condition, sending a heartbeat packet to the server, the preset condition being associated with the TCP packet information.
[0060] The preset condition in the present disclosure can refer to a condition that is predefined by the system or the user and is used for judging the management of the heartbeat packet transmission. The condition is related to the TCP packet information. For example, the condition can include, but is not limited to, any one or a combination of multiple items, such as: when the TCP packet information includes the TCP packet transmission density, the preset condition can include that the TCP packet transmission density is less than a preset density threshold; when the TCP packet information includes the TCP packet quantity, the preset condition can include that the TCP packet quantity is less than a preset quantity threshold. The preset density threshold and the preset quantity threshold can be thresholds predefined by the system according to actual conditions. For example, the thresholds can be experience values set according to user experience, or can be statistical values calculated according to a series of experimental data, and the present disclosure does not make too many limitations and details.
[0061] After obtaining the TCP packet information, the present disclosure can determine whether the TCP packet information meets the preset condition. For example, when the TCP packet information includes the TCP packet transmission density, it can be determined whether the TCP packet transmission density is less than a preset density threshold (Packet Threshold). If yes, it can be determined that the TCP packet information meets the preset condition; otherwise, it can be determined that the TCP packet information does not meet the preset condition.
[0062] By implementing the embodiments of the present disclosure, the target hardware monitors the TCP packet information transmitted on the TCP long connection in the managed heartbeat period of the target hardware. The TCP long connection is a long connection established between the terminal device and the server. When the TCP packet information meets a preset condition, the target hardware sends a heartbeat packet to the server. The preset condition is associated with the TCP packet information. In this way, the present disclosure can replace the kernel TCP / IP protocol stack or the application layer to send a heartbeat packet without waking up the application processor (AP) by optimizing the heartbeat packet transmission of the target hardware for the TCP long connection. In this way, the TCP keep-alive is realized, and the power consumption caused by the wake-up of the AP is avoided. In addition, the technical problems of waking up the AP and reducing the endurance time in the related art are also solved.
[0063] Some embodiments of the present disclosure are described below.
[0064] In some embodiments, when the TCP packet information meets the preset condition, the heartbeat packet management unit 2041 (HM) can normally send a heartbeat packet to the server. The heartbeat packet can be a heartbeat packet carrying a payload. Correspondingly, the server can send an acknowledgement packet to the target hardware (specifically, the HM of the target hardware) after receiving the heartbeat packet, to notify that the heartbeat packet is received. The target hardware can receive the acknowledgement packet.
[0065] In an optional embodiment, after sending the heartbeat packet, the target hardware can update the message sequence number (Seq) information corresponding to the heartbeat packet to obtain the latest message sequence number information, wherein the latest message sequence number (Seq) in the latest message sequence number information is the sum of the previous message sequence number and the length of the heartbeat packet. Optionally, after receiving the confirmation packet, the target hardware can update the confirmation sequence number (Ack) information corresponding to the confirmation packet to obtain the latest confirmation sequence number information, wherein the latest confirmation sequence number (Ack) in the latest confirmation sequence number information is the sum of the previous confirmation sequence number and the length of the confirmation packet.
[0066] In yet some embodiments, when the TCP packet information does not satisfy the preset condition, the heartbeat packet management unit 2041 (HM) can skip the current hosting heartbeat period, not send the heartbeat packet, and update the corresponding skip number (Skips), and continue to perform the steps of S301 and S302 in the next hosting heartbeat period for re-judgment. It can be understood that when the TCP packet information does not satisfy the preset condition, for example, the TCP packet sending density is greater than or equal to the corresponding preset density threshold, it indicates that the TCP long connection is updated in time, and there is no need for the hardware to host the heartbeat; thereby the conflict probability of the heartbeat packet and the service packet Seq / Ack hosted by the hardware can be reduced, and the sending number of unnecessary hosting packets (heartbeat packets) can be reduced.
[0067] In yet another optional embodiment, when the skip number is greater than or equal to a preset number threshold, the target hardware can forcibly send the heartbeat packet to the server, and clear the skip number to wait for the hardware hosting heartbeat processing in the next hosting heartbeat period. The preset number threshold can be a threshold predefined by the system according to actual conditions, for example, it can be an experience value set according to user experience, or it can be a statistical value calculated according to a series of experimental data, and the present disclosure does not make too many limitations and details.
[0068] In yet some embodiments, the kernel TCP / IP protocol stack is aware of the lag of the Seq / Ack change of the TCP long connection hosted by the target hardware (such as a modem), and when the target hardware sends a heartbeat packet carrying a payload, the kernel TCP / IP protocol stack cannot perceive the Seq / Ack change, and the target hardware still sends the heartbeat packet according to the previous Seq / Ack sequence number when sending the upper-layer TCP heartbeat packet. To solve this problem, the present disclosure provides an information synchronization scheme based on interrupts and system calls, which core idea is that after the target hardware sends the heartbeat packet, the kernel TCP / IP protocol stack is notified to update the corresponding Seq / Ack sequence number information through the interrupt mechanism. Please refer toFigure 4 is a flowchart of an information synchronization method according to an exemplary embodiment. As shown in Figure 4 The method shown can include the following implementation steps: S401, the target hardware calls the pre-configured interrupt processing function to obtain the latest packet information, the latest packet information including the latest sequence number of the heartbeat packet and / or the latest acknowledgement sequence number of the acknowledgement packet, the acknowledgement packet being a packet returned by the server based on the heartbeat packet.
[0069] After the target hardware sends the heartbeat packet to the server, and / or after the target hardware receives the acknowledgement packet returned by the server based on the heartbeat packet, the target hardware can trigger / call the pre-configured interrupt processing function to obtain the latest packet information through the synchronization control subunit 2043 (Seq / AckSync-Controller). The latest packet information can include the latest message sequence number information and / or the latest acknowledgement sequence number information described above, i.e., the latest sequence number of the heartbeat packet and / or the latest acknowledgement sequence number of the acknowledgement packet. Alternatively, the latest packet information can also include the corresponding socket file descriptor (sockfd), which is used to uniquely identify the TCP socket (TCP Socket), which is described in detail below in this disclosure, and will not be described here. The interrupt processing function described above in this disclosure is an interrupt function pre-defined by the system or user, for example, which can be seen from Table 2 as follows: Table 2 / / Register interrupt vector table void (*interrupt_vector_table[ ])( ) __attribute__ ((section(".isr_vector"))) = { tcp_seqack_update_IRQHandler, }; / / Interrupt service routine void tcp_seqack_update_IRQHandler(void); / / Initialize interrupt processing function void init_tcp_seqack_update_interrupt(void); S402, the target hardware calls a pre-configured TCP update function to transmit the latest packet information to the kernel TCP / IP protocol stack of the terminal device, so as to update the latest packet information. Correspondingly, the kernel TCP / IP protocol stack receives the latest packet information.
[0070] The TCP update function mentioned in the present disclosure can be a function newly added in the kernel space by the system in advance, which is used to transmit the latest packet information (for example, the latest sequence number of the heartbeat packet and / or the latest acknowledgement sequence number of the acknowledgement packet in the latest packet information) to the kernel TCP / IP protocol stack. The TCP update function can include, but is not limited to, for example, a modem_tcp_update_seqack() function and the like.
[0071] In a specific implementation, the target hardware can call the TCP update function to transmit the latest packet information to the kernel TCP / IP protocol stack, for example, the specific function call mode can be int modem_tcp_update_seqack(int sockfd, uint32_t new_seq, uint32_t new_ack). Wherein, sockfd represents a socket descriptor, new_seq represents the latest sequence number of the latest heartbeat packet, and new_ack represents the latest acknowledgement sequence number of the latest acknowledgement packet. Alternatively, if the TCP update function modem_tcp_update_seqack() successfully transmits the latest packet information to the kernel TCP / IP protocol stack, the return value of the TCP update function can be 0; otherwise, a negative number or an error code can be returned.
[0072] In some optional embodiments, after transmitting the latest packet information, the target hardware can continue to wait for the acknowledgement information of the kernel TCP / IP protocol stack, so as to ensure that the kernel TCP / IP protocol stack successfully receives and processes the update of the latest packet information.
[0073] S403, the kernel TCP / IP protocol stack performs information synchronization based on the latest sequence number of the heartbeat packet and / or the latest acknowledgement sequence number of the acknowledgement packet in the latest packet information.
[0074] After receiving the latest packet information, the kernel TCP / IP protocol stack can perform corresponding information synchronization update based on the latest packet information. The present disclosure does not limit the specific implementation of the information synchronization, for example, please refer to Figure 5 is a flowchart of information synchronization according to an exemplary embodiment. As Figure 5 shown in the flowchart can include the following steps: S501, determining a TCP socket corresponding to the socket descriptor based on the socket descriptor.
[0075] The kernel TCP / IP stack finds the TCP socket corresponding to the socket descriptor sockfd in the TCP / IP stack according to the socket descriptor sockfd passed in by the call of the TCP update function. Optionally, the disclosure can also use a spin lock or a mutex to access the TCP socket to ensure the safety of thread access. The spin lock can be a non-blocking lock, when a thread tries to acquire a spin lock held by another thread, the thread will enter a busy waiting state, i.e. constantly loop to check if the lock is available, rather than being suspended. The mutex is a blocking lock, when a thread holds the lock, other threads trying to acquire the lock will be blocked until the lock is released. The mutex allows the thread to enter a sleep state when it cannot acquire the lock, thereby releasing CPU resources to other threads. This mechanism avoids busy waiting and reduces CPU resource consumption.
[0076] S502, updating the sequence number of the heartbeat packet and / or the acknowledgement sequence number of the acknowledgement packet in the TCP socket based on the latest sequence number of the heartbeat packet and / or the latest acknowledgement sequence number of the acknowledgement packet in the latest packet information.
[0077] The disclosure can correspondingly update the sequence number of the heartbeat packet in the TCP socket to the latest sequence number of the heartbeat packet in the latest packet information, and / or correspondingly update the acknowledgement sequence number of the acknowledgement packet in the TCP socket to the latest acknowledgement sequence number of the acknowledgement packet in the latest packet information, for example, the disclosure can correspondingly update the Seq / Ack value in the TCP socket to new_seq or new_ack to ensure that the Seq / Ack in the TCP socket is consistent with the latest Seq / Ack.
[0078] In yet another optional embodiment, the kernel TCP / IP stack can also update parameter information related to the latest packet information, such as flow control parameters or other parameter information, etc. Taking the flow control parameter as an example, the flow control parameter is used to control the transmission rate of TCP packets, which can also be a control parameter of the congestion control window. The parameter can be calculated according to / based on the latest sequence number of the heartbeat packet and / or the latest acknowledgement sequence number of the acknowledgement packet in the latest packet information, and the disclosure does not limit the specific calculation implementation, for example, it can be calculated by using a pre-designed calculation formula.
[0079] S404, the kernel TCP / IP protocol stack sends update confirmation information to the target hardware. Accordingly, the target hardware receives the update confirmation information. The update confirmation information is used to indicate that the kernel TCP / IP protocol stack completes the update of the latest packet information and synchronizes the latest packet information between the target hardware and the kernel TCP / IP protocol stack of the terminal device. Thus, the synchronization of the latest packet information between the target hardware and the kernel TCP / IP protocol stack is achieved. The specific implementation of the synchronization of the latest packet information between the target hardware and the kernel TCP / IP protocol stack can be referred to the foregoing Figure 5 The related description in the embodiments will not be repeated here.
[0080] The kernel TCP / IP protocol stack can send corresponding update confirmation information to the target hardware to notify / instruct the kernel TCP / IP protocol stack to complete the update of the latest packet information and synchronize the latest packet information between the target hardware and the kernel TCP / IP protocol stack of the terminal device. Thus, the update of the latest packet information between the target hardware and the kernel TCP / IP protocol stack is synchronized.
[0081] It can be seen that, through the TCP Seq / Ack synchronization mechanism on the target hardware side and the kernel TCP / IP protocol stack side of the terminal device, the kernel TCP / IP protocol stack can realize real-time sensing of the Seq / Ack change of the TCP long connection hosted by the target hardware, eliminate the sequence number conflict problem caused by lag, and thus improve the stability, reliability and effectiveness of the hardware-hosted TCP long connection.
[0082] The terminal device involved in the present disclosure can also be referred to as user equipment (UE), a mobile station (MS), a mobile terminal (MT), etc. The terminal device can be a car, a smart car, a mobile phone, a wearable device, a tablet computer (Pad), a computer with wireless transceiver function, a virtual reality (VR) terminal device, an augmented reality (AR) terminal device, a wireless terminal device in industrial control, a wireless terminal device in self-driving, a wireless terminal device in remote medical surgery, a wireless terminal device in smart grid, a wireless terminal device in transportation safety, a wireless terminal device in smart city, a wireless terminal device in smart home, etc. The present embodiment of the present disclosure does not limit the specific technology and specific device form of the terminal device.
[0083] By implementing the present embodiment, the target hardware monitors TCP packet information transmitted on a TCP long connection in a pre-configured managed heartbeat period, the TCP long connection being a long connection established between the terminal device and a server; when the TCP packet information meets a preset condition, a heartbeat packet is sent to the server, the preset condition being associated with the TCP packet information. In this way, the present disclosure can replace the kernel TCP / IP protocol stack or the application layer to send a heartbeat packet without waking up the application processor (AP) by optimizing the target hardware to manage the TCP long connection to send a heartbeat packet, which is conducive to reducing power consumption; both the keep-alive of TCP and the power consumption caused by the wake-up of the AP are avoided, and the technical problems of waking up the AP and reducing the endurance time in the related art are also solved.
[0084] Based on the foregoing embodiments, please refer to Figure 6 is a structural schematic diagram of a heartbeat packet sending device according to an exemplary embodiment. As Figure 6 The device shown in the figure can be applied in a terminal device, for example, in the target hardware of the terminal device, etc. The device can include a processing module 601 and a transceiver module 602. Wherein: The processing module 601 is configured to monitor TCP packet information transmitted on a TCP long connection in a pre-configured managed heartbeat period, the TCP long connection being a long connection established between the terminal device and a server; The transceiving module 602 is configured to send a heartbeat packet to the server when the TCP packet information meets a preset condition, the preset condition being associated with the TCP packet information.
[0085] In some embodiments, when the TCP packet information comprises a TCP packet sending density, the preset condition comprises that the TCP packet sending density is less than a preset density threshold; and / or, When the TCP packet information comprises a TCP packet number, the preset condition comprises that the TCP packet number is less than a preset number threshold.
[0086] In some embodiments, the processing module 601 is further configured to: When the TCP packet information does not meet the preset condition, skip the hosting heartbeat period, update a corresponding skip number, and wait for the next hosting heartbeat period to repeat the step of monitoring the TCP packet information transmitted on the TCP long connection in the pre-configured hosting heartbeat period.
[0087] In some embodiments, the processing module 601 is further configured to: When the skip number is greater than or equal to a preset number threshold, forcibly send a heartbeat packet to the server, and clear the skip number.
[0088] In some embodiments, the processing module 601 is further configured to: Call a pre-configured interrupt processing function to obtain the latest packet information, the latest packet information comprising a latest sequence number of the heartbeat packet and / or a latest acknowledgement sequence number of an acknowledgement packet returned by the server based on the heartbeat packet; Call a pre-configured TCP update function to transmit the latest packet information to a kernel TCP / IP protocol stack of the terminal device to synchronously update the latest packet information.
[0089] In some embodiments, the processing module 601 is configured to: After sending the heartbeat packet to the server, and / or after receiving the acknowledgement packet returned by the server based on the heartbeat packet, call the pre-configured interrupt processing function to obtain the latest packet information.
[0090] In some embodiments, the transceiving module 602 is further configured to: Receive update acknowledgement information of the kernel TCP / IP protocol stack, the update acknowledgement information being used to indicate that the kernel TCP / IP protocol stack has completed updating of the latest packet information; Synchronize the latest data packet information between the target hardware of the terminal device and the kernel TCP / IP protocol stack.
[0091] In some embodiments, in the kernel TCP / IP protocol stack, the transceiving module 602 is configured to receive the latest data packet information; and the processing module 601 is configured to perform information synchronization based on the latest sequence number of the heartbeat packet and / or the latest acknowledgement sequence number of the acknowledgement packet in the latest data packet information.
[0092] In some embodiments, the latest data packet information further comprises a socket descriptor, and the processing module 601 is configured to: determine a TCP socket corresponding to the socket descriptor based on the socket descriptor; update the sequence number of the heartbeat packet and / or the acknowledgement sequence number of the acknowledgement packet in the TCP socket based on the latest sequence number of the heartbeat packet and / or the latest acknowledgement sequence number of the acknowledgement packet in the latest data packet information.
[0093] In some embodiments, in the kernel TCP / IP protocol stack, the processing module 601 is further configured to: update parameter information related to the latest data packet information, the parameter information at least comprising a flow control parameter determined based on the latest sequence number of the heartbeat packet and / or the latest acknowledgement sequence number of the acknowledgement packet in the latest data packet information.
[0094] In some embodiments, the TCP data packet information is obtained by monitoring through an observation window after the observation window is opened, wherein the length of the observation window is determined according to the hosting heartbeat period.
[0095] It should be noted that the above processing module 601 and the above transceiving module 602 in the present disclosure can realize the functions of some or all of the modules / units in the embodiments, for example, can realize the functions of the observation window sub-unit 2042 and the synchronization control sub-unit 2043; the above transceiving module 602 can realize the function of the heartbeat packet management unit 2041, and the present disclosure does not make excessive limitations and descriptions on this. Figure 2
[0096] For the content not introduced or described in the embodiments of the present disclosure, reference can be made to the relevant introduction in the foregoing embodiments, which will not be described here.
[0097] Please refer to Figure 7 is a structural schematic diagram of an information synchronization device according to an exemplary embodiment. As shown in Figure 7 The apparatus shown can be applied in a kernel TCP / IP protocol stack (for example, a kernel TCP / IP protocol stack of a terminal device), and the apparatus can include a transceiving module 701 and a processing module 702. Wherein: The transceiving module 701 is configured to receive latest data packet information of target hardware transmission of the terminal device, the latest data packet information being transmitted by the target hardware invoking a provisioned TCP update function, and the latest data packet information including a latest sequence number of the heartbeat data packet and / or a latest acknowledgement sequence number of the acknowledgement data packet. The processing module 702 is configured to perform information synchronization based on the latest sequence number of the heartbeat data packet and / or the latest acknowledgement sequence number of the acknowledgement data packet in the latest data packet information.
[0098] In some embodiments, the latest data packet information further includes a socket descriptor, and the processing module 702 is configured to: determine a TCP socket corresponding to the socket descriptor based on the socket descriptor; update a sequence number of a heartbeat data packet and / or an acknowledgement sequence number of an acknowledgement data packet in the TCP socket based on the latest sequence number of the heartbeat data packet and / or the latest acknowledgement sequence number of the acknowledgement data packet in the latest data packet information.
[0099] In some embodiments, the transceiving module 701 is further configured to: send update acknowledgement information to the target hardware, the update acknowledgement information being used to indicate that the kernel TCP / IP protocol stack completes update of the latest data packet information, thereby achieving synchronization of the latest data packet information between the target hardware and the kernel TCP / IP protocol stack.
[0100] In some embodiments, the processing module 702 is further configured to: update parameter information related to the latest data packet information, the parameter information at least including a flow control parameter, the flow control parameter being determined based on the latest sequence number of the heartbeat data packet and / or the latest acknowledgement sequence number of the acknowledgement data packet in the latest data packet information.
[0101] Aspects of the present disclosure not introduced or described in the embodiments can correspond to the relevant introduction in the foregoing embodiments, and will not be described here.
[0102] By implementing the embodiments of the present disclosure, the above-mentioned device can monitor the TCP packet information transmitted on the TCP long connection in the pre-configured managed heartbeat period, the TCP long connection being a long connection established between a terminal device and a server; when the TCP packet information meets a preset condition, a heartbeat packet is sent to the server, the preset condition being associated with the TCP packet information. In this way, the present disclosure can replace the kernel TCP / IP protocol stack or the application layer to send the heartbeat packet without waking up the application processor (AP) by optimizing the sending of the heartbeat packet of the target hardware-managed TCP long connection, which is conducive to reducing power consumption; both the TCP keep-alive and the power consumption caused by the wake-up of the AP are avoided, and the technical problems of waking up the AP and reducing the endurance time in the related art are also solved.
[0103] The present disclosure also provides a computer-readable storage medium having stored thereon computer program instructions, which, when executed by a processor, implement the steps of the heartbeat packet sending method provided by the present disclosure.
[0104] Figure 8 is a structural schematic diagram of a communication device according to an exemplary embodiment. For example, the communication device 800 can be the heartbeat packet sending device or the information synchronization device described above, which can be, for example, a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
[0105] Referring to Figure 8 , the communication device 800 can include one or more of the following components: a processing component 802, a memory 804, a power supply component 806, a multimedia component 808, an audio component 810, an input / output (I / O) interface 812, a sensor component 814, and a communication component 816.
[0106] The processing component 802 usually controls overall operations of the device 800, such as operations associated with displaying, making phone calls, data communications, camera operations and recording operations. The processing component 802 can include one or more processors 820 to execute instructions to complete all or part of steps of the methods described above. In addition, the processing component 802 can include one or more modules to facilitate the interaction between the processing component 802 and other components. For example, the processing component 802 can include a multimedia module to facilitate the interaction between the multimedia component 808 and the processing component 802.
[0107] The memory 804 is configured to store various types of data to support operations of the device 800. Examples of such data include instructions for any application or methods operating on the device 800, contact data, phonebook data, messages, pictures, videos, and so on. The memory 804 can be implemented by any type of volatile or nonvolatile storage devices or a combination thereof such as static random access memory (SRAM), electrically erasable programmable read only memory (EEPROM), erasable programmable read only memory (EPROM), programmable read only memory (PROM), read only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0108] The power supply component 806 supplies electrical power for various components of the device 800. The power supply component 806 can include a power supply management system, one or more power supplies, and other components associated with generating, managing and distributing electrical power for the device 800.
[0109] The multimedia component 808 includes a screen providing an output interface between the device 800 and a user. In some embodiments, the screen can include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen can be implemented as a touch screen to receive input signals from a user. The touch panel includes one or more touch sensors to sense touch, swiping and gestures on the touch panel. The touch sensors can not only sense a boundary of a touch or swiping action, but also detect duration and pressure associated with the touch or swiping action. In some embodiments, the multimedia component 808 includes a front camera and / or a rear camera. The front and / or rear camera can receive external multimedia data when the device 800 is in an operation mode, such as a shooting mode or a video mode. Each of the front and rear camera can be a fixed optical lens system or have a focal length and optical zoom capability.
[0110] The audio component 810 is configured to output and / or input audio signals. For example, the audio component 810 includes a microphone (MIC) that is configured to receive an external audio signal when the device 800 is in an operation mode, such as a calling mode, a recording mode and a voice recognition mode. The received audio signal can be further stored in the memory 804 or transmitted via the communication component 816. In some embodiments, the audio component 810 also includes a speaker for outputting audio signals.
[0111] The input / output interface 812 provides an interface between the processing component 802 and peripheral interface modules, which can be a keyboard, a click wheel, buttons, and so on. The buttons can include, but are not limited to, a home button, a volume button, a start button and a lock button.
[0112] The sensor component 814 includes one or more sensors for providing status assessments for various aspects of the device 800. For example, the sensor component 814 can detect an open / closed position of the device 800, relative positioning of components, such as a display and keypad of the device 800, a change in position of the device 800 or a component of the device 800, presence or absence of user contact with the device 800, orientation or acceleration / deceleration of the device 800, and temperature changes of the device 800. The sensor component 814 can include proximity sensor(s) configured to detect presence of nearby objects without any physical contact. The sensor component 814 can further include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor component 814 can further include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0113] The communication component 816 is configured to facilitate wired or wireless communication between the device 800 and another device. The device 800 can access a wireless network based on a corresponding communication standard, such as WiFi, 2G, or 3G, or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 further includes a Near Field Communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on Radio Frequency Identification (RFID) technology, Infrared Data Association (IrDA) technology, Ultra-WideBand (UWB) technology, Bluetooth (BT) technology, and other technologies.
[0114] In an exemplary embodiment, the device 800 can be implemented using one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, microcontrollers, or other electronic units to perform the above-described methods.
[0115] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions, such as the memory 804 including instructions, is also provided, which can be executed by the processor 820 of the device 800 to perform the above-described methods. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disc, and an optical data storage device, etc.
[0116] The apparatus can be an independent electronic device or a part of an independent electronic device. For example, in an embodiment, the apparatus can be an integrated circuit (IC) or a chip. The integrated circuit can be one IC or a collection of multiple ICs. The chip can include, but is not limited to, a GPU (Graphics Processing Unit), a CPU (Central Processing Unit), an FPGA (Field Programmable Gate Array), a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an SOC (System on Chip), and the like. The integrated circuit or the chip can execute executable instructions (or code) to implement the heartbeat packet sending method. The executable instructions can be stored in the integrated circuit or the chip, or obtained from other devices or apparatuses. For example, the integrated circuit or the chip can include a processor, a memory, and an interface for communicating with other devices. The executable instructions can be stored in the memory and executed by the processor to implement the heartbeat packet sending method. Alternatively, the integrated circuit or the chip can receive executable instructions through the interface and transmit the executable instructions to the processor for execution to implement the heartbeat packet sending method.
[0117] In another exemplary embodiment, a computer program product is also provided, which includes a computer program capable of being executed by a programmable apparatus, and the computer program has a code portion for executing the heartbeat packet sending method when executed by the programmable apparatus.
[0118] Please refer to Figure 9 FIG. 9 is a structural schematic diagram of a chip according to an exemplary embodiment. As shown in FIG. 9, the chip 900 includes a processor 901 and an interface 902. Optionally, the chip 900 can further include a memory 903. The number of the processor 901 can be one or more, and the number of the interface 902 can be multiple. Figure 9
[0119] In an embodiment, for the case that the chip is used to implement the method embodiments of the present disclosure: The interface 902 is configured to receive or output a signal. The processor 901 is configured to execute part or all of the contents of the heartbeat packet sending method embodiments.
[0120] Understandably, the processor in the embodiments of the present disclosure can be an integrated circuit chip having a processing capability of signals. In the implementation process, each step of the method embodiments described above can be completed by the integrated logic circuit of hardware in the processor or the instructions in the form of software. The processor described above can be a general processor, a digital signal processor (Digital Signal Processor, DSP), an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field programmable gate array (Field Programmable Gate Array, FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware component.
[0121] Understandably, the memory in the embodiments of the present disclosure can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (read-only memory, ROM), a programmable read-only memory (programmable ROM, PROM), an erasable programmable read-only memory (erasable PROM, EPROM), an electrically erasable programmable read-only memory (electrically EPROM, EEPROM) or a flash memory. The volatile memory can be a random access memory (random access memory, RAM) used as an external cache. By way of example but not limitation, many forms of RAM are available, such as static random access memory (static RAM, SRAM), dynamic random access memory (dynamic RAM, DRAM), synchronous dynamic random access memory (synchronous DRAM, SDRAM), double data rate synchronous dynamic random access memory (double data rate SDRAM, DDR SDRAM), enhanced synchronous dynamic random access memory (enhanced SDRAM, ESDRAM), synchronous link dynamic random access memory (synchlink DRAM, SLDRAM) and direct memory bus random access memory (direct rambus RAM, DR RAM). It should be noted that the memory of the system and method described herein is intended to include but not limited to these and any other suitable types of memory.
[0122] It should be noted that the description of the above storage medium, device and chip embodiments is similar to the description of the above method embodiments, and has similar beneficial effects as the method embodiments. For technical details not disclosed in the storage medium, storage medium and device embodiments of the present disclosure, please refer to the description of the method embodiments of the present disclosure for understanding.
[0123] Other embodiments of the present disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the present disclosure. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure following, in general, the principles of the present disclosure and including such
[0124] It should be understood that the present disclosure is not limited to the precise structures as already described and shown in the drawings, and that various modifications and changes can be made without departing from its scope. The scope of the present disclosure is limited only by the claims that follow.
Claims
1. A heartbeat packet transmission method, characterized by, The method comprises: monitoring TCP packet information transmitted on a TCP long connection in a pre-configured hosting heartbeat period, the TCP long connection being a long connection established between a terminal device and a server; when the TCP packet information meets a preset condition, sending a heartbeat packet to the server, the preset condition being associated with the TCP packet information.
2. The method of claim 1, wherein, when the TCP packet information comprises TCP packet sending density, the preset condition comprises that the TCP packet sending density is less than a preset density threshold; and / or, when the TCP packet information comprises a TCP packet quantity, the preset condition comprises that the TCP packet quantity is less than a preset quantity threshold.
3. The method of claim 2, wherein, The method further comprises: when the TCP packet information does not meet the preset condition, skipping the hosting heartbeat period, updating a corresponding skip quantity, and waiting for a next hosting heartbeat period to repeat the step of monitoring TCP packet information transmitted on a TCP long connection.
4. The method of claim 3, wherein, The method further comprises: when the skip quantity is greater than or equal to a preset quantity threshold, forcibly sending a heartbeat packet to the server and performing zero processing on the skip quantity.
5. The method of claim 1, wherein, The method further comprises: calling a pre-configured interrupt processing function to obtain latest packet information, the latest packet information comprising a latest sequence number of the heartbeat packet and / or a latest acknowledgement sequence number of an acknowledgement packet, the acknowledgement packet being a packet returned by the server based on the heartbeat packet; calling a pre-configured TCP updating function to transmit the latest packet information to a kernel TCP / IP protocol stack of the terminal device to synchronously update the latest packet information.
6. The method of claim 5, wherein, The calling of the pre-configured interrupt processing function to obtain the latest packet information comprises: after the heartbeat packet is sent to the server, and / or after the acknowledgement packet returned by the server based on the heartbeat packet is received, calling the pre-configured interrupt processing function to obtain the latest packet information.
7. The method of claim 6, wherein, The method further comprises: receiving update acknowledgement information of the kernel TCP / IP protocol stack, the update acknowledgement information being used to indicate that the kernel TCP / IP protocol stack completes updating of the latest packet information; synchronizing the latest packet information between target hardware of the terminal device and the kernel TCP / IP protocol stack.
8. The method of claim 7, wherein, The synchronization of the latest packet information between the target hardware of the terminal device and the kernel TCP / IP protocol stack comprises: the kernel TCP / IP protocol stack receives the latest packet information; the kernel TCP / IP protocol stack performs information synchronization based on the latest sequence number of the heartbeat packet and / or the latest acknowledgement sequence number of the acknowledgement packet in the latest packet information.
9. The method of claim 8, wherein, The latest packet information further comprises a socket descriptor, and the information synchronization based on the latest sequence number of the heartbeat packet and / or the latest acknowledgement sequence number of the acknowledgement packet in the latest packet information comprises: based on the socket descriptor, determining a TCP socket corresponding to the socket descriptor; corresponding update a sequence number of a heartbeat packet and / or an acknowledgement sequence number of an acknowledgement packet in the TCP socket based on the latest sequence number of the heartbeat packet and / or the latest acknowledgement sequence number of the acknowledgement packet in the latest packet information.
10. The method according to any one of claims 5-9, characterized in that, The method further comprises: updating parameter information related to the latest packet information, the parameter information at least comprising a flow control parameter determined based on the latest sequence number of the heartbeat packet and / or the latest acknowledgement sequence number of the acknowledgement packet in the latest packet information.
11. The method according to any one of claims 1-9, characterized in that, The TCP packet information is obtained by monitoring through an observation window after the observation window is opened, wherein a length of the observation window is determined according to the hosting heartbeat period.
12. A heartbeat packet transmitting apparatus characterized by comprising: The apparatus comprises: a processing module configured to monitor TCP packet information transmitted on a TCP long connection in a pre-configured hosting heartbeat period, the TCP long connection being a long connection established between a terminal device and a server; a transceiving module configured to send a heartbeat packet to the server when the TCP packet information satisfies a preset condition, the preset condition being associated with the TCP packet information.
13. A communications device, characterized by comprise: a processor; a memory for storing processor-executable instructions; wherein the processor is configured to execute the executable instructions to implement steps of the method of any one of claims 1-11.
14. A computer-readable storage medium having stored thereon computer program instructions, wherein, The computer program instructions, when executed by the processor, implement steps of the method of any one of claims 1-11.
15. A chip, characterized by comprise a processor and an interface; the processor is used to read instructions to execute the method of any one of claims 1-11.