Shop OBEX P1 Docs P2 Docs Learn Events
Here is a working example of DNS protocol i've coded for Spinneret — Parallax Forums

Here is a working example of DNS protocol i've coded for Spinneret

QetuooQetuoo Posts: 7
edited 2012-06-11 19:09 in Accessories
Here is a working DNS protocol example.

DNS protocol is used to ask : What is the IP address of "www.parallax.com" ?

This is useful as the IP address of known computer or web site can change anytime. Instead of hard coding the IP address, you ask for the IP address of the named remote computer you wish to access.

The DNS protocol is quite simple : Build the DNS packet and send it to DNS server. If everything's OK, the DNS server reply with almost the same packet with flag and count update and with "reply" section at the end containing one or more IP address for the CNAME you've asked for.
Started using a file "DNS.SPIN" downloaded on the Parallax forum bu can't remember the contributor
The original comment for this file is inside the DNS_Bruno.SPIN

The code work with my ISP DNS server (Videotron.ca), with Google public DNS server (8.8.8.8) and with Simple DNS Plus Software on my computer (my IP address )

Bug note :Some corporate DNS and corporate Firewall seem's to crash the code when i do Receive UDP packet (rxUDP), i'am searching in the WizNet code why. I'am looking at the reported size, timeout or incomplete packet as a possible cause.



Bruno

Comments

  • QetuooQetuoo Posts: 7
    edited 2011-11-23 19:10
    Qetuoo wrote: »
    Here is a working DNS protocol example.
    Bug note :Some corporate DNS and corporate Firewall seem's to crash the code when i do Receive UDP packet (rxUDP), i'am searching in the WizNet code why. I 'm looking at the reported size, timeout or incomplete packet as a possible cause.
    Bruno

    The DNS protocol use UDP or TCP packet. For packet size under 512 bytes UDP is fine to use, unless a reply is bigger than 512 bytes.
    According to some reference if you don't receive reply using UDP after 3 to 5 seconds you must switch to TCP. I will test a new version of this DNS code using TCP instead and check if it work better on problematic corporate network.

    Ref: http://msmvps.com/blogs/systmprog/archive/2006/12/23/dns-works-on-both-tcp-and-udp.aspx
  • QetuooQetuoo Posts: 7
    edited 2011-12-12 20:35
    Many corporate Firewall filter out UDP packet to external DNS server on port 53. Ask for "unlocking" this port, or keep using the internal DNS server reported by the DHCP.spin module.

    I can't figure out how to tell the Wiznet 5100 to timeout on an UDP packet that never show up. Is there anybody known how to do it ?
  • DynamoBenDynamoBen Posts: 366
    edited 2012-06-11 10:56
    I'm looking for a DNS object for a project I'm working on. Did you make any more changes beyond the code you posted here?
  • QetuooQetuoo Posts: 7
    edited 2012-06-11 19:09
    I still using thew same code, as i always search the same server name. As long as you use the internal DNS server if there one's you won't get any problem. Use external DNS only if you are sure that the Network manager don't block DNS request at firewall.

    The only things i can change in the future is to put the computer name in a Pointer parameters to be more flexible.

    If you got any problem let me know as i can fix it.
Sign In or Register to comment.