Sunteți pe pagina 1din 50

Data Link Layer

Objectives
The data link layer transforms the physical
layer (a raw transmission facility) to a link
responsible for node-to-node (hop-to-hop)
communication.
Specific responsibilities of the data link
layer include framing, addressing, flow
control, error control, and media access
control.

Framing
The data link layer divides the stream of
bits received from the network layer into
manageable data units called frames.
The data link layer adds a header to the
frame to define the addresses of the sender
and receiver of the frame.

Flow control
If the rate at which the data are absorbed by
the receiver is less than the rate at which
data are produced in the sender, the data
link layer imposes a flow control
mechanism to avoid overwhelming the
receiver.

Error detection
The data link layer also adds reliability to
the physical layer by adding mechanisms to
detect and retransmit damaged, duplicate, or
lost frames.

Acess control
When two or more devices are connected to
the same link, data link layer protocols are
necessary to determine which device has
control over the link at any given time.

Position of the data-link layer

Data link layer duties

LLC and MAC sublayers

Error Detection
and Correction
Types of Errors
Detection
Correction

Basic concepts
Networks must be able to transfer data from
one device to another with complete accuracy.
Data can be corrupted during transmission.
For reliable communication, errors must be
detected and corrected.

Types of Errors

Single-bit error

Single bit errors are the least likely type of


errors in serial data transmission because
the noise must have a very short duration
which is very rare. However this kind of
errors can happen in parallel transmission.
Example:
If data is sent at 1Mbps then each bit lasts
only 1/1,000,000 sec. or 1 s.
For a single-bit error to occur, the noise
must have a duration of only 1 s, which is
very rare.

Burst error

The term burst error means that two or


more bits in the data unit have changed
from 1 to 0 or from 0 to 1.
Burst errors does not necessarily mean that
the errors occur in consecutive bits, the
length of the burst is measured from the
first corrupted bit to the last corrupted bit.
Some bits in between may not have been
corrupted.

Burst error is most likely to happen in serial


transmission since the duration of noise is
normally longer than the duration of a bit.
The number of bits affected depends on the data
rate and duration of noise.
Example:
If data is sent at rate = 1Kbps then a noise of 1/100 sec
can affect 10 bits.(1/100*1000)
If same data is sent at rate = 1Mbps then a noise of
1/100 sec can affect 10,000 bits.(1/100*106)

Error detection
Error detection means to decide whether the
received data is correct or not without having a
copy of the original message.
Error detection uses the concept of redundancy,
which means adding extra bits for detecting
errors at the destination.

redundancy
The central concept in detecting or correcting errors
is redundancy.
To be able to detect or correct errors, we need to
send some extra bits with our data.
These redundant bits are added by the sender and
removed by the receiver.
Their presence allows the receiver to detect or
correct corrupted bits.

Redundancy

Detection Vs correction
Correction of errors is more difficult than
detection.
In error detection, we are only looking
whether any error has occurred.
In error correction, we need to know exact
no. of bits that are corrupted & their
location in message.

Forward-error-correction vs. Retransmission


Forward error correction is the process in
which the receiver tries to guess the
message by using redundant bits.
Correction by retransmission is a technique
in which the receiver detects the occurrence
of an error and asks the sender to resend the
message.

Coding
Redundancy is achieved through various
coding schemes.
The sender adds redundant bits through a
process that creates a relationship between
the redundant bits and the actual data bits.
The receiver checks the relationships
between the two sets of bits to detect or
correct the errors.

Block Coding
Message is divided into blocks, each of k-bits called
datawords.
We add r redundant bits to each block to make
length n = k+r (where n-bit blocks are called
codewords).
We can create combination of 2k datawords & 2n
codewords.
2n - 2k codewords are not used (called invalid).

Error Detection
Following 2 conditions must be met:

Each codeword can get corrupted.


If received codeword is valid, then it is
accepted and dataword is extracted for use.
Otherwise, it is discarded.

Hamming Distance

Minimum Hamming Distance

We can look at this geometrically.


Let sent codeword is x which is at centre of circle with
radius s.
All other received codewords created by 1 to s errors are
points within or on circle.
All valid codes must be outside circle.

Linear Block codes


Simple Parity-check code:
k-bit dataword is changed to n-bit codeword
where n = k + 1
Extra-bit is called parity bit.
It is selected to make total no. of 1s in
codeword even.

Checksum
The checksum is used in the Internet by
several protocols although not at the data
link layer.
Like linear codes, the checksum is based on
the concept of redundancy.

For example, if the set of numbers is (7, 11,


12, 0, 6), we send (7, 11, 12,0,6,36), where
36 is the sum of the original numbers.

We can make the job of the receiver easier


if we send the negative (complement) of the
sum, called the checksum.
In this case, we send (7, 11, 12,0,6, -36).
The receiver can add all the numbers
received (including the checksum). If the
result is 0, it assumes no error; otherwise,
there is an error.

Checksum

At the sender
The unit is divided into k sections, each of n
bits.
All sections are added together using ones
complement to get the sum.
The sum is complemented and becomes the
checksum.
The checksum is sent with the data

At the receiver
The unit is divided into k sections, each of n
bits.
All sections are added together using ones
complement to get the sum.
The sum is complemented.
If the result is zero, the data are accepted:
otherwise, they are rejected.

Performance
The checksum detects all errors involving an
odd number of bits.
It detects most errors involving an even number
of bits.
If one or more bits of a segment are damaged
and the corresponding bit or bits of opposite
value in a second segment are also damaged, the
sums of those columns will not change and the
receiver will not detect a problem.

Error Correction
It can be handled in two ways:
1) receiver can say to the sender to
retransmit the entire data unit.
2) The receiver can use an error-correcting
code, which automatically corrects certain
errors.

Single-bit error correction


To correct an error, the receiver reverses the value
of the altered bit. To do so, it must know which bit
is in error.
Number of redundancy bits needed
Let data bits = m
Redundancy bits = r
Total message sent = m+r
The value of r must satisfy the following relation:

2r m+r+1

Error Correction

Hamming Code

Hamming Code

Hamming Code

Example of Hamming Code

Single-bit error

Error
Detection

S-ar putea să vă placă și