3. The Data link layer
Computer and Data Networks, 3. Date Link Layer
1
©Dr.Z.Sun
Outline n n n n n n
Link layer services Framing Error correction and detection codes Error and flow control: Slide window protocols HDLC SLIP and PPP
Computer and Data Networks, 3. Date Link Layer
2
©Dr.Z.Sun
Functions of the Data Link Layer Relationship between packets and frames.
Computer and Data Networks, 3. Date Link Layer
3
©Dr.Z.Sun
Link layer services n n n
Unacknowledged connectionless Acknowledged connectionless Acknowledged connection-oriented
Computer and Data Networks, 3. Date Link Layer
4
n n n
Framing Error control Flow control
©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
Computer and Data Networks, 3. Date Link Layer
5
©Dr.Z.Sun
Framing – Character count A character stream. (a) Without errors. (b) With one error.
Computer and Data Networks, 3. Date Link Layer
6
©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.
Computer and Data Networks, 3. Date Link Layer
7
©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.
Computer and Data Networks, 3. Date Link Layer
8
©Dr.Z.Sun
Error correction codes Codeword = message + redundant n If two codewords are a Hamming distance d apart, it will require d singlebit 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) ?? 1 ? 101 ? 101 => 11 1 0 101 0 101
n
If the receiving node received: 11 1 0 1 1 1 0 101
=> R1 = 1, R2 = 0, R4= 1, R8 =0 => 0(1) + 1(2) + 1(4) + 0(8) = 6 This implies that bit 6 is incorrect, as it is checked by R2 and R4 Computer and Data Networks, 3. Date Link Layer
10
©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) => xrM(x). n Divide the bit string corresponding to G(x) into the bit string corresponding to xrM(x) using modulo 2 division n Subtract the remainder from the bit string corresponding to xrM(x) using modulo 2 subtraction. The results is the check-summed frame called polynomial T(x). Computer and Data Networks, 3. Date Link Layer
11
©Dr.Z.Sun
Stop-and-wait and slide window protocol n
n
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. 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 Slide window protocol allows the sender sends more frames up to a window size before stopping and waiting for acknowledgment
Computer and Data Networks, 3. Date Link Layer
12
©Dr.Z.Sun
Go Back N and Selective repeat 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. n
Computer and Data Networks, 3. Date Link Layer
13
©Dr.Z.Sun
Window size and Negative acknowledgment n n n n
NAK acknowledges when frame damaged or unexpected (potential lost frame) The maximum window size should be at most half of the range of the sequence number (Max_Seq+1)/2 Trade-off risk of unnecessary retransmission, or idle for a long period after errors Standard deviation of acknowledgment is small, the timer can be set “tight”. Otherwise “loose”.
Computer and Data Networks, 3. Date Link Layer
14
©Dr.Z.Sun
High-level Data link Control (HDLC) n n n n
n n
Computer and Data Networks, 3. Date Link Layer
15
Bit oriented and bit stuffing 2x8 bits for framing 8 bit address field identify multiple terminals Control field can be used for three types of frames: information, supervision and unnumbered. Data field 16 bits for CRC error check ©Dr.Z.Sun
Internet SLIP and PPP protocols n
n
Serial Line IP (SLIP): no error detection and correction, support only IP, need to know IP address in advance, no authentication, not a proved Internet standard. Point-to-Point protocol (PPP): handles no error detection, support multiple protocol, address can be negotiated at connection time, permit authentication, many improvement over SLIP
Computer and Data Networks, 3. Date Link Layer
16
©Dr.Z.Sun
PPP frame format (character oriented) n n
Closely resemble HDLC frame format Character oriented Default is 2.
Default
Computer and Data Networks, 3. Date Link Layer
Default for unnumbered frame
Default is 1500.
Normally 2 but can be negotiated for 4.
0: Net layer protocol 1: other
17
©Dr.Z.Sun
Summary n n n n
n
Link layer services Framing Error control • Error correction and Error detection Flow control • Stop-and-wait, slide window • Go back N, Selective repeat, Negative Acknowledgement Dial-up protocols for Internet access • HDLC and PPP
Computer and Data Networks, 3. Date Link Layer
18
©Dr.Z.Sun