【发布时间】:2021-06-07 01:48:09
【问题描述】:
在我的应用程序中,我通过 UDP 套接字以大约 58MB/秒的速率发送数据。大多数情况下它工作正常,但有时 sendto 持续时间过长,时间分组在 0.1、0.2、0.3 秒左右(见下图)。 我的系统是内核为 2.6.32-24-server 的 linux 系统,每次发送的缓冲区长度为 45000 字节。您知道为什么有时会发生这种情况吗?
【问题讨论】:
-
你用 RT 内核试过了吗?
在我的应用程序中,我通过 UDP 套接字以大约 58MB/秒的速率发送数据。大多数情况下它工作正常,但有时 sendto 持续时间过长,时间分组在 0.1、0.2、0.3 秒左右(见下图)。 我的系统是内核为 2.6.32-24-server 的 linux 系统,每次发送的缓冲区长度为 45000 字节。您知道为什么有时会发生这种情况吗?
【问题讨论】:
从发送(2):
When the message does not fit into the send buffer of the socket,
send() normally blocks, unless the socket has been placed in nonblock‐
ing I/O mode. In nonblocking mode it would fail with the error EAGAIN
or EWOULDBLOCK in this case. The select(2) call may be used to deter‐
mine when it is possible to send more data.
除此之外,内核可能同时在做其他事情。如果是这种情况,按照 yi_H 的建议,使用 RT 内核可能会有所帮助。
【讨论】: