Simulation of Different ARQ
Schemes
Simulation
Project for
INTRODUCTION TO WIRELESS AND
MOBILE SYSTEMS
By
Hang Li
Sheng Yu
March, 2003
Project Objective
This project is to write a Java-based
program called ARQ simulator to simulate 3 ARQ schemes Stop-And-Wait(SAW),
Go-Back-N(GBN) and Selective-Repeat(SR) . The project also compares the
efficiency and reliability and complexity of three schemes. The ARQ simulator
is a simple java-based simulator of ARQ (Automatic Repeat Request) protocols.
It supports three protocols: Stop-And-Wait and Go-Back-N. It will support
Selective-Repeat in the near future. The simulator assumes a point-to-point
communication and provides probabilistic simulation of the selected protocol
given a variety of input parameters specifying such things as network
characteristics, error probabilities, and transmission characteristics. Being a
probabilistic simulation (and using Java’s built-in random number generation
facilities) it is best to run each test case you are interested in several
times and average the results. The user interface is very simple. Input is via
command line arguments and output is text only.
How
to Run This Program
The ARQ simulator takes either 8 or 9 command line parameters. There are 8 if the algorithm selected is Stop-And-Wait (SAW) and there are 9 if the algorithm is Go-Back-N (GBN) or Selecttive-Repeated(SR) in which case an extra argument is needed: ‘N’ (the sender window size).
The command line syntax for running ARQ is:
java ARQ lat rate numf fsz ifd errP dropP algo [N]
For example, java ARQ 1 1000 50 500 200 0.0002 0.05 SAW
java
ARQ 1 1000 50 500 200 0.0002 0.05 GBN 2
java ARQ 1 1000 50 500 200 0.0002 0.05 SR
The command line arguments given to ARQsim (and their types) are as follows:
lat – the network latency (i.e. the delay to deliver 1 byte in one direction): an integer specifying the latency in milliseconds.
rate – the network data rate (number of bytes that can be sent in a second): an integer specifying the number of bytes transmitted per second.
numf – the number of frames the sender is to send: an integer.
fsz – the frame size: an integer specifying the number of bytes) in each frame.
ifd – the inter-frame delay (i.e. the time that must elapse between frames sent by the sender): an integer specifying the inter-frame delay in milliseconds.
errP – the probability of an error occurring in any transmitted byte: a float (between 0.0 and 1.0) where 0.0 means an error will never occur and 1.0 means an error will always occur. Choosing 1.0 will result in constant re-sends and a non-terminating simulation so don’t specify 1.0.
dropP – the probability of any frame being dropped: a float (between 0.0 and 1.0). The values are interpreted in the same way as for errP.
algo – the ARQ algorithm you want to simulate. A string (case significant) containing one of :
SAW – to select the Stop And Wait algorithm
GBN – to select the Go Back N algorithm. If GBN is selected then you must specify the sender’s window size (N) by specifying a final, integer argument.
SR- to select the Selective Repeated algorithm.
ARQ stands for Automatic Repeat reQuest. ARQ is one of the error-control mechanisms used in the data communication, in which the receiver detects transmission errors in a message and automatically requests a retransmission from the transmitter. Usually, when the transmitter receives the ARQ, the transmitter retransmits the message until it is either correctly received or the error persists beyond a predetermined number of retransmissions. There are three kinds of the ARQ schemes: Stop-And-Wait(SAW), Go-Back-N(GBN) and Selective-Repeat(SR).
Stop and Wait (SAW) transmission is the simplest reliability technique and is adequate for a very simple communications protocol. A stop and wait protocol transmits a Protocol Data Unit (PDU) of information and then waits for a response. The receiver receives each PDU and sends an Acknowledgement (ACK) PDU if a data PDU is received correctly, and a Negative Acknowledgement (NACK) PDU if the data was not received. In practice, the receiver may not be able to reliably identify whether a PDU has been received, and the transmitter will usually also need to implement a timer to recover from the condition where the receiver does not respond. Under normal transmission the sender will receive an ACK for the data and then commence transmission of the next data block. For a long delay link, the sender may have to wait an appreciable time for this response. While it is waiting the sender is said to be in the "idle" state and is unable to send further data.
Go-Back-N ARQ (GBN)
In this scheme, all the packets that have been sent but have not been acknowledged are buffered by the sender. Since the receiver only accepts the correct and in-order packets, only a buffer of one packet size is needed at the receiver. To support Go-Back-N ARQ, a protocol must number each PDU that is sent. The time period is selected to ensure the same PDU number is never used again for a different PDU, until the first PDU has "left the network" (e.g. it may have been acknowledged). The local node must also keep a buffer of all PDUs that have been sent, but have not yet been acknowledged. The receiver at the remote node keeps a record of the highest numbered PDU that has been correctly received. This number corresponds to the last acknowledgement PDU that it may have sent.
Selective Repeat ARQ (SR)
Selective Repeat error recovery is a procedure that is implemented in some communications protocols to provide reliability. It is the most complex of a set of procedures which may provide error recovery, it is however the most efficient scheme. Selective repeat is employed by the TCP transport protocol. The above features for Go-Back-N are also required for SW. However for selective repeat, the receiver must also maintain a buffer of frames that have been received, but not acknowledged. The recovery of a corrupted PDU proceeds in four stages: First, the corrupted PDU is discarded at the remote node's receiver. Second, the remote node requests retransmission of the missing PDU using a control PDU (sometimes called a Selective Reject). The receiver then stores all out-of-sequence PDUs in the receive buffer until the requested PDU has been retransmitted. The sender receives the retransmission request and then transmits the lost PDU(s). The receiver forwards the retransmitted PDU, and all subsequent in-sequence PDUs which are held in the receive buffer.
Program Design
In this project, we’ll design a reliable data transmission protocol that runs on top of an unreliable data link layer. The network setup consists of two nodes - the sender and the receiver, which are directly connected to each other over a point-to-point link. We will simulate a link with variable latency, and drop rate and error rate. The protocol must correctly handle dropped and re-ordered packets. Packet drop and byte error are randomly generated by the simulator. These parameters are configurable. The transmitter can send any number of packets. Network speed is adjustable. The reliable transmission protocol should ensure that packets sent by the transmitter are successfully received at the receiver. The simulation results should show the transmission time and the details of the transmission process by each protocol.
The Structure and
Implementation of the Program
ARQ Simulator consists of 13 Classes which are divided into 5 categories,
· ARQ: main program
· packet, Informationpack, Controlpacket,
· Sender, SAW_Sender, GBN_Sender, SA_Sender
· Receiver, SAW_Receiver, GBN_Receiver, SA_Recevier
· Network
The function and
implementation of each class is explained as follows,
·
ARQ class is the main class which is a simple single hop simulator of ARQ
protocols.
It is
implemented with other 12 classes and dynamic binding for different types of
senders and receivers.
·
packet class - describes a generic network packet which may be
specialized by either Controlpacket to be a C-packet or I-packet, respectively.
¨
Information packet class- specializes packet to add the actual data sent.
It extends class packet.
¨
Controlpacket class - specializes Netpacket to add a control code (e.g.
ACK, NACK, etc.) It extends class packet.
·
Network class is the actual network that is responsible for accepting
injected packets and delivering them to their targets subject to the network
parameters defined at invocation time and simulated transmission errors and
packet drops. It is implemented with two queue (senderQ and receiverQ) by using
Java's LinkedList class. It is also responsible for handling the simulation of
errors and packets drops and for gathering the simulation statistics.
·
Sender class is the source of the data stream. Instantiated to reflect
the algorithm requested. This abstract class also provides a generic
constructor that does initialization of the protected class data which is
common to all types of senders which sends another packet if it has one to send
. Specializations are SAW_Sender, GBN_Sender, and SR_Sender.
¨
SAW_Sender class - a stop and wait sender: sends another packet if it has
one to send (i.e. it is not done sending and the time has come to send one) iff
it has received an ACK for the previous packet sent. This class extends the abstract base class Sender.
¨
GBN_Sender - a Go-Back-N sender. The variables savedpackets and
timeoutTimes constitute the sender's window. The oldest non-ACK'd packet is
always in element 0 and there are numSentInWindow valid entries in the arrays.
When an error is detected (or an ACK is lost) the timeout value in element 0
will "expire" and the sender will resend all the packets in its
window. This class extends the abstract base class Sender.
¨
SR_Sender - a selective repeated sender: resends the packet as soon as it
times out or error. Packets are not in order. This class extends the abstract
base class Sender.
·
Receiver class- the sink of the data stream (i.e. a sender of Cpackets).
This abstract class is instantiated to reflect the algorithm requested.
Specializations are SAW_Receiver, GBN_Receiver, and SR_Receiver.
¨
SAW_Receiver class-A Stop-And-Wait receiver. The SAW_Receiver waits for
the next I-packet in sequence and ACKs it. Itignores any I-packets that are out
of sequence and relies on the sender's timeout mechanism
to deal with lost and error packets (of both types).This class extends the
abstract base class Receiver.
¨
GBN_Receiver class- A Go-Back-N receiver. The GBN_Receiver ignores any
I-packets in error (since these will be re-sent by the sender) and ACKs all
packets it receives (including duplicates) in case the ACKs were previously
lost. The code does NOT use NAKs. This class extends the abstract base class
Receiver.
¨
SR_Receiver - A Selective repeated receiver. The SR_Receiver waits for
the next I-packet in sequence and ACKs it. It accepts any I-packets that are
out of sequence. If error oocurs, signal SR_Sender to resend this packet.This
class extends the abstract base class Receiver.
Results of Simulation
The main goal of our
simulation is to observe the transmission time variance at different scheme
parameters. Our default system parameters are shown in Table 1. During
simulation, we vary one of the parameters in the parameter set while keep
others unchanged. Data is collected at different point and variance is plotted
to visualize the effect on transmission time.
|
Network latency |
1 ms |
|
Network data rate |
100 Bytes/second |
|
Total packet number |
50 |
|
Packet size |
500 Bytes/package |
|
Delay between sending
packet |
200 ms |
|
Probability of a byte
error |
0.0002 |
|
Probability of a packet
being dropped |
0.05 |
|
Window size in GBN case |
2 |
·
Simulation Results
Figure 1 shows the effect
of total number of packet being transmitted on system time. The more the packet
number, the much longer it will take for each scheme. In Figure 2 we can see
that, as the packet size increases, the transmission time takes longer as well.
Figure 3 and 4 depicts the relationship between the probability of error in one
packet / the dropping probability of the packet and the transmission time.
Results show that as the probability increases, the transmission time will be
longer because of the retransmission of the error packets. In all above cases
we can see clearly that the transmission time in SAW algorithm is the longest,
followed by GBN algorithm, and SR presents the fastest error correction
solution. We also examine the impact of the window size in GBN algorithm. Shown
in Figure 5, the larger the window size, the shorter the transmission period.





Conclusion
This project simulated
the three schemes of ARQ with a program called ARQ simulator. Based on the
simulation, the comparison shows that Selective Repeated protocol with more
complicated implementation is usually faster than the other two protocol. Error rate and drop rate affects more on
Stop-And-Wait protocol. With the increment of window size, the transmission
time decreases with Go-Back-N protocol.