Fall Semester 2006
Demo Due: 12/6/2006 (MW session); 12/7/2006 (TTh session)
Project report due: 12/11/2006 (MW session)
12/12/2006 (TTh session)
In this project, you will be implementing a go-back-n based reliable duplex data transfer protocol described in section 3.4 of our textbook (Computer Networks, Tanenbaum, 2002). The protocol uses a 3-bit go-back-n sliding window protocol. The sequence number is 3-bit wide, i.e., it varies from 0 to 7. The sliding window size is 7 (not 8, as explained in the textbook, with similar reason as that for selective repeat protocol).
Even though the protocol pseudo code is introduced in the context of data link layer in the textbook, the protocol is applicable in the transport layer as well. We assume that our protocol runs in the transport layer and on top of a best effort network layer protocol, i.e., the transport protocol runs on top of a lossy channel. Since it is not convenient to program against the real APIs in this level (you need to write kernel code and access raw IP APIs), a simulated environment is provided. The simulated environment consists of three layers:
The APIs provided by the go-back-n protocol are defined in the TransportLayer class. They have the following signatures:
public
synchronized int send(String msg);
public
synchronized int recv(byte[] buffer);
The skeleton code provided to you contains technical details on the requirements of the input/output parameters and their behaviors. In particular, send() might return an error code (i.e., -1) when the message is too big, or when the send buffer is full (the send() method is essentially a non-blocking call), and the application must check the return status to know if the message has been sent out successfully. On the other hand, the recv() method is blocking, i.e., it returns only if a message is received.
In the go-back-n protocol implementation, there are three different events to be handled, they are:
The three types of events are set through the following three public methods defined in TransportLayer class:
public
synchronized void onPacketArrival();
public
synchronized void onTimeout();
public
synchronized int send(String msg);
The onPacketArrival() method is invoked by the NetworkLayer object when a packet arrives. The onTimeout() method is called by the packet object whose retransmission timer has expired. The send() method is called by the application program when it has a message to send.
The diagram below provide additional implementation details of the reference implementation of the protocol and its environment:

The reference implementation consists of the following files:
jar xf
par.jar
java
java Bob
As soon as both processes are started, they start to communicate with each other. The following are example output from Alice and Bob:
From
>>>App:[
>>>App:[
TL:Send:
seq=0, ack=7, len=30 "[
...start timer for packet: seq=0, ack=7, len=30
TL:Send:
seq=1, ack=7, len=30 "[
...start timer for packet: seq=1, ack=7, len=30
...timeout for packet: seq=0, ack=7, len=30
TL:Send:
seq=0, ack=7, len=30 "[
...start timer for packet: seq=0, ack=7, len=30
TL:Send:
seq=1, ack=7, len=30 "[
...start timer for packet: seq=1, ack=7, len=30
RecvWin:
0...0 [0] SendWin: 0...1 [7]
...timeout for packet: seq=0, ack=7, len=30
<<<App:[Bob]-(0): It is a nice day indeed.
From Bob:
>>>App:[Bob]-(0): It is a nice day indeed.
TL:Send:
seq=0, ack=7, len=35 "[Bob]-(0): It is a nice day indeed."
...start timer for packet: seq=0, ack=7, len=35
RecvWin:
0...0 [2] SendWin: 0...0 [0]
...cancel timer for packet: seq=0, ack=7, len=35
RecvWin:
0...0 [3] SendWin: closed [0]
RecvWin:
0...0 [0] SendWin: closed [7]
RecvWin:
1...1 [1] SendWin: closed [7]
RecvWin:
2...2 [2] SendWin: closed [0]
RecvWin:
3...3 [3] SendWin: closed [0]
<<<App: [
<<<App: [
Below is the instruction on how to read the output.
>>>App:[
This output line indicates that
TL:Send:
seq=0, ack=7, len=30 "[
This line indicates that the transport layer has prepared a packet
and sent it out. The sequence number assigned to the packet is 0. It carries an
acknowledge number 7, and the payload length is 30 bytes, with the payload “[
packet.ack = (packetExpected + MAX_SEQ) % (MAX_SEQ + 1);
In the beginning, packetExpected is 0, and recall that MAX_SEQ is 7, therefore, packet.ack is (0+7)%8 = 7.
...start timer for packet: seq=0, ack=7, len=30
This line indicates that the timer for the above packet has been started.
...timeout for packet: seq=0, ack=7, len=30
This line indicates that the timer for the packet with sequence number 0 has just expired. Retransmission of all outstanding packets is about to happen.
RecvWin: 0...0
[0] SendWin: 0...1 [7]
This line indicates that a packet has arrived at the transport layer from the network. The sliding window information is shown together with the packet information. The above line contains the following information (from left to right):
o The lower edge of receiving window is 0 (i.e., the protocol is expecting to receive a packet with sequence number 0), as indicated by 0…0. Recall that the go-back-n protocol’s receiving window size is in fact 1.
o The packet received carries a sequence number 0, as indicated by [0].
o The sending window has a lower edge of 0 and a higher edge of 1. That is, there are two outstanding packets (which carries sequence numbers 0 and 1, respectively) in the sending window.
o The received packet carries an acknowledge number 7, which is outside the sending window. So, no timer is canceled and no buffer space is reclaimed.
RecvWin:
0...0 [2] SendWin: 0...0 [0]
This line shows that an out-of-order packet is received so it is discarded. But it carries an acknowledge number 0, which is within the range of the sending window. Therefore, the packet in the sending window is now acknowledged, the timer can be canceled and the buffer space for the packet can be reclaimmed.
RecvWin:
0...0 [0] SendWin: closed [7]
The line shows yet another scenario of packet receiving. It indicates that an expected packet that carries a sequence number 0 is received. The receiving window will slide to 1…1 subsequently and the packet received will be delivered immediately. At this point, the sending window is closed, that is, there is currently no outstanding packet that has been sent but not-yet-acknowledged. The packet we just received carries an ack number 7. Since the sending window is closed, no action is induced due to the acknowledgement information carried by the packet received.
...cancel timer for packet: seq=0, ack=7, len=35
This line shows that the timer for that particular packet is canceled due to the receiving of an acknowledgement.
<<<App:[Bob]-(0): It is a nice day indeed.
This line indicates that the message received (payload in the packet) has been delivered to the application. The message content is “[Bob]-(0): It is a nice day indeed.”
Just like the first project, most of the files above are provided with full implementation. But you do need to add the omitted sections in some files and modify the provided code according to the instructions below. Your tasks include:
Change the go-back-n protocol to a selective repeat protocol. Repeat task 7 for the selective repeat protocol, and compare the performance results of the two protocols.
This task is applicable only if you have finished the extra-credit task#1. Provide flow control support similar to that used in TCP, i.e., the receiver advertises its available receiving buffer, the sending must refrain from sending if the receiver has indicated that it has no receiving buffer left. You need also to implement mechanism to avoid deadlock in case the windows update packet from the receiver is lost.
Modify the go-back-n protocol to add connection management (connection setup and tear-down). Introduce an application program, Trudy, that talks to both Alice and Bob concurrently in two different connections. Apparently, you need to include the source and destination port number fields in the transport protocol header to enable connection management. You also need to provide appropriate API for the application programs to establish and close connections. Simulate various connection setup and teardown scenarios and verify that your code works in all those scenarios.



