COMPUTER NETWORKS
MODULE 2
Dr. TRIPTI C
DCS, RSET
Data link layer- Design Issues
• Provide a well-defined service interface to the network layer.
• Deal with errors in transmission of frames.
• Regulate the flow of data so that slow receivers are not overwhelmed
by fast senders.
• Framing of data.
• Detect and correct errors in frame data.
07/27/2025
FRAMING
• We are focusing on packet-switched networks, which means that blocks
of data (called frames at this level), not bit streams, are exchanged
between nodes.
• It is the network adaptor that enables the nodes to exchange frames.
Bits flow between adaptors, frames between hosts
FRAMING
• When node A wishes to transmit a frame to node B, it tells its adaptor
to transmit a frame from the node’s memory. This results in a sequence
of bits being sent over the link.
• The adaptor on node B then collects together the sequence of bits
arriving on the link and deposits the corresponding frame in B’s
memory.
• Recognizing exactly what set of bits constitute a frame—that is,
determining where the frame begins and ends—is the central challenge
faced by the adaptor
DATA LINK LAYER DESIGN ISSUES
• Services Provided to the Network
Layer
• Framing
• Error Control
• Flow Control
FUNCTIONS OF THE DATA LINK LAYER
• Provide service interface to the
network layer
• Dealing with transmission errors
• Regulating data flow
• Slow receivers not swamped by fast
senders
FUNCTIONS OF THE DATA LINK LAYER (2)
Relationship between packets and frames.
SERVICES PROVIDED TO NETWORK LAYER
(a) Virtual communication.
(b) Actual communication.
SERVICES PROVIDED TO NETWORK LAYER (2)
Placement of the data link protocol.
Types of services provided to the
Network Layer
Unacknowledged Connectionless service
Acknowledged Connectionless service
Acknowledged Connection-Oriented service
Unacknowledged Connectionless
service
Losses are taken care of at higher layers
Used on reliable medium like coax cables or optical fiber,
where the error rate is low.
Appropriate for voice, where delay is worse than bad
data.
Acknowledged Connectionless
service
Useful on unreliable medium like wireless.
Acknowledgements add delays.
Adding ack in the DLL rather than in the NL is just an optimization
and not a requirement. Leaving it for the NL is inefficient as a
large message (packet) has to be resent in that case in contrast
to small frames here.
On reliable channels, like fiber, the overhead associated with the
ack is not justified.
Acknowledged Connection-
oriented service
Most reliable,
Guaranteed service –
Each frame sent is indeed received
Each frame is received exactly once
Frames are received in order
Special care has to be taken to ensure this in
connectionless services
1. Service to Network
layer
• Main service is transferring data from network layer on the source
machine to network layer on the destination machine.
07/27/2025
Service to Network
layer
• Unacknowledged connectionless service
• Source machine send independent frames to the destination machine
without any acknowledgement policy.
• No logical connection established or released.
• If a frame is lost, no attempt to detect loss or recover it.
• Used in LANs.
Service to Network
layer
• Acknowledged connectionless service
• No logical connections used here also.
• Each frame sent is individually acknowledged.
• In case of a time-out, data will be sent again.
• Used in unreliable channels- wireless systems.
Service to Network
layer
• Acknowledged connection-oriented service
• Source and destination establish a connection before transferring data.
• Release connection after transfer of data.
• Each frame is numbered.
• Guaranteed delivery of frames.
• Ordered delivery of frames.
• Used in WAN subnets containing routers connected by point to point leased
telephone lines.
2. Error
Control
• Need to ensure frames are delivered to the destination network layer correctly in proper order.
• Use acknowledgements. Positive or negative from receiver.
• Chance of lost messages. So, no positive or negative ACK will come from receiver.
• Use timers. Start a timer at sender when a frame is transmitted.
• Timer is set to expire after an interval long enough for frame to reach destination, get processed
and ACK to propagate back to sender.
• If frame or ACK is lost. Then timer goes off. Then frame is retransmitted again.
• Chances of receiving same frame multiple times in time delays.
• Use sequence numbers for outgoing frames.
3. Flow
Control
• Senders can be running on a fast computer and the receivers on a slow computer.
• Sender pumps out frames at a high rate and receiver gets overwhelmed.
• Even if transmission is error free destination will be unable to handle the frames and
they get dropped off.
• Two solutions:
• Feedback based flow control
• Rate based flow control
Flow Control
Techniques
• Feedback based control • Rate based control
• Receiver sends back feedback information • Protocol has a built-in mechanism to limit
to sender. the rate at which sender may transmit data.
• Ask permission to send more data. • No feedbacks given.
• Depends on current status of receiver. • Rarely used.
4. Framing
• Data link layer encapsulates data into frames for transmission.
• Each frame has a frame header, payload field for holding the packets and a frame
trailer.
Frames
• A frame has the following parts:
• Frame Header − It contains the source, and the destination addresses of the frame.
• Payload field − It contains the message to be delivered.
• Trailer − It contains the error detection and error correction bits.
• Flag − It marks the beginning and end of the frame.
• Types of frame:
• Fixed size frames
• Variable size frames
Methods for
Framing
• Byte count
• Flag bytes with byte stuffing
• Starting and ending flags with bit stuffing
1. Byte Count
• Use a field in the header to specify number of bytes in the frame.
• Count can get garbled by a transmission error: unable to locate the correct start
of the next frame.
• Asking for retransmission to sender is of no use as well.
• Rarely used.
2. Flag Bytes
• Each frame starts and ends with special bytes- FLAG byte.
• Two consecutive flag bytes indicate end of one frame and start of next one.
• If receiver loses synchronization it can search for flag byte to get the end of the
current frame and start of the next frame.
• Flag byte bit pattern may occur in the data.
• This interferes with framing.
Flag Bytes with byte
stuffing
• Sender’s data link layer inserts a special escape byte(ESC) just before each
accidental flag byte in the data.
• Data link layer on receiving end removes the escape byte before the data is
given to network layer.
• If escape byte occurs in the data??
• It is also stuffed with an extra escape byte.
Flag Bytes with bit
stuffing
• Not all character codes are 8 bit. Eg: UNICODE-16 bits.
• Each frame begins and ends with a special pattern 01111110 (flag pattern).
• Whenever there are 5 consecutive 1s in the data, sender automatically stuffs a 0 in
the outgoing bit stream. It will be removed at destination data link layer.
• If user data contains the flag pattern 01111110 then it is transmitted as 011111010.
Error Detection and
Correction
• Unpredictable changes during transfer of data due to interference.
• Single bit error: only one bit of the data unit is changed.
• Burst error: 2 or more data bits have changed.
• Noise usually occurs as bursts rather than independent, single bit errors.
• Detecting and correcting errors requires redundancy sending additional
information along with the data.
• Redundancy is achieved through various coding schemes.
Error Detection and
Correction
• There are two types of attacks against errors:
• Error Detecting Codes:
• Check for whether error occurred or not.
• Error Correcting Codes:
• Need to know the exact number of bits that are corrupted and their location in
the message.
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
Four types of redundancy checks are used
in data communications
Vertical Redundancy Check
VRC
PERFORMANCE
It can detect single bit error
It can detect burst errors only if the total number of errors is odd.
Longitudinal Redundancy Check
LRC
Performance
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
CYCLIC REDUNDANCY CHECK
• 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.
Binary Division
Polynomial
Polynomial and Divisor
Standard Polynomials
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.
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 have the sender 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
THANK YOU!!!
07/27/2025