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

📄 readme.msntp

📁 linux下的获取Internet time的程式
💻 MSNTP
📖 第 1 页 / 共 2 页
字号:
MSNTP (Simple Network Time Protocol Utility) - Version 1.6----------------------------------------------------------Please read the file Copyright.msntp first.RFC 1305 (Network Time Protocol - NTP) is an attempt to provide globallyconsistent timestamps in an extremely hostile environment; it is fiendishlycomplicated and an impressive piece of virtuosity.  RFC 2030 (Simple NetworkTime Protocol - SNTP) which supersedes RFC 1769 describes a subset of this thatwill give excellent accuracy in most environments encountered in practice; ituses only the obvious algorithms that have been used since time immemorial.WARNING: the text version of RFC 1305 is incomplete, and omits the tables thatare in the Postscript version.  Unfortunately, these contain the only copy ofsome critical information.The canonical NTP code for Unix is the xntp suite, and is as complicated aswould be expected from reading RFC 1305.  While its code is moderately clean byUnix and C standards, version 3-5.86 is over 80,000 lines and unavoidablysystem-dependent.  A worse problem is that it is so badly fouled up by itsconfiguration mechanism that ab initio porting could be several weeks' work,even if the new system has all the necessary facilities and is bug free!SNTP Servers - Some Little-Known Facts--------------------------------------RFC 2030 states that SNTP clients should be used only at the lowest level,which is good practice.  It then states that SNTP servers should be used onlyat stratum 1 (i.e. top level), which is bizarre!  A far saner use of them wouldbe for the very lowest level of server, exporting solely to local clients thatdo not themselves act as servers to ANY system (e.g. on a Netware server,exporting only to the PCs that it manages).If the NTP network were being run as a directed acyclic graph (i.e. using SNTPrather than full NTP), with a diameter of D links and a maximum error per linkof E, the maximum synchronisation error would be D*E.  Reasonable figures for Dand E are 5 and 0.1 seconds, so this would be adequate for most uses.  Notethat the fact that the graph is acyclic is critical, which is one reason whySNTP client/servers must NEVER be embedded WITHIN an NTP network.The other reason is that inserting SNTP client/servers at a low stratum (butnot the root) of an NTP network could easily break NTP!  See RFC 1305 for why,but don't expect the answer to stand out at you.  It would be easy to extendMSNTP to a full-function client/server application, thus making it into a truealternative to xntp, but this incompatibility is why it MUST NOT be done.The above does not mean that the SNTP approach is unsatisfactory, but only thatit is incompatible with full NTP.  The author would favour a complete SNTPnetwork using the SNTP approach, and the statistical error reduction used inMSNTP, but it actually addresses a slightly different problem from thataddressed by NTP.  TANSTAAFL.FINAL WARNING: do NOT use this program to serve NTP requests from outside thesystems that you manage.  If you do this, and manage to break the timesynchronisation on other people's systems, you will be regarded veryunfavourably.  Actually, this should be possible only if their NTP client iscompletely broken, because MSNTP does its damnedest to declare its packets asthe lowest form of NTP timestamp.MSNTP and its Assumptions-------------------------MSNTP is intended to be a straightforward SNTP daemon/utility that is easy tobuild on any reasonable Unix platform (and most near-Unix ones), whether or notit has ever been ported to them before.  It is intended to answer the followingrequirements, either by challenge and response or the less reliable broadcastmethod:    A simple command to run on Unix systems that will check the time    and optionally drift compared with a known, local and reliable NTP    time server.  No privilege is required just to read the time and    estimate the drift.    A client for Unix systems that will synchronise the time from a known,    local and reliable NTP time server.  This is probably the most common    one, and the need that caused the program to be written.    A server for Unix systems that are synchronised other than by NTP    methods and that need to synchronise other systems by NTP.  This is    the classroom of PCs with a central server scenario.  It is NOT    intended to work as a peer with true NTP servers, and won't.    A simple method by which two or more Unix systems can keep themselves    synchronised using what is becoming a standard protocol.  Yes, I know    that there are half-a-dozen other such methods.    A base for building non-Unix SNTP clients.  Some 3/4 of the code    (including all of the complicated algorithms and NTP packet handling)    should work, unchanged, on any system with an ANSI/ISO C compiler.There are full tracing facilities and a lot of paranoia in the code to checkfor bad packets (more than in xntp) which may need relaxing in the light ofexperience.  Unfortunately, RFC 1305 does not include a precise description ofthe data protocol, despite its length, and there are some internalinconsistencies and differences between it and RFC 2030 and xntp3-5'sbehaviour.WARNING: MSNTP has not been tested in conjunction with xntp broadcasts or xntpclients, as the ability to do so was not available to the author.  It is veryunlikely that it won't work, but you should check.  Much of the paranoid codeis only partially tested, too, because it is dealing with cases that are veryhard to provoke.It assumes that the local network is tolerably secure and that any accessibleNTP or SNTP servers are trustworthy.  It also makes no attempt to check thatit has been installed and is being used correctly (e.g. at an appropriatepriority) or that the changes it makes have the desired effect.  When you first use it, you should both run it in display mode and use the date command as across-check.Furthermore, it does not attempt to solve all of the problems addressed by theNTP protocol and you should NOT use it if any of those problems are likely tocause you serious trouble.  If they are, bite the bullet and implement xntp, orbuy a fancy time-server.Building SNTP-------------All you SHOULD need to do is to uncomment the settings in file Makefile foryour system or to add new ones.  But real life is not always so simple.  AsPOSIX does not yet define sub-second timers, Internet addressing facilities,sockets etc., the code has to rely on the facilities described in theill-defined and non-standard 'X/Open' documents and the almost totallyunspecified 'BSD' extensions.Most hacks should be limited to the compiler options (e.g. setting flags like_XOPEN_SOURCE), but perverse systems may need additions to kludges.h - pleasereport them to the author.  See Makefile and kludges.h for documentation onthe standard hacks - there only 6, and most are only for obsolete systems.But, generally, using the generic set of C options usually works with nofurther ado.Sick, Bizarre or non-Unix Systems---------------------------------A very few Unix systems and almost all non-Unix systems may need changes to thecode, such as:    If the system doesn't have Berkeley sockets, you will need to replace    socket.c and possibly modify internet.h and internet.c.  All of the    systems for which the author needs this have Berkeley sockets.    NTP is supposedly an Internet protocol, but is not Internet specific.    For other types of network, you will need to replace internet.c and    probably modify internet.h.    If the system doesn't have gettimeofday or settimeofday, you will    need to modify timing.c.  If it doesn't have adjtime (e.g. HP-UX    on PA-RISC before 10.0), you can set -DADJTIME_MISSING and the code    will compile but the -a option will always give an error.    If the system has totally broken signal handling, the program will    hang or crash if it can't reach its name server or responses time    out.  You may be able to improve matters by hacking internet.c and    socket.c, but don't bet on it.    If the the program won't be able to create files in /etc when    updating the clock, you can use another lock file or even set    -DLOCKFILE=NULL, which will disable the locking code entirely.  On    systems that have it, using /var/run would be better than /etc.    If the the program hangs when flushing outstanding packets (which    you can tell by setting -W), it may help to set -DNONBLOCK_BROKEN.    This seems needed only for obsolete systems, like Ultrix.    If the system isn't Unix, even vaguely, you will probably need to    modify all of the above, and unix.c as well.    Note that adjtime is commonly sick, but you don't need to change the    code - just use the -r option whan making large corrections (see below    for more details).Any changes needed to header.h or main.c are bugs.  They may be bugs in thecode or in the compiler or libraries, but they are bugs.  Please prod thepeople responsible and tell the author, who may be able to bypass them cleanlyeven if they aren't bugs in his code.  The code also makes the followingassumptions, which would be quite hard to remove:    8-bit bytes.  Strictly, neither ANSI/ISO C nor POSIX require these,    and there were some very early versions of Unix on systems with other    byte sizes.  But, without a defined sub-byte facility in C, ....    At least 32-bit ints.  Well, actually, this wouldn't be too hard to    remove.  But most Unix programs make this assumption, and I have very    little interest in the more rudimentary versions of MS-DOS etc.    An ANSI/ISO C compiler.  It didn't seem worth writing dual-language    code in 1996.  Tough luck if you haven't got one.    Tolerably efficient floating-point arithmetic, with at least 13 digits    (decimal), preferably 15, in the mantissa of doubles.  Ditto.  If you    want to port this to a toaster, please accept my insincerest sympathies    and don't bother me.    A trustworthy local network.  It does not check for DNS, Ethernet,    packet or other spoofing, and assumes that any accessible NTP or SNTP    servers are properly synchronised.Warnings about Installation and Use-----------------------------------Anyone attempting to fiddle with the clock on their system should already knowhow to write system administration scripts, install daemons and so on.  Thereare a few warnings:    Don't use the broadcast modes unless you really have to, as the    client-server modes are far more reliable.  The broadcast modes were    implemented more for virtuosity (a.k.a. SNTP conformance) than use.    In particular, the error estimates are mere guesses, and may be low    or even very low.  And even reading broadcasts needs privilege.    The program is not intended to be installed setuid or setgid, and    doing so is asking for trouble.  Its ownerships and access modes are    not important.  It need not be run by root for merely displaying the    time (even in daemon mode).    The program does not need to run at a high priority (low in Unix    terms!) even when being used to set the clock or as a server, except    when the '-r' option is  used.  However, doing so may improve its    accuracy.    Unlike NTP, the SNTP protocol contains no protection against    client-server loops.  If you set one up, your systems will spin    themselves off into a disconnected vortex of unreality!    It will get very confused if another process changes the local time    while it is running.  There is some locking code in unix.c to prevent    this program doing this to itself, but it will protect only against    some errors.  However, the remaining failures should be harmless.    Don't run it as a server unless you REALLY know what you are doing.    It should be used as a server only on a system that is properly    synchronised, by fair means or foul.  If it isn't, you will simply    perpetrate misinformation.  And remember that broadcasts are most    unpopular with overloaded administrators of overloaded networks.    Watch out for multi-server broadcasts and systems with multiple ports    onto the same Ethernet; there is some code to protect against this,    but it is still easy to get confused.    Don't put the lock file onto an automounted partition or delete it by    hand, unless you really want to start two daemons at the same time.    Both will probably fail horribly if you do this.    The daemon save file is checked fairly carefully, but should be in a    reasonably safe directory, unless you want hackers to cause trouble.    /tmp is safe enough on most systems, but not all - /etc is better.Installing and Using the Program--------------------------------Start by copying the executable and man page to where you want them.  If youwant only to display the time and as a replacement for the rdate or date

⌨️ 快捷键说明

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