Framing
Framing is the process of breaking a continuous stream of data into smaller,
manageable parts called frames.
Purpose of Framing:
• Error Detection: Helps find and isolate errors.
• Flow Control: Manages how data flows between sender and receiver.
• Multiple Access: Allows many devices to use one channel efficiently.
Techniques of Framing:
• Byte Counting: Frame starts with the number of bytes.
• Character Counting: A special character marks the end of the frame.
• Bit Stuffing: Extra bits are added to avoid confusion with control patterns.
• Physical Layer Coding Violations: Uses illegal bit patterns to mark frame
boundaries.
Error Control
Error control ensures that data is delivered accurately and correctly during
transmission.
Error Detection Techniques:
• Parity Check: Adds a bit to make the number of 1s either even or odd.
• Checksum: Data is added up; the total is checked by the receiver.
• CRC (Cyclic Redundancy Check): Uses math (polynomial division) to detect
errors.
Error Correction Technique:
• ARQ (Automatic Repeat Request): Resends data when errors are found.
Types of ARQ:
• Stop-and-Wait: Sends one frame, waits for acknowledgment.
• Go-Back-N: Sends many frames; if error found, resends from the failed one.
• Selective Repeat: Only resends the specific frame that had an error.
Flow Control Mechanisms
Flow control ensures that the sender doesn’t overload the receiver during data
transmission.
I. Feedback-Based Flow Control
1. Stop-and-Wait
• Sends one frame at a time.
• Waits for an ACK (Acknowledgment) before sending the next.
• If no ACK received within timeout, frame is retransmitted.
• Advantage: Simple.
• Disadvantage: Slow; waits after every frame.
2. Sliding Window
• Sends multiple frames before needing an ACK.
• Uses a window size to control how many frames can be sent.
• Receiver sends ACK for the last correctly received frame, confirming all
previous ones too.
• Advantage: Faster and more efficient than Stop-and-Wait.
• Disadvantage: Needs more memory and control logic.
II. Rate-Based Flow Control
1. Leaky Bucket Algorithm
• Incoming data is collected in a bucket (buffer).
• Data is sent out at a fixed rate, like a steady leak.
• Prevents sudden data bursts from overwhelming the system.
• Advantage: Maintains a smooth data flow and avoids congestion.
2. Token Bucket Algorithm
• Like leaky bucket but allows bursts of data.
• Tokens are added to a bucket at a steady rate.
• To send data, the sender must use a token per unit of data.
• If enough tokens exist, data can be sent quickly.
• Advantage: More flexible than leaky bucket; allows occasional high-speed
transmission.
Error Detection and Correction Techniques
These techniques ensure that data sent over a network arrives correctly. They add extra
bits to help detect and fix errors during transmission.
Error Detection Techniques
1. Parity Check:
• Adds one extra bit to data (parity bit).
• Two types:
o Even Parity: Makes total number of 1s even.
o Odd Parity: Makes total number of 1s odd.
• Example:
o Data: 1101
o Even parity: 11010
o Odd parity: 11011
• Limitation: Only detects odd number of errors (e.g., 1-bit error).
2. Checksum:
• Adds up all data bits in binary and sends the result (checksum) along with the
data.
• Receiver adds the data again and compares checksum.
• Example:
o Data: 1010 + 1100 + 0111 = 10101
o Discard overflow bit: 0101 (Checksum)
o Transmit: 1010 1100 0111 0101
• Limitation: Might miss some types of multi-bit errors.
3. CRC (Cyclic Redundancy Check):
• Uses polynomial division to generate a special code (CRC bits).
• Receiver performs same division to check for errors.
• Example:
o Data: 11010110
o Generator: 1011
o Remainder: 0010
o Transmit: 11010110 0010
• Advantage: Can detect burst errors and more complex issues.
Error Correction Technique
Hamming Code:
• Adds multiple parity bits to the data.
• Can detect and correct 1-bit errors.
• Example:
o Data: 1101
o Hamming Code: 1110101
o If error occurs (e.g., becomes 1110111), receiver uses parity bits to find
and fix it.
Stop-and-Wait Protocol (Simplified)
Definition:
A basic and reliable method for sending data in networks where each frame is
acknowledged before sending the next.
Key Points:
• One Frame at a Time: Sender sends one frame, then waits.
• ACK Required: Receiver sends an acknowledgment (ACK) after receiving the
frame.
• Timeout: If no ACK is received in time, the sender resends the frame.
Working:
1. Sender sends a frame with a sequence number.
2. Receiver gets it and sends back an ACK.
3. If sender receives ACK → sends next frame.
If not → resends the same frame.
Advantages:
• Very simple.
• Reliable data transfer.
Disadvantages:
• Slow.
• Wastes bandwidth due to waiting.
Sliding Window Protocol (Simplified)
Definition:
An efficient method where the sender can send multiple frames before needing
ACKs, improving speed and bandwidth usage.
Key Terms:
• Sender Window: Number of frames sender can send without waiting.
• Receiver Window: Number of frames receiver can accept and buffer.
Types of Sliding Window Protocols:
1. Go-Back-N ARQ
• Sender sends multiple frames at once (up to window size).
• If one frame is lost or has an error, the sender goes back and resends all
frames from that point onward.
• Receiver discards any frames received after the error until the correct one
arrives.
• Simple but wasteful if many good frames are resent.
Good for simple systems
Wastes bandwidth on retransmitting correct frames
2. Selective Repeat ARQ
• Sender also sends multiple frames.
• But if a frame has an error, only that frame is retransmitted.
• Receiver keeps the correct frames and sends ACKs for them.
• Efficient but needs more memory to store out-of-order frames.
Efficient bandwidth usage
More complex, needs extra buffer
ALOHA Protocol (Simplified)
Purpose:
A protocol that helps multiple devices share a common communication
channel, especially in wireless networks.
1. Pure ALOHA
• Devices send data anytime, without checking the channel.
• If two send at the same time, collision happens.
• After collision, devices wait a random time before trying again.
Very simple
High chance of collisions → less efficient (~18% max efficiency)
2. Slotted ALOHA (Simplified Notes)
Why Slotted ALOHA?
Pure ALOHA allows sending anytime, which leads to high collisions. Slotted
ALOHA reduces this issue by organizing time.
Key Concepts:
• Time is Divided into Slots:
Data transmission is allowed only at the beginning of time slots.
• Synchronization Required:
All stations must wait for the next time slot to send data. This makes the
system more organized.
• Reduced Collisions:
Since stations wait for slot boundaries, fewer transmissions overlap, leading to
better efficiency than Pure ALOHA.
• Collision Handling:
If two or more stations send at the same slot, a collision occurs.
The stations then wait for a random number of slots before trying again.
Efficiency Comparison:
• Slotted ALOHA Efficiency: ~37%
• Pure ALOHA Efficiency: ~18%
Quick Protocol Comparison Table
Protocol Efficiency Complexity Notes
Stop-and- Sends one frame,
Low Simple
Wait ARQ waits for ACK
Go-Back-N Resends all frames
Medium Moderate
ARQ from the error frame
Selective Only retransmits
High Complex
Repeat ARQ erroneous frames
High collision risk
Pure ALOHA Low (~18%) Simple due to unslotted
time
Time is divided into
Slotted Medium
Moderate slots, fewer
ALOHA (~37%)
collisions
1. CSMA (Carrier Sense Multiple Access)
• Devices check if the line is free before sending data.
• If busy, they wait.
• No central controller.
• Used in Ethernet & Wi-Fi.
• Helps reduce collisions.
2. CSMA/CD (with Collision Detection)
• Used in wired networks (like Ethernet).
• Device detects collision while sending.
• If a collision happens:
o Stop sending.
o Wait for a random time (backoff).
o Then retry.
• Works well for wired networks, but not for wireless.
3. CSMA/CA (with Collision Avoidance)
• Used in wireless networks (like Wi-Fi).
• Devices try to avoid collisions before sending.
• Uses ACKs (Acknowledgments) and timers.
• Doesn’t detect collisions (unlike CSMA/CD).
• Better for wireless reliability.
CSMA vs CSMA/CD – Comparison Table
CSMA (Carrier
CSMA/CD (With
Aspect Sense Multiple
Collision Detection)
Access)
Devices listen and
Devices listen before
Basic Function detect collisions during
transmitting.
transmission.
Collision Tries to avoid Detects collisions and
Handling collisions by sensing. reacts accordingly.
Collision Not equipped to Detects collisions
Detection detect collisions. during transmission.
Device doesn’t know; Transmission stops
What Happens
data might get immediately, followed
on Collision
corrupted. by backoff.
Uses Exponential
Backoff Not applicable (no
Backoff to retry after a
Algorithm detection).
random delay.
Works in both wired
Works only in wired
Environment and wireless (e.g.,
networks (Ethernet).
Wi-Fi).
Less efficient under More efficient for
Efficiency
high traffic. medium traffic in wired
Simplified Notes (LAN Transmission Devices)
Device Function Key Points
1. NIC (Network Connects a device to Has a MAC address,
Interface Card) the network sends & receives data
Extends range but may
2. Repeater Boosts weak signals
cause signal distortion
Basic central Broadcasts to all
3. Hub
connection devices, causes traffic
Device Function Key Points
Filters data, reduces
Connects 2 network
4. Bridge traffic, increases
segments
performance
Connects different Chooses best path,
5. Router
networks connects LAN to internet
Sends data to specific
Smart version of a
6. Switch devices, faster & more
hub
secure
Connects networks Converts data formats,
7. Gateway using different essential for internet
protocols access
Internetworking
• Meaning: Connecting multiple computer networks together.
• Purpose: Devices in different networks can communicate and share
resources.
• Example: Connecting your college LAN to the internet = internetworking.
Datagram
• A packet of data sent across networks.
• Self-contained: includes source address, destination address, and data.
• Used in packet-switched networks.
Routing Algorithms
Routing = finding the best path for data between source and destination.
1. Non-Adaptive (Static) Routing
• Routes are manually set.
• Don’t change based on traffic or errors.
• Simple, good for small networks.
• Not flexible.
2. Adaptive (Dynamic) Routing
• Routes change automatically based on network conditions.
• Routers talk to each other and adjust paths.
• Used in real-world internet routing.
Types of Adaptive Routing
Algorithm
How it Works Examples Notes
Type
Routers share info with neighbors only. Easy but slow.
Distance
Each router keeps a table of distances RIP, IGRP Count-to-infinity
Vector
(like hop count). problem.
Each router builds a full map of the
OSPF, IS- Fast, accurate,
Link State network and uses algorithms (like
IS more complex.
Dijkstra) to find shortest paths.
Distance Vector Routing – Simplified
• Each router knows distance to neighbors.
• Routers share their distance tables.
• Shortest paths calculated using neighbor info.
• Process repeats until all routers agree on best paths.
• Protocols:
o RIP: Basic, uses hop count.
o IGRP: Advanced, uses bandwidth + delay.
Problems:
• Slow updates after network changes.
• Routing loops (count-to-infinity issue).
• Scalability issues in large networks.
Link State Routing – Simplified
• Each router creates and shares a link-state advertisement (LSA).
• All routers receive LSAs and build a complete network map.
• Then they run Dijkstra’s algorithm to compute shortest paths.
Process:
1. Each router shares info about its links (neighbors + cost).
2. Everyone gets a copy (LSA flooding).
3. Routers build the full map.
4. Use shortest path algorithm to update routing tables.
Protocols:
• OSPF – Common in enterprise LANs.
• IS-IS – Used by ISPs.
Dijkstra’s Algorithm – Shortest Path Finder
Definition:
Dijkstra’s algorithm finds the shortest path from a source node to all other nodes in a
weighted graph (no negative weights).
Key Concepts
• Graph = Nodes + Edges
• Weighted Graph = Edges have weights (distance, cost)
• Shortest Path = Minimum total weight path from source to destination
Steps of Algorithm
1. Initialize
o dist[source] = 0, all others = ∞
o visited = { }
2. Select Node with Minimum Distance
o Not yet visited
3. Update Neighbors
o For each neighbor:
▪ new_dist = dist[current] + edge_weight
▪ If new_dist < dist[neighbor], update it
4. Mark Node as Visited
5. Repeat until all nodes are visited
Example (A → B, C, D)
Let’s say:
• A→B = 3, A→C = 2, C→D = 1
Process:
• Start at A: dist[A] = 0
• Visit A → update B = 3, C = 2
• Visit C → update D = 3
• Visit B → no change
• Visit D → done
Final Shortest Paths from A
• A→B=3
• A→C=2
• A→D=3
Internet Protocol (IP) & Transport Protocols – Quick Summary
IP Services
Feature Description
Connectionless Sends each packet independently; no prior connection needed
Best-effort No delivery guarantee (may lose, duplicate, or misorder packets)
Addressing Assigns unique IPs to devices (e.g., [Link])
Routing Selects best path to destination based on IP address
Fragmentation Splits large packets to fit network limits, reassembles on arrival
IP Addressing (IPv4 Classes)
Class Range Usage
A [Link] – [Link] Large networks
B [Link] – [Link] Medium networks
C [Link] – [Link] Small networks
D [Link] – [Link] Multicasting
E [Link] – [Link] Reserved/Experimental
IP address = Network ID + Host ID
TCP vs UDP
Feature TCP UDP
Type Connection-oriented Connectionless
Reliability Reliable (acknowledged delivery) Unreliable
Feature TCP UDP
Order Maintains order No guarantee
Speed Slower due to overhead Faster, lightweight
Use Cases Web, Email, File Transfer Video Streaming, Games, DNS
Features Flow + Congestion Control Simple, no control mechanisms
Client-Server Model
• Client: Requests service (e.g., browser, email app).
• Server: Provides service (e.g., web server, mail server).
• Examples:
o Web browsing → Browser ↔ Web Server
o Email → Email App ↔ Mail Server
o FTP → FTP Client ↔ FTP Server
o DB Access → App ↔ DB Server
DNS – Domain Name System
• Converts domain names to IP addresses (e.g., [Link] → [Link]).
• Hierarchical Structure:
o Root Servers → TLD Servers → Authoritative Servers
• Servers:
o Root: Knows where TLD servers are.
o TLD (Top-Level Domain): .com, .org, .in, etc.
o Authoritative: Stores actual domain records.
Remote Login
• Allows users to access and control remote systems.
• Telnet:
o Sends login info as plain text (not secure).
• SSH (Secure Shell):
o Encrypted, secure remote access.
• Use Cases:
o System admin work.
o Remote file/app access.
FTP – File Transfer Protocol
• Used for uploading/downloading files.
• Two Channels:
o Control Channel: For commands (e.g., login, change directory).
o Data Channel: For actual file transfer.
• SFTP (Secure FTP): Encrypted version of FTP.
SMTP – Simple Mail Transfer Protocol
• Sends emails from client to mail server and between servers.
• Type: Client-server protocol.
• Functions:
o Sender connects and authenticates.
o Sends mail to the recipient’s server.
• Used only for sending, not receiving (for receiving: POP3/IMAP).
MIME – Multipurpose Internet Mail Extensions
• Extends SMTP to support:
o Attachments (images, files).
o Non-ASCII text (foreign languages).
o Multimedia content (audio, video).
• Encodes binary files into text format for email.
• Common MIME Types:
o text/plain, text/html
o image/jpeg, image/png
o application/pdf, etc.