570 likes | 657 Views
The Data Link Layer. Chapter 3. Functions of the Data Link Layer. Framing Error Control: dealing with transmission errors Flow Control: regulating data flow (through acknowledgments) so that slow receivers are not swamped by fast senders. Relationship between packets and frames.
E N D
The Data Link Layer Chapter 3 EETS 7304
Functions of the Data Link Layer • Framing • Error Control: dealing with transmission errors • Flow Control: regulating data flow (through acknowledgments) so that slow receivers are not swamped by fast senders. EETS 7304
Relationship between packets and frames EETS 7304
Services Provided to Network Layer (a) Virtual communication. (b) Actual communication. EETS 7304
DLL within a router EETS 7304
Framing with character count A character stream: (a) Without errors: first byte contains the message length (in bytes). (b) With one error: receiver looses synchronization and cannot recover. EETS 7304
Framing with ‘esc’ character: byte stuffing (a) A frame delimited by flag bytes. (b) Four examples of byte sequences before and after stuffing. EETS 7304
7E 7D ESC 7E 7D 5E 7D 5D 7E PPP Byte stuffing Frame format addr FF Flag 7E Contr 03 Flag 7E protocol data CRC 1 1 1 2 up to 1500 2 1 0021 IP datagram C021 Link control data 8021 network control data EETS 7304
Framing with zero insertion (HDLC) (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. Flag bit pattern: 0 1 1 1 1 1 1 0 Zero insertion eliminates flag bit pattern to appear in the output text EETS 7304
Error Detection and Correction(using additional bits) • Error-Correcting Codes (used in voice communication) • Error-Detecting Codes (used in data communication) Sender receives a positive acknowledgment if data received correctly and negative ack to ask for retransmission. • What to do if sent frame is completely lost? Solution is to use a timer slightly larger than round-trip delay. If sender doesn’t receive ack it retransmits. There is a possibility that receiver receives the same frame twice. To avoid that the frames are numbered in increasing order and each frame carries this (sequence) number. EETS 7304
Hamming Distance Hamming distance d: the number of bits in which two words differ. To mistaken one word with the other at least d bits must be in error. Hamming distance of the code: theminimum Hamming distance between any two code words. For error detection with d bit error the code must have distance d+1. S1 S2 are two valid code words. R is the word received. Since not within the set of valid words it is an error. We have no way to say whether R is S1 or S2. Hence error detection. R S1 S2 d + 1 d d For error correction with d bit error the code must have distance 2d+1. EETS 7304
Error Correction R S1 S2 2d + 1 d d Code with hamming distance 2d + 1 is capable of error correction within d or less erroneous bits. If R is received we say that the sending code word is S2. EETS 7304
110 111 100 101 010 011 000 001 Hamming code corrects single bit errors m - word bits r - check bits n = m + r code bits Example: m = 1 n = 3 r = 2 For single bit error correction: each valid word has n bit pattern dedicated to it (obtained by one bit change in a valid word). Therefore (n+1)*2m <= 2n. (m + r + 1)*2m <= 2m+r. m+r+1 <= 2r • m r • 2 complete • 3 • 3 • 3 complete • 7 4 • 1000 10 EETS 7304
Hamming (11,7) Code Coding Decoding: the position of error bit = 8*p4 + 4*p3 + 2*p2 + p1 -> 8 + 2 + 1 = 11. EETS 7304
Use of a Hamming code to correct burst errors Words are sent leftmost column first then the next column etc. If the burst error (burst <= 12) occurs it can be recovered by Hamming correction code. EETS 7304
Cyclic Redundancy Check Error Detecting Codes Only words (represented as a single number) that are divisible by given divisor are valid. In modulo arithmetic there is finite number of these words. They are evenly spaced (equidistant from each other). Say all number up to 100 divisible by 7 are legal. Coding: transform message M word into code word T using generator polynomial G. Assume we want to send M = 50. • Multiply M*10 -> 500 (10 is the order of G) • Divide M*10 : G -> 500 : 7 = 71 + 3/7 -> 500 = 71*7 + 3 (remainder) • Subtract remainder from M*10 -> T = 500 – 3 = 497 (certainly divisible by 7). Decoding: T/G -> 497/7 = 71 (good word divisible by 7) EETS 7304
CRC codes G(x) is generating polynomial of degree r. M(x) is a message word of degree m > r. Coding • Append r 0’s to the M(x) -> xr M(x). • Divide modulo 2: xr M(x) : G(x) = Q(x) + R(x)/G(x) • T(x) = xr M(x) - R(x).(Certainly divisible by G(x)) On the next slide G(x) = x4 + x + 1 = 10011 -> r = 4. M(x) = x9 + x8 + x6 + x4 + x3 + x + 1 = 1101011011 -> m = 9. • x4M(x) = 11010110110000 • R(x) = x4M(x) : G(x) = 1110 = x3 + x2 + x < G(x) • T(x) = x4M(x) + R(x) = 11010110111110 (certainly divisible by G(x)). EETS 7304
Analysis of CRC coding: choice of G(x) Decoding: Receiver calculates the remainder: (T(x) + E(x))/G(x) = E(x)/G(x). • Single bit error: E(x) = xi . If G(x) contains 2 or more terms xi will never be divisible by G(x) => single error is always detected. • Double error: E(x) = xi + xj =xj(xi-j + 1) -> xk + 1 (0 < k < frame length) • G(x) = x15 + x14 + 1 detects double errors up to 32768 frame length. …. • Polynomial coding with r check bits will detect all burst errors with the burst error length <= r. CRC calculations are performed on a fly by shift registers with feedback that is determined by G(x). EETS 7304
Elementary Data Link Protocols • An Unrestricted Simplex Protocol • A Simplex Stop-and-Wait Protocol • A Simplex Protocol for a Noisy Channel EETS 7304
protocol.h (type declarations) Continued EETS 7304
protocol.h (function declarations) EETS 7304
Unrestricted Simplex Protocol Message Sequence Chart receiver1 sender1 data-frame data-frame EETS 7304
receiver2 sender2 data-frame ack-frame data-frame ack-frame Simplex Stop-and-Wait Protocol Sender waits for ack before sending next frame. Message Sequence Chart EETS 7304
A Simplex Protocol for a Noisy Channel A Positive Ack with Retransmission PAR or Automatic Repeat reQuest ARQ Introduction of sending sequence number. Message Sequence Chart receiver3 sender3 I(0) time- out A(0) I(1) A(1) Continued EETS 7304
A Simplex Protocol for a Noisy Channel (cont.) Message Sequence Chart receiver3 sender3 I(0) time- out A(0) I(1) A(1) EETS 7304
Sliding Window Protocols So far protocol is correct, however, with poor performance (= channel utilization). • A One-Bit Sliding Window Protocol • A Protocol Using Go Back N • A Protocol Using Selective Repeat EETS 7304
Sliding Window Protocols (2) A sliding window of size 1, with a 3-bit sequence number. (Shadowy segment means pending.) (a) Initially. (b) After the first frame has been sent. (c) After the first frame has been received. (d) After the first acknowledgement has been received. EETS 7304
A One-Bit Sliding Window Protocol Continued EETS 7304
A One-Bit Sliding Window Protocol (2) Two scenarios for protocol 4. The notation is (seq, ack, packet number). An asterisk indicates where a network layer accepts a packet. • Normal case. • Abnormal case (messages sent twice: not error but waste of bandwidth). EETS 7304
Pipelining for long round-trip delays • Frame length = 1000 bits • Speed = 50 bps • Round-trip delay = 500 ms • Trans time = 20 ms • Channel efficiency = 20/520 = 4% • 25 additional frames can be sent In general: • Frame length = l bits • Speed = b bps • Round-trip delay = R ms • Channel efficiency = l/(l + bR) • Window size = (R + l/b)/(l/b) = Rb/l + 1 = number of outstanding (unacklnowledged frames). 20 ms fr1 fr3 520 ms ack1 fr26 t EETS 7304
Pipelining and error recovery • Go back n delivers in sequence without buffering. (b) Selective repeat Receiver must have buffer of window size. EETS 7304
Sliding Window Protocol Using Go Back N a c b Continued EETS 7304
Sliding Window Protocol Using Go Back N Continued EETS 7304
Sliding Window Protocol Using Go Back N Continued EETS 7304
Sliding Window Protocol Using Go Back N EETS 7304
Sliding Window Protocol Using Go Back N (2) Simulation of multiple timers in software. EETS 7304
A Sliding Window Protocol Using Selective Repeat Continued EETS 7304
A Sliding Window Protocol Using Selective Repeat (2) Continued EETS 7304
A Sliding Window Protocol Using Selective Repeat (3) Continued EETS 7304
A Sliding Window Protocol Using Selective Repeat (4) EETS 7304
A Sliding Window Protocol Using Selective Repeat (5) (a) Initial situation with a window size seven. (b) After seven frames sent and received, but not acknowledged. (c) Initial situation with a window size of four. (d) After four frames sent and received, but not acknowledged. EETS 7304
Protocol Verification • Finite State Machined Models • Petri Net Models EETS 7304
Finite State Machined Models (a) State diagram for protocol 3. (b) Transmissions. EETS 7304
A Petri net model for protocol 3 EETS 7304
Example Data Link Protocols • HDLC – High-Level Data Link Control • The Data Link Layer in the Internet EETS 7304
High-Level Data Link Control Frame format for bit-oriented protocols. EETS 7304
High-Level Data Link Control (2) Control field of (a) An information frame. (b) A supervisory frame (ack, nack). (c) An unnumbered frame. EETS 7304