Professional Documents
Culture Documents
Go Back N Arq
Go Back N Arq
Go Back N Arq
Group no: 10
Group name : THE KING MAKERS
Group
members:
Chetan .S
(1ms07is021)
Deepak.P.J
(1ms07is022)
Pavan.R
(1ms07is062)
Phaneesh.L.N ( 1ms07is066)
Introduction:
ARQ is a method of data transmission which uses timeouts and
acknowledgement signals to achieve reliable transmission over
an unreliable service i.e the internet. An acknowledgement is a
message sent by the receiver to the transmitter to indicate that it
has correctly received a data frame or packet. A timeout is a
reasonable point in time after the sender sends the frame/packet;
if the sender does not receive an acknowledgement before the
timeout, it usually re-transmits the frame/packet until it receives
an acknowledgement or exceeds a predefined number of re-
transmissions.
There are mainly 3 types of ARQ
• Stop and wait ARQ
• Go back n ARQ
• Selective repeat ARQ
LITERATURE SURVEY
The present invention relates to a data transmission system
using an automatic repeat request (hereinafter is referred to
as abbreviation "ARQ") and more particularly to
a data transmission system for realizing a procedure of
retransmission of error detected frames, which is adapted to
a transmission channel such as radio communication with
relatively high transmission error-rate.
Sw = 2 ^m -1;
Sf = 0;
Sn = 0;
While ( true)
{
Waitforevent ( );
If (event (requesttosend) )
{
If (Sn-Sf >=Sw)
Sleep ( );
Getdata ( ) ;
Makeframes (Sn);
Storeframes (Sn);
Sendframes (Sn);
Sn =Sn+1;
If ( timer not running)
Starttimer ( );
}
If ( event ( arrivalnotification ) )
{
Receive (ACK);
If ( corrupted (ACK) )
Sleep ( );
If ( ( ackno > Sf ) && ( ackno <= Sn ) ) ;
While ( Sf <= ackno )
{
Purgeframe ( Sf );
Sf = Sf + 1;
}
Stoptimer ( );
}
If ( event ( timeout ) )
{
Starttimer ( ) ;
Temp = Sf ;
While ( temp < Sn );
{
Sendframe ( Sf );
Sf = Sf + 1;
}
}
RECEIVER
Rn = 0;
While ( true )
Waitforevent ( ) ;
If ( event (arrivalnotification ) )
Receive ( frame ) ;
If ( corrupted ( frame ) )
Sleep ( ) ;
If ( seqno == Rn )
Deliverdata ( ) ;
Rn = Rn + 1 ;
sendACK ( Rn ) ;
}
PROGRAM :
#include<iostream>
#include<cstring>
#include<string>
#include<fstream>
using namespace std;
int flag=0;
int flag1=0;
int flag2=0;
int flag4=0;
int flag5=0;
int flag6=0;
int loop2;
char ch1;
char ch2;
int loop;
char sender[50]="How many wants to live after 2012 ?";
char recive[50];
int lensender;
int senderack[50];
int curpos;
int i;
int k;
int trav=0;
int Ws;
int recnext;
int errack[10]={-1};
int errno;
int errpck[10]={-1};
int waste;
char ch='r';
void dispsending();
void send();
void shift();
void dispsimple();
void dispreceiving();
int timer(char str[50],char value[50],int colval) //function takes read, to
be searched string and field, size of str1
{
int k,count=0,i=0,flag=2; //outer loop to travers through ':'
for(k=0;k<40;k++) //timer started to check the sender and receiver
{
if(str[k]==':') //to start search only after required position
got
count++;
else
if(count==colval) //start positon
{
count++; //count incremented so that loop wont search again
while( isdigit(value[i]) ) //loop till the key element
traversed
{
if(!isdigit(str[k+i])) //this returns if
key element is greater size wise
{
flag=1;
return flag+10;
}
if(str[k+i]!=value[i]) //if values are not
matching find if its greater
{
if(flag==2) //this condition makes flag change
only once its lifetime
flag=-1;
if(str[k+i]>value[i])
{
if(flag==-1) //same as above usage
flag=3; //assign if data is
greater
}
else
if(flag==-1)
flag=1;
}
i++; //increment the searching loop for size of key
element
}
if(isdigit(str[k+i])) //if next element after the search
is digit then data is greater
flag=3;
}
}
return flag+10;
}
//start of pgm
int main()
{
curpos=0;
recnext=0;
cout<<"enter the sliding window size\n";
cin>>Ws;
lensender=strlen(sender);
cout<<"how many packets to miss?";
cin>>errno;
for(i=0;i<errno;i++)
{
cin>>errpck[i]; //read the packets to miss
}
cout<<"how many ack's to miss?";
cin>>errno;
for(i=0;i<errno;i++)
{
cin>>errack[i]; //read the acks to miss
}
while(curpos<lensender)
{
cout<<" press Y to miss ack or packet: ";
while(ch=='!')
{
cin>>ch;
}
if(ch=='y')
{ //reads the second time
cout<<"how many packets to miss?";
cin>>errno;
for(i=0;i<errno;i++)
{
cin>>errpck[i]; //read the packets to miss
}
cout<<"how many ack's to miss?";
cin>>errno;
for(i=0;i<errno;i++)
{
cin>>errack[i]; //read the acks to miss
}
}
cout<<"\n\n---------------THE NEW WINDOW POSITION------------\n";
dispsimple();
send();
int use=timer(sender,recive,Ws);
if(use==-1) //if timed out the packets are resent
send();
dispsending();
dispreceiving();
//cout<<"the acknowledge\n\n";
//for(i=0;i<lensender;i++)
//cout<<senderack[i];
//cout<<endl;
loop2=curpos;
for(;senderack[loop2]==1;loop2++) //slide the
window till a acknowledge is recieved properly
{
curpos++;
}
ch='!';
cout<<"\n\n----------------- x ------ x -----------------\n";
}
return 0;
} //end of main
void send()
{
if((curpos+loop)!=errpck[flag4])
{
if(recnext==(curpos+loop))
{ //to find the first
defect packet
recive[recnext]=sender[curpos+loop];
recnext++;
}
}
else
{
break; //flag 5 used to detect if packet failure
is happen
}
}
int temp=loop;
if((curpos+loop)!=errpck[flag4])
{
if(recnext==(curpos+loop))
{
recive[recnext]=sender[curpos+loop];
recnext++;
}
}
else
{
flag4++;
flag5=1; //flag 5 used to detect if packet failure
is happen
}
}
for(loop=0;loop<temp;loop++)
{
if((curpos+loop)==errack[flag2])
{
senderack[curpos+loop]=-1;
flag2++;
flag1=1; //this is set so that we will come to know
if error in ack is occured
}
else
{
senderack[curpos+loop]=1;
}
}
}
/*int flag=0,flag1=0,flag2=0,loop2,loop;
char sender[50]="bhaskar is very good person";
char recive[50];
int lensender,senderack[50],curpos,i,k,Ws,recnext,errack,errpck;*/
void dispsending()
{
int temp;
int q;
q=trav; //used to identify the packet currently in
temp=(Ws/2)+curpos+1;
cout<<" ";
for(k=0;k<temp;k++)
cout<<" "; //print the top part
cout<<"|";
for(;k<(lensender+10+(strlen(recive)/2));k++)
cout<<"`";
cout<<"|";k++;
waste=k;
cout<<endl;
cout<<" ";
cout<<" ";
for(;k<waste-2;k++)
cout<<" ";
cout<<"| ";
cout<<endl;
q=trav;
cout<<" ";
for(k=0;k<curpos && k<lensender;k++)
cout<<" ";
cout<<" ";
ch1='&'; //for packet sending line 2
for(;k<(curpos+Ws) && k<lensender;k++)
{
if(errpck[q]==k)
{
cout<<ch1;
ch1++;
q++;
}
else
cout<<"|";
}
cout<<" ";
for(;k<waste-2;k++)
cout<<" ";
cout<<"| ";
for(k=curpos+1;k<(curpos+Ws);k++)
{ for(i=0;i<10;i++)
if(flag5==0)
{
if(errpck[i]==k)
{
cout<<"packet-"<<errpck[i];
flag5=1;
errpck[i]=-1;
}
}
else
if(errpck[i]==k)
{
cout<<","<<errpck[i];
errpck[i]=-1;
}
}
cout<<endl;
trav=q;
cout<<" ";
for(k=0;k<curpos && k<lensender;k++)
cout<<" ";
cout<<",";
for(;k<(curpos+Ws) && k<lensender;k++)
cout<<"|";
cout<<",";
for(;k<waste-2;k++)
cout<<" ";
cout<<"V ";
if(flag6==1)
cout<<" missing :-(";
cout<<endl;
cout<<" ";
for(i=0;i<curpos;i++)
cout<<sender[i];
cout<<"|";
for(;i<(curpos+Ws) && i<lensender;i++)
cout<<sender[i];
cout<<"|";
for(;i<lensender;i++)
cout<<sender[i];
for(;i<waste-2;i++)
cout<<" ";
cout<<"V";
cout<<endl;
cout<<" ";
for(k=0;k<curpos;k++)
cout<<" ";
cout<<"`";
for(;k<(curpos+Ws) && k<lensender;k++)
cout<<"`";
cout<<"`";
for(;k<lensender+10;k++)
cout<<" ";
cout<<recive;
cout<<endl;
cout<<endl<<endl;
void dispsimple()
{
cout<<" ";
for(k=0;k<curpos && k<lensender;k++)
cout<<" ";
cout<<",";
for(;k<(curpos+Ws) && k<lensender;k++)
cout<<",";
cout<<",";
cout<<endl;
cout<<" ";
for(i=0;i<curpos;i++)
cout<<sender[i];
cout<<"|";
for(;i<(curpos+Ws) && i<lensender;i++)
cout<<sender[i];
cout<<"|";
for(;i<lensender;i++)
cout<<sender[i];
for(;i<lensender+3;i++)
cout<<" ";
cout<<"-->";
for(;i<lensender+10;i++)
cout<<" ";
cout<<recive;
cout<<endl;
cout<<" ";
for(k=0;k<curpos;k++)
cout<<" ";
cout<<"`";
for(;k<(curpos+Ws) && k<lensender;k++)
cout<<"`";
cout<<"`";
cout<<endl<<endl;
}
void dispreceiving()
{
int temp;
temp=(Ws/2)+curpos+1;
cout<<" ";
for(k=0;k<temp;k++)
cout<<" "; //print the top part
cout<<"|";
for(;k<(lensender+10+(strlen(recive)/2));k++)
cout<<"`";
cout<<"|";k++;
waste=k;
cout<<endl;
cout<<" ";
for(k=0;k<curpos && k<lensender;k++)
cout<<" ";
cout<<" "; //for packet sending
for(;k<(curpos+Ws) && k<lensender;k++)
{ if(senderack[k]==1)
cout<<"|";
else
if(senderack[k]==0)
cout<<" ";
else
if(senderack[k]==-1)
cout<<"|";
}
cout<<" ";
for(;k<waste-2;k++)
cout<<" ";
cout<<"|";
cout<<endl;
cout<<" ";
for(k=0;k<curpos && k<lensender;k++)
cout<<" ";
cout<<" ";
ch2='@'; //for packet sending line 2
for(;k<(curpos+Ws) && k<lensender;k++)
{ if(senderack[k]==1)
cout<<"|";
else
if(senderack[k]==0)
cout<<" ";
else
if(senderack[k]==-1)
{
cout<<ch2;
ch2--;
}
}
cout<<" ";
for(;k<waste-2;k++)
cout<<" ";
cout<<"| (received)";
cout<<endl;
cout<<" ";
for(k=0;k<curpos && k<lensender;k++)
cout<<" ";
cout<<" "; //for packet sending line 2
for(;k<(curpos+Ws) && k<lensender;k++)
{ if(senderack[k]==1)
cout<<"|";
else
if(senderack[k]==0)
cout<<" ";
else
if(senderack[k]==-1)
cout<<" ";
}
cout<<" ";
for(;k<waste-2;k++)
cout<<" ";
cout<<"| ";
flag6=0;
for(k=curpos;k<(curpos+Ws);k++)
{
if(flag6==0)
{
if(senderack[k]==-1)
{
cout<<"ACK-"<<k;
flag6=1;
}
}
else
if(senderack[k]==-1)
{
cout<<","<<k;
}
}
cout<<endl;
cout<<" ";
for(k=0;k<curpos && k<lensender;k++)
cout<<" ";
cout<<",";
for(;k<(curpos+Ws) && k<lensender;k++)
{ if(senderack[k]==1)
cout<<"|";
else
cout<<",";
}
cout<<",";
for(;k<waste-2;k++)
cout<<" ";
cout<<"| ";
if(flag6==1)
cout<<" missing :-(";
cout<<endl;
cout<<" ";
for(i=0;i<curpos;i++)
cout<<sender[i];
cout<<"|";
for(;i<(curpos+Ws) && i<lensender;i++)
cout<<sender[i];
cout<<"|";
for(;i<lensender;i++)
cout<<sender[i];
for(;i<waste-2;i++)
cout<<" ";
if(flag6==1 || flag5==1)
cout<<"| TIME OUT (resending...)";
else
cout<<"|";
flag6=0,flag5=0;
cout<<endl;
cout<<" ";
for(k=0;k<curpos;k++)
cout<<" ";
cout<<"`";
for(;k<(curpos+Ws) && k<lensender;k++)
cout<<"`";
cout<<"`";
for(;k<lensender+10;k++)
cout<<" ";
cout<<recive;
cout<<endl;
cout<<" ";
for(k=0;k<curpos-1;k++)
cout<<" ";
cout<<curpos<<",0 <-";
for(;k<curpos+Ws-6;k++)
cout<<" ";
cout<<"-> "<<Ws-1;
cout<<endl;
}
RESULTS : ( OUT PUT )
LIMITATIONS
• Even the transmitted frames should be sent again if there is
failure in successful transmission of the previously sent
frames.
• The receiver can’t accept any frames which is out of order.
CONCLUSION