lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] Question about lwip 's disconnect timeout


From: David Empson
Subject: Re: [lwip-users] Question about lwip 's disconnect timeout
Date: Fri, 11 Jun 2010 10:16:16 +1200

If you are doing connect-transfer-disconnect repeatedly, you won't have a problem if both ends are running LWIP, as long as the number of devices which need to be connected simultaneously isn't too high (which is a factor of available memory for managing the maximum number of TCP connections and data associated with them).

The original article you posted talks about the standard implementation of closed TCP connections, where there is a delay (typically two minutes) at one end of the connection, with the TCP state machine held in the TIME_WAIT state. As noted in the article, this is to allow cleanup of any late arriving or duplicate packets, without possibility of confusing them with a new connection.

LWIP changes the standard behaviour so that if it needs to establish a new TCP connection (incoming or outgoing) but has run out of data structures for TCP connections (TCP PCBs), it will check for any closed connections still in the TIME_WAIT state, and reuse one of those PCBs. This effectively cuts off the two minute TIME_WAIT delay for the old connections. You specify the number of TCP PCBs in your lwipopts.h file. This is typically limited by available memory in your embedded system. It would be a rare embedded system that could have TCP PCBs numbering in the thousands (as well as additional memory to buffer transmit and receive data for thousands of active connections), so the TCP PCBs (maximum simultaneous connections) will run out well before the range of 16-bit port numbers is exceeded.

Reusing PCBs in the TIME_WAIT state opens up a small risk that late arriving repeated packets from the old connection will be confused with a new connection, but that can only happen if the other station's IP address and port number match, and the client's port number isn't normally reused until several thousand new connections have been made. That is almost certainly impossible to achieve within two minutes on a relatively slow embedded server.

It is more likely to be a problem if the client made the unusual decision to bind to a specific port, so it uses a fixed rather than random port number for its end of an outgoing connection. (The server end is almost always bound to a fixed port number, which is not a problem.)

----- Original Message ----- From: "megatron" <address@hidden>
To: <address@hidden>
Sent: Thursday, June 10, 2010 9:33 PM
Subject: Re: [lwip-users] Question about lwip 's disconnect timeout



Thanks kieran for your reply ! but because I'm a newer in TCP/IP and lwip,I
'm still confused.

In my application there is a TCP server on Lpc2368,which is an Arm7
controller with 32K RAM ,a remote computer is client,get data from Lpc2368
via TCP .Currnetly when connected ,it will never disconnect.But there will
be  more and more lpc2368,the computer can't connect so many lpc2368
simultaneously.So it should be changed to connect-disconnect.TO lpc2368,the server,be connected and then disconnected,will it stop responsing because of
the reason described above?




reply via email to

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