goback n protocol java program
The Reliable Lab
Introduction
Computer systems (such as computer networks) are often too complex to analyze
formally. Performing measurements in such systems can also be impossible due to
practical reasons. It is therefore common that they are evaluated by simulation.
In this lab, you will study reliable transport protocols with the use of a discrete-event
driven simulator. Specifically, you will calculate and measure the efficiency of a stop-
and-wait protocol. You will also implement a pipelined reliable transport protocol and
evaluate its properties.
It is important that you understand the fundamentals of reliable transport protocols
before you engage in this lab. Make sure to read the introduction of Chapter 3.4 and
Chapters 3.4.1-3.4.3 (pages 241 to 256) before you start.
The Simulation Model
The simulation model is shown in Figure 1. This figure is comparable to Figure 3.8(b)
(page 241) in Section 3.4 of the textbook.
The model consists of a data source that sends data to a data sink. The data source
and data sink represent a sending process and a receiving process at the application
layer respectively.
The data source generates some specific number of data chunks that it hands over to a
reliable sender. The reliable sender represents the sending side of a reliable transport
protocol at the transport layer. The reliable sender encapsulates each data chunk that it
receives in a packet. The reliable sender sends each packet through a sender channel
to a reliable receiver. The reliable receiver, representing the receiving side of a reliable
transport protocol at the transport layer, extracts the data chunk from a received packet
and delivers it to the data sink. The reliable receiver uses a receiver channel to send an
ack packet back to the reliable sender for each data packet that it has successfully
received.
The sender channel and the receiver channel are unidirectional and together represent
a bidirectional and unreliable communication channel at the network layer (cf. Figure
3.8(b) in the textbook). Each channel imposes transmission and propagation delays on
each packet that is sent through it. The channels can also be configured to drop packets
to simulate packet loss due to, for example, bit errors. The channels do not reorder
packets.The simulation model does not capture bit errors in the packets. Such errors are
implicitly modeled as packet loss at the network layer (i.e. packets can be dropped by
the channels).
The Simulator
The main class of the simulator is ReliableTransfer. The simulator is started by
executing the main method in this class:
> java ReliableTransfer configfile.cfg
The simulator takes one optional command line argument: a configuration file. If no
argument is given, default values are assigned. An example config file is included with
the source code for the lab.You do not need to bother about all classes and the simulator
internals. You only need to alter the ReliableSender class to accomplish this lab!
The ReliableTransfer Class
This class is the main class of the simulator. The simulation is set up and started in the main
method. This is where you control the simulation parameters, such as the total number of data
chunks that should be sent, transmission and propagation delays for the channels.
The DataSource Class
This class represents the data source. It generates some given number of data chunks (as
instances of the Data class) that should be sent to the data sink.
The DataSink ClassThis class represents the data sink. It ensures that all data chunks generated by the data source
are delivered in chronological order. If not, it stops the simulation.
The Data Class
The Data class represents data chunks generated by the data source.
The Channel Class
This class represents a unidirectional communication channel at the network layer. It contains
the method
void send(Packet aPacket)
Enqueues a packet for transmission to the channel receiver.
The Packet Class
This class holds a sequence number and a data chunk. The reliable sender uses this class to
send a data chunk to the reliable receiver. The reliable receiver uses this class to send an ack to
the reliable sender, in which case it does not carry any data.
The ReliableSender Class
This class represents the reliable sender. The given code implements a stop-and-wait protocol.
The protocol is similar to the FSM description in Figure 3.20 in the textbook, except that only
one packet is sent at a time.
The class contains the following central methods.
void send(Data aDataChunk)
This method is called by the data source when ReliableSender accepts more data.
public void receive(Packet aPacket)
The receiver channel delivers packets (i.e. acks) by calling this method.
public void timeout(Timer aTimer)
This method is called by the timer that is created in the class's constructor.
private void acceptData()
This method is called by the class itself to tell the data source that it accepts new data (i.e. that
it is OK that the data source invokes the send method).
private void blockData()
This method is called by the class itself to tell the data source that it is busy sending data and
that no more data chunk is acceptable at the moment (i.e. that the data source should not call
the send method).
The ReliableReceiver Class
This class represents the reliable receiver. It implements the go-back-n receiver shown in Figure
3.21 of the textbook. You should not do any modifications to this classThe Timer Class
This class represents a timer. It includes the following methods.
void start(double aDuration)
This method starts the timer. The timer fires after the given duration (The duration is given in
seconds) and invokes the timer listener (i.e. it calls the listener's timeout method). If this method
is called when the timer is running, the timer is restarted.
void stop()
This method stops the timer.
The Simulator Class
This class contains the simulation engine. It is implemented as a Singleton class, which ensures
that only one instance can be created. The class includes the following methods.
static Simulator getInstance()
This method returns the class instance.
void log(String aMessage)
This method adds the given message to the log. That is, it prints the message to the console
together with the current simulation time.
The following example shows how to add a message to the log.
Simulator.getInstance().log("received a packet.")
The Assignment
Task 1: Get acquainted with the simulator ( You have already doe this part )
▪
Run some simulations with different parameters (i.e. with different number of data
packets, and different channel delays and drop probabilities) and study the output.
▪
Get to understand the implementation of the given stop-and-wait protocol. Specifically,
study how the timer is started and stopped, and how timeouts are handled. Furthermore,
learn how data is accepted and blocked from the data source.
Task 2: Calculate the transfer time of the stop-and-wait protocol
For this task, assume that each packet has a transmission delay of 0.001 seconds and a
propagation delay of 0.01 seconds.
▪
The given store-and-wait protocol sends one data packet at a time. Calculate the total
transfer time of 100 data packets.
▪
Run a simulation and compare the result with your calculation. Do you get the same total
transfer time? If not, why?
When you are done with the lab, you are expected to show your calculations and be able to
answer the given questions.Task 3: Implement the go-back-n protocol
▪
Extend the stop-and-wait protocol in ReliableSender into the go-back-n protocol
according to the description in Section 3.4.3 of the textbook. Note that the simulation
model does not introduce bit errors in the packets! Thus, you do not need to (actually,
can not) check if packets are corrupt or not.
▪
Make sure that your implementation supports different window sizes. The instance field
windowSize is initiated in the constructor of ReliableSender. This field is meant to be
used to control the window size from the main method and will ease your setup of
experiments.
▪
Set the sender channel's packet drop probability to, for example, 0.5 and test if your
implementation can handle packet loss.
Task 4: Analyze the go-back-n protocol
For this task, assume that each packet has a transmission delay of 0.001 seconds and a
propagation delay of 0.01 seconds. Furthermore, assume that the channels do not drop
packets.
▪
Calculate the "optimal" minimum window size that gives the shortest possible total
transfer time.
▪
Run a simulation with the optimal window size that you have calculated. Also, run
simulations with smaller and larger window sizes and compare the total transfer times.
What are your conclusions?
▪
Calculate the "optimal" timeout value. What would be the effect of using a longer timeout
value? What would be the effect of using a shorter timeout value?
Hand-In
The report should contain:
▪
The source code for ReliableSender (ReliableSender.java).
▪
A document (txt/pdf) containing well motivated answers and calculations to the questions
in the tasks.
The report should be emailed to Thabo before 12:00am on the 12th of June.
|