WO2018223592A1 - 维持心跳连接的方法、装置和终端设备 - Google Patents
维持心跳连接的方法、装置和终端设备 Download PDFInfo
- Publication number
- WO2018223592A1 WO2018223592A1 PCT/CN2017/109430 CN2017109430W WO2018223592A1 WO 2018223592 A1 WO2018223592 A1 WO 2018223592A1 CN 2017109430 W CN2017109430 W CN 2017109430W WO 2018223592 A1 WO2018223592 A1 WO 2018223592A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- test
- long connection
- heartbeat period
- heartbeat
- period
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Ceased
Links
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04W—WIRELESS COMMUNICATION NETWORKS
- H04W24/00—Supervisory, monitoring or testing arrangements
- H04W24/08—Testing, supervising or monitoring using real traffic
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L43/00—Arrangements for monitoring or testing data switching networks
- H04L43/10—Active monitoring, e.g. heartbeat, ping or trace-route
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L43/00—Arrangements for monitoring or testing data switching networks
- H04L43/16—Threshold monitoring
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D30/00—Reducing energy consumption in communication networks
- Y02D30/70—Reducing energy consumption in communication networks in wireless communication networks
Definitions
- the present invention relates to the field of communications technologies, and in particular, to a method, apparatus, and terminal device for maintaining a heartbeat connection.
- the satellite mobile communication network also supports the function of the TCP/IP link to access the Internet, so the terminal device can communicate via the satellite mobile communication network.
- the existing satellite mobile communication network does not have a determined heartbeat period. If the period of the heartbeat packet sent by the terminal device is too large, the long connection cannot be maintained. If the heartbeat packet is frequently transmitted, the power consumption is increased. Therefore, how to determine a suitable heartbeat period with low connection power consumption and capable of maintaining a long connection for a communication network with no determined heartbeat period is a technical problem that needs to be solved.
- a primary object of the present invention is to provide a method of maintaining a long connection that is intended to determine a suitable heartbeat period for a communication network that has no determined heartbeat cycle and that is capable of maintaining a long connection.
- the embodiment of the present invention provides a method for maintaining a long connection, and the method includes the following steps:
- the long connection test is performed in the first heartbeat period
- the first heartbeat period is capable of maintaining a long connection port
- a long connection test is performed on the basis of the first heartbeat period to obtain a second heartbeat period capable of maintaining a long connection
- reduce the length of the first heartbeat cycle to perform a long connection test and obtain a second heartbeat cycle capable of maintaining a long connection
- Embodiments of the present invention also provide a device for maintaining a long connection, the device comprising:
- a first test module configured to perform a long connection test in a first heartbeat period after accessing the second network
- a second test module configured to maintain a long connection when the first heartbeat period Adding a long connection test based on the first heartbeat period to obtain a second heartbeat period capable of maintaining a long connection
- a third test module configured to: when the first heartbeat period cannot maintain a long connection, reduce a length on the basis of the first heartbeat period, perform a long connection test, and obtain a second heartbeat capable of maintaining a long connection Cycle
- connection maintaining module configured to maintain a long connection in the second heartbeat cycle.
- Embodiments of the present invention further provide a terminal device, where the terminal device includes a memory, a processor, and at least one application stored in the memory and configured to be executed by the processor, wherein The application is configured to perform the aforementioned method of maintaining a long connection.
- a method for maintaining a long connection when accessing a second network that has no determined heartbeat period, using a first heartbeat period as a reference period, adding on the basis of the first heartbeat period Or reduce the length of the long connection test to obtain a heartbeat cycle suitable for the second network.
- the long connection between the terminal device and the server is maintained, and the terminal device is always online, so that the server can push information to the terminal device through the second network; on the other hand, the terminal device can send the server to the server with a suitable heartbeat cycle.
- the heartbeat packet eliminates the need to send heartbeat packets frequently, reducing the power consumption of long connections.
- a suitable heartbeat period with low connection power consumption and capable of maintaining a long connection is determined.
- FIG. 1 is a flow chart of an embodiment of a method for maintaining a long connection according to the present invention
- 2 is a schematic block diagram of an embodiment of a device for maintaining a long connection according to the present invention
- FIG. 1 is a flow chart of an embodiment of a method for maintaining a long connection according to the present invention
- 2 is a schematic block diagram of an embodiment of a device for maintaining a long connection according to the present invention
- FIG. 1 is a flow chart of an embodiment of a method for maintaining a long connection according to the present invention
- 2 is a schematic block diagram of an embodiment of a device for maintaining a long connection according to the present invention
- FIG. 1 is a flow chart of an embodiment of a method for maintaining a long connection according to the present invention
- 2 is a schematic block diagram of an embodiment of a device for maintaining a long connection according to the present invention
- FIG. 1 is a flow chart of an embodiment of a method for maintaining a long connection according to the present invention
- 2 is a schematic block
- FIG. 3 is a block diagram of a second test module of FIG. 2;
- FIG. 4 is a schematic diagram of another module of the second test module of FIG. 2;
- FIG. 5 is a block diagram of a third test module of FIG. 2;
- FIG. 6 is a block diagram of a third test module of FIG. 2.
- the method includes the following steps:
- the long connection test is performed in the first heartbeat period.
- the heartbeat period according to the embodiment of the present invention refers to a period in which the terminal device sends a heartbeat packet (idle data packet) to the server.
- the first heartbeat period is a reference heartbeat period, which may be a heartbeat period randomly determined by the terminal device, or may be a known heartbeat period of the first network, that is, after the terminal device accesses the first network.
- a heartbeat cycle that maintains a long connection with the server.
- the second network is a network to be determined to be a suitable heartbeat period, and the embodiment of the present invention may perform a long connection test on the second network by using a known heartbeat period of the first network as a reference.
- Two The appropriate heartbeat cycle of the network is a public land mobile communication network
- the second network is a satellite mobile communication network, which is based on the heartbeat period of the public land mobile communication network, and performs long connection test on the satellite mobile communication network to obtain a suitable mobile communication network.
- Heartbeat cycle is based on the heartbeat period of the public land mobile communication network, and performs long connection test on the satellite mobile communication network to obtain a suitable mobile communication network.
- step S11 after accessing the second network, the terminal device performs a long connection test in the first heartbeat period to determine whether the first heartbeat cycle can maintain a long connection. Specifically, the terminal device sends the heartbeat packet M to the server according to the first heartbeat period. After receiving the heartbeat packet M, the server pushes the label data packet N to the terminal device after the delay of the first heartbeat period. If the terminal device can receive the tag data packet N, it indicates that the first heartbeat cycle can maintain the long connection between the terminal device and the server; if the terminal device cannot receive the tag data packet N, it indicates that the first heartbeat cycle cannot maintain the terminal device and the server. Long connection.
- step S12 when the first heartbeat period can maintain the long connection port, the maximum heartbeat period that the second network can reach is greater than the first heartbeat period, so the terminal device increases the length of the first heartbeat period.
- the long connection test acquires a second heartbeat period that is larger than the first heartbeat period and capable of maintaining a long connection.
- the terminal device may perform a long connection test to obtain a second heartbeat period in the following manner:
- the terminal device sequentially increases the length of the long connection test on the basis of the first heartbeat period until the long connection cannot be maintained.
- the heartbeat period of the previous test is compared with the size of the first threshold, and it is determined whether the heartbeat period of the previous test is greater than or equal to the first threshold. If the heartbeat period of the previous test is greater than or equal to the first threshold, the first threshold is selected as the second heartbeat period. If the heartbeat period of the previous test is less than the first threshold, the median value of the sequence of the heartbeat period of the current test and the heartbeat period of the previous test is taken as the heartbeat period for the long connection test.
- the long connection When the long connection is not maintained, continue to take the heartbeat period of the test and the median of the series of the heartbeat period of the previous test which is less than the heartbeat period of the test and the boundary value is used as the heartbeat period for the long connection test; When the long connection port can be maintained, continue to take the heart rate of the test and the median value of the series of the heartbeat period of the previous test which is greater than the heartbeat cycle of the test as the boundary value.
- the test is repeated until the absolute value of the difference between the median of the series and the boundary value is less than the third threshold.
- the absolute value of the difference between the median of the series and the boundary value is less than the third threshold ⁇ , the boundary value smaller than the median in the series is selected as the second heartbeat period.
- the terminal device sequentially increases the length of the long connection test on the basis of the first heartbeat period until the Kth time of the long connection cannot be maintained.
- the long connection is not maintained, it is judged whether the heartbeat period of the K-1th test is greater than or equal to the first threshold. If the heartbeat period of the K-1th test is greater than or equal to the first threshold, the first threshold is selected as the second heartbeat period. If the heartbeat period of the K-1th test is less than the first threshold, the median value of the sequence of the heartbeat period of the Kth test and the heartbeat period of the K-1th test is taken as the K+1th test.
- the heartbeat cycle performs a long connection test; when the long connection cannot be maintained, the median of the sequence of the heartbeat cycle of the K+1th test and the heartbeat cycle of the K-1th test is taken as the K+2
- the heartbeat period of the subtest is subjected to a long connection test; when the long connection is maintained, the median of the sequence of the heartbeat period of the K+1th test and the heartbeat period of the Kth test is taken as the K+2
- the heartbeat period of the subtest is tested for long connection; this is repeated until the absolute value of the difference between the median and the boundary value of the series is less than the third threshold; when the absolute value of the difference between the median and the boundary value of the series is less than the third Threshold ⁇ , select the boundary value less than the median in the series as the second heartbeat period.
- the first threshold and the third threshold may be set according to actual needs, for example, the first threshold may be set within a range of 25-35 minutes, and the third threshold may be set within a range of
- the terminal device sequentially increases the length of the ⁇ ⁇ on the basis of the first heartbeat period, and the ⁇ length of each increase may be equal, for example, each time is increased by 5 minutes; or may be unequal, such as successively decreasing, successively increasing, successively Decrease or increase to a specific value and remain unchanged, and so on.
- the terminal device multiplies the heartbeat period, that is, the heartbeat period after each increase of the length is twice the heartbeat period of the previous test.
- the first heartbeat period is T1
- first increase the heartbeat period to 2 ⁇ 1
- the long connection is maintained, continue to increase the heartbeat cycle to 22T1 for long connection testing.
- the heartbeat period is increased to 2kTl ⁇ , long connections cannot be maintained, where k is a positive integer.
- the second heartbeat period T2 of the required second network is determined by the test.
- the heartbeat period is 2kTl and the heartbeat period of the previous test is 2k-lTl, that is, 21 ⁇ -11 ⁇ 12 ⁇ 21 ⁇ 1. Therefore, the heartbeat period 2k-1T1 of the previous test is compared with the size of the first threshold. Assuming that the first threshold is 30 minutes, it is determined whether the heartbeat period 2k-1T1 of the previous test is greater than or equal to 30 minutes.
- Heartbeat cycle T2 30 minutes.
- the median tl of (2k-lTl, 2kTl) is used as a heartbeat cycle for long connection testing.
- the median t1 is used as the boundary value, and the new median t2 is continued to the left side of the series (2k-lTl, 2kTl), that is, the test is taken.
- the heartbeat period tl and the heartbeat period 2k-lT1 of the previous test which is adjacent to and less than the heartbeat period of the test are the median value t2 of the boundary value series (2k-lTl, tl) as the heartbeat period for the long connection test;
- the median t1 is used as the boundary value, and the new median t2 is continued to the right of the above series (2k-lTl, 2kTl), that is, the heartbeat period tl and phase of the test are taken.
- the heartbeat period 2kT1 of the previous test which is adjacent to and greater than the heartbeat period of this test is the median value t2 of the sequence of the boundary value (tl, 2kTl) as a heartbeat cycle for the long connection test.
- the above steps are repeated as described above, and the median value is repeatedly taken until the absolute value of the difference between the median value of the current series and the boundary value is less than the third threshold.
- the selected column is smaller than the median.
- the terminal device may also perform a long connection test to obtain a second heartbeat period in the following manner: The terminal device sequentially increases the length of the long connection test based on the first heartbeat period until the long connection cannot be maintained. Until the long connection is not maintained, considering that the heartbeat period of the previous test can maintain a long connection during the test, the heartbeat period of the previous test is directly selected as the second heartbeat period. To quickly get the second heartbeat cycle.
- the terminal device may also adopt other methods, for example: the terminal device first adds a first length to the first heartbeat period to perform a long connection test, and determines whether it can Maintain a long connection. When the long connection is maintained, the heartbeat period of this test is directly used as the second heartbeat period. When the long connection is not maintained, the second length is gradually reduced on the basis of the heartbeat period of the test (the second length is less than the first length, and the second length of each reduction may be equal or unequal). Connect the test until the long connection can be maintained; when the long connection is maintained, the heartbeat period of this test is taken as the second heartbeat period.
- step S13 when the first heartbeat period cannot maintain the long connection port, it indicates that the maximum heartbeat period that the second network can reach is smaller than the first heartbeat period, so the terminal device reduces the length of the first heartbeat period. Long connection test to obtain a second heartbeat cycle that can maintain a long connection.
- the terminal device may perform the long connection test to obtain the second heartbeat period in the following manner:
- the terminal device successively reduces the length of the long connection test on the basis of the first heartbeat period until the long connection can be maintained; when the long connection is maintained, the heartbeat period of the previous test and the heartbeat period of the current test Perform a difference operation to determine whether the difference between the heartbeat period of the previous test and the heartbeat period of the current test is less than or equal to the second threshold. If the difference is less than or equal to the second threshold, the heartbeat period of the current test is selected as the second heartbeat period. If the difference is greater than the second threshold, the median value of the sequence of the heartbeat period of the test and the heartbeat period of the previous test is taken as the heartbeat period for the long connection test.
- the long connection When the long connection is not maintained, continue to take the heartbeat period of the test and the median of the series of the heartbeat period of the previous test which is less than the heartbeat period of the test and the boundary value is used as the heartbeat period for the long connection test;
- the long connection port can be maintained, the median value of the sequence of the heartbeat period of the previous test and the heartbeat period of the previous test which is greater than the heartbeat period of the test is taken as the heartbeat period for the long connection test; This is repeated until the absolute value of the difference between the median of the series and the boundary value is less than the third threshold.
- the absolute value of the difference between the median of the series and the boundary value is less than the third threshold ⁇ , select the boundary value less than the median in the series as the second heartbeat period.
- the terminal device successively reduces the length of the long connection test based on the first heartbeat period until the Kth time of the long connection can be maintained.
- the long connection port it is judged whether the difference between the heartbeat period of the K-1th test and the heartbeat period of the Kth test is less than or equal to the second threshold. If the difference is less than or equal to the second threshold, the heartbeat period of the Kth test is selected as the second heartbeat period. If the difference is greater than the second threshold, the median of the series of the heartbeat period of the Kth test and the heartbeat period of the K-1th test is taken as the heartbeat period of the K+1th test for long connection test.
- the long connection When the long connection is not maintained, continue to take the median of the KLT cycle of the K+1th test and the heartbeat cycle of the Kth test as the heartbeat cycle of the K+2 test for the long connection test.
- the median of the sequence of the heartbeat period of the K+1th test and the heartbeat period of the K-1th test is taken as the heartbeat period of the K+2 test.
- Connection test repeats until the absolute value of the difference between the median and the boundary value of the series is less than the third threshold; when the absolute value of the difference between the median and the boundary value of the series is less than the third threshold, the selected column is smaller than
- the median boundary value is used as the second heartbeat period.
- the second threshold can be set according to actual needs, for example, the second threshold can be set within a range of 0.5-1.5 minutes.
- the terminal device successively reduces the length of the ⁇ ⁇ on the basis of the first heartbeat period, and the ⁇ length of each reduction may be equal, for example, each time is reduced by 5 minutes; or may be unequal, such as successively decreasing, successively increasing, successively Decrease or increase to a specific value and remain unchanged, and so on.
- the first reduction is 10 minutes
- the second reduction is 8 minutes
- the third reduction is 5 minutes
- the fourth reduction is 3 minutes, ....
- the heartbeat period of the terminal device after reducing the length of each time is half of the heartbeat period of the previous test.
- the heartbeat period is first reduced to Tl/2, and the long connection test is performed using T1/2.
- the long connection is not maintained, continue to reduce the heartbeat cycle to T1/22 for long connection testing.
- the heartbeat cycle is reduced to Tl/2k ⁇ , a long connection can be maintained, where k is a positive integer.
- the second heartbeat period T2 of the required second network is between the heartbeat period Tl/2k of the current test and the heartbeat period Tl/2k-1 of the previous test, that is, Tl /2k ⁇ T2 ⁇ Tl/2k-l.
- the difference between the heartbeat period 2k-lTl of the previous test and the heartbeat period Tl/2k of the current test is compared, and the difference between the two is compared with the magnitude of the second threshold to determine whether the difference is less than or equal to the second threshold. , false If the second threshold is 1 minute, it is judged whether the difference of Tl/2k-l-Tl/2k is less than or equal to 1 minute.
- the median t1 is used as the boundary value, and the new median t2 is continued to the left side of the series (Tl/2k, Tl/2k-1), that is, The heartbeat period tl of this test and the heartbeat period Tl/2k of the previous test which is adjacent to and less than the heartbeat period of this test are the median value t2 of the sequence of the boundary value (Tl/2k, tl) as a long connection of the heartbeat period.
- the median t1 is used as the boundary value, and the new median t2 is continued to the right of the above series (Tl/2k, Tl/2k-l), that is, taken
- the heartbeat period tl of the secondary test and the heartbeat period Tl/2k-l of the previous test which is adjacent and greater than the heartbeat period of the test are the median value t2 of the sequence of the boundary value (tl, Tl/2k-l) as the heartbeat period Perform a long connection test.
- the foregoing steps are repeated as described above, and the median value is repeatedly taken until the absolute value of the difference between the median value of the current series and the boundary value is less than the third threshold.
- the terminal device may perform the long connection test to obtain the second heartbeat period in the following manner: The terminal device successively reduces the length of the long connection test based on the first heartbeat period until the long connection can be maintained. So far; when the long connection is maintained, the heartbeat period of this test is directly selected as the second heartbeat period to quickly acquire the second heartbeat period.
- step S14 after acquiring the second heartbeat period, the terminal device sends a heartbeat packet to the server in a second heartbeat period, and maintains a long connection with the server, so that the server can push the terminal device through the second network. information.
- the method for maintaining a long connection in the embodiment of the present invention when accessing a second network, such as a satellite mobile terminal communication network, using the first heartbeat period as a reference period, increasing or decreasing the length of the first heartbeat period Long connection test to obtain the heartbeat period suitable for the satellite mobile terminal communication network.
- a second network such as a satellite mobile terminal communication network
- the terminal device is always online, so that the server can push information to the terminal device through the satellite mobile terminal communication network; on the other hand, the terminal device can set the server to the server with a suitable heartbeat cycle.
- Send heartbeat packets no need to send heartbeat packets frequently, reducing the power consumption of long connections.
- a suitable heartbeat period with low connection power consumption and capable of maintaining a long connection is determined.
- an embodiment of a device for maintaining a long connection is provided.
- the device is applied to a terminal device, and the device includes a first test module 10, a second test module 20, a third test module 30, and a connection maintenance module. 40, where:
- the first test module 10 is configured to perform a long connection test in a first heartbeat period after accessing the second network.
- the first test module 10 After accessing the second network, the first test module 10 performs a long connection test with the first heartbeat period to determine whether the first heartbeat cycle can maintain a long connection. Specifically, the first test module 10 sends a heartbeat packet M to the server according to the first heartbeat period. After receiving the heartbeat packet M, the server pushes the label data packet N to the terminal device after the delay of the first heartbeat period.
- the first test module 10 determines that the tag data packet N can be received by the server, and if the tag data packet N can be received, the first heartbeat cycle can maintain the long connection between the terminal device and the server, and notify the second test module 20; If the tagged data packet N cannot be received, it indicates that the first heartbeat cycle cannot maintain the long connection between the terminal device and the server, and the third test module 30 is notified.
- the subsequent second test module 20 and the third test module 30 perform a long connection test and determine a first heartbeat cycle. Whether the long connection can be maintained is the same as the first test module 10.
- the second test module 20 is configured to: when the first heartbeat cycle can maintain the long connection port, increase the length of the first heartbeat cycle to perform a long connection test, and obtain a second heartbeat cycle capable of maintaining the long connection.
- the second test module 20 increases the length of the first heartbeat period.
- the connection test acquires a second heartbeat period that is larger than the first heartbeat period and capable of maintaining a long connection.
- the second testing module 20 includes a length increasing test unit 21 and a first selecting unit 22, wherein: the length increasing test unit 21 is used for the basis of the first heartbeat period.
- the long connection test is performed successively until the long connection is not maintained; the first selecting unit 22 is configured to directly select the heartbeat period of the previous test as the second heartbeat period when the long connection cannot be maintained. Thereby the second heartbeat cycle can be quickly obtained.
- the second test module 20 includes a length increase test unit 21, a first determination unit 23, a second selection unit 24, a first median test unit 25, and a third selection unit. 26, where:
- the length of the test unit 21 is used to increase the length of the long connection test on the basis of the first heartbeat period until the long connection cannot be maintained.
- the length of the test unit 21 increases the length of the ⁇ ⁇ on the basis of the first heartbeat period, and the length of each increase may be equal, for example, each time is increased by 5 minutes; or may be unequal. Such as successive reduction
- the first increase is 1
- the length increase test unit 21 multiplies the heartbeat period, that is, the heartbeat period after each increase of the length is twice the heartbeat period of the previous test.
- the first determining unit 23 is configured to: when the long connection port cannot be maintained, compare the heartbeat period of the previous test with the size of the first threshold, determine whether the heartbeat period of the previous test is greater than or equal to the first threshold, and determine The result is sent to the second selection unit 24 and the first median test unit 25.
- the first threshold may be set according to actual needs, for example, the first threshold may be set within a range of 25-35 minutes.
- the second selecting unit 24 is configured to directly select the first threshold as the second heartbeat period if the heartbeat period of the previous test is greater than or equal to the first threshold.
- the first median testing unit 25 is configured to: if the heartbeat period of the previous test is less than the first threshold, take the median of the sequence of the heartbeat period of the current test and the heartbeat period of the previous test as a boundary value. The heartbeat cycle is tested for long connections.
- the long connection When the long connection is not maintained, continue to take the heartbeat period of the test and the median of the series of the heartbeat period of the previous test which is less than the heartbeat period of the test and the boundary value is used as the heartbeat period for the long connection test;
- the long connection port can be maintained, the median value of the sequence of the heartbeat period of the previous test and the heartbeat period of the previous test which is greater than the heartbeat period of the test is taken as the heartbeat period for the long connection test; This is repeated until the absolute value of the difference between the median of the series and the boundary value is less than the third threshold.
- the absolute value of the difference between the median of the series and the boundary value is less than the third threshold, the test is stopped and the third selection unit 26 is notified.
- the first median test unit 25 approximates the second heartbeat cycle by taking the median value successively, so as to obtain a larger second heartbeat cycle as much as possible, and reduce the power consumption of the long connection.
- the third threshold can be set according to actual needs, for example, the third threshold can be set within a range of 0.5-1.5 minutes.
- the length increase test unit 21 successively increases the length of the test based on the first heartbeat cycle to perform the long connection test until the Kth time of the long connection cannot be maintained.
- the first judging unit 23 judges whether or not the heartbeat period of the K-1th test is greater than or equal to the first threshold. If the heartbeat period of the K-1th test is greater than or equal to the first threshold, the second selecting unit 24 selects the first threshold as the second heartbeat period. If the heartbeat period of the K-1th test is less than the first threshold, the first median test unit 25 takes the median of the series of the heartbeat period of the Kth test and the heartbeat period of the K-1th test.
- the long connection test is performed as the heartbeat period of the K+1th test; when the long connection is not maintained, the sequence of the heartbeat period of the K+1th test and the heartbeat period of the K-1th test are taken as the boundary value series
- the median is used as the long-connection test for the heartbeat period of the K+2th test; when the long connection is maintained, the number of the heartbeat period of the K+1th test and the heartbeat period of the Kth test are taken as the boundary value series.
- the median is tested as a long-join test for the heartbeat period of the K+2th test; this is repeated until the absolute value of the difference between the median of the series and the boundary value is less than the third threshold.
- the third selecting unit 26 is configured to: when the absolute value of the difference between the median and the boundary value of the sequence is less than the third threshold, select a boundary value smaller than the median in the sequence as the second heartbeat period.
- the third selecting unit 26 selects the sequence The boundary value smaller than the median is used as the second heartbeat period, so that the stability of the connection can be improved.
- the second test module 20 may also adopt other methods, for example: the second test module 20 first increases the first length on the basis of the first heartbeat period. Connect the test to determine if it can maintain a long connection. When the long connection is maintained, the heartbeat period of this test is directly used as the second heartbeat period. When the long connection is not maintained, the second length is gradually reduced on the basis of the heartbeat period of the test (the second length is less than the first length, and the second length of each reduction may be equal or unequal). Connect the test until the long connection can be maintained; when the long connection is maintained, the heartbeat period of this test is taken as the second heartbeat period.
- the third test module 30 is configured to: when the first heartbeat cycle cannot maintain the long connection port, reduce the length of the first heartbeat cycle to perform a long connection test, and obtain a second heartbeat cycle capable of maintaining the long connection.
- the third test module 30 reduces the length of the first heartbeat period. Connect the test to get a second heartbeat cycle that maintains a long connection.
- the third test module 30 includes a length reduction test unit 31 and a fourth selection unit 32, wherein: the length reduction test unit 31 is used for the basis of the first heartbeat period.
- the long connection test is performed successively to reduce the length of the length until the long connection can be maintained.
- the fourth selection unit 32 is configured to select the heartbeat period of the current test as the second heartbeat period when the long connection is maintained.
- the third test module 30 includes a length reduction test unit 31, a second determination unit 33, a fifth selection unit 34, a second median test unit 35, and a sixth selection unit. 36, where:
- the length reduction test unit 31 is configured to successively reduce the length of the long-term connection test on the basis of the first heartbeat period until the long connection can be maintained.
- the length reduction test unit 31 successively reduces the length of the ⁇ on the basis of the first heartbeat period, and the length of each reduction may be equal, such as 5 minutes each time; or may be unequal. Such as successive reduction, increasing sequentially, decreasing or increasing to a specific value, and then remaining unchanged, and so on.
- the first reduction is 10 minutes
- the second reduction is 8 minutes
- the third reduction is 5 minutes
- the fourth reduction is 3 minutes, ....
- the heartbeat period after the length reduction test unit 31 is reduced by one time is half of the heartbeat period of the previous test.
- the second determining unit 33 is configured to perform a difference operation between the heartbeat period of the previous test and the heartbeat period of the current test when the long connection is maintained, and determine the heartbeat period of the previous test and the heartbeat of the test. Whether the difference of the period is less than or equal to the second threshold, and the determination result is sent to the fifth selection unit 34 and the second median test unit 35.
- the second threshold may be set according to actual needs, for example, the second threshold may be set within a range of 0.5-1.5 minutes.
- the fifth selecting unit 34 is configured to select a heartbeat period of the current test as the second heartbeat period if the difference is less than or equal to the second threshold.
- the second median testing unit 35 is configured to: if the difference is greater than the second threshold, take the median of the sequence of the heartbeat period of the test and the heartbeat period of the previous test as the boundary value as the heartbeat period Connection test. When the long connection is not maintained, continue to take the heartbeat period of the test and the median of the series of the heartbeat period of the previous test which is less than the heartbeat period of the test and the boundary value is used as the heartbeat period for the long connection test; When the long connection port can be maintained, the median value of the sequence of the heartbeat period of the previous test and the heartbeat period of the previous test which is greater than the heartbeat period of the test is taken as the heartbeat period for the long connection test; This is repeated until the absolute value of the difference between the median of the series and the boundary value is less than the third threshold. When the absolute value of the difference between the median of the series and the boundary value is less than the third threshold ⁇ , the test is stopped, and the sixth selection unit 36 is notified.
- the second median test unit 35 approximates the second heartbeat cycle by taking the median value successively, so as to obtain a larger second heartbeat cycle as much as possible, and reduce the power consumption of the long connection.
- the third threshold can be set according to actual needs, for example, the third threshold can be set within a range of 0.5-1.5 minutes.
- the length reduction test unit 31 successively reduces the length of the long-term connection test based on the first heartbeat period until the Kth time of the long connection can be maintained.
- the second determining unit 33 determines whether the difference between the heartbeat period of the K-1th test and the heartbeat period of the Kth test is less than or equal to the second threshold. If the difference is less than or equal to the second threshold, the fifth selecting unit 34 selects the heartbeat period of the Kth test as the second heartbeat period. If the difference is greater than the second threshold, the second median test unit 35 takes the median of the series of the heartbeat period of the Kth test and the heartbeat period of the K-1th test as the boundary value.
- the long connection test is performed as the heartbeat period of the K+l test; when the long connection is not maintained, the median of the sequence of the heartbeat period of the K+1th test and the heartbeat period of the second test is taken as the boundary value Long connection test as the heartbeat period of the ⁇ +2 test; when the long connection ⁇ can be maintained, continue to take the heartbeat period of the K+1th test and the heartbeat period of the K-1 test as the boundary value series
- the median is tested as a long-join test for the heartbeat period of the ⁇ +2 test; it is repeated until the absolute value of the difference between the median of the series and the boundary value is less than the third threshold.
- the sixth selecting unit 36 is configured to: when the absolute value of the difference between the median and the boundary value of the sequence is less than the third threshold, select a boundary value smaller than the median in the sequence as the second heartbeat period.
- the six selection unit 36 selects a boundary value smaller than the median value in the sequence as the second heartbeat period.
- the third test module 30 can further reduce the length of the long connection test by using other methods, as long as the final second heartbeat period can maintain a long connection. This is no longer a list of details.
- Connection Maintenance Module 40 Used to maintain a long connection in a second heartbeat cycle.
- the connection maintaining module 40 After acquiring the second heartbeat period, the connection maintaining module 40 sends a heartbeat packet to the server in a second heartbeat period to maintain a long connection with the server, so that the server can push information to the terminal device through the second network.
- Embodiments of the present invention maintain a long-connected device.
- a second network such as a satellite mobile terminal communication network
- the first heartbeat period is used as a reference period, and the length of the first heartbeat period is increased or decreased.
- Long connection test to obtain the heartbeat period suitable for the satellite mobile terminal communication network.
- the long connection between the terminal device and the server is maintained, and the terminal device is always online, so that the server can push information to the terminal device through the satellite mobile terminal communication network; on the other hand, the terminal device can set the server to the server with a suitable heartbeat cycle.
- Send heartbeat packets no need to send heartbeat packets frequently, reducing the power consumption of long connections.
- a suitable heartbeat period with low connection power consumption and capable of maintaining a long connection is determined.
- the device for maintaining a long connection provided by the foregoing embodiment is the same as the method for maintaining a long connection, and the specific implementation process is described in the method embodiment, and the technical method in the method embodiment is The levy is applicable in the device embodiment, and details are not described herein again.
- the present invention also proposes a terminal device including a memory, a processor, and at least one application stored in the memory and configured to be executed by the processor, the application being configured to use
- a method of maintaining a long connection is performed.
- the method for maintaining a long connection includes the following steps: after accessing the second network, performing a long connection test with a first heartbeat period; when the first heartbeat period can maintain a long connection, increasing the length of the first heartbeat period Perform a long connection test to obtain a second heartbeat cycle capable of maintaining a long connection.
- the first heartbeat cycle cannot maintain a long connection, reduce the length of the first heartbeat cycle to perform a long connection test, and obtain a long connection that can maintain a long connection.
- the method for maintaining a heartbeat connection described in this embodiment is a method for maintaining a heartbeat connection according to the foregoing embodiment of the present invention, and details are not described herein again.
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Health & Medical Sciences (AREA)
- Cardiology (AREA)
- General Health & Medical Sciences (AREA)
- Mobile Radio Communication Systems (AREA)
- Electrotherapy Devices (AREA)
Abstract
本发明揭示了一种维持长连接的方法、装置和终端设备,所述方法包括以下步骤:接入第二网络后,以第一心跳周期进行长连接测试;当第一心跳周期能够维持长连接时,在第一心跳周期的基础上增加时长进行长连接测试,获取能够维持长连接的第二心跳周期;当第一心跳周期不能维持长连接时,在第一心跳周期的基础上减少时长进行长连接测试,获取能够维持长连接的第二心跳周期;以第二心跳周期维持长连接。从而,一方面维持了终端设备与服务器的长连接,确保终端设备一直在线,使得服务器能够通过第二网络实时向终端设备推送信息;另一方面使得终端设备能够以合适的心跳周期向服务器定时发送心跳包,无需频繁发送心跳包,降低了长连接的功耗。
Description
技术领域
[0001] 本发明涉及通信技术领域, 特别是涉及到一种维持心跳连接的方法、 装置和终 端设备。
背景技术
[0002] [0002]在移动通信网络中, 当一个 TCP/IP链路有一段吋间没有数据通信吋, 网 络侧就会释放连接, 造成链路中断。 为了保证服务器能够实吋向终端设备推送 信息, 终端设备需要以一定的心跳周期定吋向服务器发送心跳包来维持长连接
[0003] 随着卫星移动通信技术的迅速发展, 越来越多的终端设备支持卫星移动通信。
卫星移动通信网络也支持 TCP/IP链路接入互联网的功能, 因此终端设备可以通 过卫星移动通信网络进行联网通信。 但现有的卫星移动通信网络并没有确定的 心跳周期, 如果终端设备发送心跳包的周期太大, 则无法维持长连接, 如果频 繁发送心跳包, 又会增加功耗。 因此, 如何为没有确定的心跳周期的通信网络 确定一个连接功耗低且能够维持长连接的合适心跳周期, 是当前亟需解决的技 术问题。
技术问题
[0004] 本发明的主要目的为提供一种维持长连接的方法, 旨在为没有确定的心跳周期 的通信网络确定一个连接功耗低且能够维持长连接的合适心跳周期。
问题的解决方案
技术解决方案
[0005] [0004]为达以上目的, 本发明实施例提出一种维持长连接的方法, 所述方法包 括以下步骤:
[0006] 接入第二网络后, 以第一心跳周期进行长连接测试;
[0007] 当所述第一心跳周期能够维持长连接吋, 在所述第一心跳周期的基础上增加吋 长进行长连接测试, 获取能够维持长连接的第二心跳周期;
[0008] 当所述第一心跳周期不能维持长连接吋, 在所述第一心跳周期的基础上减少吋 长进行长连接测试, 获取能够维持长连接的第二心跳周期;
[0009] 以所述第二心跳周期维持长连接。
[0010] 本发明实施例同吋提出一种维持长连接的装置, 所述装置包括:
[0011] 第一测试模块, 用于在接入第二网络后, 以第一心跳周期进行长连接测试; [0012] 第二测试模块, 用于当所述第一心跳周期能够维持长连接吋, 在所述第一心跳 周期的基础上增加吋长进行长连接测试, 获取能够维持长连接的第二心跳周期
[0013] 第三测试模块, 用于当所述第一心跳周期不能维持长连接吋, 在所述第一心跳 周期的基础上减少吋长进行长连接测试, 获取能够维持长连接的第二心跳周期
[0014] 连接维持模块, 用于以所述第二心跳周期维持长连接。
[0015] 本发明实施例还提出一种终端设备, 所述终端设备包括存储器、 处理器和至少 一个被存储在所述存储器中并被配置为由所述处理器执行的应用程序, 其特征 在于, 所述应用程序被配置为用于执行前述维持长连接的方法。
发明的有益效果
有益效果
[0016] 本发明实施例所提供的一种维持长连接的方法, 当接入没有确定的心跳周期的 第二网络吋, 以第一心跳周期为参考周期, 在第一心跳周期的基础上增加或减 少吋长进行长连接测试, 获取适合第二网络的心跳周期。 一方面维持了终端设 备与服务器的长连接, 确保终端设备一直在线, 使得服务器能够通过第二网络 实吋向终端设备推送信息; 另一方面使得终端设备能够以合适的心跳周期向服 务器定吋发送心跳包, 无需频繁发送心跳包, 降低了长连接的功耗。 从而为没 有确定的心跳周期的通信网络确定了一个连接功耗低且能够维持长连接的合适 心跳周期。
对附图的简要说明
附图说明
[0017] [0006]图 1是本发明维持长连接的方法一实施例的流程图;
[0018] 图 2是本发明维持长连接的装置一实施例的模块示意图;
[0019] 图 3是图 2中的第二测试模块的模块示意图;
[0020] 图 4是图 2中的第二测试模块的另一模块示意图;
[0021] 图 5是图 2中的第三测试模块的模块示意图;
[0022] 图 6是图 2中的第三测试模块的模块示意图。
[0023] 本发明目的的实现、 功能特点及优点将结合实施例, 参照附图做进一步说明。
实施该发明的最佳实施例
本发明的最佳实施方式
[0024] [0007]应当理解, 此处所描述的具体实施例仅仅用以解释本发明, 并不用于限 定本发明。
[0025] 下面详细描述本发明的实施例, 所述实施例的示例在附图中示出, 其中自始至 终相同或类似的标号表示相同或类似的元件或具有相同或类似功能的元件。 下 面通过参考附图描述的实施例是示例性的, 仅用于解释本发明, 而不能解释为 对本发明的限制。
[0026] 参照图 1, 提出本发明维持长连接的方法一实施例, 所述方法包括以下步骤:
[0027] Sl l、 接入第二网络后, 以第一心跳周期进行长连接测试。
[0028] S12、 当第一心跳周期能够维持长连接吋, 在第一心跳周期的基础上增加吋长 进行长连接测试, 获取能够维持长连接的第二心跳周期。
[0029] S13、 当第一心跳周期不能维持长连接吋, 在第一心跳周期的基础上减少吋长 进行长连接测试, 获取能够维持长连接的第二心跳周期。
[0030] S14、 以第二心跳周期维持长连接。
[0031] 本发明实施例所述的心跳周期, 是指终端设备定吋向服务器发送心跳包 (空闲 数据包) 的周期。
[0032] 本发明实施例中, 第一心跳周期为参考心跳周期, 可以是终端设备随机确定的 心跳周期, 也可以是已知的第一网络的心跳周期, 即终端设备接入第一网络后 能够与服务器维持长连接的心跳周期。
[0033] 本发明实施例中, 第二网络是待确定合适的心跳周期的网络, 本发明实施例可 以以已知的第一网络的心跳周期为参考, 对第二网络进行长连接测试获取第二
网络的合适心跳周期。 例如, 第一网络为公用陆地移动通信网络, 第二网络为 卫星移动通信网络, 以公用陆地移动通信网络的心跳周期为参考, 对卫星移动 通信网络进行长连接测试, 获取卫星移动通信网络的合适心跳周期。
[0034] 步骤 S11中, 当接入第二网络后, 终端设备则以第一心跳周期进行长连接测试 , 判断第一心跳周期是否能够维持长连接。 具体的, 终端设备以第一心跳周期 定吋向服务器发送心跳包 M, 服务器接收到心跳包 M后, 经过第一心跳周期的吋 延, 向终端设备推送标记数据包 N。 如果终端设备能够接收到标记数据包 N, 则 说明第一心跳周期能够维持终端设备与服务器的长连接; 如果终端设备不能接 收到标记数据包 N, 则说明第一心跳周期不能维持终端设备与服务器的长连接。
[0035] 本领域技术人员可以理解, 除了通过判断终端设备是否能接收到服务器推送的 标记数据包 N的方式来判断是否能够维持长连接外, 还可以采用现有技术中的其 它方式来判断二者是否能够维持长连接, 本发明对此不作限定。
[0036] 步骤 S12中, 当第一心跳周期能够维持长连接吋, 说明第二网络能够达到的最 大心跳周期要大于第一心跳周期, 因此终端设备在第一心跳周期的基础上增加 吋长进行长连接测试, 获取比第一心跳周期大且能够维持长连接的第二心跳周 期。
[0037] 本发明实施例中, 终端设备具体可以通过以下方式进行长连接测试获取第二心 跳周期:
[0038] 终端设备在第一心跳周期的基础上逐次增加吋长进行长连接测试, 直到不能维 持长连接为止。 当不能维持长连接吋, 比较前一次测试的心跳周期与第一阈值 的大小, 判断前一次测试的心跳周期是否大于或等于第一阈值。 如果前一次测 试的心跳周期大于或等于第一阈值, 则选取第一阈值作为第二心跳周期。 如果 前一次测试的心跳周期小于第一阈值, 则取以本次测试的心跳周期和前一次测 试的心跳周期为边界值的数列的中值作为心跳周期进行长连接测试。 当不能维 持长连接吋, 继续取以本次测试的心跳周期和相邻且小于本次测试的心跳周期 的往次测试的心跳周期为边界值的数列的中值作为心跳周期进行长连接测试; 当能够维持长连接吋, 继续取以本次测试的心跳周期和相邻且大于本次测试的 心跳周期的往次测试的心跳周期为边界值的数列的中值作为心跳周期进行长连
接测试; 如此反复, 直到数列的中值与边界值的差值的绝对值小于第三阈值为 止。 当数列的中值与边界值的差值的绝对值小于第三阈值吋, 选取数列中小于 中值的边界值作为第二心跳周期。
[0039] 例如: 终端设备在第一心跳周期的基础上逐次增加吋长进行长连接测试, 直到 不能维持长连接的第 K次为止。 当不能维持长连接吋, 判断第 K-1次测试的心跳 周期是否大于或等于第一阈值。 如果第 K-1次测试的心跳周期大于或等于第一阈 值, 则选取第一阈值作为第二心跳周期。 如果第 K-1次测试的心跳周期小于第一 阈值, 则取以第 K次测试的心跳周期和第 K-1次测试的心跳周期为边界值的数列 的中值作为第 K+1次测试的心跳周期进行长连接测试; 当不能维持长连接吋, 继 续取以第 K+1次测试的心跳周期和第 K-1次测试的心跳周期为边界值的数列的中 值作为第 K+2次测试的心跳周期进行长连接测试; 当能够维持长连接吋, 继续取 以第 K+1次测试的心跳周期和第 K次测试的心跳周期为边界值的数列的中值作为 第 K+2次测试的心跳周期进行长连接测试; 如此反复, 直到数列的中值与边界值 的差值的绝对值小于第三阈值为止; 当数列的中值与边界值的差值的绝对值小 于第三阈值吋, 选取数列中小于中值的边界值作为第二心跳周期。 第一阈值和 第三阈值可以根据实际需要设定, 如可以将第一阈值设定在 25-35分钟的范围内 , 将第三阈值设定在 0.5-1.5分钟的范围内。
[0040] 终端设备在第一心跳周期的基础上逐次增加吋长吋, 每次增加的吋长可以相等 , 如每次增加 5分钟; 也可以不相等, 如逐次减小, 逐次增大, 逐次减小或增大 到特定值后保持不变, 等等。 例如, 第一次增加 10分钟, 第二次增加 8分钟, 第 三次增加 5分钟, 第四次增加 3分钟, ......。
[0041] 作为优选, 本发明实施例中, 终端设备成倍增加心跳周期, 即每次增加吋长后 的心跳周期是前一次测试的心跳周期的两倍。
[0042] 举例而言:
[0043] 假设第一心跳周期为 Tl, 首先增加心跳周期至 2Τ1, 利用 2T1进行长连接测试 。 当能够维持长连接吋, 继续增加心跳周期至 22T1进行长连接测试。 直到心跳 周期增加到 2kTl吋, 不能维持长连接为止, 其中 k为正整数。
[0044] 当不能维持长连接吋, 说明需要的第二网络的第二心跳周期 T2介于本次测试的
心跳周期 2kTl和前一次测试的心跳周期 2k-lTl之间, 即21^-11 < 12< 21^1。 此 吋比较前一次测试的心跳周期 2k-lTl与第一阈值的大小, 假设第一阈值为 30分钟 , 则判断前一次测试的心跳周期 2k-lTl是否大于或等于 30分钟。 当 2k-lTl≥30分 钟吋, 考虑到无线网络的不确定性和终端设备的位置移动等因素, 第二心跳周 期不宜过大, 因此直接将第一阈值作为第二心跳周期, 即确定第二心跳周期 T2= 30分钟。
[0045] 当 2k-lTl < 30分钟吋, 则采取二分法逼近第二心跳周期, 以尽量获取较大的第 二心跳周期, 降低长连接的功耗, 具体为:
[0046] 取以本次测试的心跳周期 2kTl和前一次测试的心跳周期 2k-lTl为边界值的数列
(2k-lTl, 2kTl) 的中值 tl作为心跳周期进行长连接测试。
[0047] 当不能维持长连接吋, 则以中值 tl为边界值, 继续向上述数列 (2k-lTl, 2kTl ) 的左侧取新的中值 t2, 也就是说, 取以本次测试的心跳周期 tl和相邻且小于本 次测试的心跳周期的往次测试的心跳周期 2k-lTl为边界值的数列 (2k-lTl, tl) 的中值 t2作为心跳周期进行长连接测试; 当能够维持长连接吋, 则以中值 tl为边 界值, 继续向上述数列 (2k-lTl, 2kTl) 的右侧取新的中值 t2, 也就是说, 取以 本次测试的心跳周期 tl和相邻且大于本次测试的心跳周期的往次测试的心跳周期 2kTl为边界值的数列 (tl, 2kTl) 的中值 t2作为心跳周期进行长连接测试。 如此 重复前述步骤, 反复取中值, 直到当前的数列的中值与边界值的差值的绝对值 小于第三阈值为止。
[0048] 考虑到卫星移动通信网络传输吋延以及服务器和终端设备的处理吋延, 当数列 的中值与边界值的差值的绝对值小于第三阈值吋, 则选取数列中小于中值的边 界值作为第二心跳周期, 从而可以提高连接的稳定性。 例如, 取数列 (t5, t4) 的中值 t6, 判断 t6-t5或 t4-t5是否大于或等于 1分钟 (第三阈值) , 若是, 则停止 测试, 并选取 t5为第二心跳周期, 即确定 T2=t5。
[0049] 在其它实施例中, 终端设备也可以通过以下方式进行长连接测试获取第二心跳 周期: 终端设备在第一心跳周期的基础上逐次增加吋长进行长连接测试, 直到 不能维持长连接为止; 当不能维持长连接吋, 考虑到前一次测试的心跳周期在 测试吋能够维持长连接, 则直接选取前一次测试的心跳周期作为第二心跳周期
, 以快速获取第二心跳周期。
[0050] 除了逐次增加吋长进行长连接测试外, 终端设备还可以采用其它方式, 例如: 终端设备先在第一心跳周期的基础上一次性增加第一吋长进行长连接测试, 判 断是否能够维持长连接。 当能够维持长连接吋, 直接将本次测试的心跳周期作 为第二心跳周期。 当不能维持长连接吋, 在本次测试的心跳周期的基础上逐次 减少第二吋长 (第二吋长小于第一吋长, 每次减少的第二吋长可以相等或不等 ) 进行长连接测试, 直到能够维持长连接为止; 当能够维持长连接吋, 将本次 测试的心跳周期作为第二心跳周期。
[0051] 本领域技术人员可以理解, 除此之外, 还可以采用其它方式增加吋长进行长连 接测试, 只要最终的第二心跳周期大于第一心跳周期, 且能够维持长连接即可 , 本发明对此不再一一列举赘述。
[0052] 步骤 S13中, 当第一心跳周期不能维持长连接吋, 说明第二网络能够达到的最 大心跳周期要小于第一心跳周期, 因此终端设备在第一心跳周期的基础上减少 吋长进行长连接测试, 获取能够维持长连接的第二心跳周期。
[0053] 本发明实施例中, 终端设备具体可以通过以下方式进行长连接测试获取第二心 跳周期:
[0054] 终端设备在第一心跳周期的基础上逐次减少吋长进行长连接测试, 直到能够维 持长连接为止; 当能够维持长连接吋, 对前一次测试的心跳周期与本次测试的 心跳周期进行差值运算, 判断前一次测试的心跳周期与本次测试的心跳周期的 差值是否小于或等于第二阈值。 如果差值小于或等于第二阈值, 则选取本次测 试的心跳周期作为第二心跳周期。 如果差值大于第二阈值, 则取以本次测试的 心跳周期和前一次测试的心跳周期为边界值的数列的中值作为心跳周期进行长 连接测试。 当不能维持长连接吋, 继续取以本次测试的心跳周期和相邻且小于 本次测试的心跳周期的往次测试的心跳周期为边界值的数列的中值作为心跳周 期进行长连接测试; 当能够维持长连接吋, 继续取以本次测试的心跳周期和相 邻且大于本次测试的心跳周期的往次测试的心跳周期为边界值的数列的中值作 为心跳周期进行长连接测试; 如此反复, 直到数列的中值与边界值的差值的绝 对值小于第三阈值为止。 当数列的中值与边界值的差值的绝对值小于第三阈值
吋, 选取数列中小于中值的边界值作为第二心跳周期。
[0055] 例如: 终端设备在第一心跳周期的基础上逐次减少吋长进行长连接测试, 直到 能够维持长连接的第 K次为止。 当能够维持长连接吋, 判断第 K-1次测试的心跳 周期与第 K次测试的心跳周期的差值是否小于或等于第二阈值。 如果差值小于或 等于第二阈值, 则选取第 K次测试的心跳周期作为第二心跳周期。 如果差值大于 第二阈值, 则取以第 K次测试的心跳周期和第 K-1次测试的心跳周期为边界值的 数列的中值作为第 K+1次测试的心跳周期进行长连接测试; 当不能维持长连接吋 , 继续取以第 K+1次测试的心跳周期和第 K次测试的心跳周期为边界值的数列的 中值作为第 K+2次测试的心跳周期进行长连接测试; 当能够维持长连接吋, 继续 取以第 K+1次测试的心跳周期和第 K-1次测试的心跳周期为边界值的数列的中值 作为第 K+2次测试的心跳周期进行长连接测试; 如此反复, 直到数列的中值与边 界值的差值的绝对值小于第三阈值为止; 当数列的中值与边界值的差值的绝对 值小于第三阈值吋, 选取数列中小于中值的边界值作为第二心跳周期。 第二阈 值可以根据实际需要设定, 如可以将第二阈值设定在 0.5-1.5分钟的范围内。
[0056] 终端设备在第一心跳周期的基础上逐次减少吋长吋, 每次减少的吋长可以相等 , 如每次减少 5分钟; 也可以不相等, 如逐次减小, 逐次增大, 逐次减小或增大 到特定值后保持不变, 等等。 例如, 第一次减少 10分钟, 第二次减少 8分钟, 第 三次减少 5分钟, 第四次减少 3分钟, ......。
[0057] 作为优选, 本发明实施例中, 终端设备每次减少吋长后的心跳周期是前一次测 试的心跳周期的一半。
[0058] 举例而言:
[0059] 假设第一心跳周期为 Tl, 首先减少心跳周期至 Tl/2, 利用 T1/2进行长连接测试 。 当不能维持长连接吋, 继续减少心跳周期至 T1/22进行长连接测试。 直到心跳 周期减少到 Tl/2k吋, 能够维持长连接为止, 其中 k为正整数。
[0060] 当能够维持长连接吋, 说明需要的第二网络的第二心跳周期 T2介于本次测试的 心跳周期 Tl/2k和前一次测试的心跳周期 Tl/2k-l之间, 即 Tl/2k< T2< Tl/2k-l。 此吋对前一次测试的心跳周期 2k-lTl与本次测试的心跳周期 Tl/2k进行差值运算 , 比较二者的差值与第二阈值的大小, 判断差值是否小于或等于第二阈值, 假
设第二阈值为 1分钟, 则判断 Tl/2k-l-Tl/2k的差值是否小于或等于 1分钟。 当 T1/2 k-l-Tl/2k≤l分钟吋, 考虑到卫星移动通信网络传输吋延以及服务器和终端设备 的处理吋延, 则直接选取本次测试的心跳周期 Tl/2k作为第二心跳周期, 即确定 第二心跳周期 T2= Tl/2k。
[0061] 当 Tl/2k-l-Tl/2k>l分钟吋, 则采取二分法逼近第二心跳周期, 以尽量获取较大 的第二心跳周期, 降低长连接的功耗, 具体为:
[0062] 取以本次测试的心跳周期 Tl/2k和前一次测试的心跳周期 Tl/2k-l为边界值的数 歹 ij (Tl/2k, Tl/2k-l) 的中值 tl作为心跳周期进行长连接测试。
[0063] 当不能维持长连接吋, 则以中值 tl为边界值, 继续向上述数列 (Tl/2k, Tl/2k- 1) 的左侧取新的中值 t2, 也就是说, 取以本次测试的心跳周期 tl和相邻且小于 本次测试的心跳周期的往次测试的心跳周期 Tl/2k为边界值的数列 (Tl/2k, tl) 的中值 t2作为心跳周期进行长连接测试; 当能够维持长连接吋, 则以中值 tl为边 界值, 继续向上述数列 (Tl/2k, Tl/2k-l) 的右侧取新的中值 t2, 也就是说, 取 以本次测试的心跳周期 tl和相邻且大于本次测试的心跳周期的往次测试的心跳周 期 Tl/2k-l为边界值的数列 (tl, Tl/2k-l) 的中值 t2作为心跳周期进行长连接测 试。 如此重复前述步骤, 反复取中值, 直到当前的数列的中值与边界值的差值 的绝对值小于第三阈值为止。
[0064] 考虑到卫星移动通信网络传输吋延以及服务器和终端设备的处理吋延, 为了保 证连接的稳定性, 当数列的中值与边界值的差值的绝对值小于第三阈值吋, 则 选取数列中小于中值的边界值作为第二心跳周期。 例如, 取数列 (t5, t4) 的中 值 t6, 判断 t6-t5或 t4-t5是否大于或等于 1分钟 (第三阈值) , 若是, 则停止测试 , 并选取 t5为第二心跳周期, 即确定 T2=t5。
[0065] 在其它实施例中, 终端设备也可以通过以下方式进行长连接测试获取第二心跳 周期: 终端设备在第一心跳周期的基础上逐次减少吋长进行长连接测试, 直到 能够维持长连接为止; 当能够维持长连接吋, 直接选取本次测试的心跳周期作 为第二心跳周期, 以快速获取第二心跳周期。
[0066] 本领域技术人员可以理解, 除此之外, 还可以采用其它方式减少吋长进行长连 接测试, 只要最终的第二心跳周期能够维持长连接即可, 本发明对此不再一一
列举赘述。
[0067] 步骤 S14中, 当获取第二心跳周期后, 终端设备则以第二心跳周期定吋向服务 器发送心跳包, 维持与服务器长连接, 从而服务器可以通过第二网络实吋向终 端设备推送信息。
[0068] 本发明实施例维持长连接的方法, 当接入第二网络如卫星移动终端通信网络吋 , 以第一心跳周期为参考周期, 在第一心跳周期的基础上增加或减少吋长进行 长连接测试, 获取适合卫星移动终端通信网络的心跳周期。 一方面维持了终端 设备与服务器的长连接, 确保终端设备一直在线, 使得服务器能够通过卫星移 动终端通信网络实吋向终端设备推送信息; 另一方面使得终端设备能够以合适 的心跳周期向服务器定吋发送心跳包, 无需频繁发送心跳包, 降低了长连接的 功耗。 从而为没有确定的心跳周期的通信网络确定了一个连接功耗低且能够维 持长连接的合适心跳周期。
[0069] 参照图 2, 提出本发明维持长连接的装置一实施例, 该装置应用于终端设备, 该装置包括第一测试模块 10、 第二测试模块 20、 第三测试模块 30和连接维持模 块 40, 其中:
[0070] 第一测试模块 10: 用于在接入第二网络后, 以第一心跳周期进行长连接测试。
[0071] 当接入第二网络后, 第一测试模块 10则以第一心跳周期进行长连接测试, 判断 第一心跳周期是否能够维持长连接。 具体的, 第一测试模块 10以第一心跳周期 定吋向服务器发送心跳包 M, 服务器接收到心跳包 M后, 经过第一心跳周期的吋 延, 向终端设备推送标记数据包 N。 第一测试模块 10判断判断能够接收到服务器 推送的标记数据包 N, 如果能够接收到标记数据包 N, 则说明第一心跳周期能够 维持终端设备与服务器的长连接, 通知第二测试模块 20; 如果不能接收到标记 数据包 N, 则说明第一心跳周期不能维持终端设备与服务器的长连接, 通知第三 测试模块 30。
[0072] 本领域技术人员可以理解, 除了通过判断终端设备是否能接收到服务器推送的 标记数据包 N的方式来判断是否能够维持长连接外, 还可以采用现有技术中的其 它方式来判断二者是否能够维持长连接, 本发明对此不作限定。
[0073] 后续第二测试模块 20和第三测试模块 30进行长连接测试以及判断第一心跳周期
是否能够维持长连接的方式与第一测试模块 10相同。
[0074] 第二测试模块 20: 用于当第一心跳周期能够维持长连接吋, 在第一心跳周期的 基础上增加吋长进行长连接测试, 获取能够维持长连接的第二心跳周期。
[0075] 当第一心跳周期能够维持长连接吋, 说明第二网络能够达到的最大心跳周期要 大于第一心跳周期, 因此第二测试模块 20在第一心跳周期的基础上增加吋长进 行长连接测试, 获取比第一心跳周期大且能够维持长连接的第二心跳周期。
[0076] 可选地, 如图 3所示, 第二测试模块 20包括吋长增加测试单元 21和第一选取单 元 22, 其中: 吋长增加测试单元 21, 用于在第一心跳周期的基础上逐次增加吋 长进行长连接测试, 直到不能维持长连接为止; 第一选取单元 22, 用于当不能 维持长连接吋, 直接选取前一次测试的心跳周期作为第二心跳周期。 从而可以 快速获取第二心跳周期。
[0077] 可选地, 如图 4所示, 第二测试模块 20包括吋长增加测试单元 21、 第一判断单 元 23、 第二选取单元 24、 第一中值测试单元 25和第三选取单元 26, 其中:
[0078] 吋长增加测试单元 21 : 用于在第一心跳周期的基础上逐次增加吋长进行长连接 测试, 直到不能维持长连接为止。
[0079] 本发明实施例中, 吋长增加测试单元 21在第一心跳周期的基础上逐次增加吋长 吋, 每次增加的吋长可以相等, 如每次增加 5分钟; 也可以不相等, 如逐次减小
, 逐次增大, 逐次减小或增大到特定值后保持不变, 等等。 例如, 第一次增加 1
0分钟, 第二次增加 8分钟, 第三次增加 5分钟, 第四次增加 3分钟, ......。
[0080] 作为优选, 本发明实施例中, 吋长增加测试单元 21成倍增加心跳周期, 即每次 增加吋长后的心跳周期是前一次测试的心跳周期的两倍。
[0081] 第一判断单元 23: 用于当不能维持长连接吋, 比较前一次测试的心跳周期与第 一阈值的大小, 判断前一次测试的心跳周期是否大于或等于第一阈值, 并将判 断结果发送给第二选取单元 24和第一中值测试单元 25。
[0082] 第一阈值可以根据实际需要设定, 如可以将第一阈值设定在 25-35分钟的范围 内。
[0083] 第二选取单元 24: 用于如果前一次测试的心跳周期大于或等于第一阈值, 则直 接选取第一阈值作为第二心跳周期。
[0084] 第一中值测试单元 25: 用于如果前一次测试的心跳周期小于第一阈值, 则取以 本次测试的心跳周期和前一次测试的心跳周期为边界值的数列的中值作为心跳 周期进行长连接测试。 当不能维持长连接吋, 继续取以本次测试的心跳周期和 相邻且小于本次测试的心跳周期的往次测试的心跳周期为边界值的数列的中值 作为心跳周期进行长连接测试; 当能够维持长连接吋, 继续取以本次测试的心 跳周期和相邻且大于本次测试的心跳周期的往次测试的心跳周期为边界值的数 列的中值作为心跳周期进行长连接测试; 如此反复, 直到数列的中值与边界值 的差值的绝对值小于第三阈值为止。 当数列的中值与边界值的差值的绝对值小 于第三阈值吋, 停止测试, 并通知第三选取单元 26。
[0085] 第一中值测试单元 25通过逐次取中值的方式逼近第二心跳周期, 以尽量获取较 大的第二心跳周期, 降低长连接的功耗。 第三阈值可以根据实际需要设定, 如 可以将第三阈值设定在 0.5- 1.5分钟的范围内。
[0086] 例如: 吋长增加测试单元 21在第一心跳周期的基础上逐次增加吋长进行长连接 测试, 直到不能维持长连接的第 K次为止。 当不能维持长连接吋, 第一判断单元 23判断第 K-1次测试的心跳周期是否大于或等于第一阈值。 如果第 K-1次测试的 心跳周期大于或等于第一阈值, 第二选取单元 24则选取第一阈值作为第二心跳 周期。 如果第 K-1次测试的心跳周期小于第一阈值, 第一中值测试单元 25则取以 第 K次测试的心跳周期和第 K-1次测试的心跳周期为边界值的数列的中值作为第 K+1次测试的心跳周期进行长连接测试; 当不能维持长连接吋, 继续取以第 K+1 次测试的心跳周期和第 K-1次测试的心跳周期为边界值的数列的中值作为第 K+2 次测试的心跳周期进行长连接测试; 当能够维持长连接吋, 继续取以第 K+1次测 试的心跳周期和第 K次测试的心跳周期为边界值的数列的中值作为第 K+2次测试 的心跳周期进行长连接测试; 如此反复, 直到数列的中值与边界值的差值的绝 对值小于第三阈值为止。
[0087] 第三选取单元 26: 用于当数列的中值与边界值的差值的绝对值小于第三阈值吋 , 选取数列中小于中值的边界值作为第二心跳周期。
[0088] 考虑到卫星移动通信网络传输吋延以及服务器和终端设备的处理吋延, 当数列 的中值与边界值的差值的绝对值小于第三阈值吋, 第三选取单元 26则选取数列
中小于中值的边界值作为第二心跳周期, 从而可以提高连接的稳定性。
[0089] 除了逐次增加吋长进行长连接测试外, 第二测试模块 20还可以采用其它方式, 例如: 第二测试模块 20先在第一心跳周期的基础上一次性增加第一吋长进行长 连接测试, 判断是否能够维持长连接。 当能够维持长连接吋, 直接将本次测试 的心跳周期作为第二心跳周期。 当不能维持长连接吋, 在本次测试的心跳周期 的基础上逐次减少第二吋长 (第二吋长小于第一吋长, 每次减少的第二吋长可 以相等或不等) 进行长连接测试, 直到能够维持长连接为止; 当能够维持长连 接吋, 将本次测试的心跳周期作为第二心跳周期。
[0090] 本领域技术人员可以理解, 除此之外, 还可以采用其它方式增加吋长进行长连 接测试, 只要最终的第二心跳周期大于第一心跳周期, 且能够维持长连接即可 , 本发明对此不再一一列举赘述。
[0091] 第三测试模块 30: 用于当第一心跳周期不能维持长连接吋, 在第一心跳周期的 基础上减少吋长进行长连接测试, 获取能够维持长连接的第二心跳周期。
[0092] 当第一心跳周期不能维持长连接吋, 说明第二网络能够达到的最大心跳周期要 小于第一心跳周期, 因此第三测试模块 30在第一心跳周期的基础上减少吋长进 行长连接测试, 获取能够维持长连接的第二心跳周期。
[0093] 可选地, 如图 5所示, 第三测试模块 30包括吋长减少测试单元 31和第四选取单 元 32, 其中: 吋长减少测试单元 31, 用于在第一心跳周期的基础上逐次减少吋 长进行长连接测试, 直到能够维持长连接为止; 第四选取单元 32, 用于当能够 维持长连接吋, 选取本次测试的心跳周期作为第二心跳周期。
[0094] 可选地, 如图 6所示, 第三测试模块 30包括吋长减少测试单元 31、 第二判断单 元 33、 第五选取单元 34、 第二中值测试单元 35和第六选取单元 36, 其中:
[0095] 吋长减少测试单元 31 : 用于在第一心跳周期的基础上逐次减少吋长进行长连接 测试, 直到能够维持长连接为止。
[0096] 本发明实施例中, 吋长减少测试单元 31在第一心跳周期的基础上逐次减少吋长 吋, 每次减少的吋长可以相等, 如每次减少 5分钟; 也可以不相等, 如逐次减小 , 逐次增大, 逐次减小或增大到特定值后保持不变, 等等。 例如, 第一次减少 1 0分钟, 第二次减少 8分钟, 第三次减少 5分钟, 第四次减少 3分钟, ......。
[0097] 作为优选, 本发明实施例中, 吋长减少测试单元 31每次减少吋长后的心跳周期 是前一次测试的心跳周期的一半。
[0098] 第二判断单元 33: 用于当能够维持长连接吋, 对前一次测试的心跳周期与本次 测试的心跳周期进行差值运算, 判断前一次测试的心跳周期与本次测试的心跳 周期的差值是否小于或等于第二阈值, 并将判断结果发送给第五选取单元 34和 第二中值测试单元 35。
[0099] 第二阈值可以根据实际需要设定, 如可以将第二阈值设定在 0.5-1.5分钟的范围 内。
[0100] 第五选取单元 34: 用于如果差值小于或等于第二阈值, 则选取本次测试的心跳 周期作为第二心跳周期。
[0101] 第二中值测试单元 35: 用于如果差值大于第二阈值, 则取以本次测试的心跳周 期和前一次测试的心跳周期为边界值的数列的中值作为心跳周期进行长连接测 试。 当不能维持长连接吋, 继续取以本次测试的心跳周期和相邻且小于本次测 试的心跳周期的往次测试的心跳周期为边界值的数列的中值作为心跳周期进行 长连接测试; 当能够维持长连接吋, 继续取以本次测试的心跳周期和相邻且大 于本次测试的心跳周期的往次测试的心跳周期为边界值的数列的中值作为心跳 周期进行长连接测试; 如此反复, 直到数列的中值与边界值的差值的绝对值小 于第三阈值为止。 当数列的中值与边界值的差值的绝对值小于第三阈值吋, 停 止测试, 并通知第六选取单元 36。
[0102] 第二中值测试单元 35通过逐次取中值的方式逼近第二心跳周期, 以尽量获取较 大的第二心跳周期, 降低长连接的功耗。 第三阈值可以根据实际需要设定, 如 可以将第三阈值设定在 0.5- 1.5分钟的范围内。
[0103] 例如: 吋长减少测试单元 31在第一心跳周期的基础上逐次减少吋长进行长连接 测试, 直到能够维持长连接的第 K次为止。 当能够维持长连接吋, 第二判断单元 33判断第 K-1次测试的心跳周期与第 K次测试的心跳周期的差值是否小于或等于 第二阈值。 如果差值小于或等于第二阈值, 第五选取单元 34则选取第 K次测试的 心跳周期作为第二心跳周期。 如果所述差值大于第二阈值, 第二中值测试单元 3 5则取以第 K次测试的心跳周期和第 K-1次测试的心跳周期为边界值的数列的中值
作为第 K+l次测试的心跳周期进行长连接测试; 当不能维持长连接吋, 继续取以 第 K+1次测试的心跳周期和第 Κ次测试的心跳周期为边界值的数列的中值作为第 Κ+2次测试的心跳周期进行长连接测试; 当能够维持长连接吋, 继续取以第 K+1 次测试的心跳周期和第 K-1次测试的心跳周期为边界值的数列的中值作为第 Κ+2 次测试的心跳周期进行长连接测试; 如此反复, 直到数列的中值与边界值的差 值的绝对值小于第三阈值为止。
[0104] 第六选取单元 36: 用于当数列的中值与边界值的差值的绝对值小于第三阈值吋 , 选取数列中小于中值的边界值作为第二心跳周期。
[0105] 考虑到卫星移动通信网络传输吋延以及服务器和终端设备的处理吋延, 为了保 证连接的稳定性, 当数列的中值与边界值的差值的绝对值小于第三阈值吋, 第 六选取单元 36则选取数列中小于中值的边界值作为第二心跳周期。
[0106] 本领域技术人员可以理解, 除此之外, 第三测试模块 30还可以采用其它方式减 少吋长进行长连接测试, 只要最终的第二心跳周期能够维持长连接即可, 本发 明对此不再一一列举赘述。
[0107] 连接维持模块 40: 用于以第二心跳周期维持长连接。
[0108] 当获取第二心跳周期后, 连接维持模块 40则以第二心跳周期定吋向服务器发送 心跳包, 维持与服务器长连接, 从而服务器可以通过第二网络实吋向终端设备 推送信息。
[0109] 本发明实施例维持长连接的装置, 当接入第二网络如卫星移动终端通信网络吋 , 以第一心跳周期为参考周期, 在第一心跳周期的基础上增加或减少吋长进行 长连接测试, 获取适合卫星移动终端通信网络的心跳周期。 一方面维持了终端 设备与服务器的长连接, 确保终端设备一直在线, 使得服务器能够通过卫星移 动终端通信网络实吋向终端设备推送信息; 另一方面使得终端设备能够以合适 的心跳周期向服务器定吋发送心跳包, 无需频繁发送心跳包, 降低了长连接的 功耗。 从而为没有确定的心跳周期的通信网络确定了一个连接功耗低且能够维 持长连接的合适心跳周期。
[0110] 需要说明的是: 上述实施例提供的维持长连接的装置与维持长连接的方法实施 例属于同一构思, 其具体实现过程详见方法实施例, 且方法实施例中的技术特
征在装置实施例中均对应适用, 这里不再赘述。
[0111] 本发明同吋提出一种终端设备, 所述终端设备包括存储器、 处理器和至少一个 被存储在存储器中并被配置为由处理器执行的应用程序, 所述应用程序被配置 为用于执行维持长连接的方法。 所述维持长连接的方法包括以下步骤: 接入第 二网络后, 以第一心跳周期进行长连接测试; 当第一心跳周期能够维持长连接 吋, 在第一心跳周期的基础上增加吋长进行长连接测试, 获取能够维持长连接 的第二心跳周期; 当第一心跳周期不能维持长连接吋, 在第一心跳周期的基础 上减少吋长进行长连接测试, 获取能够维持长连接的第二心跳周期; 以第二心 跳周期维持长连接。 本实施例中所描述的维持心跳连接的方法为本发明中上述 实施例所涉及的维持心跳连接的方法, 在此不再赘述。
[0112] 以上所述仅为本发明的优选实施例, 并非因此限制本发明的专利范围, 凡是利 用本发明说明书及附图内容所作的等效结构或等效流程变换, 或直接或间接运 用在其他相关的技术领域, 均同理包括在本发明的专利保护范围内。
Claims
[权利要求 1] 一种维持长连接的方法, 其特征在于, 包括以下步骤:
接入第二网络后, 以第一心跳周期进行长连接测试;
当所述第一心跳周期能够维持长连接吋, 在所述第一心跳周期的基础 上增加吋长进行长连接测试, 获取能够维持长连接的第二心跳周期; 当所述第一心跳周期不能维持长连接吋, 在所述第一心跳周期的基础 上减少吋长进行长连接测试, 获取能够维持长连接的第二心跳周期; 以所述第二心跳周期维持长连接。
[权利要求 2] 根据权利要求 1所述的维持长连接的方法, 其特征在于, 所述在所述 第一心跳周期的基础上增加吋长进行长连接测试, 获取能够维持长连 接的第二心跳周期的步骤包括:
在所述第一心跳周期的基础上逐次增加吋长进行长连接测试, 直到不 能维持长连接为止;
当不能维持长连接吋, 选取前一次测试的心跳周期作为第二心跳周期
[权利要求 3] 根据权利要求 1所述的维持长连接的方法, 其特征在于, 所述在所述 第一心跳周期的基础上增加吋长进行长连接测试, 获取能够维持长连 接的第二心跳周期的步骤包括:
在所述第一心跳周期的基础上逐次增加吋长进行长连接测试, 直到不 能维持长连接的第 K次为止;
当不能维持长连接吋, 判断第 K-1次测试的心跳周期是否大于或等于 第一阈值;
如果第 K-1次测试的心跳周期大于或等于第一阈值, 则选取所述第一 阈值作为第二心跳周期;
如果第 K-1次测试的心跳周期小于第一阈值, 则取以第 K次测试的心 跳周期和第 K-1次测试的心跳周期为边界值的数列的中值作为第 K+1 次测试的心跳周期进行长连接测试; 当不能维持长连接吋, 继续取以 第 K+1次测试的心跳周期和第 K-1次测试的心跳周期为边界值的数列
的中值作为第 K+2次测试的心跳周期进行长连接测试; 当能够维持长 连接吋, 继续取以第 K+1次测试的心跳周期和第 Κ次测试的心跳周期 为边界值的数列的中值作为第 Κ+2次测试的心跳周期进行长连接测试 ; 如此反复, 直到数列的中值与边界值的差值的绝对值小于第三阈值 为止;
当数列的中值与边界值的差值的绝对值小于第三阈值吋, 选取所述数 列中小于中值的边界值作为第二心跳周期。
[权利要求 4] 根据权利要求 3所述的维持长连接的方法, 其特征在于, 所述第一阈 值为 25-35分钟。
[权利要求 5] 根据权利要求 3所述的维持长连接的方法, 其特征在于, 所述第三阈 值为 0.5-1.5分钟。
[权利要求 6] 根据权利要求 2所述的维持长连接的方法, 其特征在于, 每次增加吋 长后的心跳周期是前一次测试的心跳周期的两倍。
[权利要求 7] 根据权利要求 1所述的维持长连接的方法, 其特征在于, 所述在所述 第一心跳周期的基础上减少吋长进行长连接测试, 获取能够维持长连 接的第二心跳周期的步骤包括:
在所述第一心跳周期的基础上逐次减少吋长进行长连接测试, 直到能 够维持长连接为止;
当能够维持长连接吋, 选取本次测试的心跳周期作为第二心跳周期。
[权利要求 8] 根据权利要求 1所述的维持长连接的方法, 其特征在于, 所述在所述 第一心跳周期的基础上减少吋长进行长连接测试, 获取能够维持长连 接的第二心跳周期的步骤包括:
在所述第一心跳周期的基础上逐次减少吋长进行长连接测试, 直到能 够维持长连接的第 Κ次为止;
当能够维持长连接吋, 判断第 K-1次测试的心跳周期与第 Κ次测试的 心跳周期的差值是否小于或等于第二阈值;
如果所述差值小于或等于第二阈值, 则选取第 Κ次测试的心跳周期作 为第二心跳周期;
如果所述差值大于第二阈值, 则取以第 K次测试的心跳周期和第 K-1 次测试的心跳周期为边界值的数列的中值作为第 K+1次测试的心跳周 期进行长连接测试; 当不能维持长连接吋, 继续取以第 K+1次测试的 心跳周期和第 K次测试的心跳周期为边界值的数列的中值作为第 K+2 次测试的心跳周期进行长连接测试; 当能够维持长连接吋, 继续取以 第 K+1次测试的心跳周期和第 K-1次测试的心跳周期为边界值的数列 的中值作为第 K+2次测试的心跳周期进行长连接测试; 如此反复, 直 到数列的中值与边界值的差值的绝对值小于第三阈值为止; 当数列的中值与边界值的差值的绝对值小于第三阈值吋, 选取所述数 列中小于中值的边界值作为第二心跳周期。
[权利要求 9] 根据权利要求 8所述的维持长连接的方法, 其特征在于, 所述第二阈 值为 0.5-1.5分钟。
[权利要求 10] 根据权利要求 7所述的维持长连接的方法, 其特征在于, 每次减少吋 长后的心跳周期是前一次测试的心跳周期的一半。
[权利要求 11] 根据权利要求 1所述的维持长连接的方法, 其特征在于, 所述第一心 跳周期为第一网络的心跳周期。
[权利要求 12] 根据权利要求 11所述的维持长连接的方法, 其特征在于, 所述第一网 络为公用陆地移动通信网络, 所述第二网络为卫星移动通信网络。
[权利要求 13] —种维持长连接的装置, 其特征在于, 包括:
第一测试模块, 用于在接入第二网络后, 以第一心跳周期进行长连接 测试;
第二测试模块, 用于当所述第一心跳周期能够维持长连接吋, 在所述 第一心跳周期的基础上增加吋长进行长连接测试, 获取能够维持长连 接的第二心跳周期;
第三测试模块, 用于当所述第一心跳周期不能维持长连接吋, 在所述 第一心跳周期的基础上减少吋长进行长连接测试, 获取能够维持长连 接的第二心跳周期;
连接维持模块, 用于以所述第二心跳周期维持长连接。
[权利要求 14] 根据权利要求 13所述的维持长连接的装置, 其特征在于, 所述第二测 试模块包括:
吋长增加测试单元, 用于在所述第一心跳周期的基础上逐次增加吋长 进行长连接测试, 直到不能维持长连接为止;
第一选取单元, 用于当不能维持长连接吋, 选取前一次测试的心跳周 期作为第二心跳周期。
[权利要求 15] 根据权利要求 13所述的维持长连接的装置, 其特征在于, 所述第二测 试模块包括:
吋长增加测试单元, 用于在所述第一心跳周期的基础上逐次增加吋长 进行长连接测试, 直到不能维持长连接的第 K次为止;
第一判断单元, 用于当不能维持长连接吋, 判断第 K-1次测试的心跳 周期是否大于或等于第一阈值;
第二选取单元, 用于如果第 K-1次测试的心跳周期大于或等于第一阈 值, 则选取所述第一阈值作为第二心跳周期;
第一中值测试单元, 用于如果第 K-1次测试的心跳周期小于第一阈值 , 则取以第 K次测试的心跳周期和第 K-1次测试的心跳周期为边界值 的数列的中值作为第 K+1次测试的心跳周期进行长连接测试; 当不能 维持长连接吋, 继续取以第 K+1次测试的心跳周期和第 K-1次测试的 心跳周期为边界值的数列的中值作为第 K+2次测试的心跳周期进行长 连接测试; 当能够维持长连接吋, 继续取以第 K+1次测试的心跳周期 和第 K次测试的心跳周期为边界值的数列的中值作为第 K+2次测试的 心跳周期进行长连接测试; 如此反复, 直到数列的中值与边界值的差 值的绝对值小于第三阈值为止;
第三选取单元, 用于当数列的中值与边界值的差值的绝对值小于第三 阈值吋, 选取所述数列中小于中值的边界值作为第二心跳周期。
[权利要求 16] 根据权利要求 15所述的维持长连接的装置, 其特征在于, 所述第一阈 值为 25-35分钟。
[权利要求 17] 根据权利要求 14所述的维持长连接的装置, 其特征在于, 所述吋长增
加测试单元每次增加吋长后的心跳周期是前一次测试的心跳周期的两 倍。
[权利要求 18] 根据权利要求 13所述的维持长连接的装置, 其特征在于, 所述第三测 试模块包括:
吋长减少测试单元, 用于在所述第一心跳周期的基础上逐次减少吋长 进行长连接测试, 直到能够维持长连接为止;
第四选取单元, 用于当能够维持长连接吋, 选取本次测试的心跳周期 作为第二心跳周期。
[权利要求 19] 根据权利要求 13所述的维持长连接的装置, 其特征在于, 所述第三测 试模块包括:
吋长减少测试单元, 用于在所述第一心跳周期的基础上逐次减少吋长 进行长连接测试, 直到能够维持长连接的第 K次为止;
第二判断单元, 用于当能够维持长连接吋, 判断第 K-1次测试的心跳 周期与第 K次测试的心跳周期的差值是否小于或等于第二阈值; 第五选取单元, 用于如果所述差值小于或等于第二阈值, 则选取第 K 次测试的心跳周期作为第二心跳周期;
第二中值测试单元, 用于如果所述差值大于第二阈值, 则取以第 K次 测试的心跳周期和第 K-1次测试的心跳周期为边界值的数列的中值作 为第 K+1次测试的心跳周期进行长连接测试; 当不能维持长连接吋, 继续取以第 K+1次测试的心跳周期和第 K次测试的心跳周期为边界值 的数列的中值作为第 K+2次测试的心跳周期进行长连接测试; 当能够 维持长连接吋, 继续取以第 K+1次测试的心跳周期和第 K-1次测试的 心跳周期为边界值的数列的中值作为第 K+2次测试的心跳周期进行长 连接测试; 如此反复, 直到数列的中值与边界值的差值的绝对值小于 第三阈值为止;
第六选取单元, 用于当数列的中值与边界值的差值的绝对值小于第三 阈值吋, 选取所述数列中小于中值的边界值作为第二心跳周期。
[权利要求 20] —种终端设备, 包括存储器、 处理器和至少一个被存储在所述存储器
中并被配置为由所述处理器执行的应用程序, 其特征在于, 所述应用 程序被配置为用于执行权利要求 1所述的维持长连接的方法。
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201710433399.6 | 2017-06-09 | ||
| CN201710433399.6A CN107135518B (zh) | 2017-06-09 | 2017-06-09 | 维持心跳连接的方法、装置和终端设备 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2018223592A1 true WO2018223592A1 (zh) | 2018-12-13 |
Family
ID=59734580
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2017/109430 Ceased WO2018223592A1 (zh) | 2017-06-09 | 2017-11-03 | 维持心跳连接的方法、装置和终端设备 |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN107135518B (zh) |
| WO (1) | WO2018223592A1 (zh) |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN110753086A (zh) * | 2019-09-12 | 2020-02-04 | 华为技术有限公司 | 应用的心跳唤醒方法及终端设备 |
Families Citing this family (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN107135518B (zh) * | 2017-06-09 | 2020-05-19 | 深圳市沃特沃德股份有限公司 | 维持心跳连接的方法、装置和终端设备 |
| CN109547293A (zh) * | 2018-12-20 | 2019-03-29 | 上海数果科技有限公司 | 心跳数据包发送方法 |
| WO2022109882A1 (zh) * | 2020-11-25 | 2022-06-02 | 深圳市沃特沃德股份有限公司 | 蜂窝物联网设备的数据包发送方法、装置和计算机设备 |
| CN113873017B (zh) * | 2021-09-06 | 2023-12-26 | 绿盟科技集团股份有限公司 | 一种心跳周期调整方法、装置、客户端以及服务器 |
| CN116939004A (zh) * | 2022-04-08 | 2023-10-24 | 广州汽车集团股份有限公司 | 一种长连接联网方法与系统、计算机存储介质 |
Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN103139303A (zh) * | 2013-02-07 | 2013-06-05 | 网易(杭州)网络有限公司 | 一种用于保持连接的心跳方法、装置及系统 |
| CN105916100A (zh) * | 2016-04-01 | 2016-08-31 | 华为技术有限公司 | 代理心跳包的方法、装置和通信系统 |
| CN106452973A (zh) * | 2016-11-04 | 2017-02-22 | 乐视控股(北京)有限公司 | 维持通信链路长连接的方法、装置及终端 |
| CN107135518A (zh) * | 2017-06-09 | 2017-09-05 | 深圳市沃特沃德股份有限公司 | 维持心跳连接的方法、装置和终端设备 |
| CN107197509A (zh) * | 2017-05-22 | 2017-09-22 | 深圳市沃特沃德股份有限公司 | 心跳连接方法和装置 |
Family Cites Families (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN104144159B (zh) * | 2014-06-26 | 2016-04-13 | 腾讯科技(深圳)有限公司 | 智能心跳保活方法及智能心跳保活系统 |
-
2017
- 2017-06-09 CN CN201710433399.6A patent/CN107135518B/zh active Active
- 2017-11-03 WO PCT/CN2017/109430 patent/WO2018223592A1/zh not_active Ceased
Patent Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN103139303A (zh) * | 2013-02-07 | 2013-06-05 | 网易(杭州)网络有限公司 | 一种用于保持连接的心跳方法、装置及系统 |
| CN105916100A (zh) * | 2016-04-01 | 2016-08-31 | 华为技术有限公司 | 代理心跳包的方法、装置和通信系统 |
| CN106452973A (zh) * | 2016-11-04 | 2017-02-22 | 乐视控股(北京)有限公司 | 维持通信链路长连接的方法、装置及终端 |
| CN107197509A (zh) * | 2017-05-22 | 2017-09-22 | 深圳市沃特沃德股份有限公司 | 心跳连接方法和装置 |
| CN107135518A (zh) * | 2017-06-09 | 2017-09-05 | 深圳市沃特沃德股份有限公司 | 维持心跳连接的方法、装置和终端设备 |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN110753086A (zh) * | 2019-09-12 | 2020-02-04 | 华为技术有限公司 | 应用的心跳唤醒方法及终端设备 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN107135518B (zh) | 2020-05-19 |
| CN107135518A (zh) | 2017-09-05 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN106031072B (zh) | 一种harq帧数据结构以及在采用盲检的系统中使用harq进行传输与接收的方法 | |
| US12189694B2 (en) | Automated web page accessing | |
| CN107135518B (zh) | 维持心跳连接的方法、装置和终端设备 | |
| WO2014205267A1 (en) | System and method for a csma-ca half window scheme | |
| WO2017202375A1 (zh) | 信息传输方法和装置 | |
| US20110225230A1 (en) | Method and apparatus for detecting active and orphan session-based connections | |
| US10230615B2 (en) | System and method for optimizing network performance based on profiling | |
| CN106792962B (zh) | 一种多播分簇建立方法和装置 | |
| JP6464931B2 (ja) | 通信装置、通信方法、通信プログラム及び通信システム | |
| CN112766486B (zh) | 神经网络结构的搜索方法、终端、服务器及可读存储介质 | |
| CN107431670B (zh) | 信道估计方法、装置和系统 | |
| CN114514717A (zh) | 传输方法、装置、终端、网络设备 | |
| EP3248342B1 (en) | Method and device for transmitting data by an electronic device | |
| WO2023125304A1 (zh) | 通信操作执行方法、装置、终端和存储介质 | |
| CN116437452A (zh) | 一种数据传输方法、装置、设备及通信设备 | |
| US12192288B2 (en) | Proactive indication of network session disruption | |
| CN116233907B (zh) | 基于模拟多并发sta的ap性能检测方法及检测系统 | |
| CN110704779A (zh) | 一种网站页面访问合规性检测方法、装置及设备 | |
| JP6327455B2 (ja) | 基地局装置、映像情報処理装置、3次元マップ生成システムおよび3次元マップ生成方法 | |
| US20180288629A1 (en) | System and method for determining an ideal configuration of a network | |
| WO2011144159A1 (zh) | 接入控制方法以及接入网设备和通信系统 | |
| WO2017106397A1 (en) | Distributed and scalable physical layer and medium access design for uplink multiuser multiple-input, multiple-output (mu-mimo) in wireless local area network (wlan) systems | |
| WO2018132966A1 (zh) | 探测老化时延的方法、装置、数据中心和系统 | |
| CN117858231A (zh) | 通信方法及装置 | |
| CN117796098A (zh) | 通信方法及电子设备、存储介质 |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 17912565 Country of ref document: EP Kind code of ref document: A1 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 17912565 Country of ref document: EP Kind code of ref document: A1 |