buglwIP - A Lightweight TCP/IP stack - Bugs: bug #30889, lwIP hangs on sending small...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #30889: lwIP hangs on sending small packages

Submitter:  Ingo Ferchland <ferch>
Submitted:  Fri 27 Aug 2010 03:05:38 PM UTC
   
 
Category:  TCP Severity:  3 - Normal
Item Group:  Crash Error Status:  Fixed
Privacy:  Public Assigned to:  None
Open/Closed:  Closed Planned Release:  None
lwIP version:  CVS Head

Thu 30 Sep 2010 11:42:05 AM UTC, comment #5: 

The TCP_NODELAY or TF_NODELAY flag is an workaround only!

There is still an problem with the Nagle Algorithm, that should investigated.

Regards Ingo

Ingo Ferchland <ferch>
Thu 30 Sep 2010 11:08:19 AM UTC, comment #4: 

Looks like this is solved.  Resolving fixed.

Kieran Mansley <kieranm>
Group Member
Sat 18 Sep 2010 10:11:45 PM UTC, comment #3: 

Hello Karsten,

I can confirm that a TCP_NODELAY flag solves the problem.
After
pxTelnetConn = netconn_accept(pxTELNETListener);

I inserted a
pxTelnetConn->pcb.tcp->flags |= TF_NODELAY;

with success - Thank you very much!

And yes, sys_thread_new() sets the priority immediately on task creating. (Source: lwip-port/AT32UC3A/sys_arch.c; AVR-UC3-SoftwareFramework-1.7.0 Release)

I changed it according your attachment, thank you very much again.

Regards Ingo

Ingo Ferchland <ferch>
Tue 14 Sep 2010 04:43:10 PM UTC, comment #2: 

Ingo, I've seen the same strange behaviour as you when using the FreeRTOS port that is provided with the lwIP contrib. It seems to be the Nagle Algorithm: When sending small amounts of data in short intervals, data is enqueued to form a potentially bigger data packet to unload the line from protocol overhead. However, if the queue filled up too quick, I observed an internal dead-lock of the task. For sockets, you can disable the Nagle Algorithm by setting the flag "TCP_NODELAY" using
int on = true;
setsockopt( connection, IPPROTO_TCP, TCP_NODELAY, (char *) &on, sizeof( on ));
There is a similar flag for NETCONN. For my application setting this flag solved the problem, however, it produces a quite big protocol overhead on the network when sending single characters in a TCP packet each...
Can you please test the flag with your application and report your results?
BTW: Please check, if your sys timeouts are running properly. It seems, that the available FreeRTOS port (and I assume that your version is based on it) does not initialize the timeout struct correctly, if you initialize lwIP from within a task that has a lower priority than the lwIP task itself (i.e. sys_thread_new() is executed with a lower priority than that of the task to be created). See the attached file for a solution.
Please tell us, if this helped.

(file #21457)

Karsten Weiss <karsten>
Fri 27 Aug 2010 03:42:37 PM UTC, comment #1: 

My guess is that this is a bug in the port rather than in lwIP itself, but as I don't have access to that port or any way to run it I can't try to reproduce this to verify it.

As you can reproduce it it would be helpful if you can dig a little deeper and try and work out what is going wrong.

Kieran Mansley <kieranm>
Group Member
Fri 27 Aug 2010 03:05:38 PM UTC, original submission:  

I use the ATMEL AVR32 lwIP port with FreeRTOS. The error occured on version 1.32 and CVS Head too.

Attached a slightly modified example "tcpecho".
To crash lwip, set the line 32 in the example to "#if 1" and send with Win32 Hyperterm Application some text quickly. (Insert some text in the Hypertem window with CTRL+V)

After some text (about 50 chars), lwIP will hang at sys_arch_sem_wait() trying to get the semaphore "op_completed" for the last netconn_write.

The error does not occur with the linux telnet client! (Sending too slow?)


Ingo Ferchland <ferch>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #21457:  sys_thread_new.c added by karsten (1KiB - text/x-csrc)
file #21323:  telnet_wireshark.log added by ferch (4KiB - text/x-log)
file #21322:  task.c added by ferch (1KiB - text/x-csrc)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by karsten (Updated the item)
  • -email is unavailable- added by kieranm (Posted a comment)
  • -email is unavailable- added by ferch (Submitted the item)
  • -email is unavailable- added by ferch
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2010-09-30 kieranm StatusNeed Info Fixed
        Open/ClosedOpen Closed
    2010-09-14 karsten Attached File- Added sys_thread_new.c, #21457
    2010-08-27 kieranm StatusNone Need Info
    2010-08-27 ferch Attached File- Added telnet_wireshark.log, #21323
    2010-08-27 ferch Attached File- Added task.c, #21322
        Carbon-Copy- Added ferch

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code