TWiki> CS450 Web>Homework1>Homeworks>Homework3 (revision 2)EditAttach

Homework 3 - DNS resolution

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. Additional domains may be added if we find something interesting in the week.

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

To get started, check out the hw3 template from

svn://cs450.cs.uic.edu/pub/homeworks/hw3

this code already does most of the DNS querying and parsing for you. Your responsibility is to modify the hw3 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 (for alarm) or errno=EAGAIN (for timeout) 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:

./hw3 -d -n nameserver -i domain

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

Program usage and example runs are given below. Implementation of command line option handling is given in the template.

Usage: hw3 [-d] -n nameserver -i domain/ip_address
   -d: debug

./hw3 -i a.root-servers.net
a.root-servers.net resolves to 198.41.0.4


./hw3 -i nibbles.cs.uic.edu
nibbles.cs.uic.edu resolves to 131.193.34.150


./hw3 -d -n 192.228.79.201 -i www.cs.uic.edu
Resolving www.cs.uic.edu using server 192.228.79.201
The name edu can be resolved by NS: a.edu-servers.net
The name a.edu-servers.net resolves to IP addr: 192.5.6.30

Resolving www.cs.uic.edu using server 192.5.6.30
The name uic.edu can be resolved by NS: uic-dns2.uic.edu
The name uic-dns2.uic.edu resolves to IP addr: 128.248.7.50

Resolving www.cs.uic.edu using server 128.248.7.50
The name www.cs.uic.edu resolves to IP addr: 131.193.32.29
www.cs.uic.edu resolves to 131.193.32.29


./hw3 -d -i www.yahoo.com.tw
Resolving www.yahoo.com.tw using server 198.41.0.4
The name tw can be resolved by NS: e.dns.tw
The name a.dns.tw resolves to IP addr: 203.73.24.8

Resolving www.yahoo.com.tw using server 203.73.24.8
The name com.tw can be resolved by NS: d.twnic.net.tw
The name a.twnic.net.tw resolves to IP addr: 192.83.166.9

Resolving www.yahoo.com.tw using server 192.83.166.9
The name yahoo.com.tw can be resolved by NS: ns4.yahoo.com

Resolving ns3.yahoo.com using server 198.41.0.4
The name com can be resolved by NS: c.gtld-servers.net
The name a.gtld-servers.net resolves to IP addr: 192.5.6.30

Resolving ns3.yahoo.com using server 192.5.6.30
The name yahoo.com can be resolved by NS: ns1.yahoo.com
The name ns1.yahoo.com resolves to IP addr: 68.180.131.16

Resolving ns3.yahoo.com using server 68.180.131.16
The name ns3.yahoo.com resolves to IP addr: 121.101.152.99

Resolving www.yahoo.com.tw using server 121.101.152.99
The name www.yahoo.com.tw is also known as rc.yahoo.com.

Resolving rc.yahoo.com using server 192.228.79.201
The name com can be resolved by NS: h.gtld-servers.net
The name a.gtld-servers.net resolves to IP addr: 192.5.6.30

Resolving rc.yahoo.com using server 192.5.6.30
The name yahoo.com can be resolved by NS: ns1.yahoo.com
The name ns1.yahoo.com resolves to IP addr: 68.180.131.16

Resolving rc.yahoo.com using server 68.180.131.16
The name rc.yahoo.com is also known as rc.g01.yahoodns.net.

Resolving rc.g01.yahoodns.net using server 198.41.0.4
The name net can be resolved by NS: i.gtld-servers.net
The name a.gtld-servers.net resolves to IP addr: 192.5.6.30

Resolving rc.g01.yahoodns.net using server 192.5.6.30
The name yahoodns.net can be resolved by NS: ns1.yahoo.com
The name ns1.yahoo.com resolves to IP addr: 68.180.131.16

Resolving rc.g01.yahoodns.net using server 68.180.131.16
The name g01.yahoodns.net can be resolved by NS: yf2.yahoo.com
The name yf1.yahoo.com resolves to IP addr: 68.142.254.15

Resolving rc.g01.yahoodns.net using server 68.142.254.15
The name rc.g01.yahoodns.net is also known as any-rc.a01.yahoodns.net.

Resolving any-rc.a01.yahoodns.net using server 128.63.2.53
The name net can be resolved by NS: a.gtld-servers.net
The name a.gtld-servers.net resolves to IP addr: 192.5.6.30

Resolving any-rc.a01.yahoodns.net using server 192.5.6.30
The name yahoodns.net can be resolved by NS: ns1.yahoo.com
The name ns1.yahoo.com resolves to IP addr: 68.180.131.16

Resolving any-rc.a01.yahoodns.net using server 68.180.131.16
The name a01.yahoodns.net can be resolved by NS: yf2.yahoo.com
The name yf1.yahoo.com resolves to IP addr: 68.142.254.15

Resolving any-rc.a01.yahoodns.net using server 68.142.254.15
The name any-rc.a01.yahoodns.net resolves to IP addr: 206.190.60.37
www.yahoo.com.tw resolves to 206.190.60.37


./hw3 -d -i 128.30.76.78
Resolving 128.30.76.78 using server 198.41.0.4
The name in-addr.arpa can be resolved by NS: d.in-addr-servers.arpa
The name a.in-addr-servers.arpa resolves to IP addr: 199.212.0.73

Resolving 128.30.76.78 using server 199.212.0.73
The name 30.128.in-addr.arpa can be resolved by NS: auth-ns1.csail.mit.edu

Resolving auth-ns2.csail.mit.edu using server 192.228.79.201
The name edu can be resolved by NS: l.edu-servers.net
The name a.edu-servers.net resolves to IP addr: 192.5.6.30

Resolving auth-ns2.csail.mit.edu using server 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

Resolving auth-ns2.csail.mit.edu using server 18.72.0.3
The name auth-ns2.csail.mit.edu resolves to IP addr: 128.52.32.80

Resolving 128.30.76.78 using server 128.52.32.80
128.30.76.78 resolves to golf.csail.mit.edu

Grading

You can get the grading script using:

svn co svn://cs450.cs.uic.edu/pub/

or just svn up in your /pub if you already have one checked out. The grading script is in /pub/grading-scripts/hw3/. To run the grading script:

./hw3_score username score_file

This script will create a directory with your username, download hw3 from svn and create score_file inside hw3.

The grading script checks for only domains and it will check the last word of the last line of your program output as the final result. If all test-cases are successful in grading script you will get 6 point from grading script. However, the following tests will be done manually and points will be deducted if your program can't handle the corresponding issues.

-0.5: At least four descriptive commits are made
-1.0: Can handle non-responsive root server

The score file will look something like the following:

[SUCCESS] nibbles.cs.uic.edu [0.5]: 0.5
[SUCCESS] www.cs.uic.edu [0.5]: 0.5
[SUCCESS] cs450.cs.uic.edu [0.5]: 0.5
[SUCCESS] www.nus.edu [0.5]: 0.5
[SUCCESS] www.cornell.edu [0.5]: 0.5
[SUCCESS] www.yahoo.com.tw [1]: 1
[SUCCESS] www.prothom-alo.com [0.5]: 0.5
[SUCCESS] www.creditunion1.org [1]: 1
[SUCCESS] 128.30.76.78 [0.5]: 0.5
[SUCCESS] 63.111.24.121 [0.5]: 0.5
Total score: 6
Edit | Attach | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r2 - 2012-09-05 - 16:40:22 - 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