/**
* Maxmimum advertised TCP window size
*
- * We estimate the TCP window size as the amount of free memory we
- * have. This is not strictly accurate (since it ignores any space
- * already allocated as RX buffers), but it will do for now.
- *
- * Since we don't store out-of-order received packets, the
- * retransmission penalty is that the whole window contents must be
- * resent. This suggests keeping the window size small, but bear in
- * mind that the maximum bandwidth on any link is limited to
- *
- * max_bandwidth = ( tcp_window / round_trip_time )
- *
- * With a 48kB window, which probably accurately reflects our amount
- * of free memory, and a WAN RTT of say 200ms, this gives a maximum
- * bandwidth of 240kB/s. This is sufficiently close to realistic that
- * we will need to be careful that our advertised window doesn't end
- * up limiting WAN download speeds.
- *
- * Finally, since the window goes into a 16-bit field and we cannot
- * actually use 65536, we use a window size of (65536-4) to ensure
- * that payloads remain dword-aligned.
+ * The maximum bandwidth on any link is limited by
+ *
+ * max_bandwidth * round_trip_time = tcp_window
+ *
+ * Some rough expectations for achievable bandwidths over various
+ * links are:
+ *
+ * a) Gigabit LAN: expected bandwidth 125MB/s, typical RTT 0.5ms,
+ * minimum required window 64kB
+ *
+ * b) Home Internet connection: expected bandwidth 10MB/s, typical
+ * RTT 25ms, minimum required window 256kB
+ *
+ * c) WAN: expected bandwidth 2MB/s, typical RTT 100ms, minimum
+ * required window 200kB.
+ *
+ * The maximum possible value for the TCP window size is 1GB (using
+ * the maximum window scale of 2**14). However, it is advisable to
+ * keep the window size as small as possible (without limiting
+ * bandwidth), since in the event of a lost packet the window size
+ * represents the maximum amount that will need to be retransmitted.
+ *
+ * We therefore choose a maximum window size of 256kB.
*/
-//#define TCP_MAX_WINDOW_SIZE ( 65536 - 4 )
-#define TCP_MAX_WINDOW_SIZE 8192
+#define TCP_MAX_WINDOW_SIZE ( 256 * 1024 )
/**
* Path MTU