Vous êtes sur la page 1sur 33

Computer Networks

Part 4 : Data Link Layer


Data Link : Introduction
• Data link layer improves the quality of physical layer
 error detection and error correction
• parity check
• longitudinal check
• cyclic redundancy check
 flow control
• Stop-and-Wait
• Sliding window
• Stop-and-Wait ARQ
• Go-back-N ARQ
• Selective-reject ARQ
Error Detection

• Bit errors
 probability 0 → 1 equals probability 1 → 0 (=P)
 transmission of frame of n bits :
• probability no errors : P1=(1-P)n
• probability of one or more undetected errors P2
• probability of one or more detected bit errors P3
 error detecting codes : minimize P2
• parity check
• longitudinal redundancy check
• cyclic redundancy check
Error detection : principles (1)

• Data set V of messages


• mapping f : V → W, W redundancy data
 d message to be sent , f(d)=r ;
 sender transmits <d,r>
 receiver gets <d’,r’>
 receiver computes f(d’)
• if f(d’) = r’ : receiver concludes that no error has
occurred
• if f(d’) ≠ r’ : receiver concludes that error(s) has
occurred
Error detection : principles (2)

• Requirements of function f
 elements of W should be representable in small
number of bits (=overhead)
 size of W large enough to detect errors
 probability that f(d)=r should be equal for almost
all r
 if P(d → d’)>p, then f(d) ≠ f(d’)
 f is efficiently computable (in hardware)
Algebraic background (1)

• Let B={0,1}, V=Bn, W= Bk,


• representation of message d in V :
n −1
d : a n −1 X n −1 + a n − 2 X n − 2 + ... + a1 X 1 + a 0 = ∑
i =0
ai X i

d : [a n −1 a n − 2 ...a1 a 0 ]
• Multiplication and addition
n n n

∑i =0
ai X i + ∑
i =0
bi X i = ∑
i =0
(a i + bi ) X i

n m n m

∑i =0
ai X i × ∑
i =0
bi X i = ∑∑
i =0 j =0
ai b j X i + j
Algebraic background (2)

• Adding zero’s to a message :


 [1 0 0 ] * [1 3 4 ] = [1 3 4 0 0 ]
• Division of polynomials
 similar to integer division
6X 4 + 2X 3 + 3X 2 + 3X + 1
2
2X + 1
quotient : 3 X 2 + X
rest : 2X + 1
Parity Check

• For each block of data (e.g. 7 bits) add a bit


such that number of 1’s is even
• Effectiveness
 Odd number of errors are detected
 Even number of errors not detected
Longitudinal Parity Check
• Errors occur in bursts : failure of parity check
• Longitudinal parity check : 2 dimensional check
• block of n x n bits : burst of n bits is detected

1 1 1 0 0 1 0 0 0
1 0 1 0 1 0 1 1 1
1 0 0 1 1 0 1 0 0
0 0 1 1 0 1 1 1 1
0 1 1 0 0 1 1 0 0
1 0 0 0 0 1 0 0 0
Cyclic Redundancy Check (CRC)
• CRC : polynomial representation
 Generator polynomial P (degree n) : n+1 bits
 M : k bit message to be transmitted
 F : n bit frame check sequence
 T : concatenation of M and F : T = < M , F >; hence T =
2n M + F
• CRC : Operation
 compute F such that T/P has rest 0
 Let 2n M = QP + R, then R is rest of 2n M / P
 Then 2n M + R is dividable by P, hence F = R
 F (= R) has at most n bits
CRC : Example

• M = 1010001101 (10 bits)


• P = 110101 (6 bits)
• Computing 2n M / P results in
 Q = 1101010110
 R = 001110
• Hence T = 1010001101001110
CRC Implementation
• Computation of R consists of two steps
 conditional invertion of bits : if first bit is 1, invert the bits
where a 1 occurs in P
 1 bit left shift
• Hardware implementation : example

Exclusive OR gate 1 bit register


CRC Effectiveness (1)
• Receiver get T+E (E : error polynomial)
• Errors are not detected when E/P has rest 0
• Effectiveness of CRC :
 single bit errors are detected
 two errors are detected provided P not divisible by Xk + 1
(k : frame length);
 example

X 15 + X 14 + 1 is not divisible by
X k + 1, k < 32768
CRC Effectiveness (2)

• If X+1 is a factor of P, then odd number of


errors are detected
• Burst errors
 P with degree n : burst errors are detected of
length l < n
 probability of not detecting burst errors of length
n+1 : 1/2n+1
 probability of not detecting burst errors of length
longer than n+1 : 1/2n
Flow Control
• Flow control
 stop and wait
 sliding window

Router
Router
Router
LAN
LAN
Router
Router
Flow control
Stop-and-Wait Flow Control

• Sender :
 transmit frame
• Receiver :
 accepts the frame
 processes the frame
 sends an acknowledgement to sender
• Sender :
 when acknowledgement is received, send second
frame
Efficiency of Stop-and-Wait (1)
• Model parameters
 TD: total time to send n frames

 TF: time to send a frame


 tprop: propagation delay
 tframe: time needed to transmit a frame
 tproc: time to process a frame
 tack: time needed to transmit an acknowledgement
TF = t prop + t frame + t proc + t prop + t ack + t proc
TF = 2t prop + t frame
Efficiency of Stop-and-Wait (2)

• Efficiency nt frame
E=
n( 2t prop + t frame )
t prop
a=
t frame
1
E=
1 + 2a
Efficiency of Stop-and-Wait (3)
• Let
 d: length of the link
 V: propagation speed ( 200000 km/s )
 L: frame length
 R: link data rate
• Then d L Rd Rd
t prop = , t frame = ⇒a= = /L
V R VL V
where Rd/V length of the link in bits
a = length of the link in frames
Efficiency : example
• Satellite link
 tprop: 270 ms, R=56kbit/s, L=4000 bits
 tframe: 71 ms, a=3.8 and hence E = 1/(1+7.6) = 0.12
• LAN
 0.1 km < d < 10 km, 0.1 Mbit/s < R < 10 Mbit/s
 L=500 bits, 0.001 < a < 1
 a=0.01 : E=0.98 ; a=0.1 : E=0.83
• Telephony
 R=9.6 Kbit/s, L=500 bits
 d=100m : a=9.6 10-6 and E=1; d=5000km : E=0.5
Sliding Window Protocol (1)
• Inefficiency of stop-and-wait when frames are
short
 long frames have higher probability of errors and
retransmission of long frame higher bandwidth
needs
E [ B ]ρ
 long frames imply longer delays ( )
2(1 − ρ )
 long frames need large buffer sizes
• When a>1, need for other protocol : sliding
window protocol
Sliding Window Protocol (2)

• Receiver has buffer capacity for n frames


• n : window size = number of frames sent
without acknowledgement
• acknowledgement contains the sequence
number of next frame that is expected
• sequence number (k bits)
 added by sender to each frame ( [ 0 2k-1]
 sequence number modulo 2k
Sliding Window
0

7 1

2
6

5 3

4
Sliding Window : Example

• Sliding window with parameters


 k=3 (range of sequence number)
 n=7 window size
• Shaded area
 shaded area : frames that may be sent
 when frame is sent : shaded area is decreased
 when acknowledgment arrives : shaded area is
increased
Sliding Window : Efficiency (1)

• Parameters
 N : window size
 a = Rd/VL
 frame transmission time = 1
• Sliding window operation
 station A starts transmission at t0
 first frame arrives at t0 + a
 complete frame arrives at t0 + a + 1; B issues ack
 ack arrives at t0 + 2a + 1
Sliding Window : Efficiency (2)
• Consider two cases :
 N > 2a + 1 : ack reaches station A before window
is used, hence no interruptions
 N < 2a + 1 : at time t0 + N, ack has not arrived
yet, and transmission is stopped till t0 + 2a + 1
• Efficiency E
E = 1 , N > 2a + 1
E = N / (2a + 1) , N < 2a + 1
Error Control
• Errors
 lost frame : frame does not arrive or is unrecognizable
 damaged frame : error detected in frame
• Automatic Repeat Request (ARQ)
 positive acknowledgment (ACK)
 timeout
 negative acknowledgment (NACK)
• ARQ protocols
 Stop-and-Wait ARQ
 Go-Back-N ARQ
 Selective reject ARQ
Stop-and-Wait ARQ

• Operation of Stop-and-Wait ARQ


 Frame error detected : sent NACK
 Frame is lost : sender uses timeout mechanism
 ACK damaged : sender retransmits frame
• Efficiency of Stop-and-Wait ARQ
t frame 1
E= =
N r ( t frame + 2t prop ) N r (1 + 2a )

1 1− P
Nr = ∑ iP
i =1
i −1
(1 − P ) =
1− P
⇒E=
1 + 2a
Go-Back-N ARQ : Operation

• Operation of Go-Back-N ARQ


 after each transmission a timer is set
 Frame i is lost and frame i+1 is sent : frame i+1
arrives out of order, NACKi is sent
 Frame i is lost and frame i+1 is not sent: timer will
timeout and frame i is retransmitted
 ACK(i+1) is lost: next ACK solves problem or
timer will time out
 NACKi is lost : timer will timeout on frame i
Go-Back-N ARQ : Efficiency (1)
• Expected number of transmission for one frame

Nr = ∑
i =1
f ( i ) P i −1 (1 − P )

f(i) : total number of frames transmitted when the


frame in error has to be retransmitted i times
• Computation of f(i) :
f ( i ) = 1 + ( i − 1) K = (1 − K ) + Ki
K = 2a + 1 for N > 2a + 1
K = N for N ≤ 2a + 1
Go-Back-N ARQ : Efficiency (2)

• Computation of Nr
∞ ∞
N r = (1 − K )∑ i =1
P i −1 (1 − P ) + K ∑
i =1
iP i −1 (1 − P )

K 1 − P + KP
=1− K + =
1− P 1− P
• Efficiency :
1− P
E= , when N > 2a + 1
1 + 2aP
N (1 − P )
= , when N ≤ 2a + 1
(1 + 2a )(1 − P + NP )
Selective Reject ARQ

• Operation of Selective Reject ARQ


 retransmission of frames that receive NACK or
timeout
 More efficient than Go-Back-N, but more complex
• Efficiency
E = 1 − P , when N > 2a + 1
N (1 − P )
= , when N ≤ 2a + 1
1 + 2a
Comparison ARQ Schemes
Efficiency N=127, Selective Repeat
1.0

N=7, Go-Back-N and N=127, Go-Back-N


Selective Repeat

0.5
Stop-and-wait

P=10-3

1.0 10 100 1000 a

Vous aimerez peut-être aussi