Search code examples
tcpiocp

How to identify pushback under Win IOCP?


How can I identify TCP pushback when using IOCP? I.e. how can I find out that the receiver is not receiving, that tx/rx buffers on both sides of connection are full and that the sender should cease to send more data?


Solution

  • With any async TCP send operation the way to determine the rate that the peer is receiving data is to monitor the rate of send completions on the sender.

    I've written about this in depth here. In summary, when the receiver's buffers fill and TCP flow control is in operation and the TCP window is reduced the sender cannot send which causes the sender's TCP buffers to fill. This then means that async send requests can not complete. If you track the number of outstanding send requests that are pending you can spot this situation and throttle the sender.