⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readme.msntp

📁 linux下的获取Internet time的程式
💻 MSNTP
📖 第 1 页 / 共 2 页
字号:
commands, the installation is finished!You can use it as a simple unprivileged command to check the time, quiteindependently of whether it is running as a time-updating daemon or server, orwhether you are running xntp.  You can run it in daemon mode without updatingthe clock, to check for drift, but it may fail if the clock is changed underits feet.  Unfortunately, you cannot listen to broadcasts without privilege.If it is used with the -a option to keep the time synchronised, it is best torun it as one of root's cron jobs - for many systems, running it once a dayshould be adequate, but it will depend on the reliability of the local clock.The author runs it this way with -a and -x - see below.If it is used with the -r option to set the time (instead of the rdate or datecommands), it should be used interactively and either on a lightly loadedsystem or at a high priority.  You should then check the result by running itin display mode.You are advised NOT to run it with the -r option in a cron job, though this isnot locked out.  If you have to (for example under HP-UX before 10.0), be sureto run it as the highest priority that will not cause other system problems andset the maximum automatic change to as low a value as you can get away with.WARNING: adjtime is more than a bit sick on many systems, and will ignore largecorrections, usually without any form of hint that it has done so.  It is often(even usually) necessary to reset the clock to approximately the right timeusing the -r option before using the -a and -x options to keep it correct.It can be started as a time-updating daemon with the -a and -x options (or -rand -x if you must), and will perform some limited drift correction.  In thiscase, start it from any suitable system initialisation script and leave itrunning.  Note that it will stop if it thinks that the time difference or drifthas got out of control, and you will need to reset the time and restart it byhand.In daemon mode, it will survive its time server or network disappearing for awhile, but will eventually fail, and will fail immediately if the network callreturns an unexpected error.  If this is a problem, you can start it (say,hourly or nightly) from cron, and it will fail if it is already running(provided that you haven't disabled or deleted the lock file).If it is used as a server, it should be started from any suitable systeminitialisation script, just like any other daemon.  It must be started afterthe networking, of course.  To run it in both server modes, start one copy with the -B option and one with the -S option.Simple Examples of Use----------------------Many people use it solely to check the time of their system, especially as across-check on xntpd.  You do not need privilege and it will not cause troubleto the local network, so you can use it on someone else's system!  You canspecify one server or several.  For example:    msntp ntp.server.local ntp.server.neighbourYou can use it to check how your system is drifting, but it isn't very good atthis if the system is drifting very badly (in which case use the previoustechnique and dc) or if you are running xntp.  You do not need privilege and itwill not cause trouble to the local network.  For example:    msntp -x 120 -f /tmp/msntp.state ntp.server.localMore generally, it is used to synchronise the clock, in which case you DO needroot privilege.  It can be used in many ways, but the author favours running itin daemon mode, started from a cron job, which will restart after power cutswith no attention, and send a mail message (if cron is configured to do that)when it fails badly.  For example, the author uses a root crontab entry on onesystem of:    15 0 * * * /bin/nice --10 /usr/local/bin/msntp -a -x 480 ntp.server.localIf you have a home computer, it can be set up to resynchronise each time youdial up.  For example, the author uses a /etc/ppp/ip-up.d/msntp file on hishome Linux system of:    #!/bin/sh    sleep 60    /bin/nice --10 /usr/local/sbin/msntp -r -P 60 ntp.server.local-a would be better, but adjtime is broken in Linux.Debugging or Hacking the Program--------------------------------Almost everybody who does this is likely to need to modify only the systeminterfaces.  While they are messy, they are pretty simple and have a simplespecification.  This is documented in comments in the source.  This isdescribed above.The main program SHOULD need no attention, though it may need the odd tweak tobypass compiler problems - please report these, if you encounter any.  Ifsomething looks odd while it is running, start by setting the -v option (lowercase), as for investigating network problems, and checking any diagnostics thatappear.  Note that most of it can be checked in display mode without harmingyour system.The client will sometimes give up, complaining about inconsistent timestamps orsimilar.  This can be caused by the server being rebooted and similar glitchesto the time - unfortunately, there is no reliable way to tell an ignorablefluctuation from a server up the spout.  If this happens annoyingly often,the -V option may help tie down the problem.  In actual use, it is simplestjust to restart the client in a cron job!If it needs more than this, then you will need to debug the source seriously.Start by putting an icepack on your head and pouring yourself a large whisky!While it is commented, it is not well commented, and much of the code interactsin complex and horrible ways.  This isn't so much because it lacks 'structure'as because one part needs to make assumptions about the numerical properties ofanother.The -W option (upper case) will print out a complete trace of everything itdoes, and this should be enough to tie down the problem.  It does distort thetiming a bit, but not usually too badly.  However, wading through that amountof gibberish (let alone looking at the source) is not a pleasant task.  If youare pretty sure that you have a bug, you may tell the author, and he may askfor a copy of the output - but he will reply rudely if you send thousands oflines of tracing to him by Email!Note that there are a fair number of circumstances where its error recoverycould be better, but is left as it is to keep the code simple.  Most of theseshould be pretty rare.Changes in Version 1.2----------------------The main change was the addition of the daemon mode for drift correction (i.e.the -x option).  The daemon code is complex and has a lot of special-casing forstrange circumstances, not all of which are testable in practice.A lot of the code was reordered while doing this.  The output was slightlydifferent - considerably different with -V.The error estimation for broadcasts was modified, and should bear more relationto reality.  It remains a guess, as there is no way to get decent error errorestimates under such circumstances.The -B option is now in minutes, and has a different permissible range anddefault value.The argument consistency checking for broadcasts was tightened up a bit, and afew other internal checks added.  These should not affect any reasonablerequirement.A couple of new functions were added to the portability base, but they don'tuse any non-standard new facilities.  However, the specification of thefunctions has changed slightly.Changes in Version 1.3----------------------The main change was the addition of the restarting facility for daemon mode(i.e. the -f option), which is pretty straightforward.There were also a lot of minor changes to the paranoia code in daemon mode, totry to separate out the case of a demented server from network and other'ignorable' problems.  These are not entirely successful.Changes in Version 1.4 and 1.5------------------------------There turned out to be a couple of places where the author misunderstood thespecification of NTP, which affect only its use in server mode.  The mainchange is to use stratum 15 instead of stratum 0.And there were some more relaxations of the paranoia code, to allow for moreerratic servers, plus a kludge to improve restarting in daemon mode after aperiod of down time has unsynchronised the clock.  There is also anincompatible change to the debugging options to add a new level - the old -Voption is now -W, and -V is an intermediate one for debugging daemon mode - butthey are both hacker's facilities, and not for normal use.Version 1.5 adds some very minor fixes.Changes in Version 1.6----------------------The first change is support for multiple server addresses - it uses these in around-robin fashion.  This may be useful when you have access to severalservers, all of which are a bit iffy.  This means that the restart file formatis incompatible with msntp 1.5.It has also been modified to reset itself automatically after detecting aninconsistency in its server's timestamps, because the author got sick of thefailures.  It writes a comment to syslog (uniquely) in such cases.The ability to query a daemon save file was added.Related to the above, the -E argument has been redefined to mean an error boundon various internal times (which is what it had become, anyway) and a -P optionintroduced to be what the -E argument was documented to be.The lock and save file handling have been changed to allow defaults to be setat installation time, and to be overridable at run-time.  To disable theseat either stage, simply set the file names to the null string.And there have been the usual changes for portability, as standards have beenmodified and/or introduced.Future Versions---------------There are unlikely to be any, except probably one to fix bugs in version 1.6.I attempted to put support for intermittent connexions (e.g. dial-up) into thedaemon mode, but doing so needs so much code reorganisation that it isn't worthit.  What needs doing for that is to separate the socket handling from thetimekeeping, so that they can be run asynchronously (either in separateprocesses or threads), and to look up a network name and open a socket onlywhen prodded (and to close it immediately thereafter).  So just running itwith the -r option is the current best solution.I also attempted to put support for the "Unix 2000" interfaces into the code.Ha, ha.  Not merely do very few systems define socklen_t (needed for IPv6support), but "Unix 2000" neither addresses the leap second problem nor evenprovides an adjtime replacement!  Some function like the latter is critical,not so much because of the gradual change, but because of its atomicity;without it, msntp really needs to be made non-interruptible, and that brings ina ghastly number of system-dependencies.Realistically, it needs a complete rewrite before adding any more function.And, worse, the Unix 'standards' need fixing, too.Miscellaneous-------------Thanks are due to Douglas M. Wells of Connection Technologies for helping theauthor with several IP-related conventions, to Sam Nelson of StirlingUniversity for testing it on some very strange systems, and to David Mills forclarifying what the NTP specification really is.Thanks are also due to several other people with locating bugs, findingappropriate options for the Makefile and passing on extension code andsuggestions.  As I am sure to leave someone out, I shall not name anyone else.Version 1.0 - October 1996.Version 1.1 - November 1996 - mainly portability improvements.Version 1.2 - January 1997 - mainly drift handling, but much reorganisation.Version 1.3 - February 1997 - daemon save file, and some robustness changes.Version 1.4 - May 1997 - relatively minor fixes, more diagnostic levels etc.Version 1.5 - December 1997 - some very minor fixesVersion 1.6 - October 2000 - quite a few miscellaneous changesNick Maclaren,University of Cambridge Computer Laboratory,New Museums Site, Pembroke Street, Cambridge CB2 3QG, England.Email:  nmm1@cam.ac.ukTel.:  +44 1223 334761    Fax:  +44 1223 334679

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -