Skip to content

score/time_slave: Take gPTP timestamps from a free-running clock only #257

Description

@lavrovvalera

Important

Link the implementing PR to this issue by including Closes #257 in the PR description or commit message.

What

Take every gPTP timestamp of the TimeSlave from a free-running clock: hardware timestamps where the network interface supports them, otherwise software timestamps from a free-running monotonic clock, selected once per interface. Never use CLOCK_REALTIME and never a timestamp of 0.

Today the QNX raw socket shim falls back per message to the PHC time at the moment of the read (PTP_GET_TIME) and then to clock_gettime(CLOCK_REALTIME) (qnx_raw_recv, qnx_raw_send). CLOCK_REALTIME is the System Clock, which score::time keeps aligned to the Absolute Time (feature glossary "System Clock"), so it can jump between two timestamps. A jump between the timestamps of one measurement falsifies the peer delay, the rate ratio and the time leap evaluation, and one exchange can combine timestamps of different clocks. On Linux, a frame without a hardware timestamp (e.g. a transmit timestamp not delivered within 50 ms) is returned with the timestamp 0, which GptpEngine::HandlePacket and PeerDelayMeasurer use as a valid value.

This contradicts feat_req__time__veh_free_run_ts: "The score::time feature shall take the timestamps of time synchronization and peer delay messages with a free-running local clock that is not adjusted by the time synchronization."

Acceptance Criteria

  • The TimeSlave selects the timestamp source once per network interface: hardware timestamps if supported, otherwise software timestamps from a free-running monotonic clock.
  • No gPTP timestamp is taken from CLOCK_REALTIME, on QNX and on Linux.
  • All timestamps of one Sync/Follow_Up evaluation and of one peer delay measurement come from the same clock.
  • A missing timestamp is not used as 0; the affected message or measurement is discarded.
  • Unit tests cover the source selection and the handling of a missing timestamp on QNX and on Linux.
  • The detailed design of score/time_slave describes the timestamp sources.

How (optional)

  • QNX: e.g. ClockCycles() (already the base of the high-resolution steady clock) or CLOCK_MONOTONIC, if it is not rate-adjusted on the target.
  • Linux: kernel software timestamps (SOF_TIMESTAMPING_*_SOFTWARE) are based on CLOCK_REALTIME and therefore not suitable as the software source.

References (optional)

  • feat_req__time__veh_free_run_ts (eclipse-score/score, docs/features/time/requirements/index.rst)
  • score/time_slave/src/gptp/platform/qnx/qnx_raw_shim.cpp (qnx_raw_recv, qnx_raw_send)
  • score/time_slave/src/gptp/platform/linux/raw_socket.cpp, score/time_slave/src/gptp/gptp_engine.cpp, score/time_slave/src/gptp/details/pdelay_measurer.cpp

Metadata

Metadata

Labels

No labels
No labels

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions