Ch 3 Datalink

download Ch 3 Datalink

of 35

Transcript of Ch 3 Datalink

  • 7/23/2019 Ch 3 Datalink

    1/35

    The Data Link Layer

    Chapter 3

  • 7/23/2019 Ch 3 Datalink

    2/35

    Data Link Layer Design Issues

    a) Services Provided to the Network Layerb) Fraingc) !rror Contro"

    d) F"ow Contro"

  • 7/23/2019 Ch 3 Datalink

    3/35

    Functions o# the Data Link Layer

    a) Provide service inter#ace to the network "ayerb) Dea"ing with transission errors

    c) $egu"ating data #"ow%& S"ow receivers not swaped by #ast senders

  • 7/23/2019 Ch 3 Datalink

    4/35

    Functions o# the Data Link Layer '()

    $e"ationship between packets and #raes&

  • 7/23/2019 Ch 3 Datalink

    5/35

    Services Provided to Network Layer

    'a)irtua" counication&

    'b)*ctua" counication&

  • 7/23/2019 Ch 3 Datalink

    6/35

    Services Provided to Network Layer

    '()

    P"aceent o# the data "ink protoco"&

  • 7/23/2019 Ch 3 Datalink

    7/35

    Fraing

    * character strea& 'a)+ithout errors& 'b)+ith one error&

    Problem: Even if the error is detected, the receiver cannot figure out where

    the next frame starts ... its cannot resynchronize.

    Fraing by character count&

  • 7/23/2019 Ch 3 Datalink

    8/35

    Fraing '()

    'a)* #rae de"iited by #"ag bytes&

    'b)Four e,ap"es o# byte se-uences be#ore and a#ter stu##ing&

    Problem: Too tied to the 8-bit er character format ... !"#$%&E uses '(-bits)char

  • 7/23/2019 Ch 3 Datalink

    9/35

    Fraes that need to be send in a bit strea.

    F"ag

    The sender sends the #o""owing bit strea.

    F"agF"ag !sc

    The receiver wi"" ignore this #"ag&

    Fraes that need to be send in a bit strea.

    The sender sends the #o""owing bit strea.

    F"ag!sc

    F"agF"ag !sc

    The receiver wi"" ignore this #"ag&

    !sc!sc

    The receiver wi"" ignore this !sc/ and accept the #"ag&

  • 7/23/2019 Ch 3 Datalink

    10/35

    Fraing '3)

    0it stu##ing

    'a)The origina" data&

    'b)The data as they appear on the "ine&

    'c)The data as they are stored in receiver1s eory a#ter destu##ing&

    The goa" is to have 2%%%%%%2 as a uni-ue bit pattern&

  • 7/23/2019 Ch 3 Datalink

    11/35

    !rror Detection and Correction

    a) !rrorCorrecting Codesb)!rrorDetecting Codes

  • 7/23/2019 Ch 3 Datalink

    12/35

    0"ock Code Princip"es

    *amming distance d(v1,v2), is the number of bits in which v1and v2differ.

    *ence, d(011011,110001) = 3.

    $onsider the following maing for + and n

    &ata /loc+ $odeword00 00000

    01 00111

    10 11001

    11 11110

    "ow is a 00'00 is received, what do we do 1 %bviously this is not a codeword. 2o we

    have detecteda error. "ow let3s see the hamming distance of the received word from allcode words:

    d400'00,000005 ', d400'00,00'''5 , d400'00,''00'5 6, d400'00,''''05 7. 2o

    hamming distance to codeword for 00 is least. *ence it is most li+ely that the code

    transmitted codeword was 00000 and hence the data was 00. 2o now we have,with

    high robability, correctedthe error.

  • 7/23/2019 Ch 3 Datalink

    13/35

    0"ock Code Princip"es contd&

    *ence of n words +are valid codewords. %f the remaining n -+ words, at times

    some have minimun valid hamming distances to codewords. or examle fromrevious examle.

    #f received word was 0'0'0, then this has min hamming distance d40'0'0,000005

    and d40'0'0, ''''05 from valid code words. 2o in this case we can detect

    the error, but cannot correctit.

    $onsider airwise hamming distances between codewords:

    d400000,00'''5 79 d400000,''00'5 79 d400000,''''05 69

    d400''',''00'5 69 d400''',''''05 79 d4''00',''''05 79

    inimum distance between valid codewords 792ingle bit error will cause invalid codeword at distance ' from a valid codeword and

    at least distance from all other valid codewords. 2o we can always correct single

    bit errors. ;e can always detect two bit errors, but we might not aways be able to

    detect 7 bit errors.

  • 7/23/2019 Ch 3 Datalink

    14/35

    0"ock Code Princip"es contd&Each bit error increases the hamming distance by '.

    #n general, to correct error of u to tbits, the hamming distance between codewords

    should be at least 2t + 1.

    &esign goals:

    4'5

  • 7/23/2019 Ch 3 Datalink

    15/35

    The bits o# the codeword are nubered consecutive"y/ starting with bit % at the "e#t

    end/ and so on&

    The bits that are powers o# ( '%/ (/ 4/ 5/ %6/ 7) are check bits&

    The rest '3/ 8/ 6/ 9/ :/ 7) are data bits&

    !ach check bit #orces the parity o# soe co""ection o# bits/ inc"uding itse"#/ to be even&

    To see which check bits the data bit in position k contributes to/ rewrite k as a su o#

    power o# (/ e&g&/.

    %% ; % < ( < 5 and (: ; % < 4 < 5 < %6

    %22%222 is encoded as 22%%22%2222

    Check bits are in b"ue&

    +hich data position contributes to the #irst check bit. 3/ 8/ 9/ :/ %%

    +hich data position contributes to the second bit. =

    The e,ap"e #igure is in the ne,t tab"e&

  • 7/23/2019 Ch 3 Datalink

    16/35

    +hen a codeword arrives/ the receiver e,aines each check bit #or the correct parity&

    It the error counter is non>ero/ it contains the nuber o# incorrect bits&

    ?aing codes can correct sing"e errors.

    I# check bits %/ (/ and 5 are in error/ the inverted bit is %%/ because.

    %% ; % < ( < 5

    The trick so that ?aing codes can correct burst errors.

    *rrange k consecutive codewords in a sing"e atri,&

    Transit the data one co"un at a tie

    'nora""y the data wou"d be transitted one row at a tie)&

  • 7/23/2019 Ch 3 Datalink

    17/35

    !rrorCorrecting Codes

    @se o# a ?aing code to correct burst errors&

  • 7/23/2019 Ch 3 Datalink

    18/35

    !rrorDetecting Codes

    Error-correcting codesare wide"y used on wire"ess "inks that are noisy&

    ?owever/ they generate too "arge transission overhead #or re"iab"e "inks such as

    copper wire or #iber& There#ore/ here errordetection codes are used&

    +hen error is detected/ the data is retransitted&

    The goa" #or error correcting codes it to add redundancy to the data so that the

    errors are not on"y detected but can be at the sae tie corrected 'without

    retransission)&

    For error-detecting codesthe goa" is to on"y detect the errors with the inia"

    transission overhead& They are based on polynomial codea"so known as CRC

    (Cyclic Redundancy Check)

    * kbit #rae is regarded as po"ynoia" with coe##icients 2 and % with ters #ro

    ,k% to ,2

    For e,ap"e. %%222% A ,8< ,4< ,2

  • 7/23/2019 Ch 3 Datalink

    19/35

    Po"ynoia" arithetic is done odu"o ( using the ru"es o# a"gebraic #ie"d theory&

    0oth addition and subtraction are identica" to e,c"usive B$& For e,ape.

    %22%%2%% %%%%2222

  • 7/23/2019 Ch 3 Datalink

    20/35

    Ca"cu"ation o# the

    po"ynoia" codechecksu&

  • 7/23/2019 Ch 3 Datalink

    21/35

    @pon receiving the checksued #rae/ the receiver divides it by ',).

    GT',) < !',)H ',)

    Since T',) ',) is a"ways >ero/ the resu"t is a"ways !',) ',)&

    The errors containing ',) as a #actor wi"" s"ip by/ a"" other errors wi"" be caught&

    "ingle bit errors #ill be detected.

    +e have !',);,i#or a sing"e bit error/

    !',) ',) wi"" not be >ero/ since ',) ust have the #irst and "ast bit e-ua" to %&

    $ll errors consisting of an odd number of inverted bits #ill be detected

    i# ',) is divisib"e by ', < %)&

    !',) consists o# odd nuber o# ters/ e&g&/ ,8< ,(< ,2

    and there#ore/ cannot be divisib"e by ',

  • 7/23/2019 Ch 3 Datalink

    22/35

    !"eentary Data Link Protoco"s

    a) *n @nrestricted Sip"e, Protoco"b) * Sip"e, Stopand+ait Protoco"

    c) * Sip"e, Protoco" #or a Noisy Channe"

    Each protocol is increasing in complexity

    and drops unrealistic assumptions.

  • 7/23/2019 Ch 3 Datalink

    23/35

    @nrestriced sip"e, protoco"

    =ssumtion '. >eceiver can rocess data infinitely fast.=ssumtion . $hannel never looses data

    2endersends as fastas ossible

    >eceiver canalwaysrocess fastenough

  • 7/23/2019 Ch 3 Datalink

    24/35

    Sip"e, stopandwait protoco"=ssumtion . $hannel never looses data

    2endersendsframe

    2enderwaits forac+

    >cvr sendsac+ afterrocessing

    2endersendsframe

  • 7/23/2019 Ch 3 Datalink

    25/35

    Sip"e, protoco" #or noisy channe"=ssumtion . $hannel may loose data

    ? &ata frame can be lost

    ? =c+ can be lost

    @ost data frames:

    This means that sender will never get an ac+.2ender can imlement timer for each frame sent. #f timer exires retransmit.

    /ut what if the data frame arrived but the ac+ was lost1

    !sing above method, sender will retransmit frame that receiver has already received.

    >esult: Duplicate frame at sender.

    2o receiver needs some way of distinguishing dulicates.

    =nswer: !se seAuence numbers.

    ;hat should be the field size of these seAuence numbers 1

  • 7/23/2019 Ch 3 Datalink

    26/35

    Sip"e, protoco" #or noisy channe"2ince we are still using a sto-and-wait tye rotocol, sender will never transmitframe mB' unless it gets an ac+ for m. 2o receiver need only distinguish between

    successive frames. = ' bit seAuence number 40,'5 is enough. 2ender includesconsecutive seA numbers in frame, receiver sends ac+ with seA number.

    2ender:

    2end frame with seA number ".

    ;ait 4with timer5 for ac+ with seA number ".

    #f timer exires: retransmit frame with seA number "

    #f ac+ arrives : " mod4"B',5

    >eceiver:

    Epectframe "

    #f " arrives: deliver to networ+ layer, send ac+ for ", " mod4"B',5#f any other seA num: send revious ac+ 4mod4"-',55

    The main difference between this rotocol for simle sto-and-wait is that the receiver

    +nows which seA num to exect and sender +nown which seA num to send.

    This techniAue is called!utomatic "epeat "e#uest4=>C5

  • 7/23/2019 Ch 3 Datalink

    27/35

    * Sip"e, Protoco" #or a Noisy Channe"

    Fig& 3%(&

    * positive

    acknow"edgeentwith retransission

    protoco"&

    Last "ine Jinc'71shou"d be Jinv'71

    Continued

  • 7/23/2019 Ch 3 Datalink

    28/35

    * Sip"e, Protoco" #or a Noisy Channe" 'ctd&)

    * positive acknow"edgeent with retransission protoco"&

  • 7/23/2019 Ch 3 Datalink

    29/35

    S"iding +indow Protoco"s

    a) * Bne0it S"iding +indow Protoco"b)* Protoco" @sing o 0ack Nc) * Protoco" @sing Se"ective $epeat

  • 7/23/2019 Ch 3 Datalink

    30/35

    S"iding +indow Protoco"s '()

    * s"iding window o# si>e %/ with a 3bit se-uence nuber&

    'a)Initia""y&'b)*#ter the #irst #rae has been sent&

    'c)*#ter the #irst #rae has been received&

    'd)*#ter the #irst acknow"edgeent has been received&

  • 7/23/2019 Ch 3 Datalink

    31/35

    Pipe"ining$onsider a 0 +bs channel to a satellite with round-tri roagation delay 00 msec.

    !sing window size ':

    =t t 0 sender starts sending first bit of '000 bit frame=t t 0 msec frame comletely sent

    =t t D0 frame comletely received

    =t t 0 ac+ received by sender

    2ender busy for 0)0 6 of time ... very inefficient.

    ;hy 1

    2ender has to $ait till a frame is acked %efore sendin& t'e net frame.

    2olution: =llow sender to send u to w 4F'5 frames without waiting for ac+.

    2o from t 0 to t 0, sender could have sent ( frames, so let w should be atleast (.

    "eed for large window occurs when the bw x delay is big .... thin+ about this GG

    bw x delay determines how many frames can Hfit in the ieI. ;e will revisit this later.

  • 7/23/2019 Ch 3 Datalink

    32/35

    Pipe"ining and error contro"

    Pielining is fine ... but what if frames in the ieline are lost.

    2ender will detect loss of frames only after many successive frames have

    already been transmitted.

    2o, does the sender retransmit all frames 4lost and successive5 or Just lost 1

    The buffer at the receiver decides.

  • 7/23/2019 Ch 3 Datalink

    33/35

    obackN s& Se"ectiverepeat

    Pipe"ining and error recovery& !##ect on an error when

    'a)$eceiver1s window si>e is %&

    'b)$eceiver1s window si>e is "arge&

  • 7/23/2019 Ch 3 Datalink

    34/35

    Protoco" eri#ication

    Finite state achinesand Petri nets are used&

    +e see a Petri net

    ode" #or protoco" 3&

  • 7/23/2019 Ch 3 Datalink

    35/35

    Data Link Protoco"s in @se

    The Internet uses PPP (Point-to-Point)as the priary data "ink protoco" over

    pointtopoint "ines between routers and #or dia"up connections&

    The PPP #raes are byte oriented&

    In L*N networks %&'C (%igh-level &ata 'ink Control)protoco"s are used&These protoco"s originate #ro I0 ain#rae wor"d&

    The ?DLC #raes are bite oriented&