[PATCH v6 1/1] pcapng: add user-supplied timestamp support
Stephen Hemminger
stephen at networkplumber.org
Mon Jun 29 18:50:55 CEST 2026
On Mon, 29 Jun 2026 05:37:33 -0400
Dawid Wesierski <dawid.wesierski at intel.com> wrote:
> Add a timestamp parameter to rte_pcapng_copy() so that callers with a
> hardware PTP or pre-captured timestamp can inject an exact epoch-ns value
> directly into the packet record.
>
> Timestamp handling:
> - ts != 0: caller-supplied nanoseconds since the Unix epoch, stored as-is.
> - ts == 0: TSC captured at copy time with bit 63 set as a sentinel.
> rte_pcapng_write_packets() detects the sentinel and converts the TSC to
> epoch ns using the file's calibrated clock. The TSC will not reach
> bit 63 for centuries, and epoch-ns values stay below bit 63 until 2554,
> so the bit is safe to use as a disambiguation flag.
>
> Adding the parameter changes the ABI, so rte_pcapng_copy() is versioned.
>
> rte_pcapng_tsc_to_ns() is added as a new experimental helper. It exposes the
> same calibrated, drift-compensated, divide-free TSC-to-epoch-ns conversion
> used internally by rte_pcapng_write_packets(), allows callers to convert
> a TSC captured at packet arrival time before passing it to rte_pcapng_copy().
>
> Signed-off-by: Marek Kasiewicz <marek.kasiewicz at intel.com>
> Signed-off-by: Dawid Wesierski <dawid.wesierski at intel.com>
> ---
Looks good, I would like to make some follow on patches to replace
the tsc_to_ns routines with something in EAL since it is generally useful
to get time in nanoseconds.
More information about the dev
mailing list