lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] tcp_output_segment() "silly window avoidance" shrinking the


From: Tom Evans
Subject: [lwip-users] tcp_output_segment() "silly window avoidance" shrinking the window is "strongly discouraged" and "SHOULD NOT"?
Date: Fri, 15 Jun 2007 18:17:37 +1000

This may be a bug. I'd be interested in other opinions. If anyone has a
copy of "TCP Illustrated" it may be worth checking this in there.

I'm not using lwIP's TCP yet, but I've had a lot of experience with the
XINU TCP stack as documented here:

http://groups.google.com/group/comp.os.xinu/browse_thread/thread/989aee1
7db979996/
http://groups.google.com/group/comp.os.xinu/browse_thread/thread/51a37b3
de4339a0a/

The "silly window avoidance" code in tcp_output_segment() is as follows:

  /* silly window avoidance */
  if (pcb->rcv_wnd < pcb->mss) {
    seg->tcphdr->wnd = 0;
  } else {
    /* advertise our receive window size in this TCP segment */
    seg->tcphdr->wnd = htons(pcb->rcv_wnd);
  }

I think I can see two problems with the above.

Firstly, assume data is arriving in small chunks and is not being
removed, so the window is getting smaller. Now when (pcb->rcv_wnd <
pcb->mss), all of a sudden the window slams shut to zero.

This is mentioned in section "Managing the Window" on Page 42 of the TCP
RFC:

    ftp://ftp.rfc-editor.org/in-notes/rfc793.txt

    The mechanisms provided allow a TCP to advertise a
    large window and to subsequently advertise a much
    smaller window without having accepted that much
    data.  This, so called "shrinking the window,"
    is strongly discouraged.

In the updated specs, on Page 91:

    ftp://ftp.rfc-editor.org/in-notes/rfc1122.txt

    4.2.2.16  Managing the Window: RFC-793 Section 3.7, page 41

       A TCP receiver SHOULD NOT shrink the window, i.e., move the
       right window edge to the left.

"SWS Avoidance" is documented in section "4.2.3.3  When to Send a Window
Update" of RFC1122.

The window should only shrink "naturally" (because of incoming data).
SWS Avoidance delays the window OPENING until it can be opened EITHER to
the MSS or to half of the receive buffer size. The lwIP code is only
performing the former comparison.

The second (obvious) problem would happen if someone did the following
in lwipopts.h while trying to save memory or buffers:

    /* TCP Maximum segment size. */
    #define TCP_MSS                 512
    /* TCP receive window. */
    #define TCP_WND                 500

This is because these are then loaded into:

    pcb->rcv_wnd = TCP_WND;
    pcb->mss = TCP_MSS;

Following RFC1122 and adding the comparison against half the buffer size
would avoid this problem as well. Alternately,  a compile-time assert to
make sure that (TCP_WND >= TCP_MSS) would catch this.

=== 
Tom Evans

- The contents of this email, and any attachments, are strictly private and 
confidential.
- It may contain legally privileged or sensitive information and is intended 
solely for the individual or entity to which it is addressed.
- Only the intended recipient may review, reproduce, retransmit, disclose, 
disseminate or otherwise use or take action in reliance upon the information 
contained in this email and any attachments, with the permission of Australian 
Arrow Pty. Ltd.
- If you have received this communication in error, please reply to the sender 
immediately and promptly delete the email and attachments, together with any 
copies, from all computers.
- It is your responsibility to scan this communication and any attached files 
for computer viruses and other defects and we recommend that it be subjected to 
your virus checking procedures prior to use.
- Australian Arrow Pty. Ltd. does not accept liability for any loss or damage 
of any nature, howsoever caused, which may result directly or indirectly from 
this communication or any attached files. 




reply via email to

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