lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] Re: [lwip] Newbie TCP problem


From: Adam Dunkels
Subject: [lwip-users] Re: [lwip] Newbie TCP problem
Date: Thu, 09 Jan 2003 01:16:01 -0000

Hi Andy and other list members!

I hope you all have had lovely christmas and new years holidays! Here in 
Sweden we had a beautifully white christmas all over the country with 
temperatures as far down as -30 degrees Celsius in some parts. Needless to 
say, this caused problems for both air traffic and the trains. There are 
still major problems with the trains here in the Stockholm area but at least 
the weather is nice (sunshine, bright white snow, and -5 degrees)!

On Friday 21 December 2001 17.41, you wrote:
> I am porting lwip to a device that uses a Motorola 850 PowerPC. I am very
> new to TCP/IP and have run accross a problem which has me baffled: When
> sending data down a connection to lwip, the first 1536 bytes arrive OK in
> my app then the sender stops sending data packets.
>
> The TCP client opens a socket from a RedHat Linux PC. It does not matter if
> the data is written into the socket in 64 byte chunks with 1 second gaps
> between them or all at once, the same problem occurs.
>
> The sequence of events:
>
> The TCP connection is established.
>   The PC-app starts sending data packets.
>   lwip responds to the messages with ACK.
> The above repeats until around 1536 bytes of data have been sent
> The PC-app then sends a packet with ACK set and no data The sequence number
> of this packet is 1 less than the ack_seq value last sent to it from the
> device.
> lwip does not respond
> The PC-app then continues to send the same message out at increasing
> intervals.
> lwip does not respond
>
> Restarting the PC app, re-establishes the connection and the above sequence
> repeats. There is no need to restart lwip.
>
> Any clues as to what I might be doing wrong would be greatly appreciated.

This problem is because lwIP does not respond to TCP "keep-alives" as it 
should. I noticed this myself the other day - an idle telnet connection to 
lwIP was killed after about two hours. Thanks for spotting it nevertheless.

The TCP "keep-alive" mechanism is designed to kill connections that are 
frozen because the other end of the connection has crashed (hence the 
mechanism really should be called something else than "keep-alive"). TCP 
sends one empty segment with sequence number that is 1 less than the next 
sequence number to be expected. This segment should be responded to with an 
ACK, but lwIP version < current CVS does not respond to empty segments at 
all. 

The solution is to add the following code to the end of tcp_input.c (the 
tcp_receive() function):

  } else {
    /* Segments with length 0 is taken care of here. Segments that
       fall out of the window are ACKed. */
    if(TCP_SEQ_GT(pcb->rcv_nxt, seqno) ||
       TCP_SEQ_GEQ(seqno, pcb->rcv_nxt + pcb->rcv_wnd)) {
      tcp_ack_now(pcb);
    }      

There should be two curly braces after this code (the else corresponds to the 
if(seg->len > 0).

/adam
-- 
Adam Dunkels <address@hidden>
http://www.sics.se/~adam
[This message was sent through the lwip discussion list.]




reply via email to

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