LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Embedded & Single-board computer (https://www.linuxquestions.org/questions/linux-embedded-and-single-board-computer-78/)
-   -   NTP server on Embedded Linux (https://www.linuxquestions.org/questions/linux-embedded-and-single-board-computer-78/ntp-server-on-embedded-linux-4175485013/)

Oromis_32 11-18-2013 10:14 AM

NTP server on Embedded Linux
 
Hi guys,

I'm currently setting up a distributed system consisting of 5 single-board computers (4 BeagleBone Black and 1 Karo TX6Q), which are all ARM-based computers running Linux. (If you are interested, the system will be used as the on-board computer system in a racing car).

The boards are supposed to exchange sensor data. To be able to perform calculations on consistent data, all system clocks need to be synchronized very accurately. We want to use NTP for this job since it promises sub-millisecond precision in good network conditions.

So I downloaded the sources from http://www.ntp.org/ and compiled them using a cross-compiler for the Karo board (which is the central computer). Then I copied the generated files to the board and created a ntp.conf which looks like this:

Code:

driftfile /var/lib/ntp/ntp.drift
statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable

server localhost

restrict 192.168.10.0 mask 255.255.255.0 nomodify notrap
restrict 127.0.0.1

enable monitor

I started the ntp daemon using
Code:

ntpd -l
which gave me no error and ps shows a new running ntpd process.

Unfortunately, when I wanted to test the server using
Code:

ntpq -p
it responded with
Code:

localhost: timed out, nothing received
***Request timed out

which apparently means that the server is not working.

I haven't found anything helpful in Google, so now I hope one of you has an idea. If you need additional information, feel free to ask.

Thanks in advance

David

michaelk 11-18-2013 11:08 AM

If you want to setup ntp using the local clock as a time source then you need the following in your ntp.conf file
Quote:

server 127.127.1.0
fudge 127.127.1.0 stratum 1
You did not state if the central computer is going to be connected to the internet but I would guess that time synch is more important then an absolute time. Setting the central computer to stratum 1 will trick the others to thinking it is a good time source.

If the internet is not available and you need an absolute time reference then a GPS receiver is required. They are fairly cheap and easy to configure using gpsd.

Sounds like an interesting project.

Oromis_32 11-18-2013 12:57 PM

Thanks for your reply!

I changed my /etc/ntp.conf file to

Code:

driftfile /var/lib/ntp/ntp.drift
statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable

server 127.127.1.0
fudge 127.127.1.0 stratum 1

restrict 192.168.10.0 mask 255.255.255.0 nomodify notrap
restrict 127.0.0.1

enable monitor

Unfortunately, no difference.

Quote:

You did not state if the central computer is going to be connected to the internet but I would guess that time synch is more important then an absolute time
You are right, synch is most important. It would be nice to have an absolute time, but that has lower priority. The car will not be connected to the internet directly.

Quote:

Sounds like an interesting project.
Glad to hear that. If you want more information about what we are doing, here is our website (In German, but you can find some pretty international pictures: http://www.elefantracing.de/, http://www.elefantracing.de/medien/bilder)

michaelk 11-18-2013 01:54 PM

I assume you restarted ntp...

It isn't obvious why ntp isn't working.

Oromis_32 11-18-2013 04:12 PM

Yes, I restarted ntp ... Any further ideas?

michaelk 11-19-2013 10:51 AM

Starting ntpd with the -d switch might provide some addition debug messages.

Oromis_32 11-19-2013 11:37 AM

Nope, no luck with that either. Actually doesn't print anything. Is it possible that I screwed up compilation?

TobiSGD 11-19-2013 01:45 PM

I may be wrong on this (I don't know much about NTP), but shouldn't the IP address in that config be 127.0.0.1 instead of 127.127.1.0?

michaelk 11-19-2013 01:59 PM

Nope.

http://doc.ntp.org/4.2.0/drivers/driver1.html

I forgot to mention that if the system time is off by more then 1000s ntp will quit. Be sure to set time with the date command if required prior to starting ntpd. Does the Karo board have a backed real time clock?

Also ntpd with the -g option will force time to be set difference is > 1000s.

TobiSGD 11-19-2013 03:04 PM

Quote:

Originally Posted by michaelk (Post 5067425)

I stand corrected, thanks for that link.


All times are GMT -5. The time now is 07:47 PM.