Home > Group10_FOSTERS > GROUP10_FOSTERS:algorithm of g back n arq

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 ) ;
}
}
}

Categories: Group10_FOSTERS
  1. No comments yet.
  1. No trackbacks yet.
You must be logged in to post a comment.
Follow

Get every new post delivered to your Inbox.