1
Lecture #12: Data Link Lecture #12: Data Link Layer. Error Control.Layer. Error Control.
C o n t e n t s C o n t e n t s
Services Provided by DLLServices Provided by DLL
DLL data structuresDLL data structures
Error Control MechanismsError Control Mechanisms
– Error correctingError correcting
– Error detectingError detecting
8
2
6
10
13
2
DLL Services to the DLL Services to the Network LayerNetwork Layer
Organizing the data transfer from source machine Organizing the data transfer from source machine Network Layer to destination NL:Network Layer to destination NL:
controls two interfacescontrols two interfaces - to the Network Layer - to the Network Layer (“upper”) and to the Physical Layer (lower”)(“upper”) and to the Physical Layer (lower”)
data on DLL level is presented by a bit stream data on DLL level is presented by a bit stream in the Physical Layer interface and by a frame in the Physical Layer interface and by a frame in the Network Layer interfacein the Network Layer interface
type of the DLL service vary between:type of the DLL service vary between:– unacknowledged connectionless serviceunacknowledged connectionless service
– acknowledged connectionless serviceacknowledged connectionless service
– acknowledged connection-oriented serviceacknowledged connection-oriented service
3
Note that undelivered data might be required on some upper layer, but DLL has the smallest re-transfer overload because it repeats only the missed frames
Types of DLL ServicesTypes of DLL Services Unacknowledged connectionless serviceUnacknowledged connectionless service
– no feedback upon delivery of the frames in the remote no feedback upon delivery of the frames in the remote machinemachine
– no connection establishment before the exchangeno connection establishment before the exchange
– application: by low error rate channels; real-time application: by low error rate channels; real-time applications and wherever the system promptness applications and wherever the system promptness dominates over the correctnessdominates over the correctness
Acknowledged connectionless serviceAcknowledged connectionless service– frames which delivery is not acknowledged for certain frames which delivery is not acknowledged for certain
time-out can be retransmitted to the destinationtime-out can be retransmitted to the destination
– application: unreliable channels such as wireless data application: unreliable channels such as wireless data transfertransfer
Acknowledged connection-oriented serviceAcknowledged connection-oriented service– 3-phase transfer: connection establishment with initialization of 3-phase transfer: connection establishment with initialization of
parameters, allocation of local buffers etc.; frame[s] transmission and parameters, allocation of local buffers etc.; frame[s] transmission and connection release connection release
– guarantees not only the frame delivery, but also the order of deliveryguarantees not only the frame delivery, but also the order of delivery
3/2
4
DLL FramesDLL Frames Frame is the data structure to which DLL brakes the Frame is the data structure to which DLL brakes the
incoming bit stream provided by the physical layer.incoming bit stream provided by the physical layer. Frames’ framing methods: Frames’ framing methods:
– time gapstime gaps - inapplicable for any asynchronous transmission - inapplicable for any asynchronous transmission
– character countingcharacter counting - very hard error recovering because of - very hard error recovering because of
possible counter’s damagepossible counter’s damage
– framing characters with character stuffingframing characters with character stuffing - starting and - starting and
stopping ASCII character sequences at the frame’s stopping ASCII character sequences at the frame’s
boundaries:boundaries:• starting charactersstarting characters DLE STX DLE STX = = “Data Link Escape”“Data Link Escape” “Start “Start
of TeXt”of TeXt”• stopping charactersstopping characters DLE ETX DLE ETX = = “Data Link Escape”“Data Link Escape” “End of “End of
TeXt”TeXt”• stuffing sequence stuffing sequence DLEDLE for each incidental for each incidental DLEDLE sequence in sequence in
the payloadthe payload• ApplicationApplication: limited; suitable for ASCII oriented applications: limited; suitable for ASCII oriented applications
– framing flags with bit stuffingframing flags with bit stuffing ... ...
3/3
3/4
5
5
DLL FramesDLL Frames
– … … framing flags with bit stuffingframing flags with bit stuffing - starting - starting
and stopping bit sequences (“flags”) at the and stopping bit sequences (“flags”) at the
frame’s boundaries:frame’s boundaries:• start/stop bit pattern start/stop bit pattern 0111111001111110 - 1 byte (6 “ - 1 byte (6 “11”) ”)
• stuffing bit “stuffing bit “00” for each incidental sequence of 5 ” for each incidental sequence of 5
““11” in the payload” in the payload
• ApplicationApplication: universal: universal
– framing with redundant signal codesframing with redundant signal codes: :
possible when the physical layer can possible when the physical layer can
distinguish more than 2 conditions distinguish more than 2 conditions
(“(“11”/””/”00”) of the transferred signal; the ”) of the transferred signal; the
exceeded signal states are used for exceeded signal states are used for
flagging of the framesflagging of the frames
3/5
6
Error ControlError Control Two main mechanisms for error free transfer on DLL:Two main mechanisms for error free transfer on DLL:
– acknowledgementacknowledgement of each received frame of each received frame– indexing indexing of the sequence of outgoing framesof the sequence of outgoing frames
Acknowledged services require acknowledgement Acknowledged services require acknowledgement upon receiving of the frame. This mechanism upon receiving of the frame. This mechanism includes:includes:
– sending acknowledgment frame from the receiver to sending acknowledgment frame from the receiver to the sender for each successfully received framethe sender for each successfully received frame
– initiation of one autonomous timer process by the initiation of one autonomous timer process by the sender for each outgoing frame - the going off the sender for each outgoing frame - the going off the timer before the acknowledgement is interpreted by timer before the acknowledgement is interpreted by the sender as a transmission failurethe sender as a transmission failure
Connection-oriented servicesConnection-oriented services require indexing of the require indexing of the outgoing frame sequence helps to keep up the outgoing frame sequence helps to keep up the consistency of the transmitted data in cases as:consistency of the transmitted data in cases as:
– repeated frames due to unacknowledged transmissionrepeated frames due to unacknowledged transmission– disordered frames due to transmission problemsdisordered frames due to transmission problems
7
Flow ControlFlow Control
Flow controlFlow control synchronizes the rate at synchronizes the rate at
which frames are transmit between two which frames are transmit between two
heterogeneous computers in the case heterogeneous computers in the case
when faster sender transfers frame when faster sender transfers frame
sequence to a slower receiversequence to a slower receiver
Most developed control flow Most developed control flow
mechanisms are implemented in mechanisms are implemented in
connection-oriented DLL protocols.connection-oriented DLL protocols.
8
Error Codes - Main Error Codes - Main TermsTerms
Codeword (CW): Codeword (CW): nn bits, bits, mm bits data field (DF) + bits data field (DF) + rr bits error check (EC) redundancy bits error check (EC) redundancy
Hamming distanceHamming distance dd = ||CW = ||CW11CWCW22 || - || - the number of different bits in two CWs.the number of different bits in two CWs.
||{DF}|| = 2||{DF}|| = 2m m , however ||{EC}|| < 2, however ||{EC}|| < 2rr - - depending on the algorithm for check bits depending on the algorithm for check bits computation computation list of the valid CWs - list of the valid CWs - ““complete codecomplete code”. ”.
Hamming distance of complete codeHamming distance of complete code= = min(min(||CW||CWiiCWCWjj ||; ||; ii, , jj:: iijj))
dd-tiple error in a CW: -tiple error in a CW: dd bits of the original CW bits of the original CW are received invertedare received inverted
m r
n = m+r
CW ECDF
9
Error Correction and Error Error Correction and Error DetectionDetection
Error-correcting codesError-correcting codes: enough redundant information to : enough redundant information to reconstruct the original CW and its data field (DF) at the reconstruct the original CW and its data field (DF) at the receiver. receiver. ApplicationApplication: simplex data channels that have no : simplex data channels that have no possibility for retransmission request.possibility for retransmission request.
Error-detecting codesError-detecting codes: less redundant information that : less redundant information that can only detect presence of corrupted bit[s] but is not can only detect presence of corrupted bit[s] but is not enough to reconstruct the original CW. enough to reconstruct the original CW. ApplicationApplication: more : more efficient than error-correction coding in all cases when efficient than error-correction coding in all cases when feedback request is possible.feedback request is possible.
dd-tiple error detecting needs coding of -tiple error detecting needs coding of dd+1 Hamming +1 Hamming distance: thus after alterations of any distance: thus after alterations of any dd bits in a valid CW bits in a valid CW the obtained word is not a valid one (One more alteration the obtained word is not a valid one (One more alteration could turn it in a valid one)could turn it in a valid one)
dd-tiple error correction needs coding of 2-tiple error correction needs coding of 2dd+1 Hamming +1 Hamming distance: thus after alterations of any distance: thus after alterations of any dd bits in a valid CW bits in a valid CW the obtained word is still closer to the proper (original) CW the obtained word is still closer to the proper (original) CW in the list of legal words than any neighbor word of the list. in the list of legal words than any neighbor word of the list. Than the wrong CW can be replaced by the proper one.Than the wrong CW can be replaced by the proper one.
10
Error Correcting CodesError Correcting Codes For error-correcting code of For error-correcting code of distance 1distance 1::
– 22mm valid data fields valid data fields – nn illegal CWs at distance 1 of each valid illegal CWs at distance 1 of each valid
CWCW– nn+1 bit pattern needed to distinguish +1 bit pattern needed to distinguish
each valid CWseach valid CWs
– 22nn total bit patterns (all CWs) total bit patterns (all CWs) one one needs needs nn: 2: 2mm((nn+1) +1) 2 2nn ( (mm++rr+1) +1) 2 2rr 2 2r r ++rr+1+1 mm
– Examples: for Examples: for m m = 4 = 4 rrmin min = 3;= 3;
for for rr = 4 = 4 mmmax max = 11= 11
Parity checkParity check: CW consists of check bits : CW consists of check bits (c(cii) and data bits (d) and data bits (dii) - the rest, Even(/odd) ) - the rest, Even(/odd)
check sums modulo 2: check sums modulo 2: ssii=0(/1): =0(/1):
ccii=1, 2, 4,=1, 2, 4, 8, (...powers of 2) 8, (...powers of 2)
ddii=3, 5, 6,=3, 5, 6, 7, …7, …
ss11 = c = c11 dd3 3 dd5 5 dd7 7 dd9 9 ….….
ss22 = c = c22 dd3 3 dd6 6 dd7 7 dd10 10 ….….
ss33 = c = c44 dd5 5 dd6 6 dd7 7 dd12 12 ….….
7 6 5 4 3 2 1 value
0 0 0 0 0 0 0 00 0 0 0 1 1 1 10 0 1 1 0 0 1 20 0 1 1 1 1 0 30 1 0 1 0 1 0 40 1 0 1 1 0 1 50 1 1 0 0 1 1 60 1 1 0 1 0 0 71 0 0 1 0 1 1 81 0 0 1 1 0 0 91 0 1 0 0 1 0 A1 0 1 0 1 0 1 B1 1 0 0 0 0 1 C1 1 0 0 1 1 0 D1 1 1 1 0 0 0 E1 1 1 1 1 1 1 F
m r
n = m+r
CW
EC
DF
11
Check SumsCheck Sums
ddii cc11 cc22 cc44 cc88 cc1616
3=3= 11 22 44 88 1616
5=5= 11 22 44 88 1616
6=6= 11 22 44 88 1616
7=7= 11 22 44 88 1616
9=9= 11 22 44 88 1616
10=10= 11 22 44 88 1616
11=11= 11 22 44 88 1616
12=12= 11 22 44 88 1616
13=13= 11 22 44 88 1616s1:= c1 d3 d5 d7 d9 d11 d13...
12
Check SumsCheck Sums Application:Application:
– mostly: correction of mostly: correction of single isolated single isolated errorserrors
– correction of burst errors - only by correction of burst errors - only by matrix presentationmatrix presentation of CWs: of CWs: transmission of equi-significant bits transmission of equi-significant bits of CWs and parity check of the of CWs and parity check of the completed CWs completed CWs transformation of transformation of a transmission burst error into single a transmission burst error into single errors in sequence of CWserrors in sequence of CWs
13
Error Detecting CodesError Detecting Codes Single block parity bit detects single error with Single block parity bit detects single error with
unacceptably low probability (0.5)unacceptably low probability (0.5) nn column parity bits in the last row of a column parity bits in the last row of a nnkk
matrix block detect burst errors of length up tomatrix block detect burst errors of length up to n n. . The full probability for error detection of this The full probability for error detection of this coding is 2coding is 2--nn (the more parity bits the better (the more parity bits the better detection)detection)
Polynomial codePolynomial code ( (CRCCRC - cyclic redundancy - cyclic redundancy code) of length code) of length kk. Based on presentation of bit . Based on presentation of bit strings as polynomials with binary coefficients:strings as polynomials with binary coefficients:
the the kk-bit string -bit string
bbkk-1-1b b kk-2-2 …b …b11bb00 is presented by the polynomial is presented by the polynomial
bbkk-1-1xxkk-1 -1 + b+ bkk-2-2xxkk-2 -2 + ... + b+ ... + b11x x + b+ b00
14
Cyclic Redundancy Cyclic Redundancy CodeCode
Requisites:Requisites: mm-bit -bit message framemessage frame corresponding to polynomial corresponding to polynomial
MM((xx))
r+r+1-bit generator sequence with corresponding 1-bit generator sequence with corresponding
generator polynomialgenerator polynomial GG((xx): ): rr < < mm, b, brr=1 and b=1 and b00=1=1
Product:Product: transmitted frametransmitted frame of size ( of size (m+rm+r) bits ) bits
containing the message and an containing the message and an rr-bit checksum -bit checksum
field. Transmitted frame polynomial form is field. Transmitted frame polynomial form is TT((xx). ).
The check sum field that turns guarantees that The check sum field that turns guarantees that
TT((xx) is dividable by the generator polynomial ) is dividable by the generator polynomial
with a zero reminder (redundancy).with a zero reminder (redundancy).
15
Cyclic Redundancy Cyclic Redundancy CodeCode
CRC CRC coding procedure consists of modulo 2 coding procedure consists of modulo 2
arithmetic operations:arithmetic operations:
TT((xx) ) 2 2rr GG((xx) = ) = QQ((xx) ) [ [ RR((xx) ) GG((xx) ]) ]
and [for modulo 2 arithmetic and [for modulo 2 arithmetic and (-) operations and (-) operations are equivalent; (-) operator does not exist]:are equivalent; (-) operator does not exist]:
[ [ TT((xx))22rr ] ] [ [ RR((xx) ) GG((xx)] = )] = QQ((xx))
i.e. the expression i.e. the expression TT((xx) ) 2 2rr RR((xx) has to be ) has to be dividable by dividable by GG((xx) with ) with NONO reminder (in case of reminder (in case of correct transmission)correct transmission)
quotient
remindergenerator polynomial
16
The divisor is going into the dividend if the last has as many bits as the former.Here 1001110101=1though10011 < 10101
Cyclic Redundancy Cyclic Redundancy CodingCoding
11011 1111011 111110101 10011011 000010101 10011011 0000 1010110101 0110001100 0000000000 1100111001 1010110101 1100111001 1010110101 1100 01100 0 1010 11010 1 110 10110 10 101 01101 01 11 11011 110 10 10110 101 1 01101 0110 1 01011 0101 0 00110 0011
coding
G(x)
M(x)
Q(x)
R(x) {coding phase}
R(x) {decoding phase}
T(x)
decoding
1011 11111011 111110101 10011011 001110101 10011011 0011 1010110101 0110001100 0000000000 1100111001 1010110101 1100111001 1010110101 1100 01100 0 1010 11010 1 110 10110 10 101 01101 01 11 11111 111 10 10110 101 1 01011 0101 1 01011 0101 0 00000 0000
17
Cyclic Redundancy DecodingCyclic Redundancy DecodingError pattern Error pattern EE((xx):): xxii = 1 means that = 1 means that ii-bit has been erroneously -bit has been erroneously converted during transmissionconverted during transmission
Erroneously transmitted frame Erroneously transmitted frame TTee((xx) = ) = TT((xx) ) EE((xx))By CRC decoding By CRC decoding
TTee((xx))GG((xx) = [) = [TT((xx) ) EE((xx)])]GG((xx)= )= EE((xx) ) GG((xx))
i.e. the error detection depends of whether the error pattern is i.e. the error detection depends of whether the error pattern is dividable by the generator polynomial. Case study:dividable by the generator polynomial. Case study:
single errorssingle errors: : EE((xx)=)=xxii. Detectable by any . Detectable by any GG((xx) of more than 1 term;) of more than 1 term;double errorsdouble errors: : EE((xx)= )= xxii + + xxjj = = xxjj ( (xxi-ji-j +1). Detectable by any +1). Detectable by any GG((xx) ) that is not of type that is not of type xx((xxkk+1)+1) for for kk = 1, 2, …( = 1, 2, …(i-ji-j).).
odd number errorsodd number errors: detectable by any : detectable by any GG((xx): ): GG((xx) = () = (xx+1)+1)GG´́((xx) ) burst errors of lengthburst errors of length kk: : EE((xx)= )= xxii ( (xxk-k-11+…+1). Detectable by any +…+1). Detectable by any GG((xx): ): GG((xx) = ) = GG´́((xx)+1 and )+1 and kk-1< -1< rr. . Standard CRC polynomialsStandard CRC polynomials::
CRC12CRC12 = = xx1212++xx1111++xx33++xx22++xx+1 - 6-bit character code+1 - 6-bit character codeCRC16CRC16 = = xx1616++xx1515++xx22+1 - 8-bit character code+1 - 8-bit character codeCRC-CCITTCRC-CCITT = = xx1616++xx1212++xx55+1 - 8-bit character code+1 - 8-bit character code
19
3/33/3 FramingFraming
A character stream. A character stream. (a)(a) Without errors. Without errors. (b)(b) With one error. With one error.