ARP interfering with TCP server??

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

ARP interfering with TCP server??

beach.dk

Hi there,

I've got a bug in my embedded product that is using lwip and maybe some out
there can help me find out if the bug is located in my code or in lwip.

My application is a TCP server that I've based on the 'raw api' httpd example.
http://savannah.nongnu.org/cgi-bin/viewcvs/lwip/contrib/ports/msvc6/httpd.c
(my application is not a web server but basically it does the same 'command/answer')

The difference is that the webserver example closes the connection after each request
which my server doesn't. (I think a mordern webserver does/should not close the connection
automatially if there is a "Connection: keep-alive" present in the HTTP header)


The bug has to do with if there is need for an ARP request/reply before the command/answer
to an existing TCP connection.

Here is an example:

1) The very first Command/Answer:
   I can see that an ARP request/reply is executed successfully.
   I can see that the listening port creates a connection.
   I can see that the command/answer is executed.
   Success.

2) The second,3:rd, 4:th...... Command/Answer:
   I can see that the command/answer is executed.
   Success.

3) Wait until the entry (in the PC arp table) is deleted (2 minutes in windows XP)
   or delete is manually.

4) Another Command/Answer
   I can see that an ARP request/reply is executed successfully.
   Everything stops....


The problem is related to the ARP becuase if I add a static entry in the ARP table
it never fails.

Also it never fails for 'Commands' smaller that 129 bytes. This made me think that
it had something to do with signed/unsigned chars but I've compiled my code with both types.

If I enable debug I can see that
 "pbuf_free: 0x2000276c has ref 1, ending here."
is outputed, but that does not help *me* understand what the bug/problem is.

So has anyone out there experinced this or maybe has possibilty to test this with
your implementation of lwip.

Regards
/Per/
 

_______________________________________________
lwip-users mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: ARP interfering with TCP server??

Christiaan Simons
lwip-users-bounces+christiaan.simons=[hidden email] wrote on 24-10-2005
18:05:39:

> I've got a bug in my embedded product that is using lwip and maybe some
out
> there can help me find out if the bug is located in my code or in lwip.

Can you be more precise, can it also be in your contrib/port?

Some of them were created against an ancient lwip, without properly
releasing them for a specific version.

> My application is a TCP server that I've based on the 'raw api' httpd
example.
>
http://savannah.nongnu.org/cgi-bin/viewcvs/lwip/contrib/ports/msvc6/httpd.c

> (my application is not a web server but basically it does the same
> 'command/answer')
> The difference is that the webserver example closes the connection
> after each request which my server doesn't.

Beware that you are eating resources when more connections are made.

> 4) Another Command/Answer
>    I can see that an ARP request/reply is executed successfully.
>    Everything stops....
>
> The problem is related to the ARP becuase if I add a static entry in
> the ARP table it never fails.

ARP code in lwip works fine as far as I know. You say
everything stops? Can you use a debugger to see where it halts?
E.g. are your tcp timers still running? Are there more incoming packets?

Maybe it has something todo with lwip memory management. Reading
your remarks below it smels like a memory or pbuf chain issue.

Pbufs that carry the datagrams or segments are ususally about 128 bytes for
most example code. Multiple chained pbufs are required to receive or send
more than 128 bytes.
When these chains aren't handled (freed) properly, you get into all sorts
of problems.

> Also it never fails for 'Commands' smaller that 129 bytes. This made
> me think that
> it had something to do with signed/unsigned chars but I've compiled
> my code with both types.

Please let your compiler use both types (chars = signed),
lwip uses more explicit typedefs.

> If I enable debug I can see that
>  "pbuf_free: 0x2000276c has ref 1, ending here."

That only tells some pbuf memory was freed.
The "ending here" can be a bit misleading, the code will continue,
only the pbuf_free() will end at some point in the pbuf chain.

> So has anyone out there experinced this or maybe has possibilty to
> test this with
> your implementation of lwip.

I cannot verify this port since I don't run the MS compiler (or OS).

> Regards
> /Per/

Bye,
Christiaan.



This email and any files transmitted with it are confidential and intended
solely for the use of the individual or entity to whom they are addressed.
If you have received this email in error please notify the system manager.
This message contains confidential information and is intended only for the
individual named.  If you are not the named addressee you should not
disseminate, distribute or copy this e-mail.



_______________________________________________
lwip-users mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/lwip-users