Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 27

Peer-to-Peer Protocols

and Data Link Layer

1
 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
 Flow control, TCP reliable stream, and timing recovery
 Data Link Layer
 Framing
 PPP & HDLC protocols
 Statistical multiplexing for link sharing

2
Error control in Data Link Layer
Packets Packets
(a)
 Data Link operates
Data link Data link
over wire-like,
layer Frames layer directly-connected
A B systems
Physical Physical
layer layer  Frames can be
corrupted or lost, but
arrive in order
(b)
1 1  Data link performs
2 2
12 3 12 3
error-checking &
21 21
Medium retransmission
2  Ensures error-free
A B 1
packet transfer
1 Physical layer entity between two systems
2 Data link layer entity
There is one network layer entity per node
3

3 Network layer entity but one link layer entity per link.
Error Control in Transport Layer
 Transport layer protocol (e.g. TCP) sends segments across
network and performs end-to-end error checking &
retransmission
 Underlying network is assumed to be unreliable

Messages Messages

Transport Segments Transport


layer layer
Network Network Network Network
layer layer layer layer
Data link Data link Data link Data link
layer layer layer layer
End system End system
A Physical Physical Physical Physical
layer layer
B
layer layer

4
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
2 2
1 1

End System
α 1 1 End System
1 2
2 2 β
4 3 21 12 3 2 1 1 2 3 2 1 1 2 3 4
Medium
2
A B 1
Network

3 Network layer entity


5

4 Transport layer entity


End-to-End Approach Preferred
Hop-by-hop
Preferred when
E2E error rate is
high
Data Data Data Data
1 2 3 4 5 Faster recovery
ACK/ ACK/ ACK/ ACK/
NAK NAK NAK NAK

End-to-end Preferred when


ACK/NAK
E2E error rate
is low
More scalable
1 2 3 4 5 if complexity at
Data Data Data Data the edge6
ARQ Protocols and Reliable
Data Transfer

7
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
8
Stop-and-Wait ARQ- 1-Bit Sequence
Transmit a frame, wait for ACK
Error-free
Packet
packet
Information frame
Transmitter Receiver F0-0
Timer set after (Process A) (Process B)
F1-1
each frame
transmission Control frame
F2-0

Header
CRC
Information Header
packet CRC
9

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

(b) ACK lost Time-out


Time
A Frame Frame Frame Frame
0 1 1 2
ACK 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

10
Sequence Numbers
(c) Premature Time-out

Time-out
Time
A Frame
0 Frame Frame Frame
ACK 0 1 2
ACK
B

 The transmitting station A misinterprets duplicate ACKs


 Incorrectly assumes second ACK acknowledges Frame 1
 Question: How is the sender to know second ACK is for frame 0?
 Answer: Add frame sequence number in ACK header
 Rnext is sequence number of next frame expected by the receiver
 Implicitly acknowledges receipt of all prior frames
11
12
13
14
1-Bit Sequence Numbering
Suffices
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1

Slast Rnext
Timer

Transmitter Slast Receiver


A B
Rnext

Global State: Error-free frame 0


(Slast, Rnext) (0,0) (0,1)
arrives at receiver
ACK for
Initially system ACK for frame 0
is in state frame 1 arrives at
(0,0) arrives at transmitter
transmitter Error-free frame 1
arrives at receiver
(1,0) (1,1) 15
Stop-and-Wait ARQ
Transmitter Receiver
Ready state Always in Ready State
 Await request from higher layer for  Wait for arrival of new frame
packet transfer  When frame arrives, check for errors
 When request arrives, transmit  If no errors detected and sequence
frame with updated Slast and CRC number is correct (Slast=Rnext), then
 Go to Wait State  accept frame,
Wait state  update Rnext,
 Wait for ACK or timer to expire;  send ACK frame with Rnext,
block requests from higher layer  deliver packet to higher layer
 If timeout occurs  If no errors detected and wrong
 retransmit frame and reset timer sequence number
 If ACK received:
 discard frame
 If sequence number is incorrect or if
 send ACK frame with Rnext
errors detected: ignore ACK  If errors detected
 If sequence number is correct (Rnext =  discard frame
Slast +1): go to Ready state

16
Applications of Stop-and-Wait
ARQ
 IBM Binary Synchronous Communications
protocol (Bisync): character-oriented data link
control
 Xmodem: modem file transfer protocol
 Trivial File Transfer Protocol (RFC 1350):
simple protocol for file transfer over UDP

17
Performance Issues
 Stop and Wait ARQ works well on channels that
have low propagation delay.
 Becomes inefficient when the propagation delay is
much greater than the time to transmit a frame.
 Suppose we are transmitting 1000 bits long over a
channel that has a speed of 1.5Mbps and the time
that elapses from the beginning of the frame
transmission to the receipt of its acknowledgement
is 40ms.
 No. of bits that can be transmitted over the channel in
40ms*1.5Mbps = 60,000bits(Delay Bandwidth Product)
 But Stop and wait protocol can transmit only 1000 bits in
this period of time,
 Efficiency = 1000/60,000 = 1.6%
Stop-and-Wait Efficiency
Last frame bit ACK
First frame bit enters channel arrives
enters channel Channel idle while transmitter
waits for ACK

A t

B t

First frame bit Receiver


arrives at Last frame bit processes frame
receiver arrives at and
receiver prepares ACK

19
Stop-and-Wait Model
t0 = total time to transmit 1 frame
A
tproc

B
frame
tprop tproc tack tprop
tf time

t0  2t prop  2t proc  t f  t ack bits/Information frame


nf na bits/ACK frame
 2t prop  2t proc  
R R
-n is the no. of bits in info.frame.
f

- na is the no. of bits in ack.frame. channel transmission rate


20
S&W Efficiency on Error-free
channel
Effective transmission rate: bits for header & CRC

number of information bits delivered to destination n f  no


R 0
eff   ,
total time required to deliver the information bits t0

Transmission efficiency:
Effect of
n f  no no
1 frame overhead
Reff t0 nf
0    .
R R na 2(t prop  t proc ) R
1 
nf nf

Delay Bw
Effect of Product 21
ACK frame
Example: Impact of Delay-
Bandwidth Product-DBP
nf=1250 bytes = 10000 bits, na=no=25 bytes = 200 bits
Information 1 ms 10 ms 100 ms 1 sec
Rate (R)
200 km 2000 km 20000 km 200000 km
1 Mbps DBP- 104 105 106
103 49% 9% 1%
 0  88%
1 Gbps 106 107 108 109
1% 0.1% 0.01% 0.001%
Stop-and-Wait does not work well for very high speeds or long propagation
delays
22
S&W Efficiency in Channel with
Errors
 Pf be the probability that a frame has errors and need to
retransmitted.
 Let 1 – Pf = probability frame arrives w/o errors
 Avg. # of transmissions to first correct arrival is then 1/ (1–Pf )
 Avg. total time per frame is then tsw=t0/(1 – Pf)

n f  no
t0 no
1
Reff 1  Pf nf
 SW    (1  Pf )
R R na 2(t prop  t proc ) R
1 
nf nf

Effect of
frame loss 23
Example: Impact Bit Error Rate
nf=1250 bytes = 10000 bits, na=no=25 bytes = 200 bits
Find efficiency for random bit errors with p=0, 10-6, 10-5, 10-4
nf
1  Pf  (1  p ) for large n f and small p

1 – Pf 0 10-6 10-5 10-4


Efficiency
1 Mbps 1 0.99 0.905 0.368
& 1 ms 88% 86.6% 79.2% 32.2%

Bit errors impact performance as nfp approaches 1


24
Sliding Window
 Window size- Frames and bit sequence(2k)
 Sender side
 Window expands after receiving acknowledgement for
the outstanding frames.

 Receiver side
 Window expands after sending acknowledgement for
the received frames.

25
Example Sliding Window
Sliding Window Example

You might also like