Friday 7 July 2017

[Network] Nagle Algorithm (Related with TCP_NODELAY)

Nagle

If possible, do not send it a few times, but send it a lot at once.(Effective TCP)


1. Nagle algorithm network communication

It sends packet when receive ACK. Before receiving ACK, a socket stacks data in output buffer, and makes it as packet and send all data when receive ACK.
Therefore, it reduces network traffic. It is default TCP socket algorithm.

2. Non Nagle network communication (TCP_NODELAY)

It sends packet when data comes in output buffer regardless of ACK. It support fast response. But it is inefficient. if you set TCP_NODELAY option as true, the TCP socket do not apply Nagle algorithm.