Changeset View
Changeset View
Standalone View
Standalone View
head/sys/netinet/cc/cc_cubic.h
Show First 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | |||||
/* Number of bits of precision for fixed point math calcs. */ | /* Number of bits of precision for fixed point math calcs. */ | ||||
#define CUBIC_SHIFT 8 | #define CUBIC_SHIFT 8 | ||||
#define CUBIC_SHIFT_4 32 | #define CUBIC_SHIFT_4 32 | ||||
/* 0.5 << CUBIC_SHIFT. */ | /* 0.5 << CUBIC_SHIFT. */ | ||||
#define RENO_BETA 128 | #define RENO_BETA 128 | ||||
/* ~0.8 << CUBIC_SHIFT. */ | /* ~0.7 << CUBIC_SHIFT. */ | ||||
#define CUBIC_BETA 204 | #define CUBIC_BETA 179 | ||||
/* ~0.2 << CUBIC_SHIFT. */ | /* ~0.3 << CUBIC_SHIFT. */ | ||||
#define ONE_SUB_CUBIC_BETA 51 | #define ONE_SUB_CUBIC_BETA 77 | ||||
/* 3 * ONE_SUB_CUBIC_BETA. */ | /* 3 * ONE_SUB_CUBIC_BETA. */ | ||||
#define THREE_X_PT2 153 | #define THREE_X_PT3 231 | ||||
/* (2 << CUBIC_SHIFT) - ONE_SUB_CUBIC_BETA. */ | /* (2 << CUBIC_SHIFT) - ONE_SUB_CUBIC_BETA. */ | ||||
#define TWO_SUB_PT2 461 | #define TWO_SUB_PT3 435 | ||||
/* ~0.4 << CUBIC_SHIFT. */ | /* ~0.4 << CUBIC_SHIFT. */ | ||||
#define CUBIC_C_FACTOR 102 | #define CUBIC_C_FACTOR 102 | ||||
/* CUBIC fast convergence factor: ~0.9 << CUBIC_SHIFT. */ | /* CUBIC fast convergence factor: (1+beta_cubic)/2. */ | ||||
#define CUBIC_FC_FACTOR 230 | #define CUBIC_FC_FACTOR 217 | ||||
/* Don't trust s_rtt until this many rtt samples have been taken. */ | /* Don't trust s_rtt until this many rtt samples have been taken. */ | ||||
#define CUBIC_MIN_RTT_SAMPLES 8 | #define CUBIC_MIN_RTT_SAMPLES 8 | ||||
/* Userland only bits. */ | /* Userland only bits. */ | ||||
#ifndef _KERNEL | #ifndef _KERNEL | ||||
extern int hz; | extern int hz; | ||||
/* | /* | ||||
* Implementation based on the formulae found in the CUBIC Internet Draft | * Implementation based on the formulae found in the CUBIC Internet Draft | ||||
* "draft-rhee-tcpm-cubic-02". | * "draft-ietf-tcpm-cubic-04". | ||||
* | * | ||||
* Note BETA used in cc_cubic is equal to (1-beta) in the I-D | |||||
*/ | */ | ||||
static __inline float | static __inline float | ||||
theoretical_cubic_k(double wmax_pkts) | theoretical_cubic_k(double wmax_pkts) | ||||
{ | { | ||||
double C; | double C; | ||||
C = 0.4; | C = 0.4; | ||||
return (pow((wmax_pkts * 0.2) / C, (1.0 / 3.0)) * pow(2, CUBIC_SHIFT)); | return (pow((wmax_pkts * 0.3) / C, (1.0 / 3.0)) * pow(2, CUBIC_SHIFT)); | ||||
} | } | ||||
static __inline unsigned long | static __inline unsigned long | ||||
theoretical_cubic_cwnd(int ticks_since_cong, unsigned long wmax, uint32_t smss) | theoretical_cubic_cwnd(int ticks_since_cong, unsigned long wmax, uint32_t smss) | ||||
{ | { | ||||
double C, wmax_pkts; | double C, wmax_pkts; | ||||
C = 0.4; | C = 0.4; | ||||
Show All 12 Lines | theoretical_reno_cwnd(int ticks_since_cong, int rtt_ticks, unsigned long wmax, | ||||
return ((wmax * 0.5) + ((ticks_since_cong / (float)rtt_ticks) * smss)); | return ((wmax * 0.5) + ((ticks_since_cong / (float)rtt_ticks) * smss)); | ||||
} | } | ||||
static __inline unsigned long | static __inline unsigned long | ||||
theoretical_tf_cwnd(int ticks_since_cong, int rtt_ticks, unsigned long wmax, | theoretical_tf_cwnd(int ticks_since_cong, int rtt_ticks, unsigned long wmax, | ||||
uint32_t smss) | uint32_t smss) | ||||
{ | { | ||||
return ((wmax * 0.8) + ((3 * 0.2) / (2 - 0.2) * | return ((wmax * 0.7) + ((3 * 0.3) / (2 - 0.3) * | ||||
(ticks_since_cong / (float)rtt_ticks) * smss)); | (ticks_since_cong / (float)rtt_ticks) * smss)); | ||||
} | } | ||||
#endif /* !_KERNEL */ | #endif /* !_KERNEL */ | ||||
/* | /* | ||||
* Compute the CUBIC K value used in the cwnd calculation, using an | * Compute the CUBIC K value used in the cwnd calculation, using an | ||||
* implementation of eqn 2 in the I-D. The method used | * implementation of eqn 2 in the I-D. The method used | ||||
▲ Show 20 Lines • Show All 95 Lines • ▼ Show 20 Lines | reno_cwnd(int ticks_since_cong, int rtt_ticks, unsigned long wmax, | ||||
*/ | */ | ||||
return (((wmax * RENO_BETA) + (((ticks_since_cong * smss) | return (((wmax * RENO_BETA) + (((ticks_since_cong * smss) | ||||
<< CUBIC_SHIFT) / rtt_ticks)) >> CUBIC_SHIFT); | << CUBIC_SHIFT) / rtt_ticks)) >> CUBIC_SHIFT); | ||||
} | } | ||||
/* | /* | ||||
* Compute an approximation of the "TCP friendly" cwnd some number of ticks | * Compute an approximation of the "TCP friendly" cwnd some number of ticks | ||||
* after a congestion event that is designed to yield the same average cwnd as | * after a congestion event that is designed to yield the same average cwnd as | ||||
* NewReno while using CUBIC's beta of 0.8. RTT should be the average RTT | * NewReno while using CUBIC's beta of 0.7. RTT should be the average RTT | ||||
* estimate for the path measured over the previous congestion epoch and wmax is | * estimate for the path measured over the previous congestion epoch and wmax is | ||||
* the value of cwnd at the last congestion event. | * the value of cwnd at the last congestion event. | ||||
*/ | */ | ||||
static __inline unsigned long | static __inline unsigned long | ||||
tf_cwnd(int ticks_since_cong, int rtt_ticks, unsigned long wmax, | tf_cwnd(int ticks_since_cong, int rtt_ticks, unsigned long wmax, | ||||
uint32_t smss) | uint32_t smss) | ||||
{ | { | ||||
/* Equation 4 of I-D. */ | /* Equation 4 of I-D. */ | ||||
return (((wmax * CUBIC_BETA) + (((THREE_X_PT2 * ticks_since_cong * | return (((wmax * CUBIC_BETA) + (((THREE_X_PT3 * ticks_since_cong * | ||||
smss) << CUBIC_SHIFT) / TWO_SUB_PT2 / rtt_ticks)) >> CUBIC_SHIFT); | smss) << CUBIC_SHIFT) / TWO_SUB_PT3 / rtt_ticks)) >> CUBIC_SHIFT); | ||||
} | } | ||||
#endif /* _NETINET_CC_CUBIC_H_ */ | #endif /* _NETINET_CC_CUBIC_H_ */ |