CN104601376B - Heartbeat message sending method and device - Google Patents

Heartbeat message sending method and device Download PDF

Info

Publication number
CN104601376B
CN104601376B CN201510008018.0A CN201510008018A CN104601376B CN 104601376 B CN104601376 B CN 104601376B CN 201510008018 A CN201510008018 A CN 201510008018A CN 104601376 B CN104601376 B CN 104601376B
Authority
CN
China
Prior art keywords
time
heartbeat message
network delay
message
average value
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.)
Active
Application number
CN201510008018.0A
Other languages
Chinese (zh)
Other versions
CN104601376A (en
Inventor
李德果
朱明明
阮利
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Huawei Digital Technologies Co Ltd
Original Assignee
Beijing Huawei Digital Technologies Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Beijing Huawei Digital Technologies Co Ltd filed Critical Beijing Huawei Digital Technologies Co Ltd
Priority to CN201510008018.0A priority Critical patent/CN104601376B/en
Publication of CN104601376A publication Critical patent/CN104601376A/en
Application granted granted Critical
Publication of CN104601376B publication Critical patent/CN104601376B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

The invention discloses a kind of heartbeat message sending method and devices, belong to the communications field.The described method includes: the network delay for N number of heartbeat message that the forward direction server for obtaining current time is sent;According to the network delay of N number of heartbeat message and the negotiation time-out time T of the client1Determine new negotiation time-out time T2;According to negotiation time-out time T2Subsequent heartbeat message is sent to the server.The method is adjusted currently used negotiation time-out time according to the network delay of the heartbeat message sent, make to negotiate time-out time under the premise of can satisfy the accuracy of fault detection, shorten as far as possible, avoid mean failure rate detection time delay too long, to achieve the effect that the time delay of the accuracy rate for taking into account high fault detection and low fault detection.

Description

Heartbeat message sending method and device
Technical field
The present invention relates to the communications field, in particular to a kind of heartbeat message sending method and device.
Background technique
Zookeeper has been applied to the distributed system in many fields as a kind of effective coordination service. Zookeeper point is client part and server section, the fault detection of client be then in the application of Zookeeper more It is common a kind of.
In the prior art, static failure detection algorithm is used between the server and client of Zookeeper.Client Make an appointment one with server negotiate time-out time (full name in English: Negotiated Session Timeout, abbreviation: NST), client sends heartbeat message (Ping message) to server end using the NST of one third as the period, and server receives the heart The overtime moment connecting between the client and server is increased into a NST after jump message, and replys heartbeat to client Message (Pong message).If server end does not receive the Ping message that client is sent in a NST, then it is assumed that client Failure has occurred.If client does not receive what server end was sent sending in 2/3rds NST after Ping message Pong message, then client determining server end is overtime.
In the implementation of the present invention, it is found by the applicant that the prior art at least has the disadvantage in that
In the prior art, to the accuracy of guarantee fault detection, it is necessary to the larger of time-out time setting will be negotiated, and It can make mean failure rate detection time delay too long again in this way, time-out time will be negotiated when being set as fixed value, cannot be considered in terms of high failure inspection The time delay of the accuracy rate of survey and low fault detection.
Summary of the invention
In order to solve to set fixed value for negotiation time-out time in the prior art, lead to not take into account high fault detection The problem of accuracy rate and the time delay of low fault detection, the embodiment of the invention provides a kind of heartbeat message sending method and devices. The technical solution is as follows:
In a first aspect, a kind of heartbeat message sending method is provided, in client, which comprises
The network delay of N number of heartbeat message of the forward direction server transmission at current time is obtained, the network delay is hair Send a heartbeat message to the delay received between corresponding response message, N >=1, and N be integer;
According to the network delay of N number of heartbeat message and the negotiation time-out time T of the client1Determine new association Quotient's time-out time T2
By the negotiation time-out time of the client by T1It is updated to T2
According to updated negotiation time-out time T2Subsequent heartbeat message is sent to the server.
In the first possible implementation of first aspect, for each of N number of heartbeat message heartbeat report When including that the heartbeat message is sent in text, the heartbeat message and the corresponding response message of the heartbeat message, institute State the system time t of terminal1;The network delay for N number of heartbeat message that the forward direction server for obtaining current time is sent, packet It includes:
When receiving the corresponding response message of the heartbeat message, the system time for including in the response message is obtained t1And the system time t of response message terminal when being received2
Determine network delay δ=t of the heartbeat message2-t1
The network delay δ of the heartbeat message is added into it is pre-set, length be N circle queue.
The possible implementation of with reference to first aspect the first, in second of possible implementation of first aspect, institute State the negotiation time-out time T of the network delay and the client according to N number of heartbeat message1Determine new negotiation time-out Time T2, comprising:
When the circle queue has been expired, the average value of N number of network delay in the circle queue is obtained;
Whether the average value for detecting N number of network delay is greater than x*T1, x > 0;
If the average value that testing result is N number of network delay is greater than x*T1, it is determined that T2=(1+X) T1;X > 0.
The possible implementation of with reference to first aspect the first, in the third possible implementation of first aspect, institute State the negotiation time-out time T of the network delay and the client according to N number of heartbeat message1Determine new negotiation time-out Time T2, comprising:
When the circle queue has been expired, the maximum value of N number of network delay in the circle queue is obtained;
Whether the maximum value for detecting N number of network delay is greater than y*T1, y > 0;
If the maximum value that testing result is N number of network delay is greater than y*T1, it is determined that T2=(1+Y) T1;Y > 0.
The possible implementation of with reference to first aspect the first, in the 4th kind of possible implementation of first aspect, institute State the negotiation time-out time T of the network delay and the client according to N number of heartbeat message1Determine new negotiation time-out Time T2, comprising:
When the circle queue has been expired, the average value of N number of network delay in the circle queue is obtained;
Whether the average value for detecting N number of network delay is less than z*T1, z > 0;
If the average value that testing result is N number of network delay is less than z*T1, it is determined that T2=(1-Z) T1;0 < Z < 1.
In the 5th kind of possible implementation of first aspect, the method also includes:
By the updated negotiation time-out time T2It is sent to the server.
Second aspect provides a kind of heartbeat message sending device, in client, described device to include:
Delay acquisition module, the network delay for N number of heartbeat message that the forward direction server for obtaining current time is sent, The network delay be send a heartbeat message to the delay received between corresponding response message, N >=1, and N be integer;
Negotiate time-out time determining module, for according to N number of heartbeat message network delay and the client Negotiation time-out time T1Determine new negotiation time-out time T2
Negotiate time-out time update module, for by the negotiation time-out time of the client by T1It is updated to T2
Message sending module, for according to updated negotiation time-out time T2Subsequent heartbeat is sent to the server Message.
In the first possible implementation of second aspect, the delay acquisition module, for for N number of heartbeat Each of message heartbeat message obtains the response message when receiving the corresponding response message of the heartbeat message In include system time t1And the system time t of response message terminal when being received2;Determine the heartbeat report Network delay δ=t of text2-t1;The network delay δ of the heartbeat message is added into it is pre-set, length be N annular team Column;
It wherein, include the heartbeat message quilt in the heartbeat message and the corresponding response message of the heartbeat message When transmission, the system time t of the terminal1
In conjunction with the first possible implementation of second aspect, in second of possible implementation of first aspect, institute It states and negotiates time-out time determining module, for when the circle queue has been expired, the N number of network obtained in the circle queue to prolong When average value, whether the average value for detecting N number of network delay be greater than x*T1, x > 0, if testing result is N number of net The average value of network delay is greater than x*T1, it is determined that T2=(1+X) T1;X > 0.
In conjunction with the first possible implementation of second aspect, in the third possible implementation of first aspect, institute It states and negotiates time-out time determining module, for when the circle queue has been expired, the N number of network obtained in the circle queue to prolong When maximum value, whether the maximum value for detecting N number of network delay be greater than y*T1, y > 0, if testing result is N number of net The maximum value of network delay is greater than y*T1, it is determined that T2=(1+Y) T1;Y > 0.
In conjunction with the first possible implementation of second aspect, in the 4th kind of possible implementation of first aspect, institute It states and negotiates time-out time determining module, for when the circle queue has been expired, the N number of network obtained in the circle queue to prolong When average value, whether the average value for detecting N number of network delay be less than z*T1, z > 0, if testing result is N number of net The average value of network delay is less than z*T1, it is determined that T2=(1-Z) T1;0 < Z < 1.
In the 5th kind of possible implementation of second aspect, described device further include:
Negotiate time-out time sending module, is used for the updated negotiation time-out time T2It is sent to the service Device.
Technical solution provided in an embodiment of the present invention has the benefit that
By the network delay for N number of heartbeat message that the forward direction server at current time is sent, according to N number of heartbeat message Network delay and client negotiation time-out time T1Determine new negotiation time-out time T2, by the negotiation time-out of client Time is by T1It is updated to T2, according to updated negotiation time-out time T2Subsequent heartbeat message is sent to server, according to having sent out The network delay of the heartbeat message sent is adjusted currently used negotiation time-out time, expire negotiation time-out time can Under the premise of the accuracy of sufficient fault detection, shorten as far as possible, avoids mean failure rate detection time delay too long, taken into account to reach The effect of the accuracy rate of high fault detection and the time delay of low fault detection.
Detailed description of the invention
To describe the technical solutions in the embodiments of the present invention more clearly, make required in being described below to embodiment Attached drawing is briefly described, it should be apparent that, drawings in the following description are only some embodiments of the invention, for For those of ordinary skill in the art, without creative efforts, it can also be obtained according to these attached drawings other Attached drawing.
Fig. 1 is the method flow diagram of heartbeat message sending method provided by one embodiment of the present invention;
Fig. 2 be another embodiment of the present invention provides heartbeat message sending method method flow diagram;
Fig. 3 be another embodiment of the present invention provides network delay obtain and negotiate time-out time update schematic diagram;
Fig. 4 is the structure drawing of device of heartbeat message sending device provided by one embodiment of the present invention;
Fig. 5 be another embodiment of the present invention provides heartbeat message sending device structure drawing of device;
Fig. 6 is the block diagram of client provided by one embodiment of the present invention.
Specific embodiment
To make the object, technical solutions and advantages of the present invention clearer, below in conjunction with attached drawing to embodiment party of the present invention Formula is described in further detail.
Referring to FIG. 1, it illustrates the method flow diagrams of heartbeat message sending method provided by one embodiment of the present invention. The heartbeat message sending method can be used in client.The heartbeat message sending method may include:
Step 102, the network delay of N number of heartbeat message of the forward direction server transmission at current time is obtained, which prolongs When for send a heartbeat message to the delay received between corresponding response message, N >=1, and N be integer.
Step 104, according to the network delay of N number of heartbeat message and the negotiation time-out time T of the client1It determines new Negotiation time-out time T2
Step 106, by the negotiation time-out time of the client by T1It is updated to T2
Step 108, according to updated negotiation time-out time T2Subsequent heartbeat message is sent to the server.
In conclusion heartbeat message sending method provided in an embodiment of the present invention, is taken by the forward direction for obtaining current time The network delay for N number of heartbeat message that business device is sent is super according to the negotiation of the network delay of N number of heartbeat message and client When time T1Determine new negotiation time-out time T2, by the negotiation time-out time of client by T1It is updated to T2, according to updated Negotiate time-out time T2Subsequent heartbeat message is sent to server, according to the network delay of the heartbeat message sent to current The negotiation time-out time used is adjusted, and makes to negotiate time-out time under the premise of can satisfy the accuracy of fault detection, Shorten as far as possible, avoids mean failure rate detection time delay too long, to reach the accuracy rate for taking into account high fault detection and low failure The effect of the time delay of detection.
In order to be further described to above-mentioned scheme shown in FIG. 1, referring to FIG. 2, it illustrates another realities of the present invention The method flow diagram of the heartbeat message sending method of example offer is provided.The heartbeat message sending method can be used in client.It should Heartbeat message sending method may include:
In step 202, with T1/ 3 send N number of heartbeat message, T to server for the period1For client negotiation time-out when Between.
Client negotiates time-out time using one third and sends heartbeat to server as the period when connecting with server Message, also referred to as Ping message, if the network between client and server is unobstructed, server smoothly receives Ping report Text can then return to a Pong message to client, identical information be carried in the Ping message and Pong message, if client The Pong message for receiving client end response in the predetermined time after Ping message is being sent, then is confirming the connection with server Normally.
In embodiments of the present invention, the Pong message that the Ping message and server that user end to server is sent return In can only carry type of message, system time when message ID and client send Ping message;The Ping successively sent The message ID carried in message can be incremented by successively.
In step 204, for each of N number of heartbeat message heartbeat message, when receiving the heartbeat message pair When the response message answered, the system time t for including in the response message is obtained1And response message terminal when being received System time t2
When client receives a Pong message, it can extract and carry in the Pong message, client is sent pair System time when the Ping message answered.Client also obtains system time when receiving the Pong message simultaneously.
In step 206, network delay δ=t of the heartbeat message is determined2-t1
The client that client will acquire sends the system time Pong report corresponding with receiving when Ping message The time interval between system time when literary is retrieved as the network delay of the Ping message.
In a step 208, the network delay δ of the heartbeat message is added into it is pre-set, length be N annular team Column.
It is N number of circle queue that a length is preset in client, if client obtains the network of a Ping message Delay, and the circle queue state is less than, then is added into the annular team for the network delay of the Ping message as an element In column.
Specifically, network delay as shown in Figure 3, which obtains and negotiate time-out time, updates schematic diagram, wherein client with T1/ 3 send Ping message to server for the period, when server receives Ping message every time, i.e., return to one to client Corresponding Pong message, sending Ping message to the time received corresponding Pong message from client is that the Ping is reported Network delay δ in text.In Fig. 3, circle queue length is fixed as 8, each network delay δ that client will acquire1、δ2、 δ3…δ8It is added into circle queue.
In step 210, according to the network delay of N number of heartbeat message and the negotiation time-out time T of the client1Really Fixed new negotiation time-out time T2
Specifically, client can determine new negotiation time-out time according to following three mode:
1) when the circle queue has been expired, the average value of N number of network delay in the circle queue is obtained;It is N number of to detect this Whether the average value of network delay is greater than x*T1, x > 0;If the average value that testing result is N number of network delay is greater than x*T1, then Determine T2=(1+X) T1;X > 0.
By taking Fig. 3 as an example, when being added into 8 elements in circle queue, client obtains each network in circle queue Delay, calculates its average value, and compare the average value and T1Size relation between the 10% of/3, if the average value is greater than T1/3 10%, then the network delay of the Ping message sent before explanation is bigger than normal, at this point it is possible to which new negotiation time-out time is determined For T2=(1+0.1) T1, i.e., original is negotiated after time-out time increases 10% as new negotiation time-out time.
2) when the circle queue has been expired, the maximum value of N number of network delay in the circle queue is obtained;It is N number of to detect this Whether the maximum value of network delay is greater than y*T1, y > 0;If the maximum value that testing result is N number of network delay is greater than y*T1, then Determine T2=(1+Y) T1;Y > 0.
Alternatively, when being added into 8 elements in circle queue, client obtains each in circle queue by taking Fig. 3 as an example Network delay extracts maximum value therein, and compares the maximum value and T1Size relation between the 15% of/3, if the average value Greater than T1The network delay of the 15% of/3, then the Ping message sent before explanation is bigger than normal, at this point it is possible to by new negotiation time-out Time is determined as T2=(1+0.1) T1, i.e., original is negotiated after time-out time increases 10% as new negotiation time-out time.
3) when the circle queue has been expired, the average value of N number of network delay in the circle queue is obtained;It is N number of to detect this Whether the average value of network delay is less than z*T1, z > 0;If the average value that testing result is N number of network delay is less than z*T1, then Determine T2=(1-Z) T1;0 < Z < 1.
Alternatively, when being added into 8 elements in circle queue, client obtains each in circle queue by taking Fig. 3 as an example Network delay extracts average value therein, and compares the maximum value and T1Size relation between the 10% of/3, if the average value Less than T1The network delay of the 5% of/3, then the Ping message sent before explanation is less than normal, at this point it is possible to by new negotiation time-out Time is determined as T2=(1-0.05) T1, i.e., original is negotiated into time-out time and reduced after 5% as new negotiation time-out time.
It should be noted that scheme shown in the embodiment of the present invention is only illustrated with above-mentioned specific example, in reality In the application of border, the step-length of the above-mentioned threshold value for comparing and increase or diminution can be carried out according to the actual conditions of network Adjustment, for example, in the case where needing to guarantee higher Detection accuracy, when detecting to need to increase negotiation time-out time, Original can be negotiated into time-out time and once increase by 20%, in the case where needing to guarantee lower fault detection time delay, work as detection When needing to reduce negotiation time-out time out, original can be negotiated into time-out time first-stage reduction 10%.
In the step 212, by the negotiation time-out time of the client by T1It is updated to T2
In step 214, according to updated negotiation time-out time T2Subsequent heartbeat message is sent to the server.
As shown in figure 3, client passes through updated negotiation time-out time and sends after updating negotiation time-out time Subsequent heartbeat message.
In the step 216, by the updated negotiation time-out time T2It is sent to the server.
For the ease of the new negotiation time-out time of server timely learning, client after updating and negotiating time-out time, The updated negotiation time-out time is sent to by server by new type of message, so that server accurately carries out failure Detection.
Client empties circle queue, and repeat above-mentioned steps 206- after updating negotiation time-out time 212, when circle queue is again filled with, further according to negotiation time-out time T2It will negotiate time-out with the network delay in circle queue Time is updated to T3, recycle according to this.
In conclusion heartbeat message sending method provided in an embodiment of the present invention, is taken by the forward direction for obtaining current time The network delay for N number of heartbeat message that business device is sent is super according to the negotiation of the network delay of N number of heartbeat message and client When time T1Determine new negotiation time-out time T2, by the negotiation time-out time of client by T1It is updated to T2, according to updated Negotiate time-out time T2Subsequent heartbeat message is sent to server, according to the network delay of the heartbeat message sent to current The negotiation time-out time used is adjusted, and makes to negotiate time-out time under the premise of can satisfy the accuracy of fault detection, Shorten as far as possible, avoids mean failure rate detection time delay too long, to reach the accuracy rate for taking into account high fault detection and low failure The effect of the time delay of detection.
Referring to FIG. 4, it illustrates the structure drawing of device of heartbeat message sending device provided by one embodiment of the present invention. The heartbeat message sending device can be used in client, execute method as shown in Figure 1 or 2.The heartbeat message sends dress It sets and may include:
The network of delay acquisition module 401, N number of heartbeat message that the forward direction server for obtaining current time is sent prolongs When, the network delay is that send a heartbeat message to the delay received between corresponding response message, N >=1, and N be whole Number;
Negotiate time-out time determining module 402, for according to N number of heartbeat message network delay and the client The negotiation time-out time T at end1Determine new negotiation time-out time T2
Negotiate time-out time update module 403, for by the negotiation time-out time of the client by T1It is updated to T2
Message sending module 404, for according to updated negotiation time-out time T2It is sent to the server subsequent Heartbeat message.
In conclusion heartbeat message sending device provided in an embodiment of the present invention, is taken by the forward direction for obtaining current time The network delay for N number of heartbeat message that business device is sent is super according to the negotiation of the network delay of N number of heartbeat message and client When time T1Determine new negotiation time-out time T2, by the negotiation time-out time of client by T1It is updated to T2, according to updated Negotiate time-out time T2Subsequent heartbeat message is sent to server, according to the network delay of the heartbeat message sent to current The negotiation time-out time used is adjusted, and makes to negotiate time-out time under the premise of can satisfy the accuracy of fault detection, Shorten as far as possible, avoids mean failure rate detection time delay too long, to reach the accuracy rate for taking into account high fault detection and low failure The effect of the time delay of detection.
Referring to FIG. 5, it illustrates another embodiment of the present invention provides heartbeat message sending device structure drawing of device. The heartbeat message sending device can be used in client, execute method as shown in Figure 1 or 2.The heartbeat message sends dress It sets and may include:
The network of delay acquisition module 401, N number of heartbeat message that the forward direction server for obtaining current time is sent prolongs When, the network delay is that send a heartbeat message to the delay received between corresponding response message, N >=1, and N be whole Number;
Negotiate time-out time determining module 402, for according to N number of heartbeat message network delay and the client The negotiation time-out time T at end1Determine new negotiation time-out time T2
Negotiate time-out time update module 403, for by the negotiation time-out time of the client by T1It is updated to T2
Message sending module 404, for according to updated negotiation time-out time T2It is sent to the server subsequent Heartbeat message.
Optionally, the delay acquisition module 401 is used for for each of N number of heartbeat message heartbeat message, When receiving the corresponding response message of the heartbeat message, the system time t for including in the response message is obtained1, and The system time t of response message terminal when being received2;Determine network delay δ=t of the heartbeat message2-t1;It will The network delay δ of the heartbeat message be added into it is pre-set, length be N circle queue;
It wherein, include the heartbeat message quilt in the heartbeat message and the corresponding response message of the heartbeat message When transmission, the system time t of the terminal1
Optionally, the negotiation time-out time determining module 402 is used for when the circle queue has been expired, described in acquisition Whether the average value of N number of network delay in circle queue, the average value for detecting N number of network delay are greater than x*T1, x > 0, If the average value that testing result is N number of network delay is greater than x*T1, it is determined that T2=(1+X) T1;X > 0.
Optionally, the negotiation time-out time determining module 402 is used for when the circle queue has been expired, described in acquisition Whether the maximum value of N number of network delay in circle queue, the maximum value for detecting N number of network delay are greater than y*T1, y > 0, If the maximum value that testing result is N number of network delay is greater than y*T1, it is determined that T2=(1+Y) T1;Y > 0.
Optionally, the negotiation time-out time determining module 402 is used for when the circle queue has been expired, described in acquisition Whether the average value of N number of network delay in circle queue, the average value for detecting N number of network delay are less than z*T1, z > 0, If the average value that testing result is N number of network delay is less than z*T1, it is determined that T2=(1-Z) T1;0 < Z < 1.
Optionally, described device further include:
Negotiate time-out time sending module 405, is used for the updated negotiation time-out time T2It is sent to the clothes Business device.
In conclusion heartbeat message sending device provided in an embodiment of the present invention, is taken by the forward direction for obtaining current time The network delay for N number of heartbeat message that business device is sent is super according to the negotiation of the network delay of N number of heartbeat message and client When time T1Determine new negotiation time-out time T2, by the negotiation time-out time of client by T1It is updated to T2, according to updated Negotiate time-out time T2Subsequent heartbeat message is sent to server, according to the network delay of the heartbeat message sent to current The negotiation time-out time used is adjusted, and makes to negotiate time-out time under the premise of can satisfy the accuracy of fault detection, Shorten as far as possible, avoids mean failure rate detection time delay too long, to reach the accuracy rate for taking into account high fault detection and low failure The effect of the time delay of detection.
Referring to FIG. 6, it illustrates the block diagrams of client provided by one embodiment of the present invention.The client can be used for Execute method as shown in Figure 1 or 2.The client may include: bus 610, and be connected to the processor of bus 610 620, memory 630, receiver 640 and transmitter 650.Wherein, memory 630 is used for storage one or more than one Instruction, the instruction are configured to be executed by processor 620.Wherein:
Processor 620, the N sent for controlling and receiving device 640 and the forward direction server at the acquisition current time of transmitter 650 The network delay of a heartbeat message, the network delay are to send a heartbeat message between the corresponding response message of reception Delay, N >=1, and N are integer;
Processor 620, when for according to the negotiation time-out of the network delay of N number of heartbeat message and the client Between T1Determine new negotiation time-out time T2
Processor 620, for by the negotiation time-out time of the client by T1It is updated to T2
Processor 620, for control transmitter 650 according to updated negotiation time-out time T2It is sent to the server Subsequent heartbeat message.
In conclusion client provided in an embodiment of the present invention, the N that the forward direction server by obtaining current time is sent The network delay of a heartbeat message, according to the network delay of N number of heartbeat message and the negotiation time-out time T of client1Really Fixed new negotiation time-out time T2, by the negotiation time-out time of client by T1It is updated to T2, when overtime according to updated negotiation Between T2Subsequent heartbeat message is sent to server, according to the network delay of the heartbeat message sent to currently used negotiation Time-out time is adjusted, and is made to negotiate time-out time under the premise of can satisfy the accuracy of fault detection, is contracted as far as possible It is short, avoid mean failure rate detection time delay too long, to reach the time delay of the accuracy rate for taking into account high fault detection and low fault detection Effect.
Optionally, processor 620, for working as receiver for each of N number of heartbeat message heartbeat message 640 when receiving the corresponding response message of the heartbeat message, obtains the system time t for including in the response message1, and The system time t of response message terminal when being received2;Determine network delay δ=t of the heartbeat message2-t1;It will The network delay δ of the heartbeat message be added into it is pre-set, length be N circle queue;
It wherein, include the heartbeat message quilt in the heartbeat message and the corresponding response message of the heartbeat message When transmission, the system time t of the terminal1
Optionally, processor 620, for obtaining N number of network in the circle queue when the circle queue has been expired Whether the average value of delay, the average value for detecting N number of network delay are greater than x*T1, x > 0, if testing result is described N number of The average value of network delay is greater than x*T1, it is determined that T2=(1+X) T1;X > 0.
Optionally, processor 620, for obtaining N number of network in the circle queue when the circle queue has been expired Whether the maximum value of delay, the maximum value for detecting N number of network delay are greater than y*T1, y > 0, if testing result is described N number of The maximum value of network delay is greater than y*T1, it is determined that T2=(1+Y) T1;Y > 0.
Optionally, processor 620, for obtaining N number of network in the circle queue when the circle queue has been expired Whether the average value of delay, the average value for detecting N number of network delay are less than z*T1, z > 0, if testing result is described N number of The average value of network delay is less than z*T1, it is determined that T2=(1-Z) T1;0 < Z < 1.
Optionally, described device further include:
Processor 620 is used for control transmitter 650 for the updated negotiation time-out time T2It is sent to the service Device.
It should be understood that heartbeat message sending device provided by the above embodiment is sending heartbeat message and is updating association When quotient's time-out time, only the example of the division of the above functional modules, in practical application, it can according to need and incite somebody to action Above-mentioned function distribution is completed by different functional modules, i.e., the internal structure of device is divided into different functional modules, with complete At all or part of function described above.In addition, heartbeat message sending device provided by the above embodiment and heartbeat message Sending method embodiment belongs to same design, and specific implementation process is detailed in embodiment of the method, and which is not described herein again.
The serial number of the above embodiments of the invention is only for description, does not represent the advantages or disadvantages of the embodiments.
Those of ordinary skill in the art will appreciate that realizing that all or part of the steps of above-described embodiment can pass through hardware It completes, relevant hardware can also be instructed to complete by program, the program can store in a kind of computer-readable In storage medium, storage medium mentioned above can be read-only memory, disk or CD etc..
The foregoing is merely presently preferred embodiments of the present invention, is not intended to limit the invention, it is all in spirit of the invention and Within principle, any modification, equivalent replacement, improvement and so on be should all be included in the protection scope of the present invention.

Claims (12)

1. a kind of heartbeat message sending method, in client, which is characterized in that the described method includes:
The network delay of N number of heartbeat message of the forward direction server transmission at the client current time is obtained, the network prolongs When for send a heartbeat message to the delay received between corresponding response message, N >=1, and N be integer;
The average value of the network delay of N number of heartbeat message is obtained, being averaged for the network delay of N number of heartbeat message is detected Whether value is greater than x*T1, wherein x > 0, T1For the negotiation time-out time of the client;If testing result is N number of heartbeat The average value of the network delay of message is greater than x*T1, it is determined that it is greater than T1New negotiation time-out time T2;Or,
The maximum value of the network delay of N number of heartbeat message is obtained, the maximum of the network delay of N number of heartbeat message is detected Whether value is greater than y*T1, y > 0;If the maximum value that testing result is the network delay of N number of heartbeat message is greater than y*T1, then really Surely it is greater than T1New negotiation time-out time T2;Or,
The average value of the network delay of N number of heartbeat message is obtained, being averaged for the network delay of N number of heartbeat message is detected Whether value is less than z*T1, z > 0;If the average value that testing result is the network delay of N number of heartbeat message is less than z*T1, then really Surely it is less than T1New negotiation time-out time T2
By the negotiation time-out time of the client by T1It is updated to T2
According to updated negotiation time-out time T2Subsequent heartbeat message is sent to the server.
2. the method according to claim 1, wherein for each of N number of heartbeat message heartbeat report When including that the heartbeat message is sent in text, the heartbeat message and the corresponding response message of the heartbeat message, institute State the system time t of client1;The network delay for N number of heartbeat message that the forward direction server for obtaining current time is sent, Include:
When receiving the corresponding response message of the heartbeat message, the system time t for including in the response message is obtained1, with And the system time t of response message client when being received2
Determine network delay δ=t of the heartbeat message2-t1
The network delay δ of the heartbeat message is added into it is pre-set, length be N circle queue.
3. according to the method described in claim 2, it is characterized in that, the network delay for obtaining N number of heartbeat message Average value, comprising:
When the circle queue has been expired, the average value of N number of network delay in the circle queue is obtained;
If the average value that the testing result is the network delay of N number of heartbeat message is greater than x*T1, it is determined that it is greater than T1It is new Negotiation time-out time T2, comprising:
If the average value that testing result is N number of network delay is greater than x*T1, it is determined that T2=(1+X) T1;X > 0.
4. according to the method described in claim 2, it is characterized in that, the network delay for obtaining N number of heartbeat message Maximum value, comprising:
When the circle queue has been expired, the maximum value of N number of network delay in the circle queue is obtained;
If the maximum value that the testing result is the network delay of N number of heartbeat message is greater than y*T1, it is determined that it is greater than T1It is new Negotiation time-out time T2, comprising:
If the maximum value that testing result is N number of network delay is greater than y*T1, it is determined that T2=(1+Y) T1;Y > 0.
5. according to the method described in claim 2, it is characterized in that, the network delay for obtaining N number of heartbeat message Average value, comprising:
When the circle queue has been expired, the average value of N number of network delay in the circle queue is obtained;
If the average value that the testing result is the network delay of N number of heartbeat message is less than z*T1, it is determined that it is less than T1It is new Negotiation time-out time T2, comprising:
If the average value that testing result is N number of network delay is less than z*T1, it is determined that T2=(1-Z) T1;0 < Z < 1.
6. the method according to claim 1, wherein the method also includes:
By the updated negotiation time-out time T2It is sent to the server.
7. a kind of heartbeat message sending device, in client, which is characterized in that described device includes:
Delay acquisition module, the net for N number of heartbeat message that the forward direction server for obtaining the client current time is sent Network delay, the network delay are to send a heartbeat message to the delay received between corresponding response message, N >=1, and N For integer;
Negotiate time-out time determining module, the average value of the network delay for obtaining N number of heartbeat message detects the N Whether the average value of the network delay of a heartbeat message is greater than x*T1, wherein x > 0, T1For the client negotiation time-out when Between;If the average value that testing result is the network delay of N number of heartbeat message is greater than x*T1, it is determined that it is greater than T1New association Quotient's time-out time T2;Or, obtaining the maximum value of the network delay of N number of heartbeat message, the net of N number of heartbeat message is detected Whether the maximum value of network delay is greater than y*T1, y > 0;If testing result is the maximum value of the network delay of N number of heartbeat message Greater than y*T1, it is determined that it is greater than T1New negotiation time-out time T2;Or, obtaining the flat of the network delay of N number of heartbeat message Whether mean value, the average value for detecting the network delay of N number of heartbeat message are less than z*T1, z > 0;If testing result is the N The average value of the network delay of a heartbeat message is less than z*T1, it is determined that it is less than T1New negotiation time-out time T2
Negotiate time-out time update module, for by the negotiation time-out time of the client by T1It is updated to T2
Message sending module, for according to updated negotiation time-out time T2Subsequent heartbeat message is sent to the server.
8. device according to claim 7, which is characterized in that
The delay acquisition module, for for each of N number of heartbeat message heartbeat message, when receiving the heart When jumping the corresponding response message of message, the system time t for including in the response message is obtained1And the response message quilt The system time t of client when reception2;Determine network delay δ=t of the heartbeat message2-t1;By the heartbeat message Network delay δ be added into it is pre-set, length be N circle queue;
It wherein, include that the heartbeat message is sent in the heartbeat message and the corresponding response message of the heartbeat message When, the system time t of the client1
9. device according to claim 8, which is characterized in that the negotiation time-out time determining module, for when described When circle queue has been expired, the average value of N number of network delay in the circle queue is obtained, detects N number of network delay Whether average value is greater than x*T1, x > 0, if the average value that testing result is N number of network delay is greater than x*T1, it is determined that T2= (1+X)T1;X > 0.
10. device according to claim 8, which is characterized in that the negotiation time-out time determining module, for when described When circle queue has been expired, the maximum value of N number of network delay in the circle queue is obtained, detects N number of network delay Whether maximum value is greater than y*T1, y > 0, if the maximum value that testing result is N number of network delay is greater than y*T1, it is determined that T2= (1+Y)T1;Y > 0.
11. device according to claim 8, which is characterized in that the negotiation time-out time determining module, for when described When circle queue has been expired, the average value of N number of network delay in the circle queue is obtained, detects N number of network delay Whether average value is less than z*T1, z > 0, if the average value that testing result is N number of network delay is less than z*T1, it is determined that T2= (1-Z)T1;0 < Z < 1.
12. device according to claim 7, which is characterized in that described device further include:
Negotiate time-out time sending module, is used for the updated negotiation time-out time T2It is sent to the server.
CN201510008018.0A 2015-01-07 2015-01-07 Heartbeat message sending method and device Active CN104601376B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510008018.0A CN104601376B (en) 2015-01-07 2015-01-07 Heartbeat message sending method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510008018.0A CN104601376B (en) 2015-01-07 2015-01-07 Heartbeat message sending method and device

Publications (2)

Publication Number Publication Date
CN104601376A CN104601376A (en) 2015-05-06
CN104601376B true CN104601376B (en) 2019-03-01

Family

ID=53126901

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510008018.0A Active CN104601376B (en) 2015-01-07 2015-01-07 Heartbeat message sending method and device

Country Status (1)

Country Link
CN (1) CN104601376B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105634864A (en) * 2015-12-29 2016-06-01 南京国电南自电网自动化有限公司 GOOSE network performance self-diagnosis method used for intelligent transformer substation relay protection
CN105827697A (en) * 2016-03-14 2016-08-03 广州趣丸网络科技有限公司 User off-line detection method and user off-line detection system
WO2018074587A1 (en) * 2016-10-20 2018-04-26 日本電気株式会社 Server device, cluster system, cluster control method, and program
CN110007886B (en) * 2019-04-10 2021-10-22 广州视源电子科技股份有限公司 Screen transmission timeout time dynamic setting method and device, wireless screen transmitter and receiving end
CN113472606B (en) * 2021-06-29 2022-09-30 聚好看科技股份有限公司 Heartbeat overtime detection method, server and electronic equipment

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1286505A1 (en) * 2001-08-23 2003-02-26 Samsung Electronics Co., Ltd. Method for compensating for propagation delay in a point-to-multipoint data communication network
CN102843250A (en) * 2011-06-21 2012-12-26 中兴通讯股份有限公司 Adaptive method and adaptive device of heartbeat cycle
CN104052569A (en) * 2013-03-12 2014-09-17 中兴通讯股份有限公司 MCS switching method and device

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1286505A1 (en) * 2001-08-23 2003-02-26 Samsung Electronics Co., Ltd. Method for compensating for propagation delay in a point-to-multipoint data communication network
CN102843250A (en) * 2011-06-21 2012-12-26 中兴通讯股份有限公司 Adaptive method and adaptive device of heartbeat cycle
CN104052569A (en) * 2013-03-12 2014-09-17 中兴通讯股份有限公司 MCS switching method and device

Also Published As

Publication number Publication date
CN104601376A (en) 2015-05-06

Similar Documents

Publication Publication Date Title
CN104601376B (en) Heartbeat message sending method and device
KR101785483B1 (en) Method for acting as service agent, modem and terminal
CN108566312A (en) Off-line checking method, device and computer readable storage medium
CN110073639A (en) Packet loss tolerant transmission control protocol congestion control
CN105827697A (en) User off-line detection method and user off-line detection system
CN104579746A (en) Method and device for controlling dual-link transmission
CN106790723A (en) The monitoring method of application service, load-balancing device and monitoring device
CN106571973A (en) Heartbeat packet timeout management method and system
CN105721235B (en) A kind of method and apparatus detecting connectivity
CN106375148B (en) Dynamic network heartbeat processing method and terminal in instant messaging
CN104821889B (en) A kind of processing method and equipment of backup message
CN106254814A (en) Method, Service Management Center and the system that a kind of meeting recovers
CN109194521A (en) A kind of flow forwarding method and equipment
CN105553762A (en) Communication method and communication system between domestic appliance and mobile terminal and corresponding devices
CN108958980A (en) Prevent method, electronic device and the computer readable storage medium of Activity life cycle exception
CN108712494A (en) Handle the method, apparatus and equipment of asynchronous message
CN106936784A (en) SIP registration method, terminal and system
CN106713025B (en) A kind of network disaster tolerance method for synchronizing information
CN112073472B (en) Soft zero clearing processing method for counter
CN110278227A (en) Service processing method, device and electronic equipment
CN104735097A (en) Information collecting method and system
CN109947630B (en) Fault notification method, device and storage medium
CN107070872A (en) A kind of data processing method and device for client
CN111818622A (en) Method and device for adjusting communication mode, storage medium and electronic equipment
CN103684884B (en) The method and system of data communication is optimized based on SNMP

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant