You are to implement and measure routines coded in C to perform transport layer functions (much like socket code in a real operating system would). The functions you write will be called by (and will call) procedures that are provided for you which emulate a network environment.
The functions you will write are for the sending entity (Client also known as A) and the receiving entity (Server also known as B). Transfer of data (from client to server) and acknowledgements from server to client are required.
Your routines will fill in the payload field from the message data passed down from the application layer (#5). The other packet fields will be used by your protocols to ensure reliable delivery, as we've seen in class. Stubs for all of the routines you are to complete are in the files, client.c and server.c. The purpose of those routines are described in the stucode documentation.
Copy all of the files into a directory of your own. You will need to finish writing the functions in the client.c and server.c files. You will need the other files to make the simulation run. The Makefile will help you to keep your executable current.
For Summer 2003: Do only the alternating-bit-protocol part of the assignment. Write the code for ABP (including the measurements) but do not attempt the GBN protocol part of the assignment.
All of the data passed between the layers is encoded in one of two opaque data types: a message_t or a packet_t. You cannot access these types directly. You access parts of these types by using the routines declared in the message.h file and the packet.h file.
Variables of these types are created dynamically. You must call their
new_
functions to create instances of them before you can
use them.
Documentation about the routines that you must use to access those
data types are in the
packet_t
documentation and the message_t
documentation.
You might want to use the function in checksum.c instead of writing your own. But if you don't write your own code you must give proper credit to the real author (me).
All of the emulator routines you will need to access are declared in the file KRnet.h. Those function are described in the KRNet documentation.
Run your ABP program with 120 messages, a loss probability of 0.1, a corruption probability of 0.3, and a trace level of 2.
Compute and print the following
You can use whatever approach for checksumming you want. Remember that the sequence number and ACK field can also be corrupted. I recommend a TCP-like checksum, which consists of the sum of the (integer) sequence and ACK field values, added to a character-by-character sum of the payload field of the packet (that is, treat each character as if it were an 8 bit integer and just add them together).
You can use the checksum code in checksum.c or you can make your own checksum. If you use packet.c then you must give proper credit so no one thinks that you wrote it yourself. If you write your own then you might be eligable for bonus points.
Note that any shared `state' among your
routines needs to be in the form of file-scope global
variables. Note also that any information that your procedures
need to save from one invocation to the next must also be a
global (or static
) variable. For example, your
routines will need to keep a copy of a packet for possible
retransmission. It would probably be a good idea for such a data
structure to be a file-scope global variable in your code. Note,
however, that if one of your global variables is used by your
sender side, that variable should not be
accessed by the receiving side entity, since in real life,
communicating entities connected only by a communication channel
can not share global variables.
The best way to make file-scope global variables in C is to
statically declare those variables at the top of the one file
where they are to be used before any of the functions.
Variables are declared statically when they are preceeded by the
storage class specified static. For example:
static int global_static_variable;
If you
do not declare the variable statically then it is exported to
the linker and might accidentally be used in another file.
clientEnd()
and serverEnd()
functions to print the results of your computations.
float
-type global variable called
KRtime
that you can access from within your code to
help you out with your diagnostics messages.
stderr
than stdout
.
An easy way to compile and link the code is to use the make (1) Unix utility. We've given you a Makefile to help with this. To compile and link your code just run make simABP (to make the alternating bit protocol version) or simGBN (to make the go-back-N version) from the Unix shell.
Answers to frequently asked questions about this assignment are in a another webpage.