Anda di halaman 1dari 18

Contents

ELL 785Computer Communication Networks

Overview of data link layer

Lecture 2 Framing
Data Link Layer
Error control

Flow control: ARQs

Examples of data link protocols

2-1 2-2

Overview of data Link Layer I Overview of data Link Layer II


Services provided to network layer
Functions of Data Link Layer
Unacknowledged connectionless service
Length count
low error rate: recovery is left to higher layer Flag-bytes with byte stuffing: character (or byte)-based
Framing Flag-sequence with bit stuffing: bit-oriented
real-time traffic, e.g., voice
Clock-based, Coding violation (Line coding)
Acknowledged connectionless service
Parity checks
Error Control
Unreliable channel, e.g., wireless Checksum
(detection)
Timer: after a frame is sent, the timer is set. If no ACK comes Cyclic redundancy codes

back within a specified interval, it may retransmit the frame. Stop & Wait
Error can be corrected directly & quickly Flow control
Go-back N
(ARQ)
Selective Repeat
Acknowledged connection-oriented service
Frames are delivered without loss/duplication/error in correct S-ALOHA
Link access
CSMA-CA, -CD
sequence (MAC sublayer)
Polling
Three phases: connex establishment, frame trans., connex release

2-3 2-4
Framing: Byte stuffing I Framing: Byte stuffing II

Q: How many bits are inserted as redundancies?


Flag bytes with byte stuffing
DLE + STX and DLE+ETX: 4 bytes (32 bits)
Transmitter:
Insert a DLE character before STX and ETX as a frame delimiter Kb : R. V. of the number of bytes in the data
SYN: Synchronous idle Assume: DLE appears randomly in the data w. p. p
Frame
STX: Start of text k  
SYN DLE STX Header+Packet DLE ETX CRC SYN ETX: End of text
XX k i
Pr[# of DLEs in the data] = i p (1 p)ki Pr[Kb = k]
DLE: Data link escape i
Data to be sent k i=0
| {z }
kp
DLE STX A ETX DLE STX B DLE DLE ETX
=pE[Kb ] (e.g., p = 1/28 )
DLE DLE
Total overhead:
Insert additionally DLE if DLE appears in the data
The receiver: E[OH] = 8pE[Kb ] + 32 (bits)
Strip off one DLE from each arriving pair of DLE
Interpret each unpaired DLE with STX (or ETX) as start or stop
What if an error occurs in DLE+ETX or DLE+DLE+ETX?

2-5 2-6

Framing: Bit stuffing I Framing: Bit stuffing II

Flag sequence with bit stuffing Q: How many 0 bits as overhead should be inserted? (j = 6)
Case 1: 0 is inserted if the first j 1 1s in the frame appear
Each frame ends with a flag sequence, 01111110 New frame
Bit stuffing: 0 is inserted after a sequence of five contiguous 1s.
Frame 0111110 11111
0
Data to be sent:
th
Case 2: For the i bit of 011111,
01111110 1111110111111111110111110 01111110
0 0 0 0 011111
bit stuffing
Case 3: long 1s after the case 2
Receiver checks for five consecutive 1s:
If next bit = 0, it is removed
011111 11111
If next two bits = 10, then flag is detected
If next two bits = 11, then frame has errors (abnormal termination)
Is this robust to channel errors? We can ignore this and a sequence of bits having longer 1s after
011111
2-7 2-8
Framing: Bit stuffing III Framing: Bit stuffing IV

(Approximate) Expected number of insertions for a frame of length


K j 1 (Case 3 is ignored):

E[# of 0s] = 1 2j+1 + (K (j 1))2j What is j of minimizing E[OH] given E[K ]?


j
= (K j + 3)2 f (j) is convex (unique minimum): d 2 f (j)/dj 2 > 0
If j is increased by 1, i.e., j + 1, there would be j such that
Adding j + 1 bits of the termination string, (except the last bit)
E[OH] E[K ]2j + j + 1 < E[K ]2(j +1)
+ (j + 1) + 1
E[OH] (E[K ] j + 3)2j + j + 1 j = blog2 E[K ]c = E[OH] log2 E[K ] + 2
j
f (j) = E[K ]2 + j + 1 (for E[K ]  j)

You can still add one last 0 bit of indicating the termination
If E[K ] = 1000 bits and j = 6, E[OH] 23.625 (bits)

2-9 2-10

Framing: Length field Maximum frame size I


Determine Kmax with V bits of overhead given a message length M
Byte count
Total number of bits after framing
L bits in the header to specify the number of bytes in the frame l M m
Overhead of length field: total bits = M + V
Kmax
2L = Kmax L = blog2 Kmax c + 1
Small Kmax produces lots of small frames and more overhead
Recall the overhead of bit-stuffing, i.e., not preferable in optical fiber
When small Kmax is favorable?
E[OH] log2 E[K ] + 2
What if the field is garbled with by a transmission error? S R D S R D

Packet
See also transmission
time Total delay for the
Clock-based framing (SONET: Synchronous Optical NETworking) Propagation Total packet two half packets over
delay over both links
Coding violation, e.g. Manchester (line) encoding: delay
queueing both links
low-to-high (1), high-to-low (0) high-to-high and/or delay +
Processing
low-to-low can be used for delimiter delay 0
Time Time
Shortening packet size: pipeline effect
2-11 2-12
Maximum frame size II Maximum frame size III
All links have the same link capacity C (bps)
The expected number of bit transmission times E[T C ] (bits):
Single packet transmission Small
The first
packet delay E[M ]V
up to
E[T C ] (Kmax + V )(j 1) + E[M ] + + 0.5V
links
Kmax
One message = g(Kmax )
delay over
the final link
M is uniformly distributed over Kmax :
Time Time E[dM /Kmax e] = E[M /Kmax ] + 0.5
S 1 2 D S 1 2 D
g(Kmax ) is convex: d 2 g(Kmax )/dKmax
2
>0
Via pipelining of using small Kmax , total time required to transmit
Kmax of minimizing g(Kmax ), i.e., dg(Kmax )/dKmax = 0
the message
 s
1 l M m 
T= (Kmax + V )(j 1) + M + V E[M ]V
C Kmax Kmax
j 1
no queueing delay, propagation delay, and processing delay are
included without an error on links
2-13 2-14

Maximum frame size IV Error control

Time-sensitive stream traffic of producing R (bps): e.g., R = 64 kbps


Delay from when the first bit enters the network until it leaves source encoder decoder sink

Packet (or frame) size K with additional overhead V


Ci : link i capacity greater then R
X
T = K /R + (K + V ) (1/Ci ) Random error vector model (1):
| {z } i
assembly delay | {z } Error vectors, (e1 , . . . , en ) occurs with prob. 1/2n .
link delay
This corresponds to light-loading Random bit error model (2):
Each bit can be an error with prob. p: Let w(e) be # of errors.
 w(e)
Stability condtion: (K + V )/Ci K /R (1 p)nw(e) pw(e) = (1 p)n 1pp

Link transmission should be faster than packet generation This tends to map a txed codeword into binary blocks around it.
T K : K can be reduced up to (K + V )/Ci = K /R for some link Combination of both models: the periods of error bursts (1), the
period of low error rate (2)

2-15 2-16
Linear Block Codes I Linear Block codes II
A codeword is generated by x = u G (G: generator matrix) Maximum likelihood (ML) decoding: try to maximize
Add r(= n k) redundant bits to correct and/or detect errors
Pr[y|u] Pr[u]
2k out of 2n possible n-bit words are codewords, e.g., Pr[u|y] = argu max Pr[y|u]
Pr[y]
message codeword
 i
000 000000 i bits in errors: Pr[y|u] = pi (1 p)ni = (1 p)n 1pp
001 101001
110|100
 
010 011010 p
Log-likelihood: log Pr[y|u] = n log(1 p) + i log 1p
G = 011|010 = [ |{z} P | I] 011 110011
100 110100 maximizing the log likelihood boils down to minimizing i
101|001 k(nk)
101 011101
| {z
systematic form
} Nearest neighbour decoding
110 101110
111 000111 Decode y as the nearest codeword x
This set of 2k code words is called a block code. Hamming distance between codeword x(i) and x(j) ,
Code rate: k/n
dist(x(i) , x(j) ) = # of bits in which they differ
A binary code is called linear: x1 C and x2 C x1 + x2 C
e.g. dist(001101, 111000) = 4.
Parity check matrix H = [I | PT ] satisfies G H T = 0:
See also Syndrome decoding, soft decision decoding, etc.
y H T = (u G + e) H T = e H T (called syndrome)
2-17 2-18

Linear Block codes III Linear Block codes IV


Singleton bound: For an (n, k) linear code

Minimum distance of a code: dmin = mini6=j dist(x(i) , x(j) ) dmin 1 n k dmin n k + 1
The dmin of a linear block code is equal to the minimum weight of
Proof: The rank of H is n k. Since dmin 1 columns of H are
its nonzero code words: why?
linearly independent, this number of columns cannot be greater than
Code with dmin can detect dmin 1 bit errors
the rank of H .
A good code is one whose dmin is large
A code with dmin = n k + 1 is called "maximum distance
Lemma: Let x be a nonzero codeword C with parity check matrix separable" code.
H . Then, dmin columns are linearly dependent, while dmin 1 Error correcting capability
columns are linearly independent.
Pn Code with dmin can correct t-bit errors
Proof: Recall that i=1 i vi = 0 with i 6= 0 for all i indicates the  dmin 1
, d odd
t= 2
distinct vector vi is linearly dependent. Since H xT = 0 and x has dmin
1, d even
2
dmin nonzero elements, dmin columns of H is linearly dependent.
Pc : probability of correcting errors (with a bit prob. error )
Pt
Pc = i=0 ni i (1 )ni


2-19 2-20
Linear block codes V Linear Block codes VI
Hamming bound Undetected error probability Pud
Hamming sphere of radius t contains all possible received vectors Prob. of an error pattern being equal to a nonzero codeword
that are at a Hamming distance less than t from a codeword. For binary symmetric channel, Pud is expressed as
The size of a Hamming sphere for an (n, k) binary linear block n
X
codes V (n, t) is Pud = Aj j (1 )nj , (Aj = 0 for j = 0, 1, . . . , d 1)
t   j=dmin
X n
V (n, t) = Ai : the number of codewords with hamming distance i,
j=0
j
called the weight distribution of the code
Every codeword, a total of 2k , in C with a Hamming sphere of In the previous example, A3 = 4, A4 = 3, n = 6, dmin = 3
radius t should not overlap with each other
Pud = 43 (1 )3 + 34 (1 )2 |=103 4 109
n k
2 2 V (n, t) n k log2 V (n, t)
Random error vector model: 2k 1 non-zero codeword error
This gives the least number of redundancy that must be added
patterns among 2n (approximation)
on a codeword in order to correct t errors.
An (n, k) binary linear block code is called a perfect code if Pud < (2k 1)/2n < 2(nk) (indepedent of Aj )
| {z }
Hamming bound is satisfied. =0.1094, for n=k=3

2-21 2-22

Linear Block Codes VII Linear Block Codes VIII


Better upperbound: Simple (underestimation) approximation: for   1
Assume that a generator matrix, G, is created randomly n
X
: there can be 2k(nk) G matrices Pud Aj j (1 )nj Admin dmin
: the ensemble of codes generated by these G matrices j=dmin

Cj : a code that is randomly chosen from


Another underestimation on Pud :
Aji : the number of code words in Cj with weight i
|| : the number of code words in Pr[dmin or more bits are in error & the received word is
one of the non-zero codewords]
|| n ||
n X n
2k 1
 
n j
X X X
Aji i (1 )ni Pr[Cj ] = 2k(nk) Aji i (1 )ni
X
Pud = =  (1 )nj 2.2 109 < Pud
j=1 i=1 i=1 j=1 j 2n
| {z } j=dmin
Pr[E|Cj ]
||   Frame retx. request (w/o error-correcting capability):
X n (k1)(nk)
(*) if we show Aji 2 Pd = 1 P0 (prob. of no errors) Pud
j=1
i
1
n   = 1 (1 )n Pud n Pud
(nk)
X n i
2  (1 )ni = 2(nk) (1 (1 )n )
i=1
i
2-23 2-24
Parity check codes I Parity check codes II

Vertical Redundancy Check (VRC)


Longitudinal Redundancy Check (LRC)
Generation:
A message is organized into a block of l bits wide and k bits high
Length of codeword: n = m + 1
Pm Input: 001001 101100 101101
xi = ui , for i = 1, 2, . . . , m, and xn = mod( i=1 ui , 2)
0 0 1 0 0 1
1 0 1 1 0 0
eg. u = 0011011 x = 00110110 Codeword sent
one row at a time
Random error vector channel model
1 0 1 1 0 1
There are 2n possible error vectors equally likely to occur
1 1 0 1 1 0
Probability of error detection failure = 0.5
Random bit error Detect all odd-number bit errors: 001001 101100 101101 110110

X n 
Pud = i (1 )ni Detect a single burst of errors of length l: # of columns
i Misses burst errors of length n + 1 if there are n 1 uninverted
i even,i6=0
bits between the first and last bit
n = 32 and  = 0.001: Pud = 0.496 103 1/2000
2-25 2-26

Parity check codes III Parity check codes IV

Checksum: used in IP, ICMP, TCP, UDP, (not IPv6)


Two-dimensional parity checks Similar to LRC
Data to be sent: 1 1 0 0 1 1 1 1 0 1 1 1 0 1 0 1 1 1 0 0 1 0 1 0 1 0 0 1
Divide data by each n-bit block
7 bits
1 0 Add them using 1-s complement arithmetic"
1 1 0 0 1 1 1 1
1 0 1 1 1 0 1 1
The sum is complemented to produce checksum: its negative
0 1 Suppose 1100 1010 is to sent with a checksum of 4 bits
0 1 1 1 0 0 1 0
Sender Receiver
0 1 0 1 0 0 1 1
1100 No errors 1100
0 1 0 1 0 1 0 1 1010 1010
Data with parity check bits: 0000 1000
If a carry is
11001111 10111011 01110010 01010011 01010101 10110 produced, it is 11110
1 added back 1
All 1-bit errors can be detected & corrected 0111 1111
All 2-, 3-bit errors can be detected, d = 3 Bit-wise complement
Checksum: 1000 0000
4- and more bit errors can be detected in some cases Detect all errors involving an odd number of bits and most errors
involving an even number of bits, cant detect misordered bytes
2-27 2-28
remainder term has degree 2 or less.
A polynomial code is specied by its generator polynomial g(x). Here we
Cyclic redundancy codes (CRC) I assume that we areCyclic
dealing with a code
redundancy in which
codes (CRC)codewords
II have n bits, of
which k are information bits and n k are check bits. We refer to this type of
Polynomial representation of m-, r-, n-bit word (or vector) Polynomial arithmetic
Data bits, um1 , um2 , . . ., u0 :
Addition: (x7 + x6 + 1) + (x6 + x5) = x7 + (1 + 1) x6 + x5 + 1 = x7 + x5 + 1
U (x) = um1 x m1 + um2 x m2 + . . . + u0 (degree m 1)
Multiplication: (x + 1)(x2 + x + 1) = x3 + x2 + x + x2 + x + 1 = x3 + 1
Generate a CRC of r bits long :

C (x) = cr1 x r1 + ur2 x r2 + . . . + c0 x3 + x2 + x = q(x) Quotient


Division:
The entire frame (of n = m + r bits) to be transmitted: x3 + x+ 1 x + x
6 5 Dividend

Divisor
x6 + x4 + x3
T (x) =x r U (x) + C (x) x5 + x4 + x3
=um1 x r+m1 + . . . + u0 x r + cr1 x r1 + ur2 x r2 + . . . + c0 3 x5 + x3 + x2
35 122 x4 + x2
Multiplying x r : appending r zeros from the least significant bit 105
x4 + x2 + x
17
Codeword or code polynomial can be interchangeably used x = r(x) Remainder

2-29 FIGURE 3.55 Polynomial arithmetic 2-30

Cyclic redundancy codes (CRC) III Cyclic redundancy codes (CRC) IV

CRC codeword generation: Other description: Cyclic code is a subclass of linear code
Generator polynomial, G(x) of degree r(= n m): Codewords of a cyclic code can be generated by an m n
G(x) = 1 x r + gr1 x r1 + + g1 x + 1 generator matrix

The CRC polynomial, C (x), is generated (REM: remainder) g0 g1 g2 gr 0 0 0 0
0 g
0 g1 g2 gr 0 0 0
x r U (x)
 
C (x) = REM x r U (x) = Q(x)G(x) + C (x) 0 0 g0 g1 g2 gr 0 0

G(x) G= .
. ..

Q(x) is the quotient . .
0 0 0 g0 g1 g2 gr
C (x) is a polynomial r 1 degree
All rows of G are linearly independent
Codeword T (x): Adding C (x) back to x r U (x):
Each row represents G(x), xG(x), x 2 G(x), . . ., x m1 G(x)
r
T (x) = x U (x) + C (x)
Every codeword can be expressed as a linear combination of rows
= Q(x)G(x) + C (x) + C (x) = G(x)Q(x)
G can be rewritten in systematic form
Thus, all codewords are divisible
| {z } by G(x), i.e., multiple of G(x)
remainder=0
G = [I | P]
2-31 2-32
Cyclic redundancy codes (CRC) V Cyclic redundancy codes (CRC) VI

Decoding: Some widely used G(x)


Received codeword polynomial: CRC-12 : x 12 + x 11 + x 3 + x 2 + x + 1
CRC-16 : x 16 + x 15 + x 2 + 1
Y (x) = T (x) + E(x)
CRC-CCITT : x 16 + x 12 + x 5 + 1
Divide Y (x) by G(x): CRC-32 (IEEE 802.3,4,5) :
Y (x) T (x) E(x)

Y (x)
 
E(x)
 x 32 +x 26 +x 23 +x 22 +x 16 +x 12 +x 11 +x 10 +x 8 +x 7 +x 5 +x 4 +x 2 +x+1
= + REM = REM
G(x) G(x) G(x) G(x) G(x) Implementation of CRC: Division circuit


The number of nonzero terms of E(x) is exactly the number of
erroneous bits in Y (x)
If remainder 6= 0, transmission error is detected:


G(x) cannot divide E(x) Input

If the remainder = 0, then either


No transmission error: E(x) = 0 G(x) = gr x r + . . . + g1 x + g0 , gr = 1
Undetected transmission error: E(x) 6= 0, i.e., a codeword A(x) = an1 x n1 + . . . + a1 x + a0 (= x r U (x) or Y (x))
2-33 The same circuit can be used at the receiver 2-34

Cyclic redundancy codes (CRC) VII Cyclic redundancy codes (CRC) VIII
164 CHAPTER 3 Digital Transmission Fundamentals
Error-detecting capabilities of CRC:
Encoder for g(x) = x3 + x + 1
Notation:
g0 = 1 g1 = 1 g3 = 1 G(x) | E(x) : G(x) divides E(x) (remainder=0)
i(x) + x3 + x2 |
G(x) /E(x) : G(x) does not divide E(x)
i(x) + Reg 0 + Reg 1 Reg 2
P1) All single bit errors, E(x) = x i
Clock Input Reg 0 Reg 1 Reg 2
x i : one bit error at the i th position
0 - 0 0 0
1 1 = i3 1 0 0 G(x) has two nonzero terms, x r and 1: G(x) /E(x)
|
2 1 = i2 1 1 0
3 0 = i1 0 1 1 P2) Double bit error separated by k bits, i.e., two isolated single bit
4 0 = i0 1 1 1
| k + 1)
errors, is detected if G(x) /(x
5 0 1 0 1
6 0 1 0 0 E(x) = x i + x j = x i (1 + x k ) = x i Ek (x) for k = j i
7 0 0 1 0
Check bits: r0 = 0 r1 = 1 r2 = 0 x i (1 + x k )

| i,
G(x) /x from P1)

r(x) = x G(x) | k + 1), then G(x) /E(x)
if G(x) /(x |

FIGURE 3.58 Shift-register circuit for generated polynomial 2-35 2-36

The same division circuit that was used by the encoder can be used by the
A bit of the Theory of Finite Fields Cyclic redundancy codes (CRC) IX

P3) Odd number bit errors are detected if G(x) has a factor (1 + x)
Definition 1: A polynomial p(x) over GF(2) (Galois Field) of degree
m is said to be irreducible over GF(2) if p(x) is not divisible by any G(x) = (1 + x)B(x), where B(x) is a polynomial
polynomial over GF(2) of degree less than m, but greater than zero If G(x) | E(x), then E(x) = G(x)Q(x) = (1 + x)B(x)Q(x)
e.g., p(x) = x 2 + x is not irreducible since divisible by x + 1 For undetected errors, E(x)|x=1 = (x + 1)B(x)Q(x)|x=1 = 0
However, odd number of bits in error, E(x)|x=1 = 1
Definition 2: An irreducible polynomial p(x) of degree m is said to
|
Contradiction: G(x) /E(x) errors can be detected
be primitive if the smallest positive integer n for which p(x) divides
x n + 1 is n = 2m 1 P4) Single burst errors of length r are detected
e.g., p(x) = x 6 + x + 1 divides x 63 + 1, but does not divide any Burst error of length k r:
x n + 1 for 1 n < 63
E(x) = x i+k1 + ei+k2 x i+k2 + . . . + ei+1 x i+1 + x i
If G(x) has a primitive polynomial of degree m as a factor, = x i (1 x k1 + . . . + e1 x + 1) = x i Be (x)
then double bit error separated by k bits for 1 k < 2m 1 can be
detected | i
From 1), we know G(x) /x
Since degree of G(x) = r > k 1, G(x) /B
| e (x) G(x) /E(x)
|

2-37 2-38

Cyclic redundancy codes (CRC) X Cyclic redundancy codes (CRC) XI

6) The probability that a burst error of length > r + 1 is undetected is


P5) The probability that a burst error of length = r + 1 is undetected is 2r (if all error patterns are equally likely)
2(r1) (if all error patterns are equally likely) Burst error of length k > r + 1 starting from the i th position:
Burst error of length r + 1: E(x) = x i (1 x k1 + . . . + 1)
| {z }
k terms
E(x) = x i (1 x r + er1 x r1 + . . . e1 x +1)
k2
: there are 2 equally likely patterns of burst error or length k
| {z }
r1 terms subject to change

| i
Recall G(x) /x If G(x) | E(x), then E(x) = G(x)Q(x),

G(x) | E(x) iff er1 = gr1 , . . . , e1 = g1 Q(x) = 1 x kr1 + qkr2 x kr2 + . . . + q1 x + 1


| {z }
There are 2r1 equally likely patterns of form (er1 , . . . , e1 ) kr terms

Pr[undetected burst errors of length r + 1] = 2(r1) : there are 2kr2 such patterns.
2kr2
Pr[undetected burst errors of length > r + 1] = = 2r
2k2
2-39 2-40
Stop-and-Wait ARQ I Stop-and-Wait ARQ II

Sender transmits a frame, wait for ACK from receiver How many SN is needed for both ends? 1-Bit SN Suffices
Time-out use a timer
Case 1: a frame is lost Time 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
Time-out Time
A FrameA Time-out time time
Frame Frame Time
Frame
A 0 Frame Frame Frame Frame
Frame 1 1 2
Frame
0 1Frame ACK Frame 1 2
B 0 ACK Cant wait indefinitely
1 ACK Timer
Cant 1
wait indefinitely 2 ACK
BACK Cant wait indefinitely ACK
B Transmitter Receiver
A B
Case 2: ACK is lost use a sequence number (SN) for frame
Time-out Time
Time-out Time
A FrameA Time-out Time
Frame Frame Frame
A 0
Frame
Frame
1 Frame 1 Frame
2 Frame State transition diagram of SNs
Frame
0 ACK 1Frame ACK Frame
0 ACK 1 2 Global State:
B 1 ACK 1 ACK 2 ACK Error-free frame 0
B ACK ACK
Cant know old and new frameACK
1 (0,0) (0,1)
B Cant know old and new frame 1 arrives at receiver
Cant know old and new frame 1
ACK for ACK for
Time-out earlier use an SN for ACKTime
Case 3: Timer expires Cant know which frame is ACKed
Time-out Time frame 1 frame 0
A Time-out Cant know which frame is ACKed
Frame A Cant know which frame is ACKed Time arrives at arrives at
A 0 Frame
Frame Frame Frame
Frame transmitter
0ACK
00
Frame
Frame 2 Frame
1 Frame transmitter
ACK
ACK 0 Frame 1
Frame 2
B ACK 0 1 ACK 2 Error-free frame 1
B ACK
B (1,0) arrives at receiver (1,1)

2-41 2-42

Stop-and-Wait ARQ III Stop-and-Wait ARQ IV

Delay of one frame transmission in SW ARQ


Transmitter A Receiver B
= total time to transmit 1 frame
A
Wait for ACK or timer to expire Check for errors of frame arrived
If timeout expires retransmit If no errors detected and sequence
B
frame and reset timer number is correct (Slast = Rnext ) time

If ACK received: Accept frame


R: bit rate of transmission channel
Update Rnext
If sequence number is incorrect nf and no : bits per frame and overhead of a frame
Send ACK frame with Rnext
or if errors detected nack : bits per ACK frame
Ignore ACK If no errors detected and wrong tf : frame transmission time, i.e., nf /R
If sequence number is correct sequence number, or if errors tack : ACK transmission time, i.e., nack /R
(Rnext = Slast + 1) detected : propagation delay
Accept frame, wait for more tproc : processing time of a frame or ACK
Discard frame
frames to transmit Send ACK frame with Rnext Total frame transmission time and time-out (tout )
tsw = tf + 2 + tack + 2tproc tout
2-43 2-44
Stop-and-Wait ARQ V Stop-and-Wait ARQ VI

Link utilization U Link utilization, U e with channel errors


tf normalize 1 Pf : the probability of receiving an erroneous frame
U = =
tsw 1 + tack /tf + 2( + tproc )/tf Errors can be detected perfectly with a powerful CRC
1
Total time to transmit a frame successfully
1 + 2( + tproc )R/nf
time
Bandwidth-delay product: 2 R (bits)


Transmission efficiency



nf no nf no tf nf no 1
= U = =
tsw
nf nf tsw tf =nf /R tsw R
X
e
1)tout )Pfk1

tsw =(1 Pf ) (tsw + (k =
1 Pf
| {z }
effective information k=1 tout =tsw
transmission rate
no e e
Usw = tf /tsw = (1 Pf )U
1
nf
= Transmission efficiency with channel errors
na 2( + tproc )R
1+ + e
nf nf sw = (1 Pf )

2-45 2-46

Stop-and-Wait ARQ VII Go-Back-N ARQ I

Effect of bandwidth-delay product on Improve Stop-and-Wait by pipelining


Continue to send frames up to Ws = N in a window
(sec)
30 kbps 1.5 Mbps 45Mbps 2.4Gbps Use m-bit for sequence number (SN) for outstanding Ws frames
0.005 0.95 0.35 1.77E-02 3.39E-04 Go-Back-4: 4 frames are outstanding; so go back 4
Senders
0.050 0.72 5.14E-02 1.80E-03 3.39E-05 3 0 1 2
window 2 3 1
0 Window is
0.500 0.21 5.39E-03 1.81E-04 3.39E-06 slides 1 2 3 0 exhausted!
0.005 0.99 0.97 0.53 2.14E-02 Frame # 0 1 2 3 0 1 2 3 0 1 2 3 0 1 Time
0.050 0.99 0.77 1.04E-01 2.18E-03 A 0

0.500 0.21 0.26 1.15E-02 2.18E-04

Optimal frame length with a bit error prob.  B


A A A Out of sequence A A A A A A
e e
nf of maximizing sw : dsw /dnf |nf =nf = 0 C
K
C
K
C
K
frames C
K
C
K
C
K
C
K
C
K
C
K
1 2 3 Ignore these frames 0 1 2 3 0 1
Pf = 1 (1 )nf nf  for   1
0 1 2 3 3 0 1 2 3 0 1
p
nf = ( + no )( + 1 ) Receivers window slides

= nack + 2( + tproc )R Receiver uses a window, whose size is always 1

2-47 2-48
Go-Back-N ARQ II Go-Back-N ARQ III: Window size
Example 1: Go-Back-4 is not good.
Comparison with Stop-and-Wait ARQ Go-Back-4: Ws =N= 22 good.
Example 1: Go-Back-4 is not

Transmitter
Transmitter goes
goes back
back 4 4 Sequence
Sequence
Stop-and-Wait ARQ Time-out expires:
Time frfr frfr frfr fr fr fr fr fr fr fr fr fr frnumber
number
0 0 1 A
A 00 11 22 33 00 1 1 2 2 3 3 TimeTime
A

AA AA AA A A
BB CC CC CC C C
B Receiver is looking for A KK KK KK K K Receiver hashas
Receiver , but cant
, but cant
11 22 33 0 0
C know
knowwhether
whetherthisthis
is for the the
is for old old
frame
frame
K 00 11 22 33 00 or or
a new frame
a new frame
1
Example 2:
Example 2: Go-Back-3
Go-Back-3 is
is good.
good.
7 frames are outstanding; Go-Back-3: Ws =N= 22 1 2m 1 suffices
Go-Back-N ARQ so go back 7 frfr frfr frfr fr fr fr fr fr fr Sequence number
Time Sequence number
0 1 2 3 4 5 6 A 0
A 0 11 22 00 11 2 2 Time
Time
A

A A A
B CA CA CA
B A A
B KC KC KC Receiver has , so it
Receiver is looking for Out-of-sequence A 1K 2K 3 K Receiver
rejects hasframe 0
the old , so it
C C C 1 2 3
frames 0 1 2 3 rejects the old frame 0
K K K
1 2 3 0 1 2 3
2-49 2-50

Go-Back-N ARQ IV Go-Back-N ARQ V


Transmitter: Slast = 0, Srecent = 0
1: if Srecent < Slast + Ws 1 then Receiver: Rnext = 0 and SNreceived
2: Send a packet with Srecent (Q:) 1: if no errors in a frame and SNreceived = Rnext then
3: Increment Srecent = mod (Srecent + 1, 2m ) 2: Accept packet
4: else 3: Increment Rnext = mod (SNreceived + 1, 2m )
5: Srecent = Slast 4: else
6: Send a packet with Srecent 5: Reject the frame (Q:)
7: end if 6: end if
8: if ACK is received without an error then
Q: Use Negative-ACK (NACK) with Rnext for frames error detected or
9: Slast = Rnext Cumulative ACK is possible
out of sequence
10: else
Implicitly acknowledge all the frames up to Rnext
11: Ignore the ACK
Instruct the sender to go back and retransmit Rnext and all
12: end if
subsequent packets immediate response
Q: What if frames are lost and Srecent < Slast + Ws 1 (no more frame Set a timer for NACK
is generated)?
Use timer for each frame
2-51 2-52
Go-Back-N ARQ VI Go-Back-N ARQ VII

Bidirectional GBN ARQ: Piggybacking ACK Timer setting of Bidirectional GBN ARQ
tout 2tf ,max + 2 + tproc
Transmitter Receiver
Receiver Transmitter

A Receive Window B Receive Window

1) ACK for the received frame can be piggybacked

A Send Window B Send Window


... ...
2) Timer expires: transmit ACK alone

Buffers Buffers Disadvantages of piggybacking ACK


Timer Timer
Long frame transmission at the receiver may trigger expiry of the
Timer Note: Out-of- Timer

Timer
...
sequence error-free
... transmitters timer
Timer
... frames discarded ... Sporadic traffic arrivals:
after examined
Timer Timer Set a timer for ACK transmission
2-53 2-54

Go-Back-N ARQ VIII Go-Back-N ARQ IX


Link utilization with channel errors: Ws t0
Link utilization with error-free channel
Depends on when the oldest frame is successfully transmitted or not
tf Ws < t0 : link utilization Ugbn = tf /t0
timer
0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3


timer
0 1 2 3 4 5 6 7 Time time
0 1 2 3 4 5 6 7 Time
ACK keeps
window sliding


ACK1
The first frame transmission failure causes retx. of Ws frames
ACK1

X
tf Ws t0 : Ugbn = 1 Time tgbn =(1 Pf ) Pfi (tf + i Ws tf )
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 1 2 3 4 5 6 7
i=0
 
Time Pf Ws
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 1 2 3 4 5 6 7 =tf 1+
1 Pf
Link utilization
tf 1 Pf
Ugbn = =
tgbn 1 + (Ws 1)Pf
2-55 2-56
Go-Back-N ARQ X Go-Back-N ARQ XI

Comparison with SW-ARQ

Optimal frame length with a bit error prob. 



1 Pf Pf 1 e 1 Pf
Ugbn = Usw
1 + (Ws 1)Pf Ws Ws 1+2( +tproc )R/nf Pf = 1 (1 )nf nf  for   1
Ws 1 + 2( + tproc )R/nf
Transmission efficiency:
gbn = ((nf no )/nf )Ugbn (1 )nf (nf no )
gbn =
nf + 2R( + tproc )(1 (1 )nf )
Comparison with SW-ARQ
nf of maximizing gbn : dgbn /dnf |nf =n = 0
nf = 10 Kbits, nack = no = 200 bits f

2( + tproc )R = 100 msec1 Mbps= 105 bits p


no + no2 4no / ln(1 )
Ws = 12 is chosen nf =
2
=0  = 106  = 105  = 104
As  increases, nf decreases
S&W 8.2 % 8.1 % 7.4 % 3.0 %
GBN 98 % 87.5 % 43.3 % 4.5 %

2-57 2-58

Selective Repeat ARQ I Selective Repeat ARQ II

Two new features compared to Go-Back-N Transmitter with window size Ws


unAcked yet
Allow individual frames to be retransmitted
0 1 2 3 6 7 0 1
The receiver window (or buffer) > 1 with suitable SN ACKed
ACKed
already
Out-of-order but error-free frames can be accepted (stored)
2
NAK causes retransmission of the oldest un-acked frame 1 3
timer timer reset delete timer
unACKed ACKed
Frame SN 0 1 2 3 4 5 6 2 7 8 9 10 11 12 Time
0 4
A

7 5
ACK up to 6
B 6
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 Window advances whenever an ACK with Rnext arrives
K
1 2 2 2 2 7 8 9 1 1 1
2 0 1 2 Whenever a NAK arrives, the specific Rnext in the NACK is resent
Out of sequence!
Stored in the receiver buffer If a timer expires, the corresponding frame is resent, and the timer
Resequencing delay
is reset
2-59 Receiver window has the same structure with Rnext and Wr 2-60
Selective Repeat ARQ III Selective Repeat ARQ IV

Receiver with window size Wr If SN = 4 and Ws = Wr = 2,


timer
Can advance window by one or more if SN= Rnext
Transmitter {0,1} {1} {} Frame 0 resent
Accept out-of-order frames only if their SNs satisfy window 0 1 0 Time
A

Rnext < SN < Rnext + Wr


B
A NACK with Rnext is sent whenever an out-of-sequence frame is Receiver ACK1
{0,1} {1,2}
ACK2
{2,3} Reject old frame 0
Window
observed
Ws = Wr = 2m1 : L)Ws = 5, Wr = 4, m = 3, R)Ws = Wr = 4
Window size if SN=4 and Ws = Wr = 2m 1 as in GBN timer
{1,2,3,4} {3,4} {1,2,3} {3}
timer Transmitter {0,1,2,3,4} {2,3,4} {4} {.} {0,1,2,3} {2,3} {.}
Transmitter window 0 1 2 3 4 0 0 1 2 3 0 Time
{0,1,2} {1,2} {2} {.} Frame 0 resent A


window
0 1 2 0 Time
A
ACK4

B B


Receiver ACK1 ACK2 ACK3 Receiver {0,1,2,3} {2,3,4,5} {4,5,6,7} {0,1,2,3} {2,3,4,5} {4,5,6,7}
Window {0,1,2} {1,2,3} {2,3,0} {3,0,1} Window Window slides Window doesnt slides
{1,2,3,4} {3,4,5,6} {5,6,7,0} {1,2,3,4} {3,4,5,6}
Accept old frame 0 as a new frame
Accept old frame 0 as a new one Reject old frame 0

2-61 2-62

Selective Repeat ARQ V Selective Repeat ARQ VI

Link utilization Transmission efficiency sr


Each tx. error asks retransmission of the specific frame sr = ((nf no )/nf )Usr
timer

Optimal frame length


0 1 2 3 0 1 2 3 0 4 5 6 0

p
time no + no2 4no / ln(1 )

ACK1 ACK1 nf = the same as GBN
2

Comparison of ARQs link utilization with Pf


Average time required to transmit a frame successfully 1

GBN: Ws = 10
X tf 0.8
tsr = tf (1 Pf ) kPfk1 = SR

Link utilization
1 Pf 0.6 GBN: Ws = 100
k=1
tf
Usr = tsr = 1 Pf 0.4

0.2
Comparison with GBN: SW: Ws = 10
SW: Ws = 100
0
Usr Ugbn if Pf 0 or Ws = 1 10-4 10-3 10-2 10-1 100
Pf
2-63 2-64
the asynchronous balanced mode (ABM) for data transfer for this conguration. Commands
In this mode information frames can be transmitted in full-duplex manner, that Primary
is, simultaneously in both directions. Responses
High-level Data Link Control (HDLC) Protocol I HDLC Protocol II
HDLC FRAME FORMAT
Secondary Secondary Secondary
We saw in the discussion of ARQ that the functionality of a protocol depends on
the control elds that are dened in the header. The format of the HDLC frame
Link configurations: Balanced operation
is dened so that it can accommodate the various data transfer modes. Figure Two stations called combined stations have equal capability
Unbalanced
5.35 showsoperation
the format of an HDLC frame. Each frame is delineated by two 8-bit
Balanced point-to-point link between combined stations
Link management is localized in a primary station Primary Commands Responses Secondary
Unbalanced point-to-point link
Secondary Responses Commands Primary
Commands
Primary Secondary

Data transferFIGURE
modes5.34 HDLC congurations
Responses

Unbalanced multipoint link Normal response mode (NRM)


Commands Multipoint connections using roll-call polling
Primary
Responses Unbalanced configuration, half-duplex
Secondary Secondary Secondary Asynchronous response mode (ARM): most rarely used
Multipoint connections using hub-polling (token-polling)
The primary station Unbalanced configuration
Balancedinitializes
point-to-point linkthe link,
between controls
combined stations the flow of data,
Asynchronous balanced mode (ABM): widely used
recovers from error and releases the link
Primary Commands Responses Secondary

Secondary Responses Commands Primary Point-to-Point connections


Direct communication between the secondary stations is NOT
FIGURE 5.34 HDLC congurations
Balanced configuration, full-duplex
allowed
2-65 2-66

HDLC Protocol III HDLC Protocol IV


5.4 Data Link Controls 307
Frame format Control field format
Bits 8 8 8 >0 16 8 Information frame
1 24 5 68
01111110 Address Control Data Checksum 01111110 0 N(S) P/F N(R)

Supervisory frame
Flag sequence (01111110): bit stuffing used for data transparency
1 0 S S P/F N(R)
Address: (8 or 8 n bits extended address)
NRM and ARM: the address of the secondary station Unnumbered frame
ABM: the address of the responding station 1 1 M M P/F M M M
Control: purpose & functions of frame (1 or 2 octets)
FIGURE 5.36 Control eld format
Data: length is variable but limited considering error detection N(S): Send Sequence Number, (modulus 8 or 128)
capability (present in I-frames & some U-frames) N(R): Receive Sequence Number
Frame check sequence (FCS) computed before bit stuffing secondary. The bit indicates a nal frame when being sent from a secondary to a
primary.
The information
Thus to poll aframes and supervisory
given secondary, a host sendsframes
a frameallow HDLC to
to the secondary,
: FCS is generated based on Control & Data part of a frame for indicated by the
implement address eld withGo-Back-N,
Stop-and-Wait, the P/F bit set to 1. The
and secondaryRepeat
Selective respondsARQ.
to
error detection. such a frame by transmitting the frames it has available for transmission. Only
P/F: Poll/final bit for interaction between primary and secondary
the last frame transmitted from the secondary has the P/F bit set to 1 to indicate
16 bits for error detection using CRC-CCITT or
that it is thesends
Primary nal frame.
a 1 to poll the secondary
32 bits for error detection using CRC-32 In balanced mode the P/F bit implements the checkpointing procedure that
was
Secondary
introducedsends a 1 to denote
in the discussion on ARQ the final frame of the response
protocols.
2-67 The N(S) eld in the I-frame provides the send sequence number of the I- 2-68
frame. The N(R) eld is used to piggyback acknowledgments and to indicate the
next frame that is expected at the given station. N(R) acknowledges the correct
receipt of all frames up to and including N(R) 1.
There are four types of supervisory frames, corresponding to the four pos-
HDLC Protocol V HDLC VI

S: Supervisory Function Bits Set asynchronous balanced mode (SABM)


receive-ready (RR:00): ACK if no I-frame is available on which to Set normal response mode (SNRM)
piggyback RN Set asynchronous balanced mode extended (SABME)
receive-not-ready (RNR:10): acknowledge all frames up to N(R)-1 ; set up a connection and initialize sequence and request number
and the station is temporarily unable to accept further frames Disconnect (DISC)
reject (REJ:01): an error has been detected, and the transmitter Unnumbered acknowledgement (UA): acknowledges frames
should go back and retransmit frames from N(R) during call setup and and call release
selective-reject (SREJ:11): Indicate to the transmitter that it frame reject (FRMR): report receipt of an unacceptable frame
should retransmit the frame indicated in the N(R) subfield (for Frame exchange for connex establishment and release
Selective Repeat ARQ)
timer
M: Unnumbered Function Bits time
Unnumbered frames carry no sequence numbers Node A
SABM
Used for initializing, disconnecting the link, and special control Data transfer
UA DISC UA
response Node B

2-69 2-70

HDLC Protocol VII: NRM and SR-ARQ HDLC Protocol VIII: ABM and GBN
Combined Station A Combined Station B
B, I, 0, 0 A, I, 0, 0
Address of secondary
Primary A Secondaries B, C B, I, 1, 0 A, I, 1, 1 B ACKs fr0
X
A polls B B, RR, 0, P N(S) N(R) A sends 5
RR=receive ready frames B, I, 2, 1 A, I, 2, 1
B, I, 0, 0
N(R) B sends 3 info
X B, I, 1, 0 B, I, 3, 2 B rejects
frames B, REJ, 1
B, I, 2, 0,F fr1

A rejects fr1 B, SREJ, 1 B, I, 4, 3


A, I, 3, 1
A polls C C, RR, 0, P A goes B, I, 1, 3
back to 1
C, RR, 0, F C nothing to
B, I, 2, 4 B, RR, 2 B ACKs fr1
send
A polls B, B, SREJ, 1,P B, I, 3, 4
requests B, RR, 3 B ACKs fr2
selective B, I, 1, 0 B resends fr1
retrans. fr1 B, I, 3, 0 Then fr 3 & 4 Time
B, I, 4, 0, F If the frame is a command: address field = the receiver address
A send info fr0 B, I, 0, 5
to B, ACKs up to 4
If the frame is a response: address field = the sender address
Time I-frame: command
RR, RNR: either command or response
2-71 2-72
REJ, SREJ: response

Anda mungkin juga menyukai