Solved–Project 7– SOlution

$35.00 $24.00

Learning Objective During this project, you will implement the simplest of Transport Layer Protocols, the Stop-and-Wait Protocol for the reliable transfer of data through an arti cial network. Speci cally you will: Demonstrate how messages are segmented into packets and how they are reassembled. Understand why a checksum is needed and when it is used.…

You’ll get a: . zip file solution

 

 
Categorys:
Tags:

Description

5/5 – (2 votes)
  • Learning Objective

During this project, you will implement the simplest of Transport Layer Protocols, the Stop-and-Wait Protocol for the reliable transfer of data through an arti cial network. Speci cally you will:

  • Demonstrate how messages are segmented into packets and how they are reassembled.

  • Understand why a checksum is needed and when it is used.

  • Understand and implement the Stop-and-Wait Protocol with ACK (Acknowledgments), NACK (Negative Acknowledgments), and re-transmissions.

For a description of the Stop-and-Wait Protocol, read Section 13.6.1 in your textbook.

  • The Protocol Stack

Here is a diagram that shows where the code in this project ts into the protocol stack:

Application Layer

client.c

Transport Layer

rtp.c

Network Layer

Link Layer

Physical Layer

Figure 1: The Protocol Stack

Note that the Network Layer, Link Layer, and Physical Layers are all implemented by your operating system or networking hardware. For the sake of this project, you will be using the UDP transport protocol to emulate an unreliable network layer. The application program, client.c, simply makes the appropriate calls to connect to the remote server, send and receive messages, and disconnect from the remote server. You will be providing the send and receive features for the client to use in rtp.h.

  • Code Walkthrough

Here, we will brie y describe the code provided for this project. It is important that you study and understand the code given to you. In the past, we have asked students to write a large portion of this code, but we have found this to be unreasonable during the last few weeks of school. As a compromise, we have ginve you this code and simply ask you to complete it. However, YOU ARE RESPONSIBLE FOR UNDERSTANDING ALL OF THE CLIENT’S CODE.

The client program takes two arguments. The rst argument is the IP address of the server it should connect to (such as 127.0.0.1, the localhost), and the second argument is the port number it should connect to. You may call the client from the terminal like so:

  • $ ./prj7 client 127.0.0.1 8080

The client.c program represents the application layer. It uses the services provided by the Transport Layer (rpt.c). It begins by connecting to the remote server. Look at the socket setup() in rpt.c – it creates the UDP socket that is used to emulate an unreliable network. The socket setup() function also initializes and returns a CONN INFO structure. Next, the client program sends a message to the remote server using the rtp send message() function. The client program also receives messages from the network. If the message isn’t available or if the entire message has not been received, then the rtp receive message()

CS 2200

Georgia Tech,

Instructor: BIll Leahy

Project 7

function should block until the message has been received from the server. The client program continues to send and receive messages until it is nished. Lastly, the client program calls rtp disconnect() in order to terminate the connection with the remote server. Note that there are four distinct types of Transport Layer packets:

  1. DATA is a data packet that contains part of a message in its payload.

  1. LAST DATA is just like a data packet, but it also says that it is the last packet for the message.

  1. ACK is an acknowledgment that a packet was properly received.

  1. NACK is a negative acknowledgment that the packet was not properly received.

  1. TERM is used to tell the server to close the connection early (this is not speci cally needed for the project).

  • Implementation

    1. (20 points) Segmentation of Data When data is sent over a network, the data is chopped up into one or more parts and each part is sent inside a packet. A packet contains information that describes the message; it contains information such as the source and destination of the packet, the type of data, and the data itself. The data being sent over the network is referred to as the \payload”. Look in rtp.h

      • what other elds does our network packet carry? Think about why each eld is needed. How much payload can we t into each packet? Note that the packet structure in this project is greatly simpli ed.

Open up rpt.c and nd the packetize() function. Complete this function. Its purpose is to turn a message into an array of packets. It should do the following:

  1. Allocate an array of packets big enough to carry all of the data.

  1. Populate all the elds of the packet including the payload. Remember, the last packet should be a LAST DATA packet. All other packets should be DATA packets. This is very important! The server does check for this, and it will disconnect if these elds are not lled in properly. If you do not mark the last packet is LAST DATA, the server will hang forever!

  1. The \count” variable points to an integer. Update this integer, setting it equal to the length of the array you are returning.

  1. Return the array of packets.

Hint: Remember that when you divide the length of the message by the length of the packet you are performing integer division. It may not always be the case that the message is a multiple of the packet size. Think of a way to handle this special case.

  1. (80 points) Bad things happen in an unreliable network. In the Stop-and-Wait protocol, sending a message requires the following individual steps:

    1. Send one packet at a time.

    1. After each packet, wait for an ACK or NACK to be received.

    1. If a NACK is received, resend the last packet. Otherwise, send the next packet.

Receiving a message requires the following additional steps:

  1. Compute the checksum for each packet payload upon arrival.

  1. If the checksum does not match the checksum reported in the packet header, send a NACK. If it does match, send an ACK.

Note that most Stop-and-Wait Protocols also implement a sequence number to handle lost packets. We will ignore this issue in order to keep the project simple. You should think about why it may be necessary to keep track of sequence numbers.

Page 2

CS 2200

Georgia Tech,

Instructor: BIll Leahy

Project 7

  1. (20 points) Open rtp.c and nd the checksum() function. Complete this function. Simply sum up the ASCII values of each character in the bu er and return the sum. This is how the server computes the checksum. The server and the client use this checksum.

  1. (30 points) Open rtp.c and nd the rtp receive message() function. This message is for receiving messages from the data connection. To do this, you will use CONN INFO and the recvfrom() function. If the packet is a DATA packet, the payload will be added to the current message bu er. The packet’s payload should only be added to the bu er if the checksum of the data matches the checksum in the packet header. if the checksum matches, you should send an ACK packet using sendto(). If the checksum does not match, then you should send a NACK packet in the same manner.

  1. (30 points) Open rtp.c and nd the rtp send message() function. This function should handle packetizing the message and sending the packets one by one using sendto(). You should then accept the server’s response using recvfrom(). If the response is an ACK, you should send the next packet. Otherwise, you should resend the packet. Continue to do this until all of the packets have been sent.

  • Running the Project

To compile all of the code, use the following command:

  • $ make

To run the server on linux, use the following command to run the server:

  • $ ./prj7 server p [port number] [ c corruption rate]

To run the server on mac, use the following command to run the client:

  • $ python prj7 server p [port number] [ c corruption rate]

Regardless of operating system, make sure that python is bound to python 2. The server will not run on python 3! Your client should work with an UNMODIFIED version of the server. For example, if you wanted to run a server on port 8080 with a corruption rate of 99%, you would execute the following command:

  • $ ./prj7 server p 8080 c .99

If you wanted to run a client that would send messages to this server, you would then execute the following command (in a di erent terminal):

  • $ ./prj7 client 127.0.0.1 8080

The server will take the client’s messages and then convert them into Pig Latin. The server will be printing out debug statements in order for you to understand what it is doing. To make a .tar.gz simply execute the following command:

  • $ make submit

Make sure to submit this archive on T-Square.

Page 3