- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
Linux 内核提供了两个套接字选项来检索传入网络数据包的软件时间戳:SO_TIMESTAMP
和 SO_TIMESTAMPING
与 SOF_TIMESTAMPING_RX_SOFTWARE | SOF_TIMESTAMPING_SOFTWARE
标志。 documentation将它们描述如下:
SO_TIMESTAMP
Generates a timestamp for each incoming packet in (not necessarilymonotonic) system time.
SO_TIMESTAMPING
Request rx timestamps when data enters the kernel. These timestampsare generated just after a device driver hands a packet to thekernel receive stack.
Note that if the SO_TIMESTAMP or SO_TIMESTAMPNS option is enabledtogether with SO_TIMESTAMPING using SOF_TIMESTAMPING_SOFTWARE, a falsesoftware timestamp will be generated in the recvmsg() call and passedin ts[0] when a real software timestamp is missing.
clock_gettime
相同的时间源吗?与
CLOCK_REALTIME
提供?
最佳答案
你的猜测是正确的,它们不一样,它们之间的主要区别在于它们的工作方式或它们提供的结果,我发现自己在一些 drivers
的实现过程中处理了这个问题。 :SO_TIMESTAMP:
This enables timestamps of datagrams on the reception path, if exist any destination socket is unknown beforehand which means that the same options are true for all the packets, this also generates timestamps per each packet received, and the result is a struct timeval.
SO_TIMESTAMPNS:
Same that
SO_TIMESTAMP
but returns the timestamp as struct timespec.
SO_TIMESTAMPING:
This option supports multiple types of timestamps requests and as a result, thissocket option takes a bitmap of flags, not a boolean. Also, this option generates timestamps on reception, transmission, or both at the same time and of course, supports different timestamp resources.
struct timespec represents a simple calendar time, or an elapsed time, with sub-second resolution (nsec resolution).
struct timeval. struct timeval is an older type for representing a simple calendar time, or an elapsed time, with sub-second resolution. It is almost the same as struct timespec, but provides only microsecond resolution.
系统时间代表计算机系统的时间流逝概念。根据上下文,可能是 CPU 完成一项操作所用的时间或挂钟时间,我们通常称之为
real-time
.在这种情况下不一定是相同的
asnwer将帮助您了解
monotonic
之间的区别和
system-time
.
关于linux - SO_TIMESTAMP 和 SO_TIMESTAMPING 软件时间戳的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65363515/
Linux 内核提供了两个套接字选项来检索传入网络数据包的软件时间戳:SO_TIMESTAMP和 SO_TIMESTAMPING与 SOF_TIMESTAMPING_RX_SOFTWARE | SOF
Linux 内核提供了几种方法来获取接收的(SO_TIMESTAMP、SO_TIMESTAMPNS、SO_TIMESTAMPING)或发送的(SO_TIMESTAMPING)数据包的时间戳。 内核文档
我每 0.1 秒从 TCP 服务器(机器人发送其状态)接收消息流。我不能保证我调用 recvmsg 每 0.1 秒,所以我想在这些收到的消息上有一个时间戳,这样当我 recvmsg我知道我是否刚刚收到
在socket man page中可以看出,可以使用 SO_TIMESTAMP 和 setsockopt 来测量 Linux 内核将接收到的网络数据包传递给用户空间所花费的时间。 此处对此功能有很好的
我是一名优秀的程序员,十分优秀!