I need to setup time synchronization using PTP (precision time protocol). I'll get server address. I found ptpd server (version 2.1). I created startup files in /etc/init.d. But wondering what options other than showing on which interface I should listen for broadcasts I should use. Does anyone had experience setting this up?
Asked
Active
Viewed 6,804 times
1
-
Is this a different protocol than the ntp daemon, included in the distribution, already provide? – mdpc Nov 09 '11 at 01:10
-
PTP is different from NTP. But unless the OP has a specific requirement, he should use NTP instead. It's not quite as accurate as far as getting machines on a LAN to agree, but it's much more accurate to real wall clock time. – David Schwartz Nov 09 '11 at 01:16
-
@DavidSchwartz: I specifically was told to use PTP. NTP is not accurate enough for that task. – sashk Nov 09 '11 at 02:00
-
Did you setup a server to be the master clock? – Mar 07 '12 at 03:55
-
@luc no, this setup was for slave. difference is in arguments you pass via PTPDARGS in /etc/sysconfig/ptpd2 – sashk Mar 27 '12 at 18:59
1 Answers
2
Here are steps I've did and got ptp working as a slave. I've used ptpd2 on Centos 6.0, but should work anywhere. Startup scripts I found somewhere online - can't find that link again today.
Download ptpd2 source package from sourceforge.
After downloaded, compile it:
tar xzfv ptpd-2.1.0.tar.gz
cd ptpd-2.1.0/src
make
sudo cp ptpd2 /usr/bin/ptpd2
create startup script for ptpd2 in /etc/rc.d/init.d/ptpd2
#!/bin/sh
#
# ptpd Precision Time Protocol daemon
#
# chkconfig: - 30 70
# description: ptpd implements a sub ms time coordination of LAN connected computers \
# implementing IEEE 1588
# Source function library.
. /etc/rc.d/init.d/functions
exec="/usr/bin/ptpd2"
prog="ptpd2"
[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
lockfile=/var/lock/subsys/$prog
start() {
[ -x $exec ] || exit 5
echo -n $"Starting $prog: "
# if not running, start it up here, usually something like "daemon $exec"
daemon --user root $exec $PTPDARGS
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
# stop it here, often "killproc $prog"
killproc $prog
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
stop
start
}
reload() {
restart
}
force_reload() {
restart
}
rh_status() {
# run checks to determine if the service is running or use generic status
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
restart
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
exit 2
esac
exit $?
Create configuration file in /etc/sysconfig/ptpd2
:
#
# PTPD Configuration
#
PTPDARGS="-D -b eth2 -f /var/log/ptpd.log"
Add ptpd to be started on system boot:
/sbin/chkconfig --level 35 ptpd2 on
and start ptpd daemon: service start ptpd2
Enjoy.
Let me know if you have better solution.