Re: [ntp:questions] NTPQ -P shows both IP and DNS name (parsing problem)

2017-06-21 Thread Jakob Bohm

On 21/06/2017 13:49, roman.mescherya...@gmail.com wrote:

вторник, 20 июня 2017 г., 19:38:53 UTC+3 пользователь David Woolley написал:

I think you are expected to use the relevant management request
directly, rather than parse output intended for humans.  That would
avoid process startup, filtering, and DNS costs.


What does it mean to “use the relevant management request directly”? I’m new to 
NTP and Linux and this phrase is not clear to me. If it makes any difference, 
my program is written on Python and running under Raspbian OS.



ntpq works by sending special "management" request UDP packets to the
queried server and then parsing the resulting "management" reply UDP
packets.  The default is to query the server on 127.0.0.1 (or ::1 for
IPv6).

Some (most?, all?) of these "management" packets are documented in the
NTPv4 protocol RFC.  Their relationships with ntpq command line options
can be found (if nowhere else) in the ntpq source code.

Converting that source code from C to Python is left as an educational
exercise for fans that BBC children's program ;-)

Enjoy

Jakob
--
Jakob Bohm, CIO, Partner, WiseMo A/S.  https://www.wisemo.com
Transformervej 29, 2860 Søborg, Denmark.  Direct +45 31 13 16 10
This public discussion message is non-binding and may contain errors.
WiseMo - Remote Service Management for PCs, Phones and Embedded

___
questions mailing list
questions@lists.ntp.org
http://lists.ntp.org/listinfo/questions

Re: [ntp:questions] NTPQ -P shows both IP and DNS name (parsing problem)

2017-06-21 Thread Dan Geist


- On Jun 21, 2017, at 7:49 AM, roman mescheryakov 
roman.mescherya...@gmail.com wrote:

> вторник, 20 июня 2017 г., 19:38:53 UTC+3 пользователь David Woolley написал:
>> I think you are expected to use the relevant management request
>> directly, rather than parse output intended for humans.  That would
>> avoid process startup, filtering, and DNS costs.
> 
> What does it mean to “use the relevant management request directly”? I’m new 
> to
> NTP and Linux and this phrase is not clear to me. If it makes any difference,
> my program is written on Python and running under Raspbian OS.

I believe David is suggesting looking at the raw statistics for the ntpd 
application (usually found in /var/log/ntpstats and enabled in ntp.conf) if 
you're going to have a program doing something useful with it. The ntpq 
application is really meant more for "human" consumption and makes assumptions 
about things and have a high overhead that may not be right for you.

Here's a sample of my peerstats log:

root@catl1w66dgeist:/var/log/ntpstats# tail -f /var/log/ntpstats/peerstats
57925 45005.219 2001::15:1109::10 141a 0.05074 0.001475794 0.015326216 
0.000123019
57925 45065.271 2001::2:1109::11 133a -0.35581 0.053438858 0.019286290 
0.82599
57925 45203.271 184.XXX.140.10 1424 -0.08371 0.053683156 0.015259027 
0.000232662
57925 45273.271 2001::2:1109::10 1324 0.000186344 0.053677174 0.019365864 
0.000155594

You can get all the useful raw data and present/use it however you like. Here's 
a good reference to the available monitoring statistics:
http://doc.ntp.org/4.2.4/monopt.html

Dan

-- 
Dan Geist dan(@)polter.net
___
questions mailing list
questions@lists.ntp.org
http://lists.ntp.org/listinfo/questions

Re: [ntp:questions] GPS-PPS, standalone server. NTP

2017-06-21 Thread William Unruh
On 2017-06-21, Fida Hasan  wrote:
> On Thursday, June 15, 2017 at 2:58:07 AM UTC+10, Hans Mayer wrote:
>> Hi Fida, 
>> 
>> > However, did you ever tried to achieve 1-microsecond accuracy in your used 
>> > refid (in your case with driver 28 which NTP uses)? My primary goal is to 
>> > attain 1-microsecond accuracy bond where I can see 3 milliseconds offset 
>> > with .GPS refid.
>> 
>> Definitely not. 
>> With driver 22  I am in the +- 10 usec range. With driver 28 in millisecond 
>> range. 
>> 
>> See my blog.
>> http://blog.mayer.tv/2017/06/14/ntp-driver-22-versus-28.html
>> 
>> I assume driver 20 is very similar to 28. Both are reading serial data. 
>> 
>> I don't know if 1-microsecond is a easy goal. I am using a very cheap 
>> hardware. It's running on a BananaPI. All together about 150 EUR. With a 
>> good hardware it's maybe possible. 
>> 
>> But why do you need this ? Is it just your ambition. This I could 
>> understand. 
>> 
>> 
>> // Hans
>
> Hi Hans,
>
> I have made a stand-alone server using the only driver 20, means no other 
> servers were associated, no internet connection at all. 
> In user mode, I recorded the maximum offset as 6 microseconds. But in kernel 
> mode, the result is much better. I run the system over three days, and the 
> maximum offset comes 1.60 microseconds. From the statistical recorded data, I 
> found the average is 1.03 microseconds.
>

You mean that the fluctuation in theoffset if 1.6us. YOu have no way of
knowing what the actual offset is, or do you have an independent clock?
Ie, ntp could be adding 100ms to the time and you would not know it. 
(Not that that would be likely but 2 or 3 usec could be likely)


> Regards,
> Fida
>

> N.B. I am trying to use chrony as I found some references in favor of it. But 
> still unable to feed the GPS in it.

The shm drive is one way. Another is the pps driver

Make sure that you have the 
timepps.h header file somewhere. You have to find it somewhere .
If you have it, and you make chrony, it woill be built witht eh PPS API
driver.
Then before starting chrony and assuming you have the pps fed into the
the serial port /dev/ttyS0, do
modprobe pps-ldisc
ldattach 18 /dev/ttyS0

Then in chrony.conf put
refclock PPS /dev/pps0

and you should be set up. 


___
questions mailing list
questions@lists.ntp.org
http://lists.ntp.org/listinfo/questions


Re: [ntp:questions] GPS-PPS, standalone server. NTP

2017-06-21 Thread Miroslav Lichvar
On Tue, Jun 20, 2017 at 06:13:14AM -0700, Fida Hasan wrote:
> From this point onward, if I set up ntp, it get fix with the drivers and 
> working fine. However, according to the instruction here:
> http://catb.org/gpsd/gpsd-time-service-howto.html#_feeding_chrony_from_gpsd
> 
> 3. I installed chrony and gpsd into my system. And always ensured that Chrony 
> is Running before gpsd.
> 
> 
> allow 0/0
> 
> refclock SHM 1 refid GPS precision 1e-1 offset 0. delay 0.2
> refclock SOCK /tmp/chrony.ttyS0.sock refid PPSS
> 
> But I don't get any result. It is sure that chrony does not get feed from 
> GPSD. 

With the pps-gpio module gpsd doesn't know that /dev/pps0 is related
to /dev/ttyS0. You might need to start gpsd with both devices
specified on the command line. I'm not sure since what version that is
supported.

If that doesn't work and chrony was compiled with PPS support, you
could use gpsd just for the message-based samples provided in SHM 0
and use the PPS device directly. For example:

refclock PPS /dev/pps0 poll 2 lock NMEA refid GPS
refclock SHM 0 offset 0.5 delay 0.2 refid NMEA noselect

-- 
Miroslav Lichvar
___
questions mailing list
questions@lists.ntp.org
http://lists.ntp.org/listinfo/questions


Re: [ntp:questions] GPS-PPS, standalone server. NTP

2017-06-21 Thread girino66
Le mardi 20 juin 2017 15:13:16 UTC+2, Fida Hasan a écrit :
> > That command gives all details:
> > ntpq -c rv -c pe -c cv -c kern -c as
> > 
> > associd=0 status=041d leap_none, sync_uhf_radio, 1 event, kern,
> > version="ntpd 4.2.8p10@1.3728 Tue May 16 04:35:53 UTC 2017 (1)",
> > processor="armv7l", system="Linux/3.10.104-KPPS", leap=00, stratum=1,
> > precision=-24, rootdelay=0.000, rootdisp=1.195, refid=GPS,
> > reftime=dceaa6d4.0b6f4fcb  Tue, Jun 13 2017 20:00:52.044,
> > clock=dceaa6e1.471ffbf5  Tue, Jun 13 2017 20:01:05.277, peer=46420, tc=5,
> > mintc=3, offset=-0.94, frequency=2.094, sys_jitter=0.60,
> > clk_jitter=0.001, clk_wander=0.002
> >  remote   refid  st t when poll reach   delay   offset  
> > jitter
> > ==
> > +192.168.0.111   .GPS.1 s   21   32  3770.630   -0.008   
> > 0.009
> > +192.168.0.112   .GPS.1 s5   32  3770.4490.058   
> > 0.011
> >  192.168.0.115   192.168.0.1072 s   24   32  3770.6400.006   
> > 0.024
> > oGPS_NMEA(0) .GPS.0 l   13   32  3770.0000.000   
> > 0.000
> > associd=0 status= no events, clk_unspec,
> > device="NMEA GPS Clock",
> > timecode="$GPRMC,180104,A,.,_,_.,_,000.0,224.0,130617,001.8,E*__",
> > poll=21509, noreply=0, badformat=0, baddata=0, fudgetime2=550.000,
> > stratum=0, refid=GPS, flags=13
> > associd=0 status=041d leap_none, sync_uhf_radio, 1 event, kern,
> > pll offset:0
> > pll frequency: 2.09364
> > maximum error: 0.0075
> > estimated error:   0
> > kernel status: pll ppsfreq ppstime ppssignal nano
> > pll time constant: 5
> > precision: 1e-06
> > frequency tolerance:   500
> > pps frequency: 2.09375
> > pps stability: 0.00802612
> > pps jitter:0.001
> > calibration interval   256
> > calibration cycles:12684
> > jitter exceeded:   26092
> > stability exceeded:0
> > calibration errors:0
> > 
> > ind assid status  conf reach auth condition  last_event cnt
> > ===
> >   1 46417  f4fd   yes   yes   ok  candidate 15
> >   2 46418  f43d   yes   yes   ok  candidate  3
> >   3 46419  f01d   yes   yes   ok reject  1
> >   4 46420  971a   yes   yes  none  pps.peersys_peer  1
> > 
> > As you can see the result is quite good and stable
> > Best,
> > Jean-Michel.
> 
> 
> 
> 
> Hi Jean-Michel,
> Splendid work. I was just taking sometimes to complete my experiment with my 
> existing system (Rpi-3, GPS HAT (Uputronics)).
> 
> You know, my result is not bad if I run the system in kernel mode.
> I have used driver 20 and in the stand-alone mood, means no other servers 
> were associated, no internet connection at all.
> In user mode I recorded the maximum offset as 6 microseconds. But in kernel 
> mode I run the system over three days, and the maximum offset comes 1.60 
> microseconds. From the statistical recorded data, I found the average is 1.03 
> microseconds. 
> 
> I am very interested in going further. I have in mind to try your suggested 
> system with Odroid. You have tested with OdroidC1+, where OdroidC2 is the 
> latest version of it. So, can you please share some points to clear my 
> understanding because I literally have no experiences working with this 
> particular SBC system.
> 1. Do I need to use OdriodC1+, or OdriodC2+ would be okay?(as I found Rpi3 
> and others have differences so all of their setting does not mutually works 
> therefore troubleshooting is difficult.)
> 2. Did you use Linux/or Android as OS?
> 3. I believe this Odroid is likea clone of Rpi, means, their GPIO Pin 
> configuration is same. So, the Rpi HAT like uputronics provides should fit 
> with it?
> 
> 
> You are very resourceful. Thank you very much for all of your valuable 
> sharing. This time, I am trying to build with chrony. I have got some 
> references that chrony does better in regard to offsets. I was just wondering 
> if you have any experiences working with chrony!
> 
> While trying with chrony I still unable to fix gpsd with it therefore no GPS 
> and PPS output is observed.
> So,
> 
> 1. I made the necessary configurations:
>a) In the boot configuration file (/boot/conf.txt) I stop Linux putting 
> serial console by removing 'console=serial0,115200' 
>b) I load pps-gpio to kernel module (sudo sh -c "echo pps-gpio >> 
> /etc/modules"
>c) Told to use GPIO18 as the PPS input by inputting 
> "dtoverlay=pps-gpio,gpiopin=18" into config.txt file.
>d) I added this three additional command to the config.txt file, 
> "core_frequency=300" "force_turbo=1" and "enable_uart=1".
>  2. I installed 'picocom' and 'pps-tools' to see whether my GPS and PPS are 
> from the receiver is functioning?
> a) 'picocom -b 9600 -f n /dev/ttyS0' commands start to show output from 
> 

Re: [ntp:questions] NTPQ -P shows both IP and DNS name (parsing problem)

2017-06-21 Thread roman . mescheryakov
вторник, 20 июня 2017 г., 19:38:53 UTC+3 пользователь David Woolley написал:
> I think you are expected to use the relevant management request 
> directly, rather than parse output intended for humans.  That would 
> avoid process startup, filtering, and DNS costs.

What does it mean to “use the relevant management request directly”? I’m new to 
NTP and Linux and this phrase is not clear to me. If it makes any difference, 
my program is written on Python and running under Raspbian OS.

___
questions mailing list
questions@lists.ntp.org
http://lists.ntp.org/listinfo/questions

Re: [ntp:questions] Autokey IFF

2017-06-21 Thread Harlan Stenn
Autokey is no longer safe to use.  Moore's law caught up with the data
sizes in the protocol and some of the algorithms.

We're getting ready to release the replacement for autokey, Network Time
Security.

Please contact us if you want more information.
-- 
Harlan Stenn 
http://networktimefoundation.org - be a member!
___
questions mailing list
questions@lists.ntp.org
http://lists.ntp.org/listinfo/questions