CN108964822A - A kind of multi-scheme obtains the method and system of network time parallel - Google Patents

A kind of multi-scheme obtains the method and system of network time parallel Download PDF

Info

Publication number
CN108964822A
CN108964822A CN201810694712.6A CN201810694712A CN108964822A CN 108964822 A CN108964822 A CN 108964822A CN 201810694712 A CN201810694712 A CN 201810694712A CN 108964822 A CN108964822 A CN 108964822A
Authority
CN
China
Prior art keywords
time
network
network time
server
considered
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
CN201810694712.6A
Other languages
Chinese (zh)
Other versions
CN108964822B (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.)
Chongqing fun play Technology Co., Ltd
Original Assignee
Sichuan Feixun Information Technology 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 Sichuan Feixun Information Technology Co Ltd filed Critical Sichuan Feixun Information Technology Co Ltd
Priority to CN201810694712.6A priority Critical patent/CN108964822B/en
Publication of CN108964822A publication Critical patent/CN108964822A/en
Application granted granted Critical
Publication of CN108964822B publication Critical patent/CN108964822B/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
    • H04J3/0638Clock or time synchronisation among nodes; Internode synchronisation
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04JMULTIPLEX COMMUNICATION
    • H04J3/00Time-division multiplex systems
    • H04J3/02Details
    • H04J3/06Synchronising arrangements
    • H04J3/0635Clock or time synchronisation in a network
    • H04J3/0638Clock or time synchronisation among nodes; Internode synchronisation
    • H04J3/0658Clock or time synchronisation among packet nodes
    • H04J3/0661Clock or time synchronisation among packet nodes using timestamps

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer And Data Communications (AREA)

Abstract

Inventive network field of communication technology is related to the method and system that a kind of multi-scheme obtains network time parallel.The method of the present invention includes S1, issues the request of acquisition time to time synchronization server, hypertext transfer protocol server parallel and issues the request of subscription time theme to message queue telemetering transmission server;S2, waiting for server response, obtains the first network time that the time synchronization server is replied and/or the second network time that the hypertext transfer protocol server is replied and/or message queue telemetering transmission services the third network time replied;S3, by application condition algorithm from the first network time and/or second network time and/or the third network time fall into a trap point counting be precipitated the optimum network time be considered as the grid time.The present invention can successfully obtain network time in different operators route.

Description

A kind of multi-scheme obtains the method and system of network time parallel
Technical field
The invention belongs to a kind of methods that network communication technology field more particularly to multi-scheme obtain network time parallel And system.
Background technique
Internet of Things is the important component of generation information technology, and the important development stage in " informationization " epoch. IoT (Internet Of Things, Internet of Things) equipment is more and more abundant at present, but overwhelming majority IoT equipment is without power supply Chip, cannot itself direct proof time, need to correspond to the server of transport layer by the protocol access of transport layer come when obtaining Between.
Application No. is the domestic patents of invention of CN201710167687.1 to disclose a kind of network time acquisition methods, dress It sets and system, readable medium and storage control, the method for specifically disclosing includes: to preset at least two ntp servers Address;S1: from each ntp server address, determine that at least one can get from corresponding NTP time server The available ntp server address of network time;S2: the NTP time corresponding from each available ntp server address is determined respectively Acquisition duration needed for getting network time on server;S3: when determining most short acquisition duration, and marking with most short acquisition Long corresponding available NTP server address;S4: according to predetermined period from the corresponding NTP in available ntp server address of label Network time is obtained on time server, executes S5;S5: judging whether to get network time, if so, S4 is executed, it is no, Successively execute S1, S2, S3.The technical solution can be relatively reliable get network time.
But the IoT equipment time acquisition modes of mainstream are to default the NTP (Network used using system bottom at present Time Protocol, Network Time Protocol) agreement, but most of NTP Server (network time synchronization server) are all provided with It sets at abroad, not being local self-built server, so part operator route may shield NTP Server or udp (User Datagram Protocol, User Datagram Protocol) 123 ports (port that transport layer udp protocol uses, port Number for 123), the time cannot be successfully got when so as to cause IoT equipment from NTP Server acquisition time, thus further The application of having time stamp verification is influenced, such as: when intelligent sound box plays music, part music sources provider can checking time Stamp can not then play music once it is not right the sound box system time occur.
So we need to design it is a kind of can effective guarantee different operators route can succeed and promptly obtain The method of network time.
Summary of the invention
In view of the problems of the existing technology the present invention, proposes a kind of method that multi-scheme obtains network time parallel And system.
The technical scheme is that:
A kind of method that multi-scheme obtains network time parallel, comprising the following steps:
S1, parallel to time synchronization server, hypertext transfer protocol server issue acquisition time request and to Message queue telemetering transmission server issues the request for subscribing to time theme;
S2, waiting for server response obtain first network time that the time synchronization server is replied and/or described The second network time and/or message queue telemetering transmission service that hypertext transfer protocol server is replied reply the Three network times;
S3, by application condition algorithm from the first network time and/or second network time and/or described Third network time fall into a trap point counting be precipitated the optimum network time be considered as the grid time.
The technical program has the beneficial effect that
To the time synchronization server, the hypertext transfer protocol server and described disappeared by parallel form Breath three kinds of servers of queue telemetering transmission server are simultaneously emitted by the request of acquisition time, wait the response of each server, increase The probability of reply is received, while if application condition calculation can also be passed therethrough when receiving the reply of more than one server Method therefrom calculates the system time for analyzing the optimum network time as internet of things equipment, and energy effective guarantee is in different operators Route can succeed and promptly obtain network time.
As the preferred of the technical program, the step S2 includes:
And count the number of servers of respond request.
As the preferred of the technical program, the step S3 includes:
S3.1 judges whether an only server respond request, if the determination result is YES, then directly the server The network time of reply is calculated as the grid time;If judging result is no, execution step S3.2;
The step S3.2 judges whether that only two-server respond request if the determination result is YES then compares two The network time that platform server is replied, a kind of turnaround time shorter network time is calculated as system time;If judging result is It is no, then directly hold step S3.3;
S3.3 counts the first network time, second network time and the third network time two-by-two It calculates, the first network time, second network time and the third network time three is obtained according to application condition algorithm It is calculated among person and analyzes the optimum network time and be considered as the grid time.
As the preferred of the technical program, the step S3.2 includes:
S3.21 judges whether only two-server respond request, if judging result be it is no, directly execute described in Step S3.3;
S3.22, judges whether the time interval between two kinds of network times is less than prefixed time interval, if judging result Be it is no, then choosing a kind of network time replied at first is considered as system time;If the determination result is YES, then access time stabs more A kind of big network time is considered as system time.
As the preferred of the technical program, the step S3.3 includes:
S3.31 was compared among the first network time, second network time and the third network time A kind of timestamp maximum network time;
S3.32 chooses any network time and the maximum network of timestamp in addition to timestamp maximum network time Time is compared, and judges whether the time interval between two kinds of network times is less than prefixed time interval, if judging result is No, then choosing the network time first replied is considered as system time;If the determination result is YES, S3.33 is thened follow the steps;
The step S3.23, chooses remaining finally a kind of network time and timestamp maximum network time is compared Compared with, judge whether the time interval between two kinds of network times is less than prefixed time interval, if judging result be it is no, choose A kind of network time first replied is considered as system time;If the determination result is YES, S3.34 is thened follow the steps
The step S3.24 chooses remaining two kinds of network times in addition to timestamp maximum network time and is compared Compared with, judge whether the time interval between two kinds of network times is less than prefixed time interval, if judging result be it is no, choose A kind of network time first replied is considered as system time;If the determination result is YES, then access time stamp teaches big network time view For system time.
A kind of system that multi-scheme obtains network time parallel, comprising:
Parallel requests module, when being obtained for being issued parallel to time synchronization server, hypertext transfer protocol server Between request and to message queue telemetering transmission server issue subscribe to time theme request;
Module is obtained, is responded for waiting for server, the first network time that the time synchronization server is replied is obtained And/or the second network time and/or the message queue telemetering transmission service of the hypertext transfer protocol server reply The third network time of reply;
Computation analysis module, for passing through application condition algorithm from the first network time and/or second network Time and/or the third network time fall into a trap point counting be precipitated the optimum network time be considered as the grid time.
As the preferred of the technical program, the acquisition module includes:
Statistic unit, for counting the number of servers of respond request.
As the preferred of the technical program, the computation analysis module includes:
Judging unit, for judging whether an only server respond request, if the determination result is YES, then direct handle The network time that the server is replied is calculated as the grid time;If judging result is no, execution the first calculating analytical unit;
Described first calculates analytical unit, for judging whether only two-server respond request, if judging result is It is the network time for then comparing two-server reply, the optimum network time is analyzed according to application condition algorithm and is considered as system Network time;If judging result be it is no, directly execute second calculate analytical unit;
Described second calculates analytical unit, for the first network time, second network time and described the Three network times were calculated two-by-two, obtained the first network time, second network time according to application condition algorithm It analyzes the optimum network time with being calculated among the third network time three and is considered as the grid time.
As the preferred of the technical program, the first calculating analytical unit includes:
First judgment sub-unit, for judging whether only two-server respond request, if judging result be it is no, It then directly executes described second and calculates analytical unit;
Whether the second judgment sub-unit, the time interval for judging between two kinds of network times are less than between preset time Every, if judging result be it is no, choosing a kind of network time replied at first is considered as system time;If the determination result is YES, then A kind of access time stamp bigger network time is considered as system time.
As the preferred of the technical program, the second calculating analytical unit includes:
Comparing subunit, for comparing the first network time, second network time and the third network Timestamp maximum a kind of network time among time;
Third judgment sub-unit, for choose in addition to timestamp maximum network time any network time, with the time Stabbing maximum network time is compared, and judges whether the time interval between two kinds of network times is less than prefixed time interval, If judging result be it is no, choosing the network time first replied is considered as system time;If the determination result is YES, then the 4th is executed Judgment sub-unit;
4th judgment sub-unit, when for choosing a kind of remaining last network time and the maximum network of timestamp Between be compared, judge whether the time interval between two kinds of network times is less than prefixed time interval, if judging result is No, then choosing the network time first replied is considered as system time;If the determination result is YES, then the 5th judgment sub-unit is executed;
5th judgment sub-unit, for choosing in addition to timestamp maximum network time when remaining two kinds of networks Between be compared, judge whether the time interval between two kinds of network times is less than prefixed time interval, if judging result is No, then choosing the network time first replied is considered as system time;If the determination result is YES, then access time stabs biggish network Time is considered as system time.
The technical program has the beneficial effect that through time synchronization server, the hypertext described in parallel requests module Transfer protocol server and described three kinds of servers of message queue telemetering transmission server are simultaneously emitted by the request of acquisition time, The response that module receives each server is obtained, computation analysis module passes through application condition algorithm from the all-network time received System time of the optimum network time as internet of things equipment is precipitated in point counting of falling into a trap, and energy effective guarantee is in different operators route It can succeed and promptly obtain network time.
Detailed description of the invention
Fig. 1 is the flow chart for the method that a kind of multi-scheme of the present invention obtains network time parallel;
Fig. 2 is the specific flow chart of step S3 in the present invention;
Fig. 3 is the specific flow chart of step S3.1 in the present invention;
Fig. 4 is the specific flow chart of step S3.2 in the present invention;
Fig. 5 is the block diagram for the system that a kind of multi-scheme of the present invention obtains network time parallel;
Fig. 6 is the specific block diagram of computation analysis module in the present invention;
Fig. 7 is the first specific block diagram for calculating analytical unit in the present invention;
Fig. 8 is the second specific block diagram for calculating analytical unit in the present invention.
Specific implementation method
In order to make the objectives, technical solutions, and advantages of the present invention clearer, with reference to the accompanying drawings and embodiments, The present invention will be described in further detail.It should be appreciated that described herein, specific examples are only used to explain the present invention, It is not intended to limit the present invention.Based on the embodiments of the present invention, those of ordinary skill in the art are not making creative labor Every other embodiment obtained under the premise of dynamic, shall fall within the protection scope of the present invention.In addition, between each embodiment Technical solution can be combined with each other, but must based on can be realized by those of ordinary skill in the art, work as technical solution Combination there is conflicting or cannot achieve when and will be understood that the combination of this technical solution is not present, also not in the present invention It is required that protection scope within.
Following is a specific embodiment of the present invention in conjunction with the accompanying drawings, technical scheme of the present invention will be further described, However, the present invention is not limited to these examples.
Embodiment 1
The NTP association that most of IoT (Internet Of Things, Internet of Things) equipment is used using system bottom default Clock synchronization is discussed, but in part operator route shielding NTP Server (network time synchronization server) or udp (User Datagram Protocol, User Datagram Protocol) (port that transport layer udp protocol uses, port numbers are for 123 ports 123), so IoT equipment can not normally get network time under certain carrier network environment.
Now in order to solve the above problem, a kind of method that multi-scheme obtains network time parallel is devised.
As shown in Figure 1, obtaining the flow chart of the method for network time parallel for a kind of multi-scheme of the present invention.
A kind of method that multi-scheme obtains network time parallel, comprising the following steps:
S1, parallel to time synchronization server, hypertext transfer protocol server issue acquisition time request and to Message queue telemetering transmission server issues the request for subscribing to time theme.
S2, waiting for server response obtain first network time that the time synchronization server is replied and/or described The second network time and/or message queue telemetering transmission service that hypertext transfer protocol server is replied reply the Three network times.
S3, by application condition algorithm from the first network time and/or second network time and/or described Third network time fall into a trap point counting be precipitated the optimum network time be considered as the grid time.
The technical program is advantageous in that:
By issuing time request to a variety of servers parallel, the probability for obtaining network event is improved, it is ensured that IoT is set It is standby can be so getting network time under carrier network.
Nowadays, the intelligent electronic devices such as mobile phone, plate and set-top box can provide such as be broadcast live, review and program request memory Etc. functions, but then need to be based on current network time, so intelligent electronic device also needs to obtain net when realizing these functions The network time.But some IoT equipment itself must carry out network by server without power supply chip mostly now The acquisition of time, such as application No. is one kind of the patent disclosure of CN201410710632.7 to be based on NTP under the prior art The time synchronization method and time synchronization system of (Network Time Protocol, Network Time Protocol) network, mainly pass through setting Unique ntp server address, obtain network time from the corresponding NTP time server in the address.
But since ntp server patented technology is mostly foreign patent, the country does not have ntp server, so some are runed The chamber of commerce selects the scheme for directly abandoning NTP network clock synchronization, and IoT equipment clock synchronization is caused to fail, to further influence IoT equipment The application of middle having time stamp verification, such as: when intelligent sound box plays music, part music sources provider meeting checking time stamp, one It is not right that the sound box system time occurs in denier, then can not play music.
In this programme other than the clock synchronization scheme based on NTP network, the side to other two server clock synchronization is also added Case.It is the scheme to HTTP (HyperText Transfer Protocol, hypertext transfer protocol) server clock synchronization respectively With to the side of MQTT (Message Queuing Telemetry Transport, message queue telemetering transmission) server clock synchronization Case.Since HTTP server and MQTT server can be self-built, and MQTT is IBM (IT company-International Business Machine Corporation (IBM)) One instant communication protocol of exploitation is the important component of Internet of Things, which supports all platforms, almost can be All networking articles and external connection are got up, and are used to as sensor and brake.So selection makes for operator It is much smaller with the opposite selection NTP network server of the use cost of HTTP server and MQTT server, more transported Battalion quotient receives and also more mainstream.So increasing this two kinds of networks pair outside clock synchronization scheme of the script based on NTP network When scheme.
In addition, at the same moment, multiple programs are simultaneously in a parallel fashion to a variety of server request times It executes, the overlapping in having time, guarantees that network time obtains the accuracy of result.As long as Service-Port normal use, just can The request for receiving acquisition time simultaneously, then gives and replys.
But the request that every kind of server receives acquisition time is given again replys, and is required to that one can be consumed by processing A little times, the network time for causing every kind of server to reply is different, and design at this time is obtained by application condition algorithm from all Network time falls into a trap the point counting precipitation optimum network time, is finally considered as the system network of internet of things equipment with the optimum network time The network time.
Embodiment 2
Based on embodiment 1, difference from Example 1 is:
As Figure 1-Figure 4, the general flow chart and tool of the method for network time are obtained parallel for a kind of multi-scheme of the present invention Body flow chart.
S1, parallel to time synchronization server, hypertext transfer protocol server issue acquisition time request and to Message queue telemetering transmission server issues the request for subscribing to time theme.
The time that request issues is recorded simultaneously.
S2, waiting for server response obtain first network time that the time synchronization server is replied and/or described The second network time and/or message queue telemetering transmission service that hypertext transfer protocol server is replied reply the Three network times.
The step S2 includes:
Count the number of servers of respond request.
S3, by application condition algorithm from the first network time and/or second network time and/or described Third network time fall into a trap point counting be precipitated the optimum network time be considered as the grid time.
The step S3 includes:
S3.1 judges whether an only server respond request, if the determination result is YES, then directly the server The network time of reply is calculated as the grid time;If judging result is no, execution step S3.2;
The step S3.2 judges whether that only two-server respond request if the determination result is YES then compares two The network time that platform server is replied analyzes the optimum network time according to application condition algorithm and is considered as the grid time;If Judging result be it is no, then directly hold step S3.3;
The step S3.2 includes:
S3.21 judges whether only two-server respond request, if judging result be it is no, directly execute described in Step S3.3.
S3.22, judges whether the time interval between two kinds of network times is less than prefixed time interval, if judging result Be it is no, then choosing a kind of network time replied at first is considered as system time;If the determination result is YES, then access time stabs more A kind of big network time is considered as system time.
The step S3.3, to the first network time, second network time and the third network time two Two are calculated, and obtain the first network time, second network time and the third net according to application condition algorithm It is calculated among network time three and analyzes the optimum network time and be considered as the grid time.
The step S3.3 includes:
S3.31 was compared among the first network time, second network time and the third network time A kind of timestamp maximum network time.
S3.32, when choosing any one network time and the maximum network of timestamp in addition to timestamp maximum network time Between be compared, judge whether the time interval between two kinds of network times is less than prefixed time interval, if judging result is No, then choosing a kind of network time most replied is considered as system time;If the determination result is YES, S3.33 is thened follow the steps.
The step S3.23, chooses remaining finally a kind of network time and timestamp maximum network time is compared Compared with, judge whether the time interval between two kinds of network times is less than prefixed time interval, if judging result be it is no, choose A kind of network time first replied is considered as system time;If the determination result is YES, S3.34 is thened follow the steps.
The step S3.24 chooses remaining two kinds of network times in addition to timestamp maximum network time and is compared Compared with, judge whether the time interval between two kinds of network times is less than prefixed time interval, if judging result be it is no, choose The network time first replied is considered as system time;If the determination result is YES, then a kind of access time stamp religion big network time regards For system time.
If three server responses, obtain the first network time, second network time and the third network Time (is followed successively by t1, t2 and t3 according to time order and function, and t2 timestamp is maximum), obtains described the according to application condition algorithm It is calculated among one network time, second network time and the third network time three and analyzes the optimum network time It is considered as the grid time:
Wherein, prefixed time interval is set as 5S, is primarily due in GPRS (General Packet Radio Service, general packet radio service technology)/CDMA (Code Division Multiple Access, CDMA without Line communication technology) it is generally delayed at 3-5 seconds in network.
If a) judging, the time interval between t1 and t2 whether there is the error greater than 5s, if it is determined that between t1 and t2 Time interval be greater than 5s, then t2 is system time, and carries out next step judgement;If it is determined that the time between t1 and t2 Interval is less than or equal to 5s, then t1 is system time, terminates.
If time interval b) between t2 and t3 whether there is the error greater than 5s, if it is determined that between t2 and t3 when Between interval be greater than 5s, then t3 is system time, and carries out next step judgement;If it is determined that the time interval between t2 and t3 Less than or equal to 5s, then t2 is system time, is terminated.
If time interval c) between t1 and t3 whether there is the error greater than 5s, if it is determined that between t1 and t3 when Between interval be greater than 5s, then t3 is system time, terminate;If it is determined that the time interval between t1 and t3 is less than or equal to 5s, then T1 is system time, is terminated.
Embodiment 3
As described in Figure 6, for based on the system in 1 method of embodiment.
A kind of system that multi-scheme obtains network time parallel, comprising:
Parallel requests module, when being obtained for being issued parallel to time synchronization server, hypertext transfer protocol server Between request and to message queue telemetering transmission server issue subscribe to time theme request;
Module is obtained, is responded for waiting for server, the first network time that the time synchronization server is replied is obtained And/or the second network time and/or the message queue telemetering transmission service of the hypertext transfer protocol server reply The third network time of reply;
Computation analysis module, for passing through application condition algorithm from the first network time and/or second network Time and/or the third network time fall into a trap point counting be precipitated the optimum network time be considered as the grid time.
The technical program is advantageous in that: being passed by time synchronization server described in parallel requests module, the hypertext Defeated protocol server and described three kinds of servers of message queue telemetering transmission server are simultaneously emitted by the request of acquisition time, obtain Modulus block receives the response of each server, and computation analysis module is by application condition algorithm from the all-network time received System time of the optimum network time as internet of things equipment is precipitated in point counting of falling into a trap, and energy effective guarantee is in different operators route It can succeed and promptly obtain network time.
Embodiment 4
As described in Fig. 6-Fig. 8, for based on embodiment 3, difference from Example 3 is:
The acquisition module includes:
Statistic unit, for counting the number of servers of respond request.
The computation analysis module includes:
Judging unit, for judging whether an only server respond request, if the determination result is YES, then direct handle The network time that the server is replied is calculated as the grid time;If judging result is no, execution the first calculating analytical unit.
Described first calculates analytical unit, for judging whether only two-server respond request, if judging result is It is the network time for then comparing two-server reply, the optimum network time is analyzed according to application condition algorithm and is considered as system Network time;If judging result be it is no, directly execute second calculate analytical unit.
Described first, which calculates analytical unit, includes:
First judgment sub-unit, for judging whether only two-server respond request, if judging result be it is no, It then directly executes described second and calculates analytical unit.
Whether the second judgment sub-unit, the time interval for judging between two kinds of network times are less than between preset time Every, if judging result be it is no, choosing a kind of network time replied at first is considered as system time;If the determination result is YES, then A kind of access time stamp bigger network time is considered as system time.
Described second calculates analytical unit, for the first network time, second network time and described the Three network times were calculated two-by-two, obtained the first network time, second network time according to application condition algorithm It analyzes the optimum network time with being calculated among the third network time three and is considered as the grid time.
Described second, which calculates analytical unit, includes:
Comparing subunit, for comparing the first network time, second network time and the third network Timestamp maximum a kind of network time among time.
Third judgment sub-unit, for choosing any network time and timestamp in addition to timestamp maximum network time Maximum network time is compared, and judges whether the time interval between two kinds of network times is less than prefixed time interval, if Judging result be it is no, then choosing a kind of network time first replied is considered as system time;If the determination result is YES, then is executed Four judgment sub-units.
4th judgment sub-unit, when for choosing a kind of remaining last network time and the maximum network of timestamp Between be compared, judge whether the time interval between two kinds of network times is less than prefixed time interval, if judging result is No, then choosing a kind of network time first replied is considered as system time;If the determination result is YES, then it is single to execute the 5th judgement Member.
5th judgment sub-unit, for choosing in addition to timestamp maximum network time when remaining two kinds of networks Between be compared, judge whether the time interval between two kinds of network times is less than prefixed time interval, if judging result is No, then choosing a kind of network time first replied is considered as system time;If the determination result is YES, then access time stamp teaches big A kind of network time is considered as system time.
If three servers respond (being followed successively by t1, t2 and t3 according to time order and function), t1 and t2 is first compared, error is in 5s It is interior, then system time is used as using first reply (being assumed to be t1);It is larger using timestamp in the two if error is greater than 5s (being assumed to be t2) compares with t3;If error within 5s, uses t2 for system time;If error is greater than 5s, t1 is compared And t3, if error within 5s, using t1 as system time, if more than 5s, then uses t3 as system time.
Specific embodiment described herein is only an example for the spirit of the invention.Technology belonging to the present invention The technical staff in field can make various modifications or additions to the described embodiments or using similar method Substitution, however, it does not deviate from the spirit of the invention or beyond the scope of the appended claims.

Claims (10)

1. a kind of method that multi-scheme obtains network time parallel, which is characterized in that
S1 to time synchronization server, hypertext transfer protocol server issues the request of acquisition time parallel and to message Queue telemetering transmission server issues the request for subscribing to time theme;
S2, waiting for server response obtain the first network time and/or the hypertext that the time synchronization server is replied When the third network that the second network time and/or message queue telemetering transmission service that transfer protocol server is replied reply Between;
S3, by application condition algorithm from the first network time and/or second network time and/or the third net The network time fall into a trap point counting be precipitated the optimum network time be considered as the grid time.
2. the method that a kind of multi-scheme according to claim 1 obtains network time parallel, which is characterized in that the step S2 includes:
Count the number of servers of respond request.
3. the method that a kind of multi-scheme according to claim 1 obtains network time parallel, which is characterized in that the step S3 includes:
S3.1 judges whether an only server respond request, if the determination result is YES, then directly the server is replied Network time is calculated as the grid time;If judging result is no, execution step S3.2;
The step S3.2 judges whether only two-server respond request, if the determination result is YES, then compares two services The network time that device is replied analyzes the optimum network time according to application condition algorithm and is considered as the grid time;If judgement knot Fruit be it is no, then directly hold step S3.3;
The step S3.3, to the first network time, second network time and the third network time two-by-two into Row calculates, when obtaining the first network time, second network time and the third network according to application condition algorithm Between calculate among three and analyze the optimum network time and be considered as the grid time.
4. the method that a kind of multi-scheme according to claim 3 obtains network time parallel, which is characterized in that the step S3.2 includes:
S3.21 judges whether only two-server respond request, if judging result be it is no, directly execute the step S3.3;
S3.22, judges whether the time interval between two kinds of network times is less than prefixed time interval, if judging result be it is no, Then choosing a kind of network time replied at first is considered as system time;If the determination result is YES, then access time stabs bigger one Kind network time is considered as system time.
5. the method that a kind of multi-scheme according to claim 3 obtains network time parallel, which is characterized in that the step S3.3 includes:
S3.31 compares the first network time, timestamp among second network time and the third network time A kind of maximum network time;
S3.32 chooses any network time in addition to timestamp maximum network time, with timestamp maximum network time Be compared, judge whether the time interval between two kinds of network times is less than prefixed time interval, if judging result be it is no, A kind of network time that selection is first replied is considered as system time;
If the determination result is YES, S3.33 is thened follow the steps;
The step S3.33, selection remaining finally a kind of network time are compared with timestamp maximum network time, judge Whether the time interval between two kinds of network times be less than prefixed time interval, if judging result be it is no, choose and first reply A kind of network time is considered as system time;If the determination result is YES, S3.34 is thened follow the steps;
The step S3.34 chooses remaining two kinds of network times in addition to timestamp maximum network time, judges two kinds of networks Whether the time interval between the time is less than prefixed time interval, if judging result be it is no, choose the network time first replied It is considered as system time;If the determination result is YES, then access time stamp biggish network time is considered as system time.
6. the system that a kind of multi-scheme obtains network time parallel characterized by comprising
Parallel requests module, for issuing acquisition time to time synchronization server, hypertext transfer protocol server parallel Request and the request that subscription time theme is issued to message queue telemetering transmission server;
Obtain module, responded for waiting for server, obtain first network time that the time synchronization server is replied and/or What the second network time and/or message queue telemetering transmission service that the hypertext transfer protocol server is replied replied Third network time;
Computation analysis module, for passing through application condition algorithm from the first network time and/or second network time And/or the third network time fall into a trap point counting be precipitated the optimum network time be considered as the grid time.
7. the system that a kind of multi-scheme according to claim 6 obtains network time parallel, which is characterized in that the acquisition Module includes:
Statistic unit, for counting the number of servers of respond request.
8. the system that a kind of multi-scheme according to claim 6 obtains network time parallel, which is characterized in that the calculating Analysis module includes:
Judging unit, for judging whether an only server respond request, if the determination result is YES, then directly the service The network time that device is replied is calculated as the grid time;If judging result is no, execution the first calculating analytical unit;
Described first calculates analytical unit, for judging whether only two-server respond request, if the determination result is YES, then The network time for comparing two-server reply, when analyzing the optimum network time according to application condition algorithm and being considered as grid Between;If judging result be it is no, directly execute second calculate analytical unit;
Described second calculates analytical unit, for the first network time, second network time and the third net The network time is calculated two-by-two, obtains the first network time, second network time and institute according to application condition algorithm It states to calculate among third network time three and analyzes the optimum network time and be considered as the grid time.
9. the system that a kind of multi-scheme according to claim 8 obtains network time parallel, which is characterized in that described first Calculating analytical unit includes:
First judgment sub-unit, for judging whether only two-server respond request, if judging result be it is no, directly It executes described second and calculates analytical unit;
Whether the second judgment sub-unit, the time interval for judging between two kinds of network times are less than prefixed time interval, if Judging result be it is no, then choosing a kind of network time replied at first is considered as system time;If the determination result is YES, then when choosing Between stab a kind of bigger network time and be considered as system time.
10. the system that a kind of multi-scheme according to claim 8 obtains network time parallel, which is characterized in that described Two, which calculate analytical units, includes:
Comparing subunit, for comparing the first network time, second network time and the third network time Among a kind of timestamp maximum network time;
Third judgment sub-unit, for choose in addition to timestamp maximum network time any network time, with timestamp most Big network time is compared, and judges whether the time interval between two kinds of network times is less than prefixed time interval, if sentencing Disconnected result be it is no, then choosing the network time first replied is considered as system time;If the determination result is YES, then the 4th judgement is executed Unit;
4th judgment sub-unit is carried out for choosing remaining finally a kind of network time and timestamp maximum network time Compare, judge whether the time interval between two kinds of network times is less than prefixed time interval, if judging result be it is no, choose The network time first replied is considered as system time;If the determination result is YES, then the 5th judgment sub-unit is executed;
5th judgment sub-unit is carried out for choosing remaining two kinds of network times in addition to timestamp maximum network time Compare, judge whether the time interval between two kinds of network times is less than prefixed time interval, if judging result be it is no, choose The network time first replied is considered as system time;If the determination result is YES, then access time stabs biggish network time and is considered as and is It unites the time.
CN201810694712.6A 2018-06-29 2018-06-29 Method and system for acquiring network time in parallel by multiple schemes Active CN108964822B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810694712.6A CN108964822B (en) 2018-06-29 2018-06-29 Method and system for acquiring network time in parallel by multiple schemes

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810694712.6A CN108964822B (en) 2018-06-29 2018-06-29 Method and system for acquiring network time in parallel by multiple schemes

Publications (2)

Publication Number Publication Date
CN108964822A true CN108964822A (en) 2018-12-07
CN108964822B CN108964822B (en) 2020-09-01

Family

ID=64487894

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810694712.6A Active CN108964822B (en) 2018-06-29 2018-06-29 Method and system for acquiring network time in parallel by multiple schemes

Country Status (1)

Country Link
CN (1) CN108964822B (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110071778A (en) * 2019-04-24 2019-07-30 江苏紫米软件技术有限公司 A kind of time synchronization method, device, equipment and medium
CN111327385A (en) * 2018-12-13 2020-06-23 阿里巴巴集团控股有限公司 Clock synchronization method, device and equipment of Internet of things equipment
CN111555833A (en) * 2020-04-24 2020-08-18 光荣出行(深圳)科技有限公司 Data transmission processing method based on wireless module

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050102398A1 (en) * 2003-11-12 2005-05-12 Alex Zhang System and method for allocating server resources
CN103973804A (en) * 2014-05-19 2014-08-06 广东欧珀移动通信有限公司 Method and device for setting terminal time
CN105610958A (en) * 2016-01-13 2016-05-25 广东欧珀移动通信有限公司 Method and device for selecting time synchronization server and intelligent terminal
CN106027191A (en) * 2016-05-23 2016-10-12 北京小米移动软件有限公司 Time updating method, device and terminal equipment

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050102398A1 (en) * 2003-11-12 2005-05-12 Alex Zhang System and method for allocating server resources
CN103973804A (en) * 2014-05-19 2014-08-06 广东欧珀移动通信有限公司 Method and device for setting terminal time
CN105610958A (en) * 2016-01-13 2016-05-25 广东欧珀移动通信有限公司 Method and device for selecting time synchronization server and intelligent terminal
CN106027191A (en) * 2016-05-23 2016-10-12 北京小米移动软件有限公司 Time updating method, device and terminal equipment

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111327385A (en) * 2018-12-13 2020-06-23 阿里巴巴集团控股有限公司 Clock synchronization method, device and equipment of Internet of things equipment
CN110071778A (en) * 2019-04-24 2019-07-30 江苏紫米软件技术有限公司 A kind of time synchronization method, device, equipment and medium
CN111555833A (en) * 2020-04-24 2020-08-18 光荣出行(深圳)科技有限公司 Data transmission processing method based on wireless module

Also Published As

Publication number Publication date
CN108964822B (en) 2020-09-01

Similar Documents

Publication Publication Date Title
CN105338061B (en) A kind of implementation method and system of lightweight messages middleware
Wang et al. STCS: Spatial-temporal collaborative sampling in flow-aware software defined networks
CN108964822A (en) A kind of multi-scheme obtains the method and system of network time parallel
CN102045222B (en) Real-time overall test method of network system
CN106155812A (en) Method, device, system and the electronic equipment of a kind of resource management to fictitious host computer
US8103245B2 (en) Systems and methods for session records correlation
CN108737535A (en) A kind of information push method, storage medium and server
CN103561354B (en) Method and device for calculating and processing video smoothness
CN104956333A (en) Apparatus, method and computer program for processing out-of-order events
CN104270779A (en) Wireless network fault reason preprocessing method and wireless network fault work order distribution system
CN109005220B (en) Service implementation method of Internet of things terminal and Internet of things access gateway
CN103581966A (en) Real-time monitoring optimizing configuration method for smart phone
WO2020052133A1 (en) Gateway communication method, gateway, and energy system
CN104778042A (en) Stream data processing method based on event stream processing and plug-in type development framework
Munari et al. The role of feedback in AoI optimization under limited transmission opportunities
CN110928880B (en) Data processing method, device, terminal and medium based on block chain
CN109921915A (en) Test the method, apparatus and electronic equipment of real-time clock module arousal function
CN106162365B (en) Any active ues collection maintaining method and system based on time wheel disc and barrage behavior
CN108880934A (en) A kind of data flow statistic method and device based on block chain
CN108366176A (en) A kind of charging method of terminal applies, apparatus and system
CN112702219B (en) Internet of things network monitoring method, device, equipment and storage medium
CN110503297A (en) Business scenario acquisition methods, device, electronic equipment and medium
CN111427710B (en) Communication method, device, equipment and storage medium of components in application program
CN107888690A (en) The statistical method and system of response time
CN109561487A (en) Reduce the method, apparatus and mobile terminal of mobile terminal energy consumption

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
TA01 Transfer of patent application right

Effective date of registration: 20190426

Address after: 201616 No. 3666 Sixian Road, Songjiang District, Shanghai

Applicant after: Shanghai Feixun Data Communication Technology Co., Ltd.

Address before: 610100 125 Longquan Street Park Road, Longquanyi District, Chengdu, Sichuan.

Applicant before: Sichuan fixun Information Technology Co., Ltd.

TA01 Transfer of patent application right
TA01 Transfer of patent application right
TA01 Transfer of patent application right

Effective date of registration: 20200410

Address after: 318015 no.2-3167, zone a, Nonggang City, no.2388, Donghuan Avenue, Hongjia street, Jiaojiang District, Taizhou City, Zhejiang Province

Applicant after: Taizhou Jiji Intellectual Property Operation Co., Ltd

Address before: 201616 Shanghai city Songjiang District Sixian Road No. 3666

Applicant before: Phicomm (Shanghai) Co.,Ltd.

TA01 Transfer of patent application right

Effective date of registration: 20200714

Address after: 201616 Shanghai city Songjiang District Sixian Road No. 3666

Applicant after: Phicomm (Shanghai) Co.,Ltd.

Address before: 318015 no.2-3167, zone a, Nonggang City, no.2388, Donghuan Avenue, Hongjia street, Jiaojiang District, Taizhou City, Zhejiang Province

Applicant before: Taizhou Jiji Intellectual Property Operation Co.,Ltd.

TA01 Transfer of patent application right
TA01 Transfer of patent application right

Effective date of registration: 20200731

Address after: Unit 1-6, 19th floor, No. 10, Huasheng Road, Yuzhong District, Chongqing, 400010

Applicant after: Chongqing fun play Technology Co., Ltd

Address before: 201616 Shanghai city Songjiang District Sixian Road No. 3666

Applicant before: Phicomm (Shanghai) Co.,Ltd.

TA01 Transfer of patent application right
GR01 Patent grant
GR01 Patent grant