联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp

您当前位置:首页 >> C/C++编程C/C++编程

日期:2020-11-29 10:32

UNIVERSITY OF DELAWARE

DEPARTMENT OF COMPUTER & INFORMATION SCIENCES

CISC 650 / CPEG 651 / ELEG 651: Computer Networks II

Programming Project 2

Due Date: 11 pm on Thursday December 3, 2020

This project is an individual assignment and must be done independently by each

student. Collaboration with or help from anyone else is not permitted.

Important note: Before you start this project, read the accompanying document Project 2 Help, which

contains important and useful information about this project.

This project will build upon the programs you wrote in Project 1 for the client, server, and router. In this

project, the client will send a text file to the server using the Go-Back-N protocol. As in Project 1, all

packets between the client and server will flow through the router which will simulate errors and packet

loss. All your programs must run on the course VM cisc650.cis.udel.edu. For convenience, both the

hostname and the port numbers may be hardcoded into the client, server, and router, but this should be done

in such a way that they should be easy to change.

As you know, UDP does not provide reliable data transfer, whereas a user transmitting a file would expect

the file to be transferred reliably. In this project, you will implement reliable data transfer with the GoBack-N

protocol. In practice, UDP does not often lose packets, particularly over short distances or while

communicating between processes on the same host. This is why we have built a router that introduces

errors and loss into packets, so you can test your protocol implementation under more realistic conditions.

You will use the router program from Project 1 with no modifications. But you will have to modify the

client and server programs to carry out the requirements of this project.

Packet Formats

All packets in this project will have the same format shown in Figure 1 of Project 1. The meaning of all the

header fields is the same as it was in Project 1.

However, there are two types of packets in this project:

? Data packets are sent by the client to the server and they may have a payload field with 0 - 40

bytes of data. The Sequence Number in data packets carries the packet sequence number used

by the Go-Back-N protocol. You should assume that this sequence number starts with 0 and

increases sequentially until 15 after which it wraps back to 0.

? ACKs are sent by the server to the client and they have a payload field with 0 bytes of data.

The Sequence Number in an ACK is the ACK sequence number used by the Go-Back-N

protocol. As with data packets, this number must be in the range 0 - 15.

General Actions

As in Project 1, the router is started first, then the server is started, and finally the client. The job of the

client is to send the contents of the input file named data.txt to the server. As the server receives data packets

from the client, it stores the received data in an output file named out.txt.

The client constructs packets to send to the server by reading one line at a time from the input file. Each

line in the input file contains a sequence of printable characters (no control characters, etc.), with no more

than 39 characters on a line. The contents of each line should be transmitted as a separate packet. Since

different lines may have a different number of characters, this means that different data packets will have

different sizes. The “newline” character read from the file at the end of each line is also transmitted in the

packet. Note that the “newline” character is different from the C “null” character; the “null” character

should not be transmitted in any of the data packets sent from the client to the server. Also note that you

will never have more than 40 data bytes in a packet including the “newline” character.

The client must read the file one line at a time and send it in a packet before reading the next line. It is not

permissible to read the entire file and store it in the client before transmitting its lines.

The client assigns a sequence number to each packet that it transmits. These sequence numbers start with 0

and are then incremented for each packet. After sequence number 15, the numbers wrap around to 0 again.

Thus they will always be in the range 0 – 15. The server returns an ACK for each correctly received packet

with the ACK containing the sequence number of the latest correctly received in-sequence packet, in

conformance to the Go-Back-N protocol. Recall that ACKs are cumulative in this protocol.

The client uses a window size in the range 1 – 8 and keeps a copy of all unACK’ed packets until they get

ACK’ed. The client can transmit packets continuously until the window becomes full. After that, it can only

transmit packets if and when space becomes available in the window due to received ACKs.

When the client is finished transmitting all the lines in the data file, and has received ACKs for all of them,

it then sends a special last packet signifying “End of Transmission”. This packet will have a Count of 0 and

no data characters. It will have a Sequence Number that is the next sequence number that would have been

used if this were a valid data packet. It will also have a Checksum of 0. It is important that this packet be

transmitted only after the client has received ACKs for all transmitted data packets. The server will not

transmit an ACK for the EOT packet, and the client will not expect any ACK to be returned for it. The

client program can terminate once this packet has been transmitted. When the server receives the EOT

packet, it also terminates.

The server must check if a received data packet is a new packet, in which case the data received is stored

in the output file. If it is not a new packet (it is either a duplicate or out-of-sequence), its data is not stored

in the output file. An appropriate ACK must be returned in all cases, in accordance with the Go-Back-N

protocol.

The Project 2 Help document provides more details and help on how to implement the Go-Back-N protocol

on both the client and the server.

Client Configuration Parameters

When the client starts, it is given the following configuration parameters by the user:

? Window Size: An integer between 1 and 8.

? Timeout: The user enters an integer value n in the range 1-10, and the timeout value is then stored

as 10n microseconds. Note that the resultant timeout value should be stored with both seconds and

microseconds components (see the Help document).

These parameters should ideally be provided as command-line arguments when the client is started.

Alternatively, the client may prompt the user to enter values for these parameters and then read in these

values immediately after startup. It is not acceptable to hard code values for these parameters in your code.

Output of your program

At specific places in both your client and server programs, you must print out specific messages. The

symbol “n” below refers to the sequence number of the transmitted or received packet (note that the

sequence number must always be in the range 0 - 15), the symbol “c” below refers to the count (number

of data bytes) in the transmitted or received packet, and the symbol “s” below refers to the total size of the

transmitted or received packet. The total size includes the sizes of both the header and the data, and should

be obtained from the return values of the sendto or recvfrom functions, as the case may be.

The messages to be printed by the client are:

When a new data packet numbered n is sent by the client:

New packet n transmitted with c data bytes and s total bytes

When a data packet numbered n is retransmitted by the client:

Packet n retransmitted with c data bytes and s total bytes

When a non-corrupt ACK is received with number n:

ACK n received with s total bytes

When a corrupt ACK is received:

ACK received with corrupt checksum and s total bytes

When a timeout expires:

Timeout expired for packet numbered n

When the “End of Transmission” packet is sent:

End of Transmission Packet transmitted with sequence number n and s total bytes

The messages to be printed by the server are:

When a new non-corrupt data packet numbered n is received by the server in sequence:

New in-sequence packet n received with c data bytes and s total bytes

When a non-corrupt data packet numbered n is received by the server, but it is a duplicate or outof-sequence

packet:

Duplicate packet n received with c data bytes and s total bytes

When a corrupt data packet is received by the server:

Packet received with corrupt checksum and s total bytes

When an ACK is transmitted with number n:

ACK n transmitted

When the “End of Transmission” packet is received:

End of Transmission Packet with sequence number n received

At the end, before terminating execution, the following statistics should be printed. Do not include the last

special “End of Transmission” packet in the count of data packets in these statistics.

For client:

Number of new data packets transmitted

Total number of data packets transmitted (new plus retransmissions)

Total number of data bytes transmitted in new packets (this should be the sum of the count fields

of all transmitted new packets)

Total number of ACKs received (both corrupt and non-corrupt)

Number of ACKs received that were corrupt

Count of how many times timeout expired

For server:

Total number of data packets received (both corrupt and non-corrupt)

Number of data packets received that were corrupt

Number of non-corrupt duplicate or out-of-sequence data packets received

Number of non-corrupt new data packets received

Total number of new data bytes received (this should be the sum of the count fields of all received

non-corrupt new packets)

Number of ACKs transmitted

Testing

The files test1.txt and test2.txt in the directory /usa/sethi/networks/proj2 on cis650.cis.udel.edu are sample

input files that may be used by you to test your programs. It is strongly suggested that you first use

test1.txt for all your testing, and only if you have thoroughly debugged your programs, then proceed with

using test2.txt for further testing.

It is also suggested that you test your programs in phases using the following client and router

configuration parameter values:

? Window size 1, Timeout value n = 5, Packet and ACK loss rates 0.

? Window size 4, Timeout value n = 5, Packet and ACK loss rates 0.

? Window size 1, Timeout value n = 5, Packet loss rate 0.2, ACK loss rate 0.

? Window size 4, Timeout value n = 5, Packet loss rate 0.2, ACK loss rate 0.

? Window size 4, Timeout value n = 5, Packet loss rate 0, ACK loss rate 0.2.

? Window size 4, Timeout value n = 4, Packet loss rate 0.2, ACK loss rate 0.

Once you have tested and debugged with the above parameter values, then you should try combinations

of various other values for the parameters. Make sure your program works well under all conditions,

because we will test it out under a variety of different conditions.

Submission

Once you are ready for submission, create three scripts, one each for the client, the server, and the router.

Show the transfer of the file test1.txt with the first set of configuration parameters listed above. The scripts

should contain a long listing of the directory that contains your files (using ls -l), should show them being

compiled, then another long listing (using ls -l) of the directory after compilation is complete, a listing of

the input file (using cat filename) for the client, show the execution of the programs including the program

outputs, and then a listing of the output data file (for the server). Finally, the server script should do a diff

on the input and output files.

Submit a zipped copy of your project directory. This directory should include all your original source files,

the executables, the input and output data files, and the scripts generated by you for your test run.

Demo

You will be asked to schedule a time after your submission for a virtual meeting with me over Zoom. During

this meeting, I will run your programs under a variety of different loss and error conditions. Part of your

grade will depend on the results of this demo.

Grading

Your programs will be graded on correctness, proper output, readability, and documentation. The grade

distribution is as follows:

Correctness: 120 points

Proper Output and Testing: 30 points

Readability and Documentation: 20 points

Performance on the Demo: 30 points

Total: 200 points

As with Project 1, points for documentation will not be awarded lightly; we will be looking for meaningful

variable and function names, good use of comments, good modular structure with appropriate use of

functions, good programming style, and proper indentation.

No late assignments will be accepted, because we will have to schedule times for the demos.


版权所有:留学生编程辅导网 2020 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp