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