Chapter 2_CN
Chapter 2_CN
Data-link layer is the second layer after physical layer. The data link layer is responsible for maintaining the data link
between two hosts or nodes.
Before going through the design issues in data link layer. Some of its sub-layers and their functions are as following below.
Framing
Error control
Flow control
DATA LINK LAYER
Algorithms for achieving:
Reliable, +
Efficient,
Two machines are connected by a communication channel that acts conceptually like a
Essential property of a channel that makes it “wire-like” connection is that the bits are
For ideal channel (no distortion, unlimited bandwidth and no delay) the job of data
However, limited bandwidth, distortions and delay makes this job very difficult.
DATA LINK LAYER DESIGN ISSUES
• Physical layer delivers bits of information to and from data link layer. The functions of
3. Regulating the flow of data so that slow receivers are not swamped by fast senders.
– frame trailer.
Principal Service Function of the data link layer is to transfer the data from the
network layer on the source machine to the network layer on the destination
machine.
Process in the network layer that hands some bits to the data link layer for
transmission.
Job of data link layer is to transmit the bits to the destination machine so they
can be handed over to the network layer there (see figure in the next slide).
NETWORK LAYER SERVICES
Example: Ethernet, Voice over IP, etc. in all the communication channel were real
Typically the protocol uses a specific time period that if has passed without getting
This service is useful for commutation when an unreliable channel is being utilized (e.g.,
802.11 WiFi).
Network layer does not know frame size of the packets and other restriction of the data link
layer. Hence it becomes necessary for data link layer to have some mechanism to optimize
the transmission.
ACKNOWLEDGED CONNECTION ORIENTED SERVICE
Data link layer guarantees that each frame sent is indeed received.
It guarantees that each frame is received only once and that all frames are
Examples:
3. Finally, the connection is released – freeing up the variables, buffers, and other
resources used to maintain the connection.
FRAMING
The data link layer needs to pack bits into frames, so that each frame is distinguishable from another. Our
postal system practices a type of framing. The simple act of inserting a letter into an envelope separates
one piece of information from another; the envelope serves as the delimiter.
To provide service to the network layer the data link layer must use the service provided to it by physical
layer.
Stream of data bits provided to data link layer is not guaranteed to be without errors.
Number of received bits does not match number of transmitted bits (deletion or insertion)
Bit Value
Receiver computes its checksum error for a receiving frame and if it is different from
the checksum that is being transmitted will have to deal with the error.
1.Byte/Character count.
It uses a field in the header to specify the number of bytes in the frame.
Once the header information is being received it will be used to determine end of
the frame.
Trouble with this algorithm is that when the count is incorrectly received the
Destination may be able to detect that the frame is in error but it does not have
This methods gets around the boundary detection of the frame by having each
If they are the same (beginning and ending byte in the frame) they are called flag
byte.
If the actual data contains a byte that is identical to the FLAG byte (e.g., picture,
data stream, etc.) the convention that can be used is to have escape character
inserted just before the “FLAG” character.
FRAMING (2)
This methods achieves the same thing as Byte Stuffing method by using Bits (1)
Whenever the sender’s data link layer encounters five consecutive 1s in the data
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.
FRAMING
Many data link protocols use a combination of presented methods for safety.
For example in Ethernet and 802.11 each frame begin with a well-defined pattern
called a preamble.
It is technique that generally observes proper flow of data from sender to receiver.
Important Design issue for the cases when the sender is running on a fast powerful
Two approaches:
In this control technique, sender simply transmits data or information or frame to receiver,
then receiver transmits data back to sender and also allows sender to transmit more
amount of data or tell sender about how receiver is processing or doing.
This simply means that sender transmits data or frames after it has received
acknowledgments from user.
Receiver sends back information to the sender giving it permission to send more data, or
In this control technique, usually when sender sends or transfer data at faster
speed to receiver and receiver is not being able to receive data at the speed, then
mechanism known as built-in mechanism in protocol will just limit or restricts
overall rate at which data or information is being transferred or transmitted by
sender without any feedback or acknowledgment from receiver.
ERROR
Transmission error.
Error detection and correction are implemented either at the data link layer or the
1. Single-bit error
2. Burst error
TYPES OF ERROR
The only one bit of a given data unit is changed from 1 to 0 or from 0 to 1.
1. Burst error
The two or more bits are changed from 0 to 1 or from 1 to 0 is known as Burst Error.
The Burst Error is determined from the first corrupted bit to the last corrupted bit.
The duration of noise in Burst Error is more than the duration of noise in Single-Bit.
Burst Errors are most likely to occur in Serial Data Transmission.
The number of affected bits depends on the duration of the noise and data rate.
ERROR CONTROL
After solving the marking of the frame with start and end the data link layer has to
Ensuring that all frames are delivered to the network layer at the destination and
in proper order.
Before expiry of this timer acknowledgement from receiver must reach to the sender.
To prevent from receiving same frames by receiver sender assign a sequence number to the frame.
If the Sender Receives positive Acknowledgment it will know that the frame has
arrived safely.
Timer and Frame Sequence Number for the Sender is Necessary to handle the case
2. Checksum
4. LRC
PARITY CHECKING(VRC)
Parity bit means nothing but an additional bit added to the data at the transmitter
before transmitting the data. Before adding the parity bit, number of 1’s or zeros is
calculated in the data. Based on this calculation of data an extra bit is added to the
actual information / data. The addition of parity bit to the data will result in the change
of data string size.
This means if we have an 8 bit data, then after adding a parity bit to the data binary
errors.
In this technique, a redundant bit is also known as a parity bit which is appended
at the end of the data unit so that the number of 1s becomes even. Therefore, the
total number of transmitted bits would be 9 bits.
If the number of 1s bits is odd, then parity bit 1 is appended and if the number of
1s bits is even, then parity bit 0 is appended at the end of the data unit.
At the receiving end, the parity bit is calculated from the received data bits and
Parity check bits are computed for each row, which is equivalent to the single-
parity check.
In Two-Dimensional Parity check, a block of bits is divided into rows, and the
At the receiving end, the parity bits are compared with the parity bits computed
1) Checksum Generator
Checksum generator subdivides the data into equal segments of n bits each, and all
The sum is complemented and appended to the original data, known as checksum field.
nd each of n bits.
2) Checksum Checker
The Receiver follows the given steps:
A Checksum is verified at the receiving
The block unit is divided into k sections and e
side.
ach of n bits.
The receiver subdivides the incoming data
All the k sections are added together by using
into equal segments of n bits each, and all
one's complement algorithm to get the sum.
these segments are added together, and
then this sum is complemented. The sum is complemented.
If the complement of the sum is zero, then If the result of the sum is zero, then the data i
the data is accepted otherwise data is s accepted otherwise the data is discarded.
rejected.
EXAMPLE
EXAMPLE
CYCLIC REDUNDANCY CHECK (CRC)
CRC is a redundancy error technique used to determine the error.
In CRC technique, a string of n 0s is appended to the data unit, and this n number is less than the
Secondly, the newly extended data is divided by a divisor using a process is known as binary
division.
Thirdly, the CRC remainder replaces the appended 0s at the end of the original data.
The receiver receives the data followed by the CRC remainder. The receiver will treat this whole
unit as a single unit, and it is divided by the same divisor that was used to find the CRC
CYCLIC REDUNDANCY CHECK (CRC)
If the resultant of this division is zero
A CRC generator uses a modulo-2 division. Firstly, three zeroes are appended at the end of
the data as the length of the divisor is 4 and we know that the length of the string 0s to be
appended is always one less than the length of the divisor.
Now, the string becomes 11100000, and the resultant string is divided by the divisor
1001.
The remainder generated from the binary division is known as CRC remainder. The
CRC remainder replaces the appended string of 0s at the end of the data unit, and the
CRC GENERATOR-EXAMPLE-1
CRC CHECKER
CRC Checker
When the string 11100111 is received at the receiving end, then CRC checker
In this case, CRC checker generates the remainder of zero. Therefore, the data is
accepted.
CRC CHECKER – EXAMPLE-1
CRC CHECKER – EXAMPLE-2
ERROR CORRECTING TECHNIQUES
1.Hamming codes.
2. Binary convolutional codes.
3. Reed-Solomon codes.
4. Low-Density Parity Check codes.
ERROR CORRECTING TECHNIQUES
Hamming Code
Parity bits: The bit which is appended to the original data of binary bits so that the
Even parity: To check for even parity, if the total number of 1s is even, then the
value of the parity bit is 0. If the total number of 1s occurrences is odd, then the
value of the parity bit is 1.
Odd Parity: To check for odd parity, if the total number of 1s is even, then the value
of parity bit is 1. If the total number of 1s is odd, then the value of parity bit is 0.
HAMMING CODE
At the receiving end, the parity bits are recalculated. The decimal value of
Codeword: b1 b2 b3 b4 ….
Check bits: The bits that are powers of 2 (p1, p2, p4, p8, p16, …).
The rest of bits (m3, m5, m6, m7, m9, …) are filled with m data bits.
Example of the Hamming code with m = 7 data bits and r = 4 check bits is given in the next
slide.
THE HAMMING CODE
D - D - D - P (EVEN PARITY)
D D - - D P - (EVEN PARITY)
D D D P - - - (EVEN PARITY)
HAMMING CODE
Why Those Bits? - The three parity bits (1,2,4) are related to the data bits
(3,5,6,7) as shown at right. In this diagram, each overlapping circle corresponds
to one parity bit and defines the four bits contributing to that parity computation.
For example, data bit 3 contributes to parity bits 1 and 2. Each circle (parity bit)
encompasses a total of four bits, and each circle must have EVEN parity. Given
four data bits, the three parity bits can easily be chosen to ensure this condition.
It can be observed that changing any one bit numbered 1..7 uniquely affects the
three parity bits. Changing bit 7 affects all three parity bits, while an error in bit 6
affects only parity bits 2 and 4, and an error in a parity bit affects only that bit.
The location of any single bit error is determined directly upon checking the three
parity circles.
HAMMING CODE
HAMMING CODE
7 6 5 4 3 2 1
1 1 0 0 1 1 0 7-BIT CODEWORD
1 - 0 - 1 - 0 (EVEN PARITY)
1 1 - - 1 1 - (EVEN PARITY)
1 1 0 0 - - - (EVEN PARITY)
HAMMING CODES
When these seven bits are entered into the parity circles, it can be confirmed that the
choice of these three parity bits ensures that the parity within each circle is EVEN, as
shown here.
HAMMING CODE
• It may now be observed that if an error occurs in any of the seven bits, that error will
affect different combinations of the three parity bits depending on the bit position.
• For example, suppose the above message 1100110 is sent and a single bit error occurs
such that the codeword 1110110 is received:
The above error (in bit 5) can be corrected by examining which of the three parity bits was
affected by the bad bit:
HAMMING CODE
7 6 5 4 3 2 1
1 1 1 0 1 1 0 7-BIT CODEWORD
NOT
1 - 1 - 1 - 0 (EVEN PARITY) 1
!
1 1 - - 1 1 - (EVEN PARITY) OK! 0
NOT
1 1 1 0 - - - (EVEN PARITY) 1
!
HAMMING CODE
• In fact, the bad parity bits labeled 101 point directly to the bad bit since 101
binary equals 5. Examination of the 'parity circles' confirms that any single bit
error could be corrected in this way.
• The value of the Hamming code can be summarized:
1. Detection of 2 bit errors (assuming no correction is attempted);
2. Correction of single bit errors;
3. Cost of 3 bits added to a 4-bit message.
• The ability to correct single bit errors comes at a cost which is less than sending
the entire message twice. (Recall that simply sending a message twice
accomplishes no error correction.)
ERROR DETECTION CODES (2)
1. Simplex,
2. stop and wait,
3. Sliding window protocol
SIMPLEX
It is very simple.
The sender sends a sequence of frames without even thinking about the receiver.
To send three frames, three events occur at the sender site and three events at
Note that the data frames are shown by tilted boxes; the height of the box defines
the transmission time difference between the first bit and the last bit in the frame.
STOP AND WAIT PROTOCOL
Stop and wait protocol is data link layer protocol for transmission of
1. Sender side
2. Receiver side
expires
The sliding window is a technique for sending multiple frames at a time. It controls
the data packets between the two devices where reliable and gradual delivery of
data frames is needed. It is also used in TCP (Transmission Control Protocol).
In this technique, each frame has sent from the sequence number. The sequence
numbers are used to find the missing data in the receiver end. The purpose of the
sliding window technique is to avoid duplicate data, so it uses the sequence
number.
SLIDING WINDOW PROTOCOL
So sender can send next frame , and move little bit of sliding window
ONE-BIT SLIDING WINDOW PROTOCOL (2)
So sender can send next frame , and move little bit of sliding window
ONE-BIT SLIDING WINDOW PROTOCOL (3)
So sender can send next frame , and move little bit of sliding window
SLIDING WINDOW PROTOCOL
In this figure, Frame 0,1,2 are already sent and acknowledgement, frame 3,4,5,6
are sent but not acknowledged and frame 7,8,9,10 are not yet sent.
SLIDING WINDOW PROTOCOL
lost, all subsequent frames have to received within an agreed upon time period ,
But if there is a lot of error in the frame, lots of on the receiving negative acknowledgment.
bandwidth loss in sending the frames again. There is no waiting for any time-out to send
that frame.
So, we use the Selective Repeat ARQ protocol. In
The design of the Selective Repeat ARQ
this protocol, the size of the sender window is
protocol is shown below.
SELECTIVE REPEAT ARQ
SELECTIVE REPEAT ARQ
A high-level data link control (HDLC) is a protocol that is a bit-oriented synchronous data
link layer.
HDLC ensures the error-free transmission of data to the proper destinations and controls
A high-level data link control defines rules for transmitting data between network points.
Data in an HDLC is organized into units called frames and is sent across networks to
specified destinations.
HDLC (CONTINUE..)
HDLC also manages the pace at which data is transmitted.
HDLC is commonly used in the open systems interconnection (OSI) model's layer 2.
HDLC frames are transmitted over synchronous links or asynchronous links, which do not
This is done using a frame delimiter or flag, which contains unique sequence of bits that are
Flag
Address
Control information
This frame is generally used for transporting user data from network layer.
These frames actually carry actual data or information of upper layer and some control
information.
This frame carries data along with both send sequence number and an acknowledgment
number.
Balanced Mode).
These frames are basically required and essential for error control and flow control.
number.
These frames are also required in various functions like link setup and disconnections.
These frames basically support control purposes and are not sequenced.
These frames are also used for different miscellaneous purposes along with link
management.
This frame does not include any type of acknowledgment information i.e. in turn it