Implementing a Reliable Data Transfer Protocol


Cleveland State University

Department of Electrical Engineering and Computer Science

In this project, you will be implementing the rdt3.0 protocol covered in lecture 7. In this project description, we refer this protocol as PAR (Positive Acknowledgement with Retransmission) protocol.

The execution of network protocols is typically event-driven. Such events include the arrival of a message from the lower or higher level, and the expiration of a timer. The event is often called an interrupt.

Consider a layer n and its adjacent layers n+1 and n-1, as shown in the figure above. When layer n+1 has a message to send, it invokes the send interface provided by the layer n and passes the message to layer n. Layer n maintains a send buffer to store message to be sent (and to be retransmitted). If the buffer is already full when layer n+1 tries to send a message, an error will be returned. The send call will trigger an event so that the thread that is executing the layer n protocol can fetch the message in the send buffer and passes it to the lower layer (n-1) afternoon adding a layer n header.

Similarly, when a message arrives at layer n-1, an event is generated and the layer n protocol thread is woken up to handle the message. In general, the message is initially stored in a receive buffer of layer n before it is delivered to layer n+1, for a number of reasons (e.g., to ensure source ordering in TCP). In our PAR protocol, this buffer is not used because the message is delivered right away.

Since layer n-1 might be lossy, layer n must implements a retransmission mechanism to retransmit the messages to be sent, if the acknowledgement does not arrive in time. To do this, the protocol starts a timer each time it transmits (or retransmits) a message. If the timer expires, an event is generated and the protocol thread is woken up to perform the retransmission operation.

Event-driven programming is not trivial. Therefore, you are provided with Java skeleton code and the binary (Java byte code) files for a reference implementation for this project. In the reference implementation, the main thread executes the PAR protocol, and a separate thread is used to pick up messages arrived from UDP in the simulated network layer. The timer is implemented using the facility provided by Java (java.util.Timer and java.util.TimerTask). You are strongly encouraged to build your project based on the skeleton Java code. However, you are free to choose a different programming language if you wish, in which case, you will have to implement the simulation environment as well as the PAR protocol from scratch.

For completeness, the PAR finite state machine specification for the sender and receiver (partial) is shown below:

Partial finite state machine for the receiver (it is the same as that for rdt2.2).

Finite state machine specification for the sender.

The reference implementation consists of the following files:

  • ByteArrayUtils.java � implements utility methods to convert byte array to integer and vice versa.
  • TransportLayer.java � An abstract class that encapsulates the common data structures and methods for PAR sender and receiver. The abstract method run() is to be extended by the ParSender and ParReceiver classes.
  • Packet.java � The class that defines the structure of the packet, i.e., the transmission unit of the PAR protocol. Encoding and decoding methods are also provided, together with a simple frame verification method.
  • ParReceiver.java � The class that implements the PAR receiver protocol. It is a subclass of TransportLayer class. For simplicity, the application sender is integrated with this class.
  • ParSender.java � The class that implements the PAR sender protocol. It is a subclass of TransportLayer class. For simplicity, the application receiver is integrated with this class.
  • LossyChannel.java � This class simulates the noisy and lossy channel using UDP.

How to run the reference implementation binaries:

  • Download all the jar file (par.jar) and expand it in your working directory: jar xf par.jar
  • First, start ParReceiver: java ParReceiver
  • Then, start ParSender: java ParSender
  • The ParSender will prompt you to enter a new message when it is ready. Best in mind that the message length is limited to 1024 bytes.

Tasks:

To keep the difficulty of the project in the reasonable level, most of the files above will be provided with full implementation. Your tasks include:

  1. Thoroughly read and understand the code provided (This task does not apply if you choose to implement this project in a different language)
  2. Complete the main protocol loop in the run() method in RarReceiver and ParSender classes.
  3. Modify the send() method defined in the LossyChannel class so that you can control the loss rate dynamically. The reference implementation has a hard coded loss rate of 30%, i.e., 3 packets will be lost for every 10 packets sent. There are a number of ways you can use to convey the loss rate information dynamically (i.e., at runtime) to the program, e.g., through command line, environment variables and Java Properties. Please consult with the Java Tutorial for detail: http://java.sun.com/docs/books/tutorial/essential/environment/config.html
  4. Modify the getMessageToSend() method in ParSender class so that it can fetch packets to send from a file (ASCII file would be fine).
  5. Modify the deliverPacket() method in ParReceiver class so that it extracts the packet from  the frame received and write the payload into a file.
  6. The above two tasks enable the measurement of the performance of the PAR protocol. You need to instrument the ParSender class to measure the total time required to transmit a big file. If you choose to use an ASCII file, it should include at least 1,000 lines. You need to perform the latency measurement under the following configurations: 0 loss, 10% loss, 20%, and 30%. You can take the measurement on the same machine, or on two computers. The measurement result can be reported in a table or in a figure.

Deliverables:

  • Source code.
  • Your input file for the performance test, and proof for transmission correctness (comparison result for your input and output files).
  • Project report describing your implementation and performance measurement results.
  • Demonstration.

Extra credit (3% of the course):

The reference implementation has only a simple verification test on the correctness of the frames received. It includes a preamble with each frame sent and check the validity of the preamble. This check does not work if the transmission error occurs after the preamble part in a frame. To improve the current implementation, you need to compute a checksum for each frame and include the checksum as a trailer in each frame sent, and verify the checksum of each frame received.

Because UDP ensures no corruption for packets delivered, you need to instrument the LossyChannel class�s send() method to inject corruption into packets to be sent. Again, the corruption incidence should happen randomly with controllable probabilities, just like the segment loss rate.

Appendix: How to run the reference implementation binaries in Eclipse:

  • Download and install the eclipse on your machine. Please go to eclipse.org and find the right version for you.
  • Open eclipse by double click the icon under the installation directory.
  • When the Workbench is launched, the first thing you see is a dialog that allows you to select where the workspace should be located. The workspace is the directory where your work will be stored. You can choose the default one or create a new directory by yourself.
  • After the workspace location is chosen, the main interface of Eclipse SDK should show up subsequently.
  • Then create a new project and select Java Project in the dialog. And click next.
  • Type in your project name and click finish. Choose Yes when you see Open Associated Perspective.
  • Now you should see the project in the Package Explore on the left side.
  • Download the jar file (par.jar) and put it in your workspace -> your project home directory.
  • Right click the project name and refresh it, you should see the par.jar under your project name from the Package Explorer.
  • Right click the project name and choose Build Path -> Configure Build Path. Then you should see a window of Properties for Project. Then choose Libraries tab, you should see like this
  • Click Add JARs if your jar file is under the Project home directory. And find the par.jar file click it and choose OK to go back to the Build Path window. Click OK to finish add jar file.
  • Now you should see the par.jar file under Referenced Libraries.
  • Click par.jar file and then click RUN button and choose run as Java Application. Or right click par.jar file and choose Run As -> Java Application
  • Then it is the time to choose which java application you want to run.
  • First, start ParReceiver. You should see the result in the Console (bottom side of the window).
  • Find the New Console button, click the drop down list and choose New Console View.
  • Right click the Console and choose the Detached for at least one of two consoles. Now you will see both of the consoles with the same thing.
  • Right click the par.jar, Run As -> Java Application. Or drop down list of run button (don�t click run button here). Run ParSender. You will see both consoles change to the ParSender. Click Display Select Console for one console. You should see both of ParReceiver and ParSender now.
  • The ParSender will prompt you to enter a new message when it is ready. Best in mind that the message length is limited to 1024 bytes.
WE’VE HAD A GOOD SUCCESS RATE ON THIS ASSIGNMENT. PLACE THIS ORDER OR A SIMILAR ORDER AND GET AN AMAZING DISCOUNT