ptp
ptp- configure Precision Time Protocol to synchronize clocks.
SYNOPSIS
ptp sub-command options
DESCRIPTION
Precision Time Protocol (PTP) enables precise synchronization of clocks in measurement and control systems implemented with technologies such as network communication, local computing, and distributed objects. The protocol is applicable to systems communicating by local area networks supporting multicast messaging including, but not limited to, Ethernet. The protocol enables heterogeneous systems that include clocks of various inherent precision, resolution, and stability to synchronize to a grandmaster clock. The protocol supports system-wide synchronization accuracy in the sub-microsecond range with minimal network and local clock computing resources.
The Sync, Delay_Req, Follow_Up, and Delay_Resp messages are used to generate and communicate the timing information needed to synchronize ordinary and boundary clocks using the delay request-response mechanism.
STANDARD OPTIONS
controlField
The value of controlField depends on the message type defined in the messageType field. (default = 5)
Option |
Value |
Usage |
---|---|---|
ptpSync |
0 |
Sync |
ptpDelayRequest |
1 |
Delay request |
ptpFollowUp |
2 |
Follow-up |
ptpDelayResponse |
3 |
Delay response |
ptpManagement |
4 |
Management |
ptpOther |
5 |
(default) Other |
correctionField
Transparent clocks forward PTP timing messages through the clock in the manner of an ordinary bridge or router but, in addition, measure the time spent by a PTP timing message within the transparent clock. These "residence" times are accumulated in the correctionField in the PTP timing messages, which allows the slave to correct the timestamps, effectively removing the timing fluctuations that would otherwise be introduced by the bridges. Expressed in nanoseconds and fractions thereof. (default = 0.0)
domainNumber
A domain consists of one or more PTP devices communicating with each other as defined by the protocol. Range 0 - 255. (default = 0)
Value |
Usage |
---|---|
0 |
(default) |
1 |
Alternate domain 1 |
2 |
Alternate domain 2 |
3 |
Alternate domain 2 |
4-127 |
User-defined |
128-255 |
Reserved |
extensionId
Extension identifier. 5 byte hex list. (default = "00 00 00 00 00")
flagField
ORed values from flagField array, below. (default = 0)
Example code:
[expr $::ptpUtcOffsetValid|$::ptpFrequencyTraceable|$::ptpTwoStep|$::ptpUnicast
Option |
Value |
Usage |
---|---|---|
ptpLeap61 |
1 |
Leap 61 |
ptpLeap59 |
2 |
Leap 59 |
ptpUtcOffsetValid |
4 |
UTC offset valid |
ptpPtpTimescale |
8 |
PTP timescale |
ptpTimeTraceable |
16 |
Time traceable |
ptpFrequencyTraceable |
32 |
Frequency traceable |
ptpAlternateMaster |
256 |
Alternate master |
ptpTwoStep |
512 |
Two step For a one-step clock, the value of twoStepFlag shall be FALSE. For a two-step clock, the value of twoStepFlag shall be TRUE. |
ptpUnicast |
1024 |
Unicast TRUE, if the transport layer protocol address to which this message was sent is a unicast address. FALSE, if the transport layer protocol address to which this message was sent is a multicast address. |
ptpProfile1 |
8192 |
Profile 1 |
ptpProfile2 |
16384 |
Profile 2 |
logMessageInterval
The value of the logMessageInterval field is determined by the type of the message. (default = 0))
messageLength
Read only. The total number of octets that form the PTP message. The counted octets start with the first octet of the header and include and terminate with the last octet of any suffix or, if there are no suffix members with the last octet of the message. (default = 44)
messageType
Configure the message type from list. (default = ptpSyncMessage)
Option |
Value |
Usage |
---|---|---|
ptpSyncMessage |
0 |
PTP sync message |
ptpDelayRequestMessage |
1 |
PTP delay request message |
ptpFollowUpMessage |
8 |
PTP follow-up message |
ptpDelayResponseMessage |
9 |
PTP delay response message |
ptpAnnounceMessage |
11 |
PTP announce message |
organizationUniqueId
Organization Unique Identifier (OUI): the value of the OUI assigned to the vendor or standards organization by the IEEE. The most significant 3 octets of the clockIdentity shall be an OUI. (default = "00 00 00")
portNumber
Identifies a specific Precision Time Protocol (PTP) port on a PTP node.
sequenceId
The sequenceId of the message shall be one greater than the sequenceId of the previous message of the same message type sent to the same message destination address by the transmitting port. (default = 0)
transportSpecific
Read only. The transportSpecific field (default = 0)
Bit |
Name |
Meaning |
---|---|---|
0 |
hardwareCompatibility |
Check the length of the incoming packet before qualifying the timestamp and require the UDP payload of the PTP event messages to be at least 124 octets in length. Nodes using such hardware shall set bit 0 equal to "1" in all Announce and PTP event messages transmitted from the node. |
1-3 |
reserved |
The bit shall be transmitted as zero and ignored by the receiver |
version
Read only. Displays the PTP version. (default = 2)
COMMANDS
The ptp command is invoked with the following sub-commands. If no sub-command is specified, returns a list of all sub-commands available.
ptp cget option
Returns the current value of the configuration option given by option. Option may have any of the values accepted by the ptp command.
ptp config option value
Modify the configuration options of the port. If no option is specified, returns a list describing all of the available options (see STANDARD OPTIONS) for ptp.
ptp decode capFrame chasID cardID portID
Decodes the ptp header and trailer packet and refreshes the IxTclHal object.
ptp get chasID cardID portID
Gets current ptp header and trailer settings from IxHal and refreshes IxTclHal object.
ptp set chasID cardID portID
Sets the current ptp header and trailer settings from IxTclHal to local IxHal. Specific errors are:
- No connection to a chassis
- Invalid port number
- Unsupported feature
- The port is being used by another user
- The configured parameters are not valid for this port
ptp setDefault
Sets to IxTclHal default values for all configuration options.
EXAMPLES
package req IxTclHal
set hostname loopback
if {[ixConnectToChassis $hostname]} {
errorMsg "error connecting $hostname chassis"
return "FAIL"
}
set chassId [chassis cget -id]
set cardId 20
set portId 1
set streamId 1
set portList [list [list $chassId $cardId $portId ] ]
if { [port isValidFeature $chassId $cardId $portId $::portFeaturePtp]} {
# Configure Ptp streams
protocol setDefault
protocol config -ethernetType $::ethernetII
protocol config -name $::ipV4
protocol config -appName $::Ptp
ip setDefault
ip config -sourceIpAddr "111.111.112.222"
if {[ip set $chassId $cardId $portId]} {
errorMsg "Error calling ip set $chassId $cardId $portId"
return "FAIL"
}
udp setDefault
udp config -sourcePort ptpEventPort
udp config -destPort ptpGeneralPort
if {[udp set $chassId $cardId $portId]} {
errorMsg "Error calling udp set $chassId $cardId $portId"
return "FAIL"
}
ptpAnnounce setDefault
ptpAnnounce config -seconds 1111
ptpAnnounce config -nanoseconds 9999999
ptpAnnounce config -currentUtcOffset 1236
ptpAnnounce config -stepsRemoved 55
ptpAnnounce config -timeSource $::ptpAltPtpProfile0
ptpAnnounce config -priority1 11
ptpAnnounce config -priority2 12
ptpAnnounce config -clockClass 99
ptpAnnounce config -clockAccuracy $::ptpAccuracy100us
ptpAnnounce config -clockLogVariance 0
ptpAnnounce config -extensionId "AB CD EF 12 34"
ptpAnnounce config -organizationUniqueId "10 11 12"
ptp setDefault
ptp config -controlField $::ptpDelayRequest
ptp config -logMessageInterval 33
ptp config -domainNumber 55
ptp config -correctionField 123654.0
ptp config -sequenceId 6
ptp config -flagField [expr $::ptpUtcOffsetValid|$::ptpFrequencyTraceable|$::ptpTwoStep|$::ptpUnicast]
ptp config -messageType $::ptpAnnounceMessage
ptp config -portNumber 9999
ptp config -extensionId "AA D4 5D FE ED"
ptp config -organizationUniqueId "12 AA 45"
if {[ptp set $chassId $cardId $portId]} {
errorMsg "Error setting ptp on $chassId $cardId $portId"
return "FAIL"
}
stream setDefault
stream config -name "Ptp Announce Stream"
if {[stream set $chassId $cardId $portId $streamId]} {
errorMsg "Error setting stream on $chassId $cardId $portId $streamId"
return "FAIL"
}
incr streamId
ptpDelayResponse setDefault
ptpDelayResponse config -seconds 999
ptpDelayResponse config -nanoseconds 11
ptpDelayResponse config -portNumber 555
ptpDelayResponse config -extensionId "00 AB CD 12 34"
ptpDelayResponse config -organizationUniqueId "55 EF DA"
ptp setDefault
ptp config -controlField $::ptpDelayResponse
ptp config -logMessageInterval 127
ptp config -domainNumber 255
ptp config -correctionField 8888888
ptp config -sequenceId 2
ptp config -flagField [expr $::ptpTwoStep | $::ptpUtcOffsetValid | $::ptpFrequencyTraceable]
ptp config -messageType $::ptpDelayResponseMessage
ptp config -portNumber 0
ptp config -extensionId "00 34 AB 33 33"
ptp config -organizationUniqueId "B2 22 2A"
if {[ptp set $chassId $cardId $portId]} {
errorMsg "Error setting ptp on $chassId $cardId $portId"
return "FAIL"
}
stream setDefault
stream config -name "Ptp DelayResponse Stream"
if {[stream set $chassId $cardId $portId $streamId]} {
errorMsg "Error setting stream on $chassId $cardId $portId $streamId"
return "FAIL"
}
# Configure PTP interfaces
if {[interfaceTable select $chassId $cardId $portId]} {
errorMsg "Error selecting interfaceTable on $chassId $cardId $portId."
return "FAIL"
}
ptpProperties setDefault
ptpProperties config -clockId "AA 00 00 00 00 00 00 BC"
ptpProperties config -portNumber 22
ptpProperties config -enableClockMaster $::true
ptpProperties config -timestampError 11
ptpProperties config -badCrcPercent 0
ptpProperties config -dropFollowUpPercent 11
ptpProperties config -dropDelayResponsePercent 99
interfaceEntry config -enable false
interfaceEntry config -description {ProtocolInterface - 27:01 - 1}
interfaceEntry config -enablePtp true
if {[interfaceTable addInterface interfaceTypeConnected ]} {
errorMsg "Error adding interfaceTypeConnected to interfaceTable on $chassId $cardId $portId."
return "FAIL"
}
set interfaceDescription [interfaceEntry cget -description ]
ixWriteConfigToHardware portList
# Example how to retrieve PTP discovered information
if {[interfaceTable select $chassId $cardId $portId]} {
errorMsg "Error selecting interfaceTable on $chassId $cardId $portId."
return "FAIL"
}
interfaceEntry setDefault
ptpProperties setDefault
if {[interfaceTable getFirstInterface interfaceTypeConnected ]} {
errorMsg "Error adding interfaceTypeConnected to interfaceTable on $chassId $cardId $portId."
return "FAIL"
}
ixPuts "enablePtp: [interfaceEntry cget -enablePtp]"
ixPuts "announceInterval: [ptpProperties cget -announceInterval]"
# Below code is just for usage example
#if {[interfaceTable requestDiscoveredTable]} {
# errorMsg "Error interfaceTable requestDiscoveredTable on $chassId $cardId $portId."
# return "FAIL"
#}
# Some delay before the discovered information is ready, may depend on the configuration
#after 2000
#ptpDiscoveredInfo setDefault
#if {[interfaceTable getPtpDiscoveredInfo $interfaceDescription]} {
# errorMsg "Error getting PTP Discovered table for $interfaceDescription on $chassId $cardId $portId."
# return "FAIL"
#}
#ixPuts "ptpDiscoveredInfo clockId [ptpDiscoveredInfo cget -clockId]"
#ixPuts "ptpDiscoveredInfo announceMessageSent [ptpDiscoveredInfo cget -announceMessageSent]"
#ixPuts "ptpDiscoveredInfo timeStamp [ptpDiscoveredInfo cget -timeStamp]"
} else {
errorMsg "portFeaturePtp is not valid on $chassId $cardId $portId"
return "FAIL"
}
SEE ALSO
ptpAnnounce, ptpDelayRequest, ptpProperties, ptpFollowUp, ptpDelayResponse, ptpSync, ptpDiscoveredInfo.