不清楚内格尔算法
出于好奇,我一直在对 Nagle 算法进行一些研究。 我理解它背后的基本概念(TCP 数据包包含大量开销,特别是在处理小有效负载时),但我不确定我是否理解了实现。
我正在维基百科上阅读这篇文章,但我仍然不清楚它是如何工作的。 让我们以 Telnet 连接为例。 连接已建立,我开始打字。 假设我输入三个字符(例如 cat
)并按回车键。 现在我们讨论的是cat\r\n
,它仍然只有 5 个字节。 我认为只有在我们排队足够的字节才能发送之前,它不会被发送 - 然而,它确实立即发送(从用户的角度来看),因为 cat
是按回车键后立即执行。
我认为我对算法的工作原理有一个根本性的误解,特别是关于“如果管道中仍有未经确认的数据,则排队,否则立即发送”的位。
I've been doing some research on Nagle's algorithm out of idle curiousity. I understand the basic concept behind it (TCP packets contain a significant amount of overhead especially when dealing with small payloads), but I'm not sure I grok the implementation.
I was reading this article on Wikipedia, but I'm still unclear on how it works. Let's take the example of a Telnet connection. The connection is established and I begin typing. Let's say I type three characters (cat
, for example) and hit return. Now we're talking cat\r\n
which is still only 5 bytes. I'd think this would not get sent until we queue up enough bytes to send - and yet, it does get sent immediately (from a user perspective), since cat
is immediately executed upon hitting return.
I think I have a fundamental misunderstanding here on how the algorithm works, specifically regarding the bit where "if there is unconfirmed data still in the pipe, enqueue, else send immediately."
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
仅当服务器已响应您之前的任何消息(或者这是您在此会话中第一次接触它)时,数据才会立即发送。 因此,当服务器变得更加繁忙且响应速度变慢时,为了避免过多的数据包淹没服务器,数据在发送之前会排队到最大数据包大小。
因此,数据是否立即发送只能在先前消息(如果有)的上下文中确定。
The data gets sent immediately only if the server has already responded to any previous messages from you (or this is your first contact with it in this session). So, as the server gets busier and slower to respond, in order to avoid swamping it with too many packets, the data gets queued up to a maximum packet size before getting sent.
So whether data gets sent immediately or not only can be determined in the context of previous messages, if any.
阅读这篇文章,它非常深入并且澄清了很多事情为我。
Read this post, it is quite in-depth and clarified a lot of the things for me.