Chapter 3 The Data Link Layer
Data Link Layer Design Issues Services Provided to the Network Layer Framing Error Control Flow Control
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
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) The data link layer can be designed to offer various services: Unacknowledged connectionless service Acknowledged connectionless service Acknowledged connection-oriented service
Services Provided to Network Layer (3) Placement of the data link protocol.
Framing data link layer must use physical layer. physical layer accept a raw bit stream and attempt to deliver it to the destination. In destination, some bits may have different values and the number of bits received may be less than, equal to, or more than the number of bits transmitted. Data link layer must detect and, if necessary, correct errors. Framing: break up the bit stream into discrete frames and add checksum
Framing (2) Framing methods: Byte count Flag bytes with byte stuffing Flag bits with bit stuffing Physical layer coding violations
A character stream. (a) Without errors. (b) With one error. Framing (3) Byte count A character stream. (a) Without errors. (b) With one error.
PPP (Point-to-Point Protocol) Framing (4) Flag bytes with byte stuffing (a) A frame delimited by flag bytes. (b) Four examples of byte sequences before and after stuffing. PPP (Point-to-Point Protocol)
Framing (5) Flag bits with bit stuffing Bit stuffing Each frame begins and ends with a special bit pattern, 01111110 HDLC (High level Data Link Control) protocol 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.
Error Control reliable delivery Using feedback Ack (Acknowledgements) NAck (Negative Acknowledgements) Timer sequence numbers
Flow Control feedback-based flow control rate-based flow control ‘‘You may send me n frames now, but after they have been sent, do not send any more until I have told you to continue.’’
Error Detection and Correction Type of errors Single bit Burst Error-Correcting Codes FEC (Forward Error Correction) Error-Detecting Codes For highly reliable links, such as fiber
Error-Correcting Codes n-bit Codeword: n = m + r Code rate: m/n Hamming Distance: To reliably detect d errors, you need a distance d + 1 code to correct d errors, you need a distance 2d + 1 code
Error-Correcting Codes Example: 0000000000, 0000011111, 1111100000, and 1111111111 Hamming distance ??? Correct and detect ??? 0000000111 is Received. What was original frame? we want to design a code with m message bits and r check bits that will allow all single errors to be corrected.
Error-Correcting Codes Hamming code
Error-Correcting Codes Use of a Hamming code to correct burst errors.
Error-Correcting Codes Convolutional code are specified in terms of their rate and constraint length Are used as part of the GSM mobile phone system, in satellite communications, and in 802.11. the NASA convolutional code of r = 1/2 and k = 7
Error-Detecting Codes Parity Checksums Cyclic Redundancy Checks (CRCs)
Error-Detecting Codes Parity Problem with burst error Using rectangular matrix n bits wide and k bits high Interleaving A burst of length n + 1 will pass undetected
Error-Detecting Codes Checksums groups of parity bits
Error-Detecting Codes CRC Calculation of the polynomial code checksum.
Error-Detecting Codes CRC All single-bit errors will be detected. By making x + 1 a factor of G(x), we can catch all errors with an odd number of inverted bits. a polynomial code with r check bits will detect all burst errors of length ≤ r Use in Ethernet detects all bursts of length 32 or less detects all bursts affecting an odd number of bits
Elementary Data Link Protocols An Unrestricted Simplex Protocol Error-free Unrestricted buffers Without delay A Simplex Stop-and-Wait Protocol Flow control protocol Acknowledgement Data traffic Simplex Half duplex
Elementary Data Link Protocols A Simplex Protocol for a Noisy Channel Frames may be either damaged or lost completely Using Ack Using timer Using Sequence number How many bits are required ????? PAR (Positive Acknowledgment with Retransmission) ARQ (Automatic Repeat reQuest)
Link Utilization
Link Utilization Example: 50-kbps satellite channel with a 500-msec round-trip propagation delay Size of frames : 1000-bit The time which first frame has been completely sent: The time which first frame fully arrived: The time which first acknowledgement arrived back: t = 20 msec t = 270 msec t = 520 Sender was blocked 500/520 or 96% of the time. In other words, only 4% of the available bandwidth was used Solution : Pipelining
Sliding Window Protocols 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.
Sliding Window Protocols (2)
Sliding Window Enhancements Receiver can acknowledge frames without permitting further transmission (Receive Not Ready) Must send a normal acknowledge to resume If duplex, use piggybacking If no data to send, use acknowledgement frame If data but no acknowledgement to send, send last acknowledgement number again, or have ACK valid flag (TCP) bandwidth-delay product of the link : BD
Go Back N Based on sliding window If no error, ACK as usual with next frame expected Use window to control number of outstanding frames If error, reply with NACK Discard that frame and all future frames until error frame received correctly Transmitter must go back and retransmit that frame and all subsequent frames
Go Back N - Damaged Frame Receiver detects error in frame i Receiver sends NACK-i Transmitter gets NACK-i Transmitter retransmits frame i and all subsequent
Go Back N - Lost Frame (1) Frame i lost Transmitter sends i+1 Receiver gets frame i+1 out of sequence Receiver send NACK i Transmitter goes back to frame i and retransmits
Go Back N - Lost Frame (2) Frame i lost and no additional frame sent Receiver gets nothing and returns neither acknowledgement nor NACK Transmitter times out and sends acknowledgement frame with P bit set to 1 Receiver interprets this as command which it acknowledges with the number of the next frame it expects (frame i ) Transmitter then retransmits frame i
Go Back N - Damaged Acknowledgement Receiver gets frame i and send acknowledgement (i+1) which is lost Acknowledgements are cumulative, so next acknowledgement (i+n) may arrive before transmitter times out on frame i If transmitter times out, it sends acknowledgement with P bit set as before This can be repeated a number of times before a reset procedure is initiated
Go Back N - Damaged NACK ?
Go Back N - Diagram RR : Ready Receive Ack REJ : Reject Nack
Go Back N The maximum number of frames that may be outstanding at any instant is not the same as the size of the sequence number space The sender sends frames 0 through 7. A piggybacked acknowledgement for 7 comes back to the sender. The sender sends another eight frames, again with sequence numbers 0 through 7. Now another piggybacked acknowledgement for frame 7 comes in. Did all eight frames belonging to the second batch arrive successfully, or did all eight get lost?
Selective Repeat Also called Selective Reject or selective retransmission Only rejected frames are retransmitted Subsequent frames are accepted by the receiver and buffered Minimizes retransmission Receiver must maintain large enough buffer More complex logic in transmitter
Selective Repeat - Diagram
? Selective Repeat Limitation of windows size: For K-bit sequence number ?
Example Data Link Protocols HDLC – High-Level Data Link Control The Data Link Layer in the Internet
High-Level Data Link Control Bit-oriented Using bit stuffing techniques for redundancy Address use for detecting command/response in P2P line Sending just flags -> idle P2P line
High-Level Data Link Control (2) Control field of (a) An information frame. (b) A supervisory frame. (c) An unnumbered frame.
High-Level Data Link Control (3) Information frame Using sliding window with 3-bit Seq number Next : Use for piggybacking P/F : Poll/Final
High-Level Data Link Control (4) Supervisory frame Type 0 : Receive Ready (RR) Type 1 : Reject Next : First Frame which has received with error Type 2 : Receive Not Ready (RNR) Next : First Frame which has received with error. Stop sending Send RR or Reject for start Type 3 : Selective Reject
High-Level Data Link Control (5) Unnumbered frame Use for control Use for Sending data in Unreliable connection-less services 5 bit for Type DIS Connect (DISC) Set Normal Response Mode (SNRM) FRaMe Reject (FRMR) : Checksum is OK Number of bit is less than 32 Wrong Ack …
The Data Link Layer in the Internet A home personal computer acting as an internet host.
PPP – Point to Point Protocol PPP Features Separate packets (Framing), error detection Link Control Protocol (LCP) bringing lines up, testing them, negotiating options, and bringing them down again gracefully when they are no longer needed. Network Control Protocol (NCP) negotiate network-layer options in a way that is independent of the network layer protocol to be used
PPP – Point to Point Protocol PPP and HDLC PPP is character oriented PPP uses byte stuffing
PPP – Point to Point Protocol 11111111 is broadcast Control field indicates an unnumbered frame LCP can omit Address and Control Protocol field Codes starting with a 0 : IPv4, IPv6, IPX, AppleTalk, … Codes starting with a 1 : PPP configuration protocols (LCP, NCP) default length of Payload is 1500 bytes Padding may follow the payload if it is needed
PPP – Point to Point Protocol (2) A simplified phase diagram for bring a line up and down.
ADSL and ATM ?