CS 3251 - Computer Networks I
Sockets Programming Assignment 1 -
Assigned: September 11
Due: Friday September 22 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 simple RPN calculator.
You will read in a formula in RPN (postfix) notation and
print the result. The client will not do any calculation
but will instead send a request to the server to be calculated.
Also, the server can only perform a single operation with
each request message.
You should support addition, subtraction, multiplication and division.
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:
rpncalc 127.0.0.1 "245 549 +"
would produce the output:
794
This query would have been sent to the server
application running on the local host (same system).
The only output is the resulting value
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.
Another example is:
rpncalc 127.0.0.1 "25 5 * 60 +"
would produce the output:
185
In this case, the client will send two separate queries to
the server. The first will calculate 25 * 5. The second
will calculate 125 + 60. Only the final result should be printed.
(For the TCP implementation, only a single connection should be used.)
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 rpncalc
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.
Notes:
-
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.
-
You are implementing two complete, separate versions.
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 rpncalc-tcp, server-tcp,
rpncalc-udp and server-udp.
-
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?
-
Your programs are to be written in standard C (not C++)
and 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.
-
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!
-
You should select a port for your rpncalc 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.
- 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.
-
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?
- 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:
- You will turn in your well-documented source code,
a README file and sample output file called Sample.txt.
The README file must contain:
- Your Name and email address
- Class name, section, date and assignment title
- Names and descriptions of all files submitted
- Detailed instructions for compiling and running your client
and server programs including a Makefile.
- A description of your application protocol (1/2 to 1 page)
with sufficient detail such that somebody else could implement
your protocol
- 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.
- By 11:55 PM on the due date,
you must submit your program files online.
- 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
-
Email your submission as an attachment to the account
bpetit@gatech.edu.
Use the subject line "[cs3251] Program 1".