xref: /freebsd/contrib/ntp/libparse/README (revision ea906c4152774dff300bb26fbfc1e4188351c89a)
1c0b746e5SOllivier RobertPARSE reference clock driver:
2c0b746e5SOllivier Robert
3c0b746e5SOllivier RobertThis directory contains the files making up the parser for
4c0b746e5SOllivier Robertthe parse refclock driver. For reasonably sane clocks this refclock
5c0b746e5SOllivier Robertdrivers allows a refclock implementation by just providing a
6c0b746e5SOllivier Robertconversion routine and the appropriate NTP parameters. Refclock
7c0b746e5SOllivier Robertsupport can run as low a 3k code with the parse refclock driver.
8c0b746e5SOllivier Robert
9c0b746e5SOllivier RobertThe modules in here are designed to live in two worlds. In userlevel
10c0b746e5SOllivier Robertas part of the xntp daemon and in kernel land as part of a STREAMS module
11c0b746e5SOllivier Robertor, if someone gets to it, as part of a line discipline. Currently only
12c0b746e5SOllivier RobertSunOS4.x/SunOS5.x STREAMS are supported (volunteers for other vendors like HP?).
13c0b746e5SOllivier RobertThis structure means, that refclock_parse can work with or without kernel
14c0b746e5SOllivier Robertsupport. Kernelsupport increases accuracy tremendingly. The current restriction
15c0b746e5SOllivier Robertof the parse driver is that it only supports SYSV type ttys and that kernel
16c0b746e5SOllivier Robertsupport is only available for Suns right now.
17c0b746e5SOllivier Robert
18c0b746e5SOllivier RobertThree kernel modules are part of this directory. These work only on
19c0b746e5SOllivier RobertSunOS (SunOS4 and SunOS5).
20c0b746e5SOllivier Robert
21c0b746e5SOllivier Robert	SunOS4 (aka Solaris 1.x):
22c0b746e5SOllivier Robert		parsestreams.loadable_module.o	- standard parse module for SunOS 4
23c0b746e5SOllivier Robert
24c0b746e5SOllivier Robert		Both modules can be loaded via modload <modulename>.
25c0b746e5SOllivier Robert
26c0b746e5SOllivier Robert	SunOS5 (aka Solaris 2.x):
27c0b746e5SOllivier Robert		parse		- auto loadable streams module
28c0b746e5SOllivier Robert
29c0b746e5SOllivier Robert		To install just drop "parse" into /kernel/strmod and
30c0b746e5SOllivier Robert		start the daemon (SunOS5 will do the rest).
31c0b746e5SOllivier Robert
32c0b746e5SOllivier RobertThe structure of the parse reference clock driver is as follows:
33c0b746e5SOllivier Robert
34ea906c41SOllivier Robert	ntpd	- contains NTP implementation and calls a reference clock
35c0b746e5SOllivier Robert		  127.127.8.x which is implemented by
36c0b746e5SOllivier Robert	 	  refclock_parse.c
37c0b746e5SOllivier Robert		  - which contains several refclock decriptions. These are
38c0b746e5SOllivier Robert		    selected by the x part of the refclock address.
39c0b746e5SOllivier Robert		    The lower two bits specify the device to use. Thus the
40c0b746e5SOllivier Robert		    value (x % 4) determines the device to open
41c0b746e5SOllivier Robert		    (/dev/refclock-0 - /dev/refclock-3).
42c0b746e5SOllivier Robert
43c0b746e5SOllivier Robert		    The kind of clock is selected by the mode parameter. This parameter
44c0b746e5SOllivier Robert		    selects the clock type which deterimines how I/O is done,
45c0b746e5SOllivier Robert		    the tty parameters and the NTP parameters.
46c0b746e5SOllivier Robert
47c0b746e5SOllivier Robert		    refclock_parse operates on an abstract reference clock
48c0b746e5SOllivier Robert		    that delivers time stamps and stati. Offsets and sychron-
49c0b746e5SOllivier Robert		    isation information is derived from this data and passed
50c0b746e5SOllivier Robert		    on to refclock_receive of xntp which uses that data for
51c0b746e5SOllivier Robert		    syncronisation.
52c0b746e5SOllivier Robert
53c0b746e5SOllivier Robert		    The abstract reference clock is generated by the parse*
54c0b746e5SOllivier Robert		    routines. They parse the incoming data stream from the
55c0b746e5SOllivier Robert		    clock and convert it to the appropriate time stamps.
56c0b746e5SOllivier Robert		    The data is also mapped int the abstract clock states
57c0b746e5SOllivier Robert		    	POWERUP - clock has no valid phase and time code
58c0b746e5SOllivier Robert				  information
59c0b746e5SOllivier Robert
60c0b746e5SOllivier Robert			NOSYNC	- Time code is not confirmed, phase is probably
61c0b746e5SOllivier Robert				  ok.
62c0b746e5SOllivier Robert			SYNC	- Time code and phase are correct.
63c0b746e5SOllivier Robert
64c0b746e5SOllivier Robert		    A clock is trusted for a certain time (type parameter) when
65c0b746e5SOllivier Robert		    it leaves the SYNC state. This is derived from the
66c0b746e5SOllivier Robert		    observation that quite a few clocks can still generate good
67c0b746e5SOllivier Robert		    time code information when losing contact to their
68c0b746e5SOllivier Robert		    synchronisation source. When the clock does not reagain
69c0b746e5SOllivier Robert		    synchronisation in that trust period it will be deemed
70c0b746e5SOllivier Robert		    unsynchronised until it regains synchronisation. The same
71c0b746e5SOllivier Robert		    will happen if xntp sees the clock unsynchronised at
72c0b746e5SOllivier Robert		    startup.
73c0b746e5SOllivier Robert
74c0b746e5SOllivier Robert		    The upper bit of x specifies that all samples delivered
75c0b746e5SOllivier Robert		    from the clock should be used to discipline the NTP
76c0b746e5SOllivier Robert		    loopfilter. For clock with accurate once a second time
77c0b746e5SOllivier Robert		    information this means big improvements for time keeping.
78c0b746e5SOllivier Robert		    A prerequisite for passing on the time stamps to
79c0b746e5SOllivier Robert		    the loopfilter is, that the clock is in synchronised state.
80c0b746e5SOllivier Robert
81c0b746e5SOllivier Robert	   parse.c  These are the general routines to parse the incoming data
82c0b746e5SOllivier Robert		    stream. Usually these routines should not require
83c0b746e5SOllivier Robert		    modification.
84c0b746e5SOllivier Robert
85c0b746e5SOllivier Robert	   clk_*.c  These files hole the conversion code for the time stamps
86c0b746e5SOllivier Robert		    and the description how the time code can be parsed and
87c0b746e5SOllivier Robert		    where the time stamps are to be taken.
88c0b746e5SOllivier Robert		    If you want to add a new clock type this is the file
89c0b746e5SOllivier Robert		    you need to write in addition to mention it in
90c0b746e5SOllivier Robert		    parse_conf.c and setting up the NTP and TTY parameters
91c0b746e5SOllivier Robert		    in refclock_parse.c.
92c0b746e5SOllivier Robert
93c0b746e5SOllivier RobertFurther information can be found in parse/README.parse and the various source
94c0b746e5SOllivier Robertfiles.
95c0b746e5SOllivier Robert
96c0b746e5SOllivier RobertFrank Kardel
97