diff options
author | Daniele Lacamera <(root at danielinux.net)net> | 2005-06-23 15:26:34 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2005-06-23 15:26:34 -0400 |
commit | 835b3f0c0d7e1f716c45ec576662eac7a68b8548 (patch) | |
tree | 317013e535451e6da065e37e691fad80e88b5004 | |
parent | a628d29b56d3f420bf3ff1d7543a9caf3ce3b994 (diff) |
[TCP]: Add TCP Hybla congestion control module.
TCP Hybla congestion avoidance.
- "In heterogeneous networks, TCP connections that incorporate a
terrestrial or satellite radio link are greatly disadvantaged with
respect to entirely wired connections, because of their longer round
trip times (RTTs). To cope with this problem, a new TCP proposal, the
TCP Hybla, is presented and discussed in the paper[1]. It stems from an
analytical evaluation of the congestion window dynamics in the TCP
standard versions (Tahoe, Reno, NewReno), which suggests the necessary
modifications to remove the performance dependence on RTT.[...]"[1]
[1]: Carlo Caini, Rosario Firrincieli, "TCP Hybla: a TCP enhancement for
heterogeneous networks",
International Journal of Satellite Communications and Networking
Volume 22, Issue 5 , Pages 547 - 566. September 2004.
Signed-off-by: Daniele Lacamera (root at danielinux.net)net
Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/ipv4/Kconfig | 10 | ||||
-rw-r--r-- | net/ipv4/Makefile | 1 | ||||
-rw-r--r-- | net/ipv4/tcp_hybla.c | 187 |
3 files changed, 198 insertions, 0 deletions
diff --git a/net/ipv4/Kconfig b/net/ipv4/Kconfig index 910e25b65756..516ffe842816 100644 --- a/net/ipv4/Kconfig +++ b/net/ipv4/Kconfig | |||
@@ -478,6 +478,16 @@ config TCP_CONG_HSTCP | |||
478 | increase the congestion window by when an ACK is received. | 478 | increase the congestion window by when an ACK is received. |
479 | For more detail see http://www.icir.org/floyd/hstcp.html | 479 | For more detail see http://www.icir.org/floyd/hstcp.html |
480 | 480 | ||
481 | config TCP_CONG_HYBLA | ||
482 | tristate "TCP-Hybla congestion control algorithm" | ||
483 | depends on INET && EXPERIMENTAL | ||
484 | default n | ||
485 | ---help--- | ||
486 | TCP-Hybla is a sender-side only change that eliminates penalization of | ||
487 | long-RTT, large-bandwidth connections, like when satellite legs are | ||
488 | involved, expecially when sharing a common bottleneck with normal | ||
489 | terrestrial connections. | ||
490 | |||
481 | endmenu | 491 | endmenu |
482 | 492 | ||
483 | source "net/ipv4/ipvs/Kconfig" | 493 | source "net/ipv4/ipvs/Kconfig" |
diff --git a/net/ipv4/Makefile b/net/ipv4/Makefile index ddf5d7785bf4..ede7a5d617ff 100644 --- a/net/ipv4/Makefile +++ b/net/ipv4/Makefile | |||
@@ -34,6 +34,7 @@ obj-$(CONFIG_IP_ROUTE_MULTIPATH_CACHED) += multipath.o | |||
34 | obj-$(CONFIG_TCP_CONG_BIC) += tcp_bic.o | 34 | obj-$(CONFIG_TCP_CONG_BIC) += tcp_bic.o |
35 | obj-$(CONFIG_TCP_CONG_WESTWOOD) += tcp_westwood.o | 35 | obj-$(CONFIG_TCP_CONG_WESTWOOD) += tcp_westwood.o |
36 | obj-$(CONFIG_TCP_CONG_HSTCP) += tcp_highspeed.o | 36 | obj-$(CONFIG_TCP_CONG_HSTCP) += tcp_highspeed.o |
37 | obj-$(CONFIG_TCP_CONG_HYBLA) += tcp_hybla.o | ||
37 | 38 | ||
38 | obj-$(CONFIG_XFRM) += xfrm4_policy.o xfrm4_state.o xfrm4_input.o \ | 39 | obj-$(CONFIG_XFRM) += xfrm4_policy.o xfrm4_state.o xfrm4_input.o \ |
39 | xfrm4_output.o | 40 | xfrm4_output.o |
diff --git a/net/ipv4/tcp_hybla.c b/net/ipv4/tcp_hybla.c new file mode 100644 index 000000000000..13a66342c304 --- /dev/null +++ b/net/ipv4/tcp_hybla.c | |||
@@ -0,0 +1,187 @@ | |||
1 | /* | ||
2 | * TCP HYBLA | ||
3 | * | ||
4 | * TCP-HYBLA Congestion control algorithm, based on: | ||
5 | * C.Caini, R.Firrincieli, "TCP-Hybla: A TCP Enhancement | ||
6 | * for Heterogeneous Networks", | ||
7 | * International Journal on satellite Communications, | ||
8 | * September 2004 | ||
9 | * Daniele Lacamera | ||
10 | * root at danielinux.net | ||
11 | */ | ||
12 | |||
13 | #include <linux/config.h> | ||
14 | #include <linux/module.h> | ||
15 | #include <net/tcp.h> | ||
16 | |||
17 | /* Tcp Hybla structure. */ | ||
18 | struct hybla { | ||
19 | u8 hybla_en; | ||
20 | u32 snd_cwnd_cents; /* Keeps increment values when it is <1, <<7 */ | ||
21 | u32 rho; /* Rho parameter, integer part */ | ||
22 | u32 rho2; /* Rho * Rho, integer part */ | ||
23 | u32 rho_3ls; /* Rho parameter, <<3 */ | ||
24 | u32 rho2_7ls; /* Rho^2, <<7 */ | ||
25 | u32 minrtt; /* Minimum smoothed round trip time value seen */ | ||
26 | }; | ||
27 | |||
28 | /* Hybla reference round trip time (default= 1/40 sec = 25 ms), | ||
29 | expressed in jiffies */ | ||
30 | static int rtt0 = 25; | ||
31 | module_param(rtt0, int, 0644); | ||
32 | MODULE_PARM_DESC(rtt0, "reference rout trip time (ms)"); | ||
33 | |||
34 | |||
35 | /* This is called to refresh values for hybla parameters */ | ||
36 | static inline void hybla_recalc_param (struct tcp_sock *tp) | ||
37 | { | ||
38 | struct hybla *ca = tcp_ca(tp); | ||
39 | |||
40 | ca->rho_3ls = max_t(u32, tp->srtt / msecs_to_jiffies(rtt0), 8); | ||
41 | ca->rho = ca->rho_3ls >> 3; | ||
42 | ca->rho2_7ls = (ca->rho_3ls * ca->rho_3ls) << 1; | ||
43 | ca->rho2 = ca->rho2_7ls >>7; | ||
44 | } | ||
45 | |||
46 | static void hybla_init(struct tcp_sock *tp) | ||
47 | { | ||
48 | struct hybla *ca = tcp_ca(tp); | ||
49 | |||
50 | ca->rho = 0; | ||
51 | ca->rho2 = 0; | ||
52 | ca->rho_3ls = 0; | ||
53 | ca->rho2_7ls = 0; | ||
54 | ca->snd_cwnd_cents = 0; | ||
55 | ca->hybla_en = 1; | ||
56 | tp->snd_cwnd = 2; | ||
57 | tp->snd_cwnd_clamp = 65535; | ||
58 | |||
59 | /* 1st Rho measurement based on initial srtt */ | ||
60 | hybla_recalc_param(tp); | ||
61 | |||
62 | /* set minimum rtt as this is the 1st ever seen */ | ||
63 | ca->minrtt = tp->srtt; | ||
64 | tp->snd_cwnd = ca->rho; | ||
65 | } | ||
66 | |||
67 | static void hybla_state(struct tcp_sock *tp, u8 ca_state) | ||
68 | { | ||
69 | struct hybla *ca = tcp_ca(tp); | ||
70 | |||
71 | ca->hybla_en = (ca_state == TCP_CA_Open); | ||
72 | } | ||
73 | |||
74 | static inline u32 hybla_fraction(u32 odds) | ||
75 | { | ||
76 | static const u32 fractions[] = { | ||
77 | 128, 139, 152, 165, 181, 197, 215, 234, | ||
78 | }; | ||
79 | |||
80 | return (odds < ARRAY_SIZE(fractions)) ? fractions[odds] : 128; | ||
81 | } | ||
82 | |||
83 | /* TCP Hybla main routine. | ||
84 | * This is the algorithm behavior: | ||
85 | * o Recalc Hybla parameters if min_rtt has changed | ||
86 | * o Give cwnd a new value based on the model proposed | ||
87 | * o remember increments <1 | ||
88 | */ | ||
89 | static void hybla_cong_avoid(struct tcp_sock *tp, u32 ack, u32 rtt, | ||
90 | u32 in_flight, int flag) | ||
91 | { | ||
92 | struct hybla *ca = tcp_ca(tp); | ||
93 | u32 increment, odd, rho_fractions; | ||
94 | int is_slowstart = 0; | ||
95 | |||
96 | /* Recalculate rho only if this srtt is the lowest */ | ||
97 | if (tp->srtt < ca->minrtt){ | ||
98 | hybla_recalc_param(tp); | ||
99 | ca->minrtt = tp->srtt; | ||
100 | } | ||
101 | |||
102 | if (!ca->hybla_en) | ||
103 | return tcp_reno_cong_avoid(tp, ack, rtt, in_flight, flag); | ||
104 | |||
105 | if (in_flight < tp->snd_cwnd) | ||
106 | return; | ||
107 | |||
108 | if (ca->rho == 0) | ||
109 | hybla_recalc_param(tp); | ||
110 | |||
111 | rho_fractions = ca->rho_3ls - (ca->rho << 3); | ||
112 | |||
113 | if (tp->snd_cwnd < tp->snd_ssthresh) { | ||
114 | /* | ||
115 | * slow start | ||
116 | * INC = 2^RHO - 1 | ||
117 | * This is done by splitting the rho parameter | ||
118 | * into 2 parts: an integer part and a fraction part. | ||
119 | * Inrement<<7 is estimated by doing: | ||
120 | * [2^(int+fract)]<<7 | ||
121 | * that is equal to: | ||
122 | * (2^int) * [(2^fract) <<7] | ||
123 | * 2^int is straightly computed as 1<<int, | ||
124 | * while we will use hybla_slowstart_fraction_increment() to | ||
125 | * calculate 2^fract in a <<7 value. | ||
126 | */ | ||
127 | is_slowstart = 1; | ||
128 | increment = ((1 << ca->rho) * hybla_fraction(rho_fractions)) | ||
129 | - 128; | ||
130 | } else { | ||
131 | /* | ||
132 | * congestion avoidance | ||
133 | * INC = RHO^2 / W | ||
134 | * as long as increment is estimated as (rho<<7)/window | ||
135 | * it already is <<7 and we can easily count its fractions. | ||
136 | */ | ||
137 | increment = ca->rho2_7ls / tp->snd_cwnd; | ||
138 | if (increment < 128) | ||
139 | tp->snd_cwnd_cnt++; | ||
140 | } | ||
141 | |||
142 | odd = increment % 128; | ||
143 | tp->snd_cwnd += increment >> 7; | ||
144 | ca->snd_cwnd_cents += odd; | ||
145 | |||
146 | /* check when fractions goes >=128 and increase cwnd by 1. */ | ||
147 | while(ca->snd_cwnd_cents >= 128) { | ||
148 | tp->snd_cwnd++; | ||
149 | ca->snd_cwnd_cents -= 128; | ||
150 | tp->snd_cwnd_cnt = 0; | ||
151 | } | ||
152 | |||
153 | /* clamp down slowstart cwnd to ssthresh value. */ | ||
154 | if (is_slowstart) | ||
155 | tp->snd_cwnd = min(tp->snd_cwnd, tp->snd_ssthresh); | ||
156 | |||
157 | tp->snd_cwnd = min_t(u32, tp->snd_cwnd, tp->snd_cwnd_clamp); | ||
158 | } | ||
159 | |||
160 | static struct tcp_congestion_ops tcp_hybla = { | ||
161 | .init = hybla_init, | ||
162 | .ssthresh = tcp_reno_ssthresh, | ||
163 | .min_cwnd = tcp_reno_min_cwnd, | ||
164 | .cong_avoid = hybla_cong_avoid, | ||
165 | .set_state = hybla_state, | ||
166 | |||
167 | .owner = THIS_MODULE, | ||
168 | .name = "hybla" | ||
169 | }; | ||
170 | |||
171 | static int __init hybla_register(void) | ||
172 | { | ||
173 | BUG_ON(sizeof(struct hybla) > TCP_CA_PRIV_SIZE); | ||
174 | return tcp_register_congestion_control(&tcp_hybla); | ||
175 | } | ||
176 | |||
177 | static void __exit hybla_unregister(void) | ||
178 | { | ||
179 | tcp_unregister_congestion_control(&tcp_hybla); | ||
180 | } | ||
181 | |||
182 | module_init(hybla_register); | ||
183 | module_exit(hybla_unregister); | ||
184 | |||
185 | MODULE_AUTHOR("Daniele Lacamera"); | ||
186 | MODULE_LICENSE("GPL"); | ||
187 | MODULE_DESCRIPTION("TCP Hybla"); | ||