need help with dns

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
trolly
Member
Member
Posts: 52
Joined: Tue Mar 25, 2008 12:26 pm

need help with dns

Post by trolly »

for now, i've arp running, in my os (it can send request over the network to get MAC addr , and store the ip and the mac into a table), it work under qemu, (qemu emulate an gateway with ip:10.0.2.2)

now i try to implement DNS,

to do it, i believe that the dns query must be encapsulated into an udp datagram witch is encapsulated into the ip datagram witch is encapsulated into the ethernet datagram. I mus also pay attention to the endianness (byte order) (x86 are little-endian but network datagram are big-endian).

in practice i dont get it to work, ... i send a request to 10.0.2.2 (the gateway in qemu) the os in qemu says that the packet is transfered , but i never get a reply from the gateway


i've displayed an hexadecimal dump of the whole packet frame , i don't see something wrong. i work night and day to resolve the problem unsuccessful

there is a screen shot where you can see the dns query in hex numbers, and all the header (dns, udp,ip)
i dont show the ether header in the screen dump because i'm sure it's correct (6byte for the dst mac, 6byte for my mac and 2bytes for the proto: 0x0800 (0x0008 in little endian);
screendump.png
screendump.png (11.34 KiB) Viewed 1436 times
User avatar
01000101
Member
Member
Posts: 1599
Joined: Fri Jun 22, 2007 12:47 pm
Contact:

Re: need help with dns

Post by 01000101 »

are you planning on needing help on every protocol?
did you ever get a packet analyser/sniffer?

the only things I see here that may be the issue are:
A: the '.' right after "google" is an 0x06, when it probably should be a 0x03.
B: there's a trailing 0 (should end on 0x00 0x01)
C: your UDP ID looks a little weird, but that's probably just arbitrary anyway, so I'm not 100%.
trolly
Member
Member
Posts: 52
Joined: Tue Mar 25, 2008 12:26 pm

Re: need help with dns

Post by trolly »

in the dns querry i've puttet
[3]www[6]google[2]be[0](google .be and not .com as in the text)
plus the [0] [1] [0] [1]
the last zero is the padding for the udp packet checksum algorithm.

un the udp header i've choos an arbitrary local port and 53 for the remote port.



for the packet sniffer, i'm not sure, but i believe that the sniffer wont detect packet betwen the OS and QEMU
AntoineKaufmann
Posts: 5
Joined: Wed Jun 13, 2007 4:20 am
Location: Switzerland
Contact:

Re: need help with dns

Post by AntoineKaufmann »

trolly wrote:for the packet sniffer, i'm not sure, but i believe that the sniffer wont detect packet betwen the OS and QEMU
I don't know if there is a possibility to get the packages when using -net user. But there are two more possibilities. The first one is to put or enable debug code in qemu (by compilig it at your own; it's generally a good idea to use the svn/git-version of qemu, because they have done much work since the last release), the second one I know is to use -net tap. With that you should be able to use every sniffer you want. Perhaps there is a solution using vde (virtual distributed ethernet iirc) too.
German OS-Dev Community: http://lowlevel.brainsware.org
User avatar
01000101
Member
Member
Posts: 1599
Joined: Fri Jun 22, 2007 12:47 pm
Contact:

Re: need help with dns

Post by 01000101 »

If you had to setup a virtual connection, it should show up in Wireshark as a sniff-able connection.

Also, you shouldn't be adding the checksum padding (0) to the actual packet being transmitted, that should be done logically and only internal. It will throw off your "length" entries throughout the entire packet. Just calculate the checksum, add in null integers when necessary, but don't include them in the actual packet when you're done.
Post Reply