ptpd(8)
β¨ ptpd(8) β¨ β the Precision Time Protocol daemon
okay bestie, sit down, hydrate, because today we're talking about ptpd, the Precision Time Protocol daemon, and this is the manual page for it. this is part 1 of 2 so don't go anywhere π
NAME π
ptpd β Precision Time Protocol daemon (1588-2008)
SYNOPSIS πΈ
ptpd [ -?hH ] [ -e SETTING ] [ -kvOLAl ] [ -smMyEPanCV ] [ -c FILE ] [
-R DIR ] [ -f FILE ] [ -S FILE ] [ -d DOMAIN ] [ -u ADDRESS ] [ -r
NUMBER ] -i INTERFACE
DESCRIPTION π
so. PTPd is a daemon that implements the Precision Time Protocol (PTP) Version 2, exactly as defined by the IEEE 1588-2008 standard. PTP was literally invented to give LAN-connected computers very precise time coordination β like, clock-sync but make it β¨fancyβ¨.
π the daemon must run as root, no cap, because it needs to manipulate the system clock and use low port numbers. that's not a suggestion, that's the law.
PTPd is feature rich fr fr β it supports IPv4 multicast, unicast and hybrid mode (mixed) operation, plus Ethernet mode. and listen: even without hardware assistance, PTPd can achieve and maintain sub-microsecond level timing precision, and it can withstand PTP Grandmaster failovers, link failures and restarts with minimal impact to timing performance. it's giving main character energy π¦
PTPd is lightweight, portable, and currently supports Linux, FreeBSD and Mac OS X, running on multiple CPU architectures, 32-bit and 64-bit, including x86 and ARM. slay.
COMMAND-LINE CONFIGURATION π§
as of version 2.3.0, the configuration file is the preferred mechanism for configuring PTPd. so the short options (-x) and long options (--xxxxx) mostly give you basic control over daemon operation, and only the very basic PTP protocol settings.
the rest of the settings (peep ptpd2.conf(5) for those π) can also be specified as command-line options, but they take the long --key:section="value" form. iykyk.
BASIC DAEMON OPTIONS β
-c,--config-file PATHβ path to the configuration file (check outptpd2.conf(5))-k,--check-configβ check the configuration and dip out β returns0if the configuration is correct-v,--versionβ print the version string and exit-h,--helpβ show the help screen-H,--long-helpβ show detailed help for all settings and behaviours-e,--explain SETTINGβ show help for a single setting (section:key)-O,--default-configβ show the default configuration and exit (the output is usable as a configuration file, cute)-L,--ignore-lockβ skip lock file checks and locking (alsoglobal:ignore_lock)-A,--auto-lockβ use preset / port mode specific lock file names β super useful when you're running multiple instances-l,--lockfileβ specify the lock file path (alsoglobal:lock_file)-p,--print-lockfileβ print the path to the lock file and exit (handy for init scripts combined with auto lock files)-R,--lock-directory DIRβ directory to store lock files in (alsoglobal:lock_directory)-f,--log-file PATHβ path to the log file (alsoglobal:logfile)-S,--statistics-file PATHβ path to the statistics file (alsoglobal:statistics_file)
BASIC PTP PROTOCOL OPTIONS π
-i,--interface DEVβ REQUIRED: interface to use βeth0, etc. (alsoptpengine:interface)-d,--domain NUMBERβ PTP domain number to become part of (alsoptpengine:domain)-s,--slaveonlyβ slave only mode (alsoptpengine:preset=slaveonly)-m,--masterslaveβ full IEEE 1588 implementation: master, slave when not best GM (alsoptpengine:preset=masterslave)-M,--masteronlyβ master only mode: passive when not best GM (alsoptpengine:preset=masteronly)-y,--hybridβ hybrid mode β mixed multicast and unicast operation (multicast for sync and announce, unicast for delay request and response (alsoptpengine:ip_mode=hybrid)-U,--unicastβ unicast operation β (alsoptpengine:ip_mode=unicast). for a GM, unicast destinations must be specified (-u,--unicast-destinations,ptpengine:unicast_destinations) unless you're using unicast negotiation (-g,--unicast-negotiation,ptpengine:unicast_negotiation=y) for delay request and response (alsoptpengine:ip_mode=hybrid). for a slave, unicast destinations must be specified if not using unicast negotiation.-g,--unicast-negotiationβ enable unicast message delivery and interval negotiation using signaling messages, as used by the Telecom profile (this also enablesptpengine:ip_mode=unicast)-u,--unicast-destinations ip/host, ip/host, ...β list of unicast destinations β see--unicast(alsoptpengine:ip_mode=unicast+ptpengine:unicast_destinations)-E,--e2eβ end to end delay mechanism (alsoptpengine:delay_mechanism=E2E)-E,--p2pβ peer to peer delay mechanism (alsoptpengine:delay_mechanism=P2P)-a,--delay-overrideβ in slave state, override the delay request interval announced by the master (alsoptpengine:log_delayreq_override) β the value ofptpengine:log_delayreq_intervalis what gets used-r,--delay-interval NUMBERβ specify the delay request message interval (log 2) β (alsoptpengine:log_delayreq_interval)-n,--clock:no_adjustβ do not adjust the clock (alsoclock:no_adjust)-D<DD...>,--debugβ debug level (alsoglobal:debug_level) β only if compiled withRUNTIME_DEBUG-C,--foregroundβ don't run in the background (alsoglobal:foreground=Y)-V,--verboseβ run in the foreground, log all the messages to standard output (alsoglobal:verbose_foreground=Y)
COMPATIBILITY OPTIONS π
PTPd supports the following options compatible with versions before 2.3.0:
-b DEVβ network interface to use-i NUMBERβ PTP domain number-gβ slave only mode-Gβ Β΄Master mode with NTPΒ΄ (master only mode)-Wβ Β΄Master mode without NTPΒ΄ (master / slave mode)-Uβ hybrid mode (mixed unicast + multicast operation)-Y NUMBERβ delay request interval (log 2)-tβ do not adjust the clock
π NOTE: the above options are deprecated and will be removed in subsequent versions. until then, their use will issue a warning. so likeβ¦ don't get attached bestie.
PTPD PORT STATES π
initβ INITIALIZINGfltβ FAULTYlstn_initβ LISTENING (first time)lstn_resetβ LISTENING (subsequent reset)passβ PASSIVE (not best master, not announcing)unclβ UNCALIBRATEDslvβ SLAVEpmstβ PRE-MASTERmstβ MASTER (active)dsblβ DISABLED?(unk) β UNKNOWN state
π STATISTICS LOG FILE FORMAT π
Okay bestie, this is the part where your clock tells you everything about how it's doing. When the statistics log is enabled (ptpengine:log_statistics, verbose foreground mode or log file - ptpengine:statistics_file), a PTPd slave will log clock sync info every single time it receives a Sync and a Delay Response message. Obsessed.
When PTPd starts up, or when it flushes the log, a comment line gets logged β and yes, it starts with # β containing the names of all the columns. The format of this log is a series of comma-separated values (CSV), so it drops straight into statistics tools and most spreadsheet software for analysis and graphing. Slay.
Heads up: this log can get very large if you're running PTPd for long periods of time with high message rates. To cut down on the number of messages logged, use theglobal:statistics_log_intervalsetting to limit the output to one message per configured interval only. The size and max number of the statistics log can also be controlled β (seeptpd2.conf(5)).
The meaning of the columns is as follows:
- Timestamp β Time when the message was received. This can take the form of text date / time or Unix timestamp (with fractional seconds), or both (in which case an extra field is added), depending on the
global:statistics_timestamp_formatsetting (seeptpd2.conf(5)). When you're importing the log into plotting software: if the software can understand Unix time, it's best to set the timestamp format tounixorboth, because some software will not properly deal with the fractional part of the second when converting the date and time from text. Lowkey a trap, fr fr. - State β Port state (see PTP PORT STATES).
- Clock ID β Port identity of the current best master, as defined by IEEE 1588. This will be the local clock's ID if the local clock is the best master. Displayed as
clock_id/port(host). Port is the PTP clock port number, not to be confused with UDP ports. The clock ID is an EUI-64 64-bit ID, usually converted from the 48-bit MAC address, by inserting0xfffebetween the lower and upper half of the MAC address. PTPd will attempt to convert the clock ID back to MAC address and look up the hostname from/etc/ethers(seeethers(5)). Populating the ethers file will help the administrator recognise the masters by familiar hostnames. Cute, right? π - One Way Delay β Current value of one-way delay (or mean path delay) in seconds, calculated by PTPd in slave state from the Delay Request - Delay Response message exchange. Note: if this value remains at zero, this usually means that no Delay Response messages are being received, likely due to a network issue. π
- Offset From Master β Current value of offset from master in seconds β this is the main output of the PTP engine in slave state, which is the input of the clock servo for clock corrections. This is the value typically observed when estimating the slave performance. Main character value tbh.
- Slave to Master β Intermediate offset value (seconds) extracted from the Delay Request - Delay Response message exchange, used for computing one-way delay. If the last value was rejected by a filter, the previous value will be shown in the log. This value will also be zero if no Delay Response messages are being received.
- Master to Slave β Intermediate offset value (seconds) extracted from the Sync messages, used for computing the offset from master. If the last value was rejected by a filter, the previous value will be shown in the log.
- Observed Drift β The integral accumulator of the clock control PI servo model β frequency difference between the slave clock and master clock. This value becomes stable when the clock offset has stabilised, and can be used (and is) to detect clock stability. β¨
- Last Packet Received β This field shows what message was received last β this will be
Sfor Sync andDfor Delay Response. If a slave logs noDentries, this means it's not receiving Delay Response messages, which could be a network issue. Vibe check your network bestie. - One Way Delay Mean β One-way delay mean computed over the last sampling window.
- One Way Delay Std Dev β One-way delay standard deviation computed over the last sampling window.
- Offset From Master Mean β Offset from master mean computed over the last sampling window.
- Offset From Master Std Dev β Offset from master standard deviation computed over the last sampling window.
- Observed Drift Mean β Observed drift / local clock frequency adjustment mean computed over the last sampling window.
- Observed Drift Std Dev β Observed drift / local clock frequency adjustment standard deviation computed over the last sampling window. The lower the value, the less aggressively the clock is being controlled and therefore the more stable it is. πΈ
- raw delayMS β Raw (unfiltered) delayMS value β useful for evaluating outliers and filter performance.
- raw delaySM β Raw (unfiltered) delaySM value β useful for evaluating outliers and filter performance.
NOTE: All the statistical measures (mean and std dev) will only be computed and displayed if PTPd was built without--disable-statistics. The duration of the sampling period is controlled with theglobal:statistics_update_intervalsetting β (seeptpd2.conf(5)).
π¨ HANDLED SIGNALS π¨
PTPd handles the following signals, and honestly some of these are so useful:
SIGHUPβ Reload configuration file (if used) and reopen log files.SIGUSR1β When in slave state, force clock step to current Offset from Master value. Iconic behaviour.SIGUSR2β Dump all PTP protocol counters to current log target (and clear ifptpengine:sigusr2_clears_countersset).SIGINT|SIGTERMβ Clean exit β close logs and other open files, clean up lock file and exit. π«ΆSIGKILLβ Force an unclean exit. Not cute, no cleanup, just chaos. π
π EXIT CODES π
Upon exit, ptpd2 returns 0 on success β either successfully started in daemon mode, or otherwise exited cleanly. 0 is also returned when the -k (--check-config) option is used and the configuration was correct.
A non-zero exit code is returned on errors:
3is returned on lock file errors and whenptpd2could not be started as daemon.2is returned on memory allocation errors during startup.1is returned for all other error conditions such as configuration errors, runningptpd2in help mode or with no parameters, on self shutdown, network startup errors and when attempting to runptpd2as non-root.
So like, 1 is the "it's giving problems" code. Periodt.
π» SUPPORTED PLATFORMS AND ARCHITECTURES π»
PTPd is fully supported on Linux and FreeBSD, because that's what the core developers focus on. OpenBSD and NetBSD are also supported, but they get less developers' attention. So is Mac OS X, and as of PTPd 2.3.1 also OpenSolaris (11) derivatives (tested on OmniOS). Sun's / Oracle's Solaris 11 has not been tested but in essence, it should work as intended.
Solaris 10 is NOT supported because it does not provide theSO_TIMESTAMPsocket option. It should theoretically be possible to use Solaris 10 using thepffacility as used bysnoop, but there is currently no ongoing effort to achieve this.
Patches for QNX/Neutrino have been provided, but cannot yet officially be merged because of no availability of QNX to the developers. Some users have ported PTPd to other RTOS, but this has not been merged either. The way that these ports are just sitting there unmerged π
As of 2.3.1, PTPd runs entirely in software and only relies on kernel and OS APIs, so there are no hardware dependencies. Any little-endian or big-endian port of modern versions of the supported OSes should work, but only x86 and ARM are actively tested. The only dependencies close to hardware can be NIC drivers and how and if they impact software timestamping.
β±οΈ HARDWARE TIMESTAMPING SUPPORT β±οΈ
As of 2.3.1, PTPd still does not support hardware timestamping. This functionality will appear in the upcoming version 2.4 β potentially an interim version of 2.3.x may be delivered that will support hardware clocks and timestamping on Linux.
This is very much OS-specific and, to a large extent, hardware-specific. Linux has a PTP kernel API but not all hardware supports it. Because PTPd supports multiple OS platforms, where hardware timestamping may use different mechanisms on every platform, it has to be re-written in a modular way to allow this without unnecessarily increasing code complexity, which already is a problem. The way that complexity is already a problem π
π BUGS π
As of ptpd 2.3.1, the (Open)Solaris (11) OS family is supported, but libpcap functionality is currently broken β IPv4/pcap and Ethernet transports cannot be used on those systems. PTPd will compile and run, but will not receive any data. Not it just vibing there receiving absolutely nothing π
Please report any bugs using the bug tracker on the SourceForge page:
http://sourceforge.net/projects/ptpd/
π SEE ALSO π
π AUTHORS π
- Gael Mace
<gael_mace@users.sourceforge.net> - Alexandre Van Kempen
- Steven Kreuzer
<skreuzer@freebsd.org> - George Neville-Neil
<gnn@freebsd.org> - Wojciech Owczarek
<wojciech@owczarek.co.uk>
The ptpd2(8) man page was written by Wojciech Owczarek for ptpd 2.3.0 in November 2013.
And that's a wrap bestie β¨ this whole thing is version 2.3.1, dated June, 2015, and it lives at ptpd(8) β go forth and sync, you absolute queen ππ
π¦ where this page comes from
- debian bookworm: ptpd 2.3.1-debian1-4+b1
- debian trixie: ptpd 2.3.1-debian1-4+b2
- ubuntu jammy: ptpd 2.3.1-debian1-4
- ubuntu noble: ptpd 2.3.1-debian1-4build2
- ubuntu questing: ptpd 2.3.1-debian1-4build2
- ubuntu resolute: ptpd 2.3.1-debian1-5
- ubuntu stonking: ptpd 2.3.1-debian1-6
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms