Project 2
Demo Day: Tuesday, April 09
Simulation of a Sliding Window Protocol


In this laboratory programming assignment, you will be writing the sending and receiving transport-level code for implementing a simple reliable data transfer protocol. There are two versions of this lab, the Alternating-Bit-Protocol(Stop and Wait) version and the  Go-Back-N version. you will implement Go Back n Sliding Window Protocol ( window size =3). This lab should be fun since your implementation will differ very little from what would be required in a real-world situation. .

Physical layer:
A physical layer object connects directly to a medium. There is only one type of physical layer. It accepts a sequence of bytes which it then sends, one bit at a time, across the medium. The receiving physical layer reconstructs the bytes, one at a time, delivering each complete byte to its data link layer.  The functionality of physical layer is implemented in Channel class.

Error Type for Physical Layer:   

At runtime, you can select one from these  possible types of Channels:

1. PerfectChannel:  No data loss. Received data is passed to Network Layer.

In the following  case, data or acknowledgement can possibly be lost, requiring retransmission of lost or unacknowledged data.
2
. Lossy Channel: Any frame or any acknowledgement is lost during transmission.

Transport layer:

Transport layer gets data from the application layer, creates a packet from it and then passes this packet to the network layer for transmission.

The data packet can be declared as:

public class Packet{
   

public Packet(int i, int j, boolean flag, byte abyte0[])
{  
        ack =
false;
        seqno = i;
        size = j;
        ack = flag;
        data =
new byte[size];
        data = abyte0;
  }
  . . .
}
[Note:
We will ignore the Internet checksum field in the packet class as we will do error checking in the lower layer (Data Link Layer) in the next project(i.e., project #4)].

Where payload is 12.

Your routines will fill in the payload field from the message data passed down from application layer as explained below.

Consider  the following data that are received by the transport layer from the application layer:

give everyone a chance to speak.

Transport layer makes the data packets from the above data as follows:

 data packet 1: give everyon

 data packet 2: e a chance t

 data packet 3: o speak. (pad this packet to make the length 12 bytes long).

The routines you will write

The procedures you will write are for the sending entity (Sender) and the receiving entity (Receiver). Only unidirectional transfer of data (from Sender to Receiver) is required. Of course, the Receiver side will have to send packets to the Sender to acknowledge (positively or negatively) receipt of data. Your project will have the classes described below.

Project Classes

Description

 

 

Channel

Thread-safe shared memory for communication between the sender and receiver threads.

ErrorModel

Used to corrupt or loose packets on an imperfect channel.

Packet

Used to create a Packet

GBNProtocol

Implements the  Go-Back N protocol.  For lossy channel, loose the third packet.

Port

Communication port.  Each contains an outgoing Channel that the thread sends data to and an incoming Channel that it reads from.

Project3

Main class.  Creates two channels for communications.  Two ports, each  containing the two channels are created, one for the sender and one for the receiver.  The sender and receiver threads are created and started.  When the simulation is complete, statistics are printed.

Receiver

Thread object that reads bytes from its port's incoming Channel and sends an ACK  and passes the bytes out to the higher layer or simply writes it to the output file.

Sender

Thread object that sends the bytes of a Packet object over its port's outgoing channel.  It's main loop implements most of the functionality of the Go-Back N protocol.  It first sends as many packets as possible to fill the window.  It then checks to see if any ACK/NACKs have arrived and handles any found.  Finally, it queries the window to see if any packet or packets have timed out.  If so, the packets in the window are resent.  At this time execution returns to the top of the loop.  This continues until all packets  have been sent and ACKed.

SentPacket

Wrapper class to encapsulate a single Packet and its corresponding timer.  Implements EventListener to use a swing Timer object to flip a boolean when the packet times out.

 

Output:

Print out the following statistics after transferring a file from the sender to the receiver:

  1. the total amount of data transmitted
  2. the total number of data packets transmitted
  3. the total number of retransmissions
  4. the total number of acknowledgments sent
  5. the total number of acknowledgments received
  6. the total number of duplicate packets received

click here for help.

Good Luck!