1

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?

Michael Hampton
  • 252,907
sashk
  • 334

1 Answers1

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.

sashk
  • 334