Steve Lorimer
Steve Lorimer

Reputation: 28659

SO_TIMESTAMP for tsc not timeval?

As can be seen in the socket man page, one can use SO_TIMESTAMP with setsockopt to measure the amount of time it takes the Linux kernel to hand a received network packet off to user space.

There is a good description of this functionality here: Measuring latency in the Linux network stack between kernel and user space.

Is there any way to get a reading of the tsc rather than a timeval at the time the kernel received a packet?

Upvotes: 3

Views: 1292

Answers (1)

tc.
tc.

Reputation: 33592

No.

  • It's platform-specific.
  • The TSC can change frequency on some (P4-era) processors and has historically not been synchronized between cores (some modern CPUs synchronize it between cores in the same package).
  • Ideally you'd want the packet to be timestamped by the network card anyway; PTP typically requires this to achieve its target accuracy.

The most you can reasonably ask for is a struct timespec in the CLOCK_MONOTONIC timebase. I don't think it exists, but it would not be too difficult to add.

Upvotes: 1

Related Questions