CHAPTER: DATA LINK LAYER
TOPIC INTRODUCTION TO DATA LINK LAYER
1. What is Data Link Layer?
The Data Link Layer is the 2nd layer of the OSI model.
It works between the Physical Layer and the Network Layer.
Its main job is:
👉 To transfer data from one device to another device directly
connected on the same network
👉 And to make sure the data is delivered without errors
2. Position in OSI Model
OSI Model Layers:
Physical Layer
Data Link Layer ← (This chapter)
Network Layer
Transport Layer
Session Layer
Presentation Layer
Application Layer
3. Why Do We Need Data Link Layer?
The Physical Layer only sends raw bits (0 and 1).
But raw bits alone are not enough.
Problems that can happen:
Bits may get corrupted
Two devices may send data at the same time
No way to identify which device sent the data
No guarantee data reached correctly
So Data Link Layer solves these problems.
4. Main Responsibilities of Data Link Layer
1. Framing
It divides data into small units called Frames.
Think of a frame like an envelope that carries a letter.
2. Physical Addressing
It adds MAC address (Hardware address).
So data reaches the correct device.
3. Error Detection and Correction
It checks whether data is corrupted.
If error is found → it asks to resend.
4. Flow Control
It controls the speed of sending data.
So the receiver is not overloaded.
5. Access Control
If multiple devices use same channel,
it decides who can send data first.
5. Real Life Example to Understand Data Link Layer
Imagine you are sending a parcel inside your city.
Physical Layer = The road
Data Link Layer = The courier company
What courier company does:
✔ Puts parcel in proper packaging (Framing)
✔ Writes sender and receiver address (MAC Address)
✔ Checks if parcel is damaged (Error Detection)
✔ Sends parcels at proper speed (Flow Control)
✔ Manages many parcels at same time (Access Control)
Without courier company, parcel system would be chaotic.
Same way, without Data Link Layer, communication would fail.
6. Where Is Data Link Layer Used?
It is used in:
Ethernet (LAN)
WiFi
Bluetooth
Switches
Local network communication
Whenever two devices are directly connected, Data Link Layer
works.
7. Two Sublayers of Data Link Layer
Data Link Layer has two parts:
1. LLC (Logical Link Control)
Error control
Flow control
2. MAC (Medium Access Control)
MAC addressing
Access control
We will study them later in detail.
8. Simple Technical Summary
Data Link Layer:
Converts raw bits into frames
Adds MAC address
Detects errors
Controls flow of data
Manages channel access
It ensures reliable communication between two directly connected
devices.
TOPIC : DESIGN ISSUES OF DATA LINK LAYER
1. What Are Design Issues?
“Design issues” means:
👉 What problems must be solved while designing the Data Link
Layer?
When engineers design this layer, they must answer some
important questions like:
How should data be divided?
How to detect errors?
How to control speed?
How to avoid collision?
How to manage communication?
These problems are called Design Issues of Data Link Layer.
Main Design Issues
There are mainly 5 important design issues:
Framing
Physical Addressing
Flow Control
Error Control
Access Control
Now we study each one in detail.
1. FRAMING
What is Framing?
The Network Layer sends a large block of data.
Data Link Layer divides that data into small units called:
👉 Frames
A frame is like a structured packet with:
Header
Data
Trailer
Why Framing is Needed?
Because sending a very large block of data:
Is hard to manage
Errors become difficult to detect
Resending becomes difficult
So we break data into small manageable pieces.
Real Life Example
Imagine sending a 200-page book.
Instead of sending the whole book in one parcel, you divide it into
10 smaller packages.
If one package is damaged, you resend only that package.
That is framing.
Types of Framing Methods
Character Count
Byte Stuffing
Bit Stuffing
Physical Layer Coding Violation
2. PHYSICAL ADDRESSING
Each device in a network has a unique address called:
👉 MAC Address (Media Access Control Address)
Data Link Layer adds source and destination MAC address.
Why It Is Needed?
Because inside a local network:
Many devices are connected.
Without MAC address, data won’t know where to go.
Real Life Example
In an apartment building:
Each flat has a number.
If a courier comes without flat number, delivery becomes
impossible.
MAC address = Flat number.
3. FLOW CONTROL
What is Flow Control?
It controls the speed of sending data.
It ensures:
👉 Fast sender does not overwhelm slow receiver.
Why It Is Important?
Suppose:
Sender speed = 100 Mbps
Receiver speed = 10 Mbps
Without control, receiver buffer will overflow.
Data will be lost.
Real Life Example
Imagine pouring water into a glass.
If you pour too fast, water will overflow.
Flow control = controlling speed of pouring.
4. ERROR CONTROL
What is Error Control?
During transmission, data may get corrupted.
Data Link Layer:
✔ Detects error
✔ Sometimes corrects error
✔ Or asks for retransmission
Why Errors Occur?
Electrical noise
Signal interference
Weak connection
Real Life Example
Suppose someone tells you a phone number.
If you hear wrongly, you ask them to repeat.
That is error control.
5. ACCESS CONTROL
What is Access Control?
When multiple devices share the same channel:
Who should send data first?
This problem is called:
👉 Channel Access Problem
Data Link Layer decides:
✔ Which device can send
✔ When it can send
Real Life Example
Imagine 5 people in a meeting.
If everyone speaks at the same time, no one understands
anything.
So one person speaks at a time.
That rule = Access Control.
Summary of Design Issues
Design Issue
Purpose
Framing
Divide data into frames
Physical Addressing
Add MAC address
Flow Control
Control sending speed
Error Control
Detect & correct errors
Access Control
Manage multiple users
TOPIC : ERROR DETECTION AND CORRECTION
1. Why Errors Happen in Communication?
When data travels from one device to another, it moves through:
Wires
Optical fiber
Air (WiFi)
During transmission, signals may get disturbed due to:
Electrical noise
Signal interference
Weak signal
Hardware issues
Because of this, bits may change.
Example:
Sent: 1011001
Received: 1010001
One bit changed → this is called an error.
2. What is Error Detection?
Error Detection means:
👉 Finding whether the received data is correct or corrupted.
The receiver checks the data using special techniques.
If error is found: Receiver asks sender to resend.
3. What is Error Correction?
Error Correction means:
👉 Detecting and also fixing the error without asking for
retransmission.
This is more complex and requires extra bits.
4. Types of Errors
1. Single Bit Error
Only one bit changes.
Example:
Sent: 10101010
Received: 10100010
Only one bit changed.
2. Burst Error
Multiple consecutive bits change.
Example:
Sent: 111000111
Received: 111111111
Many bits changed.
Burst errors are more common in real life.
5. Error Detection Techniques
Now we study important techniques in detail.
1. PARITY CHECK
What is Parity?
Parity means checking whether number of 1s is even or odd.
Two types:
Even Parity
Odd Parity
Even Parity
Total number of 1s must be EVEN.
Example:
Data: 1011001
Number of 1s = 4 (Even)
Parity bit = 0 (No change needed)
If number of 1s was odd → add 1 to make even.
Why It Is Used
When data travels through a network, noise or disturbance can
change bits (0 becomes 1 or 1 becomes 0).
Parity check helps detect if such an error has occurred.
→ Types of Parity
→ Even Parity
The total number of 1s (including the parity bit) should be even.
Example:
Data = 1011001
Number of 1s = 4 (already even)
Parity bit = 0
Transmitted data = 10110010
If one bit changes during transmission, the number of 1s
becomes odd → error detected.
→ Odd Parity
The total number of 1s (including the parity bit) should be odd.
Example:
Data = 1011001
Number of 1s = 4 (even)
Parity bit = 1
Transmitted data = 10110011
Now total 1s = 5 (odd).
→ How It Works
→ Sender counts number of 1s
→ Adds parity bit
→ Receiver again counts 1s
→ If parity rule is violated → error is detected
Real Life Example
Imagine teacher counting students.
If class should have 30 students, but count is 29, something is
wrong.
Parity bit works like counting.
Limitation
Parity can detect:
✔ Single bit error
But cannot detect:
✘ Even number of errors
2. CHECKSUM
What is Checksum?
Data is divided into equal parts.
All parts are added.
Final sum is sent with data.
Receiver also adds and compares.
If result differs → error detected.
Real Life Example
Suppose shopkeeper gives you 5 items.
You check total price on bill.
If total is wrong, you detect error.
Checksum = Total calculation.
3. CRC (Cyclic Redundancy Check)
This is the most powerful and commonly used method.
Used in:
Ethernet
WiFi
Hard disks
How CRC Works (Simple Idea)
Data is treated like a binary number.
It is divided by a special binary number (Generator).
Remainder is added to data.
Receiver performs same division.
If remainder = 0 → No error
If remainder ≠ 0 → Error
Basic Idea
→ Data is treated as a binary number
→ A predefined binary number called Generator
Polynomial (G) is selected
→ Data is divided by this generator using binary division
→ The remainder obtained is called CRC code
→ This remainder is added to the original data before
transmission
→ Steps in CRC
→ Step 1: Choose generator polynomial (example: 1011)
→ Step 2: Append zeros to data equal to degree of
generator
→ Step 3: Perform binary division (modulo-2 division)
→ Step 4: Remainder obtained is CRC
→ Step 5: Add remainder to original data and transmit
→ At Receiver Side
→ Receiver divides received data by same generator
→ If remainder = 0 → No error
→ If remainder ≠ 0 → Error detected
→ Example (Simple Conceptual)
Data = 1101
Generator = 1011
After division, remainder = 100
Transmitted data = 1101100
If receiver division gives non-zero remainder → error
present
Real Life Example
Think of CRC like a digital signature.
If someone changes even one bit, signature verification fails.
CRC is very powerful in detecting burst errors.
6. Error Correction Technique
Now we study correction.
HAMMING CODE
Hamming Code can:
✔ Detect
✔ Correct single bit error
How It Works
Extra bits are added at special positions.
These bits help locate the exact position of error.
Why Hamming Code is Needed
→ During transmission, bits may change due to noise
→ Parity can only detect errors
→ Hamming Code can detect and correct single-bit errors
→ Basic Idea
→ Extra bits called Parity Bits are added at specific
positions
→ These positions are powers of 2
Positions of parity bits:
→1
→2
→4
→8
→ 16
Remaining positions are data bits.
→ Number of Parity Bits Formula
If m = number of data bits
r = number of parity bits
Then condition is:
2^r ≥ m + r + 1
This formula helps to calculate required parity bits.
→ Working of Hamming Code
→ Step 1: Place parity bits at positions 1, 2, 4, 8…
→ Step 2: Fill data bits in remaining positions
→ Step 3: Each parity bit checks specific positions
→ Step 4: Parity bits are calculated using even parity
(generally)
→ Error Detection and Correction
At receiver:
→ Recalculate parity bits
→ If all parity bits are correct → No error
→ If some parity bits show error → Add their position
numbers
→ The sum gives the position of the error bit
→ Correct that bit
→ Example (Simple Concept)
Suppose 4 data bits: 1011
We need 3 parity bits (because 2³ ≥ 4+3+1 = 8)
Total bits = 7
Positions:
1 (P1)
2 (P2)
3 (D1)
4 (P4)
5 (D2)
6 (D3)
7 (D4)
After calculating parity, code is formed.
If bit at position 6 changes → Receiver detects error at
position 6 and corrects it.
→ Advantages
→ Detects and corrects single-bit errors
→ Detects double-bit errors (but cannot correct them)
→ More reliable than parity
→ Limitation
→ Cannot correct multiple-bit errors
→ Slightly complex
Then that bit is flipped.
Real Life Example
Imagine exam paper with roll numbers.
If one digit is wrong, system can identify which digit is incorrect
and correct it.
That is Hamming code logic.
Let’s understand Hamming Code in a very simple, everyday way.
Think of it like this:
When you send a WhatsApp message, sometimes the network
can disturb one letter.
Hamming code is a smart method that not only detects an error
but also corrects one wrong bit automatically.
It is used in computer memory, networking, and digital
communication.
1 The Basic Idea
1️⃣
Suppose you want to send 4 bits of data:
Copy code
Data = 1011
But during transmission, one bit might flip (0 becomes 1 or 1
becomes 0).
So we add some extra bits called parity bits to detect and correct
errors.
These extra bits are placed at special positions.
2️⃣Where Do We Place Parity Bits?
In Hamming code:
Parity bits are placed at positions that are powers of 2.
Positions:
1 → P1
2 → P2
4 → P4
8 → P8
Other positions are data bits.
So for 4 data bits, we need 3 parity bits.
Total positions = 7 bits.
Positions look like this:
Position
1
2
3
4
5
6
7
Type
P1
P2
D1
P4
D2
D3
D4
3️⃣Place Data in Correct Positions
Data = 1 0 1 1
Fill it:
Position
1
2
3
4
5
6
7
Value
P1
P2
1
P4
0
1
1
Now we calculate parity bits.
4️⃣How Parity Works (Simple Rule)
We use even parity (total number of 1s should be even).
🔹 P1 checks positions:
1, 3, 5, 7
Values: P1, 1, 0, 1
Count 1s (excluding P1):
1 + 0 + 1 = 2 (already even)
So P1 = 0 (to keep even)
🔹 P2 checks positions:
2, 3, 6, 7
Values: P2, 1, 1, 1
1 + 1 + 1 = 3 (odd)
To make even → P2 = 1
🔹 P4 checks positions:
4, 5, 6, 7
Values: P4, 0, 1, 1
0 + 1 + 1 = 2 (even)
So P4 = 0
5️⃣Final Hamming Code
Position
1
2
3
4
5
6
7
Value
0
1
1
0
0
1
1
Final transmitted code:
Copy code
0110011
6️⃣Suppose an Error Happens
Imagine during transmission bit 5 changes:
Received:
Copy code
0110111
Now receiver checks parity again.
Each parity bit will detect something wrong.
When we combine the wrong parity positions:
Suppose P1 → correct
P2 → wrong
P4 → wrong
Binary of wrong positions = 110
That means position 6 is wrong.
So we flip bit 6 → error corrected.
This is the beauty of Hamming code.
Very good question 👍
This is the heart of Hamming code.
It is not random.
It is decided using binary position numbers.
Step Write Position Numbers in Binary
1️⃣
For 7-bit Hamming code:
Position
Binary
1
001
2
010
3
011
4
100
5
101
6
110
7
111
Now observe carefully.
Step Rule for Parity Bits
2️⃣
Each parity bit checks positions where its binary bit is 1.
Parity positions are powers of 2:
P1 → position 1 → binary 001
P2 → position 2 → binary 010
P4 → position 4 → binary 100
Now see what each parity covers.
🔹 Why P2 takes 2, 3, 6, 7
P2 is at position 2 → binary 010
Now check all positions whose second bit (middle bit) is 1.
Look at table:
Position
Binary
Middle Bit
1
001
0
2
010
1
3
011
1
4
100
0
5
101
0
6
110
1
7
111
1
So positions where middle bit = 1 are:
👉 2, 3, 6, 7
That’s why P2 checks those positions.
🔹 Why P1 takes 1, 3, 5, 7
P1 is at position 1 → binary 001
It checks positions where last bit = 1
Those are:
1 (001)
3 (011)
5 (101)
7 (111)
🔹 Why P4 takes 4, 5, 6, 7
P4 is at position 4 → binary 100
It checks positions where first bit = 1
Those are:
4 (100)
5 (101)
6 (110)
7 (111)
Why This System Is Smart
Each position number has a unique binary representation.
So if an error happens at position 6:
6 in binary = 110
That means:
P1 → no error (last bit 0)
P2 → error (middle bit 1)
P4 → error (first bit 1)
So parity check result = 110 → 6
That tells exactly which position is wrong.
Simple Analogy
Think of binary bits like 3 switches:
Switch 1 → P1
Switch 2 → P2
Switch 3 → P4
Each position turns on certain switches.
If something goes wrong, the combination of wrong switches tells
the exact position.
Final Simple Rule
A parity bit at position 2ⁿ checks all positions where the nth bit (in
binary) is 1.
That’s how it is decided.
Not random. Pure binary logic.
If you understand this, Hamming code becomes very easy.
7️⃣Simple Real-Life Analogy
Think of it like:
You pack 4 items in a box.
You attach 3 security seals.
Each seal checks specific items.
If something changes, seals tell exactly which item is wrong.
Not just “something is wrong”
But “item number 5 is wrong”.
That is powerful.
Why It’s Important
✔ Detects 1-bit error
✔ Corrects 1-bit error
✔ Used in RAM memory
✔ Used in satellites
✔ Used in digital communication
Simple Summary
Hamming Code:
Adds smart check bits
Detects AND corrects one error
Uses binary position logic
Very efficient
7. Detection vs Correction
Feature
Error Detection Error Correction
Finds error Yes. Yes
Fixes error No Yes
Extra bits required Less. More
Complexity. Low. High
8. Why Detection is More Common Than Correction?
Because:
Correction requires many extra bits.
It increases bandwidth usage.
Retransmission is often cheaper.
So usually:
Detect error → ask sender to resend.
9. Complete Real-Life Understanding
Imagine courier service.
If parcel damaged:
Option 1: Tell sender to resend (Error Detection)
Option 2: Repair parcel yourself (Error Correction)
Repairing is harder and costly.
So mostly resend is used.
Summary
Error Detection and Correction ensures:
Reliable communication
Data integrity
Correct data delivery
Main techniques:
Parity
Checksum
CRC
Hamming Code
TOPIC : ELEMENTARY DATA LINK PROTOCOLS
1. What is a Protocol?
A protocol is a set of rules.
It tells:
How data is sent
When data is sent
What happens if error occurs
How acknowledgement works
In simple words:
👉 Protocol = Communication rules between sender and receiver.
2. Why Study Elementary Protocols?
These are basic models used to understand:
Flow control
Error control
Acknowledgement system
Retransmission
They are theoretical but very important for exams and
understanding advanced protocols.
Types of Elementary Data Link Protocols
There are mainly 3 basic protocols:
Simplest Protocol
Stop-and-Wait Protocol
Stop-and-Wait ARQ Protocol
Now we study each in complete detail.
1. THE SIMPLEST PROTOCOL
Assumptions
No errors occur
Receiver can handle infinite data
No data loss
Perfect channel
This is unrealistic but used for understanding basics.
How It Works
Sender sends frame.
Receiver receives frame.
No acknowledgement.
Sender continues sending.
Very simple.
Real Life Example
Imagine you are putting letters into a magical box.
You are 100% sure:
Letters will never get lost
Receiver can handle unlimited letters
No damage
So you keep putting letters without waiting.
This is simplest protocol.
Limitation
In real life:
Errors occur
Receiver buffer is limited
Frames can be lost
So this protocol is not practical.
2. STOP-AND-WAIT PROTOCOL (Flow Control)
Now we improve the system.
Here:
Receiver has limited capacity.
How It Works
Sender sends ONE frame.
Sender stops.
Waits for acknowledgement (ACK).
After ACK → sends next frame.
Why It Is Needed?
Because receiver may be slower.
If sender keeps sending continuously, receiver buffer may
overflow.
Real Life Example
Imagine passing water bottles to someone.
You:
Give one bottle.
Wait until person says “Got it”.
Then give next.
You do not throw 10 bottles at once.
That is Stop-and-Wait.
Advantages
✔ Prevents overflow
✔ Simple
✔ Easy to implement
Disadvantage
✘ Slow
✘ Wastes time while waiting
If distance is large, waiting time increases.
3. STOP-AND-WAIT ARQ (Error Control)
Now we add error control.
ARQ = Automatic Repeat reQuest
What Happens Here?
Sender sends one frame.
Receiver checks for error.
If correct → sends ACK.
If error → sends NAK (Negative ACK) or no response.
Sender resends frame.
Real Life Example
You send a WhatsApp message.
If message not delivered, you resend it.
Or if friend says “message unclear”, you resend.
That is Stop-and-Wait ARQ.
Important Concept: Sequence Number
To avoid confusion, each frame is given a sequence number (0 or
1).
Why?
Because sometimes ACK may get lost.
Sender must know which frame was acknowledged.
Problem of Duplicate Frames
If ACK is lost:
Sender resends frame.
Receiver may receive same frame again.
Sequence number helps receiver detect duplicate.
Why These Protocols Are Important?
They form base for:
Sliding Window Protocol
Go-Back-N
Selective Repeat
TCP
Without understanding these, advanced protocols are difficult.
Summary
Elementary Protocols teach:
How communication starts
Why acknowledgement is needed
Why sequence numbers are important
How retransmission works
They are the foundation of reliable data transfer.
TOPIC : SLIDING WINDOW PROTOCOL
1. Why Do We Need Sliding Window?
In Stop-and-Wait:
Sender sends 1 frame
Waits for ACK
Sends next
This is slow, especially when distance is large.
Example:
If transmission time = 1 ms
But waiting time = 20 ms
Most time is wasted in waiting.
So we need a better system.
That better system is:
👉 Sliding Window Protocol
2. What is Sliding Window Protocol?
It allows sender to send multiple frames before waiting for ACK.
Instead of sending 1 frame, sender can send many frames
continuously.
This increases speed and efficiency.
3. Basic Idea
Sender keeps a “window” of frames it can send.
Receiver also keeps a “window” of frames it can receive.
As ACKs come, the window moves forward.
That is why it is called Sliding Window.
4. What is a Window?
Window = A group of sequence numbers that can be sent without
waiting.
Example:
Window size = 4
Sender can send:
Frame 0
Frame 1
Frame 2
Frame 3
Without waiting.
After ACK for Frame 0 comes, window slides forward.
Now sender can send Frame 4.
5. Real Life Example
Imagine you are sending books through courier.
Stop-and-Wait: Send one book. Wait for confirmation. Send next.
Sliding Window: Send 4 books together. After confirmation of first
book, send next one.
This saves time.
6. Key Concepts
1. Sequence Numbers
Each frame has a sequence number.
Example: 0, 1, 2, 3, 4, 5, 6, 7 (if 3-bit sequence number)
Role of Sequence Number in Sliding Window Protocol
Sequence number is used to uniquely identify each frame in data
transmission.
It plays a very important role in reliability and order control.
→ Why Sequence Number is Needed
→ To identify each frame uniquely
→ To maintain correct order of frames
→ To detect lost frames
→ To detect duplicate frames
→ To manage sliding window properly
→ How It Works
Suppose sequence numbers are:
0, 1, 2, 3, 4, 5, 6, 7
Window size = 4
Sender sends:
→ Frame 0
→ Frame 1
→ Frame 2
→ Frame 3
Receiver sends ACK for specific sequence numbers.
If frame 2 is lost:
Receiver notices missing sequence number 2
It knows exactly which frame is missing.
Without sequence numbers, receiver cannot know which frame
was lost.
→ Preventing Duplicate Frames
If ACK is lost, sender may resend a frame.
Receiver checks sequence number.
If same number already received → duplicate → discard
it.
→ Sequence Number and Window Size Relation
If m bits are used for sequence number:
Maximum sequence numbers = 2^m
Example:
If m = 3 bits
Sequence numbers = 0 to 7 (total 8 numbers)
Window size depends on protocol:
→ Go-Back-N: Window size ≤ 2^m − 1
→ Selective Repeat: Window size ≤ 2^(m−1)
This avoids confusion when numbers repeat.
→ Real-Life Example
Think of sequence number like page numbers in a book.
If page 25 is missing, you immediately know.
If two page 30 appear, you detect duplication.
→ Final Conclusion
Sequence number ensures:
→ Correct order
→ Error detection
→ Duplicate control
→ Proper sliding of window
Without sequence numbers, sliding window protocol cannot work
properly.
Sequence numbers repeat after limit.
Meaning of “Sequence Numbers Repeat After Limit”
In sliding window protocol, sequence numbers are finite, not
infinite.
If m bits are used for sequence number, then:
→ Total sequence numbers = 2^m
→ After reaching the maximum number, numbering starts
again from 0
This is called wrap around.
→ Example
If m = 3 bits
Possible sequence numbers are:
0, 1, 2, 3, 4, 5, 6, 7
(2³ = 8 numbers)
After 7, next sequence number will again be:
0, 1, 2, 3 …
So numbers repeat cyclically.
→ Why This Happens
Because only 3 bits are available.
With 3 bits, maximum number we can represent is 7 (111 in
binary).
We cannot go beyond that.
→ Why It Is Important
If sequence numbers repeat carelessly, receiver may get
confused between:
→ Old frame 0
and
→ New frame 0
To avoid confusion:
→ In Go-Back-N:
Window size ≤ 2^m − 1
→ In Selective Repeat:
Window size ≤ 2^(m−1)
This ensures old and new frames are not mixed.
→ Simple Real-Life Example
Think of a clock:
After 12 comes 1 again.
Time repeats, but we understand it because movement is
controlled.
Similarly, sequence numbers repeat, but window rules prevent
confusion.
2. Sender Window
Frames sender is allowed to send.
3. Receiver Window
Frames receiver is allowed to accept.
What is Window?
Window means the number of frames that can be sent without
waiting for acknowledgment (ACK).
Example:
Window size = 4
Sender can send 4 frames before waiting.
→ What Happens After First Window?
Suppose frames are numbered:
0, 1, 2, 3, 4, 5, 6, 7 …
If window size = 4
First window sends:
→ Frame 0
→ Frame 1
→ Frame 2
→ Frame 3
Now sender waits for ACK.
→ When ACK Comes
If ACK for frame 0 is received:
The window slides forward by one position
Now window becomes:
→ Frame 1
→ Frame 2
→ Frame 3
→ Frame 4
So frame 4 is new, not repeated.
→ Important Point
✔ Frames are NOT repeated normally
✔ Window moves forward
✔ New frames are sent
Frames are repeated only if there is an error or frame loss.
→ Simple Real-Life Example
Think of a train with 4 compartments allowed on a bridge at one
time.
When first compartment crosses and signal comes,
another new compartment enters.
The same 4 compartments do not repeat —
they move forward.
7. Types of Sliding Window Protocol
There are two main types:
Go-Back-N ARQ
Selective Repeat ARQ
1. GO-BACK-N ARQ
How It Works
Sender can send multiple frames.
If one frame has error, receiver discards that frame and all after it.
Sender goes back and resends all frames from error frame.
Example
Sender sends:
0, 1, 2, 3, 4
Suppose frame 2 is lost.
Receiver receives: 0, 1
Then sees problem at 2.
It discards 3 and 4.
Sender must resend: 2, 3, 4
Real Life Example
Teacher collecting assignments in order.
If roll number 3 is missing, she stops and asks again from 3
onwards.
Even if 4 and 5 came, she ignores them.
That is Go-Back-N.
Advantage
✔ Simple
✔ Easy to implement
Disadvantage
✘ Wastes bandwidth
✘ Many frames resent even if correct
2. SELECTIVE REPEAT ARQ
How It Works
Only incorrect or lost frame is resent.
Correct frames are stored.
Receiver accepts out-of-order frames.
Example
Sender sends:
0, 1, 2, 3, 4
Frame 2 is lost.
Receiver receives: 0, 1, (missing 2), 3, 4
Receiver stores 3 and 4.
Sender resends only frame 2.
Real Life Example
Suppose 5 parcels are delivered.
Parcel 3 missing.
You keep parcel 4 and 5 safely. Ask only for parcel 3 again.
That is Selective Repeat.
Advantage
✔ Efficient
✔ Saves bandwidth
Disadvantage
✘ Complex
✘ Needs more memory
8. Why Sliding Window Is Important?
Because it:
✔ Improves efficiency
✔ Improves throughput
✔ Reduces waiting time
✔ Used in real systems like TCP
[Link] Real-Life Understanding
Stop-and-Wait = One truck at a time
Sliding Window = Multiple trucks on highway
More trucks → Faster delivery.
Summary
Sliding Window Protocol:
Allows multiple frames transmission
Uses sequence numbers
Improves efficiency
Has two types:
Go-Back-N
Selective Repeat
TOPIC : HDLC (High-Level Data Link Control)
1. What is HDLC?
HDLC stands for:
👉 High-Level Data Link Control
It is a bit-oriented protocol used for:
Reliable communication
Error control
Flow control
Frame synchronization
It works at the Data Link Layer.
2. Why HDLC Was Developed?
Earlier protocols were:
Character-oriented
Less efficient
Limited in features
HDLC was developed to:
✔ Provide reliable communication
✔ Support both point-to-point and multipoint
✔ Handle errors efficiently
✔ Work on synchronous transmission
3. Where Is HDLC Used?
Used in:
WAN connections
Router-to-router communication
Leased lines
ISDN
4. Important Features of HDLC
✔ Bit-oriented protocol
✔ Supports full-duplex and half-duplex
✔ Provides error detection (CRC)
✔ Uses sliding window flow control
✔ Uses acknowledgements
5. HDLC Frame Format (Very Important)
HDLC frame has fixed structure:
| Flag | Address | Control | Data | FCS | Flag |
Now we explain each field in detail.
1. Flag Field
Size: 8 bits
Pattern: 01111110
It marks:
👉 Beginning and end of frame
This helps receiver know where frame starts and ends.
Real Life Example
Think of flag like:
📦 Opening and closing tape of a parcel.
Without it, you don’t know where parcel begins.
2. Address Field
Identifies secondary station
Used in multipoint communication
In point-to-point, it may not be very important.
Real Life Example
Like writing house number on envelope.
3. Control Field (Very Important)
It controls:
Type of frame
Sequence numbers
Acknowledgements
Control field decides whether frame is:
Information frame
Supervisory frame
Unnumbered frame
We study them now.
6. Types of HDLC Frames
1. I-Frame (Information Frame)
Used for:
✔ Carrying actual data
✔ Includes sequence number
✔ Includes acknowledgement
Used in normal data transfer.
2. S-Frame (Supervisory Frame)
Used for:
✔ Error control
✔ Flow control
✔ Sending ACK or NAK
Does not carry actual data.
3. U-Frame (Unnumbered Frame)
Used for:
✔ Link management
✔ Connection setup
✔ Disconnection
Example: Starting or ending communication.
7. FCS (Frame Check Sequence)
This field:
✔ Detects errors
✔ Uses CRC method
If CRC check fails → frame discarded.
8. Bit Stuffing (Very Important)
Since flag is:
01111110
If data accidentally contains this pattern, receiver may think frame
ended.
To avoid this:
👉 After 5 consecutive 1s, sender inserts a 0.
This is called:
Bit Stuffing
Receiver removes extra 0.
Real Life Example
Suppose your special ending word is “STOP”.
If message contains word “STOP” accidentally, confusion
happens.
So you modify message slightly to avoid confusion.
That is bit stuffing logic.
9. Real Life Full Understanding
Imagine two offices connected by private line.
HDLC:
✔ Organizes data into frames
✔ Adds address
✔ Controls flow
✔ Detects error
✔ Manages connection start and end
It works like a disciplined communication manager.
10. Why HDLC Is Important?
Because:
✔ It is a real implementation
✔ Based on sliding window
✔ Used in WAN
✔ Foundation for PPP
Summary
HDLC:
Bit-oriented protocol
Uses flags for frame boundary
Uses CRC for error detection
Uses sliding window
Has 3 types of frames
Supports reliable communication
TOPIC: THE DATA LINK LAYER IN THE INTERNET
1. Role of Data Link Layer in the Internet
In the Internet:
Data travels from your device to remote servers across multiple
networks.
Between two directly connected devices (like your
computer ↔ router, router ↔ another router), the Data
Link Layer ensures:
Frames are properly formed
Physical addressing is applied (MAC addresses)
Errors are detected and possibly corrected
Multiple devices can share the same medium efficiently
Key Point
The Internet uses many technologies, but whenever data moves
locally between two nodes, the Data Link Layer is active.
Examples:
Your computer → Home router (WiFi/Ethernet)
Router → Switch in ISP network
Switch → Another router in backbone
At each hop, the Data Link Layer handles framing, addressing,
and error control, even though the overall Internet routing is done
by the Network Layer (IP).
2. How Data Link Layer Works in Internet Communication
When you send a packet over the Internet:
Network Layer (IP) adds logical addresses (IP addresses)
Data Link Layer takes that packet → puts it into a frame
Frame includes MAC addresses for the next-hop device (not the
final destination)
Frame is sent over physical medium (Ethernet, WiFi, Fiber)
Receiver checks for errors using CRC
Correct frames are accepted; errors may request retransmission
Real Life Example
Imagine sending a letter from Delhi to Mumbai through multiple
post offices:
Letter has destination city (IP address) → used by postal
system
At each post office (hop), the letter has local handling info (MAC
address equivalent)
Each office ensures the parcel is intact (error check)
After passing multiple offices, the letter reaches the recipient
Data Link Layer = Handling the letter at each local office
Network Layer = Knowing the final city/destination
3. Real-Life Understanding in Internet Context
When you watch a YouTube video:
Video packet has IP address (Network Layer) → Mumbai
server
Your laptop uses Ethernet/WiFi (Data Link Layer) to send packet
to router
Router uses Ethernet/PPP (Data Link Layer) to forward to next
router
Each hop ensures frames are intact and addresses are correct
Conclusion: The Data Link Layer is the “local traffic manager” at
each hop, while the Network Layer handles the “long-distance
delivery.”
4. Why Data Link Layer is Crucial for Internet
Ensures reliable local transmission
Handles physical addressing for next hop
Detects and corrects errors locally → prevents corrupt
data reaching far nodes
Manages multiple devices on same link → avoids
collisions
Without it:
Packets would get lost on local networks
Collisions would increase
Internet efficiency would drop dramatically
Quick Analogy
Network Layer = planning a trip from Delhi → Mumbai
Data Link Layer = the taxi driver handling you from one
street → next street, ensuring no crash along the way
Physical Layer = the road itself
All three work together to ensure your “trip” (data transmission)
reaches safely.
✅TOPIC: THE MEDIUM ACCESS CONTROL (MAC) SUBLAYER
1. Introduction
The Data Link Layer is divided into two sublayers:
Logical Link Control (LLC) – handles error control, flow control,
and framing.
Medium Access Control (MAC) – handles how multiple devices
share the same communication channel.
Why MAC?
When multiple devices share the same medium (e.g., WiFi,
Ethernet), they can interfere with each other.
👉 MAC decides who can send data, when, and how, to avoid
collisions.
2. The Channel Allocation Problem
What is it?
Imagine multiple devices connected to a single channel.
Only one device can send at a time; otherwise, signals collide.
The problem: How to allocate the channel fairly and efficiently
among all devices?
Real-Life Example
Imagine 10 people sharing one microphone:
If two speak at the same time → confusion (collision)
Need a system to decide who speaks first
That is exactly what the channel allocation problem is for
networks.
3. Goals of MAC Sublayer
Fairness – every device should get a chance to send.
Efficiency – minimize idle time and collisions.
Priority Handling – some data (like video) may need higher
priority.
Flexibility – work in both wired and wireless networks.
4. Types of Multiple Access Protocols
The MAC sublayer solves the channel allocation problem using
multiple access protocols.
They are broadly classified as:
Random Access Protocols
Controlled Access Protocols
Channelization (Divided Channel) Protocols
4A. RANDOM ACCESS PROTOCOLS
How it works:
A device sends whenever it has data.
If collision occurs → it waits random time and tries again.
Characteristics:
Simple
Efficient when traffic is low
Collisions possible
Examples:
ALOHA
Pure ALOHA: send whenever you want; collision detected later
Slotted ALOHA: divide time into slots → send only at slot
start → reduces collisions
CSMA (Carrier Sense Multiple Access)
Device listens to the channel first
If idle → send
If busy → wait
Variants:
CSMA/CD (Collision Detection, wired Ethernet)
CSMA/CA (Collision Avoidance, WiFi)
Real-Life Example
Random Access = people sharing one road without traffic signals:
Each car enters whenever it wants
If two cars collide → stop, wait, and retry
Efficiency decreases as more cars enter
4B. CONTROLLED ACCESS PROTOCOLS
How it works:
Devices take turns
No collisions
Methods:
Polling – a central controller asks each device in turn “Do you
want to send?”
Token Passing – a special token circulates; only the device with
the token can send
Real-Life Example
Polling = Teacher asking students one by one to speak
Token Passing = Talking stick in a meeting; only person holding it
can speak
4C. CHANNELIZATION (DIVIDED CHANNEL) PROTOCOLS
How it works:
Divide the channel into separate parts: time, frequency, or codes
Methods:
TDMA (Time Division Multiple Access) – each device gets a time
slot
FDMA (Frequency Division Multiple Access) – each device gets a
frequency band
CDMA (Code Division Multiple Access) – each device uses a
unique code
Real-Life Example
TDMA = Everyone gets 5 minutes each to speak
FDMA = Each person has their own radio channel
CDMA = Everyone talks simultaneously, but listeners can filter by
code
5. Real-Life Internet Context
WiFi → uses CSMA/CA (random access with collision
avoidance)
Ethernet → uses CSMA/CD (collision detection in wired
LAN)
Cellular Networks → TDMA/FDMA/CDMA for mobile access
Token Ring Networks → token passing (rare now, but
classic example)
Conclusion:
The MAC sublayer is the traffic controller of local networks,
ensuring devices share the channel efficiently and fairly.
✅TOPIC: ETHERNET AND DATA LINK LAYER SWITCHING
1. Ethernet Overview
Ethernet is the most widely used LAN technology.
It operates at:
Physical Layer → the cables, wires, or wireless signals
Data Link Layer → framing, addressing, error detection
Key Features of Ethernet
Media Access Method: CSMA/CD (Carrier Sense Multiple Access
with Collision Detection)
Frame Structure: Uses MAC addresses to deliver frames
Speeds:
Traditional: 10 Mbps (Ethernet)
Fast Ethernet: 100 Mbps
Gigabit Ethernet: 1 Gbps
10/40/100 Gbps in modern networks
Topology: Star (modern), Bus (historical)
Real-Life Example
Your home network uses Ethernet cables from the router
to PC → this is Ethernet in action.
MAC address = like a house number for your device
CSMA/CD = traffic rules for who sends data first
2. Ethernet Frame Format
Ethernet frame contains:
Field
Size
Purpose
Preamble
7 bytes
Synchronization
Start Frame Delimiter (SFD)
1 byte
Marks frame start
Destination MAC
6 bytes
Receiver address
Source MAC
6 bytes
Sender address
Type
2 bytes
Protocol type (IP, ARP, etc.)
Data
46–1500 bytes
Actual payload
FCS (CRC)
4 bytes
Error detection
Structure of Ethernet Frame
The Ethernet frame contains the following fields:
→ 1. Preamble (7 bytes)
→ Used for synchronization
→ Helps receiver understand that a new frame is coming
→ Pattern: 10101010 repeated
→ 2. Start Frame Delimiter (SFD) (1 byte)
→ Indicates start of actual frame
→ Pattern: 10101011
→ 3. Destination MAC Address (6 bytes)
→ Address of receiving device
→ 48-bit physical address
→ 4. Source MAC Address (6 bytes)
→ Address of sending device
→ 48-bit physical address
→ 5. Type / Length Field (2 bytes)
→ In Ethernet II → Specifies protocol type (IP, ARP etc.)
→ In IEEE 802.3 → Specifies length of data field
→ 6. Data (Payload) (46 to 1500 bytes)
→ Actual data being transmitted
→ If data < 46 bytes → Padding is added
→ 7. CRC (Frame Check Sequence) (4 bytes)
→ Used for error detection
→ Based on CRC method
→ Minimum and Maximum Frame Size
→ Minimum size = 64 bytes
→ Maximum size = 1518 bytes (without VLAN)
Preamble | SFD | Dest MAC | Source MAC | Type/Length | Data |
CRC
Purpose of Ethernet Frame
→ Encapsulates data
→ Identifies sender and receiver
→ Detects transmission errors
Real-Life Analogy
Preamble/SFD = knocking on the door
Destination MAC = house number
Source MAC = your home address
Data = letter inside the envelope
FCS = seal to check damage
3. Data Link Layer Switching
Switching is used in Ethernet to improve efficiency:
A switch connects multiple devices
Switch forwards frames only to the destination port
Uses MAC address table (also called forwarding table)
How Switching Works
Learning: Switch observes source MAC addresses and
remembers which device is on which port.
Forwarding: Switch checks destination MAC and sends frame
only to that port.
Flooding: If destination MAC unknown → frame is sent to
all ports except source (like broadcasting).
Real-Life Example
Imagine an apartment building with 10 flats
Each flat = a device
Switch = building’s mail sorter
Letter (frame) = has destination address (MAC)
Mail sorter learns where each flat is (MAC table) and delivers
letters efficiently
4. Types of Switching
Store-and-Forward Switching
Switch receives full frame → checks errors using FCS →
forwards frame if correct
Pros: Error-free
Cons: Slight delay
Cut-Through Switching
Switch reads destination MAC first → forwards frame
immediately
Pros: Faster
Cons: May forward corrupted frames
5. Advantages of Ethernet Switching
Reduces collisions → full-duplex possible
Efficient frame delivery → only to the intended port
Scalable → supports large LANs
Supports VLANs (Virtual LANs) → logical segmentation
TOPIC: WIRELESS LAN, BROADBAND WIRELESS, AND
BLUETOOTH
1. Wireless LAN (WLAN)
Definition
A WLAN is a Local Area Network that uses wireless
communication instead of cables.
Commonly used for home, office, and campus networks.
Operates at 2.4 GHz or 5 GHz frequencies.
Key Features
Uses radio waves instead of wires
Supports mobility → devices can move freely
Implements CSMA/CA (Carrier Sense Multiple Access with
Collision Avoidance)
Usually based on IEEE 802.11 standards (WiFi)
Real-Life Example
Your home WiFi connecting your laptop, mobile, and smart TV is
a WLAN.
No cables are needed; the router acts as an access point (AP).
How MAC Works in WLAN
Multiple devices share the same frequency → potential
collisions
CSMA/CA is used:
Device listens before sending
If medium idle → send data
If busy → waits a random backoff time
Collisions are avoided, not detected (unlike Ethernet CSMA/CD)
Real-Life Analogy
Imagine people talking in a room, but instead of interrupting each
other, they wait for a signal from a coordinator before speaking.
2. Broadband Wireless Access
Definition
Provides high-speed Internet without physical cables over a wide
area.
Includes technologies like WiMAX (IEEE 802.16) and 4G/5G
cellular networks.
Key Features
High data rates (Mbps to Gbps)
Covers long distances (up to several km)
Uses frequency division and time division to allow multiple users
Real-Life Example
Your home WiMAX router or 4G/5G mobile data uses broadband
wireless.
A single tower serves multiple homes, providing high-speed
Internet wirelessly.
MAC in Broadband Wireless
Uses scheduling and polling to allocate channels
Avoids collisions with centralized coordination
Supports QoS (Quality of Service) → critical for video
calls, streaming
Analogy
Imagine a highway with traffic lights:
Each car gets a time slot to move
Traffic is coordinated → avoids accidents (collisions)
3. Bluetooth
Definition
Bluetooth is a short-range wireless technology
Operates at 2.4 GHz ISM band
Designed for personal area networks (PAN) → connecting
nearby devices
Key Features
Range: ~10 meters (Class 2 devices)
Low power consumption → suitable for mobile devices
Supports point-to-point and point-to-multipoint connections
Uses frequency hopping to avoid interference
Bluetooth Topology
Piconet: One master + up to 7 active slaves
Scatternet: Multiple piconets interconnected
MAC in Bluetooth
Uses polling by the master → only the device polled can
send data
Reduces collisions in short-range wireless environment
Real-Life Example
Connecting your phone to wireless headphones
Pairing smartwatch with phone
Connecting keyboard or mouse to laptop wirelessly
Frequency hopping ensures interference with WiFi or other
devices is minimized.
4. Real-Life Understanding
WLAN = Your office/home WiFi → local wireless LAN
Broadband Wireless = ISP providing high-speed wireless Internet
over town or city
Bluetooth = Connecting devices like headphones, keyboards, or
smartwatches
All three operate at Data Link Layer, with their MAC sublayer
handling medium access, collisions, and addressing.
5.. Summary
Wireless networks require careful channel allocation →
MAC protocols ensure fairness and efficiency
WLAN → local wireless, CSMA/CA
Broadband Wireless → long-range, scheduled access
Bluetooth → very short-range, master-slave polling
Key takeaway: MAC protocols are crucial in all wireless networks
to avoid collisions and ensure reliable communication.