Computer Networks Accessories

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 26

Computer Networks

Module2-Subsection-III

Data Link Layer

By

Dr. Shahana Gajala Qureshi


Data Link Layer
 The data link layer transforms the physical layer, a raw transmission
facility, to a link responsible for node-to-node (hop-to-hop) communication.
 Specific responsibilities of the data link layer include framing, addressing,
flow control, error control, and media access control.
 The data link layer divides the stream of bits received from the network layer
into manageable data units called frames.
 The data link layer adds a header to the frame to define the addresses of the
sender and receiver of the frame.
 If the rate at which the data are absorbed by the receiver is less than the rate
at which data are produced in the sender, the data link layer imposes a flow
control mechanism to avoid overwhelming the receiver.
 The data link layer also adds reliability to the physical layer by adding
mechanisms to detect and retransmit damaged, duplicate, or lost frames.
 When two or more devices are connected to the same link, data link layer
protocols are necessary to determine which device has control over the link
at any given time.

2
Data Link Layer
Framing in DLL
 Framing is a point-to-point connection between two computers or devices
consisting of a wire where data is transmitted as a stream of bits.
 However, these bits must be framed into discernible blocks of information.
 Framing is a function of the data link layer.
 Data transmission involves the synchronized transmission of bits from the
source to the destination in the physical layer.
 The data link layer receives packets from the network layer and then adds
source and destination addresses to packets.
 They are converted into frames in the data link layer.
 When the frame size becomes large, a packet is divided into a small frame.
These smaller-sized frames enable error control and flow control more
efficiently.

3
Data Link Layer
 Suppose, we have two devices with an adaptor attached to each one. This
adaptor will be sending the data into signals which will flow through the
cable and will be received by the physical layer of other devices.
 Framing in a computer network uses frames to send/receive the data. The
data link layer packs bits into frames such that each frame is
distinguishable from another.
 The data link layer prepares a packet for transport across local media by
encapsulating it with a header and a trailer to create a frame.
 The frame is defined as the data in telecommunications that moves between
various network points.
 Usually, a frame moves bit-by-bit serially and consists of a trailer field and
header field that frames the information. These frames are understandable
only by the data link layer.
The frame consists of the following parts:
1. Frame Header: It consists of the frame's source and destination address.
2. Payload Field: It contains the message to be delivered.
3. Flag: It points to the starting and the ending of the frame.
4. Trailer: It contains the error detection and correction bits.
4
Data Link Layer

 The physical layer doesn’t know anything about the frames. It takes
individual bits and converts them into equivalent signals before sending them.
Now, the receiving device's physical layer has to convert these bits into
frames, but certain problems need to be discussed before that.
Challenges in Framing
A) For example, the sending device sends 100 bits of data, out of which 50 bits
belong to frame one. The receiving device receives all the bits. How will the
receiver know that up to 50 bits belong to the frame?
5
Data Link Layer
Solution: Some protocols are defined between the devices before beginning with
the communication and data exchange. Let both the devices agree that the
frame's start and end will be 11011 (added with the header and trailer). The
frame received by the receiving device will look like this 1101101101101011011.
B) If you notice carefully, there is another problem the frame that is received
contain a part that resembles the start and the end of the frame
1101101101101011011. Hence, the receiver will consider only these
bits 1101101011011,i.e., before the resembling part will not be considered a part
of the frame. This is known as a Framing Error. (The solution to this problem is
Bit-Stuffing. )
Types of Framing
Framing is further divided into two types:
1) Fixed-size Framing
 In this type of framing, the size of the frame is fixed, and hence the frame length
acts as a delimiter of the frame.
 This framing doesn’t require the additional boundary bits to identify the frame's
start and end - for example: If a device is sending2100 bits of data and the 50
bits of frame size is fixed, then after receiving the 50 bits of data, the receiver
will automatically know that the next 50 bits are of frame two and so on.

6
Data Link Layer
Drawback: It goes through internal fragmentation when the data size is less than
the frame size. Padding is a solution to avoid such a situation.
2. Variable size Framing
 In this type of framing, the size of each frame to be transmitted may vary;
hence additional mechanisms are kept to mark the end of one frame and the
start of the next frame.
 It is used in local area networks.
 For example, It is possible that out of 200 bits of data, 100 bits constitute
frame 1, 25 bits constitute frame two, and the rest bits constitute frame 3.
Two ways to define frame delimiters in variable sized framing have three
approaches:
a) Bit-Oriented Framing
b) Byte-Oriented Framing
c) Clock Based Framing
a) Bit-Oriented Approach
 It views the frames as a collection of bits. The data is transmitted as a
sequence of bits that can be interpreted as text and multimedia data in the
upper layer.
7
Data Link Layer
Bit-Oriented Protocol
 High-Level Data Link Control (HDLC) is a data link layer protocol. The
frame format defined is given in the below figure, along with the bits.

 Beginning and Ending Sequence: The 8 bits added at the start and end of the
frame in this protocol are 01111110. These bits are also transmitted when the
link is idle to synchronize the clock.
 Cyclic Redundancy Check(CRC): It is used to detect errors.
Bit-Stuffing:
 Consider the frame to be sent and received by the devices
be 011111100101000111111001111110 again if you notice that this frame
contains a part similar to the beginning in its body. In Bit Stuffing, we stuff a
pattern of bits of arbitrary length in the message to differentiate from the
delimiter.

8
Data Link Layer
 So, whenever the sender device finds the frame consisting of five consecutive
1’s, it will stuff a ‘0’ bit. It will look like this
0111111001010001111101001111110. When the receiving device receives
this frame and encounters a ‘0’ after five consecutive bits, it will remove it to
maintain the original frame.
b) Byte-Oriented Approach
 It news the frames as a collection of bytes(8 bits), also known as a character
and hence given the name Character Oriented Approach.
There are three Byte-Oriented Protocols:
 Binary Synchronous Communication Protocol (BISYNC)
 Digital Data Communication Message Protocol (DDCMP)
 Point-to-Point Protocol(PPP).
Binary Synchronous Communication Protocol (BISYNC):
 It is a sentinel approach. The frame format defined is given in the below
figure, along with the bits.

9
Data Link Layer
 SYN: Special starting character, SOH: Start of the Header, STX: Start of the
text, ETX: End of the text.
 The STX and ETX guard the data part of the portion. To avoid the framing error
problem in this approach, we have introduced Byte Stuffing. This is used when
the frames consist of characters. A byte is stuffed in the message to
differentiate from the delimiter.
Point-to-Point Protocol(PPP):
 It is a data link layer protocol. It is a wide area network protocol that runs over
internet links. This protocol is mainly used in broadband communication that
deals with high speed and heavy loads. The frame format defined is given in the
below figure, along with the bits.

 The bit pattern for the flag is 01111110.

 The address field is set to 11111111 in case of broadcast.

 The control value is set to a constant value of 11000000. 10


Data Link Layer
 The protocol consists of 1 or 2 bytes that define the type of data in the
payload section.

 The payload carries the data. The maximum length of this field is 1500 bytes.
 The checksum field is used for error detection.
 Similar to the previous cases, if the flag bits appear in the payload part, the
situation is overcome using character/byte stuffing.
Digital Data Communication Message Protocol (DDCMP):
 A new count field is introduced in this protocol. The frame format defined is
given in the below figure, along with the bits.

 One risk with this approach is that if transmission error corrupts the count
field, then the end of the frame will not be detected by the receiver correctly.

11
Data Link Layer
c) Clock Based Framing
 This framing is mainly used for Optical Networks such as SONET. In this
approach, a series of repetitive pulses maintain a constant bit rate and keep
the digital bits aligned in the data stream.
Advantages of Framing in Data Link Layer
 Frames are used continuously in the process of time-division multiplexing.
 It facilitates a form to the sender for transmitting a group of valid bits to a
receiver.
 Frames also contain headers that include information such as error-checking
codes.
 A Frame relay, token ring, Ethernet, and other types of data link layer
methods have their frame structures.
 Frames allow the data to be divided into multiple recoverable parts that can
be inspected further for corruption.
 It provides a flow control mechanism that manages the frame flow such that
the data congestion does not occur on slow receivers due to fast senders.
 It provides reliable data transfer services between the layers of the peer
network.
12
Data Link Layer
Flow Control and Error Control in DLL
 Data Link Layer is responsible for reliable point-to-point data transfer over
a physical medium. To implement this data link layer provides three functions
:

Line Discipline : Line discipline is the functionality used to establish


coordination between link systems. It decides which device sends data and
when.
Flow Control : Flow control is an essential function that coordinates the
amount of data the sender can send before waiting for acknowledgment from
the receiver.

13
Data Link Layer
Error Control : Error control is functionality used to detect erroneous
transmissions in data frames and retransmit them.
What is Flow Control in Data Link Layer ?
 Flow control is a set of procedures that restrict the amount of data a sender
should send before it waits for some acknowledgment from the receiver.
 Flow Control is an essential function of the data link layer.
 It determines the amount of data that a sender can send.
 It makes the sender wait until an acknowledgment is received from the
receiver’s end.
 Methods of Flow Control are Stop-and-wait , and Sliding window.

14
Data Link Layer
Purpose of Flow Control
 The device on the receiving end has a limited amount of memory (to store
incoming data) and limited speed (to process incoming data). The receiver
might get overwhelmed if the rate at which the sender sends data is faster or
the amount of data sent is more than its capacity.
 Buffers are blocks in the memory that store data until it is processed. If
the buffer is overloaded and there is more incoming data, then the receiver
will start losing frames.
 The flow control mechanism was devised to avoid this loss and wastage of
frames. Following this mechanism, the receiver, as per its capacity, sends an
acknowledgment to send fewer frames or temporarily halt the transmission
until it can receive again.
 Thus, flow control is the method of controlling the rate of transmission of
data to a value that the receiver can handle.
Methods to Control the Flow of Data
i) Stop-and-wait Protocol:
 Stop-and-wait protocol works under the assumption that the communication
channel is noiseless and transmissions are error-free.

15
Data Link Layer
Working :
 The sender sends data to the receiver.
 The sender stops and waits for the acknowledgment.
 The receiver receives the data and processes it.
 The receiver sends an acknowledgment for the above data to the sender.
 The sender sends data to the receiver after receiving the acknowledgment of
previously sent data.
 The process is unidirectional and continues until the sender sends the End
of Transmission (EoT) frame.

16
Data Link Layer
ii) Sliding Window Protocol
 The sliding window protocol is the flow control protocol for noisy channels
that allows the sender to send multiple frames even before acknowledgments
are received.
 It is called a Sliding window because the sender slides its window upon
receiving the acknowledgments for the sent frames.
Working :
 The sender and receiver have a “window” of frames. A window is a space
that consists of multiple bytes. The size of the window on the receiver side is
always 1.
 Each frame is sequentially numbered from 0 to n - 1, where n is the window
size at the sender side.
 The sender sends as many frames as would fit in a window.
 After receiving the desired number of frames, the receiver sends an
acknowledgment. The acknowledgment (ACK) includes the number of the
next expected frame.
Example:

17
Data Link Layer

18
Data Link Layer
1. The sender sends the frames 0 and 1 from the first window (because the
window size is 2).
2. The receiver after receiving the sent frames, sends an acknowledgment for
frame 2 (as frame 2 is the next expected frame).
3. The sender then sends frames 2 and 3. Since frame 2 is lost on the way, the
receiver sends back a “NAK” signal (a non-acknowledgment) to inform the
sender that frame 2 has been lost. So, the sender retransmits frame 2.
What is Error Control in the Data Link Layer ?
Ways of doing Error Control : There are basically two ways of doing Error
control as given below :

19
Data Link Layer
Error detection :
 Error detection, as the name suggests, simply means detection or
identification of errors.
 These errors may cause due to noise or any other impairments during
transmission from transmitter to the receiver, in communication system.
 It is a class of techniques for detecting garbled i.e. unclear and distorted data
or messages.
 It is the process by which the receiver informs the sender about any
erroneous frame (damaged or lost) sent during transmission.
Error Correction :
 Error correction, as the name suggests, simply means correction or solving
or fixing of errors.
 It simply means reconstruction and rehabilitation of original data that is error-
free.
 But error correction method is very costly and very hard.

Various Techniques for Error Control : There are various techniques of error
control :
20
Data Link Layer

Purpose of Error Control


 Error control is a vital function of the data link layer that detects errors in
transmitted frames and retransmits all the erroneous frames.
 Error discovery and amendment deal with data frames damaged or lost in
transit and the acknowledgment frames lost during transmission.
 The method used in noisy channels to control these errors
is ARQ or Automatic Repeat Request.

21
Data Link Layer
i) Stop-and-wait ARQ:
 In the case of stop-and-wait ARQ after the frame is sent, the sender
maintains a timeout counter.
 If acknowledgment of the frame comes in time, the sender transmits the
next frame in the queue. Else, the sender retransmits the frame and starts
the timeout counter.
 In case the receiver receives a negative acknowledgment, the sender
retransmits the frame.

22
Data Link Layer
ii) Sliding Window ARQ:
 To deal with the retransmission of lost or damaged frames, a few changes are
made to the sliding window mechanism used in flow control.
iii) Go-Back-N ARQ :
 In Go-Back-N ARQ, if the sent frames are suspected or damaged, all the
frames are re-transmitted from the lost packet to the last packet transmitted.

23
Data Link Layer
iv) Selective Repeat ARQ :
 Selective Repeat ARQ is also form of ARQ protocol in which only
suspected or damaged or lost data frames are only retransmitted.
 This technique is similar to Go-Back-N ARQ though much more efficient
than the Go-Back-N ARQ technique due to reason that it reduces number of
retransmission.
 In this, the sender only retransmits frames for which NAK is received. But
this technique is used less because of more complexity between sender and
receiver and each frame must be needed to be acknowledged individually.

24
Data Link Layer
Differences between Flow Control and Error Control

25
Thank You

26

You might also like