Professional Documents
Culture Documents
Peer-to-Peer Protocols
Peer-to-Peer Protocols and Service Models
ARQ Protocols and Reliable Data Transfer
Overview
Peer-to-Peer protocols: many protocols involve the
interaction between two peers
Service Models are discussed & examples given
Detailed discussion of ARQ provides example of
development of peer-to-peer protocols
Data Link Layer
HDLC protocols
Peer-to-Peer Protocols and
Service Models
Peer-to-Peer Protocols
Peer-to-Peer processes
execute layer-n protocol
to provide service to
n + 1 peer process n + 1 peer process layer-(n+1)
Messages Messages
Network
Segments can experience long delays, can be lost, or
arrive out-of-order because packets can follow different
paths across network
End-to-end error control protocol more difficult
C
1 2 3 2 1
End System
α End System
β
4 3 21 12 3 2 1 1 2 3 2 1 1 2 3 4
Medium
2
A B 1
Network
Simple
End-to-end
ACK/NAK
inside the
network
More scalable
1 2 3 4 5 if complexity at
Data Data Data Data the edge
ARQ Protocols and Reliable
Data Transfer
Automatic Repeat Request (ARQ)
Purpose: to ensure a sequence of information
packets is delivered in order and without errors or
duplications despite transmission errors & losses
We will look at:
Stop-and-Wait ARQ
Go-Back N ARQ
Selective Repeat ARQ
Basic elements of ARQ:
Error-detecting code with high error coverage
ACKs (positive acknowledgments
NAKs (negative acknowlegments)
Timeout mechanism
Stop-and-Wait ARQ
Transmit a frame, wait for ACK
Error-free
Packet
packet
Information frame
Transmitter Receiver
Timer set after (Process A) (Process B)
each frame
transmission Control frame
Header
CRC
Information Header
packet CRC
Information frame Control frame: ACKs
Need for Sequence Numbers
(a) Frame 1 lost Time-out
Time
A Frame Frame Frame Frame
0 1 1 2
ACK ACK
B
In cases (a) & (b) the transmitting station A acts the same way
But in case (b) the receiving station B accepts frame 1 twice
Question: How is the receiver to know the second frame is also frame 1?
Answer: Add frame sequence number in header
Slast is sequence number of most recent transmitted frame
Sequence Numbers
(c) Premature Time-out
Time-out
Time
A Frame
0 Frame Frame Frame
ACK 0 1 2
ACK
B
Slast Rnext
Timer
A t
B t
B
frame
tprop tproc tack tprop
tf time
fr fr fr fr fr fr fr fr fr fr fr fr fr fr Time
0 1 2 3 4 5 6 3 4 5 6 7 8 9
A
B
A A A out of sequence A A A A A A
C C C frames C C C C C C
K K K K K K K K K
1 2 3 4 5 6 7 8 9
Rnext 0 1 2 3 3 4 5 6 7 8 9
B
Receiver is A
looking for C
K
Rnext=0
1
B A A A A A A
Receiver is Out-of- C C C C C C
looking for sequence K K K K K K
Rnext=0 frames 1 2 3 4 5 6
Go-Back-N with Timeout
Problem with Go-Back-N as presented:
If frame is lost and source does not have frame to
send, then window will not be exhausted and
recovery will not commence
Use a timeout with each frame
When timeout expires, resend all outstanding
frames
Go-Back-N Transmitter & Receiver
Transmitter Receiver
Send Window
... Receive Window
Frames
transmitted S
last Srecent Slast+W s-1
and ACKed
Frames
Buffers Rnext
received
oldest un-
Timer Slast
ACKed frame
Timer Slast+1 Receiver will only accept
... a frame that is error-free and
that has sequence number Rnext
Timer
Srecent most recent
transmission
When such frame arrives Rnext is
... incremented by one, so the
Slast+Ws-1 max Seq # receive window slides forward by
allowed one
Sliding Window Operation
Transmitter
Frames
transmitted S 0
and ACKed
last Srecent Slast+W s-1 2m – 1 1
2
Transmitter waits for error-free
ACK frame with sequence
number Slast Slast
send
When such ACK frame arrives,
Slast is incremented by one, and
window i
the send window slides forward i + Ws – 1 i+1
by one
Maximum Allowable Window Size is W s = 2m-1
M = 22 = 4, Go-Back - 4: Transmitter goes back 4
fr fr fr fr fr fr fr fr Time
A 0 1 2 3 0 1 2 3
A A A A
B C C C C Receiver has Rnext= 0, but it does not
K K K K know whether its ACK for frame 0 was
1 2 3 4
received, so it does not know whether
Rnext 0 1 2 3 4 this is the old frame 0 or a new frame 0
A A A
B C C C
K K K Receiver has Rnext= 3 , so it
1 2 3
rejects the old frame 0
Rnext 0 1 2 3
ACK Piggybacking in Bidirectional GBN
SArecent RA next
Transmitter Receiver
Receiver Transmitter
SBrecent RB next
RA next RB next
“A” Send Window “B” Send Window
... ...
Tprop Tf Tf Tprop
1 ms 1000 bits 1
10 ms 10,000 bits 2
Ws t f Ws t f
tGBN t f (1 Pf ) Pf {t f } t f Pf and
1 Pf 1 Pf
n f no no
1
tGBN nf
GBN (1 Pf )
R 1 (Ws 1) Pf
fr fr fr fr fr fr fr fr fr fr fr fr fr fr Time
0 1 2 3 4 5 6 2 7 8 9 10 11 12
A
B
A A N A A A A A A A A A
C C A C C C C C C C C C
K K K K K K K K K K K K
1 2 2 2 2 2 7 8 9 1 1 1
0 1 2
Selective Repeat ARQ
Transmitter Receiver
Frames Frames
transmitted S received Rnext Rnext + W r-1
last Srecent Slast+ W s-1
and ACKed
Buffers Buffers
Timer Slast Rnext+ 1
Timer Slast+ 1 Rnext+ 2
...
Timer
Srecent ...
Rnext+ W r- 1 max Seq #
... accepted
Slast+ W s - 1
Send & Receive Windows
Transmitter Receiver
0 0
2m-1 1 2m-1 1
2 2
Rnext
Slast
send receive j
window i window
i
i + Ws – 1 i+1
j + Wr – 1
Moves k forward when ACK Moves forward by 1 or more
arrives with Rnext = Slast + k when frame arrives with
k = 1, …, W s-1 Seq. # = Rnext
Selective Repeat ARQ
Transmitter Blocking state
Ready state When the send window is empty Srecent =
Slast +W s -1
Await request from higher layer for And the transmitter refuses to accept requests
packet transfer from the higher layers.
When request arrives, transmit frame If error free ACK frame is received with
with updated Srecent set to the lowest Rnext in the range between Slast and Srecent
number available in the send window , then the send window slides forward by
and CRC Slast = Rnext then the maximum send
If Srecent = Slast +W s -1 Go to Blocking window number to Slast +W s -1 and then
State else remains in the ready state. transmitter changing to the ready state
If error free ACK frame is received If error free NAK frame is received with
with Rnext in the range between Slast Rnext in the range between Slast and Srecent
and Srecent , then the send window , then the frame with Sequence number
slides forward by Slast = Rnext or is retransmitted and then the send
outside the range between Slast and window slides forward by Slast = Rnext
Srecent , the frame will be discarded then the maximum send window number
If error free NAK frame is received to Slast +W s -1 and the transmitter
with Rnext in the range between Slast changes to the ready state.
and Srecent , then the frame with If error free ACK frame is received with
Sequence number is retransmitted Rnext outside the range between Slast and
and then the send window slides Srecent , the frame will be discarded and
forward by Slast = Rnext no further action will takes place.
The maximum window number is Slast
+W s -1
Selective Repeat ARQ
Receiver
Always in Ready State
Wait for arrival of new frame
When frame arrives, check for errors
If no errors detected and sequence number is in the range
Rnext to Rnext+W R-1, then the frame is accepted and buffered
and an acknowledgement frame is transmitted.
The received number is Rnext and if Rnext +1 upto Rnext + k -1
have already been received, then the receive sequence
number is incremented to Rnext + k, the receive window slides
forward and the corresponding packets are delivered.
If no errors detected and outside the range
discard frame
send ACK frame with Rnext
If errors detected
discard frame
What size Ws and Wr allowed?
Example: M=22=4, Ws=3, Wr=3
Frame 0 resent
Send
{0,1,2} {1,2} {2} {.}
Window
fr0 fr1 fr2 fr0
A Time
B ACK1 ACK2
Receive
{0,1} {1,2} {2,3}
Window
Old frame 0 rejected because it
falls outside the receive window
Why Ws + Wr = 2m works
Transmitter sends frames 0 Receiver window starts at {0, …, W r}
to Ws-1; send window empty
Window slides forward to
All arrive at receiver {W s,…,W s+W r-1}
All ACKs lost
Receiver rejects frame 0 because it
Transmitter resends frame 0 is outside receive window
0 0
2m-1 1 2m-1 1
Slast Ws +Wr-1 2
2
receive Rnext Ws
send window
window Ws-1
Applications of Selective Repeat
ARQ
TCP (Transmission Control Protocol):
transport layer protocol uses variation of
selective repeat to provide reliable stream
service
Service Specific Connection Oriented
Protocol: error control for signaling
messages in ATM networks
Efficiency of Selective Repeat
Assume Pf frame loss probability, then number of
transmissions required to deliver a frame is:
tf / (1-Pf)
n f no
t f /(1 Pf ) no
SR (1 )(1 Pf )
R nf
Example: Impact Bit Error Rate on
Selective Repeat
nf=1250 bytes = 10000 bits, na=no=25 bytes = 200 bits
Compare S&W, GBN & SR efficiency for random bit errors
with p=0, 10-6, 10-5, 10-4 and R= 1 Mbps & 100 ms