设置 TCP_QUICKACK 和 TCP_NODELAY
如果在之前设置了 TCP_NODELAY 的情况下对套接字上的每个调用都设置了 TCP_QUICKACK 设置,那么 QUICKACK 选项是否会覆盖 NODELAY 调用?
连接时:
int i = 1;
setsockopt( iSock, IPPROTO_TCP, TCP_NODELAY, (void *)&i, sizeof(i));
每次写入时:
int i = 1;
setsockopt( iSock, IPPROTO_TCP, TCP_QUICKACK, (void *)&i, sizeof(i));
对 TCP_QUICKACK 的调用会使之前对 TCP_NODELAY 的调用无效吗?
If you set the TCP_QUICKACK setting on every call on the socket, having previously set TCP_NODELAY, will the QUICKACK option overwrite the NODELAY call?
On connect:
int i = 1;
setsockopt( iSock, IPPROTO_TCP, TCP_NODELAY, (void *)&i, sizeof(i));
On each write:
int i = 1;
setsockopt( iSock, IPPROTO_TCP, TCP_QUICKACK, (void *)&i, sizeof(i));
Will the call to TCP_QUICKACK null the previous call to TCP_NODELAY?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这两个选项之间没有直接关系,它们只是用于不同的目的。
TCP_NODELAY 旨在禁用/启用段缓冲,以便数据可以尽快发送到对等点,因此这通常用于提高网络利用率。 TCP_QUICKACK 用于在某些协议级别交换下尽早发送确认而不是延迟,并且它不是稳定/永久的,后续的 TCP 事务(可能在幕后发生)可以忽略此选项,具体取决于实际的协议级别处理或用户设置和堆栈行为之间的任何实际分歧。
注意
TCP_NODELAY
是可移植的,而TCP_QUICKACK
则不可移植(仅适用于 Linux 2.4.4+)。There's no direct relationship between those two options, they are just for different purposes.
TCP_NODELAY is intended to disable/enable segment buffering so data can be sent out to peer as quickly as possible, so this is typically used to improve network utilisation. TCP_QUICKACK is used to send out acknowledgements as early as possible than delayed under some protocol level exchanging, and it's not stable/permanent, subsequent TCP transactions (which may happen under the hood) can disregard this option depending on actual protocol level processing or any actual disagreements between user setting and stack behaviour.
NOTE
TCP_NODELAY
is portable whileTCP_QUICKACK
is not (only works under Linux 2.4.4+).使用 TCP_QUICKACK,而不是 TCP_NODELAY
https://news.ycombinator.com/item?id=10608356
更新:
https://brooker.co.za/blog/2024/05/ 09/nagle.html
Use TCP_QUICKACK, not TCP_NODELAY
https://news.ycombinator.com/item?id=10608356
UPDATE:
https://brooker.co.za/blog/2024/05/09/nagle.html
简短回答
详细信息
Nagle 算法
延迟确认
Nagle 算法和延迟 ACK 在 TCP/IP 网络中不能很好地协同工作
如果可以的话,延迟 ACK 会尝试为每个段发送更多数据。但 Nagle 算法的一部分依赖于 ACK 来发送数据。
Nagle 的算法和延迟的 ACK 一起产生了一个问题,因为延迟的 ACK 正在等待发送 ACK,而 Nagle 的算法正在等待接收 ACK
示例
如何解决 Nagle 算法和延迟 ACK 引起的问题
更多详情请参考此
Short answer
Details
Nagle's algorithm
Delayed ACK
Nagle's Algorithm and Delayed ACK Do Not Play Well Together in a TCP/IP Network
Delayed ACK tries to send more data per segment if it can. But part of Nagle's algorithm depends on an ACK to send data.
Nagle's algorithm and Delayed ACKs together create a problem because Delayed ACKs are waiting around to send the ACK while Nagle's is waiting around to receive the ACK
Sample
How can I resolve the issues caused by Nagle's algorithm and Delayed ACKs
For more details please refer to this
TCP_QUICKACK
和TCP_NODELAY
影响 TCP 中的不同操作。tcp(7)
手册页描述了 TCP 的哪些套接字选项相互干扰,例如
TCP_CORK
和TCP_NODELAY
。TCP_QUICKACK
andTCP_NODELAY
affect different operations in TCP. Thetcp(7)
man page describes which socket options for TCP interfere with each other, e.g.TCP_CORK
andTCP_NODELAY
.