Data Link Layer
Data Link Layer
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
.
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.
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
Error detection means to decide whether the received data is correct or not without
having a copy of the original message.
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
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-
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,
23 ≥ 4 + 3 + 1
HAMMING CODE
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