CN CDT14
CN CDT14
3
AN UNRESTRICTED SIMPLEX PROTOCOL
In this protocol: Data transmitted in one direction only
The transmitting (Tx) and receiving (Rx) hosts are always ready
Processing time can be ignored
Infinite buffer space is available
No errors occur; i.e. no damaged frames and no lost frames
(perfect channel)
4
A SIMPLEX STOP-AND-WAIT PROTOCOL
• Data are transmitted in one direction only
• No errors occur, and the sender can only process the received
information at a finite speed. (These assumptions imply that
the transmitter cannot send frames at a rate faster than the
receiver can process them.)
• The problem here is how to prevent the sender from flooding
the receiver.
• A general solution to this problem is to have the receiver
provide some sort of feedback(ACK) to the sender. The
process could be as follows: The receiver send an
acknowledge frame back to the sender telling the sender that
the last received frame has been processed and passed to the
host; permission to send the next frame is granted. The
sender, after having sent a frame, must wait for the
acknowledge frame from the receiver before sending another
5
frame.
STOP & WAIT PROTOCOL
The sender sends one frame and waits for feedback from the
receiver. When the ACK arrives, the sender sends the next
frame
6
A SIMPLEX PROTOCOL FOR A NOISY CHANNEL
In this protocol the Frames may be either damaged or lost completely.
We assume that transmission errors in the frame are detected.
One suggestion is that the sender would send a frame, the receiver would
send an ACK frame only if the frame is received correctly.
If the frame is in error the receiver simply ignores it; the transmitter
would time out and would retransmit it.
One problem here is that if the ACK frame is lost or damaged, duplicate
frames are accepted at the receiver without the receiver knowing it.
7
If the receiver has just sent an ACK frame back to the sender.
However, the ACK frame gets lost completely, the sender times
out and retransmits the frame.
There is no way for the receiver to tell whether this frame is a
retransmitted frame or a new frame, so the receiver accepts this
duplicate. The protocol thus fails in this aspect.
STOP-AND-WAIT, LOST FRAME STOP-AND-WAIT, LOST ACK FRAME
66
To overcome this problem it is required that the receiver be
able to separate a frame that it is seeing for the first time
from a retransmission.
One way to achieve this is to have the sender put a sequence
number in the header of each frame it sends.
The receiver then can check the sequence number of each
arriving frame to see if it is a new frame or a duplicate to be
discarded.
67
FLOW DIAGRAM OF A STOP & WAIT PROTOCOL
68
SLIDING WINDOW PROTOCOLS
13
DATA FRAME TRANSMISSION
Full-duplex - approach 1
Two separate communication channels(physical circuits)
Forward channel for data
Reverse channel for acknowledgement
and 1 only
SENDING & RECEIVING WINDOWS
At any instance of time
Sender maintains a set of sequence numbers of frames permitted to
send
These frames fall within sending window
Lower limit, upper limit, and size of two windows need not be the
same - Fixed or variable size
Senders Window contains frames can be sent or have been sent but
not yet acknowledged – outstanding frames
When a packet arrives from network layer
Next highest sequence number assigned
Upper edge of window advanced by 1
75
When an acknowledgement arrives
Lower edge of window advanced by 1
If the maximum window size is n, the sender needs n buffers to hold the
unacknowledged frames. If the window ever grows to its maximum
size, the sending data link layer must forcibly shut off the network layer
until another buffer becomes free.
The receiving data link layer's window corresponds to the frames it may
accept. Any frame falling outside the window is discarded without
comment. When a frame whose sequence number is equal to the lower
edge of the window is received, it is passed to the network layer, an
acknowledgement is generated, and the window is rotated by one.
Unlike the sender's window, the receiver's window always remains at its
initial size.
76
SENDER SLIDING WINDOW
• At the sending site, to hold
the outstanding frames until
they are acknowledged, we
use the concept of a
window.
frame 0 in part a.
CONTROL VARIABLES
• Sender has 3 variables: S, SF, and SL
• S holds the sequence number of recently sent frame
• SF holds the sequence number of the first frame
• SL holds the sequence number of the last frame
• Receiver only has the one variable, R, that holds the
sequence number of the frame it expects to receive. If the
seq. no. is the same as the value of R, the frame is
accepted, otherwise rejected.
79
80
A ONE BIT SLIDING WINDOW PROTOCOL
Initially, no frames are outstanding, so the lower and upper edges of the
sender’s window are equal, but as time goes on, the situation progresses as
shown. Unlike the sender’s window, the receiver’s window always remains at
its initial size, rotating as the next frame is accepted and delivered to the
network layer.
A sliding window of size 1, with a 3-bit sequence number.
(a) Initially.
81
(b) After the first frame has been sent.
(c) After the first frame has been received.
(d) After the first acknowledgement has been received.
A ONE BIT SLIDING WINDOW PROTOCOL
83
X
* Timeout
(0,0,B0) Exp=1
* (1,0,A1)
Exp=1 (0,1,A0)
*
(1,1,B1) Exp=0 *
(0,0,B0) Exp=1
* (0,1,A2)
Exp=0 *
Exp=1
*
(0,0,B2) Exp=1
*
ONE BIT SLIDING WINDOW PROTOCOL
84
Timeout Error Timeout (0,0,B0) *
Exp=1
X
(0,1,A0) (0,1,A0)
* duplicate,
(0,0,B0) Exp=1 (0,0,B0)
discarded
* *
Exp=1 Exp=1
ONE BIT SLIDING WINDOW PROTOCOL
85
Timeout * Exp=0 (0,1,A0) Exp=0
(0,0,B0) Exp=1
*
(0,1,A0) Exp=1
*
Exp=1 (1,0,A1) duplicate, ACK 0 Timeout
discarded
*
Exp=0 (1,1,A1)
(1,1,B1)
* *
Exp=0 (0,1,B0) Exp=0
*
Exp= 1
Performance of Stop-and-Wait Protocol
• In stop-and-wait, at any point in time, there is only one frame
that is sent and waiting to be acknowledged.
• This is not a good use of transmission medium.
• To improve efficiency, multiple frames should be in transition
while waiting for ACK.
Solution:
Allowing w frames sent before blocking
Problem: errors
Solutions
89
90
SELECT REPEAT PROTOCOL
Receiver stores correct frames following the bad one
Sender retransmits the bad one after noticing
95
SELECTIVE REPEAT ARQ, LOST FRAME
• Frames 0 and 1
are accepted when
received because
they are in the
range specified by
the receiver
window. Same for
frame 3.
• Receiver sends a
NAK2 to show
that frame 2 has
not been received
and then sender
resends only
frame 2 and it is
accepted as it is in
the range of the
window.
SELECTIVE REPEAT
DILEMMA
Example:
seq #’s: 0, 1, 2, 3
window size=3
receiver sees no
difference in two
scenarios!
incorrectly passes
duplicate data as new in
(a)
Q: what relationship
between seq # size and
window size?
97
SELECTIVE REPEAT ARQ, SENDER WINDOW SIZE
• Size of the sender and receiver windows must be at most one-half of 2 m.
• If m = 2, window size should be 2 m /2 = 2. Fig compares a window size of 2
with a window size of 3. Window size is 3 and all ACKs are lost, sender sends
duplicate of frame 0, window of the receiver expect to receive frame 0 (part of
the window), so accepts frame 0, as the 1st frame of the next cycle – an error.
SELECT REPEAT PROTOCOL - WINDOW SIZE
Problem is caused by new and old windows overlapped
Solution
99
Window size=(MAX_SEQ+1)/2
E.g., if 4-bit window is used, MAX_SEQ = 15
window size = (15+1)/2 = 8
Number of buffers needed
= window size
SELECT REPEAT PROTOCOL
00
(a) Initial situation with a window size seven.
(b) After seven frames sent and received, but not acknowledged.
(c) Initial situation with a window size of four.
(d) After four frames sent and received, but not acknowledged.
ACKNOWLEDGEMENT TIMER
Problem
If the reverse traffic is light, effect?
If there is no reverse traffic, effect?
Solution
Acknowledgement timer:
If no reverse traffic before timeout
send separate acknowledgement
Essential: ack timeout < data frame timeout Why?