Pcornel
Browse topics
Options
Recent
Favorites
Networking · Technical reference

TCP Nagle Algorithm

Direct 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.

When to use this

Use it when a request–response application has a fixed delay of 40 to 200 ms per request that no network change removes.

First 30 seconds

1. tcpdump -ttt — is each request sent as two small segments with a pause between?

2. Pause about 40 or 200 ms, constant → Nagle with delayed acknowledgment.

3. strace the sender: several writes per message? TCP_NODELAY set?

4. Combine the writes or set the option.

5. Fast on localhost, slow over the network → the same cause.

Operational verification

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

Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
Protocol standard + deployed implementation
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

PlatformProtocol standard
Key commandtcpdump -ni eth0 -ttt host 192.0.2.10 and tcp port 8080
Scope / prerequisiteUse it when a request–response application has a fixed delay of 40 to 200 ms per request that no network change removes.
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

2 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 Verification workflow Verify boundary
tcpdump -ni eth0 -ttt host 192.0.2.10 and tcp port 8080
strace -f -e trace=write,sendto,sendmsg,setsockopt -p <pid>
ss -ti dst 192.0.2.10

tcpdump -ttt shows the timing between packets: look for a small data segment, a pause of about 40 or 200 ms, an acknowledgment, and then a second small segment immediately after. strace on the sending process shows how the application writes — one call per message or several — and whether it sets TCP_NODELAY on its sockets. ss -ti shows the connection's state on a Linux host.

In Wireshark, the pattern is two small segments from the same side separated by the peer's acknowledgment, with tcp.time_delta near 40 ms or 200 ms before that acknowledgment.

Known-good: a request leaves in one segment — or in several without a pause between them — and the reply follows after the server's processing time.

Step 2 Failure isolation workflow Narrow the fault
  • Each request carries a fixed delay of about 40 or 200 ms. Nagle with delayed acknowledgment; set TCP_NODELAY or combine the writes.
  • The application sends a message in several small segments. It writes piecemeal; buffer the output.
  • Fast on the same host, slow across the network. Over the loopback interface acknowledgments are immediate; the pattern shows only with a real peer.
  • The delay appeared after a library or framework upgrade. The new version writes headers and body separately, or no longer sets the socket option.
  • Large transfers are unaffected. Full segments are never held.
  • Disabling the algorithm multiplied the packet count. The application writes in very small pieces; fix the writes as well.
  • A network change is requested to cure it. Nothing on the network can; the evidence is the fixed, load-independent delay with no loss.
Evidence references

Evidence · 1 on this Topic

Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.

observation · 1
Command lookup Jump straight to Cisco syntax
Key points

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.

Key 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.
ReferenceWhat it is1 section · depth on demand

Mental model

Nagle's algorithm is a rule in the TCP sender: while earlier data is still unacknowledged, do not send a new small segment — wait until the acknowledgment arrives or until enough data has collected to fill a full segment. It prevents an application that writes a few bytes at a time from flooding the network with tiny packets.

ReferenceWhy it matters1 section · depth on demand

Why it matters operationally

The algorithm is on by default and usually harmless. Its well-known side effect appears with applications that send a request in two small writes and then wait for the answer: the second piece is held back until the first is acknowledged, and the receiver delays that acknowledgment. The outcome is a fixed pause of 40 to 200 milliseconds per request — a performance fault that lives entirely in the endpoints and is regularly blamed on the network.

ReferenceHow it works1 section · depth on demand

How it works

The rule. When the application hands TCP some data:

  • if it fills a whole segment, send it;
  • if nothing is currently unacknowledged, send it, however small;
  • otherwise — a small piece, with earlier data still unacknowledged — hold it until an acknowledgment arrives or more data makes up a full segment.

For a terminal session, where each keystroke is one byte, this merges keystrokes into fewer packets on a slow line and costs nothing on a fast one.

The bad case: write, write, read. An application sends a header with one write and the body with a second, then waits for the reply.

1. The first write goes out at once: nothing was outstanding.

2. The second write is small and the first is unacknowledged, so it is held.

3. The receiver has got half a request. It has nothing to answer yet, and delays its acknowledgment in case more data arrives.

4. Both sides wait until the receiver's delayed-acknowledgment timer expires — 40 ms on Linux, up to 200 ms on Windows.

5. The acknowledgment arrives, the second piece is released, the request completes.

Neither mechanism is at fault alone; together they add a fixed delay to every request.

Remedies.

  • In the application: send each message with a single write, or use a buffered or gathered write. This is the proper fix.
  • On the socket: set TCP_NODELAY, which turns the algorithm off so small segments go out immediately. Interactive and request–response software — SSH, databases, web servers, messaging — normally sets it.
  • Not on the network: no router, switch or firewall setting changes this.

Turning the algorithm off for an application that writes byte by byte brings back the many tiny packets it was designed to prevent; the two fixes go together.

ReferenceImportant terms & boundaries2 sections · depth on demand

In depth

Nagle's algorithm and small writes

Nagle's algorithm keeps a sender from flooding the network with tiny segments. RFC 9293 describes the rule. While earlier data is still unacknowledged, the sender doesn't send a new segment smaller than a full one. Instead it collects small writes until the ACK arrives or a full segment can be built. In the RFC's sending rules, a short segment goes out only when SND.NXT equals SND.UNA, which means nothing is outstanding. The algorithm is part of the sender-side silly window syndrome avoidance that RFC 9293 requires.

When Nagle helps and when it hurts

TrafficEffect
Interactive typing over slow links (Telnet, SSH)Fewer packets; this was the original purpose
Bulk transfersNo effect; segments are full anyway
Request-response with small writes (RPC, some databases, APIs)The second small write waits for the ACK, which the receiver delays: added latency
Applications writing a header and body separatelyOne round trip of added delay per message

The Nagle and delayed ACK interaction

1. The client writes a small request header; it goes out at once (nothing outstanding).

2. The client writes the body; Nagle holds it, because the header is unacknowledged.

3. The server delays its ACK, waiting for more data or a reply.

4. After the delayed-ACK timer (for example 40 or 200 ms), the server ACKs.

5. The client sends the body, and the exchange continues, one timer later than necessary.

Turning it off

PlatformSetting
Sockets APIsetsockopt(TCP_NODELAY) per socket
Many frameworksA "no delay" option, often on by default for HTTP clients
Cisco IOS XE (for TCP sessions to the device)service nagle enables it; it is off by default
host$ strace -f -e trace=setsockopt -p $(pgrep -n myapp) 2>&1 | grep TCP_NODELAY
host$ tshark -r rpc.pcap -Y "tcp.stream==4 && tcp.len>0" -T fields -e frame.time_delta_displayed -e ip.src -e tcp.len | head -4
0.000000  10.110.0.64  92
0.041210  10.110.0.64  511
0.000340  10.30.0.15   1210
R1# show running-config | include service nagle

The 41 ms gap before the client's second, larger write is the signature of Nagle waiting for a delayed ACK. Combining the writes or setting TCP_NODELAY removes it.

Documented example, not captured output.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

How it works

Nagle's algorithm holds small segments on the sender while earlier data is unacknowledged, combining them into fewer packets. Interactive or chatty protocols disable it with TCP_NODELAY; leaving it on with delayed ACK on the other side can cause ~40–200 ms stalls.

Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor docProtocol standard + deployed implementation RFC 9293

Authoritative/upstream documentation reviewed for bounded claims in Network & Protocols → TCP Nagle Algorithm. Documentation verification only; this is not observed lab or production Evidence.

Basis: https://www.rfc-editor.org/rfc/rfc9293.html · confidence 94%
Terminology layer

Terms & aliases

Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.

Aliases that resolve here
nagle tcptcp nodelay
Confirmation

Confirm action

Continue?