[En-Nut-Discussion] telnet crashes when recieving data at high rate

Sander Smeenk sandersmeenk at hotmail.com
Wed Jun 8 13:55:46 CEST 2005


Hey,

(This one's probably for Harald ;) )

I use the telnet server from the "tcps" example project.
In my project I have one telnet thread running, and multiple other threads 
that might block the telnet thread for (for example) longer dan 0,5 sec.

When I connect to the telnet server using Microsoft Windows's Hyperterminal 
and I send a big plaintext file to the ethernut, it crashes when other 
threads block the telnet thread from running. I monitored the datarate to 
the ethernut, and it is constantly about 20 kbytes/sec.

After some examining I found out (forgive me if I'm wrong) that when an 
other thread is running (and telnet is blocked), hyperterminal continues to 
send data (quite obvious). And because it can't be handled by the telnet 
thread, this recieved data is stored on the heap until it is read by (for 
example) fgets(). At least, this is what I think, because when the other 
thread runs, the the free heap size keeps decreasing, until I read some from 
the telnet stream using "fgets()".

Now, my question is: why does the ethernut store all this data on the heap? 
Why doesn't it just discard it when there is not enough free heap space? In 
that case, the PC doesn't get an acknowlegde and sends it again. Or is this 
not the way it works?

And my main question: how can I prevent the ethernut from crashing? Is there 
a way to implement somekind of flowcontrol, like <CTRL><Q> with RS232? Or 
can I configure the tcp/ip stack somehow to prevent this crash?

I use:
<code>

#define TCPIP_BUFSIZ 1024
u_short siz = TCPIP_BUFSIZ;
NutTcpSetSockOpt(sock, SO_RCVBUF, &siz, sizeof(siz));

</code>

to set the tcp/ip buffer size to 1024. Haven't changed any other params.

Furthermore, I use WinAVR 2004-0720 (gcc version 3.4.1) and Nut/OS version 
3.9.5.1 pre.

Thanx in advance!
Sander.





More information about the En-Nut-Discussion mailing list