Here is a working example of DNS protocol i've coded for Spinneret
Qetuoo
Posts: 7
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
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
SPIN
15K
Comments
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
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 ?
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.