netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* snd_cwnd drawn and quartered
@ 2002-12-25  1:50 Werner Almesberger
  2003-01-02  1:38 ` kuznet
  0 siblings, 1 reply; 22+ messages in thread
From: Werner Almesberger @ 2002-12-25  1:50 UTC (permalink / raw)
  To: netdev; +Cc: chengjin

Hi all,

how about a little bug for Christmas ? :-)

There seems to be a bug in how fast recovery halves cwnd:
Linux TCP decrements snd_cwnd for every second incoming ACK
until we leave fast recovery.

Using the NewReno procedure, recovery ends between the time of
the inital loss plus RTT (no further losses), or about one RTT
later (if we lose the packet just sent before we detected the
initial loss).

So, in the worst case (i.e. the drawn-out recovery), cwnd gets
decremented for every second incoming ACK during two RTTs. In
the first RTT, we get the equivalent of the old cwnd of ACKs,
while in the second RTT, we've slowed down, and get only half
as many ACKs. So we end up with cwnd being a quarter of its
initial value.

Now, one could argue that this actually kind of makes sense
(i.e. no discontinuity for loss near the end of recovery),
but the code quite clearly tries to avoid this case:

net/ipv4/tcp_input.c:tcp_cwnd_down:

	if (decr && tp->snd_cwnd > tp->snd_ssthresh/2)
		tp->snd_cwnd -= decr;

Unfortunately, snd_ssthresh has already been halved at this
point, so the test actually does nothing. So I'd suggest to
change this to

	if (decr && tp->snd_cwnd > tp->snd_ssthresh)

This was found by Cheng Jin and me in his simulator based
on 2.4.18, but the code still seems to be the same in 2.5.53.

BTW, ironically, at least gcc 3.1 generates slightly worse
code if I change the second line to

		tp->snd_cwnd--;

It may still be desirable to change this for clarity,
though.

- Werner

-- 
  _________________________________________________________________________
 / Werner Almesberger, Buenos Aires, Argentina         wa@almesberger.net /
/_http://www.almesberger.net/____________________________________________/

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2003-01-19  6:55 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-12-25  1:50 snd_cwnd drawn and quartered Werner Almesberger
2003-01-02  1:38 ` kuznet
2003-01-02  6:08   ` Werner Almesberger
2003-01-02  8:31     ` Werner Almesberger
2003-01-02 21:26     ` Werner Almesberger
2003-01-14  0:12     ` kuznet
2003-01-14  1:20       ` Cheng Jin
2003-01-14  1:46         ` kuznet
2003-01-14  1:58           ` Cheng Jin
2003-01-14  2:12             ` kuznet
2003-01-14  2:19               ` Cheng Jin
2003-01-14  5:07                 ` kuznet
2003-01-14  4:01       ` Werner Almesberger
     [not found]         ` <200301140502.IAA10733@sex.inr.ac.ru>
2003-01-14  5:25           ` Werner Almesberger
2003-01-14  6:14             ` kuznet
2003-01-14  6:36               ` Werner Almesberger
2003-01-15 17:50                 ` kuznet
2003-01-15 18:25                   ` Werner Almesberger
2003-01-15 18:43                     ` kuznet
2003-01-15 19:37                       ` Werner Almesberger
2003-01-19  6:55         ` example showing how cwnd gets to one Cheng Jin
2003-01-14  0:54     ` snd_cwnd drawn and quartered kuznet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).