Assigned February 24th, to be completed by March 3rd.
Turn in this exercise by e-mailing to jmoroney@hawaii.edu allyour code.
You may do this assignment in groups of up to three.Your team cannot include anyone that was on your team in Assignment 5.
Alternating-Bit-Protocol You are to write the procedures, Aoutput, Ainput, Atimerinterrupt, Ainit,Binput, and Binit which together will implement a stop-and-wait (i.e., 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.
- The propagation delay between the two hosts is 10 milliseconds. What is the maximum throughput, expressed in frames/second, that the alternating bit protocol can obtain on this link if each data frame has a length of 125 bytes and acknowledgments are 25 bytes long. Same question if the protocol is modified to support 1500 bytes long data frames.
- In this section, we present an alternating bit protocol with a sender and a receiver processes that are subject to message loss faults. Using the synthesis method presented in 1, we synthesize an alternating bit protocol that is nonmasking faulttolerant; i.e., when faults occur the program guarantees recovery to its invariant.
- The second example is the alternating bit protocol, a basic communica-tion protocol underlying many more advanced protocols. Because of simplicity of the framework of Kahn networks our implementation of this protocol turns out to be relatively lightweight. Our treatment is very much in uenced by 4.
- ICS 451 Assignment 6: Alternating Bit Protocol Assigned February 24th, to be completed by March 3rd. Turn in this exercise by e-mailing to jmoroney@hawaii.edu all your code. You may do this assignment in groups of up to three. Your team cannot include anyone that was on your team in Assignment 5.
This assignment transfers a file from one machine to another,100 bytes at a time (the last packet may be less than100 bytes). Data bytes are sent over UDP, with a 1-byte headerin front of the data. The header is described below.
You must write two programs, a sender.c and a receiver.c.Each program takes a file name as its only command-line parameter -- theparameter for the sender is the name of the file to send, the parameterfor the receiver the name of the file to save as.
You must choose a UDP port for the receiver to listen on, and the sendershould send to that port. The port number must be a constant definedin a header file used by both the sender and receiver:
(I purposely used an invalid port number as the example because I wantyou to choose your own port number).
Cached
The receiver must bind this port number. The sender should send tothis port number on localhost (127.0.0.1 -- but see below for options),using a UDP socket and sendto.
The sender must:
- get the size of the file (see below)
- malloc an array of the same size as the file
- read the file into the array (after opening the file)
- send the contents of the array, 100 bytes at a time
- each packet must have a 1-byte header with a value of 0 or 1, indicatingthe sequence number. The first packet has the sequence number 0. Theheader is followed by the data, which is always 100 bytes exceptfor the last packet.
- after sending each packet, wait for the ack, which is a 1-bytepacket with a value of 2 (to acknowledge 0) or 3 (to acknowledge 1).Your code should ignore any packet received which is not an ack,after printing an appropriate error message.
- if there is no ack within 2 seconds (as measured by callingalarm -- you will need a handler for SIGALRM),retransmit the most recently sent packet (repeat until you get the ack)
- if the last packet is a full 100 bytes of data, send an additionalpacket with just the header (sequence number), and no data. If thelast packet is less than 100 bytes data, do not send the packet withzero bytes.
- once the last packet has been acked, print a message to confirmthat the file has been transmitted correctly.
Correspondingly, the receiver must:
- check whether the file already exists, and if so, print anerror message and exit.
- create the file.
- repeatedly read packets, distinguishing new packets fromretransmitted packets (and discarding any invalid packets as above)
- save to the file the data of each new packet
- send an ack for each received packet. Acks should be sentboth for new packets and for retransmitted packets. The acksshould be sent to the address that the packet was received from.
- once a packet is received with less than 100 bytes of data,save this last packet (if it has more than 0 data bytes), ack it,close the file, and exit.
Turn in your code for these two programs. The codewill includesender.c,receiver.c,the header file used by your two programs, and possibly other sourcefiles (as always, do not send binary files).
Measuring the size of a file
You may use the following code to measure the size of a file:
Testing retransmission
Lab #7 – Programming: Reliable Transport - Alternating Bit
Normally, the receiver will be started before the sender.
The simplest way to test retransmission is to not start the receiverat all, or to start it some time after the sender. This way, the sendershould keep sending the first packet over and over again.
To do more elaborate testing (not required for this assignment),you could drop a packet (instead of sending it) if, for example,
Options
If you wish, you may allow the sender to have a second parameter,the domain name or IP number of the machine on which the receiver isrunning, and send to that address instead of localhost.
Alternating Bit Protocol C Program
If you wish, instead of reading the whole file and storing thecontents into the malloc'd array, the sender may read the file 100 bytesat a time into a fixed 100-byte buffer (or 101-byte buffer), just sendwhat it read, and repeat.
Computer Networks, ICS 451
Instructor: Edo Biagioni