CN109525347A - Method for synchronizing time and device - Google Patents

Method for synchronizing time and device Download PDF

Info

Publication number
CN109525347A
CN109525347A CN201710852611.2A CN201710852611A CN109525347A CN 109525347 A CN109525347 A CN 109525347A CN 201710852611 A CN201710852611 A CN 201710852611A CN 109525347 A CN109525347 A CN 109525347A
Authority
CN
China
Prior art keywords
system server
time
section
time point
weighted 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.)
Granted
Application number
CN201710852611.2A
Other languages
Chinese (zh)
Other versions
CN109525347B (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.)
BYD Co Ltd
Original Assignee
BYD 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 BYD Co Ltd filed Critical BYD Co Ltd
Priority to CN201710852611.2A priority Critical patent/CN109525347B/en
Publication of CN109525347A publication Critical patent/CN109525347A/en
Application granted granted Critical
Publication of CN109525347B publication Critical patent/CN109525347B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04JMULTIPLEX COMMUNICATION
    • H04J3/00Time-division multiplex systems
    • H04J3/02Details
    • H04J3/06Synchronising arrangements
    • H04J3/0635Clock or time synchronisation in a network

Abstract

The present invention proposes a kind of method for synchronizing time and device, wherein method includes: the timestamp information that the first system server receives other second system server broadcasts in server group, and timestamp information includes: sending time section;According to the timestamp information of second system server and the receiving time point of the first system server receiving time stamp information, the time interval in preset time point second system server is determined, and then determine coincidence section and its weighted value of each time interval;And then it determines in the standard time section of preset time point the first system server;Adjustment is synchronized to the time of the first system server according to standard time section, so as to according to the time interval of each second system server of preset time point, determine the standard time section of the first system server, adjustment is synchronized to the first system server, the clock error and transmission link mistake that can tolerate part system server, improve the reliability of time synchronization.

Description

Method for synchronizing time and device
Technical field
The present invention relates to field of communication technology more particularly to a kind of method for synchronizing time and device.
Background technique
Currently, including a primary server and multiple subsystems, the method for synchronizing time of subsystem in Time Service System It is to receive the timestamp information that primary server is sent, timestamp information is parsed, sending time is obtained, when according to sending Between adjust oneself time, the time synchronization of each subsystem in service system of holding time.
However, in the prior art, the time synchronization of each subsystem depends on primary server, it is wrong in primary server clock When the error occurs, subsystem is difficult to obtain the correct time, reduces the reliability of time synchronization for mistake or transmission link.
Summary of the invention
The present invention is directed to solve at least some of the technical problems in related technologies.
For this purpose, the first purpose of this invention is to propose a kind of method for synchronizing time, to improve the reliable of time synchronization Property.
Second object of the present invention is to propose a kind of time synchronism apparatus.
Third object of the present invention is to propose a kind of terminal device.
Fourth object of the present invention is to propose a kind of computer readable storage medium.
In order to achieve the above object, first aspect present invention embodiment proposes a kind of method for synchronizing time, comprising:
The first system server receive server group in addition to the first system server other second system servers The timestamp information of broadcast, the timestamp information include: sending time section;The sending time section is according to described the Two system server send the timestamp information sending time point and systematic error determined by time interval;
For each second system server, according to the timestamp information of the second system server and described One system server receives the receiving time point of the timestamp information, determines the second system server described in preset time point Time interval;
According to the time interval in each second system server of preset time point, the weight of each time interval is determined Close section and the weighted value for being overlapped section;
According to each weighted value for being overlapped section, the standard time of the first system server described in preset time point is determined Section;
According to the standard time section of the first system server described in preset time point to the first system server Time synchronize adjustment.
Further, the basis determines each in the time interval of each second system server of preset time point A time interval is overlapped section and the weighted value for being overlapped section, comprising:
According to the time interval in each second system server of preset time point, the weight of each time interval is determined Close section and the coincidence number for being overlapped section;
The weighted value for being overlapped section is determined according to the coincidence number for being overlapped section.
Further, described according to each weighted value for being overlapped section, determine the clothes of the first system described in preset time point The standard time section of business device, comprising:
Each weighted value for being overlapped section is compared with preset filtering weighted value, corresponding weighted value is obtained and is greater than The coincidence section of the filtering weighted value;
The coincidence section that corresponding weighted value is greater than the filtering weighted value is combined, is obtained in preset time point institute State the standard time section of the first system server.
Further, described that each weighted value for being overlapped section is compared with preset filtering weighted value, acquisition pair The weighted value answered is greater than before the coincidence section of the filtering weighted value, further includes:
It is horizontal according to the quantity of system server in the server group and preset Error Tolerance, determine the mistake Filter weighted value.
Further, it is described according to the standard time section of the first system server described in preset time point to described The time of one system server synchronizes adjustment, comprising:
It is modified, is obtained in place according to time interval of the standard time section to each second system server The time interval after the amendment of each second system server in the standard time section;
According to time interval after the amendment of each second system server, calculate after the amendment in time interval Heart time point;
It is determined as the average value of the center time point of each second system server described in the preset time point The standard time point of one system server;
According to the standard time point of the first system server described in preset time point to the first system server Time synchronizes adjustment.
Further, it is described according to the standard time point of the first system server described in preset time point to described first The time of system server synchronizes adjustment, comprising:
Calculate the difference between the preset time point and standard time point;
Adjustment is synchronized according to time of the difference to the first system server.
The method for synchronizing time of the embodiment of the present invention is received by the first system server and removes the first system in server group The timestamp information of other outer second system server broadcasts of server, timestamp information includes: sending time section;When transmission Between section be according to second system server sending time stab information sending time point and systematic error determined by the time Section;For each second system server, according to the timestamp information of second system server and the first system server Receiving time stabs the receiving time point of information, determines the time interval in preset time point second system server;According to pre- If the time interval of time point each second system server, determines the coincidence section of each time interval and be overlapped section Weighted value;According to each weighted value for being overlapped section, determine in the standard time section of preset time point the first system server; Tune is synchronized to the time of the first system server according in the standard time section of preset time point the first system server It is whole, so as to determine the mark of the first system server according to the time interval of each second system server of preset time point Quasi- time interval synchronizes adjustment to the time of the first system server, can tolerate part second system server when Clock mistake and transmission link mistake, improve the reliability of time synchronization.
In order to achieve the above object, second aspect of the present invention embodiment proposes a kind of time synchronism apparatus, comprising:
Receiving module, for receiving, other second system servers are wide in addition to the first system server in server group The timestamp information broadcast, the timestamp information include: sending time section;The sending time section is according to described second System server send the timestamp information sending time point and systematic error determined by time interval;
Determining module is believed for being directed to each second system server according to the timestamp of the second system server Breath and the first system server receive the receiving time point of the timestamp information, determine described in the preset time point The time interval of second system server;
The determining module is also used to according to the time interval in each second system server of preset time point, Determine each time interval is overlapped section and the weighted value for being overlapped section;
The determining module is also used to be determined first described in the preset time point according to each weighted value for being overlapped section The standard time section of system server;
Module is adjusted, for the standard time section according to the first system server described in preset time point to described the The time of one system server synchronizes adjustment.
Further, the determining module is specifically used for,
According to the time interval in each second system server of preset time point, the weight of each time interval is determined Close section and the coincidence number for being overlapped section;
The weighted value for being overlapped section is determined according to the coincidence number for being overlapped section.
Further, the determining module is specifically used for,
Each weighted value for being overlapped section is compared with preset filtering weighted value, corresponding weighted value is obtained and is greater than The coincidence section of the filtering weighted value;
The coincidence section that corresponding weighted value is greater than the filtering weighted value is combined, is obtained in preset time point institute State the standard time section of the first system server.
Further, the determining module is specifically also used to,
It is horizontal according to the quantity of system server in the server group and preset Error Tolerance, determine the mistake Filter weighted value.
Further, the adjustment module includes:
Amending unit, for according to the standard time section to the time interval of each second system server into Row amendment, obtains time interval after the amendment for each second system server being located in the standard time section;
Computing unit calculates the amendment for time interval after the amendment according to each second system server The center time point of time interval afterwards;
Determination unit, for being determined as the average value of the center time point of each second system server pre- If the standard time point of the first system server described in time point;
Adjustment unit, for the standard time point according to the first system server described in preset time point to described first The time of system server synchronizes adjustment.
Further, the adjustment unit is specifically used for,
Calculate the difference between the preset time point and standard time point;
Adjustment is synchronized according to time of the difference to the first system server.
The time synchronism apparatus of the embodiment of the present invention is received by the first system server and removes the first system in server group The timestamp information of other outer second system server broadcasts of server, timestamp information includes: sending time section;When transmission Between section be according to second system server sending time stab information sending time point and systematic error determined by the time Section;For each second system server, according to the timestamp information of second system server and the first system server Receiving time stabs the receiving time point of information, determines the time interval in preset time point second system server;According to pre- If the time interval of time point each second system server, determines the coincidence section of each time interval and be overlapped section Weighted value;According to each weighted value for being overlapped section, determine in the standard time section of preset time point the first system server; Tune is synchronized to the time of the first system server according in the standard time section of preset time point the first system server It is whole, so as to determine the mark of the first system server according to the time interval of each second system server of preset time point Quasi- time interval synchronizes adjustment to the time of the first system server, can tolerate part second system server when Clock mistake and transmission link mistake, improve the reliability of time synchronization.
In order to achieve the above object, third aspect present invention embodiment proposes a kind of terminal device, including memory, processor And the computer program that can be run on a memory and on a processor is stored, when the processor executes described program, realize Method for synchronizing time as described in relation to the first aspect.
To achieve the goals above, fourth aspect present invention embodiment proposes a kind of computer readable storage medium, On be stored with computer program, when which is executed by processor realize first aspect described in method for synchronizing time.
The additional aspect of the present invention and advantage will be set forth in part in the description, and will partially become from the following description Obviously, or practice through the invention is recognized.
Detailed description of the invention
Above-mentioned and/or additional aspect and advantage of the invention will become from the following description of the accompanying drawings of embodiments Obviously and it is readily appreciated that, in which:
Fig. 1 is a kind of flow diagram of method for synchronizing time provided by the embodiment of the present invention;
Fig. 2 is weight-interval graph schematic diagram;
Fig. 3 is the flow diagram of another kind method for synchronizing time provided by the embodiment of the present invention;
Fig. 4 is a kind of structural schematic diagram of time synchronism apparatus provided by the embodiment of the present invention;
Fig. 5 is the structural schematic diagram of another kind time synchronism apparatus provided by the embodiment of the present invention;
Fig. 6 is the schematic diagram of terminal device provided by the embodiment of the present invention.
Specific embodiment
The embodiment of the present invention is described below in detail, examples of the embodiments are shown in the accompanying drawings, wherein from beginning to end Same or similar label indicates same or similar element or element with the same or similar functions.Below with reference to attached The embodiment of figure description is exemplary, it is intended to is used to explain the present invention, and is not considered as limiting the invention.
Below with reference to the accompanying drawings the method for synchronizing time and device of the embodiment of the present invention are described.
Fig. 1 is a kind of flow diagram of method for synchronizing time provided by the embodiment of the present invention.
As shown in Figure 1, the method for synchronizing time the following steps are included:
Step 101, other second systems take in addition to the first system server in the first system server reception server group The timestamp information of business device broadcast, timestamp information includes: sending time section;The sending time section is according to the second system Time interval determined by the sending time point and systematic error of server sending time of uniting stamp information.
The executing subject of method for synchronizing time provided in this embodiment is time synchronism apparatus, and time synchronism apparatus specifically may be used Think that any one server or other equipment in server group for example can communicate and carry out the terminal of time synchronization Deng.Time synchronism apparatus can also be the software or hardware on the server.Wherein, systematic error refers to second system The systematic error of server itself.
In the present embodiment, each system server in server group can be broadcast periodically timestamp information, such as It every 1 second, every 2 seconds etc., is not specifically limited herein, can according to need and set.It needs to be illustrated, server group In each system server can put at the same time broadcast time stamp information.For example, each system server can be 13 points of 0 second 0 minute broadcast times stab information, at this time the sending time point phase of the first system server and each second system server Together, different only systematic error.But since the time of the first system server and each second system server may be different Step, therefore, the first system server and each second system server are not necessarily and stab information in same time broadcast time.
In the present embodiment, sending time section is specifically as follows [t- Δ t, t+ Δ t].
Wherein, t is the sending time point that second system server sending time stabs information;Δ t is second system server Systematic error.
Step 102, for each second system server, according to the timestamp information of second system server, Yi Ji One system server receiving time stabs the receiving time point of information, determines the time zone in preset time point second system server Between.
In the present embodiment, step 102 may include: for each second system server, according to second system server Timestamp information and the first system server receiving time stamp information receiving time point, determine in receiving time point the The time interval of two system server;According to the time interval in receiving time point second system server, determine when default Between put second system server time interval.
Wherein, time synchronism apparatus can first take according to the sending time of second system server point and the first system The receiving time point of device receiving time of being engaged in stamp information, determines the current time in receiving time point second system server;According to In the current time of receiving time point second system server and the systematic error of second system server, determine when receiving Between put second system server time interval.
It remarks additionally, time synchronism apparatus is calculated in the current of receiving time point second system server The algorithm of time, it is identical as the algorithm that subsystem in the prior art adjusts oneself time according to sending time, it can refer to existing Subsystem adjusts the algorithm of oneself time according to sending time in technology, no longer elaborates herein.
In the present embodiment, time synchronism apparatus can stab the time point of information according to second system server sending time, And the possible time error between the first system server and second system server, a time window is determined, at this The timestamp information that second system server is sent is received in time window.And for receiving time point be located at the time window it Outer timestamp information indicates the time between the corresponding second system server of the timestamp information and the first system server Error is too big or the timestamp information is the timestamp information of mistake, therefore does not receive the timestamp information, or receive it After be not used in carry out time synchronizing, to improve the accuracy of time synchronization.
Step 103, according to the time interval in each second system server of preset time point, each time interval is determined Be overlapped section and be overlapped section weighted value.
Wherein, the process that time synchronism apparatus executes step 103 is specifically as follows, according in preset time point each second The time interval of system server determines the coincidence number for being overlapped section and being overlapped section of each time interval;According to weight The number that is overlapped for closing section determines the weighted value for being overlapped section.Wherein, the weighted value for being overlapped section can be the weight in coincidence section Close number.
In the present embodiment, time synchronism apparatus can determine the weight of each time interval by building weight-interval graph The weighted value for closing section and being overlapped section.As shown in Fig. 2, being weight-interval graph schematic diagram.In Fig. 2, in server group Including 7 nodes, wherein there is 6 second system servers to the first system server broadcast timestamp information, 6 second systems Server is respectively PE1, PE2, PE3, PE4, PE5 and PE6.Wherein, viIn the time interval for indicating second system server Center time point, wherein i is equal to 1,2,3,4,5 or 6;[a1, b5] is center time point v1Corresponding time interval;[a2, B4] it is center time point v6Corresponding time interval;[a4, b1] is center time point v5Corresponding time interval;[a5, b3] is Center time point v4Corresponding time interval.In Fig. 2, [a1, a2] is center time point v1One weight of corresponding time interval Section is closed, the coincidence number in the coincidence section is 1;[a2, a3] is center time point v1Corresponding time interval and centre time Point v6One coincidence section of corresponding time interval, the coincidence number in the coincidence section are 2;[a3, a4] is center time point v1 Corresponding time interval, center time point v6Corresponding time interval and center time point v3One of corresponding time interval It is overlapped section, the coincidence number in the coincidence section is 3;Others are overlapped section and its are overlapped number and obtain by a similar method , it is no longer described in detail herein.
Step 104, according to each weighted value for being overlapped section, the standard in preset time point the first system server is determined Time interval.
Wherein, time synchronism apparatus execute step 104 process be specifically as follows, by it is each be overlapped section weighted value with Preset filtering weighted value is compared, and obtains the coincidence section that corresponding weighted value is greater than filtering weighted value;By corresponding power The coincidence section that weight values are greater than filtering weighted value is combined, and obtains the standard time in preset time point the first system server Section.
For example, being illustrated in Fig. 2 with preset filtering weighted value for 3, the horizontal line in Fig. 2 above abscissa is indicated Preset filtering weighted value has 3 greater than the coincidence section of filtering weighted value then in Fig. 2, respectively [a4, a5], [a5, b5],[b5,b4];These three weighted values for being overlapped section are respectively 4,5,4.These three coincidence sections are combined, area is obtained Between [a4, b4], which is determined as in the standard time section of preset time point the first system server.
In addition, it is also necessary to be illustrated, the method for determination of preset filtering weighted value is specifically as follows, according to service The quantity of system server and preset Error Tolerance are horizontal in device group, determine filtering weighted value.
Wherein, Error Tolerance level specifically can be according to the first system server in server group and second system service The total quantity of device is determined.Filter the difference that weighted value can be total quantity and Error Tolerance level.For example, fault tolerant Horizontal half, one third or other ratios that can be less than or equal to total quantity of degree.The Error Tolerance used in Fig. 2 Level is specially 3.
In the present embodiment, the setting of Error Tolerance level, is the method for synchronizing time in order to enable the present embodiment, in portion When dividing timestamp information errors, also can reliably it execute.Error Tolerance is horizontal, indicates the method for synchronizing time of the present embodiment The maximum number of errors that can be tolerated.Such as in Fig. 2, center time point v2The letter of timestamp represented by corresponding time interval Breath is wrong timestamp information.
Step 105, according in the standard time section of preset time point the first system server to the first system server Time synchronize adjustment.
In the present embodiment, time synchronism apparatus can be right according to the gap between preset time point and standard time section The time of the first system server synchronizes adjustment.
In addition, it is also necessary to be illustrated, in above-described embodiment, only by taking a cycle as an example, in server group The time synchronization process of the first system server be illustrated, the time synchronization of other second system servers in server group Process is similar with the time synchronization process of the first system server, can be with reference to the first system server in embodiment illustrated in fig. 1 Time synchronization process.And other periods are directed to, it can also be with reference to the time synchronization of each system server in the said one period Process executes the time synchronization process of system server in other each periods.For other second systems in the said one period The time synchronization process of server and in other periods each system server time synchronization process, no longer carry out herein detailed Thin description.
The method for synchronizing time of the embodiment of the present invention is received by the first system server and removes the first system in server group The timestamp information of other outer second system server broadcasts of server, timestamp information includes: sending time section;When transmission Between section be according to second system server sending time stab information sending time point and systematic error determined by the time Section;For each second system server, according to the timestamp information of second system server and the first system server Receiving time stabs the receiving time point of information, determines the time interval in preset time point second system server;According to pre- If the time interval of time point each second system server, determines the coincidence section of each time interval and be overlapped section Weighted value;According to each weighted value for being overlapped section, determine in the standard time section of preset time point the first system server; Tune is synchronized to the time of the first system server according in the standard time section of preset time point the first system server It is whole, so as to determine the mark of the first system server according to the time interval of each second system server of preset time point Quasi- time interval synchronizes adjustment to the time of the first system server, can tolerate part second system server when Clock mistake and transmission link mistake, improve the reliability of time synchronization.
Fig. 3 is the flow diagram of another method for synchronizing time provided in this embodiment, on the basis of a upper embodiment On, step 105 can specifically include following steps:
Step 1051 is modified the time interval of each second system server according to standard time section, obtains Time interval after the amendment of each second system server in standard time section.
For example, being [a4, b4] in the standard time section of preset time point the first system server, according to mark in Fig. 2 Quasi- time interval is to center time point v1Time interval is after the amendment that corresponding time interval [a1, b5] obtains after being modified [a4,b5];According to standard time section to center time point v6What corresponding time interval [a2, b4] obtained after being modified repairs Time interval is [a4, b4] after just;According to standard time section to center time point v5Corresponding time interval [a4, b1] carries out Time interval is [a4, b4] after the amendment obtained after amendment.The makeover process class of other center time points corresponding time interval Seemingly, it is no longer described in detail herein.
Step 1052, according to time interval after the amendment of each second system server, calculate time interval after amendment Center time point.
For example, in Fig. 2, center time point v1The center time point of time interval [a4, b5] is v after corresponding amendment1′; Center time point v6The center time point of time interval [a4, b4] is v after corresponding amendment6′;Center time point v5Corresponding amendment The center time point of time interval [a4, b4] is v afterwards5', the center time point of time interval is similar after other amendments.
Step 1053, by the average value of the center time point of each second system server, be determined as in preset time point The standard time point of the first system server.
Step 1054, according to preset time point the first system server standard time point to the first system server Time synchronizes adjustment.
Specifically, the process that time synchronism apparatus executes step 1054 is specifically as follows, preset time point and standard are calculated Difference between time point;Adjustment is synchronized according to time of the difference to the first system server.
For example, if the difference between preset time point and standard time point is positive value, then it represents that the first system server Clock is too fast, then the clock of the first system server is slowed down the difference;If between preset time point and standard time point Difference is negative value, then it represents that the clock of the first system server is excessively slow, then the clock of the first system server is tuned up the difference The absolute value of value.
The method for synchronizing time of the embodiment of the present invention is received by the first system server and removes the first system in server group The timestamp information of other outer second system server broadcasts of server, timestamp information includes: sending time section;When transmission Between section be according to second system server sending time stab information sending time point and systematic error determined by the time Section;For each second system server, according to the timestamp information of second system server and the first system server Receiving time stabs the receiving time point of information, determines the time interval in preset time point second system server;According to pre- If the time interval of time point each second system server, determines the coincidence section of each time interval and be overlapped section Weighted value;According to each weighted value for being overlapped section, determine in the standard time section of preset time point the first system server; The time interval of each second system server is modified according to standard time section, obtains being located in standard time section Each second system server amendment after time interval;According to time interval after the amendment of each second system server, Calculate the center time point of time interval after correcting;By the average value of the center time point of each second system server, determine For in the standard time point of preset time point the first system server;According to the standard in preset time point the first system server Time point synchronizes adjustment to the time of the first system server, so as to be taken according to each second system of preset time point The time interval of business device, determines the standard time section of the first system server, carries out to the time of the first system server same Successive step can tolerate the clock error and transmission link mistake of part second system server, improve time synchronization Reliability.
In order to realize above-described embodiment, the present invention also proposes a kind of time synchronism apparatus.
Fig. 4 is a kind of structural schematic diagram of time synchronism apparatus provided in an embodiment of the present invention.As shown in figure 4, the time Synchronizing device includes: receiving module 41, determining module 42 and adjustment module 43.
Wherein, receiving module 41, for receiving in server group other second systems in addition to the first system server The timestamp information of server broadcast, the timestamp information include: sending time section;According to the sending time section The second system server send the timestamp information sending time point and systematic error determined by time interval;
Determining module 42, for being directed to each second system server, according to the timestamp of the second system server Information and the first system server receive the receiving time point of the timestamp information, determine in preset time point institute State the time interval of second system server;
The determining module 42 is also used to according to the time zone in each second system server of preset time point Between, determine each time interval is overlapped section and the weighted value for being overlapped section;
The determining module 42, is also used to according to each weighted value for being overlapped section, determines described in the preset time point the The standard time section of one system server;
Adjust module 43, for according to the standard time section of the first system server described in preset time point to described The time of the first system server synchronizes adjustment.
Time synchronism apparatus provided in this embodiment is specifically as follows any one server in server group, Huo Zheqi His equipment can for example communicate and carry out the terminal etc. of time synchronization.Time synchronism apparatus can also be soft on the server Part or hardware.Wherein, systematic error refers to the systematic error of second system server itself.
In the present embodiment, each system server in server group can be broadcast periodically timestamp information, such as It every 1 second, every 2 seconds etc., is not specifically limited herein, can according to need and set.It needs to be illustrated, server group In each system server can put at the same time broadcast time stamp information.For example, each system server can be 13 points of 0 second 0 minute broadcast times stab information, at this time the sending time point phase of the first system server and each second system server Together, different only systematic error.But since the time of the first system server and each second system server may be different Step, therefore, the first system server and each second system server are not necessarily and stab information in same time broadcast time.
In the present embodiment, time synchronism apparatus can stab the time point of information according to second system server sending time, And the possible time error between the first system server and second system server, a time window is determined, at this The timestamp information that second system server is sent is received in time window.And for receiving time point be located at the time window it Outer timestamp information indicates the time between the corresponding second system server of the timestamp information and the first system server Error is too big or the timestamp information is the timestamp information of mistake, therefore does not receive the timestamp information, or receive it After be not used in carry out time synchronizing, to improve the accuracy of time synchronization.
In the present embodiment, time synchronism apparatus can be right according to the gap between preset time point and standard time section The time of the first system server synchronizes adjustment.
In addition, it is also necessary to be illustrated, in above-described embodiment, only by taking a cycle as an example, in server group The time synchronization process of the first system server be illustrated, the time synchronization of other second system servers in server group Process is similar with the time synchronization process of the first system server, can be with reference to the first system server in embodiment illustrated in fig. 1 Time synchronization process.And other periods are directed to, it can also be with reference to the time synchronization of each system server in the said one period Process executes the time synchronization process of system server in other each periods.For other second systems in the said one period The time synchronization process of server and in other periods each system server time synchronization process, no longer carry out herein detailed Thin description.
Further, the determining module 42 is specifically used for,
According to the time interval in each second system server of preset time point, the weight of each time interval is determined Close section and the coincidence number for being overlapped section;
The weighted value for being overlapped section is determined according to the coincidence number for being overlapped section.
Wherein, time synchronism apparatus can first take according to the sending time of second system server point and the first system The receiving time point of device receiving time of being engaged in stamp information, determines the current time in receiving time point second system server;According to In the current time of receiving time point second system server and the systematic error of second system server, determine when receiving Between put second system server time interval.
It remarks additionally, time synchronism apparatus is calculated in the current of receiving time point second system server The algorithm of time, it is identical as the algorithm that subsystem in the prior art adjusts oneself time according to sending time, it can refer to existing Subsystem adjusts the algorithm of oneself time according to sending time in technology, no longer elaborates herein.
Wherein, time synchronism apparatus determines each according to the time interval in each second system server of preset time point The process of the weighted value in the coincidence section and coincidence section of a time interval is specifically as follows, according to each in preset time point The time interval of second system server determines the coincidence number for being overlapped section and being overlapped section of each time interval;Root According to the weighted value for being overlapped number and determining coincidence section for being overlapped section.Wherein, the weighted value for being overlapped section can be coincidence section Coincidence number.
Further, the determining module 42 is specifically used for,
Each weighted value for being overlapped section is compared with preset filtering weighted value, corresponding weighted value is obtained and is greater than The coincidence section of the filtering weighted value;
The coincidence section that corresponding weighted value is greater than the filtering weighted value is combined, is obtained in preset time point institute State the standard time section of the first system server.
Further, the determining module 42 is specifically also used to,
It is horizontal according to the quantity of system server in the server group and preset Error Tolerance, determine the mistake Filter weighted value.
Wherein, Error Tolerance level specifically can be according to the first system server in server group and second system service The total quantity of device is determined.Filter the difference that weighted value can be total quantity and Error Tolerance level.For example, fault tolerant Horizontal half, one third or other ratios that can be less than or equal to total quantity of degree.The Error Tolerance used in Fig. 2 Level is specially 3.
In the present embodiment, the setting of Error Tolerance level, is the method for synchronizing time in order to enable the present embodiment, in portion When dividing timestamp information errors, also can reliably it execute.Error Tolerance is horizontal, indicates the method for synchronizing time of the present embodiment The maximum number of errors that can be tolerated.
The time synchronism apparatus of the embodiment of the present invention is received by the first system server and removes the first system in server group The timestamp information of other outer second system server broadcasts of server, timestamp information includes: sending time section;When transmission Between section be according to second system server sending time stab information sending time point and systematic error determined by the time Section;For each second system server, according to the timestamp information of second system server and the first system server Receiving time stabs the receiving time point of information, determines the time interval in preset time point second system server;According to pre- If the time interval of time point each second system server, determines the coincidence section of each time interval and be overlapped section Weighted value;According to each weighted value for being overlapped section, determine in the standard time section of preset time point the first system server; Tune is synchronized to the time of the first system server according in the standard time section of preset time point the first system server It is whole, so as to determine the mark of the first system server according to the time interval of each second system server of preset time point Quasi- time interval synchronizes adjustment to the time of the first system server, can tolerate part second system server when Clock mistake and transmission link mistake, improve the reliability of time synchronization.
Further, in conjunction with reference Fig. 5, on the basis of the embodiment shown in fig. 4, the adjustment module 43 includes:
Amending unit 431, for the time zone according to the standard time section to each second system server Between be modified, obtain be located at the standard time section in each second system server amendment after time zone Between;
Computing unit 432 is repaired described in calculating for time interval after the amendment according to each second system server The center time point of time interval after just;
Determination unit 433, for being determined as the average value of the center time point of each second system server The standard time point of the first system server described in preset time point;
Adjustment unit 434, for the standard time point according to the first system server described in preset time point to described The time of the first system server synchronizes adjustment.
Further, the adjustment unit 434 is specifically used for,
Calculate the difference between the preset time point and standard time point;
Adjustment is synchronized according to time of the difference to the first system server.
For example, if the difference between preset time point and standard time point is positive value, then it represents that the first system server Clock is too fast, then the clock of the first system server is slowed down the difference;If between preset time point and standard time point Difference is negative value, then it represents that the clock of the first system server is excessively slow, then the clock of the first system server is tuned up the difference The absolute value of value.
The time synchronism apparatus of the embodiment of the present invention is received by the first system server and removes the first system in server group The timestamp information of other outer second system server broadcasts of server, timestamp information includes: sending time section;When transmission Between section be according to second system server sending time stab information sending time point and systematic error determined by the time Section;For each second system server, according to the timestamp information of second system server and the first system server Receiving time stabs the receiving time point of information, determines the time interval in preset time point second system server;According to pre- If the time interval of time point each second system server, determines the coincidence section of each time interval and be overlapped section Weighted value;According to each weighted value for being overlapped section, determine in the standard time section of preset time point the first system server; The time interval of each second system server is modified according to standard time section, obtains being located in standard time section Each second system server amendment after time interval;According to time interval after the amendment of each second system server, Calculate the center time point of time interval after correcting;By the average value of the center time point of each second system server, determine For in the standard time point of preset time point the first system server;According to the standard in preset time point the first system server Time point synchronizes adjustment to the time of the first system server, so as to be taken according to each second system of preset time point The time interval of business device, determines the standard time section of the first system server, carries out to the time of the first system server same Successive step can tolerate the clock error and transmission link mistake of part second system server, improve time synchronization Reliability.
It should be noted that the aforementioned time for being also applied for the embodiment to the explanation of method for synchronizing time embodiment Synchronizing device, details are not described herein again.
In order to realize above-described embodiment, the present invention also proposes that a kind of terminal device, Fig. 6 are end provided in an embodiment of the present invention The structural schematic diagram of end equipment.The terminal device includes:
Memory 601, processor 602 and it is stored in the computer journey that can be run on memory 601 and on processor 602 Sequence.
Processor 602 realizes the method for synchronizing time provided in Fig. 1 or embodiment illustrated in fig. 3 when executing described program.
Further, time synchronism apparatus further include:
Communication interface 603, for the communication between memory 601 and processor 602.
Memory 601, for storing the computer program that can be run on processor 602.
Memory 601 may include high speed RAM memory, it is also possible to further include nonvolatile memory (non- Volatile memory), a for example, at least magnetic disk storage.
Processor 602 realizes method for synchronizing time described in Fig. 1 or embodiment illustrated in fig. 3 when for executing described program.
If memory 601, processor 602 and the independent realization of communication interface 603, communication interface 603, memory 601 It can be connected with each other by bus with processor 602 and complete mutual communication.The bus can be Industry Standard Architecture Structure (Industry Standard Architecture, referred to as ISA) bus, external equipment interconnection (Peripheral Component, referred to as PCI) bus or extended industry-standard architecture (Extended Industry Standard Architecture, referred to as EISA) bus etc..The bus can be divided into address bus, data/address bus, control bus etc.. Only to be indicated with a thick line in Fig. 6, it is not intended that an only bus or a type of bus convenient for indicating.
Optionally, in specific implementation, if memory 601, processor 602 and communication interface 603, it is integrated in one piece of core On piece realizes that then memory 601, processor 602 and communication interface 603 can complete mutual communication by internal interface.
Processor 602 may be a central processing unit (Central Processing Unit, referred to as CPU), or It is specific integrated circuit (Application Specific Integrated Circuit, referred to as ASIC), or is matched It is set to the one or more integrated circuits for implementing the embodiment of the present invention.
In order to realize above-described embodiment, the present invention also proposes a kind of computer readable storage medium, is stored thereon with calculating Machine program realizes method for synchronizing time described in previous embodiment when the program is executed by processor.
In the description of this specification, reference term " one embodiment ", " some embodiments ", " example ", " specifically show The description of example " or " some examples " etc. means specific features, structure, material or spy described in conjunction with this embodiment or example Point is included at least one embodiment or example of the invention.In the present specification, schematic expression of the above terms are not It must be directed to identical embodiment or example.Moreover, particular features, structures, materials, or characteristics described can be in office It can be combined in any suitable manner in one or more embodiment or examples.In addition, without conflicting with each other, the skill of this field Art personnel can tie the feature of different embodiments or examples described in this specification and different embodiments or examples It closes and combines.
In addition, term " first ", " second " are used for descriptive purposes only and cannot be understood as indicating or suggesting relative importance Or implicitly indicate the quantity of indicated technical characteristic.Define " first " as a result, the feature of " second " can be expressed or Implicitly include at least one this feature.In the description of the present invention, the meaning of " plurality " is at least two, such as two, three It is a etc., unless otherwise specifically defined.
Any process described otherwise above or method description are construed as in flow chart or herein, and expression includes It is one or more for realizing custom logic function or process the step of executable instruction code module, segment or portion Point, and the range of the preferred embodiment of the present invention includes other realization, wherein can not press shown or discussed suitable Sequence, including according to related function by it is basic simultaneously in the way of or in the opposite order, Lai Zhihang function, this should be of the invention Embodiment person of ordinary skill in the field understood.
Expression or logic and/or step described otherwise above herein in flow charts, for example, being considered use In the order list for the executable instruction for realizing logic function, may be embodied in any computer-readable medium, for Instruction execution system, device or equipment (such as computer based system, including the system of processor or other can be held from instruction The instruction fetch of row system, device or equipment and the system executed instruction) it uses, or combine these instruction execution systems, device or set It is standby and use.For the purpose of this specification, " computer-readable medium ", which can be, any may include, stores, communicates, propagates or pass Defeated program is for instruction execution system, device or equipment or the dress used in conjunction with these instruction execution systems, device or equipment It sets.The more specific example (non-exhaustive list) of computer-readable medium include the following: there is the electricity of one or more wirings Interconnecting piece (electronic device), portable computer diskette box (magnetic device), random access memory (RAM), read-only memory (ROM), erasable edit read-only storage (EPROM or flash memory), fiber device and portable optic disk is read-only deposits Reservoir (CDROM).In addition, computer-readable medium can even is that the paper that can print described program on it or other are suitable Medium, because can then be edited, be interpreted or when necessary with it for example by carrying out optical scanner to paper or other media His suitable method is handled electronically to obtain described program, is then stored in computer storage.
It should be appreciated that each section of the invention can be realized with hardware, software, firmware or their combination.Above-mentioned In embodiment, software that multiple steps or method can be executed in memory and by suitable instruction execution system with storage Or firmware is realized.Such as, if realized with hardware in another embodiment, following skill well known in the art can be used Any one of art or their combination are realized: have for data-signal is realized the logic gates of logic function from Logic circuit is dissipated, the specific integrated circuit with suitable combinational logic gate circuit, programmable gate array (PGA), scene can compile Journey gate array (FPGA) etc..
Those skilled in the art are understood that realize all or part of step that above-described embodiment method carries It suddenly is that relevant hardware can be instructed to complete by program, the program can store in a kind of computer-readable storage medium In matter, which when being executed, includes the steps that one or a combination set of embodiment of the method.
It, can also be in addition, each functional unit in each embodiment of the present invention can integrate in a processing module It is that each unit physically exists alone, can also be integrated in two or more units in a module.Above-mentioned integrated mould Block both can take the form of hardware realization, can also be realized in the form of software function module.The integrated module is such as Fruit is realized and when sold or used as an independent product in the form of software function module, also can store in a computer In read/write memory medium.
Storage medium mentioned above can be read-only memory, disk or CD etc..Although having been shown and retouching above The embodiment of the present invention is stated, it is to be understood that above-described embodiment is exemplary, and should not be understood as to limit of the invention System, those skilled in the art can be changed above-described embodiment, modify, replace and become within the scope of the invention Type.

Claims (14)

1. a kind of method for synchronizing time characterized by comprising
The first system server receive server group in addition to the first system server other second system server broadcasts Timestamp information, the timestamp information includes: sending time section;The sending time section is according to second system System server send the timestamp information sending time point and systematic error determined by time interval;
For each second system server, according to the timestamp information of the second system server and first system System server receives the receiving time point of the timestamp information, determine the second system server described in preset time point when Between section;
According to the time interval in each second system server of preset time point, the coincidence area of each time interval is determined Between and it is described be overlapped section weighted value;
According to each weighted value for being overlapped section, the standard time area of the first system server described in preset time point is determined Between;
According to the first system server described in preset time point standard time section to the first system server when Between synchronize adjustment.
2. the method according to claim 1, wherein the basis is in each second system of preset time point The time interval of server, determine each time interval is overlapped section and the weighted value for being overlapped section, comprising:
According to the time interval in each second system server of preset time point, the coincidence area of each time interval is determined Between and it is described be overlapped section coincidence number;
The weighted value for being overlapped section is determined according to the coincidence number for being overlapped section.
3. the method according to claim 1, wherein the weighted value according to each coincidence section, determines The standard time section of the first system server described in preset time point, comprising:
Each weighted value for being overlapped section is compared with preset filtering weighted value, obtains corresponding weighted value greater than described Filter the coincidence section of weighted value;
The coincidence section that corresponding weighted value is greater than the filtering weighted value is combined, obtains described in the preset time point the The standard time section of one system server.
4. according to the method described in claim 3, it is characterized in that, described by each weighted value for being overlapped section and preset mistake Filter weighted value is compared, and obtains corresponding weighted value and is greater than before the coincidence section of the filtering weighted value, further includes:
It is horizontal according to the quantity of system server in the server group and preset Error Tolerance, determine the filtering power Weight values.
5. the method according to claim 1, wherein described according to the first system service described in preset time point The standard time section of device synchronizes adjustment to the time of the first system server, comprising:
It is modified according to time interval of the standard time section to each second system server, obtains being located at institute State time interval after the amendment of each second system server in standard time section;
According to time interval after the amendment of each second system server, when calculating the center of time interval after the amendment Between point;
By the average value of the center time point of each second system server, it is determined as the first system described in preset time point The standard time point of system server;
According to the standard time point of the first system server described in preset time point to the time of the first system server Synchronize adjustment.
6. according to the method described in claim 5, it is characterized in that, described according to the first system service described in preset time point The standard time point of device synchronizes adjustment to the time of the first system server, comprising:
Calculate the difference between the preset time point and standard time point;
Adjustment is synchronized according to time of the difference to the first system server.
7. a kind of time synchronism apparatus characterized by comprising
Receiving module, for receiving in server group other second system server broadcasts in addition to the first system server Timestamp information, the timestamp information include: sending time section;The sending time section is according to the second system Server send the timestamp information sending time point and systematic error determined by time interval;
Determining module, for being directed to each second system server, according to the timestamp information of the second system server, with And the first system server receives the receiving time point of the timestamp information, determines the second system described in preset time point The time interval of system server;
The determining module is also used to be determined according to the time interval in each second system server of preset time point Each time interval is overlapped section and the weighted value for being overlapped section;
The determining module is also used to determine the first system described in preset time point according to each weighted value for being overlapped section The standard time section of server;
Module is adjusted, for the standard time section according to the first system server described in preset time point to first system The time of system server synchronizes adjustment.
8. device according to claim 7, which is characterized in that the determining module is specifically used for,
According to the time interval in each second system server of preset time point, the coincidence area of each time interval is determined Between and it is described be overlapped section coincidence number;
The weighted value for being overlapped section is determined according to the coincidence number for being overlapped section.
9. device according to claim 7, which is characterized in that the determining module is specifically used for,
Each weighted value for being overlapped section is compared with preset filtering weighted value, obtains corresponding weighted value greater than described Filter the coincidence section of weighted value;
The coincidence section that corresponding weighted value is greater than the filtering weighted value is combined, obtains described in the preset time point the The standard time section of one system server.
10. device according to claim 9, which is characterized in that the determining module is specifically also used to,
It is horizontal according to the quantity of system server in the server group and preset Error Tolerance, determine the filtering power Weight values.
11. device according to claim 7, which is characterized in that the adjustment module includes:
Amending unit, for being repaired according to time interval of the standard time section to each second system server Just, obtain be located at the standard time section in each second system server amendment after time interval;
Computing unit, for time interval after the amendment according to each second system server, when calculating after the amendment Between section center time point;
Determination unit, for being determined as the average value of the center time point of each second system server when default Between put the standard time point of the first system server;
Adjustment unit, for the standard time point according to the first system server described in preset time point to the first system The time of server synchronizes adjustment.
12. device according to claim 11, which is characterized in that the adjustment unit is specifically used for,
Calculate the difference between the preset time point and standard time point;
Adjustment is synchronized according to time of the difference to the first system server.
13. a kind of terminal device, which is characterized in that on a memory and can be in processor including memory, processor and storage The computer program of upper operation when the processor executes described program, realizes such as the time as claimed in any one of claims 1 to 6 Synchronous method.
14. a kind of computer readable storage medium, is stored thereon with computer program, which is characterized in that the program is by processor Such as method for synchronizing time as claimed in any one of claims 1 to 6 is realized when execution.
CN201710852611.2A 2017-09-19 2017-09-19 Method for synchronizing time and device Active CN109525347B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710852611.2A CN109525347B (en) 2017-09-19 2017-09-19 Method for synchronizing time and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710852611.2A CN109525347B (en) 2017-09-19 2017-09-19 Method for synchronizing time and device

Publications (2)

Publication Number Publication Date
CN109525347A true CN109525347A (en) 2019-03-26
CN109525347B CN109525347B (en) 2019-11-22

Family

ID=65769613

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710852611.2A Active CN109525347B (en) 2017-09-19 2017-09-19 Method for synchronizing time and device

Country Status (1)

Country Link
CN (1) CN109525347B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110225119A (en) * 2019-06-13 2019-09-10 平安科技(深圳)有限公司 Method of data synchronization and relevant device
WO2022227318A1 (en) * 2021-04-30 2022-11-03 北京国科天迅科技有限公司 Time synchronization method and apparatus, and computer device and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102354288A (en) * 2011-06-22 2012-02-15 航天东方红卫星有限公司 Imaging quality priority task scheduling method
CN103544289A (en) * 2013-10-28 2014-01-29 公安部第三研究所 Feature extraction achieving method based on deploy and control data mining
CN105827350A (en) * 2015-01-04 2016-08-03 中国移动通信集团公司 Information synchronization method and network equipment
US20170235492A1 (en) * 2016-02-05 2017-08-17 Huawei Technologies Co., Ltd. Heartbeat-based data synchronization apparatus and method, and distributed storage system

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102354288A (en) * 2011-06-22 2012-02-15 航天东方红卫星有限公司 Imaging quality priority task scheduling method
CN103544289A (en) * 2013-10-28 2014-01-29 公安部第三研究所 Feature extraction achieving method based on deploy and control data mining
CN105827350A (en) * 2015-01-04 2016-08-03 中国移动通信集团公司 Information synchronization method and network equipment
US20170235492A1 (en) * 2016-02-05 2017-08-17 Huawei Technologies Co., Ltd. Heartbeat-based data synchronization apparatus and method, and distributed storage system

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110225119A (en) * 2019-06-13 2019-09-10 平安科技(深圳)有限公司 Method of data synchronization and relevant device
CN110225119B (en) * 2019-06-13 2022-09-16 平安科技(深圳)有限公司 Data synchronization method and related equipment
WO2022227318A1 (en) * 2021-04-30 2022-11-03 北京国科天迅科技有限公司 Time synchronization method and apparatus, and computer device and storage medium

Also Published As

Publication number Publication date
CN109525347B (en) 2019-11-22

Similar Documents

Publication Publication Date Title
US9319239B2 (en) Data network with a time synchronization system
US7996714B2 (en) Systems and methods for redundancy management in fault tolerant computing
US9647880B2 (en) Real-time distributed network slave device, real-time distributed network and method therefor
US9167058B2 (en) Timestamp correction in a multi-lane communication link with skew
JPH05307424A (en) Method for controlling clock time in computer network
US9917667B2 (en) Host-to-host test scheme for periodic parameters transmission in synchronized TTP systems
CN102932905A (en) Method and system for realizing self-compensation 1588 link asynchronous time delay
SE452231B (en) PROCEDURE FOR SYNCHRONIZING CLOCKS INTO A LOCAL BUS TYPE NETWORK
CN109525347B (en) Method for synchronizing time and device
US20040158362A1 (en) Bus system consisting of at least two data buses
CN109600186A (en) Clock synchronizing method and device
EP3076572A1 (en) Clock synchronization method for multiple clock domains, line card, and ethernet device
US11239989B2 (en) In-vehicle communication device and time synchronization method thereof
CN113424466B (en) Method and device for clock synchronization
CN103905136A (en) Time synchronization processing method and device
JP2005513909A (en) Clock synchronization with fault tolerance
CN104639796B (en) A kind of monitoring server and its method for controlling video source device time synchronized
CN107636627A (en) Time synchronizer, time synchronization system and method for synchronizing time
CN106160909A (en) The processing method and processing device of leap second saltus step
Borran et al. Quantitative analysis of consensus algorithms
US20060156061A1 (en) Fault-tolerant computer and method of controlling same
CN112511255B (en) Time synchronization method and device
CN105491433B (en) Audio video synchronization display methods and device and splice displaying system based on 1588V2 agreement
CN102064826B (en) All-digital clock generation circuit and all-digital clock generation method
CN105323086A (en) Synchronization time source selection indication method, device and system

Legal Events

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