Department of Information Technology

Assignment - Sliding Window

Username: your UpUnet-S email address (example: Name.Surname.1234@student.uu.se). Password: datakom.

The code must be Java 1.4.2 compliant

Introduction

In this assignment you should get to know better the transport protocol for reliable transfer of data i.e., a protocol like TCP. You will get a client program which uses a "stop & wait" policy for reliable transfer. The objective of the assignment is for you to improve the program so that it uses a sliding window and also something which resembles TCP fast retransmit.

This assignment will be written in Java. The level of Java knowledge required is very low, and anyone familiar with C or C++ should have no problems. Please see the "Resources" section at the end of this web page for more details about Java. Please note that you have to compile the Java code (the .java files) to produce the necessary .class files. You can compile your Java code with the command: javac Reliable.java. This assignment should not take more than 5-10 hours to complete.

Preparation

Read the section in the book that deals with Stop & Wait and Sliding Window. It is important that you understand the principle differences between the two different approaches for reliable transfer before you go any further. Please use this link: tar file zip file to download a compressed file which contains all the files that you need.

After you have copied and unpacked the tar file you should have the following files:

Client.class
Clientlink.class
DataGen.class
Link.class
Packet.class
readme.txt
Reliable.class
Reliable.java

You should work with the file called Reliable.java. This is the only file that you need to modify in order to complete the assignment. You don't need to create any new class files, just work within the Reliable.java file. Please comment your code to show that you understand how it works. The code must be Java 1.4.2 compliant.

Task

The given program implements a simple "Stop & Wait" protocol. That means that it sends a packet and then waits until it receives an ACK for that packet before it sends the next packet.

The goal of the assignment is to improve the given program with a "sliding window" protocol. The program should (just like TCP) send an amount of packets up to a full window - without needing to stop and wait for an ACK. That means that you should also implement a simple form of "fast retransmit". That works so that after the client has received a duplicate ACK i.e., two ACKs in a row with the same sequence number, it assumes that a packet was dropped and performs an immediate retransmit without waiting for a timeout. The ACKs that are used are accumulative, i.e., the server always says which sequence numbers it expects to get next.

A session between the client and the server is made up out of three parts. In the first phase you should authenticate yourself to the server with your username and password. You have to do that every time you run the program, and you cannot go further until you have given a correct username and password. You do this by typing them on the keyboard when they are asked for.

When you have passed the authentication phase the data transfer will occur. During the transfer you should user a number of given methods that you did not receive the source code for. These methods are described in more detail later in the instructions. The information that will be transferred in the data transfer phase is your own version of the file Reliable.java, i.e., the file that you have worked on for this assignment.

When the program has been completely transferred the client goes over to the marking phase. The client should send a packet with a sequence number of -1. In response to this the server should send a packet with length 1 and sequence number -1. The data in the last packet will be how many points you will receive for this assignment. The server checks your client program and gives back a result of 0, 40, 60 or 100 percent of the maximum amount of points:

Completed work Points
Neither sliding window or fast retransmit works: 0 percent
Fast retransmit works: 40 percent
Sliding Window (without fast transmit) works: 60 percent
Both Sliding Window and Fast Retransmit work: 100 percent

The code for the marking phase is given in Reliable.java and you do not need to modify it. The only code that you need to modify in this assignment is the code for data transfer.

Server

The server that your client needs to communicate with is running on the machine joshua.it.uu.se. You can test the given code that implements a "stop & wait" protocol by typing:

java Client joshua.it.uu.se 4123

If everything works ok that you should receive some text, at the end of which will be the text: "Success: 0% of the maximum amount of points.". You receive no points as you have not done anything yet. When you wish to test your implementation of sliding window and fast retransmit then you should type in:

java Client joshua.it.uu.se 5123

The reason that there is two different port numbers is that one is for the example code and the second is for your modified version. The server will be running until the deadline, after which it will be switched off. Please note that the server on 4123 expects the first seq to be 0 regardless of what the variable startseq is.

If you discover that the server doesn't work, in the worst case it might have crashed. Typically you receive the message "Connection refused" instead of the normal message. If the server is okay, then it should be working if you try again in about 5 minutes. The server is automatically restarted after 5 minutes if it has crashed.

Classes, Methods etc.

The Datagen class generates the packets that you should send. The constructor for the class takes a filename, reads in the file and then creates a sequence of packets. The method DataGen.generateData() returns a Vector of bytes which contains the packet contents that you should send.

The class Packet is used to create a packet. When a new packet should be constructed, you provide the constructor with a sequence number, length of the packet contents, an indication if the packet is an ACK or not, and the data contents. Since the client never sends ACKs itself, you don't need to handle the construction of ACKs - just concentrate on sending data and always set the third argument to false. The sequence numbers always start with 0 and grow by one for each packet that is sent.

The class Link is used for sending data to the server. The method Link.sendPacket sends a packet created with the class Packet's constructor to the server. The method Link.getPacket takes an argument which is a timeout which states how long (in milliseconds) you want to wait before a retransmit. If a timeout occurs the method casts an InterruptedIOException. In the other case the method returns a packet with the contents of the ACK.

The class Reliable is the class that you should modify. The constructor takes the following arguments: which link should be used, the size of the window and the time-out length in milliseconds. When you implement the sliding window you should not assume a specific window size, but rather you should use the size that was given to the constructor. The method Reliable.transfer is the one that performs the data transfer, and that is the method where you should implement the sliding window and fast retransmit. The given file contains examples of how the classes DataGen, Packet and Link should be used.

Hand-in format

To check how your program works, you should run it against the server running on joshua.it.uu.se port 5123 as described above. Since the file Reliable.java is the one that you have modified and it is transferred to the server, you do not need to hand in anything else, i.e., this is the hand in for this assignment. If you are working in pairs - which is recommended - you should run the program twice with a different username and password. At the beginning of the source code file, please write your name and your personal number and whether or not you have worked together with another student.

It is possible to run the client program as many times as you want, but the points that you will receive will be from the last time that you ran the client program.

Hints

  • Think before coding
  • Slides which explain "Sliding window" can be found here (L-Å Larzon)
  • The ACK number is not the ACK of the transmitted segment, but rather the ACK for the segment the server expects to see

Allocation of points and Deadlines

In order to pass the assignment you need to get 100% of the points. This is however not enough. The code will be checked and there are ways to get 100% without passing.

Resources

Deadline

(The deadline for this assignment is 19/10.) The deadline is changed to 21/10

Acknowledgements

This assignment was originally developed by Anders Lindgren from Luleå Technical University and adapted by Lars-Åke Larzon and Richard Gold.

Updated  2007-10-18 14:17:54 by Fredrik Bjurefors.