CN Notes
CN Notes
• No acknowledgment
• No retransmission
• No flow control
5. Identification
• Unique number for each datagram
• Used for fragmentation/reassembly
6. Flags (3 bits)
• Control fragmentation:
• DF (Don’t Fragment) → Packet must not be split
• MF (More Fragments) → More fragments follow
7. Fragment Offset
• Indicates position of fragment
• Measured in 8-byte units
9. Protocol
• TCP → 6
• Identifies upper-layer protocol:
• TCP → 6
• UDP → 17
• ICMP → 1
固 Fragmentation (Important
Concept) When packet size exceeds MTU:
• It is split into fragments
• Each fragment has:
• Same Identification
• Different Fragment Offset
• Reassembled at destination only
3. IPv4 Addressing
+ Structure of IPv4 Address
• 32 bits (4 bytes)
• Written in dotted decimal:
Example: 1 9 2 . 1 6 8 . 1 0 . 5
+ Network vs Host
Portion An IP address is divided
into:
• Network ID → identifies network
• Host ID → identifies device
This division is defined by the subnet mask
+ Classful Addressing
Class A
• Range: [Link] – [Link]
• Default mask: [Link]
• Large networks
Class B
• Range: [Link] – [Link]
• Default mask: [Link]
Class C
• Range: [Link] – [Link]
• Default mask: [Link]
Class D
• 224–239 → Multicast
Class E
• 240–255 → Experimental
+ Special IP
Addresses Private IP
Ranges
• [Link] – [Link]
• [Link] – [Link]
• [Link] – [Link]
Used inside LANs (notroutable on internet)
Loopback Address
• [Link] → localhost
Broadcast Address
• All host bits = 1
• Sends packet to all devices in network
Why Subnetting?
• Reduces network congestion
• Improves performance
• Enhances security
• Efficient IP allocation
+ Subnet Mask
Defines which bits belong to network vs host.
Example:
IP Address: [Link]
Subnet Mask: [Link]
• Network: [Link]
• Host: 10
+ CIDR
Notation Compact
format:
[Link] /24
Need: 4 subnets
1 [Link] .1 – .62 .6
3
2 [Link] .65 – .126 .12
7
3 [Link] .129 – .19
.190 1
4 [Link] .193 – .25
.254 5
+ Key Formulas
Number of Subnets
2^n (n = borrowed bits)
• subtract 2 for:
• Network address
• Broadcast address
+ Example
For /26:
• Host bits = 6
• Hosts = 2⁶ − 2 = 62 usable hosts
⚡ Final Summary
• IP Protocol → Handles addressing & routing
• Datagram Format → Defines packet structure
• IPv4 Addressing → Identifies devices
• Subnetting → Divides networks efficiently
Lecture 20:
1. Supernetting (Route Aggregation)
What is Supernetting?
Supernetting (also called route aggregation) is the process of combining multiple smaller IP
networks into one larger network to reduce routing table size.
Why is it needed?
• Reduces routing table entries
• Improves routing efficiency
• Saves memory and processing in routers
Example
Instead of having four separate networks:
• [Link]/24
• [Link]/24
• [Link]/24
• [Link]/24
Key Idea
• Borrow bits from the network portion
• Use a shorter prefix (CIDR notation)
Formula Insight
If combining (2^n) networks → reduce prefix by n bits
2. IPv6 Addressing
Why IPv6?
IPv4 (32-bit) provides ~4.3 billion addresses → not enough.
IPv6 solves this using:
• 128-bit addresses
• Vast address space (≈ (3.4 \times 10^{38}))
Simplification Rules
1. Remove leading zeros
• 0db8 → db8
2. Replace consecutive zeros with ::
2001:db8:: 8a2e: 370:7 334
2. Multicast
• One-to-many (selected group)
[Link]
• One-to-nearest (best route)
• Unspecified → ::
3. Applications of IPv6
1. Internet of Things (IoT)
• Every device can have a unique IP
• No need for NAT
3. Built-in Security
• Native support for IPsec
4. Auto-configuration
• Devices configure themselves (SLAAC)
Quick Summary
• Supernetting → combines networks to simplify routing
• IPv6 → solves address exhaustion with 128-bit addressing
• Applications → IoT, security, auto-config, efficient routing
Great—let’s work through exam-style numerical problems on supernetting and
IPv6 addressing, with step-by-step solutions.
Part 1: Supernetting Numericals
• [Link]/24
• [Link]/24
• [Link]/24
• [Link]/24
Final Answer
[Link]/22
• [Link]/24
• [Link]/24
Analysis
Networks must be:
• Contiguous
• Aligned in powers of 2
Here:
[Link]/20 Use
formula:
Answer
4096 IP addresses
Step 2: Range
• Start: [Link]
• End: [Link]
Answer
Range = [Link] → [Link]
Steps:
• Remove leading zeros
• Replace longest zero sequence
Answer:
2ΘΘ1:db8::ffΘΘ:42:8329
= 2^{(128 - 64)} =
2^{64} ]
Answer:
≈ 18 quintillion addresses
Rule:
• IPv6 multicast starts with FF
Answer:
Multicast Address
Problem 9: Subnetting IPv6
Given:
• Network: 2001:db8::/48
• Required subnets: 256
Step 1:
256 = (2^8)
Step 2:
New prefix:
[
48 + 8 = 56
]
Answer:
New subnet prefix = /56
[
\text{Subnets} = 2^2
=4]
= 2^{(32-26)} - 2 = 2^6 - 2 = 64 - 2 =
62 ]
Answer
• Subnets = 4
• Hosts per subnet = 62
[Link]/26 Block
size = 64
Subnets:
1. [Link] – [Link]
2. [Link] – [Link]
3. [Link] – [Link]
4. [Link] – [Link]
Problem 3: Find Network, Broadcast, Usable Range
IP: [Link]/27
Step 1: Block size
[
2^{(32-27)} = 32
]
Subnets increment by 32:
Answer
• Network = [Link]
• Broadcast = [Link]
• Usable = [Link] – [Link]
Step 1:
Find nearest power:
[
2^7 = 128
]
Step 2:
Hosts usable:
[
128 - 2 = 126
]
Step 3:
Prefix:
[
32 - 7 = 25
]
Answer
Use /25 subnet
Problem 5: Required Subnets
Given: [Link]/24
Need: 8 subnets
Step 1:
[
8 = 2^3
]
Step 2:
New prefix:
[
24 + 3 = 27
]
Answer
New subnet mask = /27
• At least 4 subnets
• Each subnet ≥ 50 hosts
Step 1: Hosts
[
2^6 = 64 → usable = 62
]
Step 2: Prefix:
[
32 - 6 = 26
]
Step 3: Subnets:
[
/24 → /26 → 2^2 = 4
]
Answer
Use /26
Step 1:
[
16 =
2^4 ]
Step 2:
[
48 + 4 =
52 ]
Answer
New prefix = /52
Problem 8: Hosts in IPv6 Subnet
Subnet: /64
Formula:
2^{(128 - 64)}
[
=
2^{64}
]
Answer
Extremely large (~18 quintillion)
Quick Tricks for Exams
✅ Block Size Shortcut
[
\text{Block size} = 256 - \text{subnet mask (last octet)}
]
Example:
• /27 → [Link]
• Block size = 32
✅ Fast Steps
1. Find required hosts or subnets
2. Convert to power of 2
3. Adjust prefix
4. Find range using block size
Lecture: 21
母 Routing in Computer Networks
(Unicast, Broadcast, Multicast, NAT, ICMP)
Routing is a core concept in Computer Networks that allows data packets to move from one
network/device to another through routers.
When you send a message, open a website, or stream a video, routing determines:
1. What is Routing?
Routing is the process of:
Selecting the best path for data packets from source to
• Routers
• Routing tables
• Routing protocols
贏 Example of Routing
Suppose:
Laptop → Home Router → ISP → Internet → Google
• Destination IP address
• Best next
hop/path Then
forwards the packet.
毯 Components of Routing
Component
Purpose
Router
Connects networks
IP Address
Identifies device
Routing Table Stores paths
Next Hop
Next router/device
Routing Protocol
Finds best route
篁 2. Unicast Communication
堕 Definition
Unicast means:
One sender communicates with one receiver.
★ Characteristics
• Most common communication type
• One-to-one transmission
• Uses unique destination IP
霭
Example
When you:
• Open YouTube
• Visit Google
• Send email
Your computer communicates with one server.
觑 Diagram
Sender ─────────► Receiver
甲 Real Example
PC IP: 1 92. 16 8.1 .1 0
Google IP: [Link]
✅ Advantages
• Efficient for private communication
• Reliable delivery
• Easy error checking
× Disadvantages
• More bandwidth if same data sent to many users
3. Broadcast Communication
堕 Definition
Broadcast means:
One sender sends data to ALL devices in the network.
Characteristics
• One-to-all communication
• Uses broadcast IP address
• Limited to local network (LAN)
Diagram
┌──► PC1
Sender ────┼──► PC2
└──► PC3
甲 Broadcast Address
Example subnet:
IP Address: [Link]
Subnet Mask: [Link]
Broadcast IP: [Link]
霭 Example Uses
ARP (Address Resolution Protocol)
A computer asks:
“Who has IP
✅ Advantages
• Useful for discovery protocols
• Easy communication to all hosts
× Disadvantages
• Creates unnecessary traffic
• Reduces network performance
• Routers usually block broadcasts
昱 4. Multicast Communication
堕 Definition
Multicast means:
One sender sends data to a selected group of receivers.
★ Characteristics
• One-to-many (selected)
• Efficient group communication
Diagram
┌──► Member1
Sender ────┤
└──► Member2
甲 Multicast IP
Range Class D IP addresses:
[Link] → [Link]
霭 Examples
• Live video streaming
• Online classes
• IPTV
• Video conferencing
✅ Advantages
• Saves bandwidth
• Efficient for group applications
× Disadvantages
• More complex routing
• Requires multicast support
囹 Comparison: Unicast vs Broadcast vs
Multicast
Feature Unicast Broadcast Multicast
• 192.168.x.x
• 10.x.x.x
• 172.16.x.x
Internet requires public IPs.
NAT Process
Private
Network
[Link]
│
▼
Router (NAT)
Public IP = 3 9 . 4 5 . 1 0 0 . 7
│
Internet
霭 Example
Suppose:
• Your laptop IP = [Link]
Inside LAN:
Source IP = 1 9 2 . 1 6 8 . 1 . 5
d Types of NAT
1⃞⃞ Static NAT
One private IP ↔ one public IP
✅ Advantages of NAT
• Saves IPv4
• addresses
• Provides security
Hides internal network
× Disadvantages
• Adds processing delay
• Breaks end-to-end connectivity sometimes
★ Purpose of ICMP
Routers/devices use ICMP to send:
• Error messages
• Network status
• Diagnostic information
觑 ICMP Example
PC ─────► Router ─────►
Server ×
Destination unreachable
Process
Your PC sends:
ICMP Echo Request
Google replies:
ICMP Echo Reply
It discovers:
• All routers between source and destination
Using ICMP TTL expiration.
ICMP and Security
Attackers may misuse ICMP:
• Ping flood
• Smurf attack
So firewalls sometimes block ICMP.
Step 2
Router performs NAT.
Step 3
Packet routed across Internet.
Step 4
ICMP may report errors if route fails.
Step 5
YouTube server replies.
霭 Summary
Concept Meaning
Routing Finding path for packets
Short Questions
1. Define routing.
Long Questions
1. Explain routing with diagram.
2. Compare unicast, multicast, and broadcast.
3. Explain NAT types with examples.
4. Explain ICMP messages and ping operation.
『 Numerical Example (Broadcast IP)
Given:
IP = [Link]
Mask = 25 5. 2 55 . 25 5. 0
[Link]
Lecture 22:
• IP Address
• Subnet Mask
• Default Gateway
• DNS Server
DHCP automates this process.
• 100 computers
• Multiple printers
• Student laptops
Manually assigning IP addresses to every device would:
1. IP Address
2. Subnet Mask
3. Default Gateway
4. DNS Server Address
5. Lease Time
Components of DHCP
1. DHCP Server
A server that assigns IP
addresses. Examples:
• Windows Server
• Linux DHCP Server
• Router acting as DHCP server
2. DHCP Client
A device requesting an IP
address. Examples:
• Laptop
• Mobile
phone • PC
DORA Process
Step 1: Discover
The client broadcasts a message:
“Is there any DHCP server available?”
Step 2: Offer
DHCP server replies:
“Yes, I can provide this IP address.”
Step 3: Request
Client responds:
Discover -------------------->
< - -- - -- - -- -- - -- - -- -- - Offer
Request - - -- - - - - -- - - - - -- - - - - >
DHCP Ports
DHCP uses UDP protocol.
1. DynamicAllocation
IP changes over
time. Example:
• Public WiFi
[Link] Allocation
Permanent IP assigned automatically.
3. Manual/Static Allocation
Administrator binds MAC address with fixed
IP. Example:
• Printer
• Server
Advantages of DHCP
Advantage Centralized Management Efficient IP Usage
Automatic Configuration
Prevents IP Conflicts
Explanation dministration
Reuses addresses
R
e
d
u
c
e
s
m
a
n
u
a
l
w
o
r
k
A
v
o
i
d
s
d
u
p
l
i
c
a
t
e
I
P
s
E
a
s
y
a
Disadvantages of DHCP
Disadvantage Explanation
Single Point of If DHCP server fails, clients cannot get
Failure Security IPs Rogue DHCP servers possible
Risks
Devices rely on DHCP server
Dependency
DHCP Example
Suppose a laptop joins a university
WiFi: DHCP assigns:
• IP: [Link]
• Subnet Mask: [Link]
• Gateway: [Link]
• DNS: [Link]
The laptop can now communicate on the network.
It is called:
• Distance → Metric (usually hopcount)
• Vector → Direction/path to destination
Basic Concept
Each router maintains a Routing Table containing:
• Destination Network
• Distance (Metric)
• Next Hop
Routers periodically exchange routing tables with neighbors.
Routing Table
Example Router A
Destination Distance Next Hop
Network 0 Direct
1
Network 1 Router B
2
Network 2 Router C
3
Distance Metric
The metric measures path
cost. Common metrics:
• Hop Count
• Delay
• Bandwidth
Most distance vector protocols use:
Hop Count
Hop Count Example
Router A ---- Router B ---- Router C
From A to C:
• Hop Count = 2
Bellman-Ford Algorithm
Distance Vector Routing
uses: Bellman-Ford
Algorithm
Step 1
Router sends routing table to neighbors.
Step 2
Neighbor compares routes.
Step 3
If better route found:
• Update routing table
Step 4
Repeat periodically.
Initially:
• A knows only B
• B knows A and C
• C knows only B
After updates:
2. IGRP
Interior Gateway Routing Protocol
Developed by:
• Cisco
Uses:
• Bandwidth
• Delay
• Reliability
Problems in Distance Vector Routing
1. Routing Loops
Packets circulate endlessly.
1. Split Horizon
Do not advertise route back to source.
2. Route Poisoning
Mark failed route with infinite metric.
Real-Life Analogy
DHCP
Like a hotel receptionist assigning room numbers to guests automatically.
Conclusion
DHCP
• Automates IP configuration
destination.
Unlike Distance Vector Routing:
• Distance Vector shares routing tables with neighbors only.
• Link State Routing shares link information with all routers.
Important Concepts
Ter Meaning
m
Connection between
Link
routers Condition/cost of
State
link
Topolo
gy Complete network
Cost map Metric of path
LSA Link State Advertisement
Working of Link State Routing
•
Reliability
Example:
• A to B cost = 2
• Router ID
• Neighbor list
• Link costs
• Sequence number
Step 4: Flooding
Router sends LSP to all routers in the
network. Flooding ensures:
B
/ \
A---C
Dijkstra's
Algorithm This
determines:
• Best route
• Lowest cost path
Dijkstra’s Algorithm
The algorithm calculates shortest path from source router to all destinations.
Example Network
A ---1---
B |
| 4
2 |
| C ---1-
-- D
• A →B → D
• Cost = 3
1. OSPF
Open Shortest Path
First Features:
• Open standard
• Uses Dijkstra algorithm
• Fast convergence
• Supports hierarchical routing
2. IS-IS
Intermediate System to Intermediate System
Commonly used by:
Routing in the
Internet Introduction
The Internet is a massive collection of interconnected
networks. Routing in the Internet involves:
• University network
• ISP network
• Company network
Each AS has:
Intra-AS Routing
Definition
Routing inside a single Autonomous
System. Also called:
• OSPF
• IS-IS
1. RIP
Routing Information Protocol
• Distance Vector
• Hop count metric
• Small networks
2. OSPF
Open Shortest Path First
• Link State
• Fast convergence
• Large enterprise networks
3. IS-IS
Intermediate System to Intermediate System
• ISP backbone routing
Inter-AS Routing
Definition
Routing between different Autonomous
Systems. Also called:
It is called:
• Path Vector Protocol
BGP Working
Routers called:
Border Routers
exchange:
• Reachability information
• AS path information
AS-PATH
BGP stores sequence of ASes a packet must travel through.
Example:
Types of BGP
Type Description
eBGP Between different
ASes iBGP Within same
AS
• Scalability
• Efficiency
• Management
Internet Routing Architecture
Internet
| | |
AS1 AS2 AS3
Each AS:
• Uses internal routing
• Connects externally through BGP
Real-Life Analogy
Intra-AS Routing
Like roads inside a university campus.
Inter-AS Routing
Like highways connecting different cities or countries.
Key Differences Between Routing Protocols
Protocol Type Algorithm
RIP Distance Vector Bellman-Ford
OSPF Link State Dijkstra
BGP Path Vector Policy-based
Conclusion
OSI Layer
Function
Application
Transport User services
1. Framing
2. Error Detection
3. Error Correction
4. Flow Control
5. Medium Access Control
6. Link Access
What is a Frame?
At the Link Layer, data is encapsulated into a structure called a
Wireless Technologies
• WiFi (802.11)
• Bluetooth
2. Link Layer Services
The Link Layer provides several services to the Network Layer.
A. Framing
The Link Layer groups bits into frames.
Example:
| Header | Data | CRC |
• Ethernet LANs
• WiFi networks
Example:
If multiple devices send simultaneously, collision occurs.
Protocols used:
• CSMA/CD (Ethernet)
• CSMA/CA (WiFi)
C. Reliable Delivery
Ensures frames arrive correctly.
Used mostly in:
• Wireless networks
• Noisy channels
Techniques:
• ACKs
• Retransmission
D. Flow Control
Prevents sender from overwhelming
receiver. Example:
• Fast sender
• Slow receiver
The Link Layer controls transmission speed.
E. Error Detection
Detects whether bits changed during
transmission. Methods:
1. Parity Check
2. Checksum
3. CRC
F. Error Correction
Some protocols can automatically correct
errors. Example:
• Hamming Code
• 48 bits long
• Written in hexadecimal
Example:
00:1A:2B:3C:4D:5E
Communication Example
Suppose:
• Laptop A sends data to Laptop
B Steps:
3. Frame transmitted
4. Receiver checks destination MAC
5. Data passed upward
• Noise
• Signal distortion
• Bit
flipping
Example:
Sent:
1011001
Receiv
ed:
101000
1
A. Parity Check
One of the simplest error detection methods.
Idea of Parity Bit
An extra bit is added to
data. Purpose:
Even Parity
If number of 1s is odd:
• Add parity bit = 1
If already even:
Example 1
Data:
1011001
Number of 1s = 4 (even)
Parity bit
= 0
Transmitte
d:
10110010
Example 2
Data:
1011011
Number of 1s = 5 (odd)
Parity bit
= 1
Transmitte
d:
10110111
• Error detected
Advantages of Parity Check
• Simple
• Low cost
• Easy implementation
Disadvantages
Cannot detect:
• Multiple bit errors in some cases
Example:
If two bits change:
• Parity may still remain correct
Types of Parity
Type Description
Single-bit parity One parity bit
Two-dimensional parity Row & column parity
• IP
•
TCP
•
UDP
Basic Idea
1. Divide data into fixed-size words
2. Add all words
3. Store result as checksum
4. Receiver repeats calculation
5. Compare results
Example of Checksum
Supposedata:
1010
1100
1001
11111
Step 2:
Overflow wrapped around.
Step 3:
Complement result.
At Receiver
Receiver:
• Adds received data
• Adds
checksum If result is
correct:
• No error
Otherwise:
• Error detected
Advantages of Checksum
• Better than parity
Real-World Example
Suppose you download a
file. During transmission:
• Noise changes
bits. The checksum at
receiver:
• Detects
corruption. Then:
Important Terms
Term Meaning
Frame Link Layer data unit
MAC Physical device address
Address Detect transmission
Error errors Extra bit for
Detection parity
Parity Sum used for validation
Bit
Checks
um
Summary
The Link Layer is responsible for:
• Node-to-node communication
• Framing
• Physical addressing
• Error detection
• Medium access control
Important concepts include:
• MAC addressing
• Frames
• Parity checking
• Checksum method
Error detection ensures reliable communication by identifying corrupted frames before data reaches
upper layers.
Lecture 25:
It is used in:
• Ethernet
• WiFi
• Hard disks
• USB
• Satellite communication
CRC belongs to the Link Layer (Data Link Layer).
• Noise
• Signal interference
• Electromagnetic disturbance
may change bits.
Example:
Sent:
110101
Received:
110111
CRC bits
These bits are appended to the original data.
CRC
Process
Sender Side
Step 1: Select Generator Polynomial
Examp
le:
1011
Length = 4
bits Degree
=3
110101
Append 3 zeros:
110101000
Step 3: Binary Division (Modulo-2 Division)
Perform XOR division using
generator. Rules:
• No borrowing
• No carrying
• XOR operation
only XOR rules:
A B XOR
0 0 0
0 1 1
1 0 1
1 1 0
(Data + remainder)
Receiver Side
Receiver performs the same division.
If remainder = 0
→ No error detected
If remainder ≠ 0
→ Error detected
Why CRC is Powerful
CRC can detect:
• Single-bit errors
• Double-bit errors
• Burst errors
Especially effective for burst errors.
Burst Error
Multiple consecutive bits become
corrupted. Example:
111000111
↓
110111111
Advantages of CRC
Advantage Explanation
High Detects many error patterns
accuracy Fast hardware
Efficient implementation Used in
Reliable realnetworks
Detects burst Better than parity/checksum
errors
Disadvantages of CRC
• Slightly complex
• Requires polynomial division hardware/software
Polynomial Representation
Binary:
1011
Polynomial:
x³ + x + 1
• Generator =
1101 The sender:
1. Appends zeros
2. Divides using XOR
3. Adds remainder
Receiver:
1. Repeats division
2. Checks remainder
Channel Partitioning Protocols
In a shared communication channel:
• Multiple users want to transmit
simultaneously. Question:
1. TDMA
2. FDMA
3. CDMA
These are called:
Working of TDMA
Example:
Suppose 4
users: •
A
•
B
•
C
• D
Time division:
Visualization
| A | B | C | D | A | B | C | D
• Simple concept
Disadvantages
• Time synchronization required
• Empty slots waste bandwidth
Example:
If user B has no data:
• Slot remains unused
Real-World Uses
• GSM mobile networks
• Satellite communication
Working of FDMA
Example:
F4 D
Frequency Band User
F1 A
F2 B
F3 C
F4 D
All users transmit simultaneously.
Visualization
Frequency
Spectrum
|A|B|C|D|
Features of FDMA
Feature Description
Separate frequencies
Yes Simultaneous
transmission Yes Guard
bands needed Yes
Guard Bands
Small unused frequency gaps to prevent interference.
Advantages of FDMA
• Continuous transmission possible
• No time synchronization needed
• Low delay
Disadvantages
• Bandwidth wastage
• Guard bands reduce efficiency
• Limited frequencies
Real-World Uses
• Radio broadcasting
• Traditional telephone systems
3. CDMA (Code Division Multiple Access)
CDMA is more
advanced. In CDMA:
• Same time
But:
• Different unique codes are assigned.
Analogy
Imagine:
• Many people speaking in different languages
simultaneously. You understand only:
• Your
language.
Similarly:
Working of CDMA
Suppose:
• User A code = 1010
• User B code = 1100
Signals overlap.
Receiver:
• Uses correlation techniques
Features of CDMA
Feature Description
Same frequency
Yes Same time
Yes Different
codes Yes
Advantages of CDMA
• High capacity
Disadvantages
• Complex implementation
• Difficult code management
• Expensive hardware
Real-World Uses
• 3G mobile
systems • GPS
• Military communication
Comparison of TDMA,FDMA, and CDMA
Feature TDMA FDMA CDMA
Example Analogy
Imagine a classroom:
TDMA
Students speak one after another.
FDMA
Students speak at same time but different rooms.
CDMA
Students speak together in same room but different languages.
Summary
CRC
• Powerful error detection technique
FDMA
• Divides channel using frequencies
CDMA
• Uses unique codes for multiple users
These techniques are fundamental in:
• Wireless communication
• Cellular networks
• Satellite systems
• Modern networking systems
Lecture 26:
“How can multiple users transmit data without interfering with each other?”
Category Examples
Channel TDMA, FDMA, CDMA
Partitioning
Random Access ALOHA, Slotted ALOHA,
CSMA
Taking Turns Polling, Token Passing
Here we focus on:
1. ALOHA
2. Slotted ALOHA
These are:
Collision occurs
What is Collision?
Collision occurs when:
• Two or more devices send frames at the same time on the same
channel. Result:
ALOHA Protocol
ALOHA is one of the earliest random access protocols.
Developed at:
University of
Hawaii Used
originally for:
No checking.
No synchronization.
If collision occurs:
• Wait random time
• Retransmit
Step 1
Station A transmits immediately.
Step 2
Receiver sends acknowledgment
(ACK). If ACK received:
• Transmission
successful If ACK not
received:
• Collision assumed
Step 3
Station waits random amount of time.
Then retransmits.
Signals overlap:
Collision occurs
Vulnerable Time
The time during which another transmission can cause collision.
For Pure ALOHA:
Why 2T?
Suppose:
• Frame transmission time = T
Collision occurs if another frame starts:
• T time before transmission
• T time after transmission
Tot
al:
2T
18 .4%
Meaning:
• Only 18.4% of channel capacity used
successfully. Very inefficient.
Advantages of Pure ALOHA
Advantage Explanation
Simple Easy implementation
No synchronization Stations independent
Flexible Easy for distributed systems
Slotted ALOHA
Slotted ALOHA improves Pure
ALOHA. Idea:
transmit:
4| If Station A wants to
send:
time.
36 .8%
Example Scenario
Suppose:
• 5 users share channel.
In Pure ALOHA
Users transmit anytime:
• Many overlaps
• More collisions
In Slotted ALOHA
Users wait for slots:
• Better coordination
• Fewer collisions
Mathematical Understanding
Where:
• ( G ) = average transmission attempts
• ( S ) = successful
throughput Pure ALOHA:
• Throughput improves.
Real-World Importance
ALOHA concepts influenced:
• Ethernet
• WiFi
• Modern MAC protocols
Though Pure ALOHA is rarely used directly today, its principles are foundational in networking.
Important Terms
Term Meaning
Collision Simultaneous transmissions
Summary
Pure ALOHA
• Send anytime
• Very simple
• High collisions
• Efficiency = 18.4%
Slotted ALOHA
• Time divided into slots
• Lower collision probability
• Better efficiency = 36.8%
Both are important random access protocols that laid the foundation for modern medium access
control techniques used in computer networks.
Lecture 27:
Collision occurs
To reduce or avoid collisions, networks use:
1. CSMA/CD
2. CSMA/CA
3. ARP (Address Resolution Protocol)
These concepts are covered in Chapter 5 of the book by James F. Kurose.
A station:
2. If idle → transmit.
3. If busy → wait.
This reduces collisions compared to ALOHA.
• Fewer collisions
• Better efficiency
Example of CSMA
Suppose:
• Station A transmitting.
• Station B wants to
send. Station B:
• Waits.
After channel becomes free:
• B transmits.
Limitation of CSMA
Due to propagation delay:
• Two stations may still start transmission simultaneously.
Thus:
Ethernet LANs
Basic Idea
Stations:
1. Sense channel before transmission.
2. Continue monitoring during transmission.
3. Detect collisions if they occur.
4. Stop transmission immediately after collision detection.
Key Concept
Sense → Transmit → Detect Collision → Stop → Retransmit
Working of CSMA/CD
• Idle → transmit
• Busy → wait
Step 2: Transmission
Station starts sending frame.
• Collision detected.
Jam Signal
Purpose:
• Inform all devices about collision.
Example of CSMA/CD
Suppose:
• A and B sense channel idle simultaneously.
• Both transmit.
• Signals collide.
Stations:
• Detect collision
• Send jam signal
• Stop transmission
Advantages of CSMA/CD
Advantage Explanation
Better efficiency Fewer
collisions Immediate collision handling
Saves bandwidth Dynamic sharing
Flexible
Disadvantages
Disadvantage Explanation
Collisions still occur Not collision-free
CSMA/CA
Working of CSMA/CA
•
Wait If
idle:
• Continue
• Channel remains
idle When timer becomes
zero:
• Transmit frame
This reduces simultaneous transmissions.
Acknowledgment Mechanism
Receiver sends:
ACK (Acknowledgment)
If sender does not receive ACK:
• Collision assumed
• Retransmission occurs
RTS/CTS Mechanism
Optional feature in WiFi.
• Collision at B.
RTS/CTS helps prevent this.
RTS/CTS Working
Step 1
Sender sends RTS.
Step 2
Receiver replies CTS.
Step 3
Other devices hearing CTS remain silent.
Step 4
Sender transmits safely.
Advantages of CSMA/CA
Advantage Explanation
Suitable for wireless Avoids collisions
Better wireless performance Efficient medium
sharing RTS/CTS improves reliability Handles
hidden terminals
Disadvantages
Disadvantage Explanation
More overhead ACKs,timers,
RTS/CTS Backoff
Delay due to
increases latency
waiting Not
Collisions still
collision-free
possible
Comparison: CSMA/CD vs CSMA/CA
Feature CSMA/CD CSMA/CA
Used In Ethernet WiFi
Collision Handling Detects collision Avoids collision
Collision Detection Yes No
ACK Required No Yes
RTS/CTS No Optional
Suitable for Wireless No Yes
• MAC addresses
But applications usually know:
• IP
addresses
Question:
IP? Answer:
ARP
Example
Suppose:
Device IP Address MAC Address
A [Link] AA-
AA B [Link]
BB-BB A wants to send
packet to B. A knows:
• B’s IP
address But needs:
• B’s MAC
address ARP resolves
this.
ARP Working
Otherwise:
• Send ARP Request
Broadcast MAC:
FF:FF:FF:FF:FF:FF
unicast.
Step 4: ARP Cache Update
Sender stores mapping:
IP MAC
[Link] BB-BB
Future communication faster.
ARP Packet Fields
Field Purpose
Sender IP Source IP
Sender MAC Source MAC
Target IP Destination IP
Target MAC Destination MAC
Types of ARP
Type Description
Standard ARP IP → MAC
Gratuitous ARP Announces own
IP/MAC Reverse ARP (RARP) MAC → IP
ARP Cache
Temporary table storing
mappings. Command in Linux:
arp - a
or
ip neigh
Advantages of ARP
Advantage Explanation
Automatic mapping Easy
communication Fast local communication
Uses cache
• Man-in-the-middle attacks
• Traffic interception
Summary
CSMA/CD
• Used in Ethernet
• Detects collisions
• Stops transmission immediately after collision
CSMA/CA
• Used in WiFi
• Avoids collisions before transmission
• UsesACKs and backoff timers
ARP
• Maps IP addresses to MAC addresses
• TCP
• UDP
The checksum method belongs to the Link Layer and also used in higher layers like the Transport
Layer.
• Noise
• Signal interference
• Hardware
faults may change
bits.
Example:
Sent:
1Θ1Θ1Θ1Θ
Receiv
ed:
1Θ1Θ11
1Θ
2. Add segments
3. Add carry (if any)
4. Take 1’s complement
5. Attach checksum
At Receiver:
1. Add all segments including checksum
2. If result = all
1s → No
error
3. Else
→ Error detected
Example of Checksum (Detailed)
Suppose sender wants to transmit three 4-bit words.
Data words:
1Θ1Θ
11ΘΘ
1ΘΘ1
1Θ11Θ
Result:
1Θ11Θ
• Leftmost carry = 1
• Remaining bits = 0110
Add carry back:
Θ11Θ
+ 1
Θ111
Intermediate result:
Θ111
Binary addition:
Θ111
+ 1ΘΘ1
------
1ΘΘΘΘ
Again:
• Carry = 1
• Remaining bits = 0000
Add carry back:
0000
+ 1
0001
Final sum:
0001
• Change 1
→ 0 Complement
of:
0001
is:
11
10
This becomes:
Checksum
Step 4: Transmitted Data
Sender sends:
Data
Word 1
1010 Word 2
1100 Word 3
1001
Checksum
1110
Receiver Side Verification
Receiver receives:
1010
1100
1001
1110
Carry
wraparound:
0110 + 1 =
0111
10000
Carry
wraparound:
0000 + 1 =
0001
Step 7: Add Checksum
0001
1110
1111
Res
ult:
111
1
Step 8: Complement Result
Complement of:
1111
is:
0000
No Error Detected
Transmission successful.
1010
1100
1011
1110
Notice:
• Original = 1001
• Changed = 1011
Now receiver performs addition.
Final result will NOT become:
1111
Thus:
Error Detected
Important Concept: 1’s Complement Addition
In checksum:
• Extra carry is wrapped around and added again.
This is very important.
Advantages of Checksum
Advantage Explanation
Sim Easy to implement
ple
Efficient
Fast
computation
Better than Detects more
parity Widely errors
used
TCP/IP protocols
Disadvantages of Checksum
Disadvantage Explanation
Cannot detect all errors Some patterns remain
undetected Less powerful than CRC CRC more reliable
• Mistake detected.
Checksum works similarly.
Mathematical View
Supposedata
words: D1, D2,
D3
Checksum:
Checksum = Complement(D1 + D2 +
D 1 + D 2 + D 3 + Checksum = All 1 s
•
TCP
•
UDP
• IP headers
• File downloads
• Memory systems
Example:
When downloading files:
• Checksum verifies integrity.
Summary
Sender
1. Divide data into words
2. Add all words
3. Wrap carry
4. Take complement
5. Send checksum
Receiver
1. Add all received words
2. Add checksum
3. If result = all 1s
→ No error
4. Else
→ Error detected
Key Points
• Checksum detects transmission errors.
• Uses binary addition and complement arithmetic.
• More powerful than parity checking.
• Simpler but less powerful than CRC.
• Widely used in networking protocols like TCP/IP.