Reference Model
Reference Model
Data Link layer• Data link Layer
– explicit in OSI– can be synchronous or asynchronous
• Reliable & Efficient Data Transfer (over a point-to-point link)– Error Detection, Error Recovery, Flow Control
• Protocol performance governed by– propagation delay– bit-rate & frame size– noise
• Provide service interface to the network layer• Regulating data flow
– Slow receivers not swamped by fast senders
(a) Virtual communication.(b) Actual communication.
Services offered to Network Layer
• Unacknowledged connectionless service
– Sender has no way of knowing if a frame has been successfully delivered
– No logical connection is established– Appropriate for low error rate and real-time traffic– Losses are taken care at higher levels– Used on reliable medium like coax cables or optical fiber, where
the error rate is low.– Appropriate for voice, where delay is worse than bad data.– Most LANs use it
Acknowledged Connectionless service
• Useful on unreliable medium like wireless.• Acknowledgements add delays.• Adding ack in the DLL rather than in the NL is just an
optimization and not a requirement. Leaving it for the NL is inefficient as a large message (packet) has to be resent in that case in contrast to small frames here.
• On reliable channels, like fiber, the overhead associated with the ack is not justified.
• No logical connection still, but each individual frame is acknowledged
• Appropriate for WLANs
Acknowledged Connection-oriented service
• Most reliable,
• Guaranteed service – Each frame sent is indeed received– Each frame is received exactly once– Frames are received in order
• Special care has to be taken to ensure this in connectionless services
1 2 3 4 5
Data Data Data
ACK/NAK
Data
1 2 3 4 5
Data Data Data Data
ACK/NAK
ACK/NAK
ACK/NAK
ACK/NAK
End to End
Hop by Hop
Data Link Frames
• General Frame format
Data Link Frames
• Start and End of frames need to be identified at the destination, so they should be marked
– Character counts– Start and ending flags with bit stuffing– Flag bytes with byte stuffing– Physical layer coding violation
Framing with Character Count
A character stream. (a) Without errors. (b) With one error.
Problem with Framing with CC
• What if the count is garbled
• Even if with checksum, the receiver knows that the frame is bad there is no way to tell where the next frame starts.
• Asking for retransmission doesn’t help either because the start of the retransmitted frame is not known
• No longer used
Framing with 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.
Framing with byte stuffing
Framing with byte stuffing
• Problem : fixed character size : assumes character size to be 8 bits : can’t handle heterogeneous environment.
Physical Layer codingviolations
• Some LANs encode 1 bit of data by using 2
physical bits– Normally, a 1 bit is a high-low pair and a 0 bit is a
low-high pair
– The start/end of a frame could be represented by
the signal low-low or high-high
• The advantage is that no extra bandwidth is
required as in byte stuffing• The IEEE 802.4 standard uses this approach
Types of Errors• Single-Bit Error
– only one bit in the data unit has changed• Burst Error
– 2 or more bits in the data unit have changed• Error Correcting Codes
– Include enough redundancy to detect and correct errors
– appropriate for unreliable channels• Error Detecting Codes
– Include enough redundancy bits to detect errors and use
– ACKs and retransmissions to recover from the errors
– Appropriate for reliable channels
Error Detection and Correction
• In some cases it is sufficient to detect an error and in some, it requires the errors to be corrected also. For eg.– On a reliable medium : ED is sufficient where
the error rate is low and asking for retransmission after ED would work efficiently
– In contrast, on an unreliable medium : Retransmission after ED may result in another error and still another and so on. Hence EC is desirable.
Redundancy
• Error detection uses the concept of redundancy, which means adding extra bits for detecting errors at the destination
Even-parity concept
NoteNote::
• In parity check, a parity bit is added to every data unit so that the total number of 1s is even (or odd for odd-parity).
• This method is called Vertical Redundancy Check
Example 1Example 1• Suppose the sender wants to send the word world. In ASCII
the five characters are coded as
1110111 1101111 1110010 1101100 1100100• The following shows the actual bits sent
11101110 11011110 11100100 11011000 11001001
• Now suppose the word world in Example 1 is received by the receiver without being corrupted in transmission.
11101110 11011110 11100100 11011000 11001001
•The receiver counts the 1s in each character and comes up with even numbers (6, 6, 4, 4, 4). The data are accepted.
• Now suppose the word world in Example 1 is corrupted during transmission.
• 11111110 11011110 11101100 11011000 11001001
• The receiver counts the 1s in each character and comes up with even and odd numbers (7, 6, 5, 4, 4). The receiver knows that the data are corrupted, discards them, and asks for retransmission.
NoteNote::
• Simple parity check can detect all Simple parity check can detect all single-bit errors. It can detect burst single-bit errors. It can detect burst errors only if the total number of errors errors only if the total number of errors in each data unit is odd.in each data unit is odd.
LRC
• In two-dimensional parity check, a block of bits is divided into rows and a redundant row of bits is added to the whole block.
Two-dimensional parity(Longitudinal redundancy check)
Example 2Example 2• Suppose the following block is sent: 10101001 00111001 11011101 11100111
10101010
• However, it is hit by a burst noise of length 8, and some bits are corrupted.
10100011 10001001 11011101 11100111 10101010
• When the receiver checks the parity bits, some of the bits do not follow the even-parity rule and the whole block is discarded.
10100011 10001001 11011101 11100111 10101010
CRC generator and checker
Binary division in a CRC generator
Binary division in CRC checker
Polynomial
Standard Polynomials
Name Polynomial Application
CRC-8CRC-8 x8 + x2 + x + 1 ATM header
CRC-10CRC-10 x10 + x9 + x5 + x4 + x 2 + 1 ATM AAL
ITU-16ITU-16 x16 + x12 + x5 + 1 HDLC
ITU-32ITU-32x32 + x26 + x23 + x22 + x16 + x12 + x11 + x10 + x8 + x7 + x5
+ x4 + x2 + x + 1LANs
Checksum
Checksum
• The sender follows these steps:The sender follows these steps:– The unit is divided into k sections, each of n The unit is divided into k sections, each of n
bits.bits.– All sections are added using one’s All sections are added using one’s
complement to get the sum.complement to get the sum.– The sum is complemented and becomes the The sum is complemented and becomes the
checksum.checksum.– The checksum is sent with the data.The checksum is sent with the data.
Checksum
• The receiver follows these steps:The receiver follows these steps:– The unit is divided into k sections, each of n The unit is divided into k sections, each of n
bits.bits.– All sections are added using one’s All sections are added using one’s
complement to get the sum.complement to get the sum.– The sum is complemented.The sum is complemented.– If the result is zero, the data are accepted: If the result is zero, the data are accepted:
otherwise, rejected.otherwise, rejected.
Checksum• Suppose the following block of 16 bits is to be
sent using a checksum of 8 bits. 10101001 00111001 • The numbers are added using one’s
complement 10101001 00111001
------------Sum 11100010
• Checksum 00011101• The pattern sent is 10101001 00111001
00011101
Checksum• Now suppose the receiver receives the pattern
sent in Example and there is no error. 10101001 00111001 00011101• When the receiver adds the three sections, it will
get all 1s, which, after complementing, is all 0s and shows that there is no error.
• 10101001• 00111001 • 00011101 • Sum 11111111 • Complement 00000000 means that the
pattern is OK.
Checksum
• Now suppose there is a burst error of length 5 that affects 4 bits.
10101111 11111001 00011101• When the receiver adds the three sections, it gets
1010111111111001 00011101
• Partial Sum 1 11000101• Carry 1• Sum 11000110 • Complement 00111001 the pattern is corrupted.
CorrectionCorrection
• Backword Error Control– Retransmission
• Forward Error Control– Single bit Error Correction– Burst Error Correction
Hamming Codes : for ED n EC
• m data bits together with r error check bits form an n = (m + r) bit codeword
• The number of bits two codeword differ in is called the hamming distance between the two codeword
• Significance : If two codeword are at HD d then it requires d single bit errors to convert one into the other
HD of a coding scheme
• For m bit data .. All the 2^m possible combinations are legal
• But not all the 2^m codewords are used -- in a coding scheme (algorithm to compute the check
bits) some of these codewords are legal and others are illegal
For eq .. Consider parity : 1(r = 1) parity bit is appended with value so that the total number of 1’s in the codeword is even ..
Then 11011 is a legal codeword in this scheme but 11010 is not
Use of HD for error detection
• To detect d single bit errors , we need (an algorithm that creates) a code list with HD at least d + 1
For eg . For the parity scheme .. HD is 2 ..hence it can be used to detect single bit errors (d=1)
• If the recvd codeword is legal .. We accept it ,• And if it is illegal we report (detect) an error
Remember : Each algorithm to compute the check bits create a different list of legal codewords
Data and redundancy bitsData and redundancy bitsHamming CodeHamming Code
Number ofdata bits
m
Number of redundancy bits
r
Total bits
m + r
11 2 3
22 3 5
33 3 6
44 3 7
55 4 9
66 4 10
77 4 11
Positions of redundancy bits in Hamming code
Redundancy bits calculation
Example of redundancy bit calculation
Error detection using Hamming code
Burst error correction example
Flow and Error ControlFlow and Error Control
• Flow Control Flow control refers to a set of procedures used to Flow control refers to a set of procedures used to
restrict the amount of data that the sender can restrict the amount of data that the sender can send before waiting for acknowledgment.send before waiting for acknowledgment.
• Error Control
Error control in the data link layer is based on Error control in the data link layer is based on automatic repeat request, which is the automatic repeat request, which is the retransmission of data (Backward Error Control).retransmission of data (Backward Error Control).
Flow Control
• Ensure sending entity does not overwhelm receiving entity
– By preventing buffer overflow• Influenced by:
– Transmission time• time taken to emit all bits into medium
– Propagation time• time for a bit to traverse the link• Assume here no errors but varying delays
Stop and Wait Flow Control
• Source transmits frame• Destination receives frame and replies with acknowledgement (ACK)• Source waits for ACK before sending next• Destination can stop flow by not send ACK• Works well for a few large frames• Stop and wait becomes inadequate if large block of data is split into small frames
Sliding Windows Flow Control
• Allows multiple numbered frames to be in transit
• Receiver has buffer W long
• Transmitter sends up to W frames without ACK
• ACK includes number of next frame expected
• Receiver can ack frames without permitting
further transmission (Receive Not Ready)
• Must send a normal acknowledge to resume
• If have full-duplex link, can piggyback ACks
Error Control
• Detection and correction of errors such as:
– Lost frames
– Damaged frames
• Common techniques use:
– Error detection
– Positive acknowledgment
– Retransmission after timeout
– Negative acknowledgement & retransmission
Elementary Data Link Protocols
• An Unrestricted Simplex Protocol
• A Simplex Stop-and-Wait Protocol
• A Simplex Protocol for a Noisy Channel
An Unrestricted Simplex Protocol• Transmitting and receiving NW layers are
always ready• Simplex transmission• Processing time ignored• Infinite buffer space• Error free channel• No sequence numbers and ACKs used• Sender
– Fetch a packet, construct a frame, send the frame
• Receiver– Receives the undamaged frame from the
physical layer.
A Simplex Stop-and-Wait Protocol
• Communication in one direction• Channel is assumed to be error free• Deals with
– preventing the sender from flooding the receiver with data faster than later is able to process them
• ACK is used– Sender sends data frame– Receiver sends ACK (dummy frame)– Sender sends the next frame
Stop-and-Wait ARQ for Noisy ChannelStop-and-Wait ARQ for Noisy Channel
Stop and Wait
• Source transmits single frame• Wait for ACK• If received frame damaged, discard it
– Transmitter has timeout– If no ACK within timeout, retransmit
• If ACK damaged,transmitter will not recognize it
– Transmitter will retransmit– Use alternate numbering and ACK0 / ACK1
Stop-and-Wait ARQ, lost frame
Stop-and-Wait ARQ, lost ACK frame
Stop-and-Wait ARQ, delayed ACK• In Stop-and-Wait ARQ, numbering frames prevents the In Stop-and-Wait ARQ, numbering frames prevents the
retaining of duplicate framesretaining of duplicate frames• Numbered acknowledgments are needed if an Numbered acknowledgments are needed if an
acknowledgment is delayed and the next frame is lostacknowledgment is delayed and the next frame is lost
Sliding Windows Flow Control
• Allows multiple numbered frames to be in transit• Receiver has buffer W long• Transmitter sends up to W frames without ACK• ACK includes number of next frame expected• Receiver can ack frames without permitting further transmission (Receive Not Ready)• Must send a normal acknowledge to resume• If have full-duplex link, can piggyback ACks
Piggybacking
• To increase the utilization of the link
• Frames in reverse direction carry the
Ack for received frames– No separate frames for Ack
Piggybacking
Go-Back-N ARQGo-Back-N ARQ
• Based on sliding window• If no error, ACK as usual• Use window to control number of outstanding frames• If error, reply with rejection
– 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 - Handling
• Damaged Frame– Error in frame i so receiver rejects frame i– Transmitter retransmits frames from i
• Lost Frame– Frame i lost and either
• Transmitter sends i+1 and receiver gets frame i+1 out of seq and rejects frame i• Or transmitter times out and send ACK with P bit set which receiver responds to with ACK i
– Transmitter then retransmits frames from i
Go Back N - Handling
• Damaged Acknowledgement– Receiver gets frame i, sends ack (i+1) which is lost– Acks are cumulative, so next ack (i+n) may arrive
before transmitter times out on frame i– If transmitter times out, it sends ack with P bit set– Can be repeated a number of times before a reset procedure is initiated
• Damaged Rejection– Reject for damaged frame is lost– Handled as for lost frame when transmitter times out
Go-Back-N ARQGo-Back-N ARQ
In Go-Back-N ARQ, the size of the sender In Go-Back-N ARQ, the size of the sender window must be less than 2window must be less than 2mm; the size ; the size
of the receiver window is always 1.of the receiver window is always 1.
Sender sliding window
Receiver sliding window
Control variables
Go-Back-N ARQ, normal operation
Go-Back-N ARQ, lost frame
Go-Back-N ARQ: sender window size
Selective-Repeat ARQSelective-Repeat ARQ
• Also called selective reject ARQ• 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• Hence less widely used• Useful for satellite links with long propagation delays
Selective Repeat ARQ, sender and receiver windows
Selective Repeat ARQ, lost frame
Selective Repeat ARQ
• In Selective Repeat ARQ, the size of the In Selective Repeat ARQ, the size of the sender and receiver window must be at sender and receiver window must be at most one-half of 2most one-half of 2mm..
Selective Repeat ARQ, sender window size
Buffer Requirement of ARQ• Stop-and-Wait:
– 1• Go-back-N:
–W+1• Selective Reject:
– 2W