GROUP10_FOSTERS:algorithm of g back n arq
SENDER
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 ) ;
}
}
}
Recent Comments