CN103457714A - Method and system for synchronizing server time - Google Patents

Method and system for synchronizing server time Download PDF

Info

Publication number
CN103457714A
CN103457714A CN2013103620961A CN201310362096A CN103457714A CN 103457714 A CN103457714 A CN 103457714A CN 2013103620961 A CN2013103620961 A CN 2013103620961A CN 201310362096 A CN201310362096 A CN 201310362096A CN 103457714 A CN103457714 A CN 103457714A
Authority
CN
China
Prior art keywords
time
server
message
terminal
clock
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.)
Pending
Application number
CN2013103620961A
Other languages
Chinese (zh)
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.)
SHENZHEN KNET SCIENCE & TECHNOLOGY Co Ltd
State Grid Corp of China SGCC
State Grid Jiangsu Electric Power Co Ltd
Nanjing Power Supply Co of Jiangsu Electric Power Co
Original Assignee
SHENZHEN KNET SCIENCE & TECHNOLOGY Co Ltd
State Grid Corp of China SGCC
State Grid Jiangsu Electric Power Co Ltd
Nanjing Power Supply Co of Jiangsu Electric Power Co
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 SHENZHEN KNET SCIENCE & TECHNOLOGY Co Ltd, State Grid Corp of China SGCC, State Grid Jiangsu Electric Power Co Ltd, Nanjing Power Supply Co of Jiangsu Electric Power Co filed Critical SHENZHEN KNET SCIENCE & TECHNOLOGY Co Ltd
Priority to CN2013103620961A priority Critical patent/CN103457714A/en
Publication of CN103457714A publication Critical patent/CN103457714A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Electric Clocks (AREA)
  • Synchronisation In Digital Transmission Systems (AREA)

Abstract

The invention provides a method and system for synchronizing server time. The method comprises the following steps that current server time is acquired and serves as request sending time, the preset SOCKET connection between a server and a terminal is built, and the request sending time is sent to the terminal in the form of a message; messages fed back by the terminal are received, the current server time is acquired, and serves as response receiving time, and the feedback messages are analyzed; a clock supplement value of the server time and terminal time is calculated according to the analysis result and the response receiving time; the server time is synchronized according to the clock supplement value. The method and system for synchronizing the server time save expenses spent in the server time synchronization calibration problem of an enterprise on the one hand and ensure that the server acquires time which is almost consistent with standard time and is high in precision, and satisfy the requirements of applications for extremely-high time precision on the other hand.

Description

The method and system of synchronization server time
Technical field
The present invention relates to computer network field, particularly relate to method and the system of a kind of synchronization server time of a kind of synchronization server time.
Background technology
Day by day flourishing today at computer network information, a lot of enterprises have all introduced enterprises and have moved application, for security consideration, the server of a lot of important mobile application is not connected with the Internet, and all terminals, server and whole network belong to a local area network be isolated from the outside.
In addition, in some cases, application requires meeting higher to the accuracy of time.At such net environment, how by a kind of not only economical simple but also accurately errorless mode server time be set to the standard time and become a technical barrier.
In the method for traditional synchronization server time, adopt the reference standard time that the mode of server time manually is set.Yet, although manually being set by the reference standard time, the mode of server time can realize that server time is set to the purpose of standard time, but the server time arranged out like this is often accurate not, and may produce the operability error at setting up procedure, cause the set of time mistake, and then have influence on the normal operation of server.
Summary of the invention
Based on this, being necessary provides the method and system of a kind of synchronization server time for accurate not problem of above-mentioned synchronization server time.
For achieving the above object, the present invention adopts following technical scheme:
The method of synchronization server time a kind of comprises the following steps:
Obtain the current server time as request transmission time, and be connected with SOCKET between terminal by the server set up in advance the described request transmitting time is sent to described terminal with the form of message;
Receive the message that described terminal is fed back, obtain the current server time as the response time of reception, and the message of described feedback is resolved;
Supplement value according to analysis result and the clock of described response time of reception calculation server time and terminal time;
Supplement value according to described clock and carry out the synchronous of server time.
The system of a kind of synchronization server time, comprise server end, and described server end comprises:
The message sending module, for obtaining the current server time as request transmission time, and be connected with SOCKET between terminal by the server end set up in advance the described request transmitting time sent to described terminal with the form of message;
The packet parsing module, the message fed back for receiving described terminal, obtain the current server time as the response time of reception, and the message of described feedback resolved;
Clock supplements the value computing module, for according to analysis result and the clock of described response time of reception calculation server time and terminal time, supplementing value;
Synchronization module, carry out the synchronous of server time for supplement value according to described clock.
By above scheme, can be found out, the method and system of a kind of synchronization server time of the present invention, server connects with terminal and carries out message interaction by SOCKET, and supplement value according to the calculation of parameter server time obtained in message interaction and the clock of terminal time, then according to this clock, supplement value and carry out the synchronous of server time.The present invention's server time that simple mode is connected with terminal by a kind of economy is set to the standard time, saved on the one hand the spending of enterprise on settlement server time synchronized calibration problem, server has got the time almost completely consistent with the standard time on the other hand, accuracy is high, has met those and time accuracy has been required to the demand of high application.
The accompanying drawing explanation
The schematic flow sheet that Fig. 1 is the method for synchronization server time a kind of in the embodiment of the present invention;
The structural representation that Fig. 2 is the system of a kind of synchronization server time in the embodiment of the present invention.
Embodiment
Below in conjunction with accompanying drawing and specific embodiment, technical scheme of the present invention is further described.
Shown in Figure 1, the method for a kind of synchronization server time of the present invention comprises the following steps:
Step S101, obtain the current server time as request transmission time (being designated as T1), and be connected with SOCKET between terminal by the server set up in advance the described request transmitting time is sent to described terminal with the form of message, then enter step S102.
Step S102, receive the message that described terminal is fed back, and obtains the current server time as response time of reception (being designated as T2), and the message of described feedback is resolved, and then enters step S103.
It should be noted that, the major part operation (step S101 described above, step S102 and follow-up step S103, step S104 etc.) in the embodiment of the present invention is all carried out in server.But, as an embodiment preferably, after step S101 sends to described terminal by the described request transmitting time with the form of message, before step S102 receives the message that described terminal fed back, can also comprise the step of carrying out as follows in terminal:
Step S1011, terminal is obtained current terminal time as request receiving time (being designated as T3), and the described request time of reception is changed after receiving the message of server transmission, joins in former message, then enters step S1012;
Step S1012, obtain current terminal time as response transmitting time (being designated as T4), described response transmitting time is changed, joined in former message and (now in message, had three time value: T1, T3, T4), obtain the message of described feedback and send to described server.
As an embodiment preferably, the process of obtaining current terminal time in described step S1011 and step S1012 specifically can comprise as follows: by the GPS(Global Positioning System of described terminal, global positioning system) module obtains the standard time as current terminal time.
Step S103, supplement value (being designated as t) according to analysis result and the clock of described response time of reception calculation server time and terminal time, then enters step S104.
As an embodiment preferably, calculate according to analysis result and described response time of reception the process that described clock supplements value in this step and specifically can comprise as follows: the request transmission time T1 obtained after being resolved according to described response time of reception T2 and to the message of described feedback, request receiving time T 3, respond transmitting time T4 and calculate the supplementary value t of described clock.
Concrete computational process is as follows: suppose that d is the server and client side two-way time, t is the time deviation between the server and client side (being the supplementary value of clock), has:
T3=T1+t+d/2;T3-T1=t+d/2;T2=T4-t+d/2;T2-T3=t-d/2;
Can release: d=(T2-T1)-(T4-T3); T=((T3-T1)+(T4-T2))/2;
Because T1, T2, T3, T4 are known, therefore by above-mentioned formula, can calculate clock and supplement value t.
Step S104, supplement value according to described clock and carry out the synchronous of server time.Concrete, calculate the supplementary value t of clock in step S103 after, call following system function and can realize the synchronous of server time:
Server standard time=current server time T 2+ clock is set and supplements value t.
As an embodiment preferably, for fear of operate miss, guarantee the accuracy of server time, step S103 calculate described clock supplement value after, step S104 according to described clock, supplement value carry out server time synchronously before, can also comprise the steps:
Step S1031, repeat abovementioned steps (comprising step S101-step S103), the clock that calculates predetermined number supplements value (as calculated continuously 5 t or 10 t etc., concrete number can be made different the setting according to different situations), and average and carry out the synchronous of server time as the supplementary value of final clock.
As an embodiment preferably, after carrying out server time synchronous, step S104 can also comprise the steps:
Step S105, transmission is closed the request of SOCKET connection to described terminal, and closes described SOCKET connection after the response that receives described terminal.Closing server is connected with the SOCKET between terminal in time, can save system resource.
Finally, consistent with the height of standard time in order to guarantee server time, we can also setup times synchronizing cycle, repeat above-mentioned steps S101-step S105 when the cycle arrives, in order to get the most accurate server time.
Corresponding with the method for above-mentioned a kind of synchronization server time, the present invention also provides the system of a kind of synchronization server time, comprises server end, and as shown in Figure 2, described server end comprises:
Message sending module 101, for obtaining the current server time as request transmission time, and be connected with SOCKET between terminal by the server end set up in advance the described request transmitting time sent to described terminal with the form of message;
Packet parsing module 102, the message fed back for receiving described terminal, obtain the current server time as the response time of reception, and the message of described feedback resolved;
Clock supplements value computing module 103, for according to analysis result and the clock of described response time of reception calculation server time and terminal time, supplementing value;
Synchronization module 104, carry out the synchronous of server time for supplement value according to described clock.
As an embodiment preferably, the system of synchronization server time of the present invention can also comprise terminal, and described terminal comprises:
The first message modular converter, after the message that receives described server end transmission, obtain current terminal time as the request receiving time, and the described request time of reception changed, and joins in former message;
The second message modular converter, for obtaining current terminal time as the response transmitting time, changed described response transmitting time, joins in former message, obtains the message of described feedback and send to described server end.
As an embodiment preferably, described terminal can also comprise: the GPS module, for obtaining the standard time;
Described the first message modular converter, the second message modular converter obtain the standard time as current terminal time by described GPS module.
As an embodiment preferably, described clock supplements after value computing module can be resolved according to described response time of reception and to the message of described feedback the request transmission time, request receiving time, the response transmitting time that obtain and calculates the supplementary value of described clock.
Other technical characterictic of the system of above-mentioned a kind of synchronization server time is identical with the method for a kind of synchronization server time of the present invention, and it will not go into details herein.
By above scheme, can find out, the method and system of a kind of synchronization server time of the present invention, server connects with terminal and carries out message interaction by SOCKET, and supplement value according to the calculation of parameter server time obtained in message interaction and the clock of terminal time, then according to this clock, supplement value and carry out the synchronous of server time.The present invention's server time that simple mode is connected with terminal by a kind of economy is set to the standard time, saved on the one hand the spending of enterprise on settlement server time synchronized calibration problem, server has got the time almost completely consistent with the standard time on the other hand, accuracy is high, has met those and time accuracy has been required to the demand of high application.
The above embodiment has only expressed several execution mode of the present invention, and it describes comparatively concrete and detailed, but can not therefore be interpreted as the restriction to the scope of the claims of the present invention.It should be pointed out that for the person of ordinary skill of the art, without departing from the inventive concept of the premise, can also make some distortion and improvement, these all belong to protection scope of the present invention.Therefore, the protection range of patent of the present invention should be as the criterion with claims.

Claims (10)

1. the method for a synchronization server time, is characterized in that, comprises the following steps:
Obtain the current server time as request transmission time, and be connected with SOCKET between terminal by the server set up in advance the described request transmitting time is sent to described terminal with the form of message;
Receive the message that described terminal is fed back, obtain the current server time as the response time of reception, and the message of described feedback is resolved;
Supplement value according to analysis result and the clock of described response time of reception calculation server time and terminal time;
Supplement value according to described clock and carry out the synchronous of server time.
2. the method for synchronization server time according to claim 1, is characterized in that, after the described request transmitting time is sent to described terminal with the form of message, receive the message that described terminal fed back before, also comprise step:
Terminal is obtained current terminal time as the request receiving time, and the described request time of reception is changed after receiving the message of server transmission, joins in former message;
Obtain current terminal time as the response transmitting time, described response transmitting time is changed, join in former message, obtain the message of described feedback and send to described server.
3. the method for synchronization server time according to claim 2, is characterized in that, the described process of obtaining current terminal time comprises:
Obtain the standard time as current terminal time by the GPS module of described terminal.
4. the method for synchronization server time according to claim 2, is characterized in that, describedly calculates according to analysis result and described response time of reception the process that described clock supplements value and comprise:
The request transmission time obtained after being resolved according to described response time of reception and to the message of described feedback, request receiving time, response transmitting time are calculated described clock and are supplemented value.
5. according to the claim 1-4 any one method of described synchronization server time, it is characterized in that, calculate described clock supplement value after, according to described clock, supplement value carry out server time synchronously before, also comprise step:
The clock that calculates predetermined number supplements value, and averages and carry out the synchronous of server time as the supplementary value of final clock.
6. according to the claim 1-4 any one method of described synchronization server time, it is characterized in that, also comprise step after carrying out server time synchronous:
Transmission is closed the request of SOCKET connection to described terminal, and closes described SOCKET connection after the response that receives described terminal.
7. the system of a synchronization server time, comprise server end, it is characterized in that, described server end comprises:
The message sending module, for obtaining the current server time as request transmission time, and be connected with SOCKET between terminal by the server end set up in advance the described request transmitting time sent to described terminal with the form of message;
The packet parsing module, the message fed back for receiving described terminal, obtain the current server time as the response time of reception, and the message of described feedback resolved;
Clock supplements the value computing module, for according to analysis result and the clock of described response time of reception calculation server time and terminal time, supplementing value;
Synchronization module, carry out the synchronous of server time for supplement value according to described clock.
8. the system of synchronization server time according to claim 7, is characterized in that, also comprises terminal, and described terminal comprises:
The first message modular converter, after the message that receives described server end transmission, obtain current terminal time as the request receiving time, and the described request time of reception changed, and joins in former message;
The second message modular converter, for obtaining current terminal time as the response transmitting time, changed described response transmitting time, joins in former message, obtains the message of described feedback and send to described server end.
9. the system of synchronization server time according to claim 8, is characterized in that, described terminal also comprises: the GPS module, for obtaining the standard time;
Described the first message modular converter, the second message modular converter obtain the standard time as current terminal time by described GPS module.
10. the system of synchronization server time according to claim 8, it is characterized in that, described clock supplements after the value computing module is resolved according to described response time of reception and to the message of described feedback the request transmission time, request receiving time, the response transmitting time that obtain and calculates the supplementary value of described clock.
CN2013103620961A 2013-08-19 2013-08-19 Method and system for synchronizing server time Pending CN103457714A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN2013103620961A CN103457714A (en) 2013-08-19 2013-08-19 Method and system for synchronizing server time

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN2013103620961A CN103457714A (en) 2013-08-19 2013-08-19 Method and system for synchronizing server time

Publications (1)

Publication Number Publication Date
CN103457714A true CN103457714A (en) 2013-12-18

Family

ID=49739712

Family Applications (1)

Application Number Title Priority Date Filing Date
CN2013103620961A Pending CN103457714A (en) 2013-08-19 2013-08-19 Method and system for synchronizing server time

Country Status (1)

Country Link
CN (1) CN103457714A (en)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106023050A (en) * 2016-06-17 2016-10-12 海南智城科技发展股份有限公司 Traffic data management system
CN107547307A (en) * 2017-07-28 2018-01-05 新华三技术有限公司 A kind of time parameter determines method and device
CN107688926A (en) * 2017-08-24 2018-02-13 成都海谱科技有限公司 A kind of definable type time task propulsion method based on automatic flow
CN107948211A (en) * 2018-01-09 2018-04-20 北京知道创宇信息技术有限公司 A kind of method for synchronizing time, device, server and storage medium
CN110034913A (en) * 2018-01-12 2019-07-19 南京计然信息技术有限公司 A kind of automatic time synchronization method of passenger flow counting terminal
CN110868284A (en) * 2018-10-12 2020-03-06 鼎信信息科技有限责任公司 Accurate timing method and system for electric energy information acquisition
CN111611134A (en) * 2020-05-21 2020-09-01 中国建设银行股份有限公司 Time monitoring method and device, application terminal and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101459502A (en) * 2007-12-13 2009-06-17 华为技术有限公司 Method and apparatus for network clock synchronization
CN101895384A (en) * 2010-07-07 2010-11-24 中兴通讯股份有限公司 Method and device for implementing boundary clock
CN102111380A (en) * 2009-12-25 2011-06-29 华为技术有限公司 Time synchronization method, device and system

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101459502A (en) * 2007-12-13 2009-06-17 华为技术有限公司 Method and apparatus for network clock synchronization
CN102111380A (en) * 2009-12-25 2011-06-29 华为技术有限公司 Time synchronization method, device and system
CN101895384A (en) * 2010-07-07 2010-11-24 中兴通讯股份有限公司 Method and device for implementing boundary clock

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106023050A (en) * 2016-06-17 2016-10-12 海南智城科技发展股份有限公司 Traffic data management system
CN107547307A (en) * 2017-07-28 2018-01-05 新华三技术有限公司 A kind of time parameter determines method and device
CN107547307B (en) * 2017-07-28 2021-04-30 新华三技术有限公司 Time parameter determination method and device
CN107688926A (en) * 2017-08-24 2018-02-13 成都海谱科技有限公司 A kind of definable type time task propulsion method based on automatic flow
CN107688926B (en) * 2017-08-24 2021-06-08 成都掌控者网络科技有限公司 Definable time task propelling method based on automatic circulation
CN107948211A (en) * 2018-01-09 2018-04-20 北京知道创宇信息技术有限公司 A kind of method for synchronizing time, device, server and storage medium
CN110034913A (en) * 2018-01-12 2019-07-19 南京计然信息技术有限公司 A kind of automatic time synchronization method of passenger flow counting terminal
CN110868284A (en) * 2018-10-12 2020-03-06 鼎信信息科技有限责任公司 Accurate timing method and system for electric energy information acquisition
CN111611134A (en) * 2020-05-21 2020-09-01 中国建设银行股份有限公司 Time monitoring method and device, application terminal and storage medium

Similar Documents

Publication Publication Date Title
CN103457714A (en) Method and system for synchronizing server time
US9307563B2 (en) Evolved packet core less direct mode communication system and communication attaching method thereof
CN101808167B (en) Method for procedure tracking, device and system
CN103458496A (en) Method and system for achieving time synchronization through WiFi-Direct
CN109996325B (en) Clock synchronization system and method of wireless sensor network
CN111050379A (en) Implementation system and method supporting multiple cloud services
CN103929263A (en) Network communication method, network communication delay determining method and network communication local time synchronizing method
CN204287779U (en) A kind of associating precision time service system
CN103546267A (en) Time synchronization monitoring method and system
CN107276709B (en) A kind of method for synchronizing time and system
CN111064726B (en) Method and system for realizing data conversion between GOOSE protocol and HDLC protocol
CN104243482A (en) Control method and device of intelligent device
WO2013189363A3 (en) Method for sending/receiving information by both parties in call state and mobile terminal
WO2016177090A1 (en) Clock synchronization method and device
CN103546268A (en) Method and device for compensating system time
CN103399795A (en) Address book synchronizing method and device
CN104579712A (en) Method for conference member to issue character information in fragmentation asynchronous conference system
CN103106057A (en) Cascading system of multiprocessor device and cascading control method of the same
CN202772918U (en) PTP signal protocol converting device
CN104218677A (en) Method for synchronizing clocks of power distribution master stations and power distribution terminals
CN113133097B (en) Wireless communication method and system
CN204615506U (en) Distribution main website and distribution terminal clock system
CN105812615A (en) Method and device for achieving editing of projection contents
CN103813382A (en) Clock synchronization method, device and system
US9361191B2 (en) Methods and apparatus for data recovery following a service interruption at a central processing station

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20131218