480 likes | 787 Views
The Data Link Layer. Chapter 3. Data Link Layer Design Issues. Services Provided to the Network Layer Framing Error Control Flow Control Addressing. Functions of the Data Link Layer. Provide service interface to the network layer Dealing with transmission errors Regulating data flow
E N D
The Data Link Layer Chapter 3
Data Link Layer Design Issues • Services Provided to the Network Layer • Framing • Error Control • Flow Control • Addressing
Functions of the Data Link Layer • Provide service interface to the network layer • Dealing with transmission errors • Regulating data flow • Slow receivers not swamped by fast senders • Clearly identify receiver (link may be shared)
Functions of the Data Link Layer (2) Relationship between packets and frames.
Services Provided to Network Layer (a) Virtual communication. (b) Actual communication.
Services Provided to Network Layer (2) Dest = 192.168.1.8 Placement of the data link protocol. 192.169.2.4 192.167.1.5 192.168.x.x
Framing A character stream. (a) Without errors. (b) With one error.
Framing – Byte Flag • A frame delimited by flag bytes. • Problem – how to deal with 16-bit character coding, e.g., UNICODE
Framing – Binary Flag • Flag = 0111,1110 (0x7E) • Bit stuffing – preclude this pattern from ever occurring in a data frame • What if frame boundary is lost? - just scan for the flag in the incoming frames • Frame can now be of any arbitrary size. (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.
Flow Control • Sender should keep pace with the receiver • Not too fast, not too slow • Feedback based flow control • Rate based flow control (not used in link layer protocols)
Error Detection and Correction • Error-Correcting Codes • Error-Detecting Codes • Hamming distance : between two binary numbers x and y • 00000,00000 00000,11111 11111,00000 11111,11111 • Hamming distance for the code book = 5 • log25 = 2 bit errors can be corrected • 00000,01010 Only these two bits could have gone wrong
Error-Correcting Codes Data bits = m; Check bits = r Each code of size n = (m+r) (n+1)2m2n or (m+r+1) 2r b1 b2b3b4b5b6b7b8b9b10b11 0 01 1 0 0 1 0 0 0 0 0 0000 1 0001 2 0010 3 0011 4 0100 5 0101 6 0110 7 0111 8 1000 9 1001 10 1010 11 1011 • Hamming code: 1-bit ECC • How to use Hamming code to correct burst errors? 8421
Error-Detecting Codes • Polynomial code (a.k.a. CRC) checksum computation. • Binary data & generator • Polynomial representation: ith binary position = xi,i = 0,1,2,..,n • Arithmetic is done modulo 2 • Normally, T(x)/G(x) = 0 • [T(X) + E(x)]/G(x) 0 • 1-bit error E(x) = xi • 2-bit errors E(x) = xi+xj = xj(xi-j + 1) • G(x) should not be divisible by x & G(x) does not divide xk + 1 • x15 +x14+ 1 will not divide xk + 1 for k < 32768
Error Correction or Error Detection? • If channel is of poor quality, use error correction • If channel is of better quality, prefer error detection + retransmission • 1000 bit frame, 10 bits for ECC = 1010 bits/frame • Versus 1001 bits for error detection • 1 Mbit payload ( 1000 frames), 10-6 BER • 1000 x 1010 (EC) versus 1000x1001 + 1001
Elementary Data Link Protocols • An Unrestricted Simplex Protocol • A Simplex Stop-and-Wait Protocol • A Simplex Protocol for a Noisy Channel
Protocol Definitions Continued
Protocol Definitions(ctd.) Say, frame arrival Send ack, L3 L2 L2 ED/ECC L1 L1 Frame arrival
Unrestricted Simplex Protocol 3 2 sender1() recv1() 1
Simplex Stop-and-Wait Protocol • L3 takes finite time to process a received packet • Or, L2 does not have infinite buffer space • As in Protocol #1: error free assumption • Main problem: Prevent sender from flooding the receiver • If receiver requires T secs. to process a frame on an average, the sender’s average frame send rate should be1/T • Main issue: Asynchronous operation
A Simplex Protocol for a Noisy Channel • Main problem: Frames can be lost (due to errors, overflows, etc.) • A positive acknowledgement with retransmission protocol • What if ACK frame itself is lost? • Can a timer based solution work? • Timer solution may result in duplicate frames being delivered to L3. • L2AL2BL3B; • L2B(ack) L2A; • L2A times out, retransmits • L2AL2BL3B; (Dup) Continued
A Simplex Protocol for a Noisy Channel (ctd.) • A +ve ACK with retransmission protocol. • Receiver should be able to detect duplicate frames • Frame header – label each frame with a unique sequence number • Header is small – what is minimum size of the seq# field? • Sequence# = {0,1} i.e., 1-bit long • These are called ARQ or PAR protocols. • ACK received OK • ACK frame was damaged/DNA (*)
Duplex Operation: Sliding Window Protocols • Data frames are sent both ways (AB & BA) • Simplex, Half duplex, Full duplex • Both sides ACK received frames • Data or ACK frames can get lost • Piggyback ACK frame to a data frame(delayed ACK) • Implies data frame will ready to send in a short time (?) • A One-Bit Sliding Window Protocol • A Protocol Using Go Back N • A Protocol Using Selective Repeat
Sliding Window Protocols (2) • Sender maintains Swin • Receiver maintains Rwin • Frame(s) to be sent must have send_seq# within Swin • Receiver is permitted to accept frames that fall within its Rwin • After every successful send/recv, windows are incremented. • Number of frames in transit = windows size A sliding window of size 1, with a 3-bit sequence number. (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.
A One-Bit Sliding Window Protocol # of the last frame received OK Continued
A One-Bit Sliding Window Protocol (ctd.) receive send
A One-Bit Sliding Window Protocol (2) Two scenarios for protocol 4. (a) Normal case. (b) Abnormal case. The notation is (seq, ack, packet number). An asterisk indicates where a network layer accepts a packet. ‘A’ is ACKing ‘1’, Whereas, ‘B’ sent seq# 1! So?
A Protocol Using Go Back N 7 6 5 4 4 4 3 2 1 0 (available send window size) • Problem of “long thin pipe”, e.g., slow satellite channel • 50kpbs, 1000 bit frame, 500ms RTT • Line utilization = • l/(l+bR) • L = frame size • b = bit rate • R = RTT • If l << bR << 50% efficiency Pipelining and error recovery. Effect on an error when (a) Receiver’s window size is 1. (However, sender has to buffer) (b) Receiver’s window size is large. (c) Window size = MAX_SEQ
Sliding Window Protocol Using Go Back N Continued
Sliding Window Protocol Using Go Back N Continued
Sliding Window Protocol Using Go Back N Continued
Sliding Window Protocol Using Go Back N (2) Simulation of multiple timers in software.
A Sliding Window Protocol Using Selective Repeat Continued
A Sliding Window Protocol Using Selective Repeat (2) Continued
A Sliding Window Protocol Using Selective Repeat (3) Continued
A Sliding Window Protocol Using Selective Repeat (5) 0 1 0 x 1 0 6 (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. • Receive windows size should be < ½(seq # cardinality) 6 7 6 7 0 0 1 4 1 5 5 6 duplicate
Protocol Verification • Finite State Machined Models • FSM is 4-tuple <S, M, I, T> • S: set of states (e.g., frame to send, expected receive frame, frame on the channel {0/1/A/-}) • M: set of frames • I: initial state • T: set of transitions • Petri Net Models • PN is a bijection of places and transitions • Places are connected to transition (and vice-a-versa) via directed arcs\ • Petri net captures concurrency very well
Finite State Machined Models (a) State diagram for protocol 3. (b) Transitions. (errors not considered) Original already delivered to L3 • Reachability analysis: protocol errors can be detected • Reaching a state in which no action is specified (incompleteness) • Reaching state(s) from where no progress can be made (deadlock) • Untenable events can be easily captured (Extraneous events)
Petri Net Models A Petri net with two places and two transitions.
Petri Net Models (2) • BD AC • A AC • AD BE • B BE • C • D • E • CF DF • EG DG • CG DF • EF DG A Petri net model for protocol 3.
Example Data Link Protocols • HDLC – High-Level Data Link Control • The Data Link Layer in the Internet
High-Level Data Link Control Frame format for bit-oriented protocols. • HDLC Stations & Configurations • Primary Station • Secondary Station • Combined Station • HDLC Configurations • Unbalanced Configuration (primary + stationary, full/half duplex) • Balanced Configuration (both ends are primary/secondary) • Symmetrical Configuration (both ends have primary+secondary) • HDLC Operational Modes • Normal Response Mode(NRM) (sec. only sends response, when instructed,UBC) • Asynchronous Response Mode(ARM) (sec. can send any time, no permission) • Asynchronous Balanced Mode(ABM)
High-Level Data Link Control (2) Control field of (a) An information frame. (b) A supervisory frame. (c) An unnumbered frame. Type: 0 - Receive Ready 1 - NAK (Reject) 2 - Receive ~Ready 3 - Selective NAK
The Data Link Layer in the Internet A home personal computer acting as an internet host.
PPP – Point to Point Protocol The PPP full frame format for unnumbered mode operation. IP, IPX, XNS, Apple Talk datagram payload 0021 LCP control data C021 NCP control data 8021
PPP – Point to Point Protocol (2) A simplified phase diagram for bring a line up and down.
PPP – Point to Point Protocol (3) The LCP frame types.