Thread: [Linuxptp-users] Status file of achieved time synchronization
PTP IEEE 1588 stack for Linux
Brought to you by:
rcochran
From: Koehrer M. (ETAS/ESW5) <mat...@et...> - 2014-02-12 15:55:43
|
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 |
From: Richard C. <ric...@gm...> - 2014-02-12 17:08:26
|
On Wed, Feb 12, 2014 at 03:55:21PM +0000, Koehrer Mathias (ETAS/ESW5) wrote: > 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 |
From: Keller, J. E <jac...@in...> - 2014-02-12 18:35:05
|
On Wed, 2014-02-12 at 18:08 +0100, Richard Cochran wrote: > On Wed, Feb 12, 2014 at 03:55:21PM +0000, Koehrer Mathias (ETAS/ESW5) wrote: > > > 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 most likely good enough though. Regards, Jake |
From: Koehrer M. (ETAS/ESW5) <mat...@et...> - 2014-02-13 13:01:41
|
> Sent: Wednesday, February 12, 2014 7:32 PM > > 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 this! Regards Mathias |
From: Richard C. <ric...@gm...> - 2014-02-18 17:38:36
|
On Thu, Feb 13, 2014 at 01:01:20PM +0000, Koehrer Mathias (ETAS/ESW5) wrote: > > 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 |
From: Richard C. <ric...@gm...> - 2014-02-14 20:35:09
|
On Thu, Feb 13, 2014 at 01:01:20PM +0000, Koehrer Mathias (ETAS/ESW5) wrote: > 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. > 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). > 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 |
From: Koehrer M. (ETAS/ESW5) <mat...@et...> - 2014-02-17 14:21:26
|
Hi Richard, thanks for the support! > From: Richard Cochran > Sent: Friday, February 14, 2014 9:35 PM > > 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 |
From: Richard C. <ric...@gm...> - 2014-02-17 17:44:45
|
On Mon, Feb 17, 2014 at 02:21:10PM +0000, Koehrer Mathias (ETAS/ESW5) wrote: > > 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. > 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 |
From: Koehrer M. (ETAS/ESW5) <mat...@et...> - 2014-02-19 14:08:34
|
Hi Richard! > 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 |
From: Julien H. <ju...@ya...> - 2014-02-19 14:16:11
|
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) <mat...@et...> À : Richard Cochran <ric...@gm...> Cc : "lin...@li..." <lin...@li...> Envoyé le : Mercredi 19 février 2014 15h08 Objet : Re: [Linuxptp-users] Status file of achieved time synchronization Hi Richard! > 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 ------------------------------------------------------------------------------ Managing the Performance of Cloud-Based Applications Take advantage of what the Cloud has to offer - Avoid Common Pitfalls. Read the Whitepaper. http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk _______________________________________________ Linuxptp-users mailing list Lin...@li... https://lists.sourceforge.net/lists/listinfo/linuxptp-users |
From: Ledda W. E. <Wil...@it...> - 2014-02-19 14:16:46
|
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:mat...@et...] Sent: 19 February 2014 15:08 To: Richard Cochran Cc: lin...@li... Subject: Re: [Linuxptp-users] Status file of achieved time synchronization Hi Richard! > 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 ------------------------------------------------------------------------------ Managing the Performance of Cloud-Based Applications Take advantage of what the Cloud has to offer - Avoid Common Pitfalls. Read the Whitepaper. http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk _______________________________________________ Linuxptp-users mailing list Lin...@li... https://lists.sourceforge.net/lists/listinfo/linuxptp-users |
From: Richard C. <ric...@gm...> - 2014-02-19 14:24:53
|
On Wed, Feb 19, 2014 at 02:08:14PM +0000, Koehrer Mathias (ETAS/ESW5) wrote: > 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 |