如何获取套接字的非 ACK-ed TCP 数据量? [英] How to get amount of non-ACK-ed TCP data for the socket?

查看:45
本文介绍了如何获取套接字的非 ACK-ed TCP 数据量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Linux 在手册页 tcp(7) 中描述了 ioctl SIOCOUTQ,它返回套接字缓冲区中未发送的数据量.如果我正确理解内核代码,则所有未确认的数据都被视为未发送".ioctl 至少从 2.4.x 开始可用.

Linux has ioctl SIOCOUTQ described in man-page tcp(7) that returns amount of unsent data in socket buffers. If I understand kernel code right, all the non-ACKed data is counted as "unsent". The ioctl is available at least since 2.4.x.

{Free,Net,Open,*}BSD、Solaris、Windows 是否有类似的东西?

Is there anything alike for {Free,Net,Open,*}BSD, Solaris, Windows?

推荐答案

您可能需要(至少)两种不同的信息:尚未发送的数据量和已发送的数据量已发送但未确认.

There are (at least) two different pieces of information you might want: the amount of data that hasn't been sent yet, and the amount of data that's been sent-but-not-ACK-ed.

在 Linux 上:SIOCOUTQ 被记录为给出未发送的数据量,但实际上给出了(未发送的数据 + 已发送但未确认的数据)的总和.最近的补丁(2016 年 2 月) 使得从 TCP_INFO 结构中的 >tcpi_notsent_bytes 字段.

On Linux: SIOCOUTQ is documented to give the amount of unsent data, but actually gives the sum of (unsent data + sent-but-not-ACK-ed data). A recent patch (Feb 2016) made it possible to get the actual unsent data from the tcpi_notsent_bytes field in the TCP_INFO struct.

在 macOS 和 iOS 上:getsockopt(fd, SOL_SOCKET, SO_NWRITE, ...) 就像 SIOCOUTQ:它被记录为提供未发送的数据量,但是实际上给出了(未发送的数据 + 已发送但未确认的数据)的总和.我不知道有什么方法可以获得更细粒度的信息.

On macOS and iOS: getsockopt(fd, SOL_SOCKET, SO_NWRITE, ...) is just like SIOCOUTQ: it's documented to give the amount of unsent data, but actually gives the sum of (unsent data + sent-but-not-ACK-ed data). I don't know any way to get more fine-grained information.

在 Windows 上:GetPerTcpConnectionEStats 使用 TcpConnectionEstatsSendBuff 选项为您提供未发送的数据和已发送但未确认的数据 作为两个独立的数字.

On Windows: GetPerTcpConnectionEStats with the TcpConnectionEstatsSendBuff option gives you both unsent data and sent-but-not-ACK-ed data as two separate numbers.

我不知道如何在其他操作系统上获取此信息.

I don't know how to get this information on other operating systems.

这篇关于如何获取套接字的非 ACK-ed TCP 数据量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆