程序代写代做代考 Introduction

Introduction
Assignment 2 due 9 Oct 2016
Implementing a Reliable Data Transfer Protocol using UDP
Your task is to write a client and a server program implementing a simple reliable data transfer protocol using UDP. You are given the option of implementing one of the following protocols: stop-and-wait protocol (rdt v.3.0), Go Back-N, or Selective Repeat.
Prototypes for a client and a server are provided in the start-up codes (downloadable from our stream website): Rserver_UDP.cpp and Rclient_UDP.cpp. In addition, two auxiliary programs are also available, myrandomizer_windows.h and CRC_simple.c. Use the makefiles provided to build these programs.
The client must be able to perform a successful file transfer operation on a (simulated) unreliable channel. Packets can be lost and/or damaged randomly during transmission.
The client:
The server:
– reads “data_for_transmission.txt”
– adds a header composed of a title and a sequence number (e.g., “PACKET #”) – adds the payload data with ‘\r\n’ at the end
– then sends the segment via UDP
– reads the packet via UDP
– extracts the line by separating it from the header (i.e., filters “PACKET #”) – saves the line on a file called “data_received.txt”
If no packet is damaged or lost, the result is that data_received.txt is identical to data_for_transmission.txt. However, as we want to simulate an unreliable channel, we are going to force packets to be transmitted with damaged bytes, or to be discarded. In that case, the file received by the server will be different from the original one.
Guidelines
For checking the integrity of the packets, you can use a simple CRC implementation that comes with the start-up codes. (available inside CRC_simple.c).
In order to simulate the unreliable channel, we wrapped the sendto() function with our own send_unreliably() function. The receiving function is used in the same fashion as the TCP samples, receiving one byte at a time. In UDP the generic receive function is replaced by:
int recvfrom(int socket, char *buffer, int length, int flags, struct sockaddr *sender_address, int *address_size);
Running the code
You are allowed to change and add new functions to the start-up codes, but you are not allowed to change the randomization process (no changes in myrandomizer_windows.h). Later on you may use the CRC function that is provided in CRC_simple.c.
Initially, try to run the prototypes without any losses. The randomization can be done separately for the client and the server. Start the server with:
Rserver_UDP 1235 0 0
Then the client with:
Rclient_UDP 127.0.0.1 1235 0 0
You should see messages from both programs. The messages coming or going are represented by arrows. For example:
<-- SEND PACKET 9 line 9 jjjjjjjjjjjjjjjjjjjj RECEIVED --> ACKNOW 9
The client will proceed reading and sending 10 lines of text. The server should be able to read those messages, split the message (filter the header off) and save the file. Compare the two *.txt files. Are they identical?
Now try to introduce some random problems in the channel, firstly in the client’s side only. After running it, are the two *.txt files identical? What are the differences?
You can perform the tests more easily by using a batch file. See the run.bat file that comes along with the start-up codes.

Marking the assignment
The assignment is going to be marked based on functionality (i.e., checking the contents of data_received.txt). The marks are distributed as follows:
– 2 marks: correct use of the CRC function.
– 3 marks: correct use of ACKnowledgments.
– 4 marks: Retransmits packets that are damaged or lost.
– 3 marks: avoids packet duplication.
– 3 marks: Receipt of in-order packets
– (3 bonus marks) will be awarded if you can correctly implement either the Go Back-N or Selective Repeat protocol
Notes
0 – zip all the files necessary to compile your codes, and do this by compressing the entire folder
1 – Submit your files electronically via Stream. You should submit the complete set of files, required to compile your codes, including the makefile, etc. Bundle all your files together in a *.zip file.