I find out it can be delay 200ms on WinSock send call
From MSDN: http://support.microsoft.com/kb/214397/en
Nagle Algorithm: http://en.wikipedia.org/wiki/Nagle's_algorithm
Issue summary:
If send small msg(< MTU) with SO_SNDBUF "0" option repetedly, send function block 200ms.
My Question: Why first send message delay 200ms?
Because TCP is idle before first send call, I think first message must be sent immediately.
But Test result is not desired.
First message also delayed 200ms, why?
Thank you for answers.
Add some details:
Naggle algorithm work for small message like following:
1. if wire is idle, send it immediately.
2. if formal message's ACK is not received, wait until ACK & send
3. Window's TCP ack delay mechanism send ack after 200ms.
So, My expect is first message sends immediately and second message wait first message's ack for 200ms and so on.
Is this wrong?
Usually TCP keeps the data in the send buffer until it is acked by peer. In your case there isn't the send buffer (because of SO_SNDBUF=0). So TCP block the sender for keeping the data for possible retransmissions. TCP stack of the peer use the "Delayed ack" routine, and send acknowledge after 200ms delay (or until 2 packets with data is received without acking).
So the sender will be blocked until all data is acknowledged by peer. It may take more than 200ms if RTT of the network is long, or if packet lose occurs.
The whole point of the delay is to see if there's more data coming that could be added to the same message. There's no reason why the first message should be an exception to this rule.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With