Subject: Re: CVS commit: src
To: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
From: Rui Paulo <rpaulo@gmail.com>
List: tech-net
Date: 10/10/2006 11:01:41
On Oct 10, 2006, at 10:31 AM, YAMAMOTO Takashi wrote:

> tcp_reno_newack does:
>
> 	if (SEQ_GEQ(th->th_ack, tp->snd_recover))
> 		tp->snd_cwnd = min(cw + incr, TCP_MAXWIN << tp->snd_scale);
>
> but snd_recover is not updated unless we're doing fast retransmit.
> what's the intention of the code?

I'm sorry, that was a huge typo.
I think the correct code is:

Index: tcp_congctl.c
===================================================================
RCS file: /cvsroot/src/sys/netinet/tcp_congctl.c,v
retrieving revision 1.1
diff -u -p -r1.1 tcp_congctl.c
--- tcp_congctl.c	9 Oct 2006 16:27:07 -0000	1.1
+++ tcp_congctl.c	10 Oct 2006 10:01:38 -0000
@@ -491,24 +491,21 @@ tcp_reno_fast_retransmit_newack(struct t
static void
tcp_reno_newack(struct tcpcb *tp, struct tcphdr *th)
{
-	u_int cw;
-	u_int incr;
-	
	/*
	 * When new data is acked, open the congestion window.
	 * If the window gives us less than ssthresh packets
	 * in flight, open exponentially (segsz per packet).
	 * Otherwise open linearly: segsz per window
-	 * (segsz^2 / cwnd per packet), plus a constant
-	 * fraction of a packet (segsz/8) to help larger windows
-	 * open quickly enough.
+	 * (segsz^2 / cwnd per packet).
	 */
-	cw = tp->snd_cwnd;
-	incr = tp->t_segsz;
-	if (cw > tp->snd_ssthresh)
+
+	u_int cw = tp->snd_cwnd;
+	u_int incr = tp->t_segsz;
+
+	if (cw > = tp->snd_ssthresh)
		incr = incr * incr / cw;
-	if (SEQ_GEQ(th->th_ack, tp->snd_recover))
-		tp->snd_cwnd = min(cw + incr, TCP_MAXWIN << tp->snd_scale);
+
+	tp->snd_cwnd = min(cw + incr, TCP_MAXWIN << tp->snd_scale);
}
struct tcp_congctl tcp_reno_ctl = {
@@ -610,22 +607,14 @@ tcp_newreno_fast_retransmit_newack(struc
static void
tcp_newreno_newack(struct tcpcb *tp, struct tcphdr *th)
{
-	u_int cw;
-	u_int incr;
-	
	/*
-	 * When new data is acked, open the congestion window.
-	 * If the window gives us less than ssthresh packets
-	 * in flight, open exponentially (segsz per packet).
-	 * Otherwise open linearly: segsz per window
-	 * (segsz^2 / cwnd per packet), plus a constant
-	 * fraction of a packet (segsz/8) to help larger windows
-	 * open quickly enough.
+	 * If we are still in fast recovery (meaning we are using
+	 * NewReno and we have only received partial acks), do not
+	 * inflate the window yet.
	 */
-	cw = tp->snd_cwnd;
-	incr = tp->t_segsz;
-	if (cw > tp->snd_ssthresh)
-		incr = incr * incr / cw;
+
+	if (tp->t_partialacks < 0)
+		tcp_reno_newack(tp, th);
}


--
Rui Paulo