MCPcopy Create free account
hub / github.com/F-Stack/f-stack / cubic_k

Function cubic_k

freebsd/netinet/cc/cc_cubic.h:139–167  ·  view source on GitHub ↗

* Compute the CUBIC K value used in the cwnd calculation, using an * implementation of eqn 2 in the I-D. The method used * here is adapted from Apple Computer Technical Report #KT-32. */

Source from the content-addressed store, hash-verified

137 * here is adapted from Apple Computer Technical Report #KT-32.
138 */
139static __inline int64_t
140cubic_k(unsigned long wmax_pkts)
141{
142 int64_t s, K;
143 uint16_t p;
144
145 K = s = 0;
146 p = 0;
147
148 /* (wmax * beta)/C with CUBIC_SHIFT worth of precision. */
149 s = ((wmax_pkts * ONE_SUB_CUBIC_BETA) << CUBIC_SHIFT) / CUBIC_C_FACTOR;
150
151 /* Rebase s to be between 1 and 1/8 with a shift of CUBIC_SHIFT. */
152 while (s >= 256) {
153 s >>= 3;
154 p++;
155 }
156
157 /*
158 * Some magic constants taken from the Apple TR with appropriate
159 * shifts: 275 == 1.072302 << CUBIC_SHIFT, 98 == 0.3812513 <<
160 * CUBIC_SHIFT, 120 == 0.46946116 << CUBIC_SHIFT.
161 */
162 K = (((s * 275) >> CUBIC_SHIFT) + 98) -
163 (((s * s * 120) >> CUBIC_SHIFT) >> CUBIC_SHIFT);
164
165 /* Multiply by 2^p to undo the rebasing of s from above. */
166 return (K <<= p);
167}
168
169/*
170 * Compute the new cwnd value using an implementation of eqn 1 from the I-D.

Callers 3

cubic_ack_receivedFunction · 0.85
cubic_after_idleFunction · 0.85
cubic_cong_signalFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected