CIS 432/532 Introduction to Computer Networks
Fall 2002

Program #2: Implementing a Reliable Transport Protocol
Due November 12th, 2:00 PM, online and in class

Overview

You will implement two simple, reliable data transport protocols: Stop-And-Wait and Go-Back-N. Your implementation will differ very little from what would be required in a real-world situation.

Since you probably don't want to modify your own Operating System, your code will execute in a simulated hardware/software environment. However, the programming interface provided to your routines, i.e., the code that would call your entities from above and from below is very close to what is done in an actual UNIX environment. (Indeed, the software interfaces described in this programming assignment are much more realistic that the infinite loop senders and receivers that many texts describe.) Stopping and starting of timers is also simulated, allowing you to simulate timer interrupts for your transport protocol.

Procedures

The procedures you will write are for the sending entity (A) and the receiving entity (B). Only unidirectional transfer of data (from A to B) is required. Of course, the B side will have to send packets to A to acknowledge (positively or negatively) receipt of data. Your will implement a set of procedures described below. These procedures will be called by (and will call) procedures that are part of a network simulator. The overall structure of the environment is shown below:

The unit of data passed between the upper layers and your protocols is a message, which is declared as:

struct msg {
    char data[20];
};

This declaration, and all other data structure and emulator routines, as well as stub routines (i.e., those you are to complete) are in the file, prog2.c, described later. Your sending entity will receive data in 20-byte chunks from layer5; your receiving entity should deliver 20-byte chunks of correctly received data to layer5 at the receiving side.

The unit of data passed between your routines and the network layer is the packet, which is declared as:

struct pkt {
    int seqnum;
    int acknum;
    int checksum;
    char payload[20];
};

Your routines will fill in the payload field from the message data passed down from layer5. The other packet fields will be used by your protocols to insure reliable delivery, as we've seen in class.

The routines you will write are detailed below. As noted above, such procedures in real-life would be part of the operating system, and would be called by other procedures in the operating system.

Software Interfaces

The procedures described above are the ones that you will write. I have written the following routines which can be called by your routines:

The simulated network environment

A call to procedure tolayer3() sends packets into the medium (i.e., into the network layer). Your procedures A_input() and B_input() are called when a packet is to be delivered from the medium to your protocol layer.

The medium is capable of corrupting and losing packets. It will not reorder packets. When you compile your procedures and my procedures together and run the resulting program, you will be asked to specify values regarding the simulated network environment:

Stop-And-Wait

You are to write the procedures A_output(), A_input(), A_timerinterrupt(), A_init(), B_input(), and B_init() which together will implement a stop-and-wait (the alternating bit protocol, which we referred to as rdt3.0 in the text) unidirectional transfer of data from the A-side to the B-side. Your protocol should use both ACK and NACK messages.

You should choose a very large value for the average time between messages from sender's layer5, so that your sender is never called while it still has an outstanding, unacknowledged message it is trying to send to the receiver. I'd suggest you choose a value of 1000. You should also perform a check in your sender to make sure that when A_output() is called, there is no message currently in transit. If there is, you can simply ignore (drop) the data being passed to the A_output() routine.

You must put your procedures in a file called stopandwait.c. You will need the initial version of this file, containing the simulation routines we have written for you, and the stubs for your procedures. You can obtain the program from /cs/classes/cis432/program2.

Make sure you read the "helpful hints" given later in this assignment.

Go-Back-N

You are to write the procedures A_output(), A_input(), A_timerinterrupt(), A_init(), B_input(), and B_init() which together will implement a Go-Back-N unidirectional transfer of data from the A-side to the B-side, with a window size of 8. Your protocol should use both ACK and NACK messages. Consult the alternating-bit-protocol version of this lab above for information about how to use the network simulator.

We would STRONGLY recommend that you first implement Stop-and-Wait, and then extend your code to implement Go-Back-N. Regardless, you must copy stopandwait.c to a new file called gobackn.c and put your Go-Back-N procedures in this new file.

Some new considerations for your Go-Back-N code (which do not apply to the Stop-and-Wait protocol) are:

BiDirectional Transfer

Graduate students must also implement bidirectional transfer of messages. For undergraduates, they will receive extra credit for implementing this. In this case, entities A and B operate as both a sender and receiver. You may also piggyback acknowledgments on data packets (or you can choose not to do so). To get the simulator to deliver messages from layer 5 to your B_output() routine, you will need to change the declared value of BIDIRECTIONAL from 0 to 1.

Helpful Hints

Turning in the Assignment

You must submit all your source code online. Do not submit any object code. Use the submission instructions for this program, which are available in the Schedule section of the class web page.

You must also print out and fill in the survey for this program. The survey is also available in the Schedule section of the class web page. Turn this in to my office on the due date (or put it under my door).

You must also include a printout showing some sample output from your program. The procedures you write should print out a message whenever an event occurs at your sender or receiver (a message/packet arrival, or a timer interrupt) as well as any action taken in response.

For Stop-and-Wait, your sample output should be for a run up to the point (approximately) when 10 messages have been ACK'ed correctly at the receiver, using a loss probability of 0.1, a corruption probability of 0.3, and a trace level of 2. Annotate your printout with a colored pen showing how your protocol correctly recovers from packet loss and corruption. You will be graded based on how well your sample output illustrates the correct operation of your protocol.

For Go-Back-N, your sample output should be for a run that is long enough so that at least 20 messages are successfully transferred from sender to receiver (i.e., the sender receives ACKs for these messages), using a loss probability of 0.2, a corruption probability of 0.2, a trace level of 2, and a mean time between arrivals of 10. Annotate parts of your printout with a colored pen showing how your protocol correctly recovers from packet loss and corruption.

Grading

You will be graded based on how well your protocols handle corruption and packet loss, as well as how they conform to the definition of Stop-and-Wait and Go-Back-N. One of the primary sources of information for this grading will be your sample output. Be sure your annotation of the output is clear and illustrates the correct operation of your protocol.

If you wish to receive partial credit for a program that does not operate correctly, you must print out clear and concise information when the program is run. I will use this information to determine how much of your program works and therefore how much partial credit you will receive. The more helpful and clear your output is, the better your chances. You should apply this same standard to how you document your code.

Any program that does not compile or that crashes while running will receive a 0.