Skip to content

TEST-XSTAMP-JITTER-001: Verify PHC-QPC Cross-Timestamp Correlation Jitter < 2µs σ #321

Description

@zarfld

Requirement

Derived from #48 (REQ-F-IOCTL-XSTAMP-001) performance requirements:

Metric Target
Correlation Jitter <2µs σ (standard deviation across 1000 samples)
PHC-QPC Capture Skew <5µs

Background

The cross-timestamp IOCTL returns a (phc_time_ns, system_qpc) pair captured at
approximately the same instant. The "correlation jitter" measures how consistently
the offset phc_time_ns - qpc_equivalent_ns is computed across 1000 samples — low
jitter means the capture window is stable and the correlation can be trusted.

qpc_equivalent_ns = (system_qpc - qpc_ref) * 1e9 / qpc_frequency

Method

  1. Collect 1000 (phc_ns, qpc_ticks) pairs via 1000 IOCTL_AVB_PHC_CROSSTIMESTAMP calls
  2. Convert each QPC tick to nanoseconds using qpc_frequency
  3. Compute offset for each sample: offset_i = phc_ns_i - qpc_ns_i
  4. Compute mean offset and standard deviation σ
  5. Assert σ < 2000 ns (2µs)

The offset mean represents the PHC-to-wall-clock delta; the σ represents jitter in the
capture window. A large σ means the two reads (PHC and QPC) are taken far apart in time,
making correlation unreliable.

Test Cases

TC-XSTAMP-JIT-001a: Correlation jitter σ < 2µs over 1000 samples

Preconditions: Driver loaded, handle open, PHC running at nominal rate.

Steps:

  1. Allocate offset_ns[1000]
  2. For i = 0..999:
    a. Call IOCTL_AVB_PHC_CROSSTIMESTAMP(phc_ns, qpc_ticks, qpc_freq)
    b. qpc_ns = qpc_ticks * 1e9 / qpc_freq
    c. offset_ns[i] = phc_ns - qpc_ns
  3. Compute mean = average(offset_ns[])
  4. Compute sigma = sqrt(sum((offset_ns[i] - mean)^2) / 1000)
  5. Report sigma in nanoseconds

Acceptance Criterion: sigma < 2000 ns (2µs) per REQ-F-IOCTL-XSTAMP-001


TC-XSTAMP-JIT-001b: PHC-QPC capture bracket < 5µs (estimated)

The driver samples PHC and QPC sequentially (no hardware-atomic path).
We estimate the capture window by bracketing the entire IOCTL with QPC
and comparing to the returned phc_time_ns delta over two consecutive calls.

Steps:

  1. QPC_before → IOCTL call 1 → QPC_after
  2. Record ioctl_window_ns = (QPC_after - QPC_before) * 1e9 / qpc_freq
  3. Repeat 100 times, report median

Acceptance Criterion: Median IOCTL window < 5µs (proxy for PHC-QPC skew)

Note: The current AVB_CROSS_TIMESTAMP_REQUEST struct does NOT include a
CaptureLatencyNs field as specified in REQ-F-IOCTL-XSTAMP-001 §Output Structure.
This test uses IOCTL window as a proxy. A driver enhancement to add CaptureLatencyNs
to the struct is needed to directly verify this criterion. This test is expected to PASS
as a proxy; the missing field is a separate driver gap.

Acceptance Criteria Summary

  • ✅ PHC-QPC correlation offset σ < 2µs over 1000 samples
  • ✅ Median IOCTL call window < 5µs (proxy for PHC-QPC capture skew)
  • ✅ All 1000 IOCTL_AVB_PHC_CROSSTIMESTAMP calls return valid == 1
  • ⚠️ CaptureLatencyNs field verification not possible without driver struct update (REQ-F-IOCTL-XSTAMP-001: Cross-Timestamp Query (PHC + System Time) #48 gap)

Implementation

  • New test file: tests/integration/ptp/ptp_ioctl_latency_test.c

Traceability

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions