Вы находитесь на странице: 1из 15

Data link layer

Framing
Error

control
Flow control

Framing
Data

link layer is supplied by data from network


layer ,break the bit stream in discrete frames
and compute checksum for each frame at TX and
Rx end ,any mismatch tells error has occur so
Correction is required
Framing techniques
Character count
Character stuffing
Bit stuffing

Character count
Header

field for each frame specifies count

value
of characters in that frame .so Rx knows by
reading count value how many characters
follow
before
frame
ends.
4
5
7
4
IET 5
DAVV
7 INDORE
If count is garbled in transmission Rx will get
out
of synchronization and unable to locate the
start of next frame.

Character stuffing
Each

frame start and ends with ASCII character


sequence DLE STX and DLE ETX.
DLE STX
IET
DLE ETX
If data itself contains DLE, data link layer inserts
an DLE for each accidental DLE in data
DLE STX I E DLE T DLE ETX
DLE STX
I E DLE DLE T DLE ETX
Disadv -Compel to make use of ASCII code while
network should be free to use arbitrary size
characters

Bit stuffing

Each frame begins and ends with a special bit


pattern called flag byte , 01111110
Whenever Tx has five consecutive 1s data link
layer stuffs 0 bit into the outgoing bit stream.
When the Rx sees five 1s followed by 0 it destuffs
0 and then stores.
TX has to send data 01111111010
Transmit data 01111110 011111011010 01111110
Rx data after deleting flag byte and stuffed bits
01111111010

Error control by data link layer


For

data transmission :
In simplex channel no retransmission canbe
requested hence error detect-correcting
codes
are used otherwise error detection followed
by retransmission is preferred since
overhead in earlier is more.
error detection and correction- Hamming
code

Hamming code

With m message bits and r redundant bits a frame


is formed n=m+r to detect single bit error
r bits needed for given m :2 r > m+r+1
The bits of codeword are numbered consecutively
starting with bit num 1from left or right end
Bits that are powers of 2 (1,2,4,8..) are check bits
Rest are filled up by message bits(3,5,6,7,9,..)
Data bit in position k contribute in determining the
value
of check bit
Each check bit forces parity of some collection of
bits, including itself to be even or odd.

Hamming code
When code word arrives,receiver initializes a
counter to 0.Examines each check bit x(1,2,4..)
for correct parity.if not ,it adds x to the counter.
If counter is 0 after all check bits have been
examined,code word is accepted as valid. if
counter is nonzero,it contains the number of bit
position in error so corrected by complement.
Hamming code can detect and correct single bit but
By arranging k code words in matrix form and
transmitting columnwise, burst error of length k
can be detected and corrected.

EXAMPLE
For

11 bit data ,format is m+r=11+4=15

bits
D15 D14 D13 D12 D11 D10 D9 P8 D7 D6 D5 P4 D3 P2 P1
P1 is set so that it establishes even parity
over bits(D3,D5,D7,D9,P1).P2 is set for
(2,3,6,7,10,11).P4 set for even parity over
bits(D5,D6,D7,P4)P8 (8,9,10,11)
At receiver each group is checked for even
parity
Bit position in error is find out and corrected
by inverting bit.
Data 1101 transmitted as

1100110
If Rx receives 1110110
apply error check

error check (x-oring)for


p1=1,p2=0,p4=1
1+4=5 bit 5 in error so
invert it and get
corrected.

ERROR DETECTING CODE


CRC :cyclic redundancy code/polynomial code
For k-bit message transmitter generates an n-bit
sequence called frame check sequence FCS
resulting frame consist of k+n bits which is exactly
divisible by some predetermined number.
Rx divides arrived frame by that same number,
If remainder is 0 assumes no error.
detect the error but cannot correct it.
Can detect single bit error
Any odd number of errors
Any burst error whose length is less than the
length of divisor polynomial.

Example-CRC

M=1011 , P= 101(msb,lsb should be 1)


FCS= ?(length atleast 1 less than divisor length ;2)
1001
101 101100
101
000100
(modulo-2 arithmatic)
101
001 remainder appended to M
So transmitted message is 101101 if any error occur
in transmission it will not get fully divisible at Rx
end.

CHECK SUM BYTE


Used by higher layer protocols. checksum generator
subdivides the data unit into equal segments of n bits.
These segments are added together using 1s
complement arithmatic (in which if carry generated by
msb again added to lower column) so that total is n
bit long.
The total sum is complemented and appeared to the
end of original data unit as redundancy bits called
checksum
field.this extended data unit is transmitted.
Receiver subdivides data unit as above and add all
segments together ,and complement it,if 0 no error.

example

Say Tx ->1010100100111001 (16 bits)


With checksum 8 bits 10101001
00111001
11100010
So checksum would be 00011101
Pattern sent 10101001 00111001 00011101

limitations :
Checksum detects all errors involving odd num of
bits as well as most of even number bits .but if
one or more segments are damaged and
corresponding bits of opposite value in second
segment are also damaged, error cannot be
detected.

Вам также может понравиться