| .TH TS2PHC 8 "March 2024" "linuxptp" |
| .SH NAME |
| ts2phc - Synchronizes one or more PTP Hardware Clocks using external time stamps. |
| |
| .SH SYNOPSIS |
| .B ts2phc |
| [ |
| .B \-hmqv |
| ] [ |
| .BI \-c " device|name" |
| ] [ |
| .BI \-f " config" |
| ] [ |
| .BI \-l " print-level" |
| ] [ |
| .BI \-s " device|name" |
| ] [ |
| .I long-options |
| ] |
| .I .\|.\|. |
| |
| .SH DESCRIPTION |
| .B ts2phc |
| synchronizes PTP Hardware Clocks (PHC) to external time stamp signals. |
| A single source may be used to distribute time to one or more PHC devices. |
| |
| .SH OPTIONS |
| .TP |
| .BI \-a |
| Adjust the direction of synchronization automatically. The program determines |
| which PHC should the reference clock for time distribution and which should |
| be the destinations by querying the port states from the running instance of |
| .B ptp4l. |
| Note that using this option, the PPS signal distribution hierarchy still |
| remains fixed as per the configuration file. This implies that using this |
| option, a PPS source of the PHC kind may become a target clock, and a PPS sink |
| may become a reference clock. Other, non-PHC types of PPS sources (generic, |
| NMEA) cannot become target clocks. Clocks which are not part of |
| .B ptp4l's |
| list of ports are not synchronized. This option is useful when the |
| .B boundary_clock_jbod |
| option of ptp4l is also enabled. |
| .TP |
| .BI \-c " device|name" |
| Specifies a PHC to be synchronized. |
| The clock may be identified by its character device (like /dev/ptp0) |
| or its associated network interface (like eth0). |
| This option may be given multiple times. |
| .TP |
| .BI \-f " config" |
| Read configuration from the specified file. |
| No configuration file is read by default. |
| .TP |
| .BI \-h |
| Displays the command line help summary. |
| .TP |
| .BI \-l " print-level" |
| Sets the maximum syslog level of messages which should be printed or |
| sent to the system logger. The default is 6 (LOG_INFO). |
| .TP |
| .B \-m |
| Prints log messages to the standard output. |
| .TP |
| .B \-q |
| Prevents sending log messages to the system logger. |
| .TP |
| .BI \-s " device|name" |
| Specifies the source of the Time of Day (ToD) data. |
| Use the key word "generic" for an external 1-PPS without ToD information. |
| When using a PHC as the time source, the clock may be identified by its character |
| device (like /dev/ptp0) or its associated network interface (like |
| eth0). |
| Use the key word "nmea" for an external 1-PPS from a GPS providing ToD |
| information via the RMC NMEA sentence. |
| .TP |
| .B \-v |
| Prints the software version and exits. |
| |
| .SH LONG OPTIONS |
| |
| Each and every configuration file option (see below) may also appear |
| as a "long" style command line argument. For example, the use_syslog |
| option may be set using either of these two forms. |
| |
| .RS |
| \f(CW\-\-use_syslog 1 \-\-use_syslog=1\fP |
| .RE |
| |
| Option values given on the command line override values in the global |
| section of the configuration file. |
| |
| .SH CONFIGURATION FILE |
| |
| The configuration file is divided into sections. Each section starts with a |
| line containing its name enclosed in brackets and it follows with settings. |
| Each setting is placed on a separate line, it contains the name of the |
| option and the value separated by whitespace characters. Empty lines and lines |
| starting with # are ignored. |
| |
| There are two different section types. |
| |
| .TP |
| .B 1. |
| The global section (indicated as |
| .BR [global] ) |
| sets the program options and the default time sink options. Other |
| sections are clock specific sections, and they override the default |
| options. |
| .TP |
| .B 2. |
| Time sink sections give the name of the configured PHC (e.g. |
| .BR [eth0] ). |
| Time sinks specified in the configuration file need not be specified |
| with the |
| .B \-c |
| command line option. |
| |
| .SH GLOBAL OPTIONS |
| |
| .TP |
| .B active_key_id |
| Used in conjunction with \fBspp\fR and \fBsa_file\fR directives to |
| specify which key from the \fBspp\fR defined Security Association |
| should be used for outbound icv calculations. All Security Assocations |
| are read from the file specified by \fBsa_file\fR. Requires \fBspp\fR |
| and \fBsa_file\fR directives. Must be in the range of 1 to 2^32-1, |
| inclusive. The default is 0 (disabled). |
| |
| .TP |
| .B clock_servo |
| The servo which is used to synchronize the local clock. Valid values |
| are "pi" for a PI controller, "linreg" for an adaptive controller |
| using linear regression, "ntpshm" and "refclock_sock" for the NTP SHM and |
| chrony SOCK reference clocks respectively to allow another process to |
| synchronize the local clock, and "nullf" for a servo that always dials |
| frequency offset zero (for use in SyncE nodes). |
| The default is "pi". |
| |
| .TP |
| .B first_step_threshold |
| The maximum offset, specified in seconds, that the servo will correct by |
| changing the clock frequency (phase when using nullf servo) instead of stepping |
| the clock. This is only applied on the first update. When set to 0.0, the servo |
| will not step the clock on start. |
| The default is 0.00002 (20 microseconds). |
| |
| .TP |
| .B free_running |
| When set to 1, no PHC will be adjusted. |
| This option can be useful in test scenarios, for example to determine |
| how well synchronized a group of local clocks are to each other. |
| The default is 0 (adjust the clocks). |
| |
| .TP |
| .B leapfile |
| The path to the current leap seconds definition file. In a Debian |
| system this file is provided by the tzdata package and can be found at |
| /usr/share/zoneinfo/leap-seconds.list. If a leapfile is configured it |
| will be reloaded if modified. The default is an empty string, which |
| causes the program to use a hard coded table that reflects the known |
| leap seconds on the date of the software's release. |
| |
| .TP |
| .B logging_level |
| The maximum logging level of messages which should be printed. |
| The default is 6 (LOG_INFO). |
| |
| .TP |
| .B max_frequency |
| The maximum allowed frequency adjustment of the clock in parts per |
| billion. This is an additional limit to the maximum allowed by the |
| hardware. When set to 0, the hardware limit will be used. |
| The default is 900000000 (90%). |
| |
| .TP |
| .B message_tag |
| The tag which is added to all messages printed to the standard output |
| or system log. If the tag contains the string "{level}", it will be replaced |
| with the log level of the message as a number. The default is an empty string |
| (which cannot be set in the configuration file as the option requires an |
| argument). |
| |
| .TP |
| .B ntpshm_segment |
| The number of the SHM segment used by ntpshm servo. |
| The default is 0. |
| |
| .TP |
| .B pi_integral_const |
| The integral constant of the PI controller. When set to 0.0, the |
| integral constant will be set by the following formula from the current |
| sync interval. |
| The default is 0.0. |
| |
| ki = min(ki_scale * sync^ki_exponent, ki_norm_max / sync) |
| |
| .TP |
| .B pi_integral_exponent |
| The ki_exponent constant in the formula used to set the integral constant of |
| the PI controller from the sync interval. |
| The default is 0.4. |
| |
| .TP |
| .B pi_integral_norm_max |
| The ki_norm_max constant in the formula used to set the integral constant of |
| the PI controller from the sync interval. |
| The default is 0.3. |
| |
| .TP |
| .B pi_integral_scale |
| The ki_scale constant in the formula used to set the integral constant of |
| the PI controller from the sync interval. |
| The default is 0.3. |
| |
| .TP |
| .B pi_proportional_const |
| The proportional constant of the PI controller. When set to 0.0, the |
| proportional constant will be set by the following formula from the current |
| sync interval. |
| The default is 0.0. |
| |
| kp = min(kp_scale * sync^kp_exponent, kp_norm_max / sync) |
| |
| .TP |
| .B pi_proportional_exponent |
| The kp_exponent constant in the formula used to set the proportional constant of |
| the PI controller from the sync interval. |
| The default is \-0.3. |
| |
| .TP |
| .B pi_proportional_norm_max |
| The kp_norm_max constant in the formula used to set the proportional constant of |
| the PI controller from the sync interval. |
| The default is 0.7 |
| |
| .TP |
| .B pi_proportional_scale |
| The kp_scale constant in the formula used to set the proportional constant of |
| the PI controller from the sync interval. |
| The default is 0.7. |
| |
| .B sa_file |
| Specifies the location of the file containing Security Associations used |
| for immediate security processing of the Authentication TLV in support of |
| the optional security mechanism defined in ieee1588-2019 ch 14.16. See |
| \fBSECURITY ASSOCIATION OPTIONS\fR for more info on file contents. |
| The default is an empty string. (disabled). |
| |
| .TP |
| .B servo_num_offset_values |
| The number of offset values considered in order to transition from the |
| SERVO_LOCKED to the SERVO_LOCKED_STABLE state. |
| The transition occurs once the last 'servo_num_offset_values' offsets |
| are all below the 'servo_offset_threshold' value. |
| The default value is 10. |
| |
| .TP |
| .B servo_offset_threshold |
| The offset threshold used in order to transition from the SERVO_LOCKED |
| to the SERVO_LOCKED_STABLE state. The transition occurs once the |
| last 'servo_num_offset_values' offsets are all below the threshold value. |
| The default value of offset_threshold is 0 (disabled). |
| |
| .TP |
| .B step_threshold |
| The maximum offset, specified in seconds, that the servo will correct |
| by changing the clock frequency instead of stepping the clock. When |
| set to 0.0, the servo will never step the clock except on start. |
| The default is 0.0. |
| |
| .TP |
| .B spp |
| Specifies the security parameters pointer for the desired security association |
| to be used for authentication tlv support. If specified, the port owning the |
| spp will attempt to attach (outbound) and check (inbound) authentication tlvs |
| for all messages in accordance to the corresponding security association |
| sourced via the \fBsa_file\fR directive. Not compatible with one step ports. |
| Must be in the range of -1 to 255, inclusive. The default is -1 (disabled). |
| |
| .TP |
| .B ts2phc.external_pps |
| Enables an external reference with the \fB-a\fP option. If set to 1, ts2phc |
| will assume the source of the PPS signal is a different clock from the PHCs |
| used by ptp4l (configured with the \fBboundary_clock_jbod\fP option). The use |
| case is a holdover using an externally controlled stabilized clock, which is |
| expected to be synchronized to the PHC that is synchronized by ptp4l, and |
| running free when ptp4l is not synchronizing any of the PHCs. Note that it is a |
| different holdover than the one enabled by the \fBts2phc.holdover\fP option |
| below. The default is 0 (disabled). |
| .TP |
| .B ts2phc.holdover |
| The holdover interval, specified in seconds. When the ToD information stops |
| working (e.g. GNSS receiver lost its fix), ts2phc is allowed for the specified |
| interval to continue synchronizing the target clock as long as the servo is in |
| the SERVO_LOCKED_STABLE state. The servo state needs be enabled by the |
| \fBservo_offset_threshold\fP option. The holdover is not supported with the |
| \fB-a\fP option and when \fBts2phc.extts_polarity\fP is set to \fIboth\fP. |
| The default is 0 (disabled). |
| |
| .TP |
| .B ts2phc.nmea_delay |
| Specifies the minimum expected delay of NMEA RMC messages in nanoseconds. |
| If the maximum delay is longer than 1 second, or 'ts2phc.pulsewidth' |
| if 'ts2phc.extts_polarity' is set to "both", this option needs to be set |
| accordingly to allow the timestamps from NMEA messages to be correctly |
| assigned to pulses from the PPS signal and wrong PPS edges to be rejected if |
| the edge rejection is enabled. |
| The default is 0 nanoseconds. |
| |
| .TP |
| .B ts2phc.nmea_remote_host, ts2phc.nmea_remote_port |
| Specifies the remote host providing ToD information when using the |
| "nmea" PPS signal source. Note that if these two options are both |
| specified, then the given remote connection will be used in preference |
| to the configured serial port. |
| These options default to the empty string, that is, not specified. |
| |
| .TP |
| .B ts2phc.nmea_serialport, ts2phc.nmea_baudrate |
| Specifies the serial port and baudrate in bps for character device |
| providing ToD information when using the "nmea" PPS signal source. Note |
| that if the options, ts2phc.nmea_remote_host and |
| ts2phc.nmea_remote_port, are both specified, then the given remote |
| connection will be used in preference to the configured serial port. |
| The default serial port is "/dev/ttyS0". |
| The default baudrate is 9600 bps. |
| |
| .TP |
| .B ts2phc.perout_phase |
| Configures the offset between the beginning of the second and the PPS |
| source's rising edge. Available only for the PHC kind of PPS source. The supported |
| range is 0 to 999999999 nanoseconds. The default is 0 nanoseconds, but |
| leaving this option unspecified will not transmit the phase to the kernel, |
| instead PPS will be requested to start at an absolute time equal to the |
| nearest 2nd full second since the start of the program. This should yield |
| the same effect, but may not work with drivers that do not support |
| starting periodic output at an absolute time. |
| |
| .TP |
| .B ts2phc.pulsewidth |
| The pulse width of the external PPS signal in nanoseconds. |
| When 'ts2phc.extts_polarity' is "both", the given pulse width is used |
| to detect and discard the time stamp of the unwanted edge. In case the PPS |
| source is of the PHC kind, an attempt is made to request the kernel to actually |
| emit using this pulse width. If this fails, it is assumed that the specified |
| pulse width is correct, and the value is used in the edge rejection algorithm. |
| The supported range is 1000000 to 990000000 nanoseconds. |
| The default is 500000000 nanoseconds. |
| |
| .TP |
| .B ts2phc.tod_source |
| Specifies the source of Time of Day (ToD) data. |
| Use the key word "generic" for an external 1-PPS without ToD information. |
| When using a PHC as the time source, the clock may be identified by its character |
| device (like /dev/ptp0) or its associated network interface (like |
| eth0). |
| Use the key word "nmea" for an external 1-PPS from a GPS providing ToD |
| information via the RMC NMEA sentence. |
| The default is "generic" |
| |
| .TP |
| .B use_syslog |
| Print messages to the system log if enabled. The default is 1 (enabled). |
| |
| .TP |
| .B verbose |
| Print messages to the standard output if enabled. The default is 0 (disabled). |
| |
| .SH TIME SINK OPTIONS |
| |
| .TP |
| .B ts2phc.channel |
| The external time stamping or periodic output channel to be used. |
| Some PHC devices feature programmable pins and one or more time |
| stamping channels. This option allows selecting a particular channel |
| to be used. When using a PHC device as the PPS source, this option |
| selects the periodic output channel. |
| The default is channel 0. |
| .TP |
| .B ts2phc.extts_correction |
| The value, in nanoseconds, to be added to each PPS time stamp. |
| The default is 0 (no correction). |
| .TP |
| .B ts2phc.extts_polarity |
| The polarity of the external PPS signal, either "rising" or "falling". |
| Some PHC devices always time stamp both edges. Setting this option to |
| "both" will allow the ts2phc program to work with such devices by |
| detecting and ignoring the unwanted edge. In this case be sure to |
| set 'ts2phc.pulsewidth' to the correct value. |
| The default is "rising". |
| .TP |
| .B ts2phc.master |
| Setting this option to 1 configures the given PHC device as the source |
| of the PPS signal. |
| The default is 0 for the time sink role. |
| .TP |
| .B ts2phc.pin_index |
| The pin index to be used. |
| Some PHC devices feature programmable pins, and this option allows |
| configuration of a particular pin for the external time stamping or |
| periodic output function. |
| The default is pin index 0. |
| |
| .SH WARNING |
| |
| Be cautious when sharing the same configuration file between ptp4l, |
| phc2sys, and ts2phc. Keep in mind that values specified in the |
| configuration file take precedence over the default values. If an |
| option which is common to the other programs is set in the |
| configuration file, then the value will be applied to all the programs |
| using the file, and this might not be what is expected. |
| |
| It is recommended to use separate configuration files for ptp4l, |
| phc2sys, and ts2phc in order to avoid any unexpected behavior. |
| |
| .SH SEE ALSO |
| .BR phc2sys (8) |
| .BR ptp4l (8) |