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

Function should_backoff

freebsd/netinet/cc/cc_chd.c:156–182  ·  view source on GitHub ↗

* Probabilistic backoff function. Returns 1 if we should backoff or 0 * otherwise. The calculation of p is similar to the calculation of p in cc_hd. */

Source from the content-addressed store, hash-verified

154 * otherwise. The calculation of p is similar to the calculation of p in cc_hd.
155 */
156static __inline int
157should_backoff(int qdly, int maxqdly, struct chd *chd_data)
158{
159 unsigned long p, rand;
160
161 rand = random();
162
163 if (qdly < V_chd_qthresh) {
164 chd_data->loss_compete = 0;
165 p = (((RANDOM_MAX / 100) * V_chd_pmax) /
166 (V_chd_qthresh - V_chd_qmin)) *
167 (qdly - V_chd_qmin);
168 } else {
169 if (qdly > V_chd_qthresh) {
170 p = (((RANDOM_MAX / 100) * V_chd_pmax) /
171 (maxqdly - V_chd_qthresh)) *
172 (maxqdly - qdly);
173 if (V_chd_loss_fair && rand < p)
174 chd_data->loss_compete = 1;
175 } else {
176 p = (RANDOM_MAX / 100) * V_chd_pmax;
177 chd_data->loss_compete = 0;
178 }
179 }
180
181 return (rand < p);
182}
183
184static __inline void
185chd_window_increase(struct cc_var *ccv, int new_measurement)

Callers 1

chd_ack_receivedFunction · 0.70

Calls 1

randomFunction · 0.50

Tested by

no test coverage detected