Docstoc

CSC 101 Lab Week 8 DNS Lookup

Document Sample
CSC 101 Lab Week 8 DNS Lookup Powered By Docstoc
					CSC101-S11-Lab 8                                                                                              Page 1


                                             CSC 101 Lab Week 8
                                               DNS Lookup


         ISSUED:         Wednesday, 18 May 2011
            DUE:         Wednesday, 25 May 2011, by the end of lab
POINTS POSSIBLE:         1
        WEIGHT:          1% of total class grade

Overview
This lab involves defining a C structure for internet computer addresses, and writing functions to perform computa-
tions with internet addresses. These addresses are often referred to with the acronym "DNS", which stands for
"Domain Name System".

Specification
Numeric addresses for computers on the Internet are composed of four parts, separated by periods, of the form
       xx.yy.zz.mm
where xx, yy, zz, and mm are positive integers. Locally, computers are usually also known by a nickname.
For this lab, you are designing a program to process a list of Internet addresses, identifying all computers from the
same locality. The locality of a internet address is the first two integer components.
Create a structure type named Address with components for the four integers of an Internet address, and a fifth
component in which to store a nickname (up to 10 characters). Your program should read a list of up to 100
addresses and nicknames terminated by a sentinel address of all zeros and a sentinel nickname. Input is from stdin,
from the keyboard or with file redirection.
Sample data:
       111.22.3.44              pluto
       21.43.65.87              saturn
       111.22.8.99              mercury
       0.0.0.0                  none

The program should display a list of messages identifying each pair of computers from the same locality: that is,
each pair of computers with matching values in the first two components of the Internet address. In the messages, the
computers should be identified by their nicknames.
Example message:
       Machines pluto and mercury are on the same local network.
Follow the messages with a nicely formatted display of the full list of addresses and nicknames, without the sentinel
"none" address. Your program should have at least the following three functions:
• scan_address - reads a single address/nickname from stdin, and returns an Address structure with that
  data
• print_address - prints a single address/nickname, returning void
• local_address - takes two address structures as input parameters and returns 1 (for true) if the addresses are
  on the same local network, or 0 (for false) otherwise.

Testing
There are further sample inputs and a pre-compiled executable in the lab 8 directory. The pre-compiled executable
is named dns-lookup, which is the same name that your program should have. Your program should get the
same results as the pre-compiled executable when run on each of the sample input files. For example, when running
from your working directory for lab 8, the following commands should produce no output to the terminal:
CSC101-S11-Lab 8                                                               Page 2


       ˜gfisher/classes/101/labs/8/dns-lookup < sample1 > sample1.fisher.out
       diff sample1.out sample1.fisher.out


Submitting Your Work
Hand in as follows:
       handin gfisher 101_lab8 dns-lookup.c

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:7
posted:9/27/2011
language:Danish
pages:2