Created
September 15, 2011 17:22
-
-
Save silas/1219875 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -up linux-2.6.18/include/net/tcp.h.orig linux-2.6.18/include/net/tcp.h | |
--- linux-2.6.18/include/net/tcp.h.orig 2011-09-14 18:58:25.474537285 -0400 | |
+++ linux-2.6.18/include/net/tcp.h 2011-09-14 18:58:37.942381278 -0400 | |
@@ -54,6 +54,9 @@ extern void tcp_time_wait(struct sock *s | |
*/ | |
#define MAX_TCP_WINDOW 32767U | |
+/* Offer an initial receive window. */ | |
+#define TCP_DEFAULT_INIT_RCVWND 10 | |
+ | |
/* Minimal accepted MSS. It is (60+60+8) - (20+20). */ | |
#define TCP_MIN_MSS 88U | |
@@ -185,6 +188,9 @@ extern void tcp_time_wait(struct sock *s | |
#define TCP_NAGLE_CORK 2 /* Socket is corked */ | |
#define TCP_NAGLE_PUSH 4 /* Cork is overridden for already queued data */ | |
+/* TCP initial congestion window */ | |
+#define TCP_INIT_CWND 10 | |
+ | |
extern struct inet_timewait_death_row tcp_death_row; | |
/* sysctl variables for tcp */ | |
diff -up linux-2.6.18/net/ipv4/tcp_input.c.orig linux-2.6.18/net/ipv4/tcp_input.c | |
--- linux-2.6.18/net/ipv4/tcp_input.c.orig 2011-09-14 18:58:46.081626607 -0400 | |
+++ linux-2.6.18/net/ipv4/tcp_input.c 2011-09-14 19:00:26.904278072 -0400 | |
@@ -742,17 +742,12 @@ void tcp_update_metrics(struct sock *sk) | |
} | |
} | |
-/* Numbers are taken from RFC2414. */ | |
__u32 tcp_init_cwnd(struct tcp_sock *tp, struct dst_entry *dst) | |
{ | |
__u32 cwnd = (dst ? dst_metric(dst, RTAX_INITCWND) : 0); | |
- if (!cwnd) { | |
- if (tp->mss_cache > 1460) | |
- cwnd = 2; | |
- else | |
- cwnd = (tp->mss_cache > 1095) ? 3 : 4; | |
- } | |
+ if (!cwnd) | |
+ cwnd = TCP_INIT_CWND; | |
return min_t(__u32, cwnd, tp->snd_cwnd_clamp); | |
} | |
@@ -834,6 +829,8 @@ static void tcp_init_metrics(struct sock | |
tcp_bound_rto(sk); | |
if (inet_csk(sk)->icsk_rto < TCP_TIMEOUT_INIT && !tp->rx_opt.saw_tstamp) | |
goto reset; | |
+ | |
+cwnd: | |
tp->snd_cwnd = tcp_init_cwnd(tp, dst); | |
tp->snd_cwnd_stamp = tcp_time_stamp; | |
return; | |
@@ -848,6 +845,7 @@ reset: | |
tp->mdev = tp->mdev_max = tp->rttvar = TCP_TIMEOUT_INIT; | |
inet_csk(sk)->icsk_rto = TCP_TIMEOUT_INIT; | |
} | |
+ goto cwnd; | |
} | |
static void tcp_update_reordering(struct sock *sk, const int metric, | |
diff -up linux-2.6.18/net/ipv4/tcp_output.c.orig linux-2.6.18/net/ipv4/tcp_output.c | |
--- linux-2.6.18/net/ipv4/tcp_output.c.orig 2011-09-14 19:00:40.465020643 -0400 | |
+++ linux-2.6.18/net/ipv4/tcp_output.c 2011-09-14 19:01:53.911210145 -0400 | |
@@ -208,19 +208,18 @@ void tcp_select_initial_window(int __spa | |
} | |
} | |
- /* Set initial window to value enough for senders, | |
- * following RFC2414. Senders, not following this RFC, | |
- * will be satisfied with 2. | |
- */ | |
- if (mss > (1<<*rcv_wscale)) { | |
- int init_cwnd = 4; | |
- if (mss > 1460*3) | |
- init_cwnd = 2; | |
- else if (mss > 1460) | |
- init_cwnd = 3; | |
- if (*rcv_wnd > init_cwnd*mss) | |
- *rcv_wnd = init_cwnd*mss; | |
- } | |
+ /* Set initial window to a value enough for senders starting with | |
+ * initial congestion window of TCP_DEFAULT_INIT_RCVWND. Place | |
+ * a limit on the initial window when mss is larger than 1460. | |
+ */ | |
+ if (mss > (1 << *rcv_wscale)) { | |
+ int init_cwnd = TCP_DEFAULT_INIT_RCVWND; | |
+ if (mss > 1460) | |
+ init_cwnd = | |
+ max_t(u32, (1460 * TCP_DEFAULT_INIT_RCVWND) / mss, 2); | |
+ else | |
+ *rcv_wnd = min(*rcv_wnd, init_cwnd * mss); | |
+ } | |
/* Set the clamp no higher than max representable value */ | |
(*window_clamp) = min(65535U << (*rcv_wscale), *window_clamp); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment