From owner-p4-projects@FreeBSD.ORG Sun Mar 22 22:07:41 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id A5D281065672; Sun, 22 Mar 2009 22:07:40 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 63BAC1065670 for ; Sun, 22 Mar 2009 22:07:40 +0000 (UTC) (envelope-from andre@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 396868FC25 for ; Sun, 22 Mar 2009 22:07:40 +0000 (UTC) (envelope-from andre@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n2MM7e81031333 for ; Sun, 22 Mar 2009 22:07:40 GMT (envelope-from andre@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n2MM7enW031330 for perforce@freebsd.org; Sun, 22 Mar 2009 22:07:40 GMT (envelope-from andre@freebsd.org) Date: Sun, 22 Mar 2009 22:07:40 GMT Message-Id: <200903222207.n2MM7enW031330@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to andre@freebsd.org using -f From: Andre Oppermann To: Perforce Change Reviews Cc: Subject: PERFORCE change 159639 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Mar 2009 22:07:42 -0000 http://perforce.freebsd.org/chv.cgi?CH=159639 Change 159639 by andre@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); } /*