Re: Sliding windows on XP and 2K don't???

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Alun Jones [MSFT] (alunj_at_online.microsoft.com)
Date: 07/14/04


Date: Wed, 14 Jul 2004 09:47:27 -0700


"Steve Alpert" <sra@newsgroups.nospam> wrote in message
news:e4#tBZaaEHA.1152@TK2MSFTNGP09.phx.gbl...
> We've been trying to speed up an application and have looked at a few
> sniffs and have found that when we're talking to a host (apparently with
> Nagle enabled), Windows XP will not transmit a second packet until a
> first packet has been ack'ed! We send a packet of about 30 bytes
> followed almost immediately by a send of another packet of about 300
> bytes and the second always waits until the server has ack'ed the first
> one? How come?
>
> These packet sizes are certainly small enough that the sliding window
> should come into play.

The Nagle algorithm is quite simple.

When the send request has less than a full frame's worth to send, and there
is unacknowledged data that has been sent, the send is buffered.
When an acknowledgement comes in, or there is more than a frame's worth of
data to send, buffered data will be sent.

So, when your first 30 bytes were given to send(), the Nagle algorithm says
"there is no unacknowledged data preceding this send, so we may put those 30
bytes on the wire."

When your next 300 bytes were given to send(), the Nagle algorithm says "I
have not yet received an acknowledgement for the previous 30 bytes, so I
won't send these 300 bytes".

Sliding windows only comes into play when you are sending continuous, long,
streams of data, at which point, since you repeatedly have more than a
frame's worth of data to send, Nagle does not come into play.

Since you know your 30 bytes will immediately be followed by 300 more, it is
your application's duty to hold the first 30 until the remaining 300 are
ready, at which point you send them as one buffer to a send() call (or a
single WSABUF to a WSASend call, if you don't want to aggregate the buffers
yourself).

I always advise against disabling the Nagle algorithm - doing so usually
indicates that your protocol is inefficient. The Nagle algorithm only
impacts inefficient protocol designs.

Alun.
~~~~



Relevant Pages

  • Re: Sliding windows on XP and 2K dont???
    ... >>first packet has been ack'ed! ... > When the send request has less than a full frame's worth to send, ... > So, when your first 30 bytes were given to send, the Nagle algorithm says ... at which point you send them as one buffer to a sendcall (or a ...
    (microsoft.public.win32.programmer.networks)
  • Re: winsock2 : use of send( ) and closesocket( )
    ... As a matter of fact, the packet size I send are rather small, ... so I guess that this is why the Nagle algorithm delays them, ... WinSock buffers outbound data and does not send it until an ...
    (microsoft.public.win32.programmer.networks)