Homework 2 - due 2 pm Sept 14

In this homework, we talk to the global domain name system to resolve domain names into IP addresses.

Some good domain names to try, which you definitely will be tested on. You will also be tested on a few secret domain names, although nothing particularly evil. Additional domains may be added if we find something interesting in the week.

  • www.google.com
  • www.cs.uic.edu
  • www.yahoo.com.tw
  • 128.30.76.78

To get started, check out the hw2 template from

svn://bits.cs.uic.edu/cs450f09/homeworks/hw2

this code already does most of the DNS querying and parsing for you. Your responsibility is to modify the hw2 to work as follows:

The file root-servers.txt contains a list of DNS root servers. Your application must use this file to find a working root server to use. You can assume it will always be called root-servers.txt, and exist in the current working directory. If a server does not respond, it must move on to the next server. Its parameters and output are illustrated below. Try to match the output as closely as possible: there should not be lots of extra lines of debug output etc. in the final version.

You are obviously not allowed to use gethostbyname or getaddrinfo for this homework, nor are you allowed to run any executables such as `host' or `nslookup' from inside your program.

Hints

To time out on a recv() call (in case you get no answer), use setsockopt() with the SO_RECVTIMEO option: http://linux.die.net/man/7/socket

Alternatively, you can use alarm(), and set up a handler for SIGALRM. "man alarm()" and "man signal" will help you set that up. Or try the newer sigitimer().

Either way, look for errno==EINTR when recv() returns -1 when using these techniques to see if you actually timed out. If you want to jump off the deep end of the pool, use a select() call (which takes a timeout parameter) instead of the blocking recv().

You can try out the template version like this:

./hw2 <dns server IP> <domain name>

to find your local DNS server, check your network settings, or run "cat /etc/resolv.conf" on a non-windows machine.

Massive hint: recursion is your friend.

Turn-in instructions

The same rules apply for your submission as for previous homeworks, with one big exception: you are now expected to commit at least 4 revisions, each with significant edits and intelligible commit comments, at least 10 minutes apart, reflecting your progress toward the final turned-in result.

For example, you may commit the template version, a version that is able to read 'root-servers.txt', a broken version that doesn't work at all, a version that handles all but the difficult yahoo example, and the final version. Remember to write a comment that indicates the current status of your project. You are of course welcome to make many more commits if you please.

To see how many commits you have, and to read the messages, use svn log

To see the difference between two revisions, say revision r129 and r157, use svn diff -r 129:157

Example use sessions

./hw2 a.root-servers.net
The name a.root-servers.net resolves to IP addr: 198.41.0.4

./hw2 www.google.com
The name www.google.com is also known as www.l.google.com.
The name www.l.google.com resolves to IP addr: 209.85.225.147
The name www.l.google.com resolves to IP addr: 209.85.225.103
The name www.l.google.com resolves to IP addr: 209.85.225.99
The name www.l.google.com resolves to IP addr: 209.85.225.104
The name www.l.google.com resolves to IP addr: 209.85.225.106
The name www.l.google.com resolves to IP addr: 209.85.225.105

./hw2 www.yahoo.com.tw
The name www.yahoo.com.tw is also known as rc.tpe.yahoo.com.
The name rc.tpe.yahoo.com is also known as tw.rc.yahoo.com.
The name tw.rc.yahoo.com is also known as w2.rd.tw.g1.b.yahoo.com.
The name w2.rd.tw.g1.b.yahoo.com is also known as tpc-w2.rd.tw.g1.b.yahoo.com.
The name tpc-w2.rd.tw.g1.b.yahoo.com resolves to IP addr: 203.84.202.10

./hw2 128.30.76.78
The name 128.in-addr.arpa can be resolved by NS: CHIA.ARIN.NET
The name NET can be resolved by NS: E.GTLD-SERVERS.NET
The name A.GTLD-SERVERS.NET resolves to IP addr: 192.5.6.30
The name ARIN.NET can be resolved by NS: aloe.ARIN.NET
The name aloe.ARIN.NET resolves to IP addr: 192.12.94.32
The name HENNA.ARIN.NET resolves to IP addr: 192.26.92.32
The name 30.128.in-addr.arpa can be resolved by NS: lampang.lcs.mit.edu
The name edu can be resolved by NS: L.GTLD-SERVERS.NET
The name A.GTLD-SERVERS.NET resolves to IP addr: 192.5.6.30
The name mit.edu can be resolved by NS: bitsy.mit.edu
The name bitsy.mit.edu resolves to IP addr: 18.72.0.3
The name fedex.ai.mit.edu resolves to IP addr: 128.52.32.80
The host at 78.76.30.128.in-addr.arpa is also known as golf.csail.mit.edu.


Topic revision: r2 - 2009-09-10 - 00:11:17 - Main.jakob
 
Copyright 2016 The Board of Trustees
of the University of Illinois.webmaster@cs.uic.edu
WISEST
Helping Women Faculty Advance
Funded by NSF