PERFORCE change 159639 for review

Andre Oppermann andre at FreeBSD.org
Sun Mar 22 15:07:42 PDT 2009


http://perforce.freebsd.org/chv.cgi?CH=159639

Change 159639 by andre at andre_t61 on 2009/03/22 22:07:35

	Rearrange things and adjust logic. More to come.

Affected files ...

.. //depot/projects/tcp_new/netinet/tcp_cc_newreno.c#2 edit

Differences ...

==== //depot/projects/tcp_new/netinet/tcp_cc_newreno.c#2 (text+ko) ====

@@ -9,23 +9,6 @@
 }
 
 /*
- * update ssthresh to approx 1/2 of cwnd
- */
-void
-newreno_ssthresh_update(struct tcpcb *tp)
-{
-	u_int win;
-
-	/* reset ssthresh */
-	win = min(tp->snd_wnd, tp->snd_cwnd) / 2 / tp->snd_mss;
-
-	if (win < 2)
-		win = 2;
-
-	tp->snd_ssthresh = win * tp->snd_mss;
-}
-
-/*
  * initial cwnd at the start of a connection
  * if there is a hostcache entry for the foreign host, base cwnd on that
  * if rfc3390 is enabled, set cwnd to approx 4 MSS as recommended
@@ -61,7 +44,7 @@
 				min(metrics.rmx_cwnd / 2,
 				 min(tp->snd_wnd, so->so_snd.sb_hiwat)));
 	else
-		tp->snd_cwnd = min(4 * tp->snd_mss, max(2 * tp->snd_mss, 4380));
+		tp->snd_cwnd = tcp_init_cwnd(tp);
 }
 
 /*
@@ -73,7 +56,7 @@
 newreno_ack_received(struct tcpcb *tp, struct tcphdr *th, tcp_win tiwin,
     int acked, int tlen, int sacked)
 {
-	u_int incr = tp->snd_mss;
+	u_int incr;
 
 	/*
 	 * Do we have new information?
@@ -108,8 +91,11 @@
 	 *   maxseg^2 / cwnd per ACK as the increment.
 	 *   If cwnd > maxseg^2, fix the cwnd increment at 1 byte to
 	 *   avoid capping cwnd.
+	 *
+	 * NB: Make sure to lower bound cwnd to one (two?) segments.
 	 */
 	if (tp->snd_cwnd > tp->snd_ssthresh) {
+		/* Congestion avoidance */
 		if (tcp_do_abc) {
 			tp->snd_abcack += acked;
 			if (tp->snd_abcack >= tp->snd_cwnd) {
@@ -127,22 +113,32 @@
 		 * snd_max check is sufficient to handle this).
 		 */
 		incr = min(acked, tcp_abc_l_var * tp->snd_mss);
-	}
+	} else
+		incr = tp->snd_mss;
 
 	/*
 	 * ABC is on by default, so (incr == 0) frequently.
+	 *
+	 * NB: Make sure to upper bound cwnd to the maximum possible window.
 	 */
-	if (incr > 0)
+	if (incr > 0 && tp->snd_wnd < (TCP_MAXWIN << tp->snd_scale))
 		tp->snd_cwnd = min(tp->snd_cwnd + incr, TCP_MAXWIN << tp->snd_scale);
 }
 
 /*
- * update the value of ssthresh before entering FR
+ * update the value of ssthresh before entering loss recovery
  */
 void
-newreno_pre_fr(struct tcpcb *tp, struct tcphdr *th)
+newreno_pre_lr(struct tcpcb *tp)
 {
-	newreno_ssthresh_update(tp);
+	/*
+	 * RFC2581:
+	 *  ssthresh = cwnd = (FlightSize / 2)
+	 * lower bound to twice mss
+	 */
+	tp->snd_ssthresh = max(2 * tp->snd_mss, SEQ_DELTA(tp->snd_una, tp->snd_nxt) / 2);
+	tp->snd_cwnd = tp->snd_ssthresh;
+
 }
 
 /*
@@ -151,7 +147,7 @@
  * of new reno.
  */
 void
-newreno_post_fr(struct tcpcb *tp, struct tcphdr *th)
+newreno_post_lr(struct tcpcb *tp, struct tcphdr *th)
 {
 	/*
 	* Out of fast recovery.
@@ -190,7 +186,7 @@
 	* this is a local network or not.
 	*/
 
-	tp->snd_cwnd = tp->t_maxseg * ss_fltsz;
+	tp->snd_cwnd = tcp_init_cwnd(tp);
 }
 
 /*


More information about the p4-projects mailing list