Time Stamp Features

Time-Stamping and Time Synchronization

Platform
Intel® PAC
Napatech SmartNIC
Content Type
User Guide

In this section

This section describes a number of time stamp features supported by the SmartNICs.

The time stamp clock

A SmartNIC with Napatech Link™ Capture Software maintains a time stamp clock, which is used for precise time-stamping of frames received on the Ethernet ports of the SmartNIC. Received frames are time-stamped either when the first byte is received or when the last byte is received depending on the setting of the TimestampMethod configuration parameter in the ntservice.ini file (see Specifying the Time Stamp Method). This setting also determines if the first or the last byte of a frame is transmitted according to the time stamp in the packet descriptor.
Note: Start-of-frame time-stamping does not apply to NT40E3-4-PTP SmartNICs running on the capture/replay image, to NT40A01 SmartNICs running on the 4 × 10/1 Gbit/s SLB image nor to the Intel® Programmable Acceleration Card with Intel® Arria® 10 GX FPGA.
Note: Using different settings of TimestampMethod for capturing data and later for transmitting the same data, will result in inaccuracies.

The time stamp clock is also used for time-stamping statistics data blocks transferred to the host memory. This enables the host application to correlate received frame data with statistics information.

The time stamp clock is driven by a local clock oscillator, and the internal resolution is 1 ns. The time stamp clock can either be free-running or be adjusted according to another reference clock.

Time stamps in packet descriptors

The standard packet descriptor, the dynamic packet descriptors and the PCAP packet descriptor contain the time stamp (see DN-1128). The time stamp in the standard packet descriptor can be retrieved using the NT_NET_GET_PKT_TIMESTAMP macro (see DN-0449).

Injection of time stamps

A time stamp can be injected into a frame to be transmitted at a specified offset on NT200A02, NT100A01 and NT50B01 SmartNICs running on a test and measurement image.

The injected data consists of the 64-bit time stamp prepended a 2-byte correction value to make the complete 10-byte checksum neutral. The original 10 bytes of frame data must be set to all zeros by the application before the injection, and they must belong to the same layer (fully contained in one checksum domain). The time stamp injection offset must be 2-byte aligned with the start of the data included in the checksum to be recalculated.

The time stamp injection can be controlled per packet by a control bit in the dynamic packet descriptors. This is illustrated in the net/timestamp_inject code example (see DN-0449). Time stamp injection can also be applied globally by using TimestampInjectAlways in the ntservice.ini file (see Configuring Global Time Stamp Injection).

The value of the time stamp can be the time when the first byte of the frame is put on the wire, or the time when the last byte is put on the wire, depending on the setting of TimestampMethod in the ntservice.ini file (see Specifying the Time Stamp Method).

The time stamp injection offset is determined by the setting of TimestampInjectDynamicOffset and TimestampInjectStaticOffset in the ntservice.ini file (see Setting the Time Stamp Injection Offset). TimestampInjectDynamicOffset can be set to the start of the frame, the end of the frame, the start of the layer 3 header or the start of the layer 4 header. The actual offset is calculated from the location of TimestampInjectDynamicOffset by adding the value of TimestampInjectStaticOffset. If, for instance, TimestampInjectDynamicOffset is set to the end of the frame and TimestampInjectStaticOffset is set to -20, the time stamp is injected 20 bytes before the end of the frame. The combination of the two offsets must result in a location inside the current frame, and there must be enough space for both the prepended 2-byte correction value, the 8-byte time stamp and a 4-byte FCS, that is the resulting offset must be between the start of the frame and 14 bytes before the end of the frame. Otherwise some of the time stamp is overwritten by the FCS, and the checksum will be wrong.

Application-triggered SmartNIC clock sampling

It is possible to execute clock sampling from a software application. As illustrated in the figure below, this can be achieved in an application by writing an event using NTAPI NT_EventWrite with the NT_EVENT_SAMPLE_TIMESTAMP parameter. This results in a special-register reading by the SmartNIC driver which triggers clock sampling as if an external signal is received. Clock samples i.e. time stamp values can be read using NTAPI NT_InfoRead. The NtInfoTimeSyncSample_s structure contains the 64-bit time stamp value. The NtInfoTimeSyncSample_s structure also contains two CPU time stamp counter (TSC) values which are retrieved before and after clock sampling. These two TSC values can be used to get the reference time of sampled time stamps. See DN-0449 for further information in detail regarding NTAPI.

Clock sampling can be achieved in an application by writing an event using NTAPI NT_EventWrite. This results in a special register read by the SmartNIC driver which triggers clock sampling as if an external signal was received. Clock samples i.e. time stamp values can be read using NTAPI NT_InfoRead. The NtInfoTimeSyncSample_s structure contains the 64-bit time stamp value.