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