lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] Limiting the number of connections: Possible bug with MEMP_


From: Tony
Subject: [lwip-users] Limiting the number of connections: Possible bug with MEMP_NUM_TCP_PCB?
Date: Thu, 3 Aug 2017 10:29:47 +0200

Hello,

I am trying to fix a strange behavior I have with LWIP...

Quite possibly I am using the LWIP wrongly, but I am not sure. I took over the maintaining of a embedded project which includes LWIP, and unfortunately I have some problems with networking (and I now face a steep learning curve, as LWIP has been integrated by someone else, and I know not enough about networking...).

I updated from 1.3.2 (which was used before) to 2.0.2. This helped with one problem I had - but introduced another.

Our application offers one port for SCPI connections.

The aim is to only allow n open TCP connection at a time, and reject all further connection requests. This worked reasonably well in 1.3.2, but now fails in 2.0.2.

I set the maximum number "n" of TCP PCBs like this, e.g. 4:

#define MEMP_NUM_TCP_PCB 4

The problematic behavior is this:
The first n connections work fine (in this example 1 to 4), and can be used simultaneously (I leave all 4 connections open).

The n+1 connection itself works fine (5th connection in this example), HOWEVER: this n+1 connection terminates the very 1st connection (takes over the 1st PCB?).

Now, if I leave all previous connections open and make a n+1 connection (the 6th connection in this example) I hit an exception (the processor tries to access memory that does not exists and I hit the exception handler in the MCU).

I narrowed down the origin of the fatal exception in tcp_alloc() to the code following this comment:
/* zero out the whole pcb, so there is no need to initialize members to zero */

The problem at that point seems to be that a struct tcp_pcb_listen (that is still in use) is reused and overwritten as a struct tcp_pcb...

However, as I have written above, something else goes wrong before that, when the n+1 connection is made. (possibly in tcp_alloc(), when tcp_kill_prio(prio); is called?)

Is there a way to simply "tell" LWIP to "refuse" further connections?

Are there things that I might have missed that need to be changed in my application, when going from 1.3.2 to 2.0.2?

And I would be most grateful for any further hints, e.g. about things I might have missed, typical errors when using LWIP, pointers to tutorials to use, and so on!

Kindest regards,
Tony


reply via email to

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