Discussion:
[Linuxptp-users] Status file of achieved time synchronization
Koehrer Mathias (ETAS/ESW5)
2014-02-12 15:55:21 UTC
Permalink
Hi all,

I want to synchronize a couple of PCs using linuxptp.
One of these PCs acts as a master the others are slaves.
Is there a way to check the currently achieved synchronization offset on the slaves?
Checking the syslog file is not really helpful as I want to do a scriptable check.

On each of the PCs an application has to run.
Starting this application on the slaves is only allowed if the time-synchronization is stable (=the clock offset is below a certain limit and the drift is low).
With "ptpd2" there is a status file /var/run/ptpd2.status" that will be re-written every second.
Is anything like that available with linuxptp as well?

Thanks for any feedback on this!

Regards

Mathias
Richard Cochran
2014-02-12 17:08:04 UTC
Permalink
Post by Koehrer Mathias (ETAS/ESW5)
Starting this application on the slaves is only allowed if the time-synchronization is stable (=the clock offset is below a certain limit and the drift is low).
With "ptpd2" there is a status file /var/run/ptpd2.status" that will be re-written every second.
Is anything like that available with linuxptp as well?
We don't have a file, but instead you can use the management
interface. The 'pmc' management client can be used in a script,
like in the example below.

Probably you are interested in the CURRENT_DATA_SET, but for gPTP
applications there is also TIME_STATUS_NP.

HTH,
Richard
---
#!/bin/bash

while [ 1 ]; do
clear
./pmc -u -b 0 "get CURRENT_DATA_SET"
sleep 1
done
Keller, Jacob E
2014-02-12 18:32:12 UTC
Permalink
Post by Richard Cochran
Post by Koehrer Mathias (ETAS/ESW5)
Starting this application on the slaves is only allowed if the time-synchronization is stable (=the clock offset is below a certain limit and the drift is low).
With "ptpd2" there is a status file /var/run/ptpd2.status" that will be re-written every second.
Is anything like that available with linuxptp as well?
We don't have a file, but instead you can use the management
interface. The 'pmc' management client can be used in a script,
like in the example below.
Probably you are interested in the CURRENT_DATA_SET, but for gPTP
applications there is also TIME_STATUS_NP.
HTH,
Richard
---
#!/bin/bash
while [ 1 ]; do
clear
./pmc -u -b 0 "get CURRENT_DATA_SET"
sleep 1
done
You could also look at the pmc code and write your own program that
directly requests the data on the management UDS socket, if you prefer
not running it in a shell script.

This is m
Koehrer Mathias (ETAS/ESW5)
2014-02-13 13:01:20 UTC
Permalink
Sent: Wednesday, February 12, 2014 7:32 PM
Post by Richard Cochran
We don't have a file, but instead you can use the management
interface. The 'pmc' management client can be used in a script,
like in the example below.
Probably you are interested in the CURRENT_DATA_SET, but for gPTP
applications there is also TIME_STATUS_NP.
Thanks for the information.
That helps.

What I do not see fully clear is the role of phc2sys.
It is used to synchronize the PTP clock from my Ethernet device to the Linux system clock.
There is likely a drift/offset between this PTP clock and the Linux system clock.
This drift/offset has to be corrected by the phc2sys tool.
What kind of information do I get when I call the 'pmc" management client?
Is it the drift/offset of the PTP clock (Ethernet) or is it the drift/offset of my Linux system clock?

One more question related to phc2sys.
When I use a PC as PTP master, I have to call phc2sys like
# phc2sys -c /dev/ptp -s CLOCK_REALTIME -w
When I use a PC as PTP slave, I have to call it like
# phc2sys -s /dev/ptp -w
If I do not explicitly specify which of the PCs should run as master or slave, there is a negotiation between the available PCs.
One of the PCs will be made the master.
Is there a way to call phc2sys to distinguish automatically between master and slave operation mode?
Or how do I have to call "phc2sys" in the situation when I do not know if the PC will be master or not?

Thanks for any help on th
Richard Cochran
2014-02-14 20:34:51 UTC
Permalink
Post by Koehrer Mathias (ETAS/ESW5)
What kind of information do I get when I call the 'pmc" management client?
Is it the drift/offset of the PTP clock (Ethernet) or is it the drift/offset of my Linux system clock?
It is the offset with respect to the PTP master. In the case of
software time stamping, this is also the drift of the Linux system
clock WRT the PTP master. Using hardware time stamping, this is the
drift of the PTP hardware clock.
Post by Koehrer Mathias (ETAS/ESW5)
When I use a PC as PTP master, I have to call phc2sys like
# phc2sys -c /dev/ptp -s CLOCK_REALTIME -w
I would only do this if you also have "free_running 1" in the
configuration file (and your system time is managed by NTP).
Post by Koehrer Mathias (ETAS/ESW5)
Or how do I have to call "phc2sys" in the situation when I do not know if the PC will be master or not?
You can simply do the same as in the slave case.

phc2sys -s /dev/ptp -w

The grand master node will adjust its system time to the free running
PTP Hardware Clock. You will want to set the correct time in the PHC
before doing this!

HTH,
Richard
Koehrer Mathias (ETAS/ESW5)
2014-02-17 14:21:10 UTC
Permalink
Hi Richard,

thanks for the support!
From: Richard Cochran
Sent: Friday, February 14, 2014 9:35 PM
Post by Koehrer Mathias (ETAS/ESW5)
Or how do I have to call "phc2sys" in the situation when I do not know if the
PC will be master or not?
You can simply do the same as in the slave case.
phc2sys -s /dev/ptp -w
The grand master node will adjust its system time to the free running
PTP Hardware Clock. You will want to set the correct time in the PHC
before doing this!
OK that makes sense! Which tool can I use to set the correct time in the PHC before starting phc2sys?
Can I use phc2sys or is there another tool required for this?
I assume, in this case I have to consider the 35s offset...


One thing that is still not clear to me is how to get the accuracy of the local clock in relation to the PTP master clock.
Using pmc I can get the drift/offset of my local PHC device in relation to the PTP master clock.
However I did not understand yet how I can retrieve the current drift/offset of my system clock (CLOCK_REALTIME) in relation to the PTP master clock.
As my application runs using the system clock I have to ensure that the offset/drift is small enough to be able to start the application.
phc2sys is responsible to adapt the system clock, thus I'd expected phc2sys to deliver this information somehow. However I do not find anything like that in the code or man page.

Thanks for some hints on that.

Regards

Mathias
Richard Cochran
2014-02-17 17:44:24 UTC
Permalink
Post by Koehrer Mathias (ETAS/ESW5)
Post by Richard Cochran
You can simply do the same as in the slave case.
phc2sys -s /dev/ptp -w
The grand master node will adjust its system time to the free running
PTP Hardware Clock. You will want to set the correct time in the PHC
before doing this!
OK that makes sense! Which tool can I use to set the correct time in the PHC before starting phc2sys?
Can I use phc2sys or is there another tool required for this?
I assume, in this case I have to consider the 35s offset...
One easy way would be to use the testptp program from
Documentation/ptp in the Linux kernel sources. You could do

testptp -s # set the ptp clock time from the system time

followed by

testptp -t val # shift the ptp clock time by 'val' seconds

in order to set the correct UTC offset. If you need something more
fancy than that, then you can always write a little C program.
Post by Koehrer Mathias (ETAS/ESW5)
phc2sys is responsible to adapt the system clock, thus I'd expected
phc2sys to deliver this information somehow. However I do not find
anything like that in the code or man page.
The phc2sys does not have a management interface like ptp4l. It can
place summary statistics in the syslog or on stdout/stderr. So you
would have to grep/tail this from the syslog or redirect the output
into a fifo. You could script a file like the one you first
mentioned. For example:

while [ 1 ]; do
grep phc2sys /var/log/syslog | grep rms | tail -n 1 > /tmp/status
sleep 2
done

I don't know what your timing requirements are, but be beware that
the phc2sys output is only an estimate, and there may be an additional
offset between the Linux system time and the PHC.

HTH,
Richard
Richard Cochran
2014-02-18 17:38:12 UTC
Permalink
Post by Koehrer Mathias (ETAS/ESW5)
What I do not see fully clear is the role of phc2sys.
It is used to synchronize the PTP clock from my Ethernet device to the Linux system clock.
There is likely a drift/offset between this PTP clock and the Linux system clock.
This drift/offset has to be corrected by the phc2sys tool.
BTW, in case you did not see the recent discussion about it, you
should know that the Linux kernel option CONFIG_NO_HZ_IDLE is harmful
to your use case. I recommend to either disable this at compile time
or to add "nohz=off" to your kernel command line.

Thanks,
Richard
Koehrer Mathias (ETAS/ESW5)
2014-02-19 14:08:14 UTC
Permalink
Hi Richard!
Post by Richard Cochran
BTW, in case you did not see the recent discussion about it, you
should know that the Linux kernel option CONFIG_NO_HZ_IDLE is harmful
to your use case. I recommend to either disable this at compile time
or to add "nohz=off" to your kernel command line.
Thanks for the hint.
With my kernel 3.2 there is no config option CONFIG_NO_HZ_IDLE.
I have only "CONFIG_NO_HZ". Is this also harmful?


Regards

Mathias
Julien Houles
2014-02-19 14:16:04 UTC
Permalink
HiMathias,

Only by using the nohz=off option in the kernel command line, the delay in phc2sys dropped from several microseconds to a hundred nanoseconds.

Julien.



________________________________
De : Koehrer Mathias (ETAS/ESW5) <***@etas.com>
À : Richard Cochran <***@gmail.com>
Cc : "linuxptp-***@lists.sourceforge.net" <linuxptp-***@lists.sourceforge.net>
Envoyé le : Mercredi 19 février 2014 15h08
Objet : Re: [Linuxptp-users] Status file of achieved time synchronization


Hi Richard!
Post by Richard Cochran
BTW, in case you did not see the recent discussion about it, you
should know that the Linux kernel option CONFIG_NO_HZ_IDLE is harmful
to your use case. I recommend to either disable this at compile time
or to add "nohz=off" to your kernel command line.
Thanks for the hint.
With my kernel 3.2 there is no config option CONFIG_NO_HZ_IDLE.
I have only "CONFIG_NO_HZ". Is this also harmful?


Regards


Mathias
Ledda William EXT
2014-02-19 14:16:37 UTC
Permalink
Yes, disable it adding "nohz=off" at kernel command line and you can see the difference. Phc2sys will report more stable and very low delay (I see hundreds of nanoseconds on my platforms)


-----Original Message-----
From: Koehrer Mathias (ETAS/ESW5) [mailto:***@etas.com]
Sent: 19 February 2014 15:08
To: Richard Cochran
Cc: linuxptp-***@lists.sourceforge.net
Subject: Re: [Linuxptp-users] Status file of achieved time synchronization

Hi Richard!
Post by Richard Cochran
BTW, in case you did not see the recent discussion about it, you
should know that the Linux kernel option CONFIG_NO_HZ_IDLE is harmful
to your use case. I recommend to either disable this at compile time
or to add "nohz=off" to your kernel command line.
Thanks for the hint.
With my kernel 3.2 there is no config option CONFIG_NO_HZ_IDLE.
I have only "CONFIG_NO_HZ". Is this also harmful?


Regards

Mathias
Richard Cochran
2014-02-19 14:24:42 UTC
Permalink
Post by Koehrer Mathias (ETAS/ESW5)
With my kernel 3.2 there is no config option CONFIG_NO_HZ_IDLE.
I have only "CONFIG_NO_HZ". Is this also harmful?
Yes, that is the old name. Use nohz=off as the others have suggested.

Thanks,
Richard

Loading...