diff mbox

TCP packet size and delivery packet decisions

Message ID 20100914093758.GA24348@ms2.inr.ac.ru
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Alexey Kuznetsov Sept. 14, 2010, 9:37 a.m. UTC
Hello!

> Therefore, how about the following?

This will work.

There is one trap though. If pktsize > max_window, packets never
will be transmitted in normal path, only from probe timer, which
will be very slow.

If we do not want to mess with tcp_write_xmit(), it is still possible
to relax the bound to tp->max_window. (BTW, this even does not
contradict to RFC, only Fs = 1 for tiny windows). This should work:



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/include/net/tcp.h b/include/net/tcp.h
index 34f5cc2..8cf8cdb 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -501,8 +501,22 @@  extern unsigned int tcp_current_mss(struct sock *sk);
 /* Bound MSS / TSO packet size with the half of the window */
 static inline int tcp_bound_to_half_wnd(struct tcp_sock *tp, int pktsize)
 {
-	if (tp->max_window && pktsize > (tp->max_window >> 1))
-		return max(tp->max_window >> 1, 68U - tp->tcp_header_len);
+	int cutoff;
+
+	/* When peer uses tiny windows, there is no use in packetizing
+	 * to sub-MSS pieces for the sake of SWS or making sure there
+	 * are enough packets in the pipe for fast recovery.
+	 *
+	 * On the other hand, for extremely large MSS devices, handling
+	 * smaller than MSS windows in this way does make sense.
+	 */
+	if (tp->max_window >= 512)
+		cutoff = (tp->max_window >> 1);
+	else
+		cutoff = tp->max_window;
+
+	if (cutoff && pktsize > cutoff)
+		return max(cutoff, 68U - tp->tcp_header_len);
 	else
 		return pktsize;
 }