The TCPIP nagle algorithm can slow down network

19 September 2003 by Snakefoot | Comment » | Trackback Off
When a file is sent over the network the file is chopped up in small packets, which then are sent. The TCPIP protocol is a secure protocol and demands that each packet is acknowledged by the receiver by sending an ACK packet. The ACK packets can create a network overhead, especially if only small packets are received.

John Nagle specified a way to acknowledge several received packets with a single ACK, also called the Nagle Algorithm or Nagling or delayed acknowledge RFC 2581. The delayed ACK packet is sent within a certain interval and acknowledges all the packets received since last interval. The interval depends on a timeout value (default 200 ms) and outstanding ACKs (default 2). This saves network bandwidth and helps against congestion, but can sacrifice max network throughput.

To configure the max outstanding ACKs in Windows XP/2003/Vista/2008:

[HKEY_LOCAL_MACHINE \SYSTEM \CurrentControlSet \Services \Tcpip \Parameters \Interfaces \{Adapter-id}]
TcpAckFrequency = 2 (Default=2, 1=Disables nagling, 2-n = If n outstanding ACKs before timed interval, sent ACK)

More Info MS KB Q328890
More Info MS KB 815230 (XP/2003 needs hotfix or SP2 for it to work)
More Info MS KB 935458 (Vista needs hotfix or SP1 for it to work)

To configure the interval timeout in Win2000 SP3+:

[HKEY_LOCAL_MACHINE \SYSTEM \CurrentControlSet \Services \Tcpip \Parameters \Interfaces \{Adapter-id}]
TcpDelAckTicks = 1 (Default=2, 0=Disables nagling, 1-6 = 100-600 ms)

More Info MS KB Q311833
More Info MS KB Q321098
More Info MS KB Q321169

To configure the interval timeout in WinNT SP4 (Go to the Services-key and do a search for "TCPIP" to find the different adapters using TCPIP):

[HKEY_LOCAL_MACHINE \SYSTEM \CurrentControlSet \Services \{Adapter-Name} \Parameters \Tcpip]
TcpDelAckTicks = 1 (Default=2, 0=Disables nagling, 1-6 = 100-600 ms)

Note if disabling or shortening delayed ACK on a few machines (Like a file-server or domain-controller), then it will probably result in greater network performance for those machines. If on large corporate network and disabling delayed ACK for all computers, then it will most likely lower the available bandwidth for actual filetransfer as more of the bandwidth is used for sending ACKs.

Note before trying to disable ACK delay (RFC 1122) one should at least consider the following:
  • Increased performance will only be seen if requests are sent to your machine, and the requesters doesn't request anything else before your machine replies back(ACK) to the first request.
  • Some additions to the above statement:
    • If the application doing socket communication uses the socket option TCP_NODELAY, then it will override the default delayed ACK frequency.
    • If all of the upload bandwidth is already used (easy if slow connection), then then disabling delayed ACK will lower performance because it will generate even more upload traffic.
    • If on a half duplex connection, then disabling delayed ACK will lower performance because only one party can sent at a time (Receiver will block the sender when sending ACK).
    • If on a ethernet hub with other computers(Instead of a switch), then disabling delayed ACK will lower performance because the increased traffic will increase chance of collision and require retransmissions.
Note Explorer.exe doesn't copy the next file before the previous file was acknowledged (XCOPY doesn't have this behavior). This means it that the receiver will only accept a file at every ACK interval, and as the default ACK interval is 200 ms, which means that the it will copy max 5 files/sec for a single connection (Imagine copying 1000 files of 1 Kbyte). The performance can be improved some if dragging a folder containing the files instead of selecting all the files and dragging.

Note SMB Signing requires that SMB commands are processed synchronously, so a client is only allowed to send the next SMB command when it receives ACK of the previous one (Only one outstanding). This means that a client can max sent 5 SMB Commands/sec, as it has to wait for the Server's 200 ms ACK delay before it is allowed to sent the next SMB Command. This can cause very low performance when copying small files to a Server with SMB signing enabled (Imagine copying 1000 files of 1 Kbyte).

Note if a computer's only job is to receive large files or streaming data, one can increase performance by increasing the number of outstanding ACKs before it sends an ACK (TcpAckFrequency). It will allow acknowledgment of large chunks of data with a single ACK packet instead of sending ACK for every 2 packet. Make sure that the TCPIP RWIN is larger than TcpAckFrequency*MTU, as the sender will stop sending data if it fills the TCPIP RWIN without getting an ACK. Recommended values:
  • 1 GigaBit: TcpAckFrequency = 13 (RWIN = 64 KByte)
  • 100 MegaBit: TcpAckFrequency = 5 (RWIN = 17 KByte)
  • 10 MegaBit: TcpAckFrequency = 2 (RWIN = 8 KByte)
More Info MS KB Q214397
More Info MS KB Q823764

Updated: 29 January 2008

Comments:

Comment by CharlesH - 9 November 2004 @ 22:16 Reply

Where did you get your info on this? I can only get win2k to recognize the setting and not NT4. Did you test this or get it to work?

The Microsoft site states…

Delayed Acknowledgments Per RFC 1122, TCP uses delayed acknowledgments to reduce the number of packets sent on the media. The Microsoft stack takes a common approach to implementing delayed acknowledgments.

The following conditions cause an acknowledgment to be sent as data is received by TCP on a given connection:
* No ACK is sent for the previous received segment.
* Segment is received, and no other segment arrives within 200ms for that connection.

In summary, normally an ACK is sent for every other TCP segment received on a connection, unless the delayed ACK timer (200ms) expires. There is no configuration parameter to disable delayed ACKs.

Comment by snakefoot - 9 November 2004 @ 22:22 Reply

CharlesH
Where did you get your info on this? I can only get win2k to recognize the setting. Did you test this or get it to work?

Most of the stuff on my pages is merely stolen from other pages, but original it came from a Microsoft document, though it seems they have removed/updated the original documents.

Delayed Acknowledgments
As specified in RFC 1122, TCP uses delayed acknowledgments (ACKs) to reduce the number of packets sent on the media. The Microsoft stack takes a common approach to implementing delayed ACKs. As data is received by TCP on a given connection, it only sends an acknowledgment back if one of the following conditions is met:
* No ACK was sent for the previous segment received.
* A segment is received, but no other segment arrives within 200 milliseconds for that connection.

In summary, normally an ACK is sent for every other TCP segment received on a connection, unless the delayed ACK timer (200 milliseconds) expires. The delayed ACK timer can be adjusted via the DelAckTicks registry parameter, which was first introduced in Windows NT 4.0, Service Pack 4.

Along with:

Normally an ACK is sent for every other TCP segment received on a connection, unless the delayed ACK timer (200 milliseconds) expires. The delayed ACK timer for each interface can be adjusted by setting the value of the TCPDelAckTicks registry entry (HKLM/SYSTEM/CurrentControlSet/Services/Tcpip/Parameters/Interfaces/[interface]), which was first introduced in Microsoft Windows NT version 4.0, Service Pack 4.

Maybe Microsoft have found out that it wasn’t working and have removed the references to WinNT4

Comment by sean - 12 February 2008 @ 6:38 Reply

I have windows xp and am trying to do this. I am in the registry and i get all the way into interfaces, but i don’t see a interface where i can change tcpackfrequency. can someone help please?

Comment by Snakefoot - 12 February 2008 @ 10:26 Reply

sean
I don’t see a interface where i can change tcpackfrequency. can someone help please?

Many registry settings doesn’t exist by default, so one has to create the setting manually using the registry editor (In this case a DWORD setting).

Comment by Blitzlunar - 13 April 2008 @ 20:41 Reply

I’m using windows 2000. Is there anyway I can get the registry edit using the DWORD TcpAckFrequency to work for my network? I noticed that this registry edit is focused on XP and Vista with no mention of previous Windows versions,and that the only thing listed for Windows 2000 is configuring the interval timeouts. I’ve noticed some improvement through the timeout configuration but compared to other results it’s still not quite as up to par. Is there a specific registry edit for Windows 2000? I’d greatly appreciate any feed back ^^

Comment by Snakefoot - 15 April 2008 @ 9:36 Reply

Blitzlunar
The only thing listed for Windows 2000 is configuring the interval timeouts. I’ve noticed some improvement through the timeout configuration.

Changing the timeout setting TcpDelAckTicks to 0 will disable the nagle algorithm (As described in the article).

Leave a comment


You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>