CS 3251 - Computer Networks I

Sockets Programming Assignment 1 -
Assigned: January 29
Due: Sunday February 11 11:59 PM


TCP and UDP Applications Programming

For this assignment you will design and write your own application program using network sockets. You will implement two different versions of the application. One version will be based on TCP. The other will use UDP. You will write both the client and server portions of this application.

The application you are designing is a loan ammortization schedule calculator. You will read in an interest rate, loan amount and duration and print the resulting payment schedule. The client will not do any calculation but will instead send a request to the server to be calculated.

You can limit the application to support only durations of years and monthly payments. You should support both integer and floating point values. You must allow the IP address of the server to be specified on the command line of the client. For instance, the command:

loan 127.0.0.1 5.6 125,000 2

indicates a 125,000 dollar loan at 5.6 percent interest for 2 years. It should produce output something like the following:

Amortization Schedule
Month           Interest       Principal       Balance
Jan, 2007       $572.92       $4,939.04       $120,060.96
Feb, 2007       $550.28       $4,961.68       $115,099.28
Mar, 2007       $527.54       $4,984.42       $110,114.86
Apr, 2007       $504.69       $5,007.26       $105,107.60
May, 2007       $481.74       $5,030.21       $100,077.39
Jun, 2007       $458.69       $5,053.27       $95,024.12
Jul, 2007       $435.53       $5,076.43       $89,947.69
Aug, 2007       $412.26       $5,099.70       $84,847.99
Sep, 2007       $388.89       $5,123.07       $79,724.92
Oct, 2007       $365.41       $5,146.55       $74,578.37
Nov, 2007       $341.82       $5,170.14       $69,408.23
Dec, 2007       $318.12       $5,193.84       $64,214.39
Jan, 2008       $294.32       $5,217.64       $58,996.75
Feb, 2008       $270.40       $5,241.56       $53,755.20
Mar, 2008       $246.38       $5,265.58       $48,489.62
Apr, 2008       $222.24       $5,289.71       $43,199.90
May, 2008       $198.00       $5,313.96       $37,885.95
Jun, 2008       $173.64       $5,338.31       $32,547.63
Jul, 2008       $149.18       $5,362.78       $27,184.85
Aug, 2008       $124.60       $5,387.36       $21,797.49
Sep, 2008       $99.91        $5,412.05       $16,385.44
Oct, 2008       $75.10        $5,436.86       $10,948.59
Nov, 2008       $50.18        $5,461.78       $5,486.81
Dec, 2008       $25.15        $5,486.81       $0.00

This query would have been sent to the server application running on the local host (same system). The only output is the resulting table or an error message if it fails. Note: The command line must work exactly this way to make sure the TA can easily test your program.

You will need to develop your own "protocol" for the communication between the client and the server. While you should use TCP or UDP to transfer messages back and forth, you must determine exactly what messages will be sent, what they mean and when they will be sent (syntax, semantics and timing). Be sure to document your protocol completely in the program writeup.

Your server application should listen for requests from loan clients, process the client and return the result. After handling a client the server should then listen for more requests. The server application should be designed so that it will never exit as a result of a client user action.

Focus on limited functionality that is fully implemented. Practice defensive programming as you parse the data arriving from the other end. Do not work on a fancy GUI, but focus on the protocol and data exchange. Make sure that you deal gracefully with whatever you or the TAs might throw at it.

You are welcome (encouraged even) to use external sources as you develop the ammortization algorithm. However, you must include a citation (text or web site) in your source code and project description if you use an external reference.

Notes:

  1. Consider adding a debug flag "-d" to turn on debugging of your application. For instance, this might cause the client to print the actual messages sent/received and the intermediate values.

  2. You are implementing two complete, separate versions of the program. A client and server using TCP and another client and server using UDP. Your final submission should include 4 separate executables. For simplicity in grading, let's call them loan-tcp, server-tcp, loan-udp and server-udp.

  3. Your TCP and UDP versions will share much of the same code for command line parsing and user interaction. However, your UDP implementation will have to deal with lost request messages. Make sure you consider what happens when a message is lost. You will need to handle this in some way such as using a timer to retransmit your request. A good way to test your client in this situation is to run it without the server. Does your client handle this gracefully?

  4. Your programs are to be written in standard C or C++ using the standard Socket libraries we have been covering in class. Your programs should run on the CoC Solaris/Sparc or Linux systems. When compiling socket programs on Solaris you must use "-lsocket -lnsl" on your link line to include the socket libraries.

  5. A portion of your grade will come from the TA running your program on one of the Solaris/Sparc or Linux systems in the CoC. You may develop your program on any Unix variant but you must verify that your build instructions and program work on a Solaris or Linux system for full credit. For Linux grading we will use the system helsinki.cc.gatech.edu. You must clearly indicate in your README and Makefile on which platform you want to be graded!

  6. You should select a port for your loan service. I recommend something between say 13000 and 14000. You will need to make sure nobody else in the class is running their server on the same system using the same port as you. (Consider using the value 13000 + your prism account number). Make sure you kill your server when you are done working. See the netstat command for checking on busy network ports.

  7. Use explicit IP addresses in the client for specifying which server to contact. Do not use DNS for host name lookups. We will do that in a later assignment.

  8. Make sure that you do sufficient error handling such that a user can't crash your server. For instance, what will you do if a user provides invalid input?

  9. You must test your program and convince me it works! Provide me with a sample output (you can use script or cut-and-paste) that shows all of your functions working. If you fail to demonstrate a capability of the program I will assume that feature does not work.

Turnin Instructions:

  1. You will turn in your well-documented source code, a README file and sample output file called Sample.txt. The README file must contain:
    1. Your Name and email address
    2. Class name, section, date and assignment title
    3. Names and descriptions of all files submitted
    4. Detailed instructions for compiling and running your client and server programs including a Makefile.
    5. A description of your application protocol (1/2 to 1 page) with sufficient detail such that somebody else could implement your protocol
    6. Any known bugs, limitations of your design or program

    You will be graded on the correctness of the code and its readability and structure. Your code and supporting documentation will account for one-third of your homework grade. (The remaining two-thirds will be split one-third for the TCP program and one-third for the UDP program.) As you write the documentation, imagine that I intend to implement your protocol in my own client that will interoperate with your server. Make sure I don't have to read your source code to figure out how to do this.

  2. By 11:55 PM on the due date, you must submit your program files online.
    1. Use the UNIX "tar" command to create an archive of your complete set of files, naming your .tar archive file "p1_firstname_lastname.tar": (e.g. tar cvf p1_george_burdell.tar
    2. Email your submission as an attachment to the account Russ.Clark@gatech.edu. Use the subject line "[cs3251] Program 1".