GDN programming assignment

Designing and implementing a communication protocol that is a basic ingredient for many other protocols.

Overview

In this assignment, each group of 2 students will design, implement, test and describe the sending and receiving code for a sliding window data link protocol: the Go Back N version. This lab should be fun since your implementation will differ very little from what would be required in a real-world situation.

Since we don't have standalone machines, with an OS that we can modify, your code will have to 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.

You can download the simulator here.

The routines you will write

Your routines are to be implemented in the form of the procedures described below. These procedures will be called by (and will call) procedures that have been written to emulate a network environment. The overall structure of the environment is shown in structure of the emulated environment. Note that this gives the uni-directional case, in this assignment we use the bi-directional case (#define BIDIRECTIONAL 1 in the code). Both A and B sides are then sending and receiving messages.

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 simulator program, simprog.c,, described later. Your sending entities will thus receive data in 20-byte chunks from a higher layer (called layer5); your receiving entities should deliver 20-byte chunks of correctly received data in the correct order to layer5 of the receiving side.

The unit of data passed between your routines and the lower layer (called layer3 here) is the packet, which is declared as:

struct pkt {
   int seqnum;
   int acknum;
   int checksum;
   struct msg mes;
    };

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.

Note that a global variable used by the A side routines may not be used by the B side routines (and vice versa), since in real live they run on different machines. To make live easy, you may use it for debugging (use the DEBUG define).

Software Interfaces

The following emulator routines can be called by your routines:

The simulated network environment

A call to procedure tolayer3() sends packets into the medium (i.e., is send out to the other side). 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 type in values regarding the simulated network environment, unless you give them on the command line:

The simulator can be compiled on any machine supporting C, it does not use special UNIX or Windows features. A problem could be the random number generator rand() and the largest integer mmm, used in the simrand() function. A simple check is performed on the returned random values and an error message is printed when this fails. In that case you have to change simrand() so that it works on your machine. When you handin your assigment, put the original simrand() back.

The Go Back N version.

You should implement a sliding window protocol using Go Back N. Your protocol should use both ACK and NACK messages. You can use the #define's as given in simprog.c, in that way you can use static declarations for buffers (e.g struct pkt window[2][NRBUFS] ) instead of having to use dynamic allocations. Test you routines for various values of these #define's and of the loss and corruption probabilities (e.g. 0.0, 0.1, 0.95). Put your procedures in a file called proggbn.c.

For the case "proggbn 10000 0.1 0.1 8.0 0", with NRBUFS set to 8 and TO_ACK set to 20.0, you should determine the "best" setting of the timeout value (TO_PKT) for packets. Consider both the transfer rate (messages per timeunit) and the loading of the network (packets per message).

You should handin your proggbn.c program, a design document describing your design and implementation, and a document describing how you have determined the time-out value.

Helpful Hints

Handin

The handin requirements are described already above, they contain the programs, design and implementation descriptions and the timing measurements and evaluations.

Send it in by email as an attachment in a compressed format.

You have a lot of time, but make a good planning. Start early as the protocols are not easy to implement, many things can go wrong, and often bugs are very hard to find and to correct.

Success,
Theo