You are on page 1of 33

DATA LINK LAYER

TE COMPS A
THE SECOND LAYER (DLL)
 Deals with algorithms for achieving reliable, efficient communication of whole units of
information called frames between two adjacent machines.
 Communication channels make errors sometimes, they have only a finite data rate, and there is a
nonzero propagation delay between the time a bit is sent and the time it is received - These limitations
have important implications for the efficiency of the data transfer.
 DLL protocols take these functions into consideration
DATA LINK LAYER DESIGN ISSUES

oThe data link layer uses the services of the physical layer to send and receive bits over
communication channels. It has a number of functions:
o Providing services to the network layer
o Framing
o Error Control
o Flow Control
o Physical Addressing
o Access Control
 Reliable delivery: : Data Link Layer provides a reliable delivery service, i.e., transmits the network
layer datagram without any error. A reliable delivery service is accomplished with retransmissions
and acknowledgements.
CONNECTIONLESS & CONNECTION-ORIENTED
SERVICES

Unacknowledged connectionless service consists of having the source machine send


independent frames to the destination machine without having the destination machine
acknowledge them. .
When acknowledged connectionless service is offered, there are still no logical
connections used, but each frame sent is individually acknowledged.
When connection-oriented service is used, transfers go through three distinct
phases. In the first phase, the connection is established by having both sides initialize
variables and counters needed to keep track of which frames have been received and
which ones have not. In the second phase, one or more frames are actually transmitted.
In the third and final phase, the connection is released, freeing up the variables,
buffers, and other resources used to maintain the connection.
PROVIDING SERVICES TO THE NETWORK
LAYER:
 1 Unacknowledged connectionless service .
 Appropriate for low error rate and real-time traffic. Ex: Ethernet
 2. Acknowledged connectionless service.
 Useful in unreliable channels, Wi-Fi. Ack/Timer/Resend
 3. Acknowledged connection-oriented service:
 Guarantee frames are received exactly once and in the right order. Appropriate over
long, unreliable links such as a satellite channel or a long distance telephone circuit

 .
FRAMING

 To provide service to the network layer, the data link layer must use the service provided to it by the
physical layer.
 If the channel is noisy, as it is for most wireless and some wired links, the physical layer will add some
redundancy to its signals to reduce the bit error rate to a tolerable level..
 The usual approach is for the data link layer to break up the bit stream into discrete frames, compute a
short token called a checksum for each frame, and include the checksum in the frame when it is
transmitted.
 Breaking up the bit stream into frames requires a good design. We will look at four methods:
 1. Byte count.
 2. Flag bytes with byte stuffing.
 3. Flag bits with bit stuffing.
 4. Physical layer coding violations.
1. BYTE COUNT (FRAMING METHOD)

The first framing method uses a field in the header to specify the number of bytes in the
frame. When the data link layer at the destination sees the byte count, it knows how
many bytes follow and hence where the end of the frame is.

A byte stream.
(a) Without errors.

(b) With one error.


2. FLAG BYTES WITH BYTE STUFFING.

 This framing method gets around the problem of resynchronization after an error by having each
frame start and end with special bytes.
 Often the same byte, called a flag byte, is used as both the starting and ending delimiter.
 Two consecutive flag bytes indicate the end of one frame and the start of the next. Thus, if the
receiver ever loses synchronization it can just search for two flag bytes to find the end of the
current frame and the start of the next frame.

 A problem we have to solve: It may happen that the flag byte occurs in the data, especially when
binary data such as photographs or songs are being transmitted.
2. FLAG BYTES WITH BYTE STUFFING.(2)

 One way to solve this problem of ‘‘accidental’’ flag byte in the data is to have the sender’s data link
layer insert a special escape byte (ESC) just before each flag byte in the data. Thus, a framing flag byte
can be distinguished from one in the data by the absence or presence of an escape byte before it.
 The data link layer on the receiving end removes the escape bytes before giving the data to the network
layer. This technique is called byte stuffing.

Four examples of
byte sequences
before and after
byte stuffing.
3. FLAG BITS WITH BIT STUFFING.

 The third method of delimiting the bit stream gets around a disadvantage of byte stuffing,
which is that it is tied to the use of 8-bit bytes. Framing can be also be done at the bit level, so
frames can contain an arbitrary number of bits made up of units of any size.
 Each frame begins and ends with a special bit pattern, 01111110 or 0x7E in hexadecimal. This
pattern is a flag byte.
 Whenever the sender’s data link layer encounters five consecutive 1s in the data, it
automatically stuffs a 0 bit into the outgoing bit stream. This bit stuffing is analogous to byte
stuffing, in which an escape byte is stuffed into the outgoing character stream before a flag
byte in the data.
 When the receiver sees five consecutive incoming 1 bits, followed by a 0 bit, it automatically
destuffs (i.e., deletes) the 0 bit.
 For Example: If the user data contain the flag pattern, 01111110, this flag is transmitted as
011111010 but stored in the receiver’s memory as 01111110.
3. FLAG BITS WITH BIT STUFFING… EXAMPLES

 Bit stuffing.
 (a) The original data. (b) The data as they appear on the line.
 (c) The data as they are stored in the receiver’s memory after destuffing.
4. PHYSICAL LAYER CODING VIOLATIONS.

 This method of framing is only applicable to networks in which the encoding on the physical
medium contains some redundancy.
 For example, 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 scheme means that every data bit has a transition in
the middle, making it easy for the receiver to locate the bit boundaries.

 The combinations high-high and low-low are not used for data but are used for delimiting frames in
some protocols.
MANCHESTER & DIFFERENTIAL MANCHESTER
ELEMENTARY DATA LINK PROTOCOLS: SIMPLEST PROTOCOL

 Problems:
 The sender sends a sequence of frames
without even thinking about the
receiver.
 Data are transmitted in one direction
only.
 Assumes:
• both sender & receiver always ready.
• Processing time can be ignored.
• Infinite buffer space is available.
 And above all, the communication
channel between the data link layers
never damages or loses frames.
ERROR DETECTION AND CORRECTION

 Types of Errors: Whenever bits flow from one point to another, they are subject to
unpredictable changes because of interference. This interference can change the
shape of the signal.
 The term single-bit error means that only 1 bit of a given data unit (such as a byte,
character, or packet) is changed from 1 to 0 or from 0 to 1.
 The term burst error means that 2 or more bits in the data unit have changed from 1
to 0 or from 0 to 10. Figure 10.1 shows the effect of a single-bit and a burst error on a
data unit.
TYPES OF ERRORS:

single-bit error

burst error

Multiple bit errors


TYPES OF ERRORS
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 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.
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,000bits.
(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 CHECKS

 Four types of redundancy checks are used


in data communications
VERTICAL REDUNDANCY CHECK -VRC

It can detect single bit error


It can detect burst errors only if the
total number of errors is odd.
LONGITUDINAL REDUNDANCY CHECK -LRC

 LCR increases the likelihood of detecting burst errors.


 If two bits in one data units are damaged and two bits in exactly
the same positions in another data unit are also damaged, the
LRC checker will not detect an error.
VRC AND LRC
CYCLIC REDUNDANCY CHECK -CRC

 Given a k-bit frame or message, the transmitter generates an n-bit sequence, known as a frame
check sequence (FCS), so that the resulting frame, consisting of (k+n) bits, is exactly divisible by
some predetermined number.
 The receiver then divides the incoming frame by the same number and, if there is no remainder,
assumes that there was no error.
CYCLIC REDUNDANCY CHECK

The algorithm for computing the CRC is as follows:

1. Let r be the degree of G(x). Append r zero bits to the


low-order end of the frame so it now contains m + r
bits and corresponds to the polynomial M(x).

2. Divide the bit string corresponding to G(x) into the bit


string corresponding to M(x). using modulo 2 division.

3. Subtract the remainder (which is always r or fewer


bits) from the bit string corresponding to M(x). using
modulo 2 subtraction. The result is the checksummed
frame to be transmitted. Call its polynomial T(x).
EXAMPLE CALCULATION OF THE CRC.
CHECKSUM

At the sender
The unit is divided into k sections, each of n bits.
All sections are added together using one’s
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 one’s
complement to get the sum.
The sum is complemented.
If the result is zero, the data are accepted:
otherwise, they are rejected.
CHECKSUM EXAMPLE-

 Consider the data unit to be transmitted is-

10011001111000100010010010000100
 Assume 8 bit checksum is used.

 Step-01:
 At sender side,
 The given data unit is divided into segments of 8 bits as-
 Now, all the segments are added and the result is obtained as-
o 10011001 + 11100010 + 00100100 + 10000100 = 1000100011
o Since the result consists of 10 bits, so extra 2 bits are wrapped around.
o 00100011 + 10 = 00100101 (8 bits)
o Now, 1’s complement is taken which is 11011010.
o Thus, checksum value = 11011010
CHECKSUM EXAMPLE-

 Step-02:
 The data along with the checksum value is transmitted to the receiver.

 Step-03:
 At receiver side,

o The received data unit is divided into segments of 8 bits.


o All the segments along with the checksum value are added.
o Sum of all segments + Checksum value = 00100101 + 11011010 = 11111111
o Complemented value = 00000000
o Since the result is 0, receiver assumes no error occurred in the data and therefore accepts it.
HAMMING CODE – ERROR CORRECTION
The hamming code uses the number of redundant bits depending on the number
of information bits in the message.
Let n be the number of information or data bits, then the number of redundant
bits P is determined from the following formula,
2P ≥ k + P + 1
 For example, if 4-bit information is to be transmitted, then k=4. The number of
redundant bits is determined by the trial and error method.
 Let P=2, we get,
 22 ≥ 4 + 2 + 1
 The above equation implies 4 not greater than or equal to 7. So let’s choose another value of
P=3.

 23 ≥ 4 + 3 + 1
HAMMING CODE

The steps involved to perform encoding of hamming codes are as follows:


1. First, perform the calculation for the total number of redundant bits required to be added
with the given message bits. The number of redundant bits can be obtained by:

P is the number of parity bits,


K is the number of information bits.
2. Once the number of redundant bits is detected then we have to check for the positions
where the redundant bits are to be placed.
Note: The redundant bits within the message bits are placed at those positions which are
powers of 2.
3. Now, determine the value of redundant bits to be inserted at the positions determined in
the previous step.
EXAMPLE FOR ENCODING

 1. Let the message be m = = 11010 and it is to be transmitted after encoding with


even parity. calculating the number of redundant bits using

 For P =3, 23 ≥ 5 + 3 + 1 = Not satisfied


 For P = 4, 24 ≥ 5 + 4 + 1 = Satisfied
 So, we will take P = 4 for k = 5
 2. The parity bits will be present at positions
 which are powers of 2 i.e., 20, 21, 22, 23, 24,
 and so on.
EXAMPLE…
 3. Lastly, we have to find the parity bits that are to be placed at the above-determined
positions. Hence the value of parity bits from the data bits will be determined as:
 P1 = D 3 D 5 D 7 D 9
 P2 = D 3 D 6 D 7
 P4 = D 5 D 6 D 7
 P8 = D 9

 4. P1 = 1 P2 = 1 P4 = 0 P8 = 1

 5. So, placing the parity bits within the hamming code along with data bits we will get,
111010011
TITLE LOREM IPSUM DOLOR

LOREM IPSUM DOLOR LOREM IPSUM DOLOR LOREM IPSUM DOLOR


SIT AMET. SIT AMET SIT AMET

You might also like