RELIABLE TRANSMISSION
RELIABLE TRANSMISSION
Concept of data flow between sender and receiver
using OSI Model
RELIABLE TRANSMISSION
Sender Side:
Network Layer (N/L) waits for an EVENT
 EVENT : (Request To Send) the data is made by sender
 When sender wants to send data
 Network Layer Gets Data from upper Layers
Data-Link Layer packages the data and Makes Frame
Physical Layer Sends Frame in form of signal
Receiver Side:
Physical Layer waits for an EVENT
 EVENT :(Arrival Notification) of frame is made to Data-Link Layer
 When the frame arrives at the receiver
 Physical layer Receives Frame
Data-Link Layer Extracts Data from the frame and Delivers Data
to Network Layer
Network
Data Link
Physical
Network
Data Link
Physical
Waiting for EVENT
Request To Send
Sender wants to send data
Gets Data
Sends Frame in signal form
Get Data( ) Make Frame ( ) Send Frame( )
Waiting for EVENT
Makes Frame
Arrival Notification
Frame arrives at receiver
Receives Frame
Extracts Data
Delivers Data
Receive Frame( ) Extract Data ( )
Deliver
Data( )
while(true)
{
 WaitForEvent( )
 If Event( RequestToSend( ) )
 {
 Get Data ( )
 Make Frame( )
 Send Frame( )
 }
}
while(true)
{
 WaitForEvent( )
 If Event( ArrivalNotification( ) )
 {
 Receive Frame ( )
 Extract Data( )
 Deliver Data( )
 }
}
Request To Send
Network
Data Link
Physical Arrival Notification
Physical
Data Link
Network
RELIABLE TRANSMISSION
When an error is introduced into the frames and they get
corrupted.
We can use some Error Correction Scheme (ECS) to correct
them
But ECS produce a very large overhead
Or even some errors are to severe to be corrected by ECS
So ultimately we need to discard the frames
We need some strategy to RECOVER these discarded frames
Flow Control: Sender needs to make sure that it is not
sending “more data” then the capacity of receiver
RELIABLE TRANSMISSION
Every strategy used for recovering frames involves two common
concepts
Acknowledgement (Ack)
Whenever frame arrives at the receiver and it is not corrupted
 Receiver sends a control frame back to sender for confirmation purpose
 This control frame is called Acknowledgement (Ack) frame
Timeout
Whenever sender transmits a frame it then waits for the
acknowledgement by starting a timer
This waiting time is usually equal to Round Trip Time (RTT)
If the acknowledgement does not come back with in waiting time,
an EVENT occurs called “Timeout”
 When “Timeout” event occurs sender retransmits the frame
RELIABLE TRANSMISSION
The general strategy to implement Acknowledgements &
Timeout is sometimes called
ARQ ( Automatic Repeat Request )
We will study the following ARQ Algorithms
Stop-And-Wait ARQ
Go-Back-N ARQ
Selective Repeat ARQ
Stop-And-Wait ARQ
Stop-And-Wait ARQ
The simplest ARQ scheme is the stop-and-wait algorithm
 After transmitting one frame, the Sender
 Starts the timer and STOPS the transmission
 WAITS for an acknowledgment until the timer expires
 If the acknowledgement comes back before the expiration
of timer only then next frame is transmitted
 If the acknowledgment does not arrive before the
expiration of timer
 the sender times out and retransmits the original frame.
Stop-And-Wait ARQ
Stop-And-Wait ARQ
 Problem: Receiver has duplicate frames
Stop-And-Wait ARQ
So apart from corrupted frames RECEIVER may also face
problems of Duplicated frames and Out-Of-Order frames (Lost
frames)
A corrupted frame can be detected by an error detection
strategy
For detecting Duplicated frames and Lost frames
Every fame is given a special number called
SEQUENCE NUMBER
If two received frames have same sequence number, it
indicates that frames are duplicated
If two frames come out of order, it means that a frame in
between may have been lost
Stop-And-Wait ARQ
Like data frames acknowledgements are also given Sequence
Numbers (or Acknowledgement Number)
The Acknowledgement Number is actually the sequence number
of next Expected Frame i.e.
 Ack_No:= Seq_No + 1
So when a receiver accepts a Data Frame with Seq_No:=3
 Receiver sends an acknowledgement back to sender with Ack_No:=4
 When sender receives the Acknowledgement with Ack_No:=4,
 This tells the sender that receiver has received the frame with Seq_No:=3
 And now it is expecting the next frame with Seq_No:=4
Stop-And-Wait ARQ
How many frames can be counted by the Sequence Number?
If M bits are used for the sequence number
It can count 2M frames
Where the count begins from zero and goes up to 2M - 1
If there are more then 2M frames, the counting is again repeated
from 0 to 2m - 1
For example if 3 bits are used for the sequence number
It can count 23 frames, i.e. 8 frames
Where the count goes from 0 to 7
If there are 8th, 9th and 10th frames, they will be numbered 0, 1 and 2
The size of sequence number field should be chosen to
minimize the size of frames
Stop-And-Wait ARQ
For the sake of Stop-and-Wait ARQ, there can only be at
most two frames on the communication line
Data Frame and Acknowledgement Frame
So one bit is enough to count the frame and
acknowledgement, i.e. using one bit possible values = 0, 1
The 4 frames will be counted like this: 0, 1, 0, 1
Now if sender sends a frame with Seq_No:= 0
The Receiver will send an Acknowledgement with
Ack_No:=1
Stop-And-Wait ARQ
Data
Frame Sn = 0
Event
canSend
Sequence Number
True
Sn = 0
RequestToSend
Frame Sn = 0
Sn = 1
False
Frame Ackn = 1
Arrival Notification
True
Data
Frame Sn = 0
Event
canSend
Sequence Number
True
Sn = 0
RequestToSend
Frame Sn = 0
Sn = 1
False
Arrival NotificationEvent TimeOut ( )
Frame Sn = 0
SN = 0;
canSend = True;
While ( true ) {
 WaitForEvent( );
 If Event( RequestToSend( ) And canSend = True ) {
 Get Data ( );
 Make Frame ( SN );
 Store Frame ( SN );
 Send Frame ( SN );
 Start Timer ( );
 SN = ( SN + 1 ) % 2
 canSend = False;
}
WaitForEvent ( );
If Event( Arrival Notification( ) ) {
Receive Frame ( AckN );
 If ( (Not Corrupted) And AckN = SN )
{
 Stop Timer ( );
 Purge Frame ( SN - 1 );
 canSend = True;
}
}
If Event( Time Out( ) ) {
Start Timer( );
Resend Frame( SN - 1 );
}
}
Stop-And-Wait ARQ
Event
Sequence Number
Frame Sn = 0
Rn = 0
Arrival Notification
Event
Sequence Number
Frame Sn = 0
Rn = 0
Arrival Notification
Rn = 1
Frame Ackn = 1
Data
Frame Sn = 0
RN = 0;
While ( true ) {
 WaitForEvent( );
 If Event( Arrival Notification ) {
 Receive Frame ( );
 If ( Frame is Corrupted )
 Sleep ( );
 If ( Sn = Rn ) {
 Extract Data ( );
 Deliver Data ( );
 Rn = (Rn + 1) mod 2
 }
 Send Acknowledgement ( Rn );
}
}
Stop-And-Wait ARQ
Drawback: Wastage of bandwidth.
At a given time there can only be One Frame on the
communication line
Stop and Wait ARQ
Go-Back-N ARQ
In this protocol we can send multiple frames without receiving
acknowledgement
This protocol uses a logical concept called:
SLIDING WINDOW
 Collection of frames that can be transmitted without receiving
acknowledgement
 Unacknowledged frames which are transmitted i.e. the frames
present in the window are called Outstanding frames
This protocol also uses the concept of:
CUMULATIVE ACKNOWLEDGEMENT
 A single acknowledgement frame which acknowledges multiple
frames
A single timer can run for all the frames
Or separate timers can run for every frame
Go-Back-N ARQ
A window is divided into three parts
Frames that have
already been
acknowledged,
sender ignores
these frames
completely
SENDER WINDOW
Outstanding frames
with unknown status,
i.e. their
acknowledgement
has not yet arrived
(actual window)
Frames that cannot be
transmitted. Every
time ACK of
outstanding frame
arrives, the window
slides to right
0 1 2 3 4 5 6 7 8 9 10 11
Receiver window
contains only one frame
Go-Back-N ARQ
Procedure:
Suppose the sender window size is 3 frames
Sender transmits frame 0,1 and 2 without waiting for
acknowledgement
After transmitting frame 0, it immediately starts the timer
Receiver sends an acknowledgement for every frame
Every time acknowledgment arrives,
 Sender window slides to the right, meaning one more frame enters the
window and the Acknowledged Frame exits the window
If the acknowledgment does not come, the sender goes back to the
beginning of window and retransmits all frames
Hence the name Go-Back-N ARQ
0 1 2 3 4 5
Sender Window = 3 FRAMES
F0
F1
F2
A1
A2
A3
TIMEOUT
0
F3
F4
F5
A4
A5
A6
TIMEOUT
1 2 3 4 5
SENDER RECEIVER SENDER RECEIVER
Cumulative Acknowledgement
F0
F1
F2
A1
A2
A3
TIMEOUT
SENDER RECEIVER
F3
A4
Acknowledgment 4 arrives
before timeout
So in this case Ack-4 is the
Accumulative
Acknowledgement
Ack-4 will be accepted as
the acknowledgement for F3,
F2 and F1
F0
F1
F2
TIMEOUT
SENDER RECEIVER
F3
A1
Go-Back-N ARQ F2 arrives at the receiver
Where receiver is expecting F1
An out-of-order frame
So receiver discards it
And also the frame after it
Ultimately timer times out
Sender goes back to the
beginning of window (i.e. F1)
Retransmits all the frames
Go-Back-N ARQ
Size of Window:
How many frames can be sent without receiving
acknowledgement? Or in other words
How many frames can be outstanding?
We know that m bits can count 2m frames
But
Go-Back-N ARQ
If
m bits are used for sequence
number field then:
size of window <= 2m – 1
Go-Back-N ARQ
If m bits
are used for sequence number field
then:
size of window <= 2m – 1
If We break this rule, receiver cannot
detect duplicate frames, i.e. if keep
the window size = 2m
Go-Back-N ARQ
Suppose m is 3 bits so it can count 2m = 23 = 8 frames
Frames are numbered as 0,1,2,3,4,5,6,7
The size of window should be 2m – 1 = 23 – 1 = 7
Now instead of 7 we choose window size = 23 = 8
Entire window is transmitted i.e. frames from 0,1,….7
 All Frames were received correctly but their acknowledgements were lost
Next expected frame by the receiver is frame-0.
Sender retransmits frame-0 but this is not the new frame, it’s
the duplicate of first frame in window
But sender mistakenly accepts this frame as the new frame
instead of discarding it
Go-Back-N ARQ
Suppose m is 3 bits so it can count 2m = 23 = 8 frames
Frames are numbered as 0,1,2,3,4,5,6,7
This time we choose size of window = 2m – 1 = 7
Entire window is transmitted i.e. frames from 0,1,….6
All Frames were received correctly but their acknowledgements
were lost
Next expected frame by the receiver is frame-7
Sender retransmits frame-0
Since receiver has already received frame-0 and is expecting
frame-7
So receiver detects the duplicate frame and rightfully discards it
Go-Back-N ARQ
Event
Sender Window Size
Seq_No of First
Outstanding Frame
SW = 2
SF = 0
RequestToSend
Seq_No of Next Frame to
be transmitted
SN = 0
DataFrame Sn = 0
Frame Sn = 0
SN = 1
Frame Sn = 1
Frame Sn = 1
SN = 2
 SW = 2m – 1
 SF = 0
 SN = 0
 While ( true ) {
 WaitForEvent( );
 If Event ( RequestToSend )
{
If ( SN – SF >= SW )
Sleep ( )
Get Data ( );
Make Frame ( SN );
Store Frame ( SN );
Send Frame ( SN );
SN = SN + 1
If ( Timer Not Running )
Start Timer( )
 }
Frame Ackn = 1
Sender Window Size
Seq_No of First
Outstanding Frame
SW = 2
SF = 0
Seq_No of Next Frame to
be transmitted
SN = 0SN = 1SN = 2
Frame Sn = 0
Frame Sn = 1
Event
Arrival Notification
Frame Sn = 0
Frame Sn = 1
SF = 1
If Event( Arrival Notification( ) )
{
Receive Frame ( AckN );
If ( Corrupted Acknowledgement )
Sleep ( );
If ( Ack No > SF and Ack No <= SN )
While ( SF < Ack No )
{
Purge Frame(SF )
SF = SF + 1
}
Stop Timer ( )
}
Sender Window Size
Seq_No of First
Outstanding Frame
SW = 2
SF = 0
Seq_No of Next Frame to
be transmitted
SN = 0SN = 1SN = 2
Frame Sn = 0
Frame Sn = 1
Event
Time Out
Frame Sn = 0
Frame Sn = 1
Temp = 0Temp = 1Temp = 2
If Event( Time Out ) {
Start Timer( );
Temp = SF
While ( Temp < SN )
{
Send Frame( Temp )
Temp = Temp + 1
}
}
}
Go-Back-N ARQ
Event
Sequence Number
Frame Sn = 0
Rn = 0
Arrival Notification
Event
Sequence Number
Frame Sn = 0
Rn = 0
Arrival Notification
Rn = 1
Frame Ackn = 1
Data
Frame Sn = 0
 RN = 0;
 While ( true ) {
 WaitForEvent( );
 If Event( Arrival Notification ) {
Receive Frame ( );
If ( Frame is Corrupted )
Sleep ( );
If ( Sn = Rn ) {
Extract Data ( );
Deliver Data ( );
Rn = Rn + 1
}
Send Acknowledgement ( Rn );
}
 }
Selective Repeat ARQ
 Assignment

Reliablt transmission

  • 2.
  • 3.
    RELIABLE TRANSMISSION Concept ofdata flow between sender and receiver using OSI Model
  • 4.
    RELIABLE TRANSMISSION Sender Side: NetworkLayer (N/L) waits for an EVENT  EVENT : (Request To Send) the data is made by sender  When sender wants to send data  Network Layer Gets Data from upper Layers Data-Link Layer packages the data and Makes Frame Physical Layer Sends Frame in form of signal Receiver Side: Physical Layer waits for an EVENT  EVENT :(Arrival Notification) of frame is made to Data-Link Layer  When the frame arrives at the receiver  Physical layer Receives Frame Data-Link Layer Extracts Data from the frame and Delivers Data to Network Layer
  • 5.
    Network Data Link Physical Network Data Link Physical Waitingfor EVENT Request To Send Sender wants to send data Gets Data Sends Frame in signal form Get Data( ) Make Frame ( ) Send Frame( ) Waiting for EVENT Makes Frame Arrival Notification Frame arrives at receiver Receives Frame Extracts Data Delivers Data Receive Frame( ) Extract Data ( ) Deliver Data( )
  • 6.
    while(true) {  WaitForEvent( ) If Event( RequestToSend( ) )  {  Get Data ( )  Make Frame( )  Send Frame( )  } } while(true) {  WaitForEvent( )  If Event( ArrivalNotification( ) )  {  Receive Frame ( )  Extract Data( )  Deliver Data( )  } } Request To Send Network Data Link Physical Arrival Notification Physical Data Link Network
  • 7.
    RELIABLE TRANSMISSION When anerror is introduced into the frames and they get corrupted. We can use some Error Correction Scheme (ECS) to correct them But ECS produce a very large overhead Or even some errors are to severe to be corrected by ECS So ultimately we need to discard the frames We need some strategy to RECOVER these discarded frames Flow Control: Sender needs to make sure that it is not sending “more data” then the capacity of receiver
  • 8.
    RELIABLE TRANSMISSION Every strategyused for recovering frames involves two common concepts Acknowledgement (Ack) Whenever frame arrives at the receiver and it is not corrupted  Receiver sends a control frame back to sender for confirmation purpose  This control frame is called Acknowledgement (Ack) frame Timeout Whenever sender transmits a frame it then waits for the acknowledgement by starting a timer This waiting time is usually equal to Round Trip Time (RTT) If the acknowledgement does not come back with in waiting time, an EVENT occurs called “Timeout”  When “Timeout” event occurs sender retransmits the frame
  • 9.
    RELIABLE TRANSMISSION The generalstrategy to implement Acknowledgements & Timeout is sometimes called ARQ ( Automatic Repeat Request ) We will study the following ARQ Algorithms Stop-And-Wait ARQ Go-Back-N ARQ Selective Repeat ARQ
  • 10.
    Stop-And-Wait ARQ Stop-And-Wait ARQ Thesimplest ARQ scheme is the stop-and-wait algorithm  After transmitting one frame, the Sender  Starts the timer and STOPS the transmission  WAITS for an acknowledgment until the timer expires  If the acknowledgement comes back before the expiration of timer only then next frame is transmitted  If the acknowledgment does not arrive before the expiration of timer  the sender times out and retransmits the original frame.
  • 11.
  • 12.
    Stop-And-Wait ARQ  Problem:Receiver has duplicate frames
  • 13.
    Stop-And-Wait ARQ So apartfrom corrupted frames RECEIVER may also face problems of Duplicated frames and Out-Of-Order frames (Lost frames) A corrupted frame can be detected by an error detection strategy For detecting Duplicated frames and Lost frames Every fame is given a special number called SEQUENCE NUMBER If two received frames have same sequence number, it indicates that frames are duplicated If two frames come out of order, it means that a frame in between may have been lost
  • 14.
    Stop-And-Wait ARQ Like dataframes acknowledgements are also given Sequence Numbers (or Acknowledgement Number) The Acknowledgement Number is actually the sequence number of next Expected Frame i.e.  Ack_No:= Seq_No + 1 So when a receiver accepts a Data Frame with Seq_No:=3  Receiver sends an acknowledgement back to sender with Ack_No:=4  When sender receives the Acknowledgement with Ack_No:=4,  This tells the sender that receiver has received the frame with Seq_No:=3  And now it is expecting the next frame with Seq_No:=4
  • 15.
    Stop-And-Wait ARQ How manyframes can be counted by the Sequence Number? If M bits are used for the sequence number It can count 2M frames Where the count begins from zero and goes up to 2M - 1 If there are more then 2M frames, the counting is again repeated from 0 to 2m - 1 For example if 3 bits are used for the sequence number It can count 23 frames, i.e. 8 frames Where the count goes from 0 to 7 If there are 8th, 9th and 10th frames, they will be numbered 0, 1 and 2 The size of sequence number field should be chosen to minimize the size of frames
  • 16.
    Stop-And-Wait ARQ For thesake of Stop-and-Wait ARQ, there can only be at most two frames on the communication line Data Frame and Acknowledgement Frame So one bit is enough to count the frame and acknowledgement, i.e. using one bit possible values = 0, 1 The 4 frames will be counted like this: 0, 1, 0, 1 Now if sender sends a frame with Seq_No:= 0 The Receiver will send an Acknowledgement with Ack_No:=1
  • 17.
  • 18.
    Data Frame Sn =0 Event canSend Sequence Number True Sn = 0 RequestToSend Frame Sn = 0 Sn = 1 False Frame Ackn = 1 Arrival Notification True
  • 19.
    Data Frame Sn =0 Event canSend Sequence Number True Sn = 0 RequestToSend Frame Sn = 0 Sn = 1 False Arrival NotificationEvent TimeOut ( ) Frame Sn = 0
  • 20.
    SN = 0; canSend= True; While ( true ) {  WaitForEvent( );  If Event( RequestToSend( ) And canSend = True ) {  Get Data ( );  Make Frame ( SN );  Store Frame ( SN );  Send Frame ( SN );  Start Timer ( );  SN = ( SN + 1 ) % 2  canSend = False; }
  • 21.
    WaitForEvent ( ); IfEvent( Arrival Notification( ) ) { Receive Frame ( AckN );  If ( (Not Corrupted) And AckN = SN ) {  Stop Timer ( );  Purge Frame ( SN - 1 );  canSend = True; } }
  • 22.
    If Event( TimeOut( ) ) { Start Timer( ); Resend Frame( SN - 1 ); } }
  • 23.
  • 24.
    Event Sequence Number Frame Sn= 0 Rn = 0 Arrival Notification
  • 25.
    Event Sequence Number Frame Sn= 0 Rn = 0 Arrival Notification Rn = 1 Frame Ackn = 1 Data Frame Sn = 0
  • 26.
    RN = 0; While( true ) {  WaitForEvent( );  If Event( Arrival Notification ) {  Receive Frame ( );  If ( Frame is Corrupted )  Sleep ( );  If ( Sn = Rn ) {  Extract Data ( );  Deliver Data ( );  Rn = (Rn + 1) mod 2  }  Send Acknowledgement ( Rn ); } }
  • 27.
    Stop-And-Wait ARQ Drawback: Wastageof bandwidth. At a given time there can only be One Frame on the communication line Stop and Wait ARQ
  • 28.
    Go-Back-N ARQ In thisprotocol we can send multiple frames without receiving acknowledgement This protocol uses a logical concept called: SLIDING WINDOW  Collection of frames that can be transmitted without receiving acknowledgement  Unacknowledged frames which are transmitted i.e. the frames present in the window are called Outstanding frames This protocol also uses the concept of: CUMULATIVE ACKNOWLEDGEMENT  A single acknowledgement frame which acknowledges multiple frames A single timer can run for all the frames Or separate timers can run for every frame
  • 29.
    Go-Back-N ARQ A windowis divided into three parts Frames that have already been acknowledged, sender ignores these frames completely SENDER WINDOW Outstanding frames with unknown status, i.e. their acknowledgement has not yet arrived (actual window) Frames that cannot be transmitted. Every time ACK of outstanding frame arrives, the window slides to right 0 1 2 3 4 5 6 7 8 9 10 11 Receiver window contains only one frame
  • 30.
    Go-Back-N ARQ Procedure: Suppose thesender window size is 3 frames Sender transmits frame 0,1 and 2 without waiting for acknowledgement After transmitting frame 0, it immediately starts the timer Receiver sends an acknowledgement for every frame Every time acknowledgment arrives,  Sender window slides to the right, meaning one more frame enters the window and the Acknowledged Frame exits the window If the acknowledgment does not come, the sender goes back to the beginning of window and retransmits all frames Hence the name Go-Back-N ARQ
  • 31.
    0 1 23 4 5 Sender Window = 3 FRAMES F0 F1 F2 A1 A2 A3 TIMEOUT 0 F3 F4 F5 A4 A5 A6 TIMEOUT 1 2 3 4 5 SENDER RECEIVER SENDER RECEIVER
  • 32.
    Cumulative Acknowledgement F0 F1 F2 A1 A2 A3 TIMEOUT SENDER RECEIVER F3 A4 Acknowledgment4 arrives before timeout So in this case Ack-4 is the Accumulative Acknowledgement Ack-4 will be accepted as the acknowledgement for F3, F2 and F1
  • 33.
    F0 F1 F2 TIMEOUT SENDER RECEIVER F3 A1 Go-Back-N ARQF2 arrives at the receiver Where receiver is expecting F1 An out-of-order frame So receiver discards it And also the frame after it Ultimately timer times out Sender goes back to the beginning of window (i.e. F1) Retransmits all the frames Go-Back-N ARQ
  • 34.
    Size of Window: Howmany frames can be sent without receiving acknowledgement? Or in other words How many frames can be outstanding? We know that m bits can count 2m frames But Go-Back-N ARQ If m bits are used for sequence number field then: size of window <= 2m – 1
  • 35.
    Go-Back-N ARQ If mbits are used for sequence number field then: size of window <= 2m – 1 If We break this rule, receiver cannot detect duplicate frames, i.e. if keep the window size = 2m
  • 36.
    Go-Back-N ARQ Suppose mis 3 bits so it can count 2m = 23 = 8 frames Frames are numbered as 0,1,2,3,4,5,6,7 The size of window should be 2m – 1 = 23 – 1 = 7 Now instead of 7 we choose window size = 23 = 8 Entire window is transmitted i.e. frames from 0,1,….7  All Frames were received correctly but their acknowledgements were lost Next expected frame by the receiver is frame-0. Sender retransmits frame-0 but this is not the new frame, it’s the duplicate of first frame in window But sender mistakenly accepts this frame as the new frame instead of discarding it
  • 37.
    Go-Back-N ARQ Suppose mis 3 bits so it can count 2m = 23 = 8 frames Frames are numbered as 0,1,2,3,4,5,6,7 This time we choose size of window = 2m – 1 = 7 Entire window is transmitted i.e. frames from 0,1,….6 All Frames were received correctly but their acknowledgements were lost Next expected frame by the receiver is frame-7 Sender retransmits frame-0 Since receiver has already received frame-0 and is expecting frame-7 So receiver detects the duplicate frame and rightfully discards it
  • 38.
  • 39.
    Event Sender Window Size Seq_Noof First Outstanding Frame SW = 2 SF = 0 RequestToSend Seq_No of Next Frame to be transmitted SN = 0 DataFrame Sn = 0 Frame Sn = 0 SN = 1 Frame Sn = 1 Frame Sn = 1 SN = 2
  • 40.
     SW =2m – 1  SF = 0  SN = 0  While ( true ) {  WaitForEvent( );  If Event ( RequestToSend ) { If ( SN – SF >= SW ) Sleep ( ) Get Data ( ); Make Frame ( SN ); Store Frame ( SN ); Send Frame ( SN ); SN = SN + 1 If ( Timer Not Running ) Start Timer( )  }
  • 41.
    Frame Ackn =1 Sender Window Size Seq_No of First Outstanding Frame SW = 2 SF = 0 Seq_No of Next Frame to be transmitted SN = 0SN = 1SN = 2 Frame Sn = 0 Frame Sn = 1 Event Arrival Notification Frame Sn = 0 Frame Sn = 1 SF = 1
  • 42.
    If Event( ArrivalNotification( ) ) { Receive Frame ( AckN ); If ( Corrupted Acknowledgement ) Sleep ( ); If ( Ack No > SF and Ack No <= SN ) While ( SF < Ack No ) { Purge Frame(SF ) SF = SF + 1 } Stop Timer ( ) }
  • 43.
    Sender Window Size Seq_Noof First Outstanding Frame SW = 2 SF = 0 Seq_No of Next Frame to be transmitted SN = 0SN = 1SN = 2 Frame Sn = 0 Frame Sn = 1 Event Time Out Frame Sn = 0 Frame Sn = 1 Temp = 0Temp = 1Temp = 2
  • 44.
    If Event( TimeOut ) { Start Timer( ); Temp = SF While ( Temp < SN ) { Send Frame( Temp ) Temp = Temp + 1 } } }
  • 45.
  • 46.
    Event Sequence Number Frame Sn= 0 Rn = 0 Arrival Notification
  • 47.
    Event Sequence Number Frame Sn= 0 Rn = 0 Arrival Notification Rn = 1 Frame Ackn = 1 Data Frame Sn = 0
  • 48.
     RN =0;  While ( true ) {  WaitForEvent( );  If Event( Arrival Notification ) { Receive Frame ( ); If ( Frame is Corrupted ) Sleep ( ); If ( Sn = Rn ) { Extract Data ( ); Deliver Data ( ); Rn = Rn + 1 } Send Acknowledgement ( Rn ); }  }
  • 49.