Functions of the Data Link Layer
• Provide service interface to the network layer
• Dealing with transmission errors• Error detection and correction codes• Positive and negative acknowledgements• Timers
• Regulating data flow• Slow receivers not swamped by fast senders
Data Link Layer Services
• Unacknowledged connectionless service
• Acknowledged connectionless service
• Acknowledged connection-oriented service
Frame Delimiting
• Character count
• Flag bytes with byte stuffing
• Starting and ending flags, with bit stuffing
• Physical layer coding violations.
Framing
(a) A frame delimited by flag bytes.(b) Four examples of byte sequences before and after stuffing.
Framing
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.
Hamming Distance
• Hamming distance between codewords X and
Y, is the number of ones in
• The number of detected error is d if d+1 is the minimum Hamming distance between two codes.
• The number of detected error is d if 2d+1 is the minimum Hamming distance between two codes.
YX
Error Correction
• Codeword Y is calculated from generation matrix G, and block of data X:
Y=XG=[x1,x2,…,xm]·G
• At the receiver side the syndrom is found that detects and correct an error using check parity matrix H:
S=YHT
Error correction
• For generation and parity check matrices it should hold
GHT=0• If
G=[In-k|P]
Then
H=[-PT|Ik]
• Here I is unity matrix, n is the codeword length, and n-k is the data block length
Error correction: Hamming Code
• In Hamming code the codeword length is 2m-1, the number of added bits is 2m-1-m-1 • Parity check matrix comprises all possible column vectors. For example for m=3
1010101
1100110
1111000
Hamming Code: Solution
• Correct the bit-stream coded by Hamming code: 111100011001110010110
• Correct stream is 111000011001100010110
000
111
001
111
011
101
001
110
010
100
0110100
1110011
0001111
Hamming Code: Exercise
• Find the generation matrix for Hamming code (7,4), and encode bit stream 001011100.
Hamming Code: Solution
• Find the generation matrix for Hamming code (7,4), and encode bit stream 001011100.
0011001
0000111
0101010
1001011
G
Error Detection Code: CRC
• Data block and codeword represented by polynomials.
• If data block is X(x)=b0+b1x+…+bm-1xm-1, codeword is Y(x)=X(x)xk-mod(X(x), G(x)), where G(x) is a generator polynomial.
• At the receiver side, codeword polynomial is divided by G(x). If the reminder is non-zero, an error is detected.
Elementary Data Link Protocols
• An Unrestricted Simplex Protocol
• A Simplex Stop-and-Wait Protocol
• A Simplex Protocol for a Noisy Channel
Protocol Definitions
Continued
Some definitions needed in the protocols to follow. These are located in the file protocol.h.
Protocol Definitions(ctd.)
Some definitions needed in the
protocols to follow. These are located in the file protocol.h.
A Simplex Protocol for a Noisy Channel
A positive acknowledgement
with retransmission protocol.
Continued
A Simplex Protocol for a Noisy Channel (ctd.)
A positive acknowledgement with retransmission protocol.
Sliding Window Protocols
• A One-Bit Sliding Window Protocol
• A Protocol Using Go Back N
• A Protocol Using Selective Repeat
Sliding Window Protocols (2)
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 (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 Protocol Using Go Back N
Pipelining and error recovery. Effect on an error when
(a) Receiver’s window size is 1.
(b) Receiver’s window size is large.
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.
Example Data Link Protocols
• HDLC – High-Level Data Link Control
• The Data Link Layer in the Internet
High-Level Data Link Control (2)
Control field of
(a) An information frame.
(b) A supervisory frame.
(c) An unnumbered frame.