10 #include <linux/module.h>
13 #define ALPHA_BASE (1<<7)
14 #define BETA_MIN (1<<6)
48 static inline u32 htcp_cong_time(
const struct htcp *
ca)
53 static inline u32 htcp_ccount(
const struct htcp *
ca)
55 return htcp_cong_time(ca) / ca->
minRTT;
58 static inline void htcp_reset(
struct htcp *
ca)
67 static u32 htcp_cwnd_undo(
struct sock *
sk)
69 const struct tcp_sock *tp = tcp_sk(sk);
70 struct htcp *
ca = inet_csk_ca(sk);
82 static inline void measure_rtt(
struct sock *sk,
u32 srtt)
85 struct htcp *ca = inet_csk_ca(sk);
104 const struct tcp_sock *tp = tcp_sk(sk);
105 struct htcp *ca = inet_csk_ca(sk);
114 if (!use_bandwidth_switch)
131 if (htcp_ccount(ca) <= 3) {
135 ca->
Bi = (3 * ca->
Bi + cur_Bi) / 4;
148 if (use_bandwidth_switch) {
153 if (!between(5 * maxB, 4 * old_maxB, 6 * old_maxB)) {
161 ca->
beta = (minRTT << 7) / maxRTT;
172 static inline void htcp_alpha_update(
struct htcp *ca)
176 u32 diff = htcp_cong_time(ca);
180 factor = 1 + (10 * diff + ((diff / 2) * (diff / 2) /
HZ)) /
HZ;
183 if (use_rtt_scaling && minRTT) {
184 u32 scale = (
HZ << 3) / (10 * minRTT);
187 scale =
min(
max(scale, 1
U << 2), 10
U << 3);
188 factor = (factor << 3) / scale;
193 ca->
alpha = 2 * factor * ((1 << 7) - ca->
beta);
207 static void htcp_param_update(
struct sock *sk)
209 struct htcp *ca = inet_csk_ca(sk);
213 htcp_beta_update(ca, minRTT, maxRTT);
214 htcp_alpha_update(ca);
217 if (minRTT > 0 && maxRTT > minRTT)
221 static u32 htcp_recalc_ssthresh(
struct sock *sk)
223 const struct tcp_sock *tp = tcp_sk(sk);
224 const struct htcp *ca = inet_csk_ca(sk);
226 htcp_param_update(sk);
230 static void htcp_cong_avoid(
struct sock *sk,
u32 ack,
u32 in_flight)
233 struct htcp *ca = inet_csk_ca(sk);
248 htcp_alpha_update(ca);
256 static void htcp_init(
struct sock *sk)
258 struct htcp *ca = inet_csk_ca(sk);
272 struct htcp *ca = inet_csk_ca(sk);
282 htcp_reset(inet_csk_ca(sk));
289 .ssthresh = htcp_recalc_ssthresh,
290 .cong_avoid = htcp_cong_avoid,
291 .set_state = htcp_state,
292 .undo_cwnd = htcp_cwnd_undo,
293 .pkts_acked = measure_achieved_throughput,
298 static int __init htcp_register(
void)
305 static void __exit htcp_unregister(
void)