lwip-users
[Top][All Lists]
Advanced

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

RE: [lwip-users] DNS for socket API


From: Pettinato, Jim
Subject: RE: [lwip-users] DNS for socket API
Date: Fri, 11 Sep 2009 10:39:41 -0400

 

Mathais,

Without enabling stats, it is difficult to guess if a resource issue is causing 
your problems. At first glance, I suspect that only having 6 pbufs in the pool 
could possibly be insufficient, especially if you are on a network with any 
level of broadcast traffic.

At first glance and without the benefit of any stats info, I would recommend 
increasing the number of pbufs in the pool - and potentially reducing the size 
of each, if memory is an issue. For me, somewhere between 128 and 256-byte 
pbufs seems a good balance between not wasting memory allocating large pbufs 
for small packets (the majority of traffic seems to consist of packets smaller 
than this range), and not wasting too much time chaining multiple pbufs for 
larger packets. I use 128 byte pbufs since much of the network traffic to our 
devices is Modbus/TCP or proprietary command/response type transfers smaller 
than that size.

Also, I agree a static buffer is probably right - it's the safest option if you 
have a finite small number of entries to populate. 

Hope this helps,

- Jim
 

-----Original Message-----
From: Mathias Zenger [mailto:address@hidden 
Sent: Thursday, September 10, 2009 11:07 AM
To: Pettinato, Jim; Mailing list for lwIP users
Subject: AW: [lwip-users] DNS for socket API

I am afraid I need your help again. My call to gethostbyname() still doesn't 
return the desired IP address. The DNS request was sent out to the DNS server 
and it returned a correct packet with the resolved address. However, this reply 
doesn't seem to arrive in my application. At least dns_recv() is never called. 
After three more tries gethostbyname() returns with the error -8 because there 
was no address available (timeout).

Unfortunately I am not that familiar with lwIP's debug options and with stats. 
As far as I see stats and some of the debug helps are enabled in my port. Where 
could I see the results if something would have been stated?

My application uses UDP, DHCP, IGMP and DNS with the socket API. Because it 
could be a problem with the available ressources here are some of my 
definitions in lwipopts.h:

#define MEMP_NUM_PBUF           6
#define MEMP_NUM_RAW_PCB        1

#define LWIP_UDP                1
#define UDP_TTL                 255

#define MEMP_NUM_UDP_PCB        6

#define MEMP_NUM_SYS_TIMEOUT    6

#define MEMP_NUM_NETBUF         3
#define MEMP_NUM_NETCONN        4

#define PBUF_POOL_SIZE          6
#define PBUF_POOL_BUFSIZE       500
#define PBUF_LINK_HLEN          16

The following definition is in opt.h (probably right):

/** DNS use a local buffer if DNS_USES_STATIC_BUF=0, a static one if
    DNS_USES_STATIC_BUF=1, or a dynamic one if DNS_USES_STATIC_BUF=2.
    The buffer will be of size DNS_MSG_SIZE */ #ifndef DNS_USES_STATIC_BUF
#define DNS_USES_STATIC_BUF             1
#endif






-----Ursprüngliche Nachricht-----
Von: Pettinato, Jim [mailto:address@hidden
Gesendet: Dienstag, 8. September 2009 16:53
An: address@hidden; Mailing list for lwIP users
Betreff: RE: [lwip-users] DNS for socket API



Sorry for assuming the simplest source of your problem - I pretty much strictly 
use the raw API, so am less familiar with the socket / netconn API.

Can you verify that the DHCP-returned DNS server IP is being stored properly? 
It should be stuffed into dns.c's static array variable dns_servers[0].

There are at minimum the following memory requirements for DNS to work...
You need an available UDP pcb, one open entry in the DNS table (i.e.
DNS_TABLE_SIZE large enough for all resolved names) and some free pbufs in the 
pool to send the packet.

Is dns_send() getting called or is it not getting that far?

Do you have stats enabled? Any allocation errors should show up in the 
associated memory structure's stats.


-----Original Message-----
From: address@hidden
[mailto:address@hidden On Behalf Of Mathias Zenger
Sent: Tuesday, September 08, 2009 10:33 AM
To: address@hidden
Subject: WG: [lwip-users] DNS for socket API

Thanks for your hint. I dug even deeper but still wasn't successful. At the end 
I was able to break in

do_dns_found(const char *name, struct ip_addr *ipaddr, void *arg)

This method returns ERR_VAL (-8) which says "timeout or memory error" or 
"illegal value" or "dns server response was invalid" respectively (depending on 
different method comments).

I guess that my name argument is OK. At least my debugger resolves the name 
pointer to "ntpbmt01.dyndns.org" which is the desired server. The second 
argument (addr) gets defined in netconn_gethostbyname(). I am only passing the 
name pointer to gethostbyname(). Could there anyway be a problem with the 
memory (e.g. a missing memory allocation / lwIP configuration setting)?
Still there is no DNS packet output which I would expect to see after the call 
of dns_enqueue()...



-----Ursprüngliche Nachricht-----
Von: Pettinato, Jim [mailto:address@hidden
Gesendet: Freitag, 4. September 2009 17:27
An: address@hidden; Mailing list for lwIP users
Betreff: RE: [lwip-users] DNS for socket API



-8 (ERR_ARG) would appear to indicate that the netconn_gethostbyname() function 
is being passed either a NULL pointer for the name to look up, or a NULL 
pointer for the destination to write the resolved IP address. Check your 
arguments to the call; my guess would be perhaps you are a level of indirection 
off on your addr argument (i.e. passing the value instead of the address of 
your ip_addr variable).


-----Original Message-----
From: address@hidden
[mailto:address@hidden On Behalf Of Mathias Zenger
Sent: Friday, September 04, 2009 10:40 AM
To: Mailing list for lwIP users
Subject: AW: [lwip-users] DNS for socket API

Hi,

I am working on my 'problem' again.

My call of gethostbyname() after a few seconds always returns NULL. I set a 
breakpoint within this function and saw that

err = netconn_gethostbyname(name, &addr);

returns the error code -8. Unfortunately I still don't know what I am doing 
wrong. DHCP works fine and gives the correct DNS server address. LWIP_DNS is 
set to 1. There is no packet output from my device to the DNS server at all (no 
packet captured with Wireshark). Is there a special need to 'somehow handle' 
the DNS server address?

To solve my previous problems I replaced the netdb.c/h files in my stack.
Afterwards the compiler errors/warnings disappeared. Was it a bad idea to just 
replace the two 1.3.0 files by the 1.3.1 version?

Any other ideas? Thanks.
Regards,
Mathias


-----Ursprüngliche Nachricht-----
Von: address@hidden
[mailto:address@hidden Auftrag von address@hidden
Gesendet: Dienstag, 11. August 2009 16:41
An: Mailing list for lwIP users
Betreff: Re: [lwip-users] DNS for socket API


Simon Goldschmidt wrote:
>> In netdb.c I get some warnings for implicit declarations of strlen(),
>> memcpy() and memset(). This probably could indicate a missing 
>> string.h include.
>>
> That could well be as I think the example ports include string.h in 
> their
port-defined cc.h file. Just try to add the missing include in netdb.c until we 
added it to CVS.
>
I've just added #include <string.h> to netdb.c in CVS.
>> The error in netdb.c says 'conflicting types for lwip_gethostbyname_r'.
In
>> netdb.h I get the error messages 'previous declaration of 
>> lwip_gethostbyname_r was here' and 'expected declaration specifiers 
>> or '...'
>> before size_t'
>>
>
> That would mean another standard include is missing in netdb.h. I'll 
> check
that.
>
#include <stddef.h> was added to netdb.h 2 weeks ago.

Simon


_______________________________________________
lwip-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/lwip-users




_______________________________________________
lwip-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/lwip-users




_______________________________________________
lwip-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/lwip-users






reply via email to

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