PTP 1588 timestamps

1.1k Views Asked by At

In PTP 1588, timestamped packets means the time when first bit of PTP packet leaves the device pin?

Does that mean if that time has to be fed in the packet, PTP stack should know how much time from a given stage in PTP stack till the device pin will be taken by that PTP packet?

so that time can be pre-fed in the packet?

2

There are 2 best solutions below

0
maxy On

Yes I think the IEEE1588 standard does have a definition where exactly the time stamping point is. It is not so important where exactly this point is, because the delay (as long as it is a constant delay) will be compensated.

Usually when you use PTP, you have a hardware timestamping unit (TSU) which has a digital clock that can be adjusted from software. Timestamping can be either be implemented in the PHY (the chip that drives the wire), or in the MAC (the periphery of the CPU that buffers the frames until the software has time to read them).

When a PTP frame is recognized, usually the current timestamp plus the PTP sequence number and message type are stored into a separate memory for the CPU to fetch later. The CPU will then use this information to adjust the clock of the TSU (usually not the same as to the normal system time seen from the OS). The TSU clock is then used by application-programmed hardware, e.g. to timestamp external signals, or to generate precise pulses. It is usually not used directly by the software, because that would add back many of the unpredictable latencies that were avoided by having hardware timestamping.

You cannot just append the timestamp to the frame, because then the CPU cannot get any transmit timestamps. If the software does any kind of timestamping on the CPU, the precision of PTP is usually lost, because of a lot of uncertainties (like interrupt latency, scheduler latency, queues, etc.)

However, PTP frames also contain a correction field which can be adjusted on the fly by hardware components, e.g. a switch may add the forwarding delay directly into the frame, modifying it on the fly, and calculating a new checksum.

0
chux - Reinstate Monica On

OP: In PTP 1588, timestamped packets means the time when first bit of PTP packet leaves the device pin?

... so the it is not just when the "first bit .. leaves", but the beginning of that informative bit: leaving or entering.

Unless otherwise specified in a transport-specific annex to this standard, the message timestamp point for an event message shall be the beginning of the first symbol after the Start of Frame (SOF) delimiter. IEEE 1588-2008 7.3.4.1 Event message timestamp point


OP: Does that mean if that time has to be fed in the packet, PTP stack should know how much time from a given stage in PTP stack till the device pin will be taken by that PTP packet? so that time can be pre-fed in the packet?

That is one course approach.

A certainly more accurate, though complex approach is to inject time info in the later parts of the packet. Any trailing CRC also needs real-time calculation.

1588 does not specify the implementation of how to meets its objective.