CIS 410/510 Introduction to Networks
Fall 1999

Program 1: Encoding

Handed Out: 12 October 1999
Due: 28 October 1999 online by 5pm


Overview

You will write a client-server program that emulates a point-to-point link. The link uses either NRZ or NRZI encoding to transfer signals from one end to the other. The "link" will use a TCP connection to transport the bits.

Input

The arguments that the server must accept are:
-p < port > port the server listens on
-t < encoding > encoding type (optional), possible values are NRZ (default) or NRZI
-d < debug > debugging string (optional), possible values are details, status, and fatal (default)
The arguments that the client must accept are:
-f < file > file to send
-h < host > host name of the server
-p < port > port the server listens on
-t < encoding > encoding type (optional), possible values are NRZ (default) or NRZI
-d < debug > debugging string (optional), possible values are details, status, and fatal (default)

Output

Your server program should print out the file being transferred. The client should have no output. Both programs should also print any errors resulting from system calls that fail.

Supplied Code

I will supply you with TCP code and an example client and server, along with some supporting files, in the class directory in:

   /cs/classes/cis510networks/program1
Together, these will form a framework for this assignment. The files are:
Makefile Has the information needed to compile the programs. You should first type make depend to create dependencies (be sure mkdep has execute permission). This will allow you to recompile only the necessary modules when you change a file. To compile the programs, type make. To remove any object files, type make clean.

You must use the Makefile to compile your program and you must use the executable names of server and client. You may modify the Makefile to add additional files required for your executables, but you should otherwise not change its format.

server.cc Implements a sample server. You should modify this so that it does argument parsing and then creates one end of a TCP connection and waits for the client to connect and form the "link". Once the link is created, the server receives a file from the server and then closes the connection. The file is transfered with one of the encodings listed above.
client.cc Implements the client. You should modify this so that it does the argument parsing and then connects to the server to form a "link." The client sends a file to the server and then closes the connection. The file is transfered with one of the encodings listed above.
test.cc A place for you to implement a test program.
tcp_socket.h/.cc Defines the TCP socket interface. You can use this interface to create a client and server TCP socket, then send and receive data over this socket. The data transfer over the socket is reliable, so you do not need to worry about error or loss.
debug.h/.cc Functions that help you to print debugging comments.

Read the comments in the files for more details.

Data Format

The TCP socket interface transfers data using a character string. When the client sends a file to the server, it uses one of the encoding methods listed above to encode the bits in the string. The server then decodes the bits to arrive at the original string. The bits must be sent in order from least significant to most significant. This will allow interoperability between your client and server and those written by others in the class (as well as the solution).

The server knows the file transfer is done when it tries to read data and it gets 0 bytes back from the socket interface.

Error Checking

You should check for errors resulting from system calls. If a system error occurs, use the perror() interface to print out its corresponding code and then immediately exit the program.

Debugging

You must use the debugging interface defined in debug.h to print out any debugging comments. This way you can turn off the extra comments via the command line.

Coding hints

You should first write a test program that just reads in a string, encodes it, then immediately decodes it. This way you can be sure you are manipulating bits correctly without bothering with the TCP interface. Once you do this, then you should get the client and server communicating, and then check for interoperability with the solution code.

When you are testing your program, it will be very helpful to print each bit as you read it in, then again when you encode it, then again when you decode it. This will allow you to check whether your encoding is working as it should.

You can run both the client and the server on the same machine.

Extra Graduate Requirements

Graduates are also required to implement bit stuffing. The client should insert a 0 whenever the data contains three 1's in a row. Likewise, the server should recognize the bit stuffing and remove the extra 0's.

Deliverables

You should submit all your source code (including the files I have supplied). The code should be documented. Do not submit any object code. Use the submit program documented in the Assignments section of the class web page.

Grading

During grading, I will run your client and server and check if it transfers files correctly under all the encoding methods. I will also check that your client and server can interoperate with the solution code.