ICS 651 (Computer Networks) Project 1

The goals of this project are:

  1. to learn about signaling
  2. to learn about TCP connection establishment and teardown
  3. to become familiar with TCP header formats

This is an individual project. You may discuss ideas with your colleagues, but you must be the sole author of all your code.

Your implementation must interoperate with the implementations of at least 2 other people. Your implementation must be in C and compile and run on a Unix system.

The project is due Tuesday, February 16th 1998, at 4pm HST. Submission is electronic:

  1. send e-mail to esb@hawaii.edu
  2. subject line must be "project 1"
  3. body contains your file "tcp.c"
  4. your file "tcp.c" must show, in a comment near the beginning:
    1. your full name.
    2. whether you think your program works, and if not, what you think the problem is.
    3. the full name of the people (if any) with whom you have seen your code successfully interoperate.
Late submissions lose 10% of the grade after 4pm Feb 16th, 30% after 4pm Feb 17th, 60% after 4pm Feb 18th, and 100% after 4pm Feb 19th.

Signaling is the management of connections by sending special messages. The assignment is to implement the TCP state machine for connection establishment/teardown described starting on page 21 of the TCP specification, RFC 793. To simplify your task, you are not required to implement any of the data transfer, retransmission, and window management operations of TCP, only the connection establishmeent and teardown.

Project Specification

Your job is to implement a file, tcp.c, which must provide the following functions:
  1. int tcp_connect(int IP_address, short local_port, short remote_port) opens a connection to the specified IP address if possible, returning -1 in case of failure (reset received, timeout, destination unreachable). If the connection succeeds, tcp_connect returns a connection identifier, an integer in 1..10 representing the connection.
  2. int tcp_listen(short local_port, int * IP_address, int timeout) listens for a connection, and if a connection succeeds, fills in the IP address and returns the connection identifier. If no connection is received within the given timeout (in milliseconds), tcp_listen must return -1.
  3. void tcp_close(int connection) closes the connection specified by the argument.
  4. void tcp_init() is called exactly once, before any call to connect or listen or close.
tcp.c may use the following functions:
  1. int ip_send(int IP_address, char * packet, int bytes) will send the given number of bytes pointed to by "packet" to the specified IP address, returning 0. The call may fail (for example if the IP address is unreachable), and then the return value will be -1.
  2. int ip_receive(char * packet, int size, int * from, int timeout) returns -1 if the call timed out (timeout is specified in milliseconds). If the call succeeded (did not time out) the packet is filled with data (up to "size" -- any additional data in the packet is discarded), the integer pointed to by "from" is filled with the source IP address, and the number of bytes received is returned.
Your project is to implement a small subset of TCP, but you must still use the TCP header format. The following fields of the TCP header MUST be set appropriately: I have made available by anonymous ftp the files:
  1. ip.c, implementing a simulated IP (the simulator only works with testtcp.c)
  2. testtcp.c, a simple program that calls the TCP functions.
  3. tcp.c, a skeleton for your implementation of tcp.c.
  4. ipsim.h, used by the C files.
  5. makefile, a makefile for this program (might need to be customized for your Unix -- read carefully before using).
The test program, specified in testtcp.c, will accept as command-line arguments one of the following:

Details

The call to tcp_connect should time out if more than 10 seconds expire without receiving a packet that was expected by the state machine.

Be sure your TCP works correctly when both sides call tcp_connect (the "SYN-SENT, SYN-RCVD, ESTAB" path through the state machine).

This specification does not ever require you to retransmit a packet.

This specification does not ever require you to transmit a packet with any data. Therefore, the "bytes" parameter to ip_send should always have the value 20. You should check the return value of ip_receive to make sure the packets are 20 bytes long.

See page 36 of the specification to find out when you need to send a reset (cases 1 and 2 only).

To correctly process an incoming reset, assume the window has size 1 byte.

Both ip.c and testtcp.c can be compiled with the "-DDEBUG" flag to enable print statements and to slow down message generation. See the source code for details.

I do make mistakes. If you find mistakes in the design of this protocol, please send mail to me or to the mailing list. I will probably reply within 24 hours (except on weekends). If you are not subscribed to the mailing list, please send a message now with "subscribe ics451-l email firstname lastname" in the body, to listproc@hawaii.edu.