A message sending method and system based on backoff mechanism
Through the network switching method based on the backoff mechanism, the adaptability problem of long-term and short-term communication in different network environments is solved, high availability and priority processing of important information in weak network environments is achieved, and the efficiency and reliability of real-time communication is improved.
Patent Information
- Application Number
- CN202310247785.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-15
- Publication Date
- 2025-08-19
- Estimated Expiration
- 2043-03-15
AI Technical Summary
The existing technology has unstable long-connect communication in weak network environments, low information transmission efficiency, high communication delay in short-connect communication, and inability to effectively switch communication methods in different network environments, resulting in poor real-time communication effects.
Using a backoff mechanism method, switching long connections and short connection communication methods are performed according to the network situation, and connecting attempts are made through backoff control methods, including monitoring the communication status, enabling short connections and attempting to restore long connections, using the backoff mechanism to adjust the connection interval time, and combining the cache module and probe module to optimize information transmission.
It realizes low latency and high transmission in strong network environments and high availability communication in weak network environments, solves the problem of excessive network load or excessive intervals in the prior art, provides adaptability and compatibility, ensures the reliability of information transmission and priority processing of important information.
Smart Images

Figure CN116193525B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication technology, and in particular to a message sending method and system based on a backoff mechanism. Background Art
[0002] As mobile communication bandwidth increases, mobile network costs based on mobile communication technologies have become an indispensable part of people's daily lives. Existing technologies generally use either long or short connection technologies as communication methods. Short connections are often used for non-instantaneous communications, while long connections are used for real-time communications such as live broadcasts, instant messaging, and online games. However, in weak network environments, long connections struggle to meet usage requirements, and highly frequent polling connection access creates additional system and network burdens, hindering both real-time communication and the recovery of long connections. Summary of the Invention
[0003] The present invention addresses the problems existing in the prior art and provides a message sending method based on a backoff mechanism, including: a long connection communication mode and a short connection communication mode. According to the network communication situation, a backoff control method is used to switch between the long connection communication mode and the short connection communication mode.
[0004] The backoff control method includes:
[0005] S1. Monitor the communication status of the persistent connection. When the persistent connection is working, maintain the persistent connection and the normal heartbeat frequency. If the persistent connection fails or the number of missing heartbeats reaches a threshold, proceed to step S2.
[0006] S2. Enable short connection communication mode and start long connection communication link attempt based on backoff mechanism.
[0007] When the long connection communication link attempt fails, the short connection communication mode and the long connection communication link attempt based on the backoff method are maintained.
[0008] When the long connection communication link attempt is successful, the process proceeds to step S3.
[0009] S3. Close the short connection communication mode and the long connection communication link attempt based on the backoff mechanism, send the message in the long connection communication mode, and enter step S1.
[0010] Furthermore, the long connection communication method includes repackaging the long connection of the identifiable information source into a standard long connection.
[0011] Furthermore, the short connection communication method includes repackaging the short connection of the identifiable information source into a standard short connection.
[0012] Furthermore, all information to be sent is stored in a sending buffer device, wherein the information in the sending buffer device is sorted and buffered according to the information classification, wherein the information with the highest sorting order is sent first.
[0013] Furthermore, all received information is stored in a receiving buffer device, in which the information is sorted and buffered according to the information classification, with the information with the highest sorting being transmitted first.
[0014] Optionally, the persistent communication link attempt based on the backoff mechanism includes:
[0015] (1) Get the current backoff time interval Tx.
[0016] (2) According to the preset parameter short_length, Tx is divided into Kx time units TK, and according to the preset parameter long_length, Tx is divided into Mx time units TM.
[0017] (3) Perform a long connection communication link attempt. The number of failed attempts is recorded as m. The time interval between the mth attempt and the m+1th attempt is Tx+m = Tmin+(A+m)*TK+(B+m)*TM. Where: A is L1*Kx, B is L2*Mx, L1 and L2 are preset proportional coefficients, and A and B are positive integers rounded up.
[0018] (4) When the g-th attempt to establish a long-connection communication link succeeds, the current backoff interval Ty = Tmin + (A + g - 1) * TK + (B + g - 1) * TM. This Ty is the Tx in step (1) of the next round of backoff-based long-connection communication link attempts, and (A + g - 1) > 0 and (B + g - 1) > 0.
[0019] Optionally, the persistent communication link attempt based on the backoff mechanism includes:
[0020] (1) Get the current backoff time interval Tx, which is Tx = Tmin + Cx * TG, where Cx is a positive integer and TG is a preset time interval unit.
[0021] (2) Perform a long connection communication link attempt. The number of failed connection attempts is recorded as m. The time interval between the m-th attempt and the m+1-th attempt is Tx+m = Tmin+(Cx+m)*TG.
[0022] (3) When the g-th attempt to establish a long connection communication link succeeds, record the current backoff time interval Ty = Tmin + Cy * TG, and Cy = (Cx + g - 1). Ty is Tx in step (1) of the next round of attempts to establish a long connection communication link based on the backoff mechanism, and Cy is Cx in step (1) of the next round of attempts to establish a long connection communication link based on the backoff mechanism, and Cy>0.
[0023] Furthermore, Tx, Tx+m, and Ty are all greater than Tm and less than Tl, wherein: Tm = Tmin*H, Tl = Tmax*H. Tmin is a preset minimum interval time, Tmax is a preset maximum interval time, and H is a ratio value greater than 1.
[0024] Furthermore, when the calculated value of Tx, Tx+m, and Ty is ≤ Tm, the value is Tm. When the calculated value of Tx, Tx+m, and Ty is ≥ Tl, the value is Tl.
[0025] A second object of the present invention is to provide a message sending system based on a backoff mechanism, comprising: a long chain module, a short chain module, a cache module, a probe module, a backoff module and an information transmission module.
[0026] The long link module repackages the target-identifiable long connection into a standard long connection and performs long connection communication.
[0027] The short link module repackages the short connection of the identifiable target into a standard short connection and performs segment connection communication.
[0028] The buffer module is used to buffer information to be sent and received information, and to sort the information according to categories.
[0029] The probe module detects network communication conditions based on the network probes of the long chain module and the short chain module.
[0030] The backoff module is used to obtain feedback information from the probe module, execute the analysis steps of the backoff control method in the message sending method based on the backoff mechanism, and control the detection frequency of the probe module according to the analysis results.
[0031] The information transmission module sends the top-ranked information in the cache module through the long chain module or the short chain module according to the analysis result of the backoff module, and sends the top-ranked information received in the cache module to the application end corresponding to the information.
[0032] The present invention has at least one of the following beneficial effects:
[0033] 1. This invention switches between long and short connections, enabling real-time communication to proceed via long connections when network conditions are good, and via short connections in weaker networks. This allows for low-latency, high-speed transmission in strong networks. Furthermore, it allows for high-latency, low-resource utilization, and high-availability communication in weaker networks.
[0034] 2. The backoff control method of the present invention fully solves the problem of excessive network load caused by too fast detection frequency in the existing fixed algorithm backoff control method under high load conditions on the basis of ensuring the reliability of the detection frequency. It also solves the problem of too large detection frequency interval in the existing exponential backoff algorithm backoff control method, which cannot restore long connection communication as soon as possible.
[0035] 3. The present invention can provide an overall communication solution for multi-application systems, overcoming the platform differences and mutual compatibility issues between the business layer and the communication layer. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 The figure is a schematic diagram of the message sending and receiving process of the message sending system based on the backoff mechanism of the present invention. DETAILED DESCRIPTION
[0037] The technical solutions in the embodiments of the present invention will be described clearly and completely below with reference to the accompanying drawings in the embodiments of the present invention.
[0038] Example 1
[0039] A message sending method based on a backoff mechanism includes: a long connection communication mode and a short connection communication mode. In particular, according to the network communication situation, a backoff control method is used to switch between the long connection communication mode and the short connection communication mode.
[0040] Among them, the backoff control method includes:
[0041] S1. Monitor the communication status of the persistent communication mode. When the persistent communication mode is unblocked, maintain the persistent communication and the normal heartbeat frequency.
[0042] When the long connection communication mode fails or the number of lost heartbeats reaches a threshold, step S2 is entered.
[0043] S2. Enable short connection communication mode and start long connection communication link attempt based on backoff mechanism.
[0044] When the long connection communication link attempt fails, the short connection communication mode and the long connection communication link attempt based on the backoff method are maintained.
[0045] When the long connection communication link attempt is successful, the process proceeds to step S3.
[0046] S3. Close the short connection communication mode and the long connection communication link attempt based on the backoff mechanism, send the message in the long connection communication mode, and enter step S1.
[0047] Among them, long connection communication link attempts based on the backoff mechanism include:
[0048] (1) Get the current backoff time interval Tx.
[0049] (2) According to the preset parameter short_length, Tx is divided into Kx time units TK, and according to the preset parameter long_length, Tx is divided into Mx time units TM.
[0050] (3) Perform a long connection communication link attempt. The number of failed attempts is recorded as m. The time interval between the mth attempt and the m+1th attempt is Tx+m = Tmin+(A+m)*TK+(B+m)*TM. Where: A is L1*Kx, B is L2*Mx, L1 and L2 are preset proportional coefficients, and A and B are positive integers rounded up.
[0051] (4) When the g-th attempt to establish a long-connection communication link succeeds, the current backoff interval Ty = Tmin + (A + g - 1) * TK + (B + g - 1) * TM. This Ty is the Tx in step (1) of the next round of backoff-based long-connection communication link attempts, and (A + g - 1) > 0 and (B + g - 1) > 0.
[0052] Tx, Tx+m, and Ty are all greater than Tm and less than Tl, where: Tm = Tmin*H, Tl = Tmax*H. Tmin is the preset minimum interval time, Tmax is the preset maximum interval time, and H is a proportional value greater than 1.
[0053] When the calculated values of Tx, Tx+m, and Ty are ≤ Tm, the value is Tm. When the calculated values of Tx, Tx+m, and Ty are ≥ Tl, the value is Tl.
[0054] Example 2
[0055] A message sending method based on a backoff mechanism includes: a long connection communication mode and a short connection communication mode. In particular, according to the network communication situation, a backoff control method is used to switch between the long connection communication mode and the short connection communication mode.
[0056] Among them, the backoff control method includes:
[0057] S1. Monitor the communication status of the persistent connection. When the persistent connection is working, maintain the persistent connection and the normal heartbeat frequency. If the persistent connection fails or the number of missing heartbeats reaches a threshold, proceed to step S2.
[0058] S2. Enable short connection communication mode and start long connection communication link attempt based on backoff mechanism.
[0059] When the long connection communication link attempt fails, the short connection communication mode and the long connection communication link attempt based on the backoff method are maintained.
[0060] When the long connection communication link attempt is successful, the process proceeds to step S3.
[0061] S3. Close the short connection communication mode and the long connection communication link attempt based on the backoff mechanism, send the message in the long connection communication mode, and enter step S1.
[0062] Among them, long connection communication link attempts based on the backoff mechanism include:
[0063] (1) Get the current backoff time interval Tx, which is Tx = Tmin + Cx * TG, where Cx is a positive integer and TG is a preset time interval unit.
[0064] (2) Perform a long connection communication link attempt. The number of failed connection attempts is recorded as m. The time interval between the m-th attempt and the m+1-th attempt is Tx+m = Tmin+(Cx+m)*TG.
[0065] (3) When the g-th attempt to establish a long connection communication link succeeds, record the current backoff time interval Ty = Tmin + Cy * TG, and Cy = (Cx + g - 1). Ty is Tx in step (1) of the next round of attempts to establish a long connection communication link based on the backoff mechanism, and Cy is Cx in step (1) of the next round of attempts to establish a long connection communication link based on the backoff mechanism, and Cy>0.
[0066] Tx, Tx+m, and Ty are all greater than Tm and less than Tl, where: Tm = Tmin*H, Tl = Tmax*H. Tmin is the preset minimum interval time, Tmax is the preset maximum interval time, and H is a proportional value greater than 1.
[0067] When the calculated values of Tx, Tx+m, and Ty are ≤ Tm, the value is Tm. When the calculated values of Tx, Tx+m, and Ty are ≥ Tl, the value is Tl.
[0068] Currently, communication technologies are mainly divided into long-connection communication and short-connection communication. Long-connection communication has the advantages of low latency and high transmission speed, but it requires high network fluency. In weak network environments, long-connection communication can lead to unstable connections, low information transmission efficiency, and serious information loss. Short-connection communication has lower requirements for network fluency and can maintain effective communication in weak network environments with low resource consumption, but it also suffers from high communication latency.
[0069] The present invention can switch between long connection communication and short connection communication based on the network connection situation, so that real-time communication can be carried out in a long connection mode when the network conditions are good, and in a short connection mode in a weak network environment, so that real-time communication has a certain communication capability even under weak network conditions.
[0070] The present invention also includes a fallback mechanism, which attempts to restore a long connection while simultaneously communicating on a short connection, and controls long connection communication requests based on a backoff mechanism. The backoff control method provided by the present invention has either an adaptive interval duration unit (Example 1) or a fixed interval duration unit (Example 2). After each long connection communication request fails, the request interval is appropriately extended (by one duration unit), and after a successful request, the interval is appropriately shortened (by one duration unit). Through this method, the backoff mechanism provided by the present invention has a more reasonable speed control and fallback mechanism. This not only fully addresses the problem of existing fixed algorithm backoff control methods (fixed intervals) causing excessive network load due to excessively high detection frequencies under high load conditions, but also addresses the problem of existing exponential backoff algorithm backoff control methods (exponentially increasing duration intervals) causing excessive detection frequency intervals and preventing long connection communication from being restored quickly. Furthermore, a suitable interval fallback method is provided to prevent the infinite accumulation of request intervals.
[0071] Example 3
[0072] Based on the message sending method based on the backoff mechanism of embodiment 1 or 2, the long connection communication mode includes repackaging the long connection of the identifiable information source into a standard long connection.
[0073] The short connection communication method includes repackaging the short connection of the identifiable information source into a standard short connection.
[0074] This method can standardize the processing of requests from multiple platforms or application software, programs, and web pages, solve the differences and compatibility issues between different business requests, and facilitate the convenience and practicality of the business layer.
[0075] Example 4
[0076] Based on the message sending method based on the backoff mechanism of embodiment 1 or 2, the information to be sent is stored in the sending buffer device. The information in the sending buffer device is sorted and buffered according to the information classification, wherein the information with the highest sorting is sent first.
[0077] The received information is stored in a receiving buffer device, which is sorted and buffered according to the information classification, with the information with the highest sorting priority being transmitted.
[0078] This method allows you to prioritize incoming and outgoing messages based on their importance, prioritizing important messages when network traffic is poor. It also allows you to cache some information after an application, program, or webpage crashes due to network problems, allowing you to retrieve the information from the crash period when the application, program, or webpage recovers.
[0079] Example 5
[0080] A message sending system based on backoff mechanism, such as Figure 1 As shown, it includes: a long chain module, a short chain module, a cache module, a probe module, a backoff module and an information transmission module.
[0081] The long chain module repackages the target-identifiable long connection into a standard long connection and performs long connection communication, specifically the WebSocket communication module.
[0082] The short link module repackages the target-identifiable short connection into a standard short connection and performs segment connection communication, specifically the Http communication module.
[0083] The cache module is used to cache information to be sent and received, and sort them according to their categories. The categories of information can be: importance classification, source classification, etc.
[0084] The probe module detects network communication conditions based on the network probes of the long chain module and the short chain module.
[0085] The backoff module is used to perform the following analysis and control:
[0086] S1. Obtain the communication status of the probe module monitoring the long link module. When the long link communication mode is unobstructed, maintain the long link communication of the long link module and the regular heartbeat frequency of the probe module. When the long link communication mode fails or the heartbeat loss reaches the threshold, proceed to step S2.
[0087] S2. Enable the short link module and start a long connection communication link attempt based on the backoff mechanism.
[0088] When the long connection communication link attempt fails, the short connection communication mode is maintained and the probe module is controlled to make a long connection communication link attempt based on the backoff mechanism.
[0089] When the long connection communication link attempt is successful, the process proceeds to step S3.
[0090] S3. Close the short-chain module and the long-connection communication link attempt based on the backoff mechanism, send a message with the long-chain module, and proceed to step S1.
[0091] Among them, the long connection communication link attempt of the probe module based on the backoff mechanism includes:
[0092] (1) Get the current backoff time interval Tx of the probe module;
[0093] (2) Tx is divided into Kx time units TK according to the preset parameter short_length, and Tx is divided into Mx time units TM according to the preset parameter long_length;
[0094] (3) Control the probe module to attempt a long connection communication link. The number of failed attempts is recorded as m. The time interval between the mth attempt and the m+1th attempt by the probe module is Tx+m = Tmin+(A+m)*TK+(B+m)*TM; where: A is L1*Kx, B is L2*Mx, L1 and L2 are preset proportional coefficients, and A and B are positive integers rounded up;
[0095] (4) When the probe module attempts the long connection communication link for the gth time and succeeds, the current backoff time interval Ty = Tmin + (A + g-1) * TK + (B + g-1) * TM is recorded; Ty is Tx in step (1) during the next round of long connection communication link attempts based on the backoff mechanism, and (A + g-1) > 0, (B + g-1) > 0.
[0096] The information transmission module sends the top-ranked information in the cache module through the long chain module or the short chain module according to the analysis result of the backoff module, and sends the top-ranked information received in the cache module to the application end corresponding to the information.
[0097] Example 6
[0098] A message sending system based on backoff mechanism, such as Figure 1 As shown, it includes: a long chain module, a short chain module, a cache module, a probe module, a backoff module and an information transmission module.
[0099] The long chain module repackages the target-identifiable long connection into a standard long connection and performs long connection communication, specifically the WebSocket communication module.
[0100] The short link module repackages the target-identifiable short connection into a standard short connection and performs segment connection communication, specifically the Http communication module.
[0101] The cache module is used to cache information to be sent and received, and sort them according to their categories. The categories of information can be: importance classification, source classification, etc.
[0102] The probe module detects network communication conditions based on the network probes of the long chain module and the short chain module.
[0103] The backoff module is used to perform the following analysis and control:
[0104] S1. Obtain the communication status of the probe module monitoring the long link module. When the long link communication mode is unobstructed, maintain the long link communication of the long link module and the regular heartbeat frequency of the probe module. When the long link communication mode fails or the heartbeat loss reaches the threshold, proceed to step S2.
[0105] S2. Enable the short link module and start a long connection communication link attempt based on the backoff mechanism.
[0106] When the long connection communication link attempt fails, the short connection communication mode is maintained and the probe module is controlled to make a long connection communication link attempt based on the backoff mechanism.
[0107] When the long connection communication link attempt is successful, the process proceeds to step S3.
[0108] S3. Close the short-chain module and the long-connection communication link attempt based on the backoff mechanism, send a message with the long-chain module, and proceed to step S1.
[0109] Among them, the long connection communication link attempt of the probe module based on the backoff mechanism includes:
[0110] (1) Obtain the current backoff time interval Tx, where Tx = Tmin + Cx * TG, where Cx is a positive integer and TG is a preset time interval unit.
[0111] (2) Perform a long connection communication link attempt. The number of failed attempts is recorded as m. The time interval between the m-th attempt and the m+1-th attempt is Tx+m = Tmin+(Cx+m)*TG.
[0112] (3) When the g-th attempt to establish a long connection communication link is successful, record the current backoff time interval Ty = Tmin+Cy*TG, and Cy = (Cx+g-1); Ty is Tx in step (1) of the next round of attempts to establish a long connection communication link based on the backoff mechanism, and Cy is Cx in step (1) of the next round of attempts to establish a long connection communication link based on the backoff mechanism, and Cy>0.
[0113] The information transmission module sends the top-ranked information in the cache module through the long chain module or the short chain module according to the analysis result of the backoff module, and sends the top-ranked information received in the cache module to the application end corresponding to the information.
[0114] While embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions, and variations may be made to these embodiments without departing from the principles and spirit of the invention, and that the scope of the invention is defined by the appended claims and their equivalents.
Claims
1. A message sending method based on a backoff mechanism, comprising: Long connection communication mode and short connection communication mode, characterized in that switching control between the long connection communication mode and the short connection communication mode is performed through a backoff control method according to the network communication situation; The backoff control method includes: S1 monitors the communication status of long connection communication, when the long connection communication is smooth, maintain long connection communication and conventional heartbeat frequency; when the long connection communication fails or the heartbeat threshold is reached, proceeds to step S2; S2. Enable short-term communication and initiate a long-term communication attempt based on a backoff mechanism. When the long connection communication link attempt fails, the short connection communication mode and the long connection communication link attempt based on the backoff method are maintained; When the long connection communication link attempt is successful, proceed to step S3; The long connection communication link attempt based on the backoff mechanism includes: (1) Get the current backoff time interval T x ; (2) According to the preset parameter short_length, T x Divide into K x Time unit T K , according to the preset parameter long_length, T x Divide into M x Time unit T M ; (3) Perform a long connection communication link attempt. The number of failed attempts is recorded as m. The time interval between the mth attempt and the m+1th attempt is T x+m = T min +(A+m)*T K +(B+m)*T M ; Where: A is L1*K x , B is L2*M x , L1 and L2 are preset proportional coefficients, A and B are positive integers rounded up; (4) When the g-th attempt to connect the long communication link is successful, the current backoff time interval T is recorded. y = T min +(A+g-1)*T K +(B+g-1)*T M ; The T y T in step (1) during the next round of long connection communication link attempt based on the backoff mechanism x , and (A+g-1)>0, (B+g-1)>0; or, (1) Get the current backoff time interval T x , the T x = T min +C x *T G , where: C x is a positive integer, T G is a preset time interval unit; (2) Perform a long connection communication link attempt. The number of failed attempts is m. The time interval between the mth attempt and the m+1th attempt is T x+m = T min + (C x +m)*T G ; (3) When the g-th attempt to connect the long communication link is successful, the current backoff time interval T is recorded. y = T min +C y *T G , and C y = (C x +g-1); the T y T in step (1) during the next round of long connection communication link attempt based on the backoff mechanism x , the C y C in step (1) during the next round of long connection communication link attempt based on the backoff mechanism x , and C y >0; The T x 、T x+m 、T y Both are greater than T m , less than T l , where: T m = T min *H, T l = T max *H; T min is the preset minimum interval time, T max is the preset maximum interval time, and H is a proportional value greater than 1; When T x 、T x+m 、T y Calculated value ≤ T m When the value is T m When T x 、T x+m 、T y Calculated value ≥ T l When the value is T l; S3. Close the short connection communication mode and the long connection communication link attempt based on the backoff mechanism, send the message in the long connection communication mode, and enter step S1.
2. The message sending method based on the backoff mechanism according to claim 1, characterized in that: The long connection communication method includes repackaging a long connection of an identifiable information source into a standard long connection.
3. The message sending method based on the backoff mechanism according to claim 1, characterized in that: The short connection communication method includes repackaging the short connection of the identifiable information source into a standard short connection.
4. The message sending method based on the backoff mechanism according to claim 1, characterized in that: The information to be sent is stored in a sending buffer device; the information in the sending buffer device is sorted and buffered according to the classification of the information, wherein the information with the highest sorting level is sent first.
5. The message sending method based on the backoff mechanism according to claim 1, characterized in that: The received information is stored in a receiving buffer device; the information in the receiving buffer device is sorted and buffered according to the classification of the information, wherein the information with the highest sorting is transmitted first.
6. A message sending system based on a backoff mechanism, comprising: Long link module, short link module, cache module, probe module, backoff module and information transmission module; characterized in that the long link module repackages the long connection of the identifiable target into a standard long connection and performs long connection communication; The short link module repackages the target-identifiable short connection into a standard short connection and performs segment connection communication; The cache module is used to cache information to be sent and received information, and sort them according to the classification of the information; The probe module detects network communication conditions based on the network probes of the long chain module and the short chain module; The backoff module is used to obtain feedback information from the probe module, perform the analysis step of the backoff control method in the message sending method based on the backoff mechanism according to any one of claims 1 to 5, and control the detection frequency of the probe module according to the analysis result; The information transmission module sends the top-ranked information in the cache module through the long chain module or the short chain module according to the analysis result of the backoff module, and sends the top-ranked information received in the cache module to the application end corresponding to the information.
Citation Information
Patent Citations
Equipment state updating method and device, computer equipment and storage medium
CN114281373A