COMPSCI 235 Internet Technology: Labs

Lab submission instructions

Each submission should include all your source code and header files, and a Makefile. You should make a tar ball of your working directory as follows. Suppose your working directory is called workdir.

~/workdir$ cd ..
$ tar czvf Yourlastname-Assignmentname.tgz workdir

Upload the tarball Yourlastname-Assignmentname.tgz to the folder Assignmentname under the AssignmentSubmission class folder in EEE. For instance, for the first part of lab 1, you'll find a folder Lab1-Part1 in EEE. You should upload a tarball Yourlastname-Lab1-Part1.tgz to the folder Lab1-Part1.

Lab 1: TCP Proxy

Part 1: A proxy that connects to a fixed destination host

The first lab is to get you familiarized with the Linux programming environment, and some basics of TCP socket programming. Your task is to write a simple TCP proxy, tcpproxy, that takes three arguments: destination-host, destination-port, and listen-port. The tcpproxy listens on the listen-port. Once it accepts a connection from a client, it forwards everything it receives from this connection to the destination-host and destination-port, and vice versa.

The structure of your program may look like the following. The program starts a listening socket. For every connection it accepts, it forks (you may use pthread) a child process. This child process starts a new connection to the destination-host and destination-port. It then forwards the data it receives between the connection the tcpproxy accepts and the connection to the destination host and port. You should use "select" in the child process.

More details about a TCP proxy can be found at this site. But be aware that it uses a special library libasync.a that we do not use. You can download the sample code used in DM-TCP from this site as well. All code compiles on the ICS Linux cluster.

Part 2: Change destination host and port

In this part of your lab, you are going to add a control channel that allows you to change the destination and the port of the tcpproxy. You should use listen-port + 1 as the listening port for the control channel.

The control channel supports two commands: set and list. The commands are case-insensitive. When you send the ASCII string set destination-host destination-port to the control channel, the proxy's destination hosts and ports should be changed to the new values. When you send the command list to the control channel, the tcpproxy should return the current destination host and port it connects to. Each command line terminates with a new line. If you send a control-D, the current control session is terminated.

For instance, after you start your proxy at a machine yourhost.ics.uci.edu

$./tcpproxy www.mit.edu 80 8888 

If you want to change the destination to a different host, you may do the following

$telnet yourhost.ics.uci.edu 8889
set www.uci.edu 80
control-D
$

When you connect to your proxy again, the destination host and port should be changed to the port 80 of www.uci.edu.

Lab 2: RPCs

The goal of this lab is to introduce remote procedure calls. You'll work in groups for this lab. Each project group only needs to turn in one submission.

We'll use the first lab of the lab series of MIT's class 6.824. You can get all details and code from this site. Please read the instructures and the distributed code before you come to class on Wednesday. We'll discuss the lab in class. If you do not come prepared, the discussion might not be helpful, and you may waste much time in finishing the lab.

You must follow the turn-in procedure noted at the beginning of this page to turn in your code.

You may find that using tags in Emacs is helpful in navigating through the code. After you untar the source code, cd to the top-level directory of the code, and build a TAGS' table:

~/workdir$ etags `find . -name *.cc -or -name *.h`

Then in emacs, you can use commands such as M-. when the cursor is at a function or a variable to find out the definition of the function or variable. Read this page for more information on how to use etags.

Last updated: 09/26/07. Home