CMPSCI 453/591
 Computer Networking
Professor Jim Kurose
Programming Assignment 1

Assigned: Class 7 (10/4/05)
Due: Class 10 (10/13/05)
Off campus: Postmarked ten days after viewing lecture 6or receiving this (whichever is later)
Last Modified: never (at least not yet)



In this programming assignment you will program the simple message relay application shown below.

The sender process accepts user-entered "messages" from the keyboard, and sends these messages to the receiver process via the message-relay process. The receiver process displays a message once the message has been received in its entirety. All communication among the processes is done using TCP sockets.There are two application-level messages defined: a DATA message (containing the text of a message) and a CLOSE message, which instructs the receiver of the CLOSE message to shut down, as discussed below

Since the goal of the programming assignment is for you to learn socket programming (not to build a hardened application), you can hardwire in specific IP addresses where the processes are known to be running (i.e., you need not somehow ask the user for the host names or IP addresses of the process to which messages will be sent). You may also assume that the relay and the receiver will only be receiving messages from a single sender or relay, respectivly. The extra credit option (i.e., not required) for this assignment asks you to program a relay that can handle multiple senders concurrently.

Please read the information posted on the class WWW site about what to hand with your assignment. Note that a short design document is required.Your should program your each process to print an informative statement whenever it takes an action (e.g., sends or receives a message, detects termination of input, etc), so that you can see that your processes are working correctly (or not!). Tis also allows the TA to also determine from this output if your processes are working correctly. You should hand in screen shots (or file content, if your process is writing to a file) of these informative messages.

You may write your programs in Java, C++, or C. Other languages are OK, but ask me first. You are welcome to do this assignment using the WINSOCK API, rather than the Unix API, if you have a Windoze machine. See http://www.lowtek.com/sockets/ for links to tutorials on the WINSOCK API.

Programming the assignment in JAVA

Programming the assignment in C

If you choose to write your programs in C, you'll need to master the C system calls needed for socket programming.  These include socket(), bind(), listen(), accept(), connect(), and close(). For an audio/html tutorial of socket programming in C, see "Unix Network Programming," by Jim Kurose at http://www-aml.cs.umass.edu/%7Ejsmanic/unetpgm/.  (You need only sessions 2, 3 and 4 to do this assignment; enter any username). For a quick text-only tutorial of socket programming specifically under Linux, see http://www.lowtek.com/sockets/.
 

Programming notes

Here are a few tips/thoughts to help you with the assignment:

Extra Credit.

OK.  You've got your sender, relay, and receiver processes running.  You want to do more.  For extra credit, rewrite your relay to be able to handle multiple senders concurrently. Your relay still only needs to forward messages to a single receiver (the goal here is to let your program a concurrent server). The relay waits on the welcoming socket and then creates a new thread or process to handle all communication with the incoming sender. You'll need to do some extra reading on your own to figure out how to do this. See the resources listed above.