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

Submitted by:  Ingo Ferchland <ferch>
Submitted on:  Fri 27 Aug 2010 03:05:38 PM UTC  
 
Category: TCPSeverity: 3 - Normal
Item Group: Crash ErrorStatus: Fixed
Privacy: PublicAssigned to: None
Open/Closed: ClosedPlanned 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>
Project Administrator
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>
Project Administrator
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>

 

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
  • -unavailable- added by karsten (Updated the item)
  • -unavailable- added by kieranm (Posted a comment)
  • -unavailable- added by ferch (Submitted the item)
  • -unavailable- added by ferch
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 7 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 30 Sep 2010 11:08:19 AM UTCkieranmStatusNeed Info=>Fixed
      Open/ClosedOpen=>Closed
    Tue 14 Sep 2010 04:43:10 PM UTCkarstenAttached File-=>Added sys_thread_new.c, #21457
    Fri 27 Aug 2010 03:42:37 PM UTCkieranmStatusNone=>Need Info
    Fri 27 Aug 2010 03:09:19 PM UTCferchAttached File-=>Added telnet_wireshark.log, #21323
    Fri 27 Aug 2010 03:05:38 PM UTCferchAttached File-=>Added task.c, #21322
      Carbon-Copy-=>Added ferch

    Back to the top


    Powered by Savane 3.1-cleanup1