SlideShare a Scribd company logo
MICRO PROJECT
COMPUTER NETWORKS LAB
COURSE CODE: CS-692
TEAM MEMBERS:
NAME: CLASS ROLL NO: UNIVERSITY ROLL
NO:
FAIZAAN AHMED
KHAN
(CSE/2013/089) 11700113029
GIRI SWAGARIKA
JAHARLAL
(CSE/2014/B03) 11700213023
ABHIPSA
CHAKRABORTY
(CSE/2014/B02) 11700213002
SHREYA DAS (CSE/2014/B05) 11700213067
GO BACK N ARQ:
AIM:
Go Back n is a connection oriented protocol in which the transmitter has a window of
sequence numbers that may be transmitted without acknowledgment. The receiver will
only accept the next sequence number it is expecting - other sequence numbers are silently
ignored. In this portion we will know about how the protocol works.
THEORY:
Go-Back-N ARQ is a specific instance of the automatic repeat request (ARQ) protocol, in
which the sending process continues to send a number of frames specified by a window
size even without receiving an acknowledgement (ACK) packet from the receiver. It is a
special case of the general sliding window protocol with the transmit window size of N and
receive window size of 1. It can transmit N frames to the peer before requiring an ACK.
The receiver process keeps track of the sequence number of the next frame it expects to
receive, and sends that number with every ACK it sends. The receiver will discard any
frame that does not have the exact sequence number it expects (either a duplicate frame it
already acknowledged, or an out-of-order frame it expects to receive later) and will resend
an ACK for the last correct in-order frame. Once the sender has sent all of the frames in
its window, it will detect that all of the frames since the first lost frame are outstanding, and
will go back to the sequence number of the last ACK it received from the receiver process
and fill its window starting with that frame and continue the process over again.
Go-Back-N ARQ is a more efficient use of a connection than Stop-and-wait ARQ, since unlike
waiting for an acknowledgement for each packet, the connection is still being utilized as
packets are being sent. In other words, during the time that would otherwise be spent
waiting, more packets are being sent. However, this method also results in sending frames
multiple times – if any frame was lost or damaged, or the ACK acknowledging them was
lost or damaged, then that frame and all following frames in the window (even if they were
received without error) will be re-sent. To avoid this, Selective Repeat ARQ can be used.
Go-Back-N ARQ protocol : To understand this protocol you should first understand
what is window size. I'll assume that you already know it. consider above scenario
there are four frames 0,1,2,3 respectively. Now as sending window size is 3 it'll send
frame 0,1,2 at a time.
 At receiver side frame 0 arrives it sends ack for that.
 Now at sender side window shift at frame 3 and it sends frame no 3.
 At receiver side frame 1 arrives it sends ack for that.
 Now at sender side window shift at frame 0 and it sends frame no 0. (this is not
previous frame 0)
 Now receiver detects frame 2 is missing or lost. It'll send NAK for that.
 Sender receives NAK at this point sending window is pointing towards frame 2,3 and
next frame 0.
 With same scenario Stop-N-Wait protocol re-transmits all frames that are pointed by
sending window. But in Go-Back-N only frame 2 is re-transmits. and repeat this until it
gets ack for frame 2.
So Go-Back-N is more efficient.
Features required for Go-Back-N ARQ
 To support Go-Back-N ARQ, a protocol must number each PDU which is sent. (PDUs
are normally numbered using modulo arithmetic, which allows the same number to
be re-used after a suitably long period of time. 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 which have been sent, but have
not yet been acknowledged.
 The receiver at the remote node keeps a record of the highest numbered PDU which
has been correctly received. This number corresponds to the last acknowledgement
PDU which it may have sent.
Recovery of lost PDUs using Go-Back-N
The recovery of a corrupted PDU proceeds in three 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 NACK or REJECT). The receiver discards all PDUs which do
not have the number of the requested PDU.
 The final stage consists of retransmission of the lost PDU(s).
Retransmission using Go-Back-N
A remote node may request retransmission of corrupted PDUs by initiating Go-Back-N
error recovery by sending a control PDU indicating the last successfully received PDU.
This allows the remote node to instruct the sending node where to begin retransmission of
PDUs. The remote node does not store any out-of-sequence PDUs and therefore
must discard all received PDUs until one is received with the expected sequence number.
Upon receipt of a Go-Back-N control PDU (by the local node), the transmitter winds-
back the sequence of PDUs pending transmission to the indicated PDU in its buffer of
unacknowledged PDUs. The transmitter then retransmits (Goes Back-to-N) the requested
PDU followed by all successive PDUs. This is sometimes known as "wind back" of the
transmitter.
Example of Go-Back-N:
The sender in this example transmits four PDUs (1-4) and the first one (1) of these is not
successfully received. The receiver notes that it was expecting a PDU numbered 1 and
actually receives a PDU numbered 2. It therefore deduces that (1) was lost. It requests
retransmission of the missing PDU by sending a Go-Back-N request (in this case N=1), and
discards all received PDUs with a number greater than 1.The sender receives the Go-Back-
N request and retransmits the missing PDU (1), followed by all subsequently sent PDUs (2-
4) which the receiver the correctly receives and acknowledges.
If the retransmission is not successful, the protocol relies upon a protocol timer in the local
node to detect that no acknowledgment was received. The lost PDUs may then be
recovered by Polling.
CODE:
#include<stdio.h>
int main()
{
int windowsize,sent=0,ack,i;
printf("enter window sizen");
scanf("%d",&windowsize);
while(1)
{
for( i = 0; i < windowsize; i++)
{
printf("Frame %d has been transmitted.n",sent);
sent++;
if(sent == windowsize)
break;
}
printf("nPlease enter the last Acknowledgement received.n");
scanf("%d",&ack);
if(ack == windowsize)
break;
else
sent = ack;
}
return 0;
}
OUTPUT:
enter window size
8
Frame 0 has been transmitted.
Frame 1 has been transmitted.
Frame 2 has been transmitted.
Frame 3 has been transmitted.
Frame 4 has been transmitted.
Frame 5 has been transmitted.
Frame 6 has been transmitted.
Frame 7 has been transmitted.
Please enter the last Acknowledgement received.
2
Frame 2 has been transmitted.
Frame 3 has been transmitted.
Frame 4 has been transmitted.
Frame 5 has been transmitted.
Frame 6 has been transmitted.
Frame 7 has been transmitted.
Please enter the last Acknowledgement received.
8
--------------------------------
STOP AND WAIT ARQ:
AIM:
"Stop-n-wait" (sometimes known as "positive acknowledgement with retransmission") is
the fundamental technique to provide reliable transfer under unreliable packet delivery
system. In this portion we will know about how the protocol works.
THEORY AND DIAGRAM:
Stop-and-wait ARQ also can be referred as alternating bit protocol is a method used
in telecommunications to send information between two connected devices. It ensures that
information is not lost due to dropped packets and that packets are received in the correct
order. It is the simplest kind of automatic repeat-request (ARQ) method. A stop-and-wait
ARQ sender sends one frame at a time; it is a special case of the general sliding window
protocol with both transmit and receive window sizes equal to 1 and more than one
respectively . After sending each frame, the sender doesn't send any further frames until it
receives an acknowledgement (ACK) signal. After receiving a good frame, the receiver
sends an ACK. If the ACK does not reach the sender before a certain time, known as the
timeout, the sender sends the same frame again. Timer is set after each frame transmission.
The above behavior is the simplest Stop-and-Wait implementation. However, in a real life
implementation there are problems to be addressed.
Typically the transmitter adds a redundancy check number to the end of each frame. The
receiver uses the redundancy check number to check for possible damage. If the receiver
sees that the frame is good, it sends an ACK. If the receiver sees that the frame is damaged,
the receiver discards it and does not send an ACK—pretending that the frame was
completely lost, not merely damaged.
One problem is when the ACK sent by the receiver is damaged or lost. In this case, the
sender doesn't receive the ACK, times out, and sends the frame again. Now the receiver has
two copies of the same frame, and doesn't know if the second one is a duplicate frame or
the next frame of the sequence carrying identical data.
Another problem is when the transmission medium has such a long latency that the
sender's timeout runs out before the frame reaches the receiver. In this case the sender
resends the same packet. Eventually the receiver gets two copies of the same frame, and
sends an ACK for each one. The sender, waiting for a single ACK, receives two ACKs, which
may cause problems if it assumes that the second ACK is for the next frame in the sequence.
To avoid these problems, the most common solution is to define a 1 bit sequence number in
the header of the frame. This sequence number alternates (from 0 to 1) in subsequent
frames. When the receiver sends an ACK, it includes the sequence number of the next
packet it expects. This way, the receiver can detect duplicated frames by checking if the
frame sequence numbers alternate. If two subsequent frames have the same sequence
number, they are duplicates, and the second frame is discarded. Similarly, if two
subsequent ACKs reference the same sequence number, they are acknowledging the same
frame.
Stop-and-wait ARQ is inefficient compared to other ARQs, because the time between
packets, if the ACK and the data are received successfully, is twice the transit time
(assuming the turnaround time can be zero). The throughput on the channel is a fraction of
what it could be. To solve this problem, one can send more than one packet at a time with a
larger sequence number and use one ACK for a set. This is what is done in Go-Back-N
ARQ and the Selective Repeat ARQ.
How this protocol works..
1) Normal operation:
After transmitting one packet, the sender
waits for an acknowledgment (ACK) from
the receiver before transmitting the next
one. In this way, the sender can recognize
that the previous packet is transmitted
successfuly and we could say "stop-n-wait"
guarantees reliable transfer between
nodes.
To support this feature, the sender keeps a
record of each packet it sends.
Also, to avoid confusion caused by delayed
or duplicated ACKs, "stop-n-wait" sends
each packets with unique sequence
numbers and receives that numbers in each
ACKs.
2) Timeout:
If the sender doesn't receive ACK for previous sent packet after a certain period of time, the
sender times out and retransmit that packet again. There are two cases when the sender
doesn't receive ACK; one is when the ACK is lost and the other is when the frame itself is
not transmitted.
To support this feature, the sender keeps timer per each packet.
3. How it is shown in nam (network animator)..
"stop-n-wait" protocol can be shown as below in nam.
1. Packet_0 is sent and ACK_0 is received
2. Packet_1 is sent and ACK_1 is received
3. Packet_2 will be sent and be received and so on..
Shortcoming:
The main shortcoming of the stop-and-wait algorithm is that it allows the sender to have
only one outstanding frame on the link at a time. The sender should wait till it gets an ACK
of previous frame before it sends next frame. As a result, it wastes a substantial amount of
network bandwidth. To improve efficiency while providing reliability, "sliding window"
protocol is appeared.
CODE:
#include<stdio.h>
#define MAXSIZE 100
typedef struct
{
unsigned char data[MAXSIZE];
}packet;
typedef enum{data,ack}frame_kind;
typedef struct
{
frame_kind kind;
int sq_no;
int ack;
packet info;
}frame;
typedef enum{frame_arrival}event_type;
typedef enum{true_false}boolean;
void frame_network_layer(packet *p)
{
printf("n from network arrival");
}
void to_physical_layer(frame *f)
{
printf("n to physical layer");
}
void wait_for_event(event_type *e)
{
printf("n waiting for event n");
}
void sender(void)
{
frame s;
packet buffer;
event_type event;
printf("n ***SENDER***");
frame_network_layer(&buffer);
s.info=buffer;
to_physical_layer(&s);
wait_for_event(&event);
}
void from_physical_layer(frame *f)
{
printf("from physical layer");
}
void to_network_layer(packet *p)
{
printf("n to network layer");
}
void receiver(void)
{
frame r,s;
event_type event;
printf("n ***RECEIVER***");
wait_for_event(&event);
from_physical_layer(&r);
to_network_layer(&r.info);
to_physical_layer(&s);
}
main()
{
sender();
receiver();
}
OUTPUT:

More Related Content

What's hot (20)

Go Back N Arq1
Go  Back N Arq1Go  Back N Arq1
Go Back N Arq1
 
Data Link Control
Data Link ControlData Link Control
Data Link Control
 
6 data linkcontrol
6  data linkcontrol6  data linkcontrol
6 data linkcontrol
 
Flow Control
Flow ControlFlow Control
Flow Control
 
3a data link layer continued
3a data link layer continued3a data link layer continued
3a data link layer continued
 
Sliding window protocol(ARQ technique)
Sliding window protocol(ARQ technique)Sliding window protocol(ARQ technique)
Sliding window protocol(ARQ technique)
 
Sliding window protocol
Sliding window protocolSliding window protocol
Sliding window protocol
 
Stop-and-Wait ARQ Protocol
Stop-and-Wait ARQ ProtocolStop-and-Wait ARQ Protocol
Stop-and-Wait ARQ Protocol
 
Flow control
Flow controlFlow control
Flow control
 
Arq protocol part 2
Arq protocol part 2Arq protocol part 2
Arq protocol part 2
 
Mac sub layer
Mac sub layerMac sub layer
Mac sub layer
 
Chapter 12
Chapter 12Chapter 12
Chapter 12
 
Ch11
Ch11Ch11
Ch11
 
GO BACK N PROTOCOL
GO BACK N PROTOCOLGO BACK N PROTOCOL
GO BACK N PROTOCOL
 
Ch 11
Ch 11Ch 11
Ch 11
 
Sliding window and error control
Sliding window and error controlSliding window and error control
Sliding window and error control
 
Advance Repeat reQuest (ARQ)
Advance Repeat reQuest (ARQ)Advance Repeat reQuest (ARQ)
Advance Repeat reQuest (ARQ)
 
Flowctrl
FlowctrlFlowctrl
Flowctrl
 
go back n protocol
go back n protocolgo back n protocol
go back n protocol
 
Selective repeat protocol
Selective repeat protocolSelective repeat protocol
Selective repeat protocol
 

Similar to Micro project on ARQ

session -7 - Sliding Window Protocol 1- N oisy Channels.ppt
session -7 - Sliding Window Protocol 1- N oisy Channels.pptsession -7 - Sliding Window Protocol 1- N oisy Channels.ppt
session -7 - Sliding Window Protocol 1- N oisy Channels.pptnanisrikar276711
 
Unit IV_Flow.pptx
Unit IV_Flow.pptxUnit IV_Flow.pptx
Unit IV_Flow.pptxTejasRao8
 
09 Data Link LayerFlow Control.ppt
09 Data Link LayerFlow Control.ppt09 Data Link LayerFlow Control.ppt
09 Data Link LayerFlow Control.pptShaliniKumariGupta1
 
Automatic Repeat Request (Arq) Protocols
Automatic Repeat Request (Arq) ProtocolsAutomatic Repeat Request (Arq) Protocols
Automatic Repeat Request (Arq) Protocolstheijes
 
Comparison of TCP congestion control mechanisms Tahoe, Newreno and Vegas
Comparison of TCP congestion control mechanisms Tahoe, Newreno and VegasComparison of TCP congestion control mechanisms Tahoe, Newreno and Vegas
Comparison of TCP congestion control mechanisms Tahoe, Newreno and VegasIOSR Journals
 
Comparison of TCP congestion control mechanisms Tahoe, Newreno and Vegas
Comparison of TCP congestion control mechanisms Tahoe, Newreno and VegasComparison of TCP congestion control mechanisms Tahoe, Newreno and Vegas
Comparison of TCP congestion control mechanisms Tahoe, Newreno and VegasIOSR Journals
 
Flow Control (1).ppt
Flow Control (1).pptFlow Control (1).ppt
Flow Control (1).pptsarthakgithub
 
Datalink control(framing,protocols)
Datalink control(framing,protocols)Datalink control(framing,protocols)
Datalink control(framing,protocols)Hira Awan
 
Flow & Error Control
Flow & Error ControlFlow & Error Control
Flow & Error Controltameemyousaf
 

Similar to Micro project on ARQ (20)

session -7 - Sliding Window Protocol 1- N oisy Channels.ppt
session -7 - Sliding Window Protocol 1- N oisy Channels.pptsession -7 - Sliding Window Protocol 1- N oisy Channels.ppt
session -7 - Sliding Window Protocol 1- N oisy Channels.ppt
 
Unit IV_Flow.pptx
Unit IV_Flow.pptxUnit IV_Flow.pptx
Unit IV_Flow.pptx
 
09 Data Link LayerFlow Control.ppt
09 Data Link LayerFlow Control.ppt09 Data Link LayerFlow Control.ppt
09 Data Link LayerFlow Control.ppt
 
Data link layer (Unit 2).pdf
Data link layer (Unit 2).pdfData link layer (Unit 2).pdf
Data link layer (Unit 2).pdf
 
PROTOCOL ICT.pptx
PROTOCOL ICT.pptxPROTOCOL ICT.pptx
PROTOCOL ICT.pptx
 
Lecture 20
Lecture 20Lecture 20
Lecture 20
 
Automatic Repeat Request (Arq) Protocols
Automatic Repeat Request (Arq) ProtocolsAutomatic Repeat Request (Arq) Protocols
Automatic Repeat Request (Arq) Protocols
 
Error control
Error controlError control
Error control
 
Presentation on dll
Presentation on dllPresentation on dll
Presentation on dll
 
Comparison of TCP congestion control mechanisms Tahoe, Newreno and Vegas
Comparison of TCP congestion control mechanisms Tahoe, Newreno and VegasComparison of TCP congestion control mechanisms Tahoe, Newreno and Vegas
Comparison of TCP congestion control mechanisms Tahoe, Newreno and Vegas
 
Comparison of TCP congestion control mechanisms Tahoe, Newreno and Vegas
Comparison of TCP congestion control mechanisms Tahoe, Newreno and VegasComparison of TCP congestion control mechanisms Tahoe, Newreno and Vegas
Comparison of TCP congestion control mechanisms Tahoe, Newreno and Vegas
 
Transport layer
Transport layerTransport layer
Transport layer
 
Lecture 23
Lecture 23Lecture 23
Lecture 23
 
Flow Control (1).ppt
Flow Control (1).pptFlow Control (1).ppt
Flow Control (1).ppt
 
Datalink control(framing,protocols)
Datalink control(framing,protocols)Datalink control(framing,protocols)
Datalink control(framing,protocols)
 
Congestion Control
Congestion ControlCongestion Control
Congestion Control
 
Go Back N ARQ
Go  Back N ARQGo  Back N ARQ
Go Back N ARQ
 
Flow & Error Control
Flow & Error ControlFlow & Error Control
Flow & Error Control
 
Go back.pptx
Go back.pptxGo back.pptx
Go back.pptx
 
07 data linkcontrol
07 data linkcontrol07 data linkcontrol
07 data linkcontrol
 

Recently uploaded

KIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and Clustering
KIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and ClusteringKIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and Clustering
KIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and ClusteringDr. Radhey Shyam
 
Electrostatic field in a coaxial transmission line
Electrostatic field in a coaxial transmission lineElectrostatic field in a coaxial transmission line
Electrostatic field in a coaxial transmission lineJulioCesarSalazarHer1
 
shape functions of 1D and 2 D rectangular elements.pptx
shape functions of 1D and 2 D rectangular elements.pptxshape functions of 1D and 2 D rectangular elements.pptx
shape functions of 1D and 2 D rectangular elements.pptxVishalDeshpande27
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdfKamal Acharya
 
A case study of cinema management system project report..pdf
A case study of cinema management system project report..pdfA case study of cinema management system project report..pdf
A case study of cinema management system project report..pdfKamal Acharya
 
İTÜ CAD and Reverse Engineering Workshop
İTÜ CAD and Reverse Engineering WorkshopİTÜ CAD and Reverse Engineering Workshop
İTÜ CAD and Reverse Engineering WorkshopEmre Günaydın
 
RS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical SolutionsRS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical SolutionsAtif Razi
 
Pharmacy management system project report..pdf
Pharmacy management system project report..pdfPharmacy management system project report..pdf
Pharmacy management system project report..pdfKamal Acharya
 
KIT-601 Lecture Notes-UNIT-5.pdf Frame Works and Visualization
KIT-601 Lecture Notes-UNIT-5.pdf Frame Works and VisualizationKIT-601 Lecture Notes-UNIT-5.pdf Frame Works and Visualization
KIT-601 Lecture Notes-UNIT-5.pdf Frame Works and VisualizationDr. Radhey Shyam
 
retail automation billing system ppt.pptx
retail automation billing system ppt.pptxretail automation billing system ppt.pptx
retail automation billing system ppt.pptxfaamieahmd
 
NO1 Pandit Black Magic Removal in Uk kala jadu Specialist kala jadu for Love ...
NO1 Pandit Black Magic Removal in Uk kala jadu Specialist kala jadu for Love ...NO1 Pandit Black Magic Removal in Uk kala jadu Specialist kala jadu for Love ...
NO1 Pandit Black Magic Removal in Uk kala jadu Specialist kala jadu for Love ...Amil baba
 
Arduino based vehicle speed tracker project
Arduino based vehicle speed tracker projectArduino based vehicle speed tracker project
Arduino based vehicle speed tracker projectRased Khan
 
Furniture showroom management system project.pdf
Furniture showroom management system project.pdfFurniture showroom management system project.pdf
Furniture showroom management system project.pdfKamal Acharya
 
Hall booking system project report .pdf
Hall booking system project report  .pdfHall booking system project report  .pdf
Hall booking system project report .pdfKamal Acharya
 
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...Amil baba
 
Event Management System Vb Net Project Report.pdf
Event Management System Vb Net  Project Report.pdfEvent Management System Vb Net  Project Report.pdf
Event Management System Vb Net Project Report.pdfKamal Acharya
 
Peek implant persentation - Copy (1).pdf
Peek implant persentation - Copy (1).pdfPeek implant persentation - Copy (1).pdf
Peek implant persentation - Copy (1).pdfAyahmorsy
 
BRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWING
BRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWINGBRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWING
BRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWINGKOUSTAV SARKAR
 
Fruit shop management system project report.pdf
Fruit shop management system project report.pdfFruit shop management system project report.pdf
Fruit shop management system project report.pdfKamal Acharya
 
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptx
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptxCloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptx
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptxMd. Shahidul Islam Prodhan
 

Recently uploaded (20)

KIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and Clustering
KIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and ClusteringKIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and Clustering
KIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and Clustering
 
Electrostatic field in a coaxial transmission line
Electrostatic field in a coaxial transmission lineElectrostatic field in a coaxial transmission line
Electrostatic field in a coaxial transmission line
 
shape functions of 1D and 2 D rectangular elements.pptx
shape functions of 1D and 2 D rectangular elements.pptxshape functions of 1D and 2 D rectangular elements.pptx
shape functions of 1D and 2 D rectangular elements.pptx
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
 
A case study of cinema management system project report..pdf
A case study of cinema management system project report..pdfA case study of cinema management system project report..pdf
A case study of cinema management system project report..pdf
 
İTÜ CAD and Reverse Engineering Workshop
İTÜ CAD and Reverse Engineering WorkshopİTÜ CAD and Reverse Engineering Workshop
İTÜ CAD and Reverse Engineering Workshop
 
RS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical SolutionsRS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
 
Pharmacy management system project report..pdf
Pharmacy management system project report..pdfPharmacy management system project report..pdf
Pharmacy management system project report..pdf
 
KIT-601 Lecture Notes-UNIT-5.pdf Frame Works and Visualization
KIT-601 Lecture Notes-UNIT-5.pdf Frame Works and VisualizationKIT-601 Lecture Notes-UNIT-5.pdf Frame Works and Visualization
KIT-601 Lecture Notes-UNIT-5.pdf Frame Works and Visualization
 
retail automation billing system ppt.pptx
retail automation billing system ppt.pptxretail automation billing system ppt.pptx
retail automation billing system ppt.pptx
 
NO1 Pandit Black Magic Removal in Uk kala jadu Specialist kala jadu for Love ...
NO1 Pandit Black Magic Removal in Uk kala jadu Specialist kala jadu for Love ...NO1 Pandit Black Magic Removal in Uk kala jadu Specialist kala jadu for Love ...
NO1 Pandit Black Magic Removal in Uk kala jadu Specialist kala jadu for Love ...
 
Arduino based vehicle speed tracker project
Arduino based vehicle speed tracker projectArduino based vehicle speed tracker project
Arduino based vehicle speed tracker project
 
Furniture showroom management system project.pdf
Furniture showroom management system project.pdfFurniture showroom management system project.pdf
Furniture showroom management system project.pdf
 
Hall booking system project report .pdf
Hall booking system project report  .pdfHall booking system project report  .pdf
Hall booking system project report .pdf
 
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
 
Event Management System Vb Net Project Report.pdf
Event Management System Vb Net  Project Report.pdfEvent Management System Vb Net  Project Report.pdf
Event Management System Vb Net Project Report.pdf
 
Peek implant persentation - Copy (1).pdf
Peek implant persentation - Copy (1).pdfPeek implant persentation - Copy (1).pdf
Peek implant persentation - Copy (1).pdf
 
BRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWING
BRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWINGBRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWING
BRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWING
 
Fruit shop management system project report.pdf
Fruit shop management system project report.pdfFruit shop management system project report.pdf
Fruit shop management system project report.pdf
 
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptx
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptxCloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptx
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptx
 

Micro project on ARQ

  • 1. MICRO PROJECT COMPUTER NETWORKS LAB COURSE CODE: CS-692 TEAM MEMBERS: NAME: CLASS ROLL NO: UNIVERSITY ROLL NO: FAIZAAN AHMED KHAN (CSE/2013/089) 11700113029 GIRI SWAGARIKA JAHARLAL (CSE/2014/B03) 11700213023 ABHIPSA CHAKRABORTY (CSE/2014/B02) 11700213002 SHREYA DAS (CSE/2014/B05) 11700213067
  • 2. GO BACK N ARQ: AIM: Go Back n is a connection oriented protocol in which the transmitter has a window of sequence numbers that may be transmitted without acknowledgment. The receiver will only accept the next sequence number it is expecting - other sequence numbers are silently ignored. In this portion we will know about how the protocol works. THEORY: Go-Back-N ARQ is a specific instance of the automatic repeat request (ARQ) protocol, in which the sending process continues to send a number of frames specified by a window size even without receiving an acknowledgement (ACK) packet from the receiver. It is a special case of the general sliding window protocol with the transmit window size of N and receive window size of 1. It can transmit N frames to the peer before requiring an ACK. The receiver process keeps track of the sequence number of the next frame it expects to receive, and sends that number with every ACK it sends. The receiver will discard any frame that does not have the exact sequence number it expects (either a duplicate frame it already acknowledged, or an out-of-order frame it expects to receive later) and will resend an ACK for the last correct in-order frame. Once the sender has sent all of the frames in its window, it will detect that all of the frames since the first lost frame are outstanding, and will go back to the sequence number of the last ACK it received from the receiver process and fill its window starting with that frame and continue the process over again. Go-Back-N ARQ is a more efficient use of a connection than Stop-and-wait ARQ, since unlike waiting for an acknowledgement for each packet, the connection is still being utilized as packets are being sent. In other words, during the time that would otherwise be spent waiting, more packets are being sent. However, this method also results in sending frames multiple times – if any frame was lost or damaged, or the ACK acknowledging them was lost or damaged, then that frame and all following frames in the window (even if they were received without error) will be re-sent. To avoid this, Selective Repeat ARQ can be used.
  • 3. Go-Back-N ARQ protocol : To understand this protocol you should first understand what is window size. I'll assume that you already know it. consider above scenario there are four frames 0,1,2,3 respectively. Now as sending window size is 3 it'll send frame 0,1,2 at a time.  At receiver side frame 0 arrives it sends ack for that.  Now at sender side window shift at frame 3 and it sends frame no 3.  At receiver side frame 1 arrives it sends ack for that.  Now at sender side window shift at frame 0 and it sends frame no 0. (this is not previous frame 0)  Now receiver detects frame 2 is missing or lost. It'll send NAK for that.  Sender receives NAK at this point sending window is pointing towards frame 2,3 and next frame 0.  With same scenario Stop-N-Wait protocol re-transmits all frames that are pointed by sending window. But in Go-Back-N only frame 2 is re-transmits. and repeat this until it gets ack for frame 2. So Go-Back-N is more efficient.
  • 4. Features required for Go-Back-N ARQ  To support Go-Back-N ARQ, a protocol must number each PDU which is sent. (PDUs are normally numbered using modulo arithmetic, which allows the same number to be re-used after a suitably long period of time. 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 which have been sent, but have not yet been acknowledged.  The receiver at the remote node keeps a record of the highest numbered PDU which has been correctly received. This number corresponds to the last acknowledgement PDU which it may have sent. Recovery of lost PDUs using Go-Back-N The recovery of a corrupted PDU proceeds in three 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 NACK or REJECT). The receiver discards all PDUs which do not have the number of the requested PDU.  The final stage consists of retransmission of the lost PDU(s). Retransmission using Go-Back-N A remote node may request retransmission of corrupted PDUs by initiating Go-Back-N error recovery by sending a control PDU indicating the last successfully received PDU. This allows the remote node to instruct the sending node where to begin retransmission of
  • 5. PDUs. The remote node does not store any out-of-sequence PDUs and therefore must discard all received PDUs until one is received with the expected sequence number. Upon receipt of a Go-Back-N control PDU (by the local node), the transmitter winds- back the sequence of PDUs pending transmission to the indicated PDU in its buffer of unacknowledged PDUs. The transmitter then retransmits (Goes Back-to-N) the requested PDU followed by all successive PDUs. This is sometimes known as "wind back" of the transmitter. Example of Go-Back-N: The sender in this example transmits four PDUs (1-4) and the first one (1) of these is not successfully received. The receiver notes that it was expecting a PDU numbered 1 and actually receives a PDU numbered 2. It therefore deduces that (1) was lost. It requests retransmission of the missing PDU by sending a Go-Back-N request (in this case N=1), and discards all received PDUs with a number greater than 1.The sender receives the Go-Back- N request and retransmits the missing PDU (1), followed by all subsequently sent PDUs (2- 4) which the receiver the correctly receives and acknowledges. If the retransmission is not successful, the protocol relies upon a protocol timer in the local node to detect that no acknowledgment was received. The lost PDUs may then be recovered by Polling. CODE: #include<stdio.h> int main() { int windowsize,sent=0,ack,i; printf("enter window sizen"); scanf("%d",&windowsize);
  • 6. while(1) { for( i = 0; i < windowsize; i++) { printf("Frame %d has been transmitted.n",sent); sent++; if(sent == windowsize) break; } printf("nPlease enter the last Acknowledgement received.n"); scanf("%d",&ack); if(ack == windowsize) break; else sent = ack; } return 0; } OUTPUT: enter window size 8 Frame 0 has been transmitted. Frame 1 has been transmitted. Frame 2 has been transmitted. Frame 3 has been transmitted. Frame 4 has been transmitted. Frame 5 has been transmitted. Frame 6 has been transmitted. Frame 7 has been transmitted. Please enter the last Acknowledgement received. 2 Frame 2 has been transmitted. Frame 3 has been transmitted. Frame 4 has been transmitted. Frame 5 has been transmitted. Frame 6 has been transmitted. Frame 7 has been transmitted. Please enter the last Acknowledgement received. 8 --------------------------------
  • 7. STOP AND WAIT ARQ: AIM: "Stop-n-wait" (sometimes known as "positive acknowledgement with retransmission") is the fundamental technique to provide reliable transfer under unreliable packet delivery system. In this portion we will know about how the protocol works. THEORY AND DIAGRAM: Stop-and-wait ARQ also can be referred as alternating bit protocol is a method used in telecommunications to send information between two connected devices. It ensures that information is not lost due to dropped packets and that packets are received in the correct order. It is the simplest kind of automatic repeat-request (ARQ) method. A stop-and-wait ARQ sender sends one frame at a time; it is a special case of the general sliding window protocol with both transmit and receive window sizes equal to 1 and more than one respectively . After sending each frame, the sender doesn't send any further frames until it receives an acknowledgement (ACK) signal. After receiving a good frame, the receiver sends an ACK. If the ACK does not reach the sender before a certain time, known as the timeout, the sender sends the same frame again. Timer is set after each frame transmission. The above behavior is the simplest Stop-and-Wait implementation. However, in a real life implementation there are problems to be addressed. Typically the transmitter adds a redundancy check number to the end of each frame. The receiver uses the redundancy check number to check for possible damage. If the receiver sees that the frame is good, it sends an ACK. If the receiver sees that the frame is damaged, the receiver discards it and does not send an ACK—pretending that the frame was completely lost, not merely damaged. One problem is when the ACK sent by the receiver is damaged or lost. In this case, the sender doesn't receive the ACK, times out, and sends the frame again. Now the receiver has two copies of the same frame, and doesn't know if the second one is a duplicate frame or the next frame of the sequence carrying identical data. Another problem is when the transmission medium has such a long latency that the sender's timeout runs out before the frame reaches the receiver. In this case the sender resends the same packet. Eventually the receiver gets two copies of the same frame, and sends an ACK for each one. The sender, waiting for a single ACK, receives two ACKs, which may cause problems if it assumes that the second ACK is for the next frame in the sequence.
  • 8. To avoid these problems, the most common solution is to define a 1 bit sequence number in the header of the frame. This sequence number alternates (from 0 to 1) in subsequent frames. When the receiver sends an ACK, it includes the sequence number of the next packet it expects. This way, the receiver can detect duplicated frames by checking if the frame sequence numbers alternate. If two subsequent frames have the same sequence number, they are duplicates, and the second frame is discarded. Similarly, if two subsequent ACKs reference the same sequence number, they are acknowledging the same frame. Stop-and-wait ARQ is inefficient compared to other ARQs, because the time between packets, if the ACK and the data are received successfully, is twice the transit time (assuming the turnaround time can be zero). The throughput on the channel is a fraction of what it could be. To solve this problem, one can send more than one packet at a time with a larger sequence number and use one ACK for a set. This is what is done in Go-Back-N ARQ and the Selective Repeat ARQ. How this protocol works.. 1) Normal operation: After transmitting one packet, the sender waits for an acknowledgment (ACK) from the receiver before transmitting the next one. In this way, the sender can recognize that the previous packet is transmitted successfuly and we could say "stop-n-wait" guarantees reliable transfer between nodes. To support this feature, the sender keeps a record of each packet it sends. Also, to avoid confusion caused by delayed or duplicated ACKs, "stop-n-wait" sends each packets with unique sequence numbers and receives that numbers in each ACKs.
  • 9. 2) Timeout: If the sender doesn't receive ACK for previous sent packet after a certain period of time, the sender times out and retransmit that packet again. There are two cases when the sender doesn't receive ACK; one is when the ACK is lost and the other is when the frame itself is not transmitted. To support this feature, the sender keeps timer per each packet. 3. How it is shown in nam (network animator).. "stop-n-wait" protocol can be shown as below in nam.
  • 10. 1. Packet_0 is sent and ACK_0 is received
  • 11. 2. Packet_1 is sent and ACK_1 is received 3. Packet_2 will be sent and be received and so on..
  • 12. Shortcoming: The main shortcoming of the stop-and-wait algorithm is that it allows the sender to have only one outstanding frame on the link at a time. The sender should wait till it gets an ACK of previous frame before it sends next frame. As a result, it wastes a substantial amount of network bandwidth. To improve efficiency while providing reliability, "sliding window" protocol is appeared. CODE: #include<stdio.h> #define MAXSIZE 100 typedef struct { unsigned char data[MAXSIZE]; }packet; typedef enum{data,ack}frame_kind; typedef struct { frame_kind kind; int sq_no; int ack; packet info; }frame; typedef enum{frame_arrival}event_type; typedef enum{true_false}boolean; void frame_network_layer(packet *p) { printf("n from network arrival"); } void to_physical_layer(frame *f) { printf("n to physical layer"); } void wait_for_event(event_type *e) { printf("n waiting for event n"); } void sender(void) { frame s; packet buffer; event_type event;
  • 13. printf("n ***SENDER***"); frame_network_layer(&buffer); s.info=buffer; to_physical_layer(&s); wait_for_event(&event); } void from_physical_layer(frame *f) { printf("from physical layer"); } void to_network_layer(packet *p) { printf("n to network layer"); } void receiver(void) { frame r,s; event_type event; printf("n ***RECEIVER***"); wait_for_event(&event); from_physical_layer(&r); to_network_layer(&r.info); to_physical_layer(&s); } main() { sender(); receiver(); }