Data Link Layer
Data Link Layer
1. Actual Communication :
In this communication, physical medium is present through which Data Link Layer simply
transmits data frames. The actual path is Network Layer -> Data link layer -> Physical
Layer on sending machine, then to physical media and after that to Physical Layer -> Data
link layer -> Network Layer on receiving machine.
2. Virtual Communication :
In this communication, no physical medium is present for Data Link Layer to transmit
data. It can be only be visualized and imagined that two Data Link Layers are
communicating with each other with the help of or using data link protocol.
Types of Services provided by Data Link Layer :
The Data link layer generally provides or offers three types of services as given below :
1. Unacknowledged Connectionless Service
2. Acknowledged Connectionless Service
3. Acknowledged Connection-Oriented Service
• Detecting start of the frame: When a frame is transmitted, every station must be
able to detect it. Station detects frames by looking out for a special sequence of bits
that marks the beginning of the frame i.e. SFD (Starting Frame Delimiter).
• How does the station detect a frame: Every station listens to link for SFD pattern
through a sequential circuit. If SFD is detected, sequential circuit alerts station.
Station checks destination address to accept or reject frame.
• Detecting end of frame: When to stop reading the frame.
Types of framing – There are two types of framing:
1. Fixed size – The frame is of fixed size and there is no need to provide boundaries to the
frame, the length of the frame itself acts as a delimiter.
• Drawback: It suffers from internal fragmentation if the data size is less than the
frame size
• Solution: Padding
2. Variable size – In this, there is a need to define the end of the frame as well as the
beginning of the next frame to distinguish. This can be done in two ways:
10. Length field – We can introduce a length field in the frame to indicate the length of
the frame. Used in Ethernet(802.3). The problem with this is that sometimes the
length field might get corrupted.
11. End Delimiter (ED) – We can introduce an ED(pattern) to indicate the end of the
frame. Used in Token Ring. The problem with this is that ED can occur in the data.
This can be solved by:
12. 1. Character/Byte Stuffing: Used when frames consist of characters. If data contains
ED then, a byte is stuffed into data to differentiate it from ED.
13. Let ED = “$” –> if data contains ‘$’ anywhere, it can be escaped using ‘\O’ character.
–> if data contains ‘\O$’ then, use ‘\O\O\O$'($ is escaped using \O and \O is escaped
using \O).
Disadvantage – It is very costly and obsolete method.
2. Bit Stuffing: Let ED = 01111 and if data = 01111
–> Sender stuffs a bit to break the pattern i.e. here appends a 0 in data = 011101.
–> Receiver receives the frame.
–> If data contains 011101, receiver removes the 0 and reads the data.
Examples –
• If Data –> 011100011110 and ED –> 0111 then, find data after bit stuffing?
• –> 011010001101100
• If Data –> 110001001 and ED –> 1000 then, find data after bit stuffing?
• –> 11001010011
Data-link layer uses the techniques of error control simply to ensure and confirm
that all the data frames or packets, i.e. bit streams of data, are transmitted or
transferred from sender to receiver with certain accuracy. Using or providing
error control at this data link layer is an optimization, it was never requirement.
Error control is basically process in data link layer of detecting or identifying and
re-transmitting data frames that might be lost or corrupted during transmission.
In both of these cases, receiver or destination does not receive correct data-frame
and sender or source does not even know anything about any such loss regarding
data frames. Therefore, in such type of cases, both sender and receiver are
provided with some essential protocols that are required to detect or identify
such type of errors like loss of data frames.
The Data-link layer follows technique known as re-transmission of frames to
detect or identify transit errors and also to take necessary actions that are
required to reduce or remove such errors. Each and every time an effort is
detected during transmission, particular data frames retransmitted and this
process is known as ARQ (Automatic Repeat Request).
1. Stop-and-Wait ARQ :
Stop-and-Wait ARQ is also known as alternating bit protocol. It is one of
simplest flow and error control techniques or mechanisms. This mechanism is
generally required in telecommunications to transmit data or information
among two connected devices. Receiver simply indicates its readiness to receive
data for each frame. In these, sender sends information or data packet to
receiver. Sender then stops and waits for ACK (Acknowledgment) from receiver.
Further, if ACK does not arrive within given time period i.e., time-out, sender
then again resends frame and waits for ACK. But, if sender receives ACK, then it
will transmi next data packet to receiver and then again wait for ACK fro
receiver. This process to stop and wait continues until sender has no data frame
or packet to send.
Flow control is design issue at Data Link Layer. It is technique that generally observes
proper flow of data from sender to receiver. It is very essential because it is possible for
sender to transmit data or information at very fast rate and hence receiver can receive this
information and process it. This can happen only if receiver has very high load of traffic as
compared to sender, or if receiver has power of processing less as compared to sender.
Flow control is basically technique that gives permission to two of stations that are working
and processing at different speeds to just communicate with one another. Flow control in
Data Link Layer simply restricts and coordinates number of frames or amount of data
sender can send just before it waits for an acknowledgment from receiver. Flow control is
actually set of procedures that explains sender about how much data or frames it can
transfer or transmit before data overwhelms receiver.
The receiving device also contains only limited amount of speed and memory to store data.
This is why receiving device should be able to tell or inform the sender about stopping the
transmission or transferring of data on temporary basis before it reaches limit. It also needs
buffer, large block of memory for just storing data or frames until they are processed.
Approaches to Flow Control :
Flow Control is classified into two categories –
• This method is very easiest and simple and each of the frames is checked and
acknowledged well.
• It can also be used for noisy channels.
• This method is also very accurate.
Disadvantages –
• The main issue is complexity at the sender and receiver due to the transferring of
multiple frames.
• The receiver might receive data frames or packets out the sequence.
Error Detecting Codes (Implemented either at Data link layer or Transport Layer of OSI
Model)
Whenever a message is transmitted, it may get scrambled by noise or data may get
corrupted. To avoid this, we use error-detecting codes which are additional data added to a
given digital message to help us detect if any error has occurred during transmission of the
message.
Basic approach used for error detection is the use of redundancy bits, where additional
bits are added to facilitate detection of errors.
Some popular techniques for error detection are:
1. Simple Parity check
2. Two-dimensional Parity check
3. Checksum
4. Cyclic redundancy check
• 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.
4. Cyclic redundancy check (CRC)
Protocols
Write a short note on simplex stop and wait protocol for noiseless
channel
Stop – and – Wait protocol is data link layer protocol for transmission of frames over
noiseless channels. It provides unidirectional data transmission with flow control
facilities but without error control facilities.
This protocol takes into account the fact that the receiver has a finite processing speed.
If data frames arrive at the receiver’s end at a rate which is greater than its rate of
processing, frames be dropped out. In order to avoid this, the receiver sends an
acknowledgement for each frame upon its arrival. The sender sends the next frame only
when it has received a positive acknowledgement from the receiver that it is available
for further data processing.
Design
• Sender Site: The data link layer in the sender site waits for the network layer for
a data packet. It then checks whether it can send the frame. If it receives a positive
notification from the physical layer, it makes frames out of the data and sends it.
It then waits for an acknowledgement before sending the next frame.
• Receiver Site: The data link layer in the receiver site waits for a frame to arrive.
When it arrives, the receiver processes it and delivers it to the network layer. It
then sends an acknowledgement back to the sender.
•
Write a short note on stop and wait protocol for noisy channel
Simplex Stop – and – Wait protocol for noisy channel is data link layer protocol for data
communications with error control and flow control mechanisms. It is popularly known
as Stop – and –Wait Automatic Repeat Request (Stop – and –Wait ARQ) protocol. It
adds error control facilities to Stop – and – Wait protocol.
This protocol takes into account the facts that the receiver has a finite processing speed
and that frames may get corrupted while transmission. If data frames arrive at the
receiver’s end at a rate which is greater than its rate of processing, frames can be
dropped out. Also, frames may get corrupted or entirely lost when they are transmitted
via network channels. So, the receiver sends an acknowledgment for each valid frame
that it receives. The sender sends the next frame only when it has received a positive
acknowledgment from the receiver that it is available for further data processing.
Otherwise, it waits for a certain amount of time and then resends the frame.
Design
• Sender Site − At the sender site, a field is added to the frame to hold a sequence
number. If data is available, the data link layer makes a frame with the certain
sequence number and sends it. The sender then waits for arrival of
acknowledgment for a certain amount of time. If it receives a positive
acknowledgment for the frame with that sequence number within the stipulated
time, it sends the frame with next sequence number. Otherwise, it resends the
same frame.
• Receiver Site − The receiver also keeps a sequence number of the frames
expected for arrival. When a frame arrives, the receiver processes it and checks
whether it is valid or not. If it is valid and its sequence number matches the
sequence number of the expected frame, it extracts the data and delivers it to the
network layer. It then sends an acknowledgement for that frame back to the
sender along with its sequence number.
Flow Diagram
The following flow diagram depicts communication via simplex stop – and – wait ARQ
protocol for noisy channel −
Write a short note on sliding window protocol
Sliding window protocols are data link layer protocols for reliable and sequential
delivery of data frames. The sliding window is also used in Transmission Control
Protocol.
In this protocol, multiple frames can be sent by a sender at a time before receiving an
acknowledgment from the receiver. The term sliding window refers to the imaginary
boxes to hold frames. Sliding window method is also known as windowing.
Working Principle
In these protocols, the sender has a buffer called the sending window and the receiver
has buffer called the receiving window.
The size of the sending window determines the sequence number of the outbound
frames. If the sequence number of the frames is an n-bit field, then the range of sequence
numbers that can be assigned is 0 to 2 𝑛−1. Consequently, the size of the sending
window is 2 𝑛−1. Thus in order to accommodate a sending window size of 2𝑛−1, a n-bit
sequence number is chosen.
The sequence numbers are numbered as modulo-n. For example, if the sending window
size is 4, then the sequence numbers will be 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, and so on. The
number of bits in the sequence number is 2 to generate the binary sequence 00, 01, 10,
11.
The size of the receiving window is the maximum number of frames that the receiver can
accept at a time. It determines the maximum number of frames that the sender can send
before receiving acknowledgment.
Example
Suppose that we have sender window and receiver window each of size 4. So the
sequence numbering of both the windows will be 0,1,2,3,0,1,2 and so on. The following
diagram shows the positions of the windows after sending the frames and receiving
acknowledgments.
Types of Sliding Window Protocols
The Sliding Window ARQ (Automatic Repeat reQuest) protocols are of two categories
−
• Go – Back – N ARQ
• Go – Back – N ARQ provides for sending multiple frames before receiving the
acknowledgment for the first frame. It uses the concept of sliding window, and
so is also called sliding window protocol. The frames are sequentially numbered
and a finite number of frames are sent. If the acknowledgment of a frame is not
received within the time period, all frames starting from that frame are
retransmitted.
• This protocol also provides for sending multiple frames before receiving the
acknowledgment for the first frame. However, here only the erroneous or lost
frames are retransmitted, while the good frames are received and buffered.
Solution 1 –
One way to achieve full-duplex transmission is to have two separate channels with one
for forwarding data transmission and the other for reverse data transfer (to accept). But
this will almost completely waste the bandwidth of the reverse channel.
Solution 2(Piggybacking) –
A preferable solution would be to use each channel to transmit the frame (front and back)
both ways, with both channels having the same capacity. Assume that A and B are users.
Then the data frames from A to B are interconnected with the acknowledgment from A to
B. and can be identified as a data frame or acknowledgment by checking the sort field in
the header of the received frame.
One more improvement can be made. When a data frame arrives, the receiver waits does
not send the control frame (acknowledgment) back immediately. The receiver waits until
its network layer moves to the next data packet.
Acknowledgment is associated with this outgoing data frame. Thus the acknowledgment
travels along with the next data frame.
Definition of Piggybacking :
This technique in which the outgoing acknowledgment is delayed temporarily is called
piggybacking.
As we can see in the figure, we can see with piggybacking, a single message (ACK + DATA)
over the wire in place of two separate messages. Piggybacking improves the efficiency of
the bidirectional protocols.
Advantages of piggybacking :
16. The major advantage of piggybacking is the better use of available channel
bandwidth. This happens because an acknowledgment frame needs not to be sent
separately.
17. Usage cost reduction
18. Improves latency of data transfer
Disadvantages of piggybacking :
19. The disadvantage of piggybacking is the additional complexity.
20. If the data link layer waits long before transmitting the acknowledgment (block the
ACK for some time), the frame will rebroadcast.
NOTE – To avoid the delay and rebroadcast of frame transmission, piggybacking uses a very
short duration timer.
Conclusion :
There is a dispute as to whether this is a legal or illegal activity, but piggybacking is still a
dark side of Wi-Fi. Cyber-terrorist attacks in India are a clear reminder that we cannot
control incidents occurring anywhere in the world or control unsecured Wi-Fi networks.
So it is the responsibility of the owner and administrator to secure their wireless
connection.