Chapter 4 Data Link Layer

Document Sample
Chapter 4 Data Link Layer Powered By Docstoc
					      Chapter 4
Data Link Layer
             Framing
         Error control
         Flow control
          Multiplexing
    Link Maintenance
             Security
                         1
Services
   Transfers frames across direct connections
       Directly connected (can be wireless), wire-like
       Losses & errors, but no out-of-sequence frames
   More detailed services
       Framing (bits ↔ frames)
       Error control (protection from impairment)
       Flow control
       Multiplexing
       Link Maintenance
       Security: Authentication & Encryption
                                                          2
Data Link Protocols
            Packets              Packets

            Data link            Data link
             layer      Frames    layer
        A                                    B
            Physical             Physical
             layer                layer




Examples
 PPP

 HDLC

 Ethernet LAN

 IEEE 802.11 (WiFi) LAN

                                                 3
       Framing
(Chapter 5.4 in Leon-Garcia)




                               4
Framing
transmitted         received         Bit stream - frames
   frames            frames          Frame boundaries can
                                      be determined using:
                                     1.   Character Counts
         Framing                     2.   Control Characters
                                     3.   Framing Bits
                                     4.   Framing by illegal code
                    0110110111
       0111110101




                                                                    5
    Control Characters
       Transmission of printable characters using ASCII
               Octets with HEX value < 0x20 are nonprintable
               Use control characters: STX (start of text) = 0x02; ETX (end of text) = 0x03.


                                          Data to be sent
                            A DLE B ETX DLE STX E
                                   After stuffing and framing
DLE STX A DLE DLE B ETX DLE DLE STX E DLE ETX
           What about transmission of data (including non-printable characters)?
                Introduce DLE (data link escape) = 0x10
                DLE STX (DLE ETX) used to indicate beginning (end) of frame
                Insert extra DLE in front of occurrence of DLE STX (DLE ETX) in frame
                All DLEs occur in pairs except at frame boundaries.
                                                                                                6
Bit Stuffing
HDLC frame

Flag Address Control          Information         FCS    Flag
                            any number of bits

   Frame delineated by flag character
   HDLC uses bit stuffing to prevent occurrence of flag
    01111110 inside the frame
   Transmitter inserts extra 0 after each consecutive
    five 1s inside the frame
   Receiver checks for five consecutive 1s
       if next bit = 0, it is removed
       if next two bits are 10, then flag is detected
       If next two bits are 11, then frame has errors          7
Example: Bit stuffing
  (a)           Data to be sent

          0110111111111100
            After stuffing and framing

  0111111001101111101111100001111110


  (b)             Data received

01111110000111011111011111011001111110
             After destuffing and deframing

        *000111011111-11111-110*              8
Example: Framing in Ethernet
   Ethernet complies to standard IEEE 802.3
   An illegal manchester coding is used for
    framing.
   A character count is also included in the
    header.
   All frames have an integral number of bytes.
    If not, the frame is considered to be received
    in error.

                                                     9
Error Control Coding
(Chapter 3.9 in Leon-Garcia)




                               10
Error Control
   Two approaches
       Forward error correction (FEC)
       Error detection & retransmission (ARQ)
   Add redundancy (admit only codewords with a certain pattern)
   Blindspot: when channel transforms a codeword into another
    codeword
   (n,k) block code
   There are capacity-achieving codes
       Usually with somewhat high complexity;
       When bandwidth is abundant it suffices to use simpler codes.

                             c1…cn
        b1…bk      Encoder             Channel             Decoder



                                                                       11
Single Parity Check
   n=k+1

         Information bits:       b1, b2, b3, …, bk
     Check Bit:      bk+1= b1+ b2+ b3+ …+ bk modulo 2

        Codeword:        (b1, b2, b3, …, bk,, bk+!)


   All codewords have even # of 1s
       All error patterns that change an odd number of bits are
        detectable
       Others undetectable
   Redundancy: overhead = 1/(k + 1)
                                                                   12
Example
   Information (7 bits): (0, 1, 0, 1, 1, 0, 0)




                                                  13
Probability of Error

    P[error detection failure]
             = P[undetectable error pattern]
             = P[all error patterns with even number of 1s]

            =    n p2(1 – p)n-2 + n    p4(1 – p)n-4 + …
                 2                4


   Example: Evaluate above for n = 6, p = 0.01
                  P[undetectable error] = 0.0014



                                                              14
Two-Dimensional Parity Check

        1 0 0 1 0 0
        0 1 0 0 0 1
                          row check bits
        1 0 0 1 0 0
        1 1 0 1 1 0
        1 0 0 1 1 1

       column check bit




                                           15
Error-detecting capability
1 0 0 1 0 0                   1 0 0 1 0 0
0 0 0 0 0 1                   0 0 0 0 0 1
              One error                       Two errors
1 0 0 1 0 0                   1 0 0 1 0 0
1 1 0 1 1 0                   1 0 0 1 1 0
                                                        1, 2, or 3 errors
1 0 0 1 1 1                   1 0 0 1 1 1
                                                        can always be
                                                       detected; Not all
                                                      patterns >4 errors
1 0 0 1 0 0                   1 0 0 1 0 0
                                                       can be detected
0 0 0 1 0 1                   0 0 0 1 0 1
1 0 0 1 0 0 Three             1 0 0 1 0 0
            errors                            Four errors
1 0 0 1 1 0                   1 0 0 0 1 0     (undetectable)

1 0 0 1 1 1                   1 0 0 1 1 1
                                                                      16

          Arrows indicate failed check bits
Hamming Codes
   Class of linear block codes
   Capable of correcting all single-error patterns
   For each m > 2, there is a (2m–1, n-m) Hamming code



         m    n = 2m–1 k = n–m    Code rate k/n
         3        7        4          4/7
         4       15       11         11/15
         5       31       26         26/31

                                                    17
m = 3 Hamming Code
   Information bits are b1, b2, b3, b4
   Parity checks (binary addition/multiplication)

                   b5 = b1        + b3 + b4
                   b6 = b1 + b2       + b4
                   b7 =      + b2 + b3 + b4


   Linearity
   24 = 16 codewords



                                                     18
Hamming (7,4) code
   Information                Codeword            Weight
  b1   b2   b3   b4   b1 b2 b3 b4 b5 b6 b7         w(b)

  0    0    0    0    0   0   0   0   0   0   0     0
  0    0    0    1    0   0   0   1   1   1   1     4
  0    0    1    0    0   0   1   0   1   0   1     3
  0    0    1    1    0   0   1   1   0   1   0     3
  0    1    0    0    0   1   0   0   0   1   1     3
  0    1    0    1    0   1   0   1   1   0   0     3
  0    1    1    0    0   1   1   0   1   1   0     4
  0    1    1    1    0   1   1   1   0   0   1     4
  1    0    0    0    1   0   0   0   1   1   0     3
  1    0    0    1    1   0   0   1   0   0   1     3
  1    0    1    0    1   0   1   0   0   1   1     4
  1    0    1    1    1   0   1   1   1   0   0     4
  1    1    0    0    1   1   0   0   1   0   1     4
  1    1    0    1    1   1   0   1   0   1   0     4
  1    1    1    0    1   1   1   0   0   0   0     3      19

  1    1    1    1    1   1   1   1   1   1   1     7
Parity Check Equations
   Rearrange parity check equations:
           0 = b1        + b3 + b4 + b5
           0 = b1 + b2          + b4      + b6
           0=       + b2 + b3 + b4               + b7

   In matrix form:        b1
                           b2                              All codewords must
                                                            satisfy these
     0   = 1011100         b3                               equations
     0   = 1101010         b4 = H bt = 0                   Note: each nonzero
     0   = 0111001         b5                               3-tuple appears once
                                                            as a column in check
                           b6                               matrix H
                           b7                                                20
Hamming Code: Error Detection
                0
                0
      1011100   1     1                 Single error detected
s=He= 1101010   0   = 0
      0111001   0     1
                0
                0
                0
                1
      1011100   0     0   1     1
s=He= 1101010   0   = 1 + 0 =           Double error detected
                                1
      0111001   1     1   0     1
                0
                0
                1
                1
      1011100   1   1     0     1
s=He= 1101010   0 = 1 +                     Triple error not
                          1 +   0 = 0
                0                           detected
      0111001       0     1     1
                                                               21
                0
                0
Minimum distance
   Undetectable error pattern must have 3 or more bits
   At least 3 bits must be changed to convert one codeword
    into another codeword

     Set of n-       o                                  Set of n-
                                          o
      tuples                 Distance 3            o     tuples
      within                                             within
    distance 1   o
                     b1       o      o        b2       distance 1
       of b1                                              of b2
                         o                    o


   Spheres of distance 1 around each codeword do not
    overlap
   If a single error occurs, the resulting n-tuple will be in a
    unique sphere around the original codeword                      22
General Hamming Codes
   For m > 2, the Hamming code is obtained
    through the check matrix H:
       Each nonzero m-tuple appears once as a column
       The resulting code corrects all single errors

   P[undetectable error]
                 = P[ error is a codeword]
                 ≈ (# of codewords with dmin) x pdmin

   Animated example
    http://www.systems.caltech.edu/EE/Faculty/rjm/SAMPLE_20040708.html
                                                                         23
Hamming Codes: Error-correction
          (Transmitter) b       +             R (Receiver)

                                e Error pattern

   Compute syndrome:
        s = HR = H (b + e) = Hb + He = He
   If s = 0, then the receiver accepts R as the transmitted
    codeword, find the corresponding k-bit message
   If s is nonzero, then an error is detected
       Hamming decoder assumes a single error has occurred
       Each single-bit error pattern has a unique syndrome
       The receiver matches the syndrome to a single-bit error
        pattern and corrects the appropriate bit
                                                                  24
Hamming Codes: Performance
   Assume bit errors occur independent of each other
    and with probability p

                        s = H R = He
                                       7p

               s=0                      s=0
                               1–3p            3p


No errors in    Undetectable    Correctable   Uncorrectable
transmission       errors         errors         errors
  (1–p)7           7p3            7p(1–3p)        21p2

                                                              25
Other Error Control Codes
   Good practical codes for error detection:
     Internet Check Sums

     CRC Polynomial Codes

    They can detect the vast majority of errors.

   Good codes for error “correction”:
     Turbo codes

     Low-density parity-check (LDPC) codes

                                                   26
Internet Checksum
   Several Internet protocols (e.g. IP, TCP, UDP) use
    check bits to detect errors in the header
   A checksum is calculated for header contents and
    included in a special field.
   Treating each 16-bit word in data as an integer, find
         x = b0 + b1 + b2+ ...+ bL-1 modulo 216-1
   The checksum is then given by:
         bL = - x modulo 216-1
    Thus, the headers satisfy the following pattern:
      0 = b0 + b1 + b2+ ...+ bL-1 + bL modulo 216-1

                                                            27
Polynomial Codes
   Convenient mathematical formulation of coding
   Polynomials as codewords
   Implemented using shift-register circuits
   Called cyclic redundancy check (CRC) codes
   Excellent for detecting burst errors

                          Encoder for g(x) = x3 + x + 1
                        g0 = 1             g1 = 1                   g3 = 1
0,0,0,i0,i1,i2,i3
                    +            Reg 0    +         Reg 1   Reg 2




                                                                             28
Automatic Repeat Request
         (ARQ)
   (Chapter 5 in Leon-Garcia)




                                29
Peer-to-Peer Protocols
                        Each layer provides
                         a service to the layer
                         above.
 n+1          n+1
                        It does so by
                         executing a peer-to-
                         peer protocol.
  n            n
                        The protocol uses
                         the the services of
                         the layer below.


 n–1          n–1



                                              30
Service Models
   The service model specifies the manner in
    which information is transferred.
       Connection-oriented
       Connectionless




                                                31
Connection-Oriented
   Connection setup
   Message transfer
   Connection release
   Example: TCP, PPP



    n + 1 peer process                          n + 1 peer process
           send                                       receive

     SDU         Layer n connection-oriented service      SDU




                                                                     32
Connectionless Transfer Service
    No setup
    Each message sent independently
    Must provide all address information per message
    Simple & quick
    Example: UDP, IP


     n + 1 peer process                          n + 1 peer process
            send                                       receive

      SDU            Layer n connectionless service


                                                                      33
Automatic Repeat Request (ARQ)
   Purpose: To pass to the receiver every frame
    correctly, only once, in order.
   Bad things can happen: Error, arbitrary delay, out-
    of-order arrival, or loss. Aim at very high reliability.
   Assume if frames arrive, they arrive in-order for
    now. We save the out-of-order problem for later.
   Basic elements:
       Error-detecting code
       ACKs (positive acknowledgments)
       NAKs (negative acknowledgments)
       Timeout mechanism
                                                               34
Stop-and-Wait ARQ
Transmit a frame, wait for ACK
                                                               Error-free
       Packet
                                                                packet
                                Information frame

                  Transmitter                       Receiver
Timer set after
  each frame
 transmission                      Control frame




                                                                            35
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?
    Need a sequence number: Slast=SN of most recent transmitted frame.
                                                                           36
Sequence Numbers
    (c) Premature Time-out
                 Time-out
                                                               Time
          A     Frame
                   0            Frame     Frame   Frame
                    ACK           0         1       2
                                    ACK
          B

   The transmitting station misinterprets duplicate ACKs
   Question: How is the receiver to know second ACK is for frame 0?


   Need SN in ACK: Rnext=SN of next frame expected by the receiver.
   Implicitly acknowledges receipt of all prior frames.
   What if ACK only if Slast=Rnext?
                                                                       37
How many bits for SN?
1-Bit SN 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




                                                                          38
Finite State Machine
              Transmitter                           Slast       Receiver
                  A                                                B
                                   Rnext


 Frame 0                                                                 ACK 0
 lost/error                                                              lost/error
                    (0,0)       Error-free frame 0
                                                            (0,1)
                                arrives

                      ACK 1        Global State:               ACK 0
                      arrives      (Slast, Rnext)              arrives


                    (1,0)                                   (1,1)
                                Error-free frame 1                       Frame 1
 ACK 1
                                arrives                                  lost/error
 lost/error                                                                           39
S/W Efficiency
                   Last frame bit                          ACK
 First frame bit   enters channel                         arrives
 enters channel
                              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



                                                                        40
S/W Transmission Time
         t0 = total time to transmit 1 frame if no error
A
                                                        tproc


B
                 frame
     tprop                   tproc    tack      tprop
                 tf time


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

                                nf na                   bits/ACK frame
        2t prop  2t proc      
                               R   R

                                             channel transmission rate
                                                                         41
Efficiency on Error-free channel
                                                      Overhead bits (header, CRC)
Effective transmission rate:
                     # of information bits n f  no
        R    0
             eff                                  ,
                           total time          t0

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

                                                                 Effect of
                                   Effect of
                                                         Delay-Bandwidth Product
                                                                              42
                                  ACK frame
Delay-Bandwidth Product
nf=10,000 bits, na=no=200 bits
2xDelayxBW     1 ms     10 ms     100 ms      1 sec
 Efficiency
              200 km   2000 km   20,000 km 200,000 km
 1 Mbps        103       104        105          106
               88%      49%          9%          1%
 1 Gbps        106       107        108          109
               1%       0.1%       0.01%       0.001%


S/W inefficient for very high speeds or long delays
                                                        43
 Average Transmission Number

Proposition: Let Pf be the frame error probability. Then the average
   number of transmissions per successful frame is 1/ (1–Pf ).
Proof: The number of transmissions to first correct arrival has
   geometric distribution.
                        
              E[ N ]   iP[n  i ]
                       i 1
                                                           
                                                       d
                i (1  Pf ) Pf                             Pf
                                   i 1
                                           (1  Pf )
                                                                   i

                i 1                                  dPf   i 1


                   1    d 1  1
                                               
                                                1 .
              
                1  Pf dPf  1  Pf
                           
                                                1 P
                                                    f


E.g., if 1-in-10 gets through, then in average 10 tries to success.
                                                                       44
Efficiency in Channel with Errors
   Assuming time-out is equal to t0 (it should be larger)

                                                            no
                                                       1
             Reff         n f  no                          nf
     SW                                                                (1  Pf )
              R         Rt0 /(1  Pf )          na 2(t prop  t proc ) R
                                             1    
                                                nf         nf
                                                                                   Effect of
                                                                                 frame loss
   If bit-error-rate is p, then

                                         n f p
     1  Pf  (1  p)              e
                              nf
                                                  for large n f and small p


                                                                                               45
Go-Back-N
   A sliding-window protocol.
   Keep channel busy by continuing to send frames
   Allow a window of up to Ws outstanding frames
   If ACK for oldest frame arrives before window is
    exhausted, we can continue transmitting
   If window is exhausted, pull back and retransmit all
    outstanding frames




                                                           46
Go-Back-N ARQ
        Go-Back-4:                    4 frames are outstanding; so go back 4

            fr   fr   fr   fr   fr   fr    fr    fr   fr    fr       fr       fr   fr       fr           Time
            0    1    2    3    4    5     6     3    4     5        6        7    8        9
A




B
                       A    A    A        out of sequence        A        A    A        A        A   A
                       C    C    C        frames                 C        C    C        C        C   C
                       K    K    K                               K        K    K        K        K   K
                       1    2    3                               4        5    6        7        8   9


Rnext   0             1    2    3         3                  4        5       6    7        8        9

   Frame transmission are pipelined to keep the channel busy
   Frame with errors and subsequent out-of-sequence frames are ignored
                                                                                                           47
 Choose Window Size > RTT
                                Time-out
Stop-and-Wait ARQ
               fr                      fr                      fr                     Time
   A           0                       0                       1



   B                 Receiver is                      A
                     looking for                      C
                                                      K
                       Rnext=0
                                                      1

Go-Back-N ARQ               If window exhausted, go back N
                fr    fr   fr     fr   fr   fr   fr       fr        fr fr    fr
                0
                                                                                      Time
                      1    2      3    0    1    2        3         4 5      6
   A



   B                                              A                           A
                                                           A         A   A        A
                 Receiver is Out-of-              C        C         C   C    C   C
                 looking for sequence             K        K         K   K    K   K
                                                                                             48

                   Rnext=0    frames              1        2         3   4    5   6
Go-Back-N with Timeout
   Problem with Go-Back-N as presented:
       If frame is lost and source does not have frame to
        send, then window will not be exhausted and
        recovery will not commence
   Use a timeout with each frame
       When timeout expires, resend all outstanding
        frames




                                                         49
 Go-Back-N Transmitter & Receiver
                    Transmitter                        Receiver

                  Send Window (size Ws)
                          ...                              Receive Window (size 1)

  Frames
transmitted S
             last      Srecent   Slast+Ws-1
and ACKed
                                                     Frames
                    Buffers                                     Rnext
                                                    received
                                  oldest un-
          Timer      Slast
                                 ACKed frame
          Timer     Slast+1                     Receiver will only accept
                      ...                       error-free frame with SN Rnext.
          Timer
                    Srecent       most recent
                                                When the frame arrives Rnext is
                                 transmission
                                                incremented by 1, so the receive
                       ...                      window slides forward by 1.
                  Slast+Ws-1        max SN
                                    allowed
                                                                              50
 Maximum Window Size Ws = 2m-1
Example: M = 22 = 4, Go-Back – 4 is not good.
                                            Transmitter goes back 4
         fr       fr       fr       fr       fr         fr         fr      fr         Time
  A      0        1        2        3        0          1          2       3




                       A        A        A   A
    B                  C        C        C   C                Receiver has Rnext= 0, but it does not
                       K        K        K   K                know whether this is the old frame 0 or
                       1        2        3   0
                                                              a new frame 0
Rnext         0        1    2       3        0

  Example: Go-Back-3 is good.
         fr       fr       fr        fr          fr      fr                           Time
   A     0        1        2         0           1       2




                       A        A        A
    B                  C        C        C
                       K        K        K            Receiver has Rnext= 3 , so it
                       1        2        3
                                                      rejects the old frame 0                           51
 Rnext        0        1        2    3
ACK Piggybacking in Bidirectional GBN


    In bi-directional communication, ACKs are
     often piggybacked on data frames to reduce
     overhead.


                                          SArecent RA next
         Transmitter                                         Receiver
          Receiver                                           Transmitter
                       SBrecent RB next




                                                                           52
Choice of Timeout & Window Size
                                    Tout
                                                                     Tproc




        Tprop            Tf            Tf              Tprop

   Timeout value should allow for:
       2 Tprop + Tproc
       A frame begins transmission right before the first frame arrives Tf
       Next frame carries the ACK, Tf (piggy-back)
       Thus, timeout > 2 Tprop + 2 Tf + Tproc
   Ws should be large enough to keep channel busy for Tout
                                                                              53
Efficiency of Go-Back-N
   GBN  1 if channel is error-free and Ws is large enough to
    keep channel busy
   Assume Pf frame loss probability, time to deliver a frame is:
       tf                  if first attempt succeeds
       Tf + Wstf /(1-Pf)   otherwise go back Ws and try again


                                       Wt                 Wt
          tGBN  t f (1  Pf )   t f  s f  Pf  t f  Pf s f
                                       1  Pf             1  Pf
                                              
                   n f  no              n
                                      1 o
                      tGBN               nf
          GBN                                 (1  Pf )
                        R       1  (Ws  1) Pf

                      Delay-bandwidth product determines Ws          54
Improvement over Go-Back-N?
   Go-Back-N repeats multiple frames when a few errors
    or losses occur
   How about retransmitting only an individual frame?
   Selective Repeat ARQ
       Timeout pinpoints individual frame
       Receiver maintains a window of acceptable SN
       Error-free, but out-of-sequence frames with SN within the
        receive window are buffered
       Arrival of Rnext causes window to slide forward by 1 or more
       NAK causes retransmission of oldest un-acked frame


                                                                   55
Selective Repeat ARQ

    fr   fr   fr   fr   fr   fr       fr   fr   fr   fr       fr fr fr fr           Time
    0    1    2    3    4    5        6    2    7    8        9 10 11 12
A




B
               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   K
               1    2             2    2   2    2         7    8   9   1    1   1
                                                                       0    1   2



                                                                                      56
Selective Repeat ARQ
                      Transmitter                          Receiver

                 Send Window                          Receive Window
                         ...

  Frames                                         Frames
transmitted S                                   received Rnext    Rnext + Wr-1
             last       Srecent   Slast+ Ws-1
and ACKed

              Buffers                             Buffers
   Timer       Slast                              Rnext+ 1
    Timer    Slast+ 1                             Rnext+ 2
                ...
    Timer
              Srecent                                ...
                                                 Rnext+ Wr- 1         max Seq #
                ...                                                   accepted
            Slast+ Ws - 1                                                     57
  Send & Receive Windows
           Transmitter                      Receiver
              0                              0
   2m-1                  1       2m-1                  1

                             2                                 2
                                                 Rnext
                   Slast
             send                             receive          j
            window    i                       window
                                                           i
    i + Ws – 1    i+1
                                        j + Wr – 1
Moves k forward when ACK         Moves forward by 1 or more
arrives with Rnext = Slast + k    when frame arrives with
      k = 1, …, Ws-1                   Seq. # = Rnext     58
  What size Ws and Wr allowed?
     Example: M=22=4, Ws=3, Wr=3
                                                       Frame 0 resent
 Send
          {0,1,2} {1,2}   {2}          {.}
Window
               fr0        fr1      fr2                  fr0
          A                                                             Time




          B               ACK1          ACK2           ACK3
Receive
                     {0,1,2} {1,2,3}         {2,3,0}      {3,0,1}
Window
                                               Old frame 0 accepted as a
                                               new frame because it falls
                                               in the receive window        59
  Ws + Wr = 2m is maximum allowed
     Example: M=22=4, Ws=2, Wr=2
                                                     Frame 0 resent
 Send
              {0,1}         {1}            {.}
Window
                      fr0             fr1                fr0
          A                                                                                 Time




          B                               ACK1             ACK2
Receive
                                  {0,1}          {1,2}         {2,3}
Window
                                                         Old frame 0 rejected because it
                                                         falls outside the receive window
                                                                                               60
  Why Ws + Wr = 2m works
      The number of bits, m, is enough to label all
       outstanding frames.
      Usually, Ws = Wr = 2m-1


           0                                  0
2m-1               1               2m-1               1

           Slast              Ws +Wr-1                    2
                        2

                                          receive   Rnext Ws
          send                            window
         window        Ws-1
                                                               61
Efficiency of Selective Repeat
   # of transmissions required to deliver a frame is:
    tf / (1-Pf)



                     n f  no
                   t f /(1  Pf )      no     
           SR                      1      (1  Pf )
                         R             n      
                                          f   



                                                            62
Example: Impact Bit Error Rate on
Selective Repeat
nf=10,000 bits, na=no=200 bits
p = 0, 10-6, 10-5, 10-4 and R = 1 Mbps & 100 ms
1 Mbps x 100 ms = 100000 bits = 10 frames → Use Ws = 11

Efficiency        0         10-6        10-5          10-4
    S&W         8.9%       8.8%         8.0%          3.3%
    GBN         98%       88.2%        45.4%          4.9%
     SR         98%        97%          89%           36%

   GBN >> S&W for large delay-bandwidth product
   GBN becomes inefficient as error rate increases
   SR is the best. Efficiency drops as error rate increases
                                                               63
 Comparison of ARQ Efficiencies
Assume na, no << nf, and L = 2(tprop+tproc)R/nf =(Ws-1).

Selective-Repeat:
                       no      
     SR    (1  Pf )1         (1  Pf )
                       n       
                          f    
Go-Back-N:                                    For Pf≈0, SR & GBN same
                   1  Pf           1  Pf
   GBN                        
              1  (WS  1) Pf       1  LPf
                                              For Pf→1, GBN & SW same
Stop-and-Wait:
                    (1  Pf )            1  Pf
    SW                               
               na 2(t prop  t proc ) R 1  L
            1    
               nf           nf                                     64
ARQ Efficiencies
                              ARQ Efficiency Com parison
                                                                    Selective
               1.5                                                  Repeat
                                                                    Go Back N 10
  Efficiency




                1

               0.5                                                  Stop and Wait
                                                                    100
                0                                                   Go Back N 100
                      -9 -8 -7 -6 -5 -4 -3 10 10
                     10-9 10-8 10-7 10-6 10-5 10-4 10-3 -2-2 -1-1

                                   - LOG(p)
                                       p                            Stop and Wait
                                                                    10
          Delay-Bandwidth product = 10, 100                                         65
Standard Data Link Layer Protocols:
          PPP & HDLC
    (Chapter 5.5-6 in Leon-Garcia)




                                      66
DLL


      Network     “Packet”   Network
       layer                  layer




      Data link   “Frame”    Data link
       layer                  layer




       Physical               Physical
        layer                  layer
                                         67
PPP: Point-to-Point Protocol
   A data link layer protocol.
   Encapsulating IP packets over point-to-point links.
       Router-router;
       Dial-up to router (PC to Internet service provider (ISP))
   Functions:
       Provides Framing and Error Detection
       Link Control Protocols
         Set up, configure, testing, maintain, terminate;
         Authentication: Password Authentication Protocol, etc.
       Network Control Protocols
         Configure network layer protocols
         E.g., IP, IPX (Novell), Appletalk

                                                                    68
PPP Frame Format

                                   1 or 2     variable        2 or 4
   Flag     Address     Control    Protocol   Information                Flag
                                                              FCS
 01111110   1111111     00000011                                       01111110




                                                            CRC 16 or
 All stations are to
                                                             CRC 32
 accept the frame

                           HDLC
                      Unnumbered frame

• Can support multiple network protocols simultaneously
• Specifies what kind of packet is contained in the payload
                                                                                  69
High-Level Data Link Control (HDLC)

   Bit-oriented data link control
   Derived from IBM Synchronous Data Link
    Control (SDLC)




                                             70
HDLC Data Transfer Modes
    Normal Response Mode
         Used in polling multidrop lines

               Commands
     Primary
                                                                 Responses


                     Secondary      Secondary        Secondary


    Asynchronous Balanced Mode
         Used in full-duplex point-to-point links

        Primary Commands                        Responses Secondary
      Secondary   Responses                     Commands     Primary


    Mode is selected during connection establishment                        71
HDLC Frame Format

    Flag Address Control           Information          FCS       Flag

    Control field gives HDLC its functionality
    Codes in fields have specific meanings and uses
        Flag: delineate frame boundaries
        Address: identify secondary station (1 or more octets)
        Control: purpose & functions of frame (1 or 2 octets)
        Information: user data; length not standardized
        Frame Check Sequence: 16- or 32-bit CRC




                                                                         72
    Control Field Format
Information Frame
   1             2-4                            5                 6-8
  0              N(S)                         P/F                  N(R)

Supervisory Frame
    1         0            S          S       P/F                  N(R)

Unnumbered Frame
    1        1            M          M        P/F        M         M          M

   S: Supervisory Function Bits              Note: The information frames and
   N(R): Receive Sequence Number                supervisory frames allow HDLC to
                                                 implement Stop-and-Wait, Go-Back-
   N(S): Send Sequence Number                   N, and Selective Repeat ARQ.
   M: Unnumbered Function Bits               Note: The unnumbered frames implement
   P/F: Poll/final bit used in interaction      control functions.
    between primary and secondary
                                                                                  73
    Example: HDLC Using Polling
                       Address of secondary
                            Primary A         Secondaries B, C
A polls B            B, RR, 0, P                        N(S) N(R)
RR=receive
                                                  B, I, 0, 0
ready                N(R)                                         B sends 3 info
                                          X       B, I, 1, 0
                                                                        frames
                                                  B, I, 2, 0,F
A rejects fr1        B, SREJ, 1
A polls C            C, RR, 0, P
                                                  C, RR, 0, F      C nothing to
                                                                          send
A polls B,       B, SREJ, 1,P
requests
selective                                         B, I, 1, 0       B resends fr1
retrans. fr1                                      B, I, 3, 0       Then fr 3 & 4
                                                  B, I, 4, 0, F
A send info fr0         B, I, 0, 5
to B, ACKs up to 4
                                                                           74
                            Time
HDLC Flow Control
   Flow control prevents transmitter from overrunning
    receiver buffers.
   Receiver can control flow by delaying
    acknowledgement messages.
   Receiver can also use supervisory frames to
    explicitly control transmitter
       Receive Not Ready (RNR) & Receive Ready (RR)



            I3    I4   I5   RNR5     RR6      I6



                                                         75