CN Unit-2
CN Unit-2
This sub layer runs above the data link layer and provides flow control and error
information. It is responsible for assigning the frame sequence number. Thus it
controls the synchronization, flow control, and error checking functions of the
data link layer. Functions are –
• (i) Error Recovery.
• (ii) It performs the flow control operations.
• (iii) User addressing.
Media Access Control Sub-layer (MAC) –
The bottom sub layer of the Data Link Layer is the Media Access Control. It is
also known as Medium Access Control. It provides multiplexing and flow
control for the transmission media. The main responsibility of this sub layer is
to encapsulate the frame, check for transmission errors, and then allow the
frame to be forwarded to the upper layer..
Functions are –
• (i) To perform the control of access to media.
• (ii) It performs the unique addressing to stations directly connected to LAN.
• (iii) Detection of errors.
1. Framing: The packet received from the Network layer is known as a frame
in the Data link layer. At the sender’s side, DLL receives packets from the
Network layer and divides them into small frames, then, sends each frame bit-
by-bit to the physical layer. It also attaches some special bits (for error control
and addressing) at the header and end of the frame. At the receiver’s end, DLL
takes bits from the Physical layer organize them into the frame, and sends
them to the Network layer.
2. Addressing: The data link layer encapsulates the source and destination’s
MAC address / physical address in the header of each frame to ensure node-to-
node delivery. MAC address is the unique hardware address that is assigned to
the device while manufacturing.
3. Error Control: Data can get corrupted due to various reasons like noise,
attenuation, etc. So, it is the responsibility of the data link layer, to detect the
error in the transmitted data and correct it using error detection and correction
techniques respectively. DLL adds error detection bits into the frame’s header,
so that receiver can check received data is correct or not.
4. Flow Control: If the receiver’s receiving speed is lower than the sender’s
sending speed, then this can lead to an overflow in the receiver’s buffer and
some frames may get lost. So, it’s the responsibility of DLL to synchronize the
sender’s and receiver’s speeds and establish flow control between them.
5. Access Control: When multiple devices share the same communication
channel there is a high probability of collision, so it’s the responsibility of
DLL to check which device has control over the channel and CSMA/CD and
CSMA/CA can be used to avoid collisions and loss of frames in the channel.
Framing In Data Link Layer
Parts of a Frame
Based on the size, the following are the types of framing in computer
networks,
• Fixed Size Framing
• Variable Size Framing
• The frame has a fixed size. In fixed-size framing, there is no need for
defining the boundaries of the frames to mark the beginning and end of a
frame.
For example- This type of framing is used in ATMs, Wide area networks. They
use frames of fixed size called cells.
Variable – Sized Framing
• Here, the size of each frame to be transmitted may be different.
• So additional mechanisms are used, to mark the end of one frame and the
beginning of the next frame.
Simplest Protocol
Simplest Protocol is a protocol that neither has flow control nor has error
control( as we have already told you that it lies under the category of Noiseless
channels).
• The flow control is not needed by the Simplest Protocol. The data link
layer at the sender side mainly gets the data from the network layer and
then makes the frame out of data and sends it.
• On the Receiver site, the data link layer receives the frame from the
physical layer and then extracts the data from the frame, and then delivers
the data to its network layer.
• The Data link layers of both sender and receiver mainly provide
transmission services for their Network layers.
• The data link layer also uses the services provided by the physical layer
such as signaling, multiplexing, etc for the physical transmission of the
bits.
• Let us now take a look at the procedure used by the data link layer at both
sides (sender as well as the receiver).
• There is no frame send by the data link layer of the sender site until its
network layer has a data packet to send.
• Similarly, the receiver site cannot deliver a data packet to its network
layer until a frame arrives.
Design of the Simplest Protocol
• The design of the simplest protocol is very simple as there is no error and
a flow control mechanism.
• The sender end (present at the data link layer) gets the data from the
network layer and converts the data into the form of frames so that it can
be easily transmitted.
• Now on the receiver's end, the data frame is taken from the physical layer and
then the data link layer extracts the actual data (by removing the header from
• Receivers algorithm –
• The idea is very simple, and the sender sends the sequence of data frames
without thinking about the receiver.
• Whenever sending request comes from the network layer, the sender
sends the data frames. Similarly, whenever the receiving request comes
from the physical layer, the receiver receives the data frames.
• The sender cannot send the data frame until the network layer has a data
packet to be transmitted.
• The receiver is always ready to receive data frames, and it is constantly
running, but no action takes place until notified by the physical layer.
• Similarly, the sender is always ready to send data frames, and it is constantly
running, but no action takes place until notified by the network layer.
Stop and Wait Protocol
• Stop and wait means, whatever the data that sender wants to send, he sends
the data to the receiver.
• After sending the data, sender stops and waits until receive the
acknowledgment from the receiver.
• The stop and wait protocol is a flow control protocol where flow control is
one of the services of the data link layer.
• It provides unidirectional data transmission which means that either sending
or receiving of data will take place at a time.
• It provides flow-control mechanism but does not provide any error control
mechanism.
Receiver side
The following are the problems associated with a stop and wait protocol:
1. Problems occur due to lost data
Suppose the sender sends the data and the data is lost. The receiver is
waiting for the data for a long time. Since the data is not received by the
receiver, so it does not send any acknowledgment. Since the sender does not
receive any acknowledgment so it will not send the next packet. This problem
occurs due to the lost data.
Suppose the sender sends the data and it has also been received by the
receiver. On receiving the packet, the receiver sends the acknowledgment. In
this case, the acknowledgment is lost in a network, so there is no chance for the
sender to receive the acknowledgment. There is also no chance for the sender to
send the next packet as in stop and wait protocol, the next packet cannot be sent
until the acknowledgment of the previous packet is received.
Suppose the sender sends the data and it has also been received by the
receiver. The receiver then sends the acknowledgment but the acknowledgment
is received after the timeout period on the sender's side. As the acknowledgment
is received late, so acknowledgment can be wrongly considered as the
acknowledgment of some other data packet.
Stop and Wait for ARQ (Automatic Repeat Request)
The above 3 problems are resolved by Stop and Wait for ARQ (Automatic
Repeat Request) that does both error control and flow control.
• The sender sends the data frame with a sequence number. The sequence
numbers are 1 and 0
• The sender also maintains a copy of the data frame that is being currently
sent so that if the ACK is not received then the sender can re-transmit the
frame.
• The sender can send only one frame at a time and the receiver can also
receive only one frame at a time.
• The stop and wait ARQ is a connection-oriented protocol.
• In the stop and wait ARQ, a time tracker is used.
• Stop and Wait ARQ has very less efficiency , it can be improved by increasing
the window size. Also , for better efficiency , Go back N and Selective Repeat
Protocols are used.
• The Stop and Wait ARQ solves the main three problems but may cause big
performance issues as the sender always waits for acknowledgement even if it
has the next packet ready to send, where we have a high propagation delay.
• To solve this problem, we can send more than one packet at a time with a
larger sequence number. This can be solved with Sliding Window Protocols,
Working of Stop and Wait for ARQ:
Sender A sends a data frame or packet with sequence number 0.
sequence number 1
1. Go-Back-N ARQ
2. Selective Repeat ARQ
Go-Back-N ARQ
• Before understanding the working of Go-Back-N ARQ, we first look at
the sliding window protocol. As we know that the sliding window
protocol is different from the stop-and-wait protocol.
• In the stop-and-wait protocol, the sender can send only one frame at a
time and cannot send the next frame without receiving the
acknowledgment of the previously sent frame, whereas, in the case of
sliding window protocol, the multiple frames can be sent at a time.
The sender will then send the next frame, i.e., 4, and the window slides containing
• Now, let's assume that the receiver is not acknowledging the frame no 2,
either the frame is lost, or the acknowledgment is lost. Instead of sending
the frame no 6, the sender Go-Back to 2, which is the first frame of the
current window, retransmits all the frames in the current window, i.e.,
2,3,4,5.
Go-Back-N ARQ protocol is also known as Go-Back-N Automatic Repeat
Request. It is a data link layer protocol that uses a sliding window method.
If a frame is corrupted or lost in it,all In this, only the frame is sent again, which is
subsequent frames have to be sent corrupted or lost.
again.
If it has a high error rate,it wastes a lot There is a loss of low bandwidth.
of bandwidth.
It does not require sorting. In this, sorting is done to get the frames in the
correct order.
Error Control :
The error control function of the data link layer detects the errors in
transmitted frames and re-transmits all the erroneous frames.
Purpose of Error Control :
The function of error control function of the data link layer helps in dealing
with data frames that are damaged in transit, data frames lost in transit and
acknowledged frames that are lost in transmission. The method used for error
control is called Automatic Repeat Request (ARQ) which is used for the noisy
channel.
Example – Stop & Wait ARQ and Sliding Window ARQ
Difference between Flow Control and Error Control :
Transmission Modes
Transmission mode means transferring data between two devices. It is also
known as a communication mode. Buses and networks are designed to allow
communication to occur between individual devices that are interconnected.
There are three types of transmission mode:-
1. Simplex Mode –
In Simplex mode, the communication is unidirectional, as on a one-way street.
Only one of the two devices on a link can transmit, the other can only receive.
The simplex mode can use the entire capacity of the channel to send data in
one direction.
Example: Keyboard and traditional monitors. The keyboard can only introduce
input, the monitor can only give the output.
Advantages:
• Simplex mode is the easiest and most reliable mode of communication.
• It is the most cost-effective mode, as it only requires one communication
channel.
• There is no need for coordination between the transmitting and receiving
devices, which simplifies the communication process.
• Simplex mode is particularly useful in situations where feedback or
response is not required, such as broadcasting or surveillance.
Disadvantages:
• Only one-way communication is possible.
• There is no way to verify if the transmitted data has been received
correctly.
• Simplex mode is not suitable for applications that require bidirectional
communication.
2. Half-Duplex Mode –
In half-duplex mode, each station can both transmit and receive, but not at the
same time. When one device is sending, the other can only receive, and vice
versa. The half-duplex mode is used in cases where there is no need for
communication in both directions at the same time. The entire capacity of the
channel can be utilized for each direction.
Example: Walkie-talkie in which message is sent one at a time and messages
are sent in both directions.
Channel capacity=Bandwidth * Propagation Delay
Advantages:
• Half-duplex mode allows for bidirectional communication, which is useful
in situations where devices need to send and receive data.
• It is a more efficient mode of communication than simplex mode, as the
channel can be used for both transmission and reception.
• Half-duplex mode is less expensive than full-duplex mode, as it only
requires one communication channel.
Disadvantages:
• Half-duplex mode is less reliable than Full-Duplex mode, as both devices
cannot transmit at the same time.
• There is a delay between transmission and reception, which can cause
problems in some applications.
• There is a need for coordination between the transmitting and receiving
devices, which can complicate the communication process.
3. Full-Duplex Mode –
In full-duplex mode, both stations can transmit and receive simultaneously. In
full_duplex mode, signals going in one direction share the capacity of the link
with signals going in another direction, this sharing can occur in two ways:
• Either the link must contain two physically separate transmission paths, one
for sending and the other for receiving.
• Or the capacity is divided between signals traveling in both directions.
Advantages:
• Full-duplex mode allows for simultaneous bidirectional communication,
which is ideal for real-time applications such as video conferencing or
online gaming.
• It is the most efficient mode of communication, as both devices can
transmit and receive data simultaneously.
• Full-duplex mode provides a high level of reliability and accuracy, as there
is no need for error correction mechanisms.
Disadvantages:
• Full-duplex mode is the most expensive mode, as it requires two
communication channels.
• It is more complex than simplex and half-duplex modes, as it requires two
physically separate transmission paths or a division of channel capacity.
• Full-duplex mode may not be suitable for all applications, as it requires a
high level of bandwidth and may not be necessary for some types of
communication.
Connection-Oriented vs Connectionless Service
Connection-Oriented Service
Similarly, a receiver can respond or send the data to the sender in the form of
packets. After successfully exchanging or transmitting data, a sender can
terminate the connection by sending a signal to the receiver. In this way, we can
say that it is a reliable network service.
TCP (Transmission Control Protocol) is a connection-oriented protocol that
allows communication between two or more computer devices by establishing
connections in the same or different networks.
Benefits of Connection-Oriented Services:
• Connection-Oriented Services are reliable.
• There is no duplication of data packets.
• There are no chances of Congestion.
• These are Suitable for long connections.
• Sequencing of data packets is guaranteed.
Disadvantages