EmbeddedRelated.com
Forums

Problem with NicheLite TCP/IP stack

Started by tprochownik September 12, 2008
Hello.

I have downloaded NicheLite TCP/IP stack for LPC200 from Inter Niche.
I have compiled example project (included in source) with Keil
uVision and downloaded it into MCB2300 eval board.

Let's start:

NicheLite for LPC, v3.0
Copyright 1997-2006 by InterNiche Technologies. All rights reserved.

Unable to open NV Parameters file "webport.nv"
Creating sample file
nv_defaults: set net 0 IP to 0.0.0.0
nv_defaults: set DNS server IP to 10.0.0.70
LPC23xx Auto-negotiation: 100 Mbps, Full Duplex
IP address of if0 : 0.0.0.0
Acquired IP address via DHCP client for interface: if0
IP address : 10.0.2.1
Subnet Mask: 255.0.0.0
Gateway : 10.0.0.100
INET>

Thats OK.
Try to connect with http server...OK. I can see test www page.

Now try something else: run Hyper Terminal and try to connect with
port 80 (IP 10.0.2.1). Ok - it works, disconnect: OK.
But if I repeat this test (connection and at once disconnection)
about 55 times program would stop with message on console:

INET> trap
panic: tk_block stack

I think problem is in dynamic memory allocation. Program allocs
memory block during opening connections, but doesn't free it during
closing.
I coudn't resolve this problem so far, would you help me?
t.pro

An Engineer's Guide to the LPC2100 Series

--- In l..., "tprochownik" <916@...> wrote:
>
> Hello.
>
> I have downloaded NicheLite TCP/IP stack for LPC200 from Inter Niche.
> I have compiled example project (included in source) with Keil
> uVision and downloaded it into MCB2300 eval board.
>
> Let's start:
>
> NicheLite for LPC, v3.0
> Copyright 1997-2006 by InterNiche Technologies. All rights reserved.
>
> Unable to open NV Parameters file "webport.nv"
> Creating sample file
> nv_defaults: set net 0 IP to 0.0.0.0
> nv_defaults: set DNS server IP to 10.0.0.70
> LPC23xx Auto-negotiation: 100 Mbps, Full Duplex
> IP address of if0 : 0.0.0.0
> Acquired IP address via DHCP client for interface: if0
> IP address : 10.0.2.1
> Subnet Mask: 255.0.0.0
> Gateway : 10.0.0.100
> INET> Thats OK.
> Try to connect with http server...OK. I can see test www page.
>
> Now try something else: run Hyper Terminal and try to connect with
> port 80 (IP 10.0.2.1). Ok - it works, disconnect: OK.
> But if I repeat this test (connection and at once disconnection)
> about 55 times program would stop with message on console:
>
> INET> trap
> panic: tk_block stack
>
> I think problem is in dynamic memory allocation. Program allocs
> memory block during opening connections, but doesn't free it during
> closing.
> I coudn't resolve this problem so far, would you help me?
>

Your board is a TCP server, yes?

How often are you connecting/disconnecting? TCP will hang on to
socket endpoints for a while after a disconnect to ensure that late,
out-of-order segments and any remnants of the four-way disconnect
handshake are securely dumped and so cannot become part of any new
connection.

If you connect/disconnect continually at a rate consistently greater
than this disconnect timeout, your server will run out of ephemeral
sockets because of all these socket descriptors/objects in this
'TIME_WAIT' state.

If your Apache/IIS server gets a burst of connect/disconnect, it
doesn't matter too much because a pool of 20000 sockets takes along
time to become exhausted. With a tiddly uC with a bit of RAM, this
will become a problem very quickly.

The TIME_WAIT timeout can be quite long on some systems and is usually
in the order of minutes, rather than seconds.

**Don't use connect/disconnect protocols**

Don't use them on Windows/Linux unless it's absolutely unavoidable,
(eg. on web servers where the number of interacting clients exceeds
the number of available sockets). Such protocols have very high
latencies but, sadly, they are often used because developers cannot be
bothered to develop a real protocol that can assemble/disassemble
protocol-units to/from byte streams.

On a uC, it's even more important to avoid continual connect/disconnects.

Rgds,
Martin