* 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. */
| 154 | * otherwise. The calculation of p is similar to the calculation of p in cc_hd. |
| 155 | */ |
| 156 | static __inline int |
| 157 | should_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 | |
| 184 | static __inline void |
| 185 | chd_window_increase(struct cc_var *ccv, int new_measurement) |
no test coverage detected