BSD sockets setsockopt option to avoid waiting for acknowledge before next send

杀马特。学长 韩版系。学妹 提交于 2019-12-13 08:26:37

问题


I am trying to send some KBytes of data trough Ethernet with a proprietary simple raw TCP protocol.

Standard Windows configuration requires two (2) packets received before returning an acknowledge packet, unless you modify the registry with TcpAckFrequency = 1, in which case one received packet is enough to send back the acknowledgement, or otherwise anyway you will get an ACK after TcpDelAckTicks * 100 = 200 ms by default (this is another registry key). This is a problem if I send the data in chunks of less than 1460 bytes, because each chunk will get an acknowledge after 200 ms, and the sender will wait that before sending the next packet. One solution is to send data in pieces bigger than 1460 bytes, so that two packets will be actually sent and ACK received.

But, what about if I want to send smaller packets? Is there a way to configure the socket with setsockopt for not waiting acknowledgment packets before sending the next packet?

Thank you very much in advance.


回答1:


Turn off the Nagle algorithm at the sender. In C this is the TCP_NODELAY option.



来源:https://stackoverflow.com/questions/16747777/bsd-sockets-setsockopt-option-to-avoid-waiting-for-acknowledge-before-next-send

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!