Data link layer
Data link layer
05/12/2024 4
Data Link Layer Design Issues
• Framing
• Error control
• Flow control
Data Link Layer
• Algorithms for achieving:
• Reliable,
• Efficient, communication of a whole units – frames (as opposed to bits –
Physical Layer) between two machines.
• Two machines are connected by a communication channel that acts conceptually
like a wire (e.g., telephone line, coaxial cable, or wireless channel).
• Essential property of a channel that makes it “wire-like” connection is that the bits
are delivered in exactly the same order in which they are sent.
Data Link Layer
• For ideal channel (no distortion, unlimited bandwidth and no delay) the job of data
link layer would be trivial.
• 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 Data Link Layer are:
1. Providing a well-defined service interface to the network layer.
2. Dealing with transmission errors.
3. Regulating the flow of data so that slow receivers are not swamped by fast
senders.
• Data Link layer
– Takes the packets from Physical layer, and
– Encapsulates them into frames
Data Link Layer Design Issues
• Each frame has a
– frame header – a field for holding the packet, and
– frame trailer.
• Frame Management is what Data Link Layer does.
• Example: Ethernet, Voice over IP, etc. in all the communication channel were real
time operation is more important that quality of transmission.
Acknowledged Connectionless Service
• Each frame send by the Data Link layer is acknowledged and the sender knows if a
specific frame has been received or lost.
• Typically the protocol uses a specific time period that if has passed without getting
acknowledgment it will re-send the frame.
• 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
• Source and Destination establish a connection first.
• Each frame sent is numbered
• 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
received in the correct order.
• Examples:
• Satellite channel communication,
• Long-distance telephone communication, etc.
Acknowledged Connection
Oriented Service
• Three distinct phases:
1. Connection is established by having both side initialize variables and
counters needed to keep track of which frames have been received and which
ones have not.
2. One or more frames are transmitted.
3. Finally, the connection is released – freeing up the variables, buffers, and
other resources used to maintain the connection.
Framing
• 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.
• Errors could be:
• Number of received bits does not match number of transmitted bits (deletion or
insertion)
• Bit Value
• It is up to data link layer to correct the errors if necessary.
18
Framing
• Transmission of the data link layer starts with breaking up the bit stream
• into discrete frames
• Computation of a checksum for each frame, and
• Include the checksum into the frame before it is transmitted.
• 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.
19
Framing Methods
1.Byte count.
20
Byte Count Framing Method
• 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 will get out of synch with transmission.
• Destination may be able to detect that the frame is in error but it does not have a
means (in this algorithm) how to correct it.
21
Byte Count Framing Method
A byte stream. (a) Without errors. (b) With one error.
22
Flag Bytes with Byte Stuffing
Framing Method
• This methods gets around the boundary detection of the frame by having each
appended by the frame start and frame end special bytes.
• 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.
23
Flag Bytes with Byte Stuffing Framing
Method
• A frame delimited by flag bytes.
• Four examples of byte sequences before and after byte stuffing.
24
Flag Bits with Bit Stuffing
Framing Method
• This methods achieves the same thing as Byte Stuffing method by using Bits (1)
instead of Bytes (8 Bits).
• 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.
• USB uses bit stuffing.
25
Flag Bits with Bit Stuffing Framing
Method
Bit stuffing:
• The original data.
• The data as they appear on the line.
• The data as they are stored in the receiver’s memory after destuffing.
26
Physical layer coding violations
• Some Redundancy
• Some LAN’s encode 1 bit of data by using 2 physical bits.
• 1 bit-high-low Used for data
• 0-Bit- Low- high
• High-High and Low-Low combinations are used to indicate start and end of
frames.
27
Flow Control
• Important Design issue for the cases when the sender is running on a fast powerful
computer and receiver is running on a slow low-end machine.
• Two approaches:
28
Feedback-based Flow Control
• Receiver sends back information to the sender giving it permission to send more
data, or
29
Rate-based Flow Control
• Built in mechanism that limits the rate at which sender may transmit data, without
the need for feedback from the receiver.
30
Flow Control Techniques
• Sliding Window
31
Stop and Wait Flow Control
• In the Stop-and-wait method, the sender waits for an acknowledgement after every
frame it sends.
• When acknowledgement is received, then only next frame is sent. The process of
alternately sending and waiting of a frame continues until the sender transmits the
EOT (End of transmission) frame.
• Advantage of Stop-and-wait
• The Stop-and-wait method is simple as each frame is checked and acknowledged
before the next frame is sent.
• Disadvantage of Stop-and-wait
• Stop-and-wait technique is inefficient to use as each frame must travel across all the
way to the receiver, and an acknowledgement travels all the way before the next
frame is sent. Each frame sent and received uses the entire time needed to traverse the
link.
32
Stop and Wait Flow Control
33
Sliding Window Flow Control
• The Sliding Window is a method of flow control in which a sender can transmit
the several frames before getting an acknowledgement.
• In Sliding Window Control, multiple frames can be sent one after the another due
to which capacity of the communication channel can be utilized efficiently.
• A single ACK acknowledge multiple frames.
• Sliding Window refers to imaginary boxes at both the sender and receiver end.
• The window can hold the frames at either end, and it provides the upper limit on
the number of frames that can be transmitted before the acknowledgement.
• Frames can be acknowledged even when the window is not completely filled.
34
Sliding Window Flow Control
Sender Window
• At the beginning of a transmission, the sender window contains n-1 frames, and
when they are sent out, the left boundary moves inward shrinking the size of the
window. For example, if the size of the window is w if three frames are sent out,
then the number of frames left out in the sender window is w-3.
• Once the ACK has arrived, then the sender window expands to the number which
will be equal to the number of frames acknowledged by ACK.
• For example, the size of the window is 7, and if frames 0 through 4 have been sent
out and no acknowledgement has arrived, then the sender window contains only
two frames, i.e., 5 and 6. Now, if ACK has arrived with a number 4 which means
that 0 through 3 frames have arrived undamaged and the sender window is
expanded to include the next four frames. Therefore, the sender window contains
six frames (5,6,7,0,1,2).
35
Sliding Window Flow Control
36
Sliding Window Flow Control
Receiver Window
• At the beginning of transmission, the receiver window does not contain n frames, but it contains n-
1 spaces for frames.
• When the new frame arrives, the size of the window shrinks.
• The receiver window does not represent the number of frames received, but it represents the
number of frames that can be received before an ACK is sent. For example, the size of the window
is w, if three frames are received then the number of spaces available in the window is (w-3).
• Once the acknowledgement is sent, the receiver window expands by the number equal to the
number of frames acknowledged.
• Suppose the size of the window is 7 means that the receiver window contains seven spaces for
seven frames. If the one frame is received, then the receiver window shrinks and moving the
boundary from 0 to 1. In this way, window shrinks one by one, so window now contains the six
spaces. If frames from 0 through 4 have sent, then the window contains two spaces before an
acknowledgement is sent.
37
Sliding Window Flow Control
38
Error Control
• After solving the marking of the frame with start and end the data link layer has
to handle eventual errors in transmission or detection.
• Ensuring that all frames are delivered to the network layer at the destination
and in proper order.
• 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 when there is no response (positive or negative) from the Receiver .
Error Types
Types of Error:
1. Single Bit Error-In a single-bit error, only 1 bit in the data unit has changed.
2. Burst Error-A burst error means that 2 or more bits in the data unit have
changed.
Single-bit error
Burst error of length 8
The structure of encoder and
decoder
To detect or correct errors, we need to send extra (redundant) bits with data.
Error Detection and Correction
Two basic strategies to deal with errors:
2. Error detecting codes: Include only enough redundancy to allow the receiver
to deduce that an error has occurred (but not which error).
Error Detection and Correction
• Error codes are examined in Link Layer because this is the first place that we have
run up against the problem of reliability transmitting groups of bits.
• Codes are reused because reliability is an overall concern.
• The error correcting code are also seen in the physical layer for noise channels.
Basic approach used for error detection is the use of redundancy bits, where
additional bits are added to facilitate detection of errors.
Error-Detecting Codes
This scheme makes the total number of 1’s even, that is why it is called even parity
checking.
Simple Parity check
Checksum
•In checksum error detection scheme, the data is divided into k segments each of m
bits.
•In the sender’s end the segments are added using 1’s complement arithmetic to get
the sum. The sum is complemented to get the checksum.
•The checksum segment is sent along with the data segments.
•At the receiver’s end, all received segments are added using 1’s complement
arithmetic to get the sum. The sum is complemented.
•If the result is zero, the received data is accepted; otherwise discarded.
Checksum
Cyclic redundancy check (CRC)
• Unlike checksum scheme, which is based on addition, CRC is based on binary
division.
• In CRC, a sequence of redundant bits, called cyclic redundancy check bits, are
appended to the end of data unit so that the resulting data unit becomes exactly
divisible by a second, predetermined binary number.
• At the destination, the incoming data unit is divided by the same number. If at this
step there is no remainder, the data unit is assumed to be correct and is therefore
accepted.
• A remainder indicates that the data unit has been damaged in transit and therefore
must be rejected.
Cyclic redundancy check (CRC)
Cyclic redundancy check (CRC)
References
05/12/2024 56
THANK YOU
57