Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/cc/cc_cubic.c
Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | |||||
* http://caia.swin.edu.au/urp/newtcp/ | * http://caia.swin.edu.au/urp/newtcp/ | ||||
*/ | */ | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/limits.h> | |||||
#include <sys/malloc.h> | #include <sys/malloc.h> | ||||
#include <sys/module.h> | #include <sys/module.h> | ||||
#include <sys/socket.h> | #include <sys/socket.h> | ||||
#include <sys/socketvar.h> | #include <sys/socketvar.h> | ||||
#include <sys/sysctl.h> | #include <sys/sysctl.h> | ||||
#include <sys/systm.h> | #include <sys/systm.h> | ||||
#include <net/vnet.h> | #include <net/vnet.h> | ||||
▲ Show 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | if (type == CC_ACK && !IN_RECOVERY(CCV(ccv, t_flags)) && | ||||
(ccv->flags & CCF_CWND_LIMITED) && (!V_tcp_do_rfc3465 || | (ccv->flags & CCF_CWND_LIMITED) && (!V_tcp_do_rfc3465 || | ||||
CCV(ccv, snd_cwnd) <= CCV(ccv, snd_ssthresh) || | CCV(ccv, snd_cwnd) <= CCV(ccv, snd_ssthresh) || | ||||
(V_tcp_do_rfc3465 && ccv->flags & CCF_ABC_SENTAWND))) { | (V_tcp_do_rfc3465 && ccv->flags & CCF_ABC_SENTAWND))) { | ||||
/* Use the logic in NewReno ack_received() for slow start. */ | /* Use the logic in NewReno ack_received() for slow start. */ | ||||
if (CCV(ccv, snd_cwnd) <= CCV(ccv, snd_ssthresh) || | if (CCV(ccv, snd_cwnd) <= CCV(ccv, snd_ssthresh) || | ||||
cubic_data->min_rtt_ticks == TCPTV_SRTTBASE) | cubic_data->min_rtt_ticks == TCPTV_SRTTBASE) | ||||
newreno_cc_algo.ack_received(ccv, type); | newreno_cc_algo.ack_received(ccv, type); | ||||
else { | else { | ||||
ticks_since_cong = ticks - cubic_data->t_last_cong; | if ((ticks_since_cong = | ||||
ticks - cubic_data->t_last_cong) < 0) { | |||||
/* | |||||
* dragging t_last_cong along | |||||
*/ | |||||
ticks_since_cong = INT_MAX; | |||||
cubic_data->t_last_cong = ticks - INT_MAX; | |||||
} | |||||
/* | /* | ||||
* The mean RTT is used to best reflect the equations in | * The mean RTT is used to best reflect the equations in | ||||
* the I-D. Using min_rtt in the tf_cwnd calculation | * the I-D. Using min_rtt in the tf_cwnd calculation | ||||
* causes w_tf to grow much faster than it should if the | * causes w_tf to grow much faster than it should if the | ||||
* RTT is dominated by network buffering rather than | * RTT is dominated by network buffering rather than | ||||
* propagation delay. | * propagation delay. | ||||
*/ | */ | ||||
w_tf = tf_cwnd(ticks_since_cong, | w_tf = tf_cwnd(ticks_since_cong, | ||||
cubic_data->mean_rtt_ticks, cubic_data->max_cwnd, | cubic_data->mean_rtt_ticks, cubic_data->max_cwnd, | ||||
CCV(ccv, t_maxseg)); | CCV(ccv, t_maxseg)); | ||||
w_cubic_next = cubic_cwnd(ticks_since_cong + | w_cubic_next = cubic_cwnd(ticks_since_cong + | ||||
cubic_data->mean_rtt_ticks, cubic_data->max_cwnd, | cubic_data->mean_rtt_ticks, cubic_data->max_cwnd, | ||||
CCV(ccv, t_maxseg), cubic_data->K); | CCV(ccv, t_maxseg), cubic_data->K); | ||||
ccv->flags &= ~CCF_ABC_SENTAWND; | ccv->flags &= ~CCF_ABC_SENTAWND; | ||||
if (w_cubic_next < w_tf) | if (w_cubic_next < w_tf) { | ||||
/* | /* | ||||
* TCP-friendly region, follow tf | * TCP-friendly region, follow tf | ||||
* cwnd growth. | * cwnd growth. | ||||
*/ | */ | ||||
CCV(ccv, snd_cwnd) = w_tf; | if (CCV(ccv, snd_cwnd) < w_tf) | ||||
CCV(ccv, snd_cwnd) = ulmin(w_tf, INT_MAX); | |||||
} | |||||
else if (CCV(ccv, snd_cwnd) < w_cubic_next) { | else if (CCV(ccv, snd_cwnd) < w_cubic_next) { | ||||
/* | /* | ||||
* Concave or convex region, follow CUBIC | * Concave or convex region, follow CUBIC | ||||
* cwnd growth. | * cwnd growth. | ||||
*/ | */ | ||||
if (V_tcp_do_rfc3465) | if (V_tcp_do_rfc3465) | ||||
CCV(ccv, snd_cwnd) = w_cubic_next; | CCV(ccv, snd_cwnd) = ulmin(w_cubic_next, | ||||
INT_MAX); | |||||
else | else | ||||
CCV(ccv, snd_cwnd) += ((w_cubic_next - | CCV(ccv, snd_cwnd) += ulmax(1, | ||||
((ulmin(w_cubic_next, INT_MAX) - | |||||
CCV(ccv, snd_cwnd)) * | CCV(ccv, snd_cwnd)) * | ||||
CCV(ccv, t_maxseg)) / | CCV(ccv, t_maxseg)) / | ||||
CCV(ccv, snd_cwnd); | CCV(ccv, snd_cwnd)); | ||||
} | } | ||||
/* | /* | ||||
* If we're not in slow start and we're probing for a | * If we're not in slow start and we're probing for a | ||||
* new cwnd limit at the start of a connection | * new cwnd limit at the start of a connection | ||||
* (happens when hostcache has a relevant entry), | * (happens when hostcache has a relevant entry), | ||||
* keep updating our current estimate of the | * keep updating our current estimate of the | ||||
* max_cwnd. | * max_cwnd. | ||||
▲ Show 20 Lines • Show All 231 Lines • Show Last 20 Lines |