SO_RCVBUF怎么会比TCP接收窗口小呢? (Windows XP)

发布于 2024-08-28 19:30:51 字数 159 浏览 8 评论 0原文

我有一个在 Windows XP 上使用 TCP 的应用程序。当我使用 SO_RCVBUF 选项调用 getsockopt 时,它报告 8192 字节。然而,Wireshark 显示该应用程序宣传的接收缓冲区为 64K。这怎么可能?要有64K的接收窗口,难道不需要64K的缓冲区吗?有两个不同的缓冲区吗?

I have an application using TCP on Windows XP. When I call getsockopt with the SO_RCVBUF option, it reports 8192 bytes. However, Wireshark shows the app advertising a receive buffer of 64K. How is this possible? To have a 64K receive window, doesn't it need a 64K buffer? Are there two different buffers?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

感性不性感 2024-09-04 19:30:51

我正在研究这个问题,我认为 SO_RCVBUF 和 TCP 窗口不一定是同一件事。

如果您查看 http://msdn.microsoft.com/en-us/magazine /cc302334.aspx 部分“Windows NT 和 Windows 2000 套接字体系结构” 您会看到 Windows 内核套接字驱动程序 Afd.sys 位于传输协议之上。它有自己的套接字 SND/RCV 缓冲区,这些缓冲区是您在套接字选项SO_SNDBUF中设置的>SO_RCVBUF 或通过 Afd 注册表项。
然后 TCP 传输协议有自己的 TCP 窗口缓冲区,这是每个人都熟悉的,并且可以在注册表 Tcpip 参数中设置,或者自动确定考虑到 SO_RCVBUF ,我认为是混乱从何而来。 http://msdn.microsoft.com/en-us/library/ms819736.aspx

因此,我相信数据会根据需要从传输层读取到 afd.sys 套接字缓冲区 SO_RCVBUF 中,等待应用程序读出。您可能希望 SO_RCVBUF 至少与您希望一次读取的数据一样大。

但是我不知道 SO_RCVBUF 和 TCP 窗口将如何相互作用。 TCP 是否会等待 ACK 数据,直至将其读入 SO_RCVBUF 中?我不清楚。

I'm looking into this, and I don't think SO_RCVBUF and the TCP Window are necessarily the same thing.

If you look at http://msdn.microsoft.com/en-us/magazine/cc302334.aspx section "The Windows NT and Windows 2000 Sockets Architecture" you see that the Windows Kernel Socket driver Afd.sys sits on top of the Transport protocols. It has its own socket SND/RCV buffers which are what you set in the socket options SO_SNDBUF, SO_RCVBUF or via Afd registry keys.
Then the TCP transport protocol has its own TCP Window Buffer which is the one everyone is familiar with and is set either in the registry Tcpip parameters or is determined automatically bearing in mind among other things SO_RCVBUF which I think is where the confusion comes from. http://msdn.microsoft.com/en-us/library/ms819736.aspx

So I believe data is read from the transport layer into the afd.sys socket buffer SO_RCVBUF as needed where it waits to be read out by the application. You would want the SO_RCVBUF to be at least as large as the data you hope to read at once.

However I don't know how the SO_RCVBUF and TCP Window will interplay. Will TCP wait to ACK data until it is read into SO_RCVBUF? That is unclear to me.

不甘平庸 2024-09-04 19:30:51

您自己设置窗口大小吗?确保在 connect(2)accept(2) 之前执行此操作。但 Windows 在这方面可能比较特殊,请检查 msdn

Are you setting the window size yourself? Make sure you do that before connect(2) or accept(2). But again windows might be special in this regard, check the msdn.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文