lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-devel] Wrong value of the initial window (SYN packets) with bi


From: Dmitry Adamushko
Subject: Re: [lwip-devel] Wrong value of the initial window (SYN packets) with big TCP_WND and window scaling.
Date: Wed, 15 Jul 2015 18:25:01 +0200


Hi Simon,

[ I'm not subscribed to the list, please keep me in cc' ]

[quote]
When TCP_WND is set to (for example) 1MiB, the initially advertised window in SYN packets ends up being 0. Would the fix below be sufficient?
> Shouldn't the #error check in init.c be enough to keep TCP_WND <= 0xffff (unless window scaling is enabled)?

This is exactly the scenario with window-scaling enabled (sorry that I didn't make it explicit). Hence, TCP_WND > 0xffff is legitimate.

#define TCP_WND                  (1*1048576)
#define LWIP_WND_SCALE                  1
#define TCP_RCV_SCALE                   7
#define LWIP_TCP_TIMESTAMPS             1

In my specific scenario, a Linux host opened a connection to a server-side LWIP application. The LWIP stack responded with SYN-ACK but, because of this bug, window was set to 0. Hence, the Linux app was not able to send any data (its request) immediately... what happened then, IIRC, is that Linux stack sent a window probe after some time, then LWIP responded with an ACK with the proper window (using the scaling factor). Only then Linux was able to send data.

This fix is similar to what the Linux stack does.

--Dmitry


On Thu, Jul 9, 2015 at 3:24 PM, Dmitry Adamushko <address@hidden> wrote:
Hi,

When TCP_WND is set to (for example) 1MiB, the initially advertised window in SYN packets ends up being 0. Would the fix below be sufficient?

Note: It should be 32KiB if we want to be cautious about (rare cases?) TCP stacks interpreting 'window-size' as a signed value. However, I see that setting TCP_WND to values bigger than 32KiB is supported even without window scaling (according to existing checks for TCP_WND in src/core/init.c), hence I used 64KiB.

--- a/src/core/tcp_out.c
+++ b/src/core/tcp_out.c
@@ -1141,7 +1141,7 @@ tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb)
   if (seg->flags & TF_SEG_OPTS_WND_SCALE) {
     /* The Window field in a SYN segment itself (the only type where we send
        the window scale option) is never scaled. */
-    seg->tcphdr->wnd = htons(pcb->rcv_ann_wnd);
+    seg->tcphdr->wnd = htons(LWIP_MIN(pcb->rcv_ann_wnd, 65535U));
   } else
 #endif /* LWIP_WND_SCALE */
   {


-- Dmitry



--

-- Dmitry

reply via email to

[Prev in Thread] Current Thread [Next in Thread]