In this project, you will be writing the sending and receiving transport-level code for a reliable data transfer protocol--Go-Back-N. 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. Stopping/starting of timers are also simulated, and timer interrupts will cause your timer handling routine to be activated.
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 receipt of data. Your routines are to be implemented in the form of the procedures described below. These procedures will be called by (and will call) procedures which emulate a network environment. The overall structure of the emulated environment is shown in Figure 1.
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, gbn.c, described later. Your sending entity will thus 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.
The routines you will write are detailed below. Such procedures in real-life would be part of the operating system, and would be called by other procedures in the operating system.
The procedures described above are the ones that you will write. The following routines are provided to you and can be called by your routines:
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 the procedures provided to you together and run the resulting program, you will be asked to specify values regarding the simulated network environment:
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.
You should put your procedures in a file called gbn.c. You will need the initial version of this file, containing the emulation routines that have been written for you, and the stubs for your procedures. You can obtain this program from gbn.c.
Some considerations for your Go-Back-N code are:
You will have to buffer packets that have been transmitted but not yet acknowledged. You'll also need buffering in your sender because of the nature of Go-Back-N: sometimes your sender will be called but it won't be able to send the new message because the new message falls outside of the window. In this case, you should buffer the message and send it later when the window is no longer full. Rather than have you worry about buffering an arbitrary number of messages, it will be OK for you to have some finite, maximum number of buffers available at your sender (say for 50 messages) and have your sender simply abort (give up and exit) should all 50 buffers be in use at one point (Note: using the values given below, this should never happen!) In the ¡°real-world,'' of course, one would have to come up with a more elegant solution to the finite buffer problem!
Copy gbn.c to your turnin directory. Then, go to your turnin directory and type the command: /home/course/cs586/public/bin/turnin cs586 project2.
You should also hand in a sample output. For your sample output, your procedures 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. You should hand in output for a run that was long enough so that at least 10 messages were successfully transferred from sender to receiver (i.e., the sender receives ACK for these messages), a loss probability of 0.1, and a corruption probability of 0.1, a mean time between arrivals of 10, and a trace level of 2. You should annotate parts of your printout with a colored pen showing how your protocol correctly recovered from packet loss and corruption.
You can use the 'script' Unix command to record a script of your interaction with the Unix system. Once it's started, the script session is dumping everything that shows up on your screen into some file. To obtain a copy of your program run, first issue the command ¡®script¡¯ to the Unix shell; then run your program. If you don't provide a file name to the script command, it places its output in a default file named 'typescript'. Do not use the name of your program's source code file as the filename for the output of the script command. If you type 'script gbn.c', you will overwrite and destroy whatever used to be in gbn.c. When your program terminates, exit from the scripting session by issuing the command 'exit' to the Unix shell. You should hand in a printout of the typescript file.
Total Score: 100 points
¡¤
Sender: 60 points
A_init(): 10 points
A_input (): 20 points
A_timerinterrupt(): 10 points
A_output(): 20 points
¡¤
Receiver 25 points
B_init(): 5 points
B_input() : 20 points
¡¤
Annotated sample output 15 points.