1 /* $NetBSD: tcp_congctl.c,v 1.14 2008/02/29 07:39:17 matt Exp $ */
4 * Copyright (c) 1997, 1998, 1999, 2001, 2005, 2006 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe and Kevin M. Lahey of the Numerical Aerospace Simulation
9 * Facility, NASA Ames Research Center.
10 * This code is derived from software contributed to The NetBSD Foundation
11 * by Charles M. Hannum.
12 * This code is derived from software contributed to The NetBSD Foundation
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
18 * 1. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
24 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
25 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
26 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
28 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
38 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
39 * All rights reserved.
41 * Redistribution and use in source and binary forms, with or without
42 * modification, are permitted provided that the following conditions
44 * 1. Redistributions of source code must retain the above copyright
45 * notice, this list of conditions and the following disclaimer.
46 * 2. Redistributions in binary form must reproduce the above copyright
47 * notice, this list of conditions and the following disclaimer in the
48 * documentation and/or other materials provided with the distribution.
49 * 3. Neither the name of the project nor the names of its contributors
50 * may be used to endorse or promote products derived from this software
51 * without specific prior written permission.
53 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
54 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
55 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
56 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
57 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
58 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
59 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
60 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
61 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
62 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
67 * @(#)COPYRIGHT 1.1 (NRL) 17 January 1995
69 * NRL grants permission for redistribution and use in source and binary
70 * forms, with or without modification, of the software and documentation
71 * created at NRL provided that the following conditions are met:
73 * 1. Redistributions of source code must retain the above copyright
74 * notice, this list of conditions and the following disclaimer.
75 * 2. Redistributions in binary form must reproduce the above copyright
76 * notice, this list of conditions and the following disclaimer in the
77 * documentation and/or other materials provided with the distribution.
78 * 3. All advertising materials mentioning features or use of this software
79 * must display the following acknowledgements:
80 * This product includes software developed by the University of
81 * California, Berkeley and its contributors.
82 * This product includes software developed at the Information
83 * Technology Division, US Naval Research Laboratory.
84 * 4. Neither the name of the NRL nor the names of its contributors
85 * may be used to endorse or promote products derived from this software
86 * without specific prior written permission.
88 * THE SOFTWARE PROVIDED BY NRL IS PROVIDED BY NRL AND CONTRIBUTORS ``AS
89 * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
90 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
91 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NRL OR
92 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
93 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
94 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
95 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
96 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
97 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
98 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
100 * The views and conclusions contained in the software and documentation
101 * are those of the authors and should not be interpreted as representing
102 * official policies, either expressed or implied, of the US Naval
103 * Research Laboratory (NRL).
107 * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1994, 1995
108 * The Regents of the University of California. All rights reserved.
110 * Redistribution and use in source and binary forms, with or without
111 * modification, are permitted provided that the following conditions
113 * 1. Redistributions of source code must retain the above copyright
114 * notice, this list of conditions and the following disclaimer.
115 * 2. Redistributions in binary form must reproduce the above copyright
116 * notice, this list of conditions and the following disclaimer in the
117 * documentation and/or other materials provided with the distribution.
118 * 3. Neither the name of the University nor the names of its contributors
119 * may be used to endorse or promote products derived from this software
120 * without specific prior written permission.
122 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
123 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
124 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
125 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
126 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
127 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
128 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
129 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
130 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
134 * @(#)tcp_input.c 8.12 (Berkeley) 5/24/95
137 #include <sys/cdefs.h>
138 __KERNEL_RCSID(0, "$NetBSD: tcp_congctl.c,v 1.14 2008/02/29 07:39:17 matt Exp $");
140 #include "opt_inet.h"
141 #include "opt_tcp_debug.h"
142 #include "opt_tcp_congctl.h"
144 #include <sys/param.h>
145 #include <sys/systm.h>
146 #include <sys/malloc.h>
147 #include <sys/mbuf.h>
148 #include <sys/protosw.h>
149 #include <sys/socket.h>
150 #include <sys/socketvar.h>
151 #include <sys/errno.h>
152 #include <sys/syslog.h>
153 #include <sys/pool.h>
154 #include <sys/domain.h>
155 #include <sys/kernel.h>
156 #include <sys/mutex.h>
159 #include <net/route.h>
161 #include <netinet/in.h>
162 #include <netinet/in_systm.h>
163 #include <netinet/ip.h>
164 #include <netinet/in_pcb.h>
165 #include <netinet/in_var.h>
166 #include <netinet/ip_var.h>
170 #include <netinet/in.h>
172 #include <netinet/ip6.h>
173 #include <netinet6/ip6_var.h>
174 #include <netinet6/in6_pcb.h>
175 #include <netinet6/ip6_var.h>
176 #include <netinet6/in6_var.h>
177 #include <netinet/icmp6.h>
178 #include <netinet6/nd6.h>
181 #include <netinet/tcp.h>
182 #include <netinet/tcp_fsm.h>
183 #include <netinet/tcp_seq.h>
184 #include <netinet/tcp_timer.h>
185 #include <netinet/tcp_var.h>
186 #include <netinet/tcpip.h>
187 #include <netinet/tcp_congctl.h>
189 #include <netinet/tcp_debug.h>
194 * consider separating the actual implementations in another file.
197 static int tcp_reno_fast_retransmit(struct tcpcb
*, const struct tcphdr
*);
198 static void tcp_reno_slow_retransmit(struct tcpcb
*);
199 static void tcp_reno_fast_retransmit_newack(struct tcpcb
*,
200 const struct tcphdr
*);
201 static void tcp_reno_newack(struct tcpcb
*, const struct tcphdr
*);
202 static void tcp_reno_congestion_exp(struct tcpcb
*tp
);
204 static int tcp_newreno_fast_retransmit(struct tcpcb
*, const struct tcphdr
*);
205 static void tcp_newreno_fast_retransmit_newack(struct tcpcb
*,
206 const struct tcphdr
*);
207 static void tcp_newreno_newack(struct tcpcb
*, const struct tcphdr
*);
210 static void tcp_congctl_fillnames(void);
212 extern int tcprexmtthresh
;
214 MALLOC_DEFINE(M_TCPCONGCTL
, "tcpcongctl", "TCP congestion control structures");
216 /* currently selected global congestion control */
217 char tcp_congctl_global_name
[TCPCC_MAXLEN
];
219 /* available global congestion control algorithms */
220 char tcp_congctl_avail
[10 * TCPCC_MAXLEN
];
223 * Used to list the available congestion control algorithms.
225 TAILQ_HEAD(, tcp_congctlent
) tcp_congctlhd
=
226 TAILQ_HEAD_INITIALIZER(tcp_congctlhd
);
228 static struct tcp_congctlent
* tcp_congctl_global
;
230 static kmutex_t tcp_congctl_mtx
;
233 tcp_congctl_init(void)
237 mutex_init(&tcp_congctl_mtx
, MUTEX_DEFAULT
, IPL_NONE
);
239 /* Base algorithms. */
240 r
= tcp_congctl_register("reno", &tcp_reno_ctl
);
242 r
= tcp_congctl_register("newreno", &tcp_newreno_ctl
);
245 /* NewReno is the default. */
246 #ifndef TCP_CONGCTL_DEFAULT
247 #define TCP_CONGCTL_DEFAULT "newreno"
250 r
= tcp_congctl_select(NULL
, TCP_CONGCTL_DEFAULT
);
255 * Register a congestion algorithm and select it if we have none.
258 tcp_congctl_register(const char *name
, const struct tcp_congctl
*tcc
)
260 struct tcp_congctlent
*ntcc
, *tccp
;
262 TAILQ_FOREACH(tccp
, &tcp_congctlhd
, congctl_ent
)
263 if (!strcmp(name
, tccp
->congctl_name
)) {
264 /* name already registered */
268 ntcc
= malloc(sizeof(*ntcc
), M_TCPCONGCTL
, M_WAITOK
|M_ZERO
);
270 strlcpy(ntcc
->congctl_name
, name
, sizeof(ntcc
->congctl_name
) - 1);
271 ntcc
->congctl_ctl
= tcc
;
273 TAILQ_INSERT_TAIL(&tcp_congctlhd
, ntcc
, congctl_ent
);
274 tcp_congctl_fillnames();
276 if (TAILQ_FIRST(&tcp_congctlhd
) == ntcc
)
277 tcp_congctl_select(NULL
, name
);
283 tcp_congctl_unregister(const char *name
)
285 struct tcp_congctlent
*tccp
, *rtccp
;
290 TAILQ_FOREACH(tccp
, &tcp_congctlhd
, congctl_ent
) {
291 if (!strcmp(name
, tccp
->congctl_name
))
299 if (size
<= 1 || tcp_congctl_global
== rtccp
|| rtccp
->congctl_refcnt
)
302 TAILQ_REMOVE(&tcp_congctlhd
, rtccp
, congctl_ent
);
303 free(rtccp
, M_TCPCONGCTL
);
304 tcp_congctl_fillnames();
310 * Select a congestion algorithm by name.
313 tcp_congctl_select(struct tcpcb
*tp
, const char *name
)
315 struct tcp_congctlent
*tccp
, *old_tccp
, *new_tccp
;
316 bool old_found
, new_found
;
320 old_found
= (tp
== NULL
|| tp
->t_congctl
== NULL
);
325 TAILQ_FOREACH(tccp
, &tcp_congctlhd
, congctl_ent
) {
326 if (!old_found
&& tccp
->congctl_ctl
== tp
->t_congctl
) {
331 if (!new_found
&& !strcmp(name
, tccp
->congctl_name
)) {
336 if (new_found
&& old_found
) {
338 mutex_enter(&tcp_congctl_mtx
);
340 old_tccp
->congctl_refcnt
--;
341 tp
->t_congctl
= new_tccp
->congctl_ctl
;
342 new_tccp
->congctl_refcnt
++;
343 mutex_exit(&tcp_congctl_mtx
);
345 tcp_congctl_global
= new_tccp
;
346 strlcpy(tcp_congctl_global_name
,
347 new_tccp
->congctl_name
,
348 sizeof(tcp_congctl_global_name
) - 1);
358 tcp_congctl_release(struct tcpcb
*tp
)
360 struct tcp_congctlent
*tccp
;
362 KASSERT(tp
->t_congctl
);
364 TAILQ_FOREACH(tccp
, &tcp_congctlhd
, congctl_ent
) {
365 if (tccp
->congctl_ctl
== tp
->t_congctl
) {
366 tccp
->congctl_refcnt
--;
373 * Returns the name of a congestion algorithm.
376 tcp_congctl_bystruct(const struct tcp_congctl
*tcc
)
378 struct tcp_congctlent
*tccp
;
382 TAILQ_FOREACH(tccp
, &tcp_congctlhd
, congctl_ent
)
383 if (tccp
->congctl_ctl
== tcc
)
384 return tccp
->congctl_name
;
390 tcp_congctl_fillnames(void)
392 struct tcp_congctlent
*tccp
;
393 const char *delim
= " ";
395 tcp_congctl_avail
[0] = '\0';
396 TAILQ_FOREACH(tccp
, &tcp_congctlhd
, congctl_ent
) {
397 strlcat(tcp_congctl_avail
, tccp
->congctl_name
,
398 sizeof(tcp_congctl_avail
) - 1);
399 if (TAILQ_NEXT(tccp
, congctl_ent
))
400 strlcat(tcp_congctl_avail
, delim
,
401 sizeof(tcp_congctl_avail
) - 1);
406 /* ------------------------------------------------------------------------ */
409 * TCP/Reno congestion control.
412 tcp_reno_congestion_exp(struct tcpcb
*tp
)
417 * Halve the congestion window and reduce the
418 * slow start threshold.
420 win
= min(tp
->snd_wnd
, tp
->snd_cwnd
) / 2 / tp
->t_segsz
;
424 tp
->snd_ssthresh
= win
* tp
->t_segsz
;
425 tp
->snd_recover
= tp
->snd_max
;
426 tp
->snd_cwnd
= tp
->snd_ssthresh
;
429 * When using TCP ECN, notify the peer that
430 * we reduced the cwnd.
432 if (TCP_ECN_ALLOWED(tp
))
433 tp
->t_flags
|= TF_ECN_SND_CWR
;
439 tcp_reno_fast_retransmit(struct tcpcb
*tp
, const struct tcphdr
*th
)
442 * We know we're losing at the current
443 * window size so do congestion avoidance
444 * (set ssthresh to half the current window
445 * and pull our congestion window back to
448 * Dup acks mean that packets have left the
449 * network (they're now cached at the receiver)
450 * so bump cwnd by the amount in the receiver
451 * to keep a constant cwnd packets in the
454 * If we are using TCP/SACK, then enter
455 * Fast Recovery if the receiver SACKs
456 * data that is tcprexmtthresh * MSS
457 * bytes past the last ACKed segment,
458 * irrespective of the number of DupAcks.
464 tcp_reno_congestion_exp(tp
);
465 tp
->t_partialacks
= 0;
466 TCP_TIMER_DISARM(tp
, TCPT_REXMT
);
468 if (TCP_SACK_ENABLED(tp
)) {
469 tp
->t_dupacks
= tcprexmtthresh
;
470 tp
->sack_newdata
= tp
->snd_nxt
;
471 tp
->snd_cwnd
= tp
->t_segsz
;
472 (void) tcp_output(tp
);
475 tp
->snd_nxt
= th
->th_ack
;
476 tp
->snd_cwnd
= tp
->t_segsz
;
477 (void) tcp_output(tp
);
478 tp
->snd_cwnd
= tp
->snd_ssthresh
+ tp
->t_segsz
* tp
->t_dupacks
;
479 if (SEQ_GT(onxt
, tp
->snd_nxt
))
486 tcp_reno_slow_retransmit(struct tcpcb
*tp
)
491 * Close the congestion window down to one segment
492 * (we'll open it by one segment for each ack we get).
493 * Since we probably have a window's worth of unacked
494 * data accumulated, this "slow start" keeps us from
495 * dumping all that data as back-to-back packets (which
496 * might overwhelm an intermediate gateway).
498 * There are two phases to the opening: Initially we
499 * open by one mss on each ack. This makes the window
500 * size increase exponentially with time. If the
501 * window is larger than the path can handle, this
502 * exponential growth results in dropped packet(s)
503 * almost immediately. To get more time between
504 * drops but still "push" the network to take advantage
505 * of improving conditions, we switch from exponential
506 * to linear window opening at some threshhold size.
507 * For a threshhold, we use half the current window
508 * size, truncated to a multiple of the mss.
510 * (the minimum cwnd that will give us exponential
511 * growth is 2 mss. We don't allow the threshhold
515 win
= min(tp
->snd_wnd
, tp
->snd_cwnd
) / 2 / tp
->t_segsz
;
518 /* Loss Window MUST be one segment. */
519 tp
->snd_cwnd
= tp
->t_segsz
;
520 tp
->snd_ssthresh
= win
* tp
->t_segsz
;
521 tp
->t_partialacks
= -1;
523 tp
->t_bytes_acked
= 0;
527 tcp_reno_fast_retransmit_newack(struct tcpcb
*tp
,
528 const struct tcphdr
*th
)
530 if (tp
->t_partialacks
< 0) {
532 * We were not in fast recovery. Reset the duplicate ack
538 * Clamp the congestion window to the crossover point and
539 * exit fast recovery.
541 if (tp
->snd_cwnd
> tp
->snd_ssthresh
)
542 tp
->snd_cwnd
= tp
->snd_ssthresh
;
543 tp
->t_partialacks
= -1;
545 tp
->t_bytes_acked
= 0;
550 tcp_reno_newack(struct tcpcb
*tp
, const struct tcphdr
*th
)
553 * When new data is acked, open the congestion window.
556 u_int cw
= tp
->snd_cwnd
;
557 u_int incr
= tp
->t_segsz
;
562 * RFC 3465 Appropriate Byte Counting (ABC)
565 int acked
= th
->th_ack
- tp
->snd_una
;
567 if (cw
>= tp
->snd_ssthresh
) {
568 tp
->t_bytes_acked
+= acked
;
569 if (tp
->t_bytes_acked
>= cw
) {
570 /* Time to increase the window. */
571 tp
->t_bytes_acked
-= cw
;
573 /* No need to increase yet. */
578 * use 2*SMSS or 1*SMSS for the "L" param,
579 * depending on sysctl setting.
581 * (See RFC 3465 2.3 Choosing the Limit)
585 abc_lim
= (tcp_abc_aggressive
== 0 ||
586 tp
->snd_nxt
!= tp
->snd_max
) ? incr
: incr
* 2;
587 incr
= min(acked
, abc_lim
);
592 * If the window gives us less than ssthresh packets
593 * in flight, open exponentially (segsz per packet).
594 * Otherwise open linearly: segsz per window
595 * (segsz^2 / cwnd per packet).
598 if (cw
>= tp
->snd_ssthresh
) {
599 incr
= incr
* incr
/ cw
;
603 tp
->snd_cwnd
= min(cw
+ incr
, TCP_MAXWIN
<< tp
->snd_scale
);
606 const struct tcp_congctl tcp_reno_ctl
= {
607 .fast_retransmit
= tcp_reno_fast_retransmit
,
608 .slow_retransmit
= tcp_reno_slow_retransmit
,
609 .fast_retransmit_newack
= tcp_reno_fast_retransmit_newack
,
610 .newack
= tcp_reno_newack
,
611 .cong_exp
= tcp_reno_congestion_exp
,
615 * TCP/NewReno Congestion control.
618 tcp_newreno_fast_retransmit(struct tcpcb
*tp
, const struct tcphdr
*th
)
620 if (SEQ_LT(th
->th_ack
, tp
->snd_high
)) {
622 * False fast retransmit after timeout.
623 * Do not enter fast recovery
629 * Fast retransmit is same as reno.
631 return tcp_reno_fast_retransmit(tp
, th
);
638 * Implement the NewReno response to a new ack, checking for partial acks in
642 tcp_newreno_fast_retransmit_newack(struct tcpcb
*tp
, const struct tcphdr
*th
)
644 if (tp
->t_partialacks
< 0) {
646 * We were not in fast recovery. Reset the duplicate ack
650 } else if (SEQ_LT(th
->th_ack
, tp
->snd_recover
)) {
652 * This is a partial ack. Retransmit the first unacknowledged
653 * segment and deflate the congestion window by the amount of
654 * acknowledged data. Do not exit fast recovery.
656 tcp_seq onxt
= tp
->snd_nxt
;
657 u_long ocwnd
= tp
->snd_cwnd
;
660 * snd_una has not yet been updated and the socket's send
661 * buffer has not yet drained off the ACK'd data, so we
662 * have to leave snd_una as it was to get the correct data
663 * offset in tcp_output().
665 if (++tp
->t_partialacks
== 1)
666 TCP_TIMER_DISARM(tp
, TCPT_REXMT
);
668 tp
->snd_nxt
= th
->th_ack
;
670 * Set snd_cwnd to one segment beyond ACK'd offset. snd_una
671 * is not yet updated when we're called.
673 tp
->snd_cwnd
= tp
->t_segsz
+ (th
->th_ack
- tp
->snd_una
);
674 (void) tcp_output(tp
);
675 tp
->snd_cwnd
= ocwnd
;
676 if (SEQ_GT(onxt
, tp
->snd_nxt
))
679 * Partial window deflation. Relies on fact that tp->snd_una
682 tp
->snd_cwnd
-= (th
->th_ack
- tp
->snd_una
- tp
->t_segsz
);
685 * Complete ack. Inflate the congestion window to ssthresh
686 * and exit fast recovery.
688 * Window inflation should have left us with approx.
689 * snd_ssthresh outstanding data. But in case we
690 * would be inclined to send a burst, better to do
691 * it via the slow start mechanism.
693 if (SEQ_SUB(tp
->snd_max
, th
->th_ack
) < tp
->snd_ssthresh
)
694 tp
->snd_cwnd
= SEQ_SUB(tp
->snd_max
, th
->th_ack
)
697 tp
->snd_cwnd
= tp
->snd_ssthresh
;
698 tp
->t_partialacks
= -1;
700 tp
->t_bytes_acked
= 0;
705 tcp_newreno_newack(struct tcpcb
*tp
, const struct tcphdr
*th
)
708 * If we are still in fast recovery (meaning we are using
709 * NewReno and we have only received partial acks), do not
710 * inflate the window yet.
712 if (tp
->t_partialacks
< 0)
713 tcp_reno_newack(tp
, th
);
717 const struct tcp_congctl tcp_newreno_ctl
= {
718 .fast_retransmit
= tcp_newreno_fast_retransmit
,
719 .slow_retransmit
= tcp_reno_slow_retransmit
,
720 .fast_retransmit_newack
= tcp_newreno_fast_retransmit_newack
,
721 .newack
= tcp_newreno_newack
,
722 .cong_exp
= tcp_reno_congestion_exp
,