Turn on the NTP clock server to turn the computer into a network time server

Turn on the NTP clock server to turn the computer into a network time server

Anyone familiar with Windows knows that in the computer system time setting, you can set the local computer time to synchronize with the Internet time server time, so that the computer will synchronize with the network time regularly, so you don’t have to worry about your computer after a long time. A time deviation occurred.

We all know that the time of the computer comes from the crystal oscillator on the motherboard, no matter how expensive your computer is, a few hundred dollars of N-hand goods, or tens of thousands of dollars, the time accuracy of this thing is as good as you buy. There will not be much difference in the accuracy of electronic watches for children. Is there no way to update the time automatically for computers in a non-Internet environment? Of course not! The computer uses a network timing protocol called NTP to provide time through the network. The NTP server maintains the time through a high-precision atomic clock (it is often said in the news that the error is not more than one second in ten thousand years. How big is the specific error? , It depends on the specific type of atomic clock), the client computer communicates with the NTP server, receives a high-precision and credible time source, calculates its own time error, and then corrects it.
Some people have said that my internet speed is very slow, and it takes a few minutes to open a webpage. If you measure your server time accurately, it will be more than ten seconds slower to transmit to me. What should I do? Don't worry, computer engineers have long considered this issue. The NTP protocol is certainly not that simple. In order to let more people understand this NTP protocol, let me talk about the principle algorithm: Suppose that the client C and server S are at the current moment, and their respective clock times are C1 and S1. At this moment, the client and server are performing Time synchronization, there should be such a dialogue between them: the client said to the server: "My time is C1." This sentence was heard by the server after the network delay t1, and the server said: "I am listening at S2. When you say that time is C1, and tell you at time S3."
This sentence was heard by the client at time C4 after a network delay of t2. t1+t2=(C4-C1)-(S3-S2)
This is the total delay time of two network transmissions. Assuming that the transmission and reception delays are equal, the single network transmission delay is t3=(t1+t2)/2. In this way, the last time the client receives the server is S3, and S3-t3 is the correct time to be corrected by the client.
Of course, the real NTP protocol is more complicated than this. After many calculations, the NTP timing accuracy of the WAN can usually reach 50ms, which is 1/20 second. It can be said that the timing requirements of ordinary people can be fully satisfied. If the data local area network and metropolitan area network have less routing exchanges, the network delay between multiple transmissions is relatively stable, there is no big deviation, and the timing accuracy can even reach 10ms.
So, let’s get back to the subject, in a non-Internet environment, to realize the time synchronization of the entire internal network, it is a very good way to move the NTP server to the local area network to provide time for other hosts, so that only one or a few of them are needed. Just keep the time of the time server accurate.
Suppose you find a computer to serve as an NTP server, and plan to buy an atomic clock to provide time to the server (Rb 60,000 clock, cesium clock 500,000, hydrogen clock 1.3 million), with a timing accuracy of 0.1ns to 5ns, the boss looks at you Thinks that the budget is too high and does not agree with you to buy an atomic clock, but requires you to fix the company’s internal timing issues within three days to prevent employees from leaving get off work early on the grounds that time is not allowed, otherwise you will be fired. So you spend 100 yuan to buy a GPS module from Taobao and connect it to your computer. The satellite timing is realized through GPS signals with a timing accuracy of 50ns. Next, we must find a way to achieve time synchronization within the company's intranet. Although many people know that Windows can be set to synchronize the time with the server, few people know that it can also be set as a time server in turn, just like the conversation between the client and the server we simulated just now, just let the client listen to others The query, and act as a server to answer it.

The previous pass was sold too long, so let’s just talk about dry goods. After entering Windows, press Windows+R to bring up the Run dialog box, enter regedit, open the "Registry Editor" after confirming, and select in turn from the tree list on the left side of the registry: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\ NtpServer, find Enabled on the right, double-click and change the value to 1, which means that the NTP server is set to be available. Then, expand HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Config in turn, find AnnounceFlags on the right, double-click to modify the value to 5, indicating that it is a reliable time source.

Turn on the NTP time server and turn your computer into a network time source

Finally, make sure that the Windows Time service of the computer keeps running. Under normal circumstances, the Windows computer service is turned on, right-click "My Computer" (Win10 calls this computer, and it hurts to change it), select "Manage", Open "Computer Management", select "Services and Applications" -> "Services" on the left, find Windows Time on the right, and you can see whether the service is running or not. In this interface, users can also set whether the service is started or disabled and many more. You have already configured the time server of the local area network. Now let everyone change the address of the Internet time server to the IP address of your server.
Article source: Anhui Jingzhun Electronic Technology Company

Guess you like

Origin blog.csdn.net/weixin_44990608/article/details/107041543