Pcornel
Networking · Network & Protocols › TCP, UDP & Transport

TCP Nagle Algorithm

Cheat sheet · https://pcornel.dk/topic.php?topic=326

Back to the Topic

Answer

Nagle's algorithm makes a TCP sender hold back a small segment while earlier data is still unacknowledged, so that an application writing a few bytes at a time does not produce a flood of tiny packets.

Remember

The bad case is write, write, read: the second small write waits for an acknowledgment that the receiver is delaying. It is fixed in the endpoints — send each message in one write, or set TCP_NODELAY on the socket. Nothing on a router, switch or firewall changes it.

First checks

  • tcpdump -ni <if> -ttt host <ip> and tcp port <port> — small segment, pause, acknowledgment, second small segment.
  • strace -f -e trace=write,sendto,sendmsg,setsockopt -p <pid> — how the application writes, and whether it sets TCP_NODELAY.
  • ss -ti dst <ip> — the connection's state.

Commands

tcpdump -ttt
ss -ti

Verify in this order

application writes a message in pieces → first piece sent → second piece held until the first is acknowledged → receiver delays the acknowledgment → fixed pause → request completes

Where it usually breaks

physical/link dependency → local object state → peer/control state → policy → forwarding/adjacency → end-to-end result

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=326

Confirmation

Confirm action

Continue?