Skip to content

Commit

Permalink
RC5 last minute fixes continued:
Browse files Browse the repository at this point in the history
- updated README and INSTALL
- maximum unicast destination count changed to
  2048 in configure.ac
- RPM specs updated for rc5
- added hostname+pid info to status file
- added "Status update:" line to periodic updates
- fixed unused variable warnings for
  debug inet_ntoa() supporting struct in_addr
- removed unicastAddr completely
- ensured that initial timeLeft is set to
  requested +10 on first grant
  • Loading branch information
wowczarek committed Jun 15, 2015
1 parent a0b3238 commit cda230b
Show file tree
Hide file tree
Showing 14 changed files with 140 additions and 109 deletions.
6 changes: 3 additions & 3 deletions COPYRIGHT
@@ -1,6 +1,6 @@
/*-
* Copyright (c) 2015 Wojciech Owczarek,
* Copyright (c) 2014 Perseus Telecom,
* Copyright (c) 2015 Wojciech Owczarek.
* Copyright (c) 2014 Perseus Telecom.
* Copyright (c) 2013-2014 Harlan Stenn,
* George N. Neville-Neil,
* Wojciech Owczarek,
Expand All @@ -20,7 +20,7 @@
* Martin Burnicki,
* Jan Breuer,
* Gael Mace,
* Alexandre Van Kempen
* Alexandre Van Kempen.
*
* Copyright (c) 2005-2008 Kendall Correll, Aidan Williams
*
Expand Down
35 changes: 23 additions & 12 deletions INSTALL
@@ -1,6 +1,6 @@
PTP Daemon Version 2 Build and Installation Instructions

12 June 2015
15 June 2015

George V. Neville-Neil, Wojciech Owczarek

Expand Down Expand Up @@ -58,23 +58,34 @@ You will need the following tools and libraries to build ptpd2:
* As of 2.3.1, support was added for multiple unicast destinations
(both GMs and slaves) - with negotiation (signaling) and without.
The default maximum number of unicast destinations (also the
maximum number of slaves for a signaling GM) is set to 16. This
can be changed to a maximum of 1024 using:

./configure --with-max-unicast-destinations=[16...1024]

It is possible to change this limit to more than 1024, but realistically,
due to message scheduling, timer signal usage and single-thread
architecture, anywhere above 400 ptpd will struggle.
maximum number of slaves for a signaling GM) is set to 128. This
can be changed to a maximum of 2048 using:

./configure --with-max-unicast-destinations=[16...2048]

It is possible to change this limit to more than 2048, but realistically,
due to message scheduling, timer signal usage and single-threaded
architecture, anywhere above 1000 ptpd may struggle. Ptpd has been
successfully tested as unicast Telecom (negotiation) master
at 1000 slaves at low message rates (1/sec) and provided adequate
performance. When running high numbers of slaves, it is recommended
to use libpcap (ptpengine:use_libpcap=y) to allow easier matching
of Sync and FollowUp, unless the NIC supports software transmit
timestamps. Without those and without libpcap, ptpd loops packets
back into its own socket, so the followUp destination cannot be
matched with the Sync destination, and a lookup table is used.
Hash collissions are low, but they may happen, in which case
ptpd will send followUp to the wrong slave. This is only and issue
in extreme scenarios.

* With certain NIC drivers on Linux providing the SO_TIMESTAMPING
functionality with software transmit timestamps (SOF_TIMESTAMPING_
TX_SOFTWARE), unpredictable transmit timestamp failures can occur,
which may cause unstable operation and in some cases high CPU usage
(see https://sourceforge.net/p/ptpd/discussion/469208/thread/4aea6e47).
While fixes have been implemented, there is still some risk.
To disable SO_TIMESTAMPING support completely on Linux,
regardless of OS support, use:
While fixes have been implemented and have shown success,
there is still some risk. To disable SO_TIMESTAMPING support on Linux
completely, regardless of OS support, use:

./configure --disable-so-timestamping

Expand Down
6 changes: 5 additions & 1 deletion README
@@ -1,4 +1,4 @@
README for PTPd Version 2
README for PTPd Version 2.x

- Introduction -

Expand All @@ -22,6 +22,10 @@ If you are just looking for software to update the time on your desktop, you
probably want something that implements the Network Time Protocol. It can
coordinate computer clocks with an absolute time reference such as UTC.

Please refer to the INSTALL file for build instructions and configuration
options. Please refer to the README.repocheckout file for information
on how to build from source code repositories.

- Legal notice -

PTPd was written by using only information contained within 'IEEE Std
Expand Down
7 changes: 4 additions & 3 deletions configure.ac
Expand Up @@ -592,17 +592,18 @@ AC_MSG_CHECKING([for maximum unicast destination table size])
AC_ARG_WITH(
[max-unicast-destinations],
[AS_HELP_STRING(
[--with-max-unicast-destinations = [ 16 .. 1024]],
[--with-max-unicast-destinations = [ 16 .. 2048]],
[Change maximum supported number of unicast destinations -
this determines the maximum supported number of slaves
in unicast mode (with and without signaling)]
)],
[max_destinations=$with_max_unicast_destinations],
[max_destinations=0]
[max_destinations=128]
)

test $max_destinations -lt 16 && max_destinations=16
test $max_destinations -gt 1024 && max_destinations=1024
test $max_destinations -gt 2048 && max_destinations=2048

PTP_UNICAST_MAX="-DPTPD_UNICAST_MAX=$max_destinations"
AC_SUBST([PTP_UNICAST_MAX])
AC_MSG_RESULT([$max_destinations])
Expand Down
13 changes: 7 additions & 6 deletions packagebuild/rpm-rh/ptpd-slaveonly.spec
@@ -1,4 +1,4 @@
# (c) 2014: Wojciech Owczarek, PTPd project
# (c) 2014-2015: Wojciech Owczarek, PTPd project

%define _use_internal_dependency_generator 0

Expand All @@ -12,11 +12,11 @@
Summary: Synchronises system time using the Precision Time Protocol (PTP) implementing the IEEE 1588-2008 (PTP v 2) standard
Name: ptpd-slaveonly
Version: 2.3.1
Release: 0.99.rc4%{distver}
Release: 0.99.rc5%{distver}
License: distributable
Group: System Environment/Daemons
Vendor: PTPd project team
Source0: ptpd-2.3.1-rc4.tar.gz
Source0: ptpd-2.3.1-rc5.tar.gz
Source1: ptpd.init
Source2: ptpd.sysconfig
Source3: ptpd.conf
Expand Down Expand Up @@ -45,11 +45,11 @@ build - it is not possible to run as PTP master using ptpd-slave-only.

%prep

%setup -n ptpd-2.3.1-rc4
%setup -n ptpd-2.3.1-rc5

%build

./configure --enable-slave-only --with-max-unicast-destinations=128
./configure --enable-slave-only --with-max-unicast-destinations=512

make

Expand Down Expand Up @@ -157,8 +157,9 @@ fi
%{_datadir}/ptpd/*

%changelog
* Mon Jun 15 2015 Wojciech Owczarek <wojciech@owczarek.co.uk> 2.3.1-0.99.rc5
* Mon Jun 01 2015 Wojciech Owczarek <wojciech@owczarek.co.uk> 2.3.1-0.99.rc4
- RC4 release, adds leap seconds file
- rc4 release, adds leap seconds file
* Wed Apr 15 2015 Wojciech Owczarek <wojciech@owczarek.co.uk> 2.3.1-0.99.rc4.pre2
- Added the slaveonly spec
* Mon Apr 13 2015 Wojciech Owczarek <wojciech@owczarek.co.uk> 2.3.1-0.99.rc4.pre1
Expand Down
13 changes: 7 additions & 6 deletions packagebuild/rpm-rh/ptpd.spec
@@ -1,4 +1,4 @@
# (c) 2014: Wojciech Owczarek, PTPd project
# (c) 2014-2015: Wojciech Owczarek, PTPd project

%define _use_internal_dependency_generator 0

Expand All @@ -12,11 +12,11 @@
Summary: Synchronises system time using the Precision Time Protocol (PTP) implementing the IEEE 1588-2008 (PTP v 2) standard
Name: ptpd
Version: 2.3.1
Release: 0.99.rc4%{distver}
Release: 0.99.rc5%{distver}
License: distributable
Group: System Environment/Daemons
Vendor: PTPd project team
Source0: ptpd-2.3.1-rc4.tar.gz
Source0: ptpd-2.3.1-rc5.tar.gz
Source1: ptpd.init
Source2: ptpd.sysconfig
Source3: ptpd.conf
Expand Down Expand Up @@ -44,11 +44,11 @@ time synchronised via the PTP protocol or serving PTP time.

%prep

%setup -n ptpd-2.3.1-rc4
%setup -n ptpd-2.3.1-rc5

%build

./configure --with-max-unicast-destinations=128
./configure --with-max-unicast-destinations=512

make

Expand Down Expand Up @@ -156,8 +156,9 @@ fi
%{_datadir}/ptpd/*

%changelog
* Mon Jun 15 2015 Wojciech Owczarek <wojciech@owczarek.co.uk> 2.3.1-0.99.rc5
* Mon Jun 01 2015 Wojciech Owczarek <wojciech@owczarek.co.uk> 2.3.1-0.99.rc4
- RC4 release, adds leap seconds file and config files
- rc5 release, adds leap seconds file and config files
* Wed Apr 15 2015 Wojciech Owczarek <wojciech@owczarek.co.uk> 2.3.1-0.99.rc4.pre2
* Mon Apr 13 2015 Wojciech Owczarek <wojciech@owczarek.co.uk> 2.3.1-0.99.rc4.pre1
* Tue Oct 07 2014 Wojciech Owczarek <wojciech@owczarek.co.uk> 2.3.1-0.99.rc3
Expand Down
2 changes: 1 addition & 1 deletion src/dep/datatypes_dep.h
Expand Up @@ -81,7 +81,7 @@ typedef struct {
*/
typedef struct {
Integer32 eventSock, generalSock;
Integer32 multicastAddr, peerMulticastAddr,unicastAddr;
Integer32 multicastAddr, peerMulticastAddr;

/* Interface address and capability descriptor */
InterfaceInfo interfaceInfo;
Expand Down
59 changes: 27 additions & 32 deletions src/dep/net.c
Expand Up @@ -1447,11 +1447,13 @@ netRecvEvent(Octet * buf, TimeInternal * time, NetPath * netPath, int flags)
if(!(flags & MSG_ERRQUEUE))
#endif
netPath->lastSourceAddr = from_addr.sin_addr.s_addr;

netPath->receivedPacketsTotal++;

/* do not report "from self" */
if(!netPath->lastSourceAddr || (netPath->lastSourceAddr != netPath->interfaceAddr.s_addr)) {
netPath->receivedPackets++;
}
netPath->receivedPacketsTotal++;

if (msg.msg_controllen <= 0) {
ERROR("received short ancillary data (%ld/%ld)\n",
Expand Down Expand Up @@ -1481,6 +1483,8 @@ netRecvEvent(Octet * buf, TimeInternal * time, NetPath * netPath, int flags)
DBG("IP_RECVDSTADDR Dst: %s\n", inet_ntoa(*pa));
}
#endif


if (cmsg->cmsg_level == SOL_SOCKET) {
#if defined(SO_TIMESTAMPING) && defined(SO_TIMESTAMPNS)
if(cmsg->cmsg_type == SO_TIMESTAMPING ||
Expand Down Expand Up @@ -1531,6 +1535,7 @@ netRecvEvent(Octet * buf, TimeInternal * time, NetPath * netPath, int flags)

}


if (!timestampValid) {
/*
* do not try to get by with recording the time here, better
Expand Down Expand Up @@ -1573,10 +1578,11 @@ netRecvEvent(Octet * buf, TimeInternal * time, NetPath * netPath, int flags)
netPath->lastDestAddr = *(Integer32 *)(pkt_data + 30);
}

/* do not report "from self" */
if(!netPath->lastSourceAddr || (netPath->lastSourceAddr != netPath->interfaceAddr.s_addr)) {
netPath->receivedPackets++;
}
/* do not report "from self" */
if(!netPath->lastSourceAddr || (netPath->lastSourceAddr != netPath->interfaceAddr.s_addr)) {
netPath->receivedPackets++;
}

netPath->receivedPacketsTotal++;

/* XXX Total cheat */
Expand Down Expand Up @@ -1666,7 +1672,7 @@ netRecvGeneral(Octet * buf, NetPath * netPath)

/* do not report "from self" */
if(!netPath->lastSourceAddr || (netPath->lastSourceAddr != netPath->interfaceAddr.s_addr)) {
netPath->receivedPackets++;
netPath->receivedPackets++;
}

netPath->receivedPacketsTotal++;
Expand Down Expand Up @@ -1703,16 +1709,16 @@ netSendPcapEther(Octet * buf, UInteger16 length,
#endif

//
// alt_dst: alternative destination.
// destinationAddress: destination:
// if filled, send to this unicast dest;
// if zero, do the normal operation (send to unicast with -u, or send to the multcast group)
// if zero, sending to multicast.
//
///
/// TODO: merge these 2 functions into one
///
ssize_t
netSendEvent(Octet * buf, UInteger16 length, NetPath * netPath,
const RunTimeOpts *rtOpts, Integer32 alt_dst, TimeInternal * tim)
const RunTimeOpts *rtOpts, Integer32 destinationAddress, TimeInternal * tim)
{
ssize_t ret;
struct sockaddr_in addr;
Expand All @@ -1730,23 +1736,22 @@ netSendEvent(Octet * buf, UInteger16 length, NetPath * netPath,
(struct ether_addr *)netPath->interfaceID,
netPath->pcapGeneral);

if (ret <= 0)
if (ret <= 0)
DBG("Error sending ether multicast event message\n");
else {
netPath->sentPackets++;
netPath->sentPacketsTotal++;
}
} else {
#endif
if (netPath->unicastAddr || alt_dst ) {
if(alt_dst) {
addr.sin_addr.s_addr = alt_dst;
} else if (netPath->unicastAddr) {
addr.sin_addr.s_addr = netPath->unicastAddr;
}
if (destinationAddress ) {
addr.sin_addr.s_addr = destinationAddress;
/*
* This function is used for PTP only anyway...
* This function is used for PTP only anyway - for now.
* If we're sending to a unicast address, set the UNICAST flag.
* Transport API in LibCCK / 2.4 uses a callback for this,
* so the client can do something with the payload before it's sent,
* depending if it's unicast or multicast.
*/
*(char *)(buf + 6) |= PTP_UNICAST;

Expand Down Expand Up @@ -1836,7 +1841,7 @@ netSendEvent(Octet * buf, UInteger16 length, NetPath * netPath,

ssize_t
netSendGeneral(Octet * buf, UInteger16 length, NetPath * netPath,
const const RunTimeOpts *rtOpts, Integer32 alt_dst)
const const RunTimeOpts *rtOpts, Integer32 destinationAddress)
{
ssize_t ret;
struct sockaddr_in addr;
Expand All @@ -1859,13 +1864,9 @@ netSendGeneral(Octet * buf, UInteger16 length, NetPath * netPath,
}
} else {
#endif
if(alt_dst || netPath->unicastAddr) {
if(alt_dst) {
addr.sin_addr.s_addr = alt_dst;
} else if (netPath->unicastAddr) {
addr.sin_addr.s_addr = netPath->unicastAddr;
}
if(destinationAddress) {

addr.sin_addr.s_addr = destinationAddress;
/*
* This function is used for PTP only anyway...
* If we're sending to a unicast address, set the UNICAST flag.
Expand Down Expand Up @@ -1928,6 +1929,7 @@ netSendPeerGeneral(Octet * buf, UInteger16 length, NetPath * netPath, const RunT

if (ret <= 0)
DBG("error sending ether multicast general message\n");

} else if (dst)
#else
if (dst)
Expand Down Expand Up @@ -1962,6 +1964,7 @@ netSendPeerGeneral(Octet * buf, UInteger16 length, NetPath * netPath, const RunT
sizeof(struct sockaddr_in));
if (ret <= 0)
DBG("Error sending multicast peer general message\n");

}

if (ret > 0) {
Expand Down Expand Up @@ -2009,10 +2012,6 @@ netSendPeerEvent(Octet * buf, UInteger16 length, NetPath * netPath, const RunTim
sizeof(struct sockaddr_in));
if (ret <= 0)
DBG("Error sending unicast peer event message\n");
else {
netPath->sentPackets++;
netPath->sentPacketsTotal++;
}

#ifndef SO_TIMESTAMPING
/*
Expand Down Expand Up @@ -2062,10 +2061,6 @@ netSendPeerEvent(Octet * buf, UInteger16 length, NetPath * netPath, const RunTim
sizeof(struct sockaddr_in));
if (ret <= 0)
DBG("Error sending multicast peer event message\n");
else {
netPath->sentPackets++;
netPath->sentPacketsTotal++;
}
#ifdef SO_TIMESTAMPING
if(!netPath->txTimestampFailure) {
if(!getTxTimestamp(netPath, tim)) {
Expand Down
6 changes: 3 additions & 3 deletions src/dep/ntpengine/ntpdcontrol.c
Expand Up @@ -693,9 +693,9 @@ NTPDCquery(
* Try to be compatible with older implementations of ntpd.
*/
if (res == INFO_ERR_FMT && req_pkt_size != 48) {
int oldsize;

oldsize = req_pkt_size;
#ifdef RUNTIME_DEBUG
int oldsize = req_pkt_size;
#endif /* RUNTIME_DEBUG */

switch(req_pkt_size) {
case REQ_LEN_NOMAC:
Expand Down

0 comments on commit cda230b

Please sign in to comment.