3

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?

4

1 に答える 1

1

いいえ。

  • プラットフォーム固有です。
  • TSCは、一部の(P4時代の)プロセッサで周波数を変更でき、これまでコア間で同期されていませんでした(一部の最新のCPUは、同じパッケージ内のコア間で周波数を同期します)。
  • とにかく、パケットにネットワークカードのタイムスタンプを付けるのが理想的です。PTPは通常、目標精度を達成するためにこれを必要とします。

あなたが合理的に求めることができる最も多くはタイムベースstruct timespecにあります。CLOCK_MONOTONIC存在するとは思いませんが、追加するのはそれほど難しくありません。

于 2013-03-07T04:47:32.593 に答える