Skip to main content

Goals 

  • Practice with Unix calls for datagram network communication. 
  • Continue to develop skills to read and correctly interpret Unix manual pages.

Credits

This lab was developed by Prof. L. Felipe Perrone. Permission to reuse this material in parts or in its entirety is granted provided that this credits note is not removed. Additional students files associated with this lab, as well as any existing solutions can be provided upon request by e-mail to: perrone[at]bucknell[dot]edu

Academic Responsibility

It should go without saying that all the work that you will turn in for this lab will be yours. You should try your best to debug your code on your own, but it’s fine to get help from a colleague as long as that means getting assistance to identify the problem and doesn’t go as far as receiving source code to fix it (in writing or orally).

Set Up

Before you start, do the following on a terminal:

cd ~/csci307/Labs/Lab4
cp ~perrone/csci307/Labs/Lab4/* .

Problem 1

  1. Read the manual pages of nslookup(1) and dig(1). Use one of these programs to look up the IPv4 addresses of the lab machine on which you are working and other machine at Bucknell. In your file answers.txt, for each of these two machines, list all its canonical names and its IPv4 address in dotted decimal notation.
  2. Read the manual page of getaddrinfo(3). Explain the purpose of the parameter struct addrinfo **res and why it had to be declared as a double pointer.
  3. Study the program getaddrs.c given to you and do your best to understand what it does and how it works. This program calls getaddrinfo(3) to perform a network address translation. Explain how to translate into a human-readable string the numeric error code returned by this function when it runs into an error.
  4. Read the manual page of freeaddrinfo(3). Imagine a program that calls getaddrinfo(3) many times. Explain why this program should invokes freeaddrinfo(3) after each call to getaddrinfo(3).

After you debug your code and get everything working correctly, add, commit and push your files to your gitlab as follows:

git add answers.txt
git commit -m "lab4-1 completed" 
git push

Problem 2

Study the programs timeClient-udp.c and timeServer-udp.c given to you. You can compile them with the Makefile provided and experiment with them. Run timeServer-udp in your local lab machine, then open an ssh connection to a remote machine and invoke timeClient-udp to send requests to the server.

  1. Modify timeClient-udp.c and timeServer-udp.c to read a port number from the command line. Make sure that the programs run as expected.
  2. Starting from your two modified programs, create corresponding programs flightClient-udp.c and flightServer-udp.c.
  3. Using your flightServer-udp.c, create a program that instantiates three different flights (choose their data as you wish) and inserts them all in a global list declared as struct slist *flight_list. Modify the server loop so that when it receives a message from the client, it sends back a single message with all the data in the three flights the server has stored.
  4. Using your flightClient-udp.c, create a program that sends a request to the corresponding server, receives a message with all the data for three flights, and prints to the terminal the data for each flight. You don’t need to change the request message used in the timeClient-udp.c and timeServer-udp.c given to you, only the response that is sent from server to client.

After you debug your code and get everything working correctly, add, commit and push your files to your gitlab as follows:


git add Makefile
git add snode.h snode.c
git add slist.h slist.c
git add flight.h flight.c
git add timeClient-udp.c timeServer-udp.c
git add flightClient-udp.c flightServer-udp.c
git commit -m “lab4-2 completed” 
git push

Grading Rubric

The rubric below shows the number of points that will be earned for each item that compiles and runs correctly. If the item does not compile correctly, 60% of the total points will be deducted. If the item compiles correctly and runs with major errors, 40% of the total points will be deducted. If the item compiles correctly and runs with minor errors, 20% of the total points will be deducted. If the item compiles with warnings, and runs correctly, 10% of the total points will be deducted.

  1. Problem 1.1 [5 points]
  2. Problem 1.2 [5 points]
  3. Problem 1.3 [5 points]
  4. Problem 1.4 [5 points]
  5. Problem 2.1 [5 points]
  6. Problem 2.3 [35 points]
  7. Problem 4 [40 points]