19
Computer and Data Networks, 3. Date Link Layer 1 ©  Dr.Z.Sun 3. The Data link layer 

Cdn Slides 3

Embed Size (px)

Citation preview

8/8/2019 Cdn Slides 3

http://slidepdf.com/reader/full/cdn-slides-3 1/18

Computer and Data Networks, 3. Date Link Layer 1 © Dr.Z.Sun

3. The Data link layer 

8/8/2019 Cdn Slides 3

http://slidepdf.com/reader/full/cdn-slides-3 2/18

Computer and Data Networks, 3. Date Link Layer 2  © Dr.Z.Sun

Outline

n Link layer services 

n Framing 

n Error correction and detection codes 

n Error and flow control: Slide window protocols 

n HDLC 

n SLIP and PPP 

8/8/2019 Cdn Slides 3

http://slidepdf.com/reader/full/cdn-slides-3 3/18

Computer and Data Networks, 3. Date Link Layer 3  © Dr.Z.Sun

Functions of the Data Link Layer 

Relationship between packets and frames.

8/8/2019 Cdn Slides 3

http://slidepdf.com/reader/full/cdn-slides-3 4/18

Computer and Data Networks, 3. Date Link Layer 4  © Dr.Z.Sun

 Link layer services

n Unacknowledged connectionless 

n Acknowledged connectionless n Acknowledged connection-oriented 

n Framing 

n Error control n Flow control 

8/8/2019 Cdn Slides 3

http://slidepdf.com/reader/full/cdn-slides-3 5/18

Computer and Data Networks, 3. Date Link Layer 5  © Dr.Z.Sun

Framing methods:

Four methods: 

n Character count 

n Flag bytes with bytes stuffing 

n Starting & ending flags with bit stuffing 

n Physical layer coding violations 

8/8/2019 Cdn Slides 3

http://slidepdf.com/reader/full/cdn-slides-3 6/18

Computer and Data Networks, 3. Date Link Layer 6  © Dr.Z.Sun

Framing – Character count 

A character stream. (a) Without errors. (b) With one error.

8/8/2019 Cdn Slides 3

http://slidepdf.com/reader/full/cdn-slides-3 7/18

Computer and Data Networks, 3. Date Link Layer 7  © Dr.Z.Sun

Framing – Flag bytes and byte stuffing

(a) A frame delimited by flag bytes.

(b) Four examples of byte sequences before and after stuffing.

8/8/2019 Cdn Slides 3

http://slidepdf.com/reader/full/cdn-slides-3 8/18

Computer and Data Networks, 3. Date Link Layer 8  © Dr.Z.Sun

Framing – bit stuffing

Bit stuffing 

(a) The original data.

(b) The data as they appear on the line.

(c) The data as they are stored in receiver’s memory after destuffing.

8/8/2019 Cdn Slides 3

http://slidepdf.com/reader/full/cdn-slides-3 9/18

Computer and Data Networks, 3. Date Link Layer 9  © Dr.Z.Sun

 Error correction codes

n Codeword = message + redundant 

n If two codewords are a Hamming distance d apart, it will require d single- bit error to convert one into the other 

n To detect d errors, you need a distance 

of d+1 code n To correct d errors, you need a distance 

2d+1 code 

n Example: parity bit (even or odd)

Hamming method: (m+r+1)<=2 r 

n power of 2 (1,2,4, ...) check bits 

n the rest (3,5,6,7,9, ...) data bits 

n example bit 11 checked by (1,2,8)

8/8/2019 Cdn Slides 3

http://slidepdf.com/reader/full/cdn-slides-3 10/18

Computer and Data Networks, 3. Date Link Layer 10  © Dr.Z.Sun

 Assume Xi are data bits and Ri data bits

n X3 corresponds to R1 and R2 

n

X5 corresponds to R1 and R4 n X6 corresponds to R2 and R4 

n X7 corresponds to R1, R2 and R4 

n X9 corresponds to R1 and R8 

n X10 corresponds to R2 and R8 

n X11 corresponds to R1, R2 and R8 

n R1 corresponds to {X3, X5, X7,

X9, X11} n R2 corresponds to {X3, X6, X7,

X10, X11} 

n R4 corresponds to {X5, X6, X7} 

n R8 corresponds to {X9, X10,X11} 

n Example : m = 1101101 => ?? 1 ? 101 ? 101 => 11 1 0 101 0 101

n If the receiving node received: 11 1 0 1 11 1 0 101

=> R1 = 1, R2 = 0, R4= 1, R8 =0 => 0 (1) + 1(2) + 1(4) + 0 (8) = 6 6 

This implies that bit 6 is incorrect, as it is checked by R2 and R4 

8/8/2019 Cdn Slides 3

http://slidepdf.com/reader/full/cdn-slides-3 11/18

Computer and Data Networks, 3. Date Link Layer 11 © Dr.Z.Sun

 Error detection codes

Polynomial code (cyclic redundancy code or CRC code)

n Let r be the degree of generator polynomial G(x). Append r zeros to the low-order end of the frame M(x) => x r M(x).

n Divide the bit string corresponding to G(x) into the bit string corresponding to x r M(x) using modulo 2 division 

n Subtract the remainder from the bit 

string corresponding to x r M(x) using modulo 2 subtraction. The results is the check-summed frame called polynomial T(x).

8/8/2019 Cdn Slides 3

http://slidepdf.com/reader/full/cdn-slides-3 12/18

Computer and Data Networks, 3. Date Link Layer 12  © Dr.Z.Sun

Stop-and-wait and slide window protocol

n Stop-and-wait ARQ : the sender sends a frame and 

waits for acknowledgement before sending any further frame. There are two sorts of errors: sending and acknowledgement.

n How about efficiency (stop and wait or window size is 1)? 

Satellite link is 50 kbit/s, round trip time 500 ms, frame size 1000 bits, frame transmission time 20 ms.

Efficiency = 20/(20+500) =1/26 n Slide window protocol allows the sender sends more 

frames up to a window size before stopping and waiting for acknowledgment 

8/8/2019 Cdn Slides 3

http://slidepdf.com/reader/full/cdn-slides-3 13/18

Computer and Data Networks, 3. Date Link Layer 13  © Dr.Z.Sun

Go Back N and Selective repeat 

n Pipe line technique: channel capacity is B bit/s, frame size L,round-trip time R.

Channel Efficiency = L/(L+BR)

If L< BR the efficiency will be less 

than 50%.n Two techniques trade-off 

bandwidth and buffer space 

Go back to N (receive window = 1)

only receives frame in order and retransmit all frames after errors.

Selective repeat buffers frames and retransmit only the errored frame.

8/8/2019 Cdn Slides 3

http://slidepdf.com/reader/full/cdn-slides-3 14/18

Computer and Data Networks, 3. Date Link Layer 14  © Dr.Z.Sun

Window size and Negative acknowledgment 

n NAK acknowledges when frame damaged or unexpected (potential lost frame)

n The maximum window size should be at most half of the range of the sequence number (Max_Seq+1)/2 

n Trade-off risk of unnecessary retransmission, or idle for a long period after errors 

n Standard deviation of acknowledgment is small, the timer can be set “tight”. Otherwise “loose”.

8/8/2019 Cdn Slides 3

http://slidepdf.com/reader/full/cdn-slides-3 15/18

Computer and Data Networks, 3. Date Link Layer 15  © Dr.Z.Sun

 High-level Data link Control (HDLC)

n Bit oriented and bit 

stuffing n 2x8 bits for framing 

n 8 bit address field identify multiple terminals 

n Control field can be used for three types of frames: information, supervision and unnumbered.

n Data field 

n 16 bits for CRC error check 

8/8/2019 Cdn Slides 3

http://slidepdf.com/reader/full/cdn-slides-3 16/18

8/8/2019 Cdn Slides 3

http://slidepdf.com/reader/full/cdn-slides-3 17/18

Computer and Data Networks, 3. Date Link Layer 17  © Dr.Z.Sun

PPP frame format (character oriented)

n Closely resemble HDLC frame format 

n Character oriented 

Default for unnumbered frame 

0: Net layer protocol 1: other 

Default is 2. Default is 1500.

Normally 2 but can be negotiated 

for 4.

Default 

8/8/2019 Cdn Slides 3

http://slidepdf.com/reader/full/cdn-slides-3 18/18

Computer and Data Networks, 3. Date Link Layer 18  © Dr.Z.Sun

Summary

n Link layer services 

n Framing n Error control 

• Error correction and Error detection 

n Flow control • Stop-and-wait, slide window 

• Go back N, Selective repeat, Negative Acknowledgement 

n Dial-up protocols for Internet access 

• HDLC and PPP