Self-adaptive time synchronization method and device, equipment and storage medium

By introducing an adaptive selection mechanism in the time synchronization system, evaluating the priority of multiple backup servers, and switching to the optimal backup server when the main server fails, the problem of inability to adapt to network changes in the prior art is solved, and high availability and accuracy of time synchronization is achieved.

CN119995769AInactive Publication Date: 2025-05-13SHENZHEN FENGRUNDA TECH CO LTD
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202510438104.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-09
Publication Date
2025-05-13
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The existing time synchronization scheme is based on a fixed NTP server and cannot effectively adapt to network changes, resulting in the inability to switch under high load or failure conditions, affecting the accuracy of time synchronization.

Method used

An adaptive time synchronization method is proposed, which sends time synchronization requests to multiple backup servers through a switch, collects real-time network status data, and evaluates the priority of the backup server based on historical response time data, time source type information and real-time network status data. When the primary server fails, switch to the optimal backup server based on the priority evaluation results.

Benefits of technology

It realizes quick and intelligent switching to the optimal backup server when the main server fails, ensuring the stable operation of time synchronization services, and improving the high availability of the system and the accuracy of time synchronization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119995769A_ABST
    Figure CN119995769A_ABST
Patent Text Reader

Abstract

The invention discloses a self-adaptive time synchronization method, device and equipment and a storage medium, relates to the technical field of network communication, and discloses a self-adaptive time synchronization method which comprises the following steps: sending a first time synchronization request to a plurality of backup servers through a switch; collecting real-time network state data of the plurality of backup servers based on the first time synchronization request; evaluating the priorities of the plurality of backup servers according to the historical response time data, the time source type information and the real-time network state data of the plurality of backup servers to obtain a backup server priority evaluation result; and when the abnormal detection information of the main server meets a preset condition, determining an updated main server from the plurality of backup servers according to the backup server priority evaluation result. The optimal NTP server can be selected in the time synchronization process, and the accuracy of time synchronization is kept.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of network communication technology, and in particular to an adaptive time synchronization method, device, equipment and storage medium. Background Art

[0002] Currently, existing time synchronization solutions are generally based on fixed NTP servers. By presetting specific NTP servers, client devices in the network periodically send time synchronization requests to these servers, thereby calibrating device time with standard time.

[0003] However, the fixed selection mechanism limits the ability of the time synchronization system to adapt to network changes, resulting in ineffective switching under high load or failure conditions. How to select the optimal NTP server during time synchronization and maintain the accuracy of time synchronization has become a problem to be solved.

[0004] The above contents are only used to assist in understanding the technical solution of the present application and do not constitute an admission that the above contents are prior art. Summary of the invention

[0005] The main purpose of this application is to provide an adaptive time synchronization method, device, equipment and storage medium, aiming to solve the technical problem of how to select the optimal NTP server in the process of time synchronization and maintain the accuracy of time synchronization.

[0006] To achieve the above object, the present application proposes an adaptive time synchronization method, which is applied to an adaptive time synchronization system, wherein the adaptive time synchronization system includes a switch and multiple network time protocol servers, wherein the network time protocol servers include a primary server and multiple backup servers, and the primary server is a time synchronization source for the switch; The adaptive time synchronization method comprises: Sending a first time synchronization request to the plurality of backup servers through the switch; Collecting real-time network status data of the plurality of backup servers based on the first time synchronization request; Evaluate the priorities of the multiple backup servers according to the historical response time data, time source type information and the real-time network status data of the multiple backup servers to obtain a backup server priority evaluation result; When the abnormality detection information of the primary server meets the preset condition, an updated primary server is determined from the plurality of backup servers according to the backup server priority evaluation result.

[0007] In one embodiment, the step of evaluating the priorities of the multiple backup servers according to the historical response time data of the multiple backup servers, the time source type information, and the real-time network status data to obtain the backup server priority evaluation result includes: Determine the response time stability index, the historical failure rate index and the time source accuracy level of the plurality of backup servers based on the historical response time data and the time source type information; Determine the network delay index and the server load rate index of the plurality of backup servers based on the real-time network status data; Based on the response time stability index, the historical failure rate index, the time source accuracy level, the network delay index and the server load rate index, the priorities of the multiple backup servers are evaluated to obtain a backup server priority evaluation result.

[0008] In one embodiment, the step of determining the response time stability index, the historical failure rate index, and the time source accuracy level of the multiple backup servers based on the historical response time data and the time source type information includes: Determine a response time stability index and a historical failure rate index of the plurality of backup servers based on the historical response time data; Determine server level information or hardware clock type information of the plurality of backup servers based on the time source type information; The time source accuracy levels of the plurality of backup servers are determined based on the server hierarchy information or the hardware clock type information.

[0009] In one embodiment, the step of determining the network delay index and the server load rate index of the plurality of backup servers based on the real-time network status data comprises: Determine the round trip delay, processor utilization, memory utilization, and time synchronization request processing queue length of the plurality of backup servers based on the real-time network status data; Determining network delay indicators of the plurality of backup servers according to the round-trip delay; The server load rate indicators of the plurality of backup servers are determined according to the processor utilization, the memory utilization, and the time synchronization request processing queue length.

[0010] In one embodiment, when the abnormality detection information of the primary server meets the preset condition, the step of determining an updated primary server from the multiple backup servers according to the backup server priority evaluation result includes: When the abnormality detection information of the primary server meets the preset conditions, determining the target server from the multiple backup servers according to the backup server priority evaluation result; Sending a second time synchronization request to the target server through the switch, where the time interval for sending the second time synchronization request is shorter than the time interval for sending the first time synchronization request; Determine a time accuracy verification result based on the second time synchronization request; When the time verification result is that the target server passes the time accuracy verification, the target server is determined to be the updated main server.

[0011] In one embodiment, the step of determining a time accuracy check result based on the second time synchronization request includes: Collecting first time deviation information of the target server based on the second time synchronization request; The second time deviation information of the main server is obtained, and a time accuracy verification result is determined based on the first time deviation information and the second time deviation information.

[0012] In one embodiment, when the abnormality detection information of the primary server meets the preset condition, before the step of determining the updated primary server from the multiple backup servers according to the backup server priority evaluation result, it also includes: Collecting continuous timeout information and second time deviation information of the main server; The abnormality detection information of the main server is determined according to the continuous timeout information and the second time deviation information.

[0013] In addition, to achieve the above purpose, the present application also proposes an adaptive time synchronization device, the adaptive time synchronization device comprising: A sending module, used for sending a first time synchronization request to multiple backup servers through a switch; A collection module, configured to collect real-time network status data of the plurality of backup servers based on the first time synchronization request; An evaluation module, configured to evaluate the priorities of the multiple backup servers according to the historical response time data of the multiple backup servers, the time source type information, and the real-time network status data, and obtain a backup server priority evaluation result; The determination module is used to determine an updated main server from the multiple backup servers according to the backup server priority evaluation result when the abnormality detection information of the main server meets the preset conditions.

[0014] In addition, to achieve the above-mentioned purpose, the present application also proposes an adaptive time synchronization device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, and the computer program is configured to implement the steps of the adaptive time synchronization method described above.

[0015] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the adaptive time synchronization method described above are implemented.

[0016] In addition, to achieve the above-mentioned purpose, the present application also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the steps of the adaptive time synchronization method described above are implemented.

[0017] One or more technical solutions proposed in this application have at least the following technical effects: An adaptive time synchronization method is provided, which is applied to an adaptive time synchronization system. The adaptive time synchronization system includes a switch and multiple network time protocol servers. The network time protocol servers include a main server and multiple backup servers, and the main server is a time synchronization source for the switch. The adaptive time synchronization method includes: sending a first time synchronization request to the multiple backup servers through the switch; collecting real-time network status data of the multiple backup servers based on the first time synchronization request; evaluating the priorities of the multiple backup servers according to the historical response time data, time source type information and the real-time network status data of the multiple backup servers, and obtaining a backup server priority evaluation result; when the abnormal detection information of the main server meets the preset conditions, determining an updated main server from the multiple backup servers according to the backup server priority evaluation result, in this way, the adaptive time synchronization system can quickly and intelligently switch to the optimal backup server when the main server fails, ensuring that the system's time synchronization service continues to run stably, and ensuring the high availability of the adaptive time synchronization system and the accuracy of time synchronization. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0019] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0020] Figure 1 A flowchart of the first embodiment of the adaptive time synchronization method of the present application is provided; Figure 2 A flowchart of the second embodiment of the adaptive time synchronization method of the present application is provided; Figure 3 A brief flowchart of the adaptive time synchronization method provided in Example 2 of the present application; Figure 4 This is a schematic diagram of the module structure of the adaptive time synchronization device according to an embodiment of the present application; Figure 5 A schematic diagram of the device structure of the hardware operating environment involved in the adaptive time synchronization method in the embodiment of the present application.

[0021] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0022] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.

[0023] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.

[0024] The main solution of the embodiment of the present application is: sending a first time synchronization request to multiple backup servers through a switch; collecting real-time network status data of the multiple backup servers based on the first time synchronization request; evaluating the priorities of the multiple backup servers according to the historical response time data, time source type information and the real-time network status data of the multiple backup servers to obtain a backup server priority evaluation result; when the abnormality detection information of the main server meets the preset conditions, determining an updated main server from the multiple backup servers according to the backup server priority evaluation result.

[0025] Since existing time synchronization solutions are generally based on fixed NTP servers, by presetting specific NTP servers, client devices in the network periodically send time synchronization requests to these servers, thereby calibrating device time with standard time. However, the fixed selection mechanism limits the ability of the time synchronization system to adapt to network changes, resulting in the inability to effectively switch under high load or failure conditions. How to select the optimal NTP server during the time synchronization process and maintain the accuracy of time synchronization has become a problem to be solved.

[0026] The present application provides a solution that enables the adaptive time synchronization system to quickly and intelligently switch to the optimal backup server when a primary server fails, ensuring the continuous and stable operation of the system's time synchronization service, and ensuring the high availability of the adaptive time synchronization system and the accuracy of time synchronization.

[0027] It should be noted that the execution subject of this embodiment may be a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or an electronic device capable of realizing the above functions, an adaptive time synchronization system, etc. The following takes the adaptive time synchronization system as an example to illustrate this embodiment and the following embodiments.

[0028] Based on this, the embodiment of the present application provides an adaptive time synchronization method, referring to Figure 1 , Figure 1 This is a flowchart of the first embodiment of the adaptive time synchronization method of the present application.

[0029] In this embodiment, the adaptive time synchronization method is applied to an adaptive time synchronization system, the adaptive time synchronization system includes a switch and multiple network time protocol servers, the network time protocol servers include a primary server and multiple backup servers, the primary server is the time synchronization source of the switch; the adaptive time synchronization method includes steps S10 to S40: Step S10, sending a first time synchronization request to the multiple backup servers through the switch; It should be noted that in the adaptive time synchronization system, the switch, as a client device, is responsible for sending NTP (Network Time Protocol Server) time synchronization requests and communicating with the selected Network Time Protocol server (hereinafter referred to as NTP server) according to the selection result of the adaptive selection module. The NTP server includes a primary server and multiple backup servers. The primary server and the backup servers are connected to the switch through the network interface. The primary server is the time synchronization source of the switch and provides accurate time information for the switch. The backup server is used to provide time synchronization services when the original primary server is unavailable and become the updated primary server. Both the primary NTP server and the backup NTP server are connected to the switch through their network interfaces.

[0030] Among them, the adaptive selection module is integrated inside the switch and connected to the network interface of the switch to receive response data from the NTP server. It is responsible for implementing the server selection logic, analyzing historical response data and combining it with real-time data to predict the optimal time synchronization source and intelligently select the optimal NTP server from multiple NTP servers for time synchronization.

[0031] It should be noted that the switch will periodically send a time synchronization request carrying the current timestamp of the switch, ie, a first time synchronization request, to all backup servers to obtain real-time network status data of multiple backup servers according to the response data of the backup servers.

[0032] Step S20: collecting real-time network status data of the multiple backup servers based on the first time synchronization request; It should be understood that when the switch receives response data from multiple backup servers based on the first time synchronization request feedback, the adaptive selection module will obtain the timestamp information of each backup server receiving the first time synchronization request and sending the response data based on the feedback response data, and at the same time monitor the real-time network status data of each backup server through the network interface, such as response time, packet loss rate, and bandwidth utilization.

[0033] Step S30, evaluating the priorities of the multiple backup servers according to the historical response time data, time source type information and the real-time network status data of the multiple backup servers to obtain a backup server priority evaluation result; It should be noted that historical response time data refers to all response time data collected from multiple backup servers within a certain time window (such as the past hour). Based on historical response time data, the response volatility and failure rate of multiple backup servers can be evaluated. Time source type information refers to the level (such as Stratum level) or hardware clock type (GPS / atomic clock) of the backup server, which can be used to evaluate the time accuracy of the backup server.

[0034] It should be understood that by analyzing the historical response time data, time source type information, and real-time network status data of each backup server, the scores of multiple key performance indicators of each backup server can be obtained based on these data to evaluate the performance and reliability of each backup server and obtain the backup server priority evaluation results. By comprehensively analyzing the historical response time data, time source type information, and real-time network status data, the optimal NTP server is intelligently selected for time synchronization, thereby improving the accuracy and efficiency of time synchronization.

[0035] Step S40, when the abnormality detection information of the primary server meets the preset conditions, determining an updated primary server from the multiple backup servers according to the backup server priority evaluation result.

[0036] It should be noted that the abnormal detection information is used to trigger the switching of the NTP server, which can be obtained by detecting the real-time network status data of the main server. When a failure of the main server is detected, that is, when the abnormal detection information meets the preset conditions, the backup server with the highest priority among the multiple backup servers will be determined as the updated main server according to the backup server priority evaluation result. By introducing a backup NTP server, time synchronization can still be performed when the main server is unavailable, thereby enhancing the reliability and flexibility of the system.

[0037] In a feasible implementation manner, before step S40, the following steps may be included: collecting continuous timeout information and second time deviation information of the main server; and determining abnormality detection information of the main server according to the continuous timeout information and the second time deviation information.

[0038] It should be noted that when the switch sends NTP requests to the main server periodically, the timer will be started to wait for the response of the main server, and wait for the response of the main server within the preset timeout period. If the time synchronization information of the main server response is received within the preset timeout period, the timeout counter will be reset to 0, indicating that there is no continuous timeout. If the time synchronization information of the main server response is not received within the preset timeout period, the timeout counter will be increased by 1, indicating that a timeout has occurred. The continuous timeout information of the main server can be determined based on the count of the timeout counter, thereby determining whether the main server is in an unavailable state.

[0039] It should be understood that the NTP request periodically sent by the switch to the main server contains the current timestamp of the switch. After receiving the NTP request, the main server will immediately return an NTP response message, which contains the current timestamp of the main server. Based on the NTP protocol, the time deviation information can be calculated according to the current timestamp of the switch and the current timestamp of the main server to obtain the second time deviation information to determine whether the time synchronization accuracy of the main server meets the requirements. According to the continuous timeout information and the time deviation information, the abnormal detection information of the main server can be obtained, thereby predicting whether the main server may fail.

[0040] Exemplarily, when the main server is detected to have timed out continuously (such as no response to 3 NTP requests) according to the continuous timeout information or when the time deviation is detected to exceed a threshold (such as ±100ms) according to the second time deviation information, it will be determined that the abnormal detection information of the main server meets the preset conditions. At this time, the adaptive selection module will switch the main server for time synchronization selected by the switch.

[0041] In a feasible implementation, step S40 may include steps S41 to S44: Step S41, when the abnormality detection information of the primary server meets the preset conditions, determining the target server from the multiple backup servers according to the backup server priority evaluation result; It should be understood that when the abnormal detection information of the main server meets the preset conditions, that is, when the main server fails, the backup server with the highest score will be determined as the target server from multiple backup servers based on the backup server priority evaluation results, and a temporary time synchronization channel will be established between the switch and the target server.

[0042] Step S42, sending a second time synchronization request to the target server through the switch, wherein the time interval for sending the second time synchronization request is shorter than the time interval for sending the first time synchronization request; It should be understood that the second time synchronization request sent to the target server through the switch based on the temporary time synchronization channel is different from the first time synchronization request sent periodically to all backup servers. The second time synchronization request is a fast verification request (short interval request, such as once per second), and its sending time interval is lower than the time interval for sending the first time synchronization request. After the target server is determined, it will be triggered immediately to confirm the time accuracy of the newly selected backup server through the fast verification mechanism in a short time.

[0043] Step S43, determining a time accuracy check result based on the second time synchronization request; It should be understood that after sending the second time synchronization request to the target server through the switch, the target server will return an NTP response message, and the switch will calculate the time deviation of the target server based on the NTP response information to evaluate the time accuracy of the target server and determine whether the target server meets the switch's requirements for time synchronization accuracy.

[0044] In a feasible implementation, step S43 may include steps S431-S432: Step S431, collecting first time deviation information of the target server based on the second time synchronization request; It should be noted that when the switch sends the second time synchronization request to the target server through the temporary time synchronization channel, the target server will immediately return an NTP response message containing its current timestamp. After the switch receives the response message, the adaptive selection module will parse the timestamp of the target server according to the calculation rules of the NTP protocol, and combine the timestamp recorded when the switch sends the second time synchronization request and the timestamp when the target server returns the response, calculate the time deviation between the two, and obtain the first time deviation information.

[0045] Step S432: Acquire the second time deviation information of the main server, and determine the time accuracy verification result based on the first time deviation information and the second time deviation information.

[0046] It should be understood that while collecting the first time deviation information of the target server, the adaptive selection module will synchronously obtain the second time deviation information of the main server. The second time deviation information comes from the historical record regularly updated before the failure of the main server. According to the second time deviation information, the time deviation value calculated when the switch and the main server communicated successfully for the last time can be determined. According to the first time deviation information and the time deviation value of the last effective synchronization between the switch and the main server, the deviation comparison value can be calculated (obtained by difference). If the deviation comparison value is less than the preset deviation tolerance threshold, the time accuracy check result is determined to be that the target server passes the time accuracy check, otherwise the time accuracy check result is determined to be that the target service is abnormal and marked. Specifically, the preset deviation tolerance threshold is the maximum allowed absolute value of the time deviation. If the deviation comparison value exceeds, the server is determined to be unavailable, for example, ±10 ms. If the first target server fails the check, the next backup server is selected as the new target server in order of priority until the target server passes the time accuracy check.

[0047] Step S44: When the time verification result shows that the target server has passed the time accuracy verification, the target server is determined to be an updated main server.

[0048] It should be understood that if the time accuracy check result shows that the time synchronization accuracy of the target server meets the time synchronization accuracy requirements of the switch, the adaptive selection module will confirm that the target server is the updated master server. At this time, the switch will use the target server as the new time synchronization source, determine that the target server is the updated master server, and terminate the time synchronization connection with the original master server, and close the time synchronization channel with the original master server. After the switch, the status of the new master server is continuously monitored. If its performance deteriorates (such as increased latency) and causes the abnormal detection information of the master server to meet the preset conditions, the priority evaluation process is re-triggered.

[0049] The present embodiment provides an adaptive time synchronization method, which is applied to an adaptive time synchronization system. The adaptive time synchronization system includes a switch and multiple network time protocol servers, and the network time protocol servers include a main server and multiple backup servers, and the main server is the time synchronization source of the switch; the adaptive time synchronization method includes: sending a first time synchronization request to the multiple backup servers through the switch; collecting real-time network status data of the multiple backup servers based on the first time synchronization request; evaluating the priorities of the multiple backup servers according to the historical response time data, time source type information and the real-time network status data of the multiple backup servers, and obtaining a backup server priority evaluation result; when the abnormal detection information of the main server meets the preset conditions, determining an updated main server from the multiple backup servers according to the backup server priority evaluation result, in this way, the adaptive time synchronization system can quickly and intelligently switch to the optimal backup server when the main server fails, ensuring that the system's time synchronization service continues to run stably, and ensuring the high availability of the adaptive time synchronization system and the accuracy of time synchronization.

[0050] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the above-mentioned embodiment 1 can be referred to the above introduction, and will not be repeated in the following. Figure 2 , step S30 includes steps S31 to S33: Step S31, determining the response time stability index, the historical failure rate index and the time source accuracy level of the multiple backup servers based on the historical response time data and the time source type information; It should be understood that by analyzing the historical response time data of each backup server, the response volatility and failure rate of multiple backup servers can be evaluated to obtain a response time stability index and a historical failure rate index. By analyzing the time source type information of each backup server, the time source accuracy level of multiple backup servers can be evaluated.

[0051] In a feasible implementation, step S31 may include steps S311 to S313: Step S311, determining the response time stability index and the historical failure rate index of the plurality of backup servers based on the historical response time data; It should be noted that based on the historical response time data, all response time data collected from multiple backup servers within a preset time window (such as within the past 1 hour) can be obtained. By calculating the standard deviation of the historical response time, the response time stability index can be obtained to evaluate the volatility of the server response time. The smaller the standard deviation, the more stable the response time. The more stable the response time, the higher the priority. For example, if the standard deviation of the response time of a backup server in the past 1 hour is 5ms, while that of another server is 20ms, the former is more stable.

[0052] It should be noted that based on the historical response time data, the ratio of the number of server response timeouts or invalid responses to the total number of requests within a preset time window (such as the past 1 hour) can be obtained to obtain a historical failure rate index. For example, if a backup server has 3 timeouts in 100 requests, the historical failure rate index of the backup server is 3%.

[0053] Step S312, determining server level information or hardware clock type information of the plurality of backup servers based on the time source type information; It should be noted that the time source type information is the level of the backup server (such as the Stratum level) or the hardware clock type (GPS, atomic clock or other types of clocks), where the level of the backup server corresponds to the server level information, and the hardware clock type corresponds to the hardware clock type information. The time accuracy of different server levels is different, and the clock accuracy of different hardware clock types is different. The NTP protocol adopts a layered architecture, dividing the time server into different levels (Stratum). The server at each level obtains time from the upper level and provides time synchronization services to the lower level. According to the Stratum level classification in the NTP protocol, Stratum 0 is a reference clock source such as an atomic clock or GPS, and Stratum 1 is a server directly connected to Stratum0. The lower the level, the higher the time accuracy.

[0054] Step S313: determining the time source accuracy levels of the multiple backup servers based on the server level information or the hardware clock type information.

[0055] It should be understood that the time accuracy of the backup servers can be evaluated based on the server - level information or the hardware clock type information, and the time - source accuracy levels of multiple backup servers can be obtained. Exemplarily, the time - source accuracy level based on GPS or atomic clock is the highest and can be set to 10, while the time accuracy of the Stratum3 server is the lowest and can be set to 5.

[0056] Step S32: Determine the network latency index and the server load rate index of the multiple backup servers based on the real - time network status data; It should be understood that by analyzing the real - time network status data of each backup server, the current network performance and load status of multiple backup servers can be evaluated, and the network latency index and the server load rate index can be obtained.

[0057] In a feasible implementation manner, step S32 may include steps S321 to S323: Step S321: Determine the round - trip delay, processor utilization rate, memory utilization rate, and the length of the time - synchronization request processing queue of the multiple backup servers based on the real - time network status data; It should be understood that after obtaining the real - time network status data through the network interface of the backup server, the round - trip delay, processor utilization rate, memory utilization rate, and the length of the time - synchronization request processing queue of multiple backup servers can be determined based on the real - time network status data. Among them, the round - trip delay can be directly measured by the time difference between the last NTP request and response cycle. The processor utilization rate (i.e., CPU utilization rate), memory utilization rate, and the length of the time - synchronization request processing queue can be obtained from the monitoring tools or APIs of the server operating system when collecting the real - time network status data. The CPU utilization rate is the proportion of the CPU occupied within a preset time, expressed as a percentage; the memory utilization rate is the proportion of the used memory in the total memory; the length of the time - synchronization request processing queue is the length of the server NTP request processing queue, that is, the number of current NTP requests waiting to be processed.

[0058] Step S322: Determine the network latency index of the multiple backup servers according to the round - trip delay; It should be understood that by converting the round - trip delay (Round - Trip Time, RTT) into a delay score, the network latency index can be obtained. The lower the RTT, the higher the network latency index and the higher the priority. For example, the latency index corresponding to RTT ≤ 10ms is 10; the latency index corresponding to 0ms < RTT ≤ 50ms is 7; the latency index corresponding to RTT > 50ms is 3.

[0059] Step S323: determining server load rate indicators of the plurality of backup servers according to the processor utilization, the memory utilization, and the time synchronization request processing queue length.

[0060] It should be noted that for each backup server, the weighted average of its CPU utilization, memory utilization, and NTP request processing queue length can be calculated as the load rate indicator of the backup server. The servers are sorted according to the load rate. The lower the load rate (that is, the lower the CPU and memory utilization, and the shorter the NTP request queue), the higher the load rate indicator and the higher the priority.

[0061] Step S33, evaluating the priorities of the multiple backup servers based on the response time stability index, the historical failure rate index, the time source accuracy level, the network delay index and the server load rate index to obtain a backup server priority evaluation result.

[0062] It should be understood that the response time stability index is used to determine the short-term consistency of the backup server's time synchronization, the historical failure rate index is used to determine the potential risk of future failures of the backup server, the time source accuracy level is used to determine the long-term reliability of the backup server's time synchronization, the network latency index is used to determine the real-time communication efficiency of the backup server, and the server load rate index is used to determine the current availability of the backup server. The performance and reliability of each backup server can be evaluated by combining the response time stability index, the historical failure rate index, the time source accuracy level, the network latency index, and the server load rate index to obtain the backup server priority evaluation result.

[0063] Specifically, when evaluating the priorities of multiple backup servers based on the response time stability index, historical failure rate index, time source accuracy level, network latency index, and server load rate index, the original score of each indicator must be normalized to a range of 0 to 100 points, and then weighted and summed to obtain the priority of each backup server, sorted from high to low by comprehensive score, and the backup server with the highest score is selected as the optimal candidate. If the scores are the same, the server with a higher time source accuracy level or lower network latency is preferred.

[0064] This embodiment provides an adaptive time synchronization method, which realizes a comprehensive evaluation of the backup server from historical performance, real-time status to hardware attributes, ensuring that the priority sorting has both long-term stability and can quickly respond to changes in the network environment, thereby improving the reliability and accuracy of the adaptive time synchronization system.

[0065] For example, to help understand the implementation process of the adaptive time synchronization method obtained by combining this embodiment with the above-mentioned embodiment 1, please refer to Figure 3 , Figure 3 A brief flowchart of an adaptive time synchronization method is provided, specifically: After starting the adaptive selection module, the switch initiates a time synchronization request, records the backup server response time, obtains historical response time data, and analyzes the historical response time data, time source type information, and real-time network status data. The optimal server is selected as the primary server (primary device) based on the backup server priority evaluation result. If the primary server fails or times out, that is, when the abnormal detection information of the primary server meets the preset conditions, the latest backup server priority evaluation result is obtained, and then the backup server is switched to according to the backup server priority evaluation result to ensure the continuity of time synchronization. During the whole process, the switch maintains communication with the selected server to achieve accurate time synchronization.

[0066] It should be noted that the above examples are only used to understand the present application and do not constitute a limitation on the adaptive time synchronization method of the present application. More simple transformations based on this technical concept are all within the scope of protection of the present application.

[0067] This application also provides an adaptive time synchronization device, please refer to Figure 4 , the adaptive time synchronization device comprises: A sending module 10, configured to send a first time synchronization request to multiple backup servers via a switch; A collection module 20, configured to collect real-time network status data of the plurality of backup servers based on the first time synchronization request; An evaluation module 30, configured to evaluate the priorities of the multiple backup servers according to the historical response time data of the multiple backup servers, the time source type information, and the real-time network status data, and obtain a backup server priority evaluation result; The determination module 40 is configured to determine an updated main server from among the plurality of backup servers according to the backup server priority evaluation result when the abnormality detection information of the main server meets a preset condition.

[0068] In one embodiment, the evaluation module 30 is also used to determine the response time stability index, historical failure rate index and time source accuracy level of the multiple backup servers based on the historical response time data and the time source type information; determine the network delay index and server load rate index of the multiple backup servers based on the real-time network status data; evaluate the priorities of the multiple backup servers based on the response time stability index, the historical failure rate index, the time source accuracy level, the network delay index and the server load rate index to obtain a backup server priority evaluation result.

[0069] In one embodiment, the evaluation module 30 is also used to determine the response time stability index and the historical failure rate index of the multiple backup servers based on the historical response time data; determine the server hierarchy information or the hardware clock type information of the multiple backup servers based on the time source type information; determine the time source accuracy level of the multiple backup servers based on the server hierarchy information or the hardware clock type information.

[0070] In one embodiment, the evaluation module 30 is also used to determine the round-trip delay, processor utilization, memory utilization and time synchronization request processing queue length of the multiple backup servers based on the real-time network status data; determine the network latency indicators of the multiple backup servers according to the round-trip delay; determine the server load rate indicators of the multiple backup servers according to the processor utilization, the memory utilization and the time synchronization request processing queue length.

[0071] In one embodiment, the determination module 40 is further configured to determine a target server from the plurality of backup servers according to the backup server priority evaluation result when the abnormality detection information of the primary server meets a preset condition; A second time synchronization request is sent to the target server through the switch, wherein the time interval for sending the second time synchronization request is shorter than the time interval for sending the first time synchronization request; a time accuracy check result is determined based on the second time synchronization request; and when the time check result is that the target server passes the time accuracy check, the target server is determined to be an updated master server.

[0072] In one embodiment, the determination module 40 is also used to collect the first time deviation information of the target server based on the second time synchronization request; obtain the second time deviation information of the main server, and determine the time accuracy verification result based on the first time deviation information and the second time deviation information.

[0073] In one embodiment, the determination module 40 is further configured to collect continuous timeout information and second time deviation information of the main server; and determine abnormality detection information of the main server according to the continuous timeout information and the second time deviation information.

[0074] The adaptive time synchronization device provided by the present application adopts the adaptive time synchronization method in the above embodiment, which can solve the technical problem of how to select the optimal NTP server in the process of time synchronization and maintain the accuracy of time synchronization. Compared with the prior art, the beneficial effects of the adaptive time synchronization device provided by the present application are the same as the beneficial effects of the adaptive time synchronization method provided by the above embodiment, and other technical features in the adaptive time synchronization device are the same as the features disclosed in the above embodiment method, which will not be repeated here.

[0075] The present application provides an adaptive time synchronization device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the adaptive time synchronization method in the above-mentioned embodiment one.

[0076] Reference below Figure 5 , which shows a schematic diagram of the structure of an adaptive time synchronization device suitable for implementing the embodiment of the present application. The adaptive time synchronization device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 5 The adaptive time synchronization device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0077] like Figure 5As shown, the adaptive time synchronization device may include a processing device 1001 (such as a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a ROM (Read Only Memory) 1002 or a program loaded from a storage device 1003 to a RAM (Random Access Memory) 1004. In the RAM 1004, various programs and data required for the operation of the adaptive time synchronization device are also stored. The processing device 1001, the ROM 1002, and the RAM 1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, an LCD (Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the adaptive time synchronization device to communicate with other devices wirelessly or by wire to exchange data. Although the figure shows an adaptive time synchronization device with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or have alternatively.

[0078] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.

[0079] The adaptive time synchronization device provided by the present application adopts the adaptive time synchronization method in the above embodiment, which can solve the technical problem of how to select the optimal NTP server in the process of time synchronization and maintain the accuracy of time synchronization. Compared with the prior art, the beneficial effects of the adaptive time synchronization device provided by the present application are the same as the beneficial effects of the adaptive time synchronization method provided by the above embodiment, and other technical features in the adaptive time synchronization device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.

[0080] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.

[0081] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

[0082] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, and the computer-readable program instructions are used to execute the adaptive time synchronization method in the above-mentioned embodiment.

[0083] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, RAM (Random Access Memory), ROM (Read Only Memory), EPROM (Erasable Programmable Read Only Memory) or flash memory, optical fiber, CD-ROM (CD-Read Only Memory, portable compact disk read-only memory), optical storage device, magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.

[0084] The computer-readable storage medium may be included in the adaptive time synchronization device; or may exist independently without being assembled into the adaptive time synchronization device.

[0085] The above-mentioned computer-readable storage medium carries one or more programs. When the above-mentioned one or more programs are executed by the adaptive time synchronization device, the adaptive time synchronization device: sends a first time synchronization request to multiple backup servers through a switch; collects real-time network status data of the multiple backup servers based on the first time synchronization request; evaluates the priorities of the multiple backup servers according to the historical response time data, time source type information and real-time network status data of the multiple backup servers to obtain backup server priority evaluation results; when the abnormality detection information of the main server meets the preset conditions, determines an updated main server from the multiple backup servers according to the backup server priority evaluation results.

[0086] Computer program code for performing the operations of the present application may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a LAN (Local Area Network) or a WAN (Wide Area Network), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0087] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0088] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.

[0089] The readable storage medium provided in the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned adaptive time synchronization method, and can solve the technical problem of how to select the optimal NTP server in the process of time synchronization and maintain the accuracy of time synchronization. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in the present application are the same as the beneficial effects of the adaptive time synchronization method provided in the above-mentioned embodiment, and will not be repeated here.

[0090] The present application also provides a computer program product, including a computer program, which implements the steps of the above-mentioned adaptive time synchronization method when executed by a processor.

[0091] The computer program product provided by the present application can solve the technical problem of how to select the optimal NTP server in the process of time synchronization and maintain the accuracy of time synchronization. Compared with the prior art, the beneficial effects of the computer program product provided by the present application are the same as the beneficial effects of the adaptive time synchronization method provided by the above embodiment, which will not be repeated here.

[0092] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.

Claims

1. An adaptive time synchronization method, characterized in that: The adaptive time synchronization method is applied to an adaptive time synchronization system, the adaptive time synchronization system includes a switch and multiple network time protocol servers, the network time protocol servers include a main server and multiple backup servers, the main server is the time synchronization source of the switch; The adaptive time synchronization method comprises: Sending a first time synchronization request to the plurality of backup servers through the switch; Collecting real-time network status data of the plurality of backup servers based on the first time synchronization request; Evaluate the priorities of the multiple backup servers according to the historical response time data, time source type information and the real-time network status data of the multiple backup servers to obtain a backup server priority evaluation result; When the abnormality detection information of the primary server meets the preset condition, an updated primary server is determined from the plurality of backup servers according to the backup server priority evaluation result.

2. The method according to claim 1, characterized in that The step of evaluating the priorities of the multiple backup servers according to the historical response time data, the time source type information and the real-time network status data of the multiple backup servers to obtain the backup server priority evaluation result comprises: Determine the response time stability index, the historical failure rate index and the time source accuracy level of the plurality of backup servers based on the historical response time data and the time source type information; Determine the network delay index and the server load rate index of the plurality of backup servers based on the real-time network status data; Based on the response time stability index, the historical failure rate index, the time source accuracy level, the network delay index and the server load rate index, the priorities of the multiple backup servers are evaluated to obtain a backup server priority evaluation result.

3. The method according to claim 2, characterized in that The step of determining the response time stability index, the historical failure rate index and the time source accuracy level of the plurality of backup servers based on the historical response time data and the time source type information comprises: Determine a response time stability index and a historical failure rate index of the plurality of backup servers based on the historical response time data; Determine server level information or hardware clock type information of the plurality of backup servers based on the time source type information; The time source accuracy levels of the plurality of backup servers are determined based on the server hierarchy information or the hardware clock type information.

4. The method according to claim 2, characterized in that The step of determining the network delay index and the server load rate index of the plurality of backup servers based on the real-time network status data comprises: Determine the round trip delay, processor utilization, memory utilization, and time synchronization request processing queue length of the plurality of backup servers based on the real-time network status data; Determining network delay indicators of the plurality of backup servers according to the round-trip delay; The server load rate indicators of the plurality of backup servers are determined according to the processor utilization, the memory utilization, and the time synchronization request processing queue length.

5. The method according to claim 1, characterized in that The step of determining an updated main server from the plurality of backup servers according to the backup server priority evaluation result when the abnormality detection information of the main server meets the preset condition comprises: When the abnormality detection information of the primary server meets the preset conditions, determining the target server from the multiple backup servers according to the backup server priority evaluation result; Sending a second time synchronization request to the target server through the switch, where the time interval for sending the second time synchronization request is shorter than the time interval for sending the first time synchronization request; Determine a time accuracy verification result based on the second time synchronization request; When the time verification result is that the target server passes the time accuracy verification, the target server is determined to be the updated main server.

6. The method according to claim 5, characterized in that The step of determining a time accuracy check result based on the second time synchronization request comprises: Collecting first time deviation information of the target server based on the second time synchronization request; The second time deviation information of the main server is obtained, and a time accuracy verification result is determined based on the first time deviation information and the second time deviation information.

7. The method according to any one of claims 1 to 6, characterized in that Before the step of determining an updated main server from the plurality of backup servers according to the backup server priority evaluation result when the abnormality detection information of the main server meets the preset condition, the method further includes: Collecting continuous timeout information and second time deviation information of the main server; The abnormality detection information of the main server is determined according to the continuous timeout information and the second time deviation information.

8. An adaptive time synchronization device, characterized in that: The device comprises: A sending module, used for sending a first time synchronization request to multiple backup servers through a switch; A collection module, configured to collect real-time network status data of the plurality of backup servers based on the first time synchronization request; An evaluation module, configured to evaluate the priorities of the multiple backup servers according to the historical response time data of the multiple backup servers, the time source type information, and the real-time network status data, and obtain a backup server priority evaluation result; The determination module is used to determine an updated main server from the multiple backup servers according to the backup server priority evaluation result when the abnormality detection information of the main server meets the preset conditions.

9. An adaptive time synchronization device, characterized in that: The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the adaptive time synchronization method according to any one of claims 1 to 7.

10. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the adaptive time synchronization method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • System and method for verifying instant clock accuracy

    CN101373390A

  • Clock synchronization method and system

    CN107231208A

  • Main and standby server switching method and device

    CN118250152A

  • Real-time clock verification method and device, equipment, storage medium and vehicle

    CN118611807A

  • Timestamp precision verification method and system for network equipment

    CN118694462A