Data link layer Questions and answers
Framing Methods in the Data Link Layer
Framing is a function of the Data Link Layer that divides a continuous stream of
bits from the network layer into manageable units called frames.
Various Framing Methods
1. Character Count (Byte Count) Framing
Description
The first field of the frame specifies the number of characters (bytes) in
the frame.
Receiver uses this count to determine the end of the frame.
Simple Example
[Count=5] [A] [B] [C] [D]
Count field = 5 (including count byte)
Receiver reads 5 bytes to get one complete frame.
Disadvantage
If the count field is corrupted, the entire framing is disturbed.
2. Flag Byte with Byte Stuffing
Description
Frames start and end with a special flag byte (e.g., 01111110).
If the flag appears in data, an extra byte (escape character) is added (byte
stuffing).
Simple Example
Flag = F
Escape = ESC
F A B ESC F C F
ESC F in data means the flag is part of data, not frame boundary.
Used In
Character-oriented protocols (e.g., PPP)
3. Flag Bit with Bit Stuffing
Description
Frames are marked by a special bit pattern (usually 01111110).
If five consecutive 1s appear in data, a 0 is inserted (bit stuffing).
Simple Example
Data:
01111110
After bit stuffing:
011111010
Receiver removes the extra 0 during decoding.
Used In
Bit-oriented protocols (e.g., HDLC)
Methods of Line Discipline in the Data Link
Layer
Line discipline is a function of the Data Link Layer that determines which
device is allowed to transmit data and when over a communication link.
There are two main methods:
1. ENQ/ACK (Enquiry / Acknowledgement)
(Used in point-to-point communication)
Description
The sender sends an ENQ (Enquiry) frame to check if the receiver is ready.
The receiver replies with ACK (Acknowledgement) if it is ready.
After receiving ACK, the sender transmits data.
If the receiver is not ready, it sends NAK.
Simple Example
1. Sender → Receiver : ENQ
2. Receiver → Sender : ACK
3. Sender → Receiver : DATA
4. Receiver → Sender : ACK
Data transmission starts only after permission is granted.
2. Poll/Select
(Used in multipoint (multi-drop) communication)
This method has two modes:
a) Poll Mode
A primary station controls the communication.
It asks (polls) secondary stations one by one to check if they have data to
send.
Simple Example
Primary → Secondary 1 : Poll
Secondary 1 → Primary : No data
Primary → Secondary 2 : Poll
Secondary 2 → Primary : Sends data
Only the polled station can transmit.
b) Select Mode
The primary station wants to send data to a secondary station.
The primary selects the destination station before sending data.
Simple Example
Primary → Secondary 3 : Select
Secondary 3 → Primary : ACK
Primary → Secondary 3 : Data
Ensures the receiver is ready to accept data.
Explain Sliding Window protocol
Sliding Window Protocol
The Sliding Window Protocol is a flow control and error control mechanism
used in the Data Link Layer (and Transport Layer) to ensure reliable and
efficient data transmission.
Basic Idea
The sender can send multiple frames before receiving an acknowledgement
(ACK).
A window defines the range of sequence numbers that can be sent or
accepted.
As ACKs are received, the window slides forward, allowing new frames to
be sent.
Types of Sliding Window Protocols
1. Stop-and-Wait ARQ (window size = 1)
2. Go-Back-N ARQ
3. Selective Repeat ARQ
1. Stop-and-Wait ARQ (Window Size = 1)
Working
Sender sends one frame and waits for ACK.
If ACK is received → send next frame.
If timeout occurs → retransmit frame.
Simple Example
Sender sends Frame 0
Receiver sends ACK 0
Sender sends Frame 1
Simple but inefficient for long-distance links.
2. Go-Back-N ARQ
Working
Sender window size = N
Sender can send N frames without waiting for ACK.
Receiver accepts frames in order only.
If a frame is lost, receiver discards all subsequent frames.
Sender retransmits from the lost frame onward.
Simple Example
Sender window size = 4
Frames sent: 0 1 2 3
Frame 1 is lost.
Receiver receives Frame 0 → sends ACK 1
Receiver discards Frames 2 and 3
Sender retransmits Frames 1, 2, and 3
Efficient but causes unnecessary retransmissions.
3. Selective Repeat ARQ
Working
Sender window size = N
Receiver window size = N
Receiver accepts frames out of order.
Only the lost or corrupted frames are retransmitted.
Simple Example
Sender window size = 4
Frames sent: 0 1 2 3
Frame 1 is lost.
Receiver receives Frames 0, 2, 3
Receiver buffers Frames 2 and 3
Receiver requests retransmission of Frame 1 only
Sender retransmits Frame 1
Most efficient but more complex.
Explain Stop-and-Wait Protocol
The Stop-and-Wait Protocol is the simplest flow control and error control
protocol used in the Data Link Layer.
Working of Stop-and-Wait Protocol
1. The sender transmits one frame.
2. The sender waits for an acknowledgement (ACK).
3. If the ACK is received correctly → sender transmits the next frame.
4. If ACK is not received within a timeout period → sender retransmits the
same frame.
At any time, only one frame can be in transit.
Simple Example
Assume a sender S and receiver R.
1. S → R : Frame 0
2. R → S : ACK 0
3. S → R : Frame 1
4. R → S : ACK 1
Data is transferred successfully, one frame at a time.
Example with Lost Frame
1. S → R : Frame 0 (lost)
2. No ACK received
3. Timeout occurs
4. S → R : Frame 0 (retransmitted)
5. R → S : ACK 0
Lost frame is retransmitted.
Example with Lost ACK
1. S → R : Frame 1
2. R → S : ACK 1 (lost)
3. Timeout occurs
4. S → R : Frame 1 (retransmitted)
5. R discards duplicate Frame 1
6. R → S : ACK 1
Duplicate frames are handled using sequence numbers (0 and 1).
Write about MAC Address (Media Access
Control Address)
A MAC address is a unique physical address assigned to every
network interface (NIC) of a device.
It works at the Data Link Layer (Layer 2) of the OSI model and is used
to identify devices within a local network (LAN).
Characteristics of MAC Address
Length: 48 bits (6 bytes)
Format: Hexadecimal
Written as six pairs of hex digits
Example format:
00:1A:2B:3C:4D:5E
Structure of MAC Address
A MAC address has two parts:
1. OUI (Organizationally Unique Identifier) – First 24 bits
o Identifies the manufacturer
2. NIC Identifier – Last 24 bits
o Uniquely identifies the network interface
Example Breakdown
00:1A:2B : 3C:4D:5E
↑ OUI ↑ NIC part
Simple Example
Assume a small LAN with two computers:
Device MAC Address
Computer A 00:1A:2B:11:22:33
Computer B 00:1A:2B:44:55:66
Computer A wants to send data to Computer B.
It places Computer B’s MAC address in the destination field of
the frame.
The switch checks the MAC address table and forwards the frame
only to Computer B.
Data reaches the correct device in the LAN.
Types of MAC Address
1. Unicast – Sent to a single device
Example: 00:1A:2B:3C:4D:5E
2. Multicast – Sent to a group of devices
Example: 01:00:5E:xx:xx:xx
3. Broadcast – Sent to all devices in the LAN
Example:
FF:FF:FF:FF:FF:FF
Explain Error Detection Methods in the Data
Link Layer
Error detection is an important function of the Data Link Layer.
It ensures that data frames received are free from transmission errors caused by
noise, interference, or signal distortion.
Types of Transmission Errors
Single-bit error – only one bit is altered
Multiple-bit error – more than one bit is altered
Burst error – a sequence of bits is altered
Error Detection Methods
1. Parity Check
a) Single Parity Check
One extra bit called parity bit is added.
Even parity: total number of 1s is even
Odd parity: total number of 1s is odd
Example (Even Parity)
Data: 1011001 (number of 1s = 4 → even)
Parity bit = 0
Transmitted data:
10110010
📌 Detects single-bit errors only.
b) Two-Dimensional Parity Check
Parity is calculated for rows and columns.
Better detection than single parity.
Example
1 0 1 | 0
0 1 1 | 0
1 1 0 | 0
---------
0 0 0
📌 Can detect burst errors more effectively.
2. Checksum
Data is divided into equal-sized blocks (usually 16 bits).
Blocks are added using 1’s complement arithmetic.
The 1’s complement of the sum is the checksum.
Receiver repeats the process.
Example
Data blocks:
10101010
01010101
Sum = 11111111
Checksum = 00000000
✔ Used in TCP/IP, UDP, and IP.
3. Cyclic Redundancy Check (CRC)
Most powerful error detection technique.
Based on binary division using a generator polynomial.
Remainder of the division is appended to the data.
Steps
1. Append (n–1) zeros to data (n = length of generator).
2. Divide the data by the generator polynomial.
3. Append the remainder as CRC bits.
4. Receiver divides again; zero remainder → no error.
Example
Data: 110101
Generator: 1011
Remainder = 100
Transmitted frame:
110101100
Detects single-bit, double-bit, and burst errors.
4. Longitudinal Redundancy Check (LRC)
Parity bits are added for each bit position.
Used along with block transmission.
Example
1010101
0101010
1110001
-------
0101110 ← LRC
Used in older communication systems.
Explain various Types of Error Correction
Techniques
Error correction techniques are broadly classified into:
1. Forward Error Correction (FEC)
2. Backward Error Correction (Retransmission / ARQ)
1. Forward Error Correction (FEC)
In FEC, the sender adds redundant bits so that the receiver can detect and
correct errors without retransmission.
a) Hamming Code
Most common FEC technique
Can detect and correct single-bit errors
Uses parity bits placed at positions that are powers of 2 (1, 2, 4, 8, …)
Example
Data bits: 1011
After adding parity bits (Hamming Code):
P1 P2 D1 P4 D2 D3 D4
Receiver identifies the error position and corrects it.
✔ Used where retransmission is costly or impossible.
Advantages of FEC
No need for retransmission
Suitable for real-time and noisy channels
Disadvantages of FEC
Extra bandwidth needed
Complex implementation
2. Backward Error Correction (Retransmission / ARQ)
In ARQ (Automatic Repeat reQuest), errors are detected and the receiver
requests retransmission.
a) Stop-and-Wait ARQ
Working
Sender sends one frame
Waits for ACK
If ACK not received → retransmits
Example
Frame 0 sent → ACK 0 lost
Sender retransmits Frame 0
b) Go-Back-N ARQ
Working
Sender can send multiple frames
If one frame is lost, all following frames are retransmitted
Example
Frames sent: 0 1 2 3
Frame 1 lost → resend 1 2 3
c) Selective Repeat ARQ
Working
Only the erroneous or lost frames are retransmitted
Receiver buffers correct frames
Example
Frames sent: 0 1 2 3
Frame 1 lost → resend only Frame 1