0% found this document useful (0 votes)
7 views13 pages

CN Unit 2 Notes

lecture note of unit 2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views13 pages

CN Unit 2 Notes

lecture note of unit 2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

UNIT II

Data Link Layer: Data Link layer provides with successful delivery of message from one node to the another. It checks whether this delivery of message is error free. Other functions performed
by data link layer are error control, framing, flow control etc.
•It contains two sub-layers:
• Logical Link Control Layer
• It is responsible for transferring the packets to the Network layer of the receiver that is receiving.
• It identifies the address of the network layer protocol from the header.
• It also provides flow control.
• Media Access Control Layer
• A Media access control layer is a link between the Logical Link Control layer and the network's physical layer.
• It is used for transferring the packets over the network

Data-link layer Service Provided:

•Framing: The data link layer translates the physical's raw bit stream into packets known as Frames. The Data link layer adds the header and trailer to the frame. The header which is added to the
frame contains the hardware destination and source address.
•Physical Addressing: The Data link layer adds a header to the frame that contains a destination address. The frame is transmitted to the destination address mentioned in the header.
•Flow Control: Flow control is the main functionality of the Data-link layer. It is the technique through which the constant data rate is maintained on both the sides so that no data get corrupted.
It ensures that the transmitting station such as a server with higher processing speed does not exceed the receiving station, with lower processing speed.
•Error Control: Error control is achieved by adding a calculated value CRC (Cyclic Redundancy Check) that is placed to the Data link layer's trailer which is added to the message frame before
it is sent to the physical layer. If any error seems to occurr, then the receiver sends the acknowledgment for the retransmission of the corrupted frames.
•Access Control: When two or more devices are connected to the same communication channel, then the data link layer protocols are used to determine which device has control over the link at a
given time.
Data-link layer Service: Framing

Data-link layer takes the packets from the Network Layer and encapsulates them into frames. If the frame size becomes too large, then the packet may be divided into small sized frames.
Smaller sized frames makes flow control and error control more efficient.
Then, it sends each frame bit-by-bit on the hardware. At receiver's end, data link layer picks up signals from hardware and assembles them into frames.

Parts of a Frame

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 Framing:

Framing can be of two types, fixed sized framing and variable sized framing.
Fixed-sized Framing

Here the size of the frame is fixed and so the frame length acts as delimiter of the frame. Consequently, it does not require additional boundary bits to identify the start and end of the frame.
Variable – Sized Framing

Here, the size of each frame to be transmitted may be different. So additional mechanisms are kept to mark the end of one frame and the beginning of the next frame.
**A delimiter is a character or symbol which separates one piece of data from another Framing Method :
Character count

Byte Stuffing/ Character Stuffing Bit stuffing physical


layer coding violations Character Count

First framing method uses a field in the header to specify the number of characters in the frame. When the data link layer at the destination sees the character count, it knows how many characters
follow and hence where the end of the frame is.
For Example,

Consider a data − 1 2 3 4 5 6 7 8 9 0 1 2 3

Divide this data into three frames −


The disadvantage is that if the count is garbled by a transmission error, the destination will lose synchronization and will be unable to locate the start of the next frame. So,
this method is rarely used.

Byte Stuffing/ Character Stuffing

 If the pattern of the flag byte is present in the message byte, there should be a strategy so that the receiver does not consider the pattern as the end of the frame.

 In byte stuffing, a special byte called the escape character (ESC) is stuffed before every byte in the message with the same pattern as the flag byte. If the ESC
sequence is found in the message byte, then another ESC byte is stuffed before it.

Bit stuffing

Bit stuffing refers to the insertion of one or more bits into a data transmission as a way to provide signaling information to a receiver. The receiver knows how to detect,
remove or disregard the stuffed bits.
Flow Control in the Data Link Layer
•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.

Need 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.
Stop-and-wait Protocol
Stop-and-wait protocol works under the assumption that the communication channel is noiseless and transmissions are error-free.
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.

Advantages –
•This method is very easiest and simple and each of the frames is checked and acknowledged well.
•This method is also very accurate.
Disadvantages –
•This method is fairly slow.
•In this, only one packet or frame can be sent at a time.
•It is very inefficient and makes the transmission process very slow.
Sliding Window
This method improves the efficiency of stop and wait method by allowing multiple frames to be
transmitted before receiving an acknowledgment.

• Sliding Window refers to imaginary boxes at both the sender and receiver end.

• Both the sender and the receiver has finite sized buffers called windows. The sender and the
receiver agrees upon the number of frames to be sent based upon the buffer size.

• A single ACK acknowledge multiple frames.

• Each frame is sequentially numbered from 0 to n - 1, where n is the window size at the sender side. maximum n-1 frames can be sent before acknowledgement.

• The sender sends as many frames as would fit in a window. Frames can be acknowledged even when the window is not completely filled.

• After receiving the desired number of frames, the receiver sends an acknowledgment. The acknowledgment (ACK) includes the number of the next expected frame.
• The sender sends the frames 0 and 1 from the first window (because the window size is 2).
• The receiver after receiving the sent frames, sends an
acknowledgment for frame 2 (as frame 2 is the next expected frame).

• The sender then sends frames 2 and 3. Since frame 2 is lost on the
way, the receiver sends back a “NAK” signal (a
nonacknowledgment) to inform the sender that frame 2 has been lost.
So, the sender retransmits frame 2.

Advantages
It performs much better than stop-and-wait flow control.
This method increases efficiency.
Multiples frames can be sent one after another.
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 control in data link layer
Error control is the process of detecting and correcting data frames that
have been corrupted or lost during transmission.
In case of lost or corrupted frames, the receiver does not receive the correct
data-frame and sender is ignorant about the loss. Data link layer follows a
technique to detect transit errors and take necessary actions, which is
retransmission of frames whenever error is detected or frame is lost. The
process is called Automatic Repeat Request (ARQ).
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.

Sliding Window ARQ


It is a technique used for continuous transmission error control.
•In this case, the sender keeps the copies of all the transmitted frames until they have been acknowledged. Suppose the frames from 0 through 4 have been transmitted, and the last
acknowledgement was for frame 2, the sender has to keep the copies of frames 3 and 4 until they receive correctly.

•The receiver can send either NAK or ACK depending on the conditions. The NAK frame tells the sender that the data have been received damaged. Since the sliding window is a continuous
transmission mechanism, both ACK and NAK must be numbered for the identification of a frame. The ACK frame consists of a number that represents the next frame which the receiver expects
to receive. The NAK frame consists of a number that represents the damaged frame.

•The sliding window ARQ is equipped with the timer to handle the lost acknowledgements. Suppose then n-1 frames have been sent before receiving any acknowledgement. The sender waits
for the acknowledgement, so it starts the timer and waits before sending any more. If the allotted time runs out, the sender retransmits one or all the frames depending upon the protocol used.

It is further categorized into two categories as


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.

• Go-Back-N ARQ is form of ARQ protocol in which transmission process continues to send or transmit total number of frames that are specified by window size even without receiving an
ACK (Acknowledgement) packet from the receiver. It uses sliding window flow control protocol. If no errors occur, then operation is identical to sliding window.
• Damaged Frame: When the frame is damaged, then the receiver sends a NAK frame.

• Lost Data Frame: In Sliding window protocols, data frames are sent sequentially. If any of the frames is lost, then the next frame arrive at the receiver is out of sequence. The receiver checks
the sequence number of each of the frame, discovers the frame that has been skipped, and returns the NAK for the missing frame. The sending device retransmits the frame indicated by NAK
as well as the frames transmitted after the lost frame.

• Lost Acknowledgement: The sender can send as many frames as the windows allow before waiting for any acknowledgement. Once the limit of the window is reached, the sender has no more
frames to send; it must wait for the acknowledgement. If the acknowledgement is lost, then the sender could wait forever. To avoid such situation, the sender is equipped with the timer that
starts counting whenever the window capacity is reached. If the acknowledgement has not been received within the time limit, then the sender retransmits the frame since the last ACK.
Three frames have been transmitted before an error discovered in the third frame. In this
case, ACK 2 has been returned telling that the frames 0,1 have been received successfully
without any error. The receiver discovers the error in data 2 frame, so it returns the NAK 2
frame. The frame 3 is also discarded as it is transmitted after the damaged frame. Therefore,
the sender retransmits the frames 2,3.
Selective Repeat ARQ
• It is also form of ARQ protocol in which only suspected or damaged or lost data frames are only retransmitted.
• Selective-Reject ARQ technique is more efficient than Go-Back-n ARQ.
• The receiver storage buffer keeps all the damaged frames on hold until the frame in error is correctly received.
• The receiver must have an appropriate logic for reinserting the frames in a correct order.
• The sender must consist of a searching mechanism that selects only the requested frame for retransmission.

Hybrid ARQ
A typical communication channel has imperfections. Packets get lost or corrupted. When the receiver detects errors, it discards the erroneous packet and requests the sender to retransmit it. This is
called Automatic Repeat
Request (ARQ).
However, if errors are within certain limits, the receiver can not only detect but also correct errors. This is possible if the sender employs Error-Correcting Codes (ECCs). These include parity
bits that help in correcting errors in information bits. The technique is called Forward Error Correction (FEC). FEC avoids ARQ retransmissions but parity bits are an overhead.

Hybrid ARQ is a technique that combines both ARQ and FEC. Packet errors are corrected where possible. Where not possible, retransmission is requested. First and subsequent packet
transmissions are combined to increase the chance of correct decoding.

In hybrid ARQ with soft combining, the erroneously received packet is stored in a buffer memory and later combined with the retransmission to obtain a single, combined packet that is more
reliable than its constituents.
Decoding of the error-correction code operates on the combined signal

You might also like