[lwip-users] Pbuf_cat and pbuf_free question

2017-10-09 Thread Mike Rosing

I'm not sure if my problem is a memory leak or buffer overflow since the error occurs in system free() with garbage in the memory chain.  The difference I've added (among other things) is the use of PBUF_REF and pbuf_cat().  The following sequence works fine, but is it correct?ref = pbuf_alloc(PBUF_RAW, 1024, PBUF_REF);ref->payload = upptr;pbuf_cat(head, ref);udp_sendto(udp_raw, head, server, port);pbuf_free(head);I do NOT have pbuf_free(ref) because according the manual I'm not supposed to reference it again after using pbuf_cat().  Am I creating a memory leak, or is this OK?Mike 
 

___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Re: [lwip-users] time out on last ack

2017-08-09 Thread Mike Rosing

At one point I set up an increment of 10 seconds per check, so 10, 20 , 30 ... and it would never reconnect even after a minute.  For my purposes the "REUSE" was important - same IP address, same port.  And re-establishing connection quickly (within 10 seconds) was also important.  It did not seem to matter how long I waited, the "INUSE" error always came up and it confused me because the SO_REUSE compile flag was set.  Now it does reuse it after 1 second wait and using tcp_abandon().  I'm happy!MikeOn August 9, 2017 at 9:48 AM goldsimon  wrote:Mike Rosing wrote: > After searching a while I see that the LwIP is waiting for LAST_ACK, but the server never sends it.  I would have expected lwip to time out this PCB eventually (although that can need quite some time). How long did you wait?  Simon___lwip-users mailing listlwip-users@nongnu.orghttps://lists.nongnu.org/mailman/listinfo/lwip-users
 

___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

[lwip-users] time out on last ack

2017-08-09 Thread Mike Rosing

A couple weeks ago I posted this question:"I have a situation where the LwIP is a client and I have compiled with SO_REUSE = 1, but the reconnect fails with error -8 (in use).  After searching a while I see that the LwIP is waiting for LAST_ACK, but the server never sends it.  What can I do to force the internal pcb's to timeout and just allow a reconnect to proceed instead of thinking the connection is still live?"The answer is to use tcp_abandon() when the pcb->state == 9.  This removes the pcb from the "time wait" list and allows the connection to re-establish.  For anyone's future reference if you have a similar problem.Mike
 

___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

[lwip-users] time out on last ack

2017-07-28 Thread Mike Rosing

I have a situation where the LwIP is a client and I have compiled with SO_REUSE = 1, but the reconnect fails with error -8 (in use).  After searching a while I see that the LwIP is waiting for LAST_ACK, but the server never sends it.  What can I do to force the internal pcb's to timeout and just allow a reconnect to proceed instead of thinking the connection is still live?Thanks.Mike
 

___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Re: [lwip-users] ARP message stops TCP?

2017-07-20 Thread Mike Rosing

After some online digging it looks like I will have problems to work on eventually - for the moment things are working.  The call backs are inside the interrupt level, the calls to the library are in the main loop.  I don't know what the priority levels are for the interrupts, or if this system allows nesting, so I suspect I'll see weird problems eventually.Thank you for the warning - when the time comes to rewrite (which always happens!) that will be on top of the list.MikeOn July 20, 2017 at 2:52 PM "goldsi...@gmx.de"  wrote:Mike Rosing wrote:I do think the call backs are inside the interruptEhrm, unless everything in lwIP runs on that interrupt level and *not*in main loop (or a thread), that's OK. If not, sooner or later, you'llget a problem!, but the total time is 10's of microseconds and the system responsetime is milliseconds, so it should not be an issue.This doesn't depend on the callback run time vs. system response time.If it just happens that lwIP is processing timers while your callbackfires, you'll have a problem.In the end, just don't try to use a library in a way that it wasn'tmeant to!Simon___lwip-users mailing listlwip-users@nongnu.orghttps://lists.nongnu.org/mailman/listinfo/lwip-users
 

___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Re: [lwip-users] ARP message stops TCP?

2017-07-20 Thread Mike Rosing

Thank you - I have not seen that page.  I will check into that.I did change the delay time between messages from minutes to seconds, and then the system works fine.  I have also tried a completely different approach using UDP only, and LwIP works fine, Linux fails to receive what LwIP sends.  So I think the problems I have are not on the LwIP side.  I do think the call backs are inside the interrupt, but the total time is 10's of microseconds and the system response time is milliseconds, so it should not be an issue.  But it is easy enough to measure and double check.At this point I think LwiP is pretty solid.  Now that I understand how it works it is more robust than the rest of my system!MikeOn July 20, 2017 at 2:07 PM "goldsi...@gmx.de"  wrote:Mike Rosing wrote:I have a strange problem where raw API LwIP (2.0.2) seems to work most of the time but appears to randomly stop.  So I put wireshark up and looked at the messages between LwIP and the server it was talking to.  From the description of your program, it sounds like your problem could well be that you're violating lwIP's threading requirements. Have you read the documentation on how lwIP must be used (e.g. http://www.nongnu.org/lwip/2_0_x/pitfalls.html)?  Simon ___lwip-users mailing listlwip-users@nongnu.orghttps://lists.nongnu.org/mailman/listinfo/lwip-users
 

___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

[lwip-users] ARP message stops TCP?

2017-07-17 Thread Mike Rosing

I have a strange problem where raw API LwIP (2.0.2) seems to work most of the time but appears to randomly stop.  So I put wireshark up and looked at the messages between LwIP and the server it was talking to.My system waits for a time range from the server, does a calculation using that time as a pair of pointers into a large block of RAM and then sends the result back to the server.  If an ARP message happens before this begins there are no problems.  But if an ARP message happens while I'm doing the calculation, I can never send the data to the server.Error checking on tcp_write() and tcp_output() always gives ERR_OK.  I use tcp_sent to set a callback, and when it does not get called after 6 seconds I call tcp_output() again.  After 15 tries, I give up and close the connection.Here is a wireshark summary where it works:245    13598.007929140    Dell_ff:f5:5a    LogicPro_03:6a:c6    ARP    42    Who has 192.168.1.18? Tell 192.168.1.13246    13598.008196524    LogicPro_03:6a:c6    Dell_ff:f5:5a    ARP    60    192.168.1.18 is at 00:08:ee:03:6a:c6247    13941.860230081    192.168.1.13    192.168.1.18    TCP    88    41177 → 41177 [PSH, ACK] Seq=1767318291 Ack=45 Win=29200 Len=34248    13941.860460015    192.168.1.13    192.168.1.18    TCP    88    [TCP Retransmission] 41177 → 41177 [PSH, ACK] Seq=1767318291 Ack=45 Win=29200 Len=34249    13942.679840223    192.168.1.13    192.168.1.18    TCP    88    [TCP Retransmission] 41177 → 41177 [PSH, ACK] Seq=1767318291 Ack=45 Win=29200 Len=34250    13942.680185640    192.168.1.18    192.168.1.13    TCP    60    41177 → 41177 [ACK] Seq=45 Ack=1767318325 Win=5898 Len=0251    13944.948207758    192.168.1.18    192.168.1.13    TCP    76    [TCP Retransmission] 41177 → 41177 [PSH, ACK] Seq=45 Ack=1767318325 Win=5898 Len=22252    13944.948240490    192.168.1.13    192.168.1.18    TCP    54    41177 → 41177 [ACK] Seq=1767318325 Ack=67 Win=29200 Len=0In this case LwIP took a while to ACK the message (LwIP on .18) and several seconds to do the computation, and then it sent back the answer.Here is a wireshark summary where it fails:263    15129.006878304    192.168.1.13    192.168.1.18    TCP    88    41177 → 41177 [PSH, ACK] Seq=1767318393 Ack=111 Win=29200 Len=34264    15129.007133951    192.168.1.13    192.168.1.18    TCP    88    [TCP Retransmission] 41177 → 41177 [PSH, ACK] Seq=1767318393 Ack=111 Win=29200 Len=34265    15132.471845070    192.168.1.13    192.168.1.18    TCP    88    [TCP Retransmission] 41177 → 41177 [PSH, ACK] Seq=1767318393 Ack=111 Win=29200 Len=34266    15132.472195643    192.168.1.18    192.168.1.13    TCP    60    41177 → 41177 [ACK] Seq=133 Ack=1767318427 Win=5796 Len=0267    15134.007797724    Dell_ff:f5:5a    LogicPro_03:6a:c6    ARP    42    Who has 192.168.1.18? Tell 192.168.1.13268    15134.008057081    LogicPro_03:6a:c6    Dell_ff:f5:5a    ARP    60    192.168.1.18 is at 00:08:ee:03:6a:c6269    15221.737092479    192.168.1.18    192.168.1.13    TCP    60    [TCP Retransmission] 41177 → 41177 [FIN, ACK] Seq=133 Ack=1767318427 Win=5796 Len=0The code times out and says the write failed because it called tcp_write() and then tcp_output() 15 times - and the data was never sent.I think I can force this to work by closing the server side on a timeout (and probably reducing the number of tries on the client side before giving up).  I hope that I have something stupid set in the opt.h or lwipopts.h files.I suspect the ARP messages just happen to be a clue, not a cause, but I do not know enough about how network protocols are supposed to work.  Any ideas on what the problem could be?Thanks,Mike
 

___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Re: [lwip-users] SNTP example?

2017-05-02 Thread Mike Rosing

Thanks Simon!I did try wireshark, but did not see anything to my IP.  So I looked at the address it was trying to use for the NTP server, and found it was pointing to my gateway (which is what the example did).  I changed that to point to a real NTP server found on the NIST web site and then sntp_process was called.  I did not know about lwip_stats, so that is a great help, I will check that.I can at least now set my RTC when the program starts.  The next test will be to see if it goes out once an hour.  Now I can put LwIP to work talking to other custom servers.  I think that will be simpler, but if I run into problems I will be back with more questions.MikeOn May 2, 2017 at 2:47 PM "goldsi...@gmx.de"  wrote:Mike Rosing wrote:The SNTP seems to initialize ok, but the routine sntp_process() is never called.Have you checked (e.g. using wireshark) that SNTP requests are sent andresponses are received? If not, sntp_process() won't get called either.If the response is received, check "lwip_stats" to see if there are any"err" counters going up. If not, try adding a breakpoint to udp_input()when the response is received and see where it goes.Simon___lwip-users mailing listlwip-users@nongnu.orghttps://lists.nongnu.org/mailman/listinfo/lwip-users
 

___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Re: [lwip-users] SNTP example?

2017-04-30 Thread Mike Rosing
The SNTP seems to initialize ok, but the routine sntp_process() is never 
called.  I did check my millisecond timer is working (it wasn't when I started) 
so the timeouts should be working correctly.  I know the initial sntp_request() 
is executed, but I have no idea how to proceed with debugging from there.  How 
do I figure out what is broken?  Any hints greatly appreciated!
Thanks,
Mike


> On April 29, 2017 at 7:35 PM Mike Rosing <mros...@vitalmetric.com> wrote:
> 
> 
> Found it - I'm definitely not even close.  I will probably be back with more 
> questions after I beat my head on the wall for a while.
> 
> Thank you!
> Mike
> 
> > On April 29, 2017 at 4:43 PM Dirk Ziegelmeier <d...@ziegelmeier.net> wrote:
> > 
> > 
> > Look AG lwip contrib repository, Unix port, simhost.c. There is an example
> > in there.
> > 
> > Dirk
> > 
> > On Apr 29, 2017 23:17, "Mike Rosing" <mros...@vitalmetric.com> wrote:
> > 
> > Hello,
> > 
> > I have ported 2.0.2 to the TI C6748 and finally got DHCP to get an
> > address.  The next thing I'd like to do is use sntp.  What do I do after
> > calling sntp_init()?
> > 
> > I did add sys_now() so there is a millisecond timer running.  The port is
> > copied from the version 1.3.2 example given in the C6748 Starterware.  I'm
> > pretty sure it all works, I'm just clueless as how to use the sntp.c
> > subroutines so I can set my RTC once an hour.
> > 
> > Any help/pointers on how to use the code would be greatly appreciated.
> > Mike
> > 
> > ___
> > lwip-users mailing list
> > lwip-users@nongnu.org
> > https://lists.nongnu.org/mailman/listinfo/lwip-users
> > ___
> > lwip-users mailing list
> > lwip-users@nongnu.org
> > https://lists.nongnu.org/mailman/listinfo/lwip-users
> 
> ___
> lwip-users mailing list
> lwip-users@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/lwip-users

___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users


Re: [lwip-users] SNTP example?

2017-04-29 Thread Mike Rosing
Found it - I'm definitely not even close.  I will probably be back with more 
questions after I beat my head on the wall for a while.

Thank you!
Mike

> On April 29, 2017 at 4:43 PM Dirk Ziegelmeier <d...@ziegelmeier.net> wrote:
> 
> 
> Look AG lwip contrib repository, Unix port, simhost.c. There is an example
> in there.
> 
> Dirk
> 
> On Apr 29, 2017 23:17, "Mike Rosing" <mros...@vitalmetric.com> wrote:
> 
> Hello,
> 
> I have ported 2.0.2 to the TI C6748 and finally got DHCP to get an
> address.  The next thing I'd like to do is use sntp.  What do I do after
> calling sntp_init()?
> 
> I did add sys_now() so there is a millisecond timer running.  The port is
> copied from the version 1.3.2 example given in the C6748 Starterware.  I'm
> pretty sure it all works, I'm just clueless as how to use the sntp.c
> subroutines so I can set my RTC once an hour.
> 
> Any help/pointers on how to use the code would be greatly appreciated.
> Mike
> 
> ___
> lwip-users mailing list
> lwip-users@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/lwip-users
> ___
> lwip-users mailing list
> lwip-users@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/lwip-users

___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users


[lwip-users] SNTP example?

2017-04-29 Thread Mike Rosing

Hello,I have ported 2.0.2 to the TI C6748 and finally got DHCP to get an address.  The next thing I'd like to do is use sntp.  What do I do after calling sntp_init()?  I did add sys_now() so there is a millisecond timer running.  The port is copied from the version 1.3.2 example given in the C6748 Starterware.  I'm pretty sure it all works, I'm just clueless as how to use the sntp.c subroutines so I can set my RTC once an hour.Any help/pointers on how to use the code would be greatly appreciated.Mike
 

___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users