Professional Documents
Culture Documents
Functions of DLL
• Providing a well-defined service interface to the network
layer.
• Dealing with transmission errors.
• Regulating the flow of data so that slow receivers are not
swamped by fast senders.
3
By Pavan Poudel
Data Flow
• To the Network Layer, it looks as though the path to the new
machine happens at the DLL level, when it is really
happening at the physical level.
4
By Pavan Poudel
DLL Services
• Framing
▫ Encapsulate datagram into frame, adding header(MAC address)
and trailer(error control bits)
• Link Access
▫ Channel access for shared medium
• Flow control
▫ Pacing between adjacent sending and receiving nodes
• Error Detection
▫ Signal attenuation, noise may cause error
▫ On detection of error, receiver sends signal to sender for
retransmission
• Error Correction
▫ Receiver identifies and corrects bit errors without resorting to
retransmission
6
By Pavan Poudel
DLL Services
• DLL can offer many different services which may vary from
system to system.
• Types of DLL services:
▫ Unacknowledged connectionless service
▫ Acknowledged connectionless service
▫ Acknowledged connection-oriented service
7
By Pavan Poudel
Framing
• The usual approach is for the data link layer to break the bit
stream up into discrete frames and compute the checksum for
each frame .
• When a frame arrives at the destination, the checksum is
recomputed. If the newly-computed checksum is different
from the one contained in the frame, the data link layer knows
that an error has occurred and takes steps to deal with it.
• Breaking the bit stream up into frames is more difficult than it
at first appears. One way to achieve this framing is to insert
time gaps between frames, much like the spaces between
words in ordinary text.
11
By Pavan Poudel
Framing Methods
• Character count
• Flag bytes with byte stuffing
• Starting and ending flags, with bit stuffing
12
By Pavan Poudel
Character Count
• The trouble with this algorithm is that the count can be
garbled by a transmission error.
• For example, if the character count of 5 in the second frame
of (b) becomes a 7, the destination will get out of
synchronization and will be unable to locate the start of the
next frame.
• Even if the checksum is incorrect so the destination knows
that the frame is bad, it still has no way of telling where the
next frame starts.
• Sending a frame back to the source asking for a
retransmission does not help either, since the destination
does not know how many characters to skip over to get to the
start of the retransmission.
• For this reason, the character count method is rarely used
anymore.
14
By Pavan Poudel
Byte Stuffing
• It may easily happen that the flag byte's bit pattern occurs in
the data. This situation will usually interfere with the framing.
• One way to solve this problem is to have the sender's data
link layer insert a special escape byte (ESC) just before each
''accidental'' flag byte in the data.
• Same is done if escape byte/character itself is present in
message.
• The data link layer on the receiving end removes the escape
byte before the data are given to the network layer.
• This technique is called byte stuffing or character stuffing.
• Thus, a framing flag byte can be distinguished from one in the
data by the absence or presence of an escape byte before it.
• Problem:
▫ two communicating machine might use 8-bit or 16-bit
characters
17
By Pavan Poudel
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.
19
By Pavan Poudel
Error Control
Types of Error:
• Content Error :
1. Error in bits of data
2. Eg: 0 is received in place of 1
• Flow integrity error:
1. Data blocks missing
2. Loss during transmission
• On the basis of no. of bits error
▫ Single bit error : error in only one bit
10110 -> 10100
▫ Burst Error : error in two or more bits in a data unit
11001010->11011001
▫ Extra bits are added in order to detect/correct errors.
20
By Pavan Poudel
• Parity Checking
• Checksum Error Detection
• Cyclic Redundancy Check(CRC)
21
By Pavan Poudel
Even Parity
1 0 1 0 1 1 0 1 1 0 1 0 1 1 0 No. of 1’s = 5(Odd)
Odd Parity
22
By Pavan Poudel
Parity Checking
Parity
Even Parity
1 0 1 1 1 1 0 1 Even (but Error)
• Limitations:
• Cannot detect error in 2,4 or 6 bits
• Cannot correct the error (error location unknown)
• Not suitable for burst error which are more common
23
By Pavan Poudel
10101101
00101101 • Limitations:
Can only detect error but
11011010
Not able to correct error
10011101
101110111
Ignored
24
By Pavan Poudel
CRC
CRC Generator: Data 0 0 ……0
• Append n 0’s to the data unit where n is
1 less than the number of bits in the pre-
decided divisor(n+1 bit). Divisor (n+1)bits
CRC
CRC checker Received Codeword
Data CRC
• Received codeword is divided by same
(n+1) bit divisor which was used at the
transmitter.
Divisor (n+1)bits
• If remainder is zero, then the received
codeword is error free and hence should
be accepted. Remainder
• But non-zero remainder indicates If remainder is 0 then
presence of errors and hence there is no error
CRC Example
CRC Example
• Let’s assume that we have
received the same bits i.e.
T(x) = 11010110111110.
Now let’s check the
remainder by using XOR
method with G(x).
• Here Remainder is Zero
so, the frame is transmitted
successfully.
29
By Pavan Poudel
Hamming Code
Dec. no. Binary P1 P2 P4 P8
1 0001 X
2 0010 X
3 0011 X X
4 0100 X
5 0101 X X
6 0110 X X
7 0111 X X X
8 1000 X
9 1001 X X
10 1010 X X
11 1011 X X X
12 1100 X X
13 1101 X X X
14 1110 X X X
15 1111 X X X X
Hamming Code
32
By Pavan Poudel
Hamming Code
• Data To be encoded 10101101011
Hamming Code
• Encoded Data
34
By Pavan Poudel
Hamming Code
35
By Pavan Poudel
#Assignment
• Generate CRC code for data 110010101. The divisor is
10101. Also check whether there are errors in the
received codeword 1100101011011.
36
By Pavan Poudel
Flow Control
• Deals with the issue where sender sends data at higher rate
than receiver can receive
• One way is to implement buffer.
▫ Receiver should able to inform sender when the buffer is
full.
• Two approaches:
▫ Feedback-based flow control
Feedback to the sender telling how receiver is doing
▫ Rate-based flow control
Transfer rate is fixed by sender
Not used often in DLL
37
By Pavan Poudel
Duplex Protocol
• As opposed to sending information in only one direction, we
should make full use of the connection.
• Data is sent both ways
• We are already sending ACK back, so why not the data
• Use header to determine if it is data or ACK
• Piggybacking:
▫ Not to send separate frame for ACK rather, piggyback
ACK on next data frame
▫ Gives free ride to ACK and decrease overhead.
44
By Pavan Poudel
Sending Window
• At any instant, the sender is permitted to send frames with
sequence numbers in a certain range (the sending window)
46
By Pavan Poudel
Receiving Window
• The receiver maintains a receiving window corresponding to
the sequence numbers of frames that are accepted
47
By Pavan Poudel
Stop-and-wait ARQ
• Stop-and-Wait ARQ is an addition to the Stop-and-Wait flow
control protocol:
▫ Frames have 1-bit sequence numbers (SN = 0 or 1) i.e.
maximum window size = 1.
▫ Sender sends the frame and waits to get ACK.
▫ Receiver sends an ACK (1-SN) if frame SN is correctly
received.
▫ Sender waits for an ACK (1-SN) before transmitting the
next frame with sequence number 1-SN.
▫ Frame is retransmitted if transmitter receives negative
acknowledgement (NAK) or if no ACK is received for
certain time.
▫ Transmit next frame only after getting positive ACK for
previous frame.
50
By Pavan Poudel
Stop-and-wait protocol
Sender Receiver Sender Receiver
Data 0 Data 0
ACK 1 ACK 1
Data 1 Data 1
ACK 0
Stop-and-wait Protocol
Sender Receiver Sender Receiver
Data 0 Data 0
ACK 1 ACK 1
Data 1 Data 1
Time Out Lost
Time Out
ACK 0
Data 1 Lost
Data 1
ACK 0
ACK 0
Go-Back-n ARQ
• The sender keeps track of the outstanding frames and
updates the variables and windows as the ACKs arrive
• Allow transmitter to continuously send enough frames (frame
in window) and waits for acknowledgement.
• If a frame is damaged or lost, all the frames since last frame
acknowledged are re-transmitted.
• Increased efficiency due to pipelining.
0 1 2 3 4 5 3 4 5 6
0 1 2 3 4 5 3 4 5
Error
Discarded
55
By Pavan Poudel
Go-Back-n ARQ
Sender Receiver Sender Receiver
Data 0 Data 0
Data 1 Data 1
Lost
Data 2 Damaged Data 2
NAK 2 Frame
Retransmitted Discarded
Data 3 Data 3
Data 4 Data 4
Data 2
Retransmitted Data 2
Data 3 Data 3
1 2 3 4 5 6 7 3 8 9 10 Transmitter
NAK
Receiver 1 2 3 4 5 6 7 3 8 9 10
Damaged Retransmitted
59
By Pavan Poudel