0% found this document useful (0 votes)
22 views30 pages

Compter Networks Transport Layer

The document discusses multiplexing and demultiplexing in the Transport Layer, highlighting their roles in enabling efficient communication between multiple applications over a network. It explains how port numbers are used to identify applications and describes the differences between connection-oriented (TCP) and connectionless (UDP) multiplexing. Additionally, it covers flow control mechanisms, retransmission strategies, and various application layer protocols, emphasizing their importance in reliable data transmission and network communication.

Uploaded by

Chiranjivi M
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views30 pages

Compter Networks Transport Layer

The document discusses multiplexing and demultiplexing in the Transport Layer, highlighting their roles in enabling efficient communication between multiple applications over a network. It explains how port numbers are used to identify applications and describes the differences between connection-oriented (TCP) and connectionless (UDP) multiplexing. Additionally, it covers flow control mechanisms, retransmission strategies, and various application layer protocols, emphasizing their importance in reliable data transmission and network communication.

Uploaded by

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

Multiplexing and Demultiplexing in the Transport Layer

Multiplexing and demultiplexing are essential functions of the Transport Layer that enable
efficient communication between multiple applications on a network.
1. What is Multiplexing?
 Definition: Multiplexing allows multiple applications to send data over a single
network connection simultaneously.
 It ensures that data from different applications is properly combined and transmitted
over the network.
 Each data segment is assigned a port number to identify the application.
Example of Multiplexing:
 A user is:
o Streaming a video (YouTube – port 443)
o Downloading a file (FTP – port 21)
o Browsing a website (HTTP – port 80)
 The Transport Layer adds port numbers to each data segment and sends them over
the network.
2. What is Demultiplexing?
 Definition: Demultiplexing ensures that the received data is correctly delivered to the
appropriate application.
 When data reaches the destination device, the Transport Layer checks port numbers
and forwards each segment to the correct application.
Example of Demultiplexing:
 The receiver's computer gets incoming packets from various applications.
 The Transport Layer reads the port numbers and sends data to the correct
application:
o Port 443 → Web browser
o Port 21 → FTP client
o Port 80 → Web service
3. How Port Numbers Work in Multiplexing & Demultiplexing
 Port numbers (0–65535) help identify applications.
 Commonly Used Ports:
Service Port Number
HTTP (Web) 80
HTTPS (Secure Web) 443
FTP (File Transfer) 21
SMTP (Email Sending) 25
DNS (Domain Name Resolution) 53

4. Types of Multiplexing in the Transport Layer


1. Connection-Oriented Multiplexing (TCP)
o Ensures reliable data delivery.
o Uses unique socket pairs (IP + Port).
o Example: Video calls (Zoom, Skype).
2. Connectionless Multiplexing (UDP)
o Fast but unreliable (no acknowledgment or retransmission).
o Example: Live streaming, VoIP calls, online gaming.

Conclusion
 Multiplexing allows multiple applications to send data over a single connection.
 Demultiplexing ensures that received data is delivered to the correct application.
 Port numbers play a crucial role in both processes

 User Datagram Protocol (UDP) – Transport Layer Protocol


 UDP (User Datagram Protocol) is a connectionless, fast, and lightweight transport
layer protocol used for applications requiring low latency and real-time
communication. Unlike TCP, UDP does not provide reliability, sequencing, or
error correction.
1. Features of UDP
 Connectionless – No handshake or session establishment before communication.
 Unreliable – No acknowledgment, retransmission, or error correction.
 Fast and Lightweight – Minimal overhead since it does not require connection
management.
 Supports Broadcast & Multicast – Can send data to multiple recipients
simultaneously.
 Used for Real-time Applications – Ideal for streaming, gaming, VoIP, and DNS.
2. UDP Header Format
 UDP has a simple 8-byte header, making it efficient for fast transmission.
Field Size (Bytes) Description
Source Port 2 Identifies sender’s port number
Destination Port 2 Identifies receiver’s port number
Length 2 Specifies the total size of UDP packet
Checksum 2 Used for error detection (optional)
5. Applications of UDP
🔹 Live Streaming (YouTube, Netflix) – Fast transmission, occasional packet loss is
acceptable.
🔹 Online Gaming (PUBG, Fortnite) – Low latency is more important than reliability.
🔹 Voice over IP (VoIP) – Audio transmission requires fast delivery, even if some packets
are lost.
🔹 DNS (Domain Name System) – Quick resolution of domain names to IP addresses.
🔹 IoT Devices – Used in sensors and lightweight communication protocols.
6. Advantages & Disadvantages of UDP
✅ Advantages:
✔️ Faster than TCP due to minimal overhead.
✔️ Supports real-time applications.
✔️ Efficient for broadcast and multicast transmission.
❌ Disadvantages:
❌ No guarantee of packet delivery.
❌ No error correction or retransmission.
❌ Packets may arrive out of order or be lost.

Transmission Control Protocol (TCP) – Transport Layer Protocol


TCP (Transmission Control Protocol) is a connection-oriented, reliable transport layer
protocol that ensures accurate and complete data delivery between applications. Unlike
UDP, TCP provides error correction, retransmission, and flow control, making it ideal for
applications that require data integrity.
1. Features of TCP
✅ Connection-Oriented: Establishes a handshake before transmitting data.
✅ Reliable Data Transfer: Ensures packets are delivered without loss, duplication, or
errors.
✅ Error Checking & Correction: Uses checksums and acknowledgments (ACKs) to
detect and fix errors.
✅ Flow Control: Prevents overwhelming the receiver using the Sliding Window Protocol.
✅ Congestion Control: Adjusts transmission speed based on network conditions.
✅ Ordered Data Delivery: Reassembles packets in the correct sequence.
2. TCP Header Format
TCP has a 20-60 byte header containing essential control information.
Field Size (Bytes) Description
Source Port 2 Identifies sender's port number
Destination Port 2 Identifies receiver's port number
Sequence Number 4 Ensures correct ordering of data
Acknowledgment Number 4 Confirms receipt of data
Data Offset 1 Specifies header size
Flags (Control Bits) 1 Manages connection (SYN, ACK, FIN, etc.)
Window Size 2 Controls data flow
Checksum 2 Ensures error detection
Urgent Pointer 2 Indicates urgent data

5. Applications of TCP
✅ Web Browsing (HTTP/HTTPS) – Ensures complete page loading.
✅ Email (SMTP, IMAP, POP3) – Guarantees correct message delivery.
✅ File Transfers (FTP, SFTP) – Ensures complete and error-free file downloads.
✅ Remote Access (SSH, Telnet) – Provides secure and reliable communication.
6. Advantages & Disadvantages of TCP
✅ Advantages:
✔️ Reliable, error-free data delivery.
✔️ Ensures ordered and complete transmission.
✔️ Handles network congestion efficiently.
❌ Disadvantages:
❌ Slower than UDP (more control overhead).
❌ Requires more processing power and memory.
❌ Not suitable for real-time applications like streaming or gaming.

Flow Control in the Transport Layer


1. What is Flow Control?
Flow control is a mechanism in the Transport Layer that regulates data transmission speed
to prevent the sender from overwhelming the receiver. This ensures efficient and reliable
communication by preventing buffer overflow at the receiver’s end.
2. Why is Flow Control Needed?
 The sender may transmit data faster than the receiver can process.
 If the receiver's buffer overflows, data may be lost.
 Flow control ensures the receiver has enough time to process incoming data without
losing packets.

3. Flow Control Mechanisms in TCP


TCP uses two primary flow control mechanisms to manage data transmission efficiently:
A. Stop-and-Wait Protocol
✔️ How It Works:
 The sender sends one packet and waits for an acknowledgment (ACK) before
sending the next.
 If the ACK is received, the sender transmits the next packet.
 If no ACK is received (timeout), the sender retransmits the packet.
✔️ Pros:
 Simple and ensures reliable delivery.
❌ Cons:
 Inefficient for high-speed networks (idle waiting time).
 Low throughput due to continuous waiting.

B. Sliding Window Protocol (TCP Flow Control)


✔️ How It Works:
 Instead of sending one packet at a time, TCP sends multiple packets before waiting
for ACKs.
 A window size is defined (e.g., 4 packets).
 The sender slides the window forward as it receives ACKs, allowing continuous data
transmission.
✔️ Types of Sliding Window Protocols:
1. Go-Back-N (GBN) – If an error occurs, all unacknowledged packets are
retransmitted.
2. Selective Repeat (SR) – Only the corrupted/lost packets are retransmitted.
✔️ Pros:
 Efficient for high-speed networks.
 Reduces idle waiting time.
❌ Cons:
 Requires buffering at sender and receiver.

4. TCP Flow Control Using the Window Size


 TCP advertises a "Receive Window (rwnd)" in each ACK packet.
 The sender adjusts its transmission rate based on the receiver’s window size.
 If the window size = 0, the sender pauses transmission until further notice.
Retransmission Strategies in the Transport Layer
Retransmission strategies are mechanisms used in the Transport Layer to ensure reliable
data delivery when packets are lost, corrupted, or not acknowledged. These strategies help
recover lost data and maintain efficient communication between sender and receiver.

1. Why is Retransmission Needed?


 Packets may be lost due to network congestion.
 Data may get corrupted due to transmission errors.
 The receiver may fail to acknowledge (ACK) a packet.
 Ensures reliable communication, especially in TCP.

2. Types of Retransmission Strategies


A. Automatic Repeat reQuest (ARQ)
ARQ is a fundamental retransmission technique where the receiver requests retransmission
if an error or packet loss is detected. It includes:

1. Stop-and-Wait ARQ
✔️ How It Works:
 Sender sends one packet and waits for an acknowledgment (ACK).
 If ACK is received, the sender sends the next packet.
 If ACK is not received (timeout or error detected), the sender retransmits the
packet.
✔️ Pros:
 Simple and reliable.
❌ Cons:
 Inefficient for high-speed networks due to idle waiting time.

2. Go-Back-N ARQ
✔️ How It Works:
 Sender can send multiple packets before waiting for ACKs.
 If a packet is lost, the receiver discards all subsequent packets.
 The sender then retransmits all unacknowledged packets starting from the lost one.
✔️ Pros:
 Better efficiency than Stop-and-Wait.
❌ Cons:
 Wastes bandwidth by retransmitting unnecessary packets.

3. Selective Repeat ARQ


✔️ How It Works:
 The sender retransmits only the lost or corrupted packets instead of all subsequent
packets.
 Receiver buffers correctly received packets and waits for missing ones.
✔️ Pros:
 More efficient than Go-Back-N (avoids redundant retransmissions).
❌ Cons:
 Requires more complex buffering and processing.

B. Fast Retransmit (TCP-Specific Strategy)


✔️ How It Works:
 Instead of waiting for a timeout, TCP retransmits a lost packet immediately if it
receives three duplicate ACKs (same ACK repeatedly).
✔️ Example:
1️⃣ Sender sends Packets 1, 2, 3, 4, 5.
2️⃣ Packet 3 is lost.
3️⃣ Receiver ACKs Packet 2 three times (duplicate ACKs).
4️⃣ Sender immediately retransmits Packet 3 instead of waiting for a timeout.
✔️ Pros:
 Speeds up recovery of lost packets.
❌ Cons:
 Works best for minor packet losses, but not for heavy congestion.

C. Timer-Based Retransmission (Timeout)


✔️ How It Works:
 Sender starts a timer when a packet is sent.
 If an ACK is not received before the timer expires, the packet is retransmitted.
✔️ Pros:
 Ensures eventual delivery of all packets.
❌ Cons:
 Choosing the right timeout value is crucial:
o Too short → Unnecessary retransmissions.
o Too long → Increased delays.
Share

You said:
application layer protocol
The Application Layer is the topmost layer in the OSI (Open Systems Interconnection)
model and the TCP/IP model, responsible for providing end-user services and network
applications. It enables communication between software applications and the underlying
network.
Application Layer Protocols
Several protocols operate at the Application Layer, each designed for specific types of
communication:
1. Hypertext Transfer Protocol (HTTP/HTTPS)
o Used for web browsing.
o HTTPS is the secure version with encryption (TLS/SSL).
2. File Transfer Protocol (FTP)
o Used for transferring files between a client and a server.
3. Simple Mail Transfer Protocol (SMTP)
o Used for sending emails.
4. Post Office Protocol v3 (POP3) & Internet Message Access Protocol (IMAP)
o POP3: Retrieves emails from a mail server (downloads messages).
o IMAP: Manages emails on the server without downloading them.
5. Domain Name System (DNS)
o Resolves domain names (e.g., www.google.com) to IP addresses.
6. Dynamic Host Configuration Protocol (DHCP)
o Assigns dynamic IP addresses to devices on a network.
7. Telnet & Secure Shell (SSH)
o Telnet: Allows remote login (not secure).
o SSH: Secure alternative for remote login and command execution.
8. Trivial File Transfer Protocol (TFTP)
o A lightweight version of FTP used for simple file transfers.
9. Network Time Protocol (NTP)
o Synchronizes system clocks across a network.
10. Simple Network Management Protocol (SNMP)
 Used for managing and monitoring network devices.
Importance of Application Layer Protocols
 Enables end-user communication and data transfer.
 Supports secure and reliable data exchange.
 Facilitates web browsing, email, remote access, and network management.
Would you like a deeper explanation of any specific protocol?
4o
You said:
in detailed for above
ChatGPT said:
Detailed Explanation of Application Layer Protocols
The Application Layer in the OSI model and TCP/IP model provides services to user
applications and ensures communication over a network. Below is a detailed description of
the most commonly used Application Layer Protocols:
1. Hypertext Transfer Protocol (HTTP/HTTPS)
 Purpose: Used for web browsing and data exchange over the internet.
 Port: HTTP (80), HTTPS (443)
 Functionality:
o HTTP follows a request-response model where a client (browser) requests a
resource from a web server.
o HTTP is stateless, meaning each request is independent.
o HTTPS (Hypertext Transfer Protocol Secure) adds encryption using
TLS/SSL for secure data transmission.
Example Workflow:
1. A user types www.example.com in a browser.
2. The browser sends an HTTP request to fetch the web page.
3. The web server responds with an HTML page.
4. The browser renders the page for the user.
2. File Transfer Protocol (FTP)
 Purpose: Used for transferring files between a client and a server.
 Port: 21 (control) and 20 (data transfer)
 Functionality:
o FTP allows users to upload and download files over a network.
o Operates in active mode (server initiates data transfer) or passive mode
(client initiates transfer).
o Anonymous FTP allows access without authentication.
o Secure FTP (SFTP) uses SSH encryption for security.
Example Use Case:
 A web developer uploads a website’s files to a hosting server using FTP.

3. Simple Mail Transfer Protocol (SMTP)


 Purpose: Used for sending emails from an email client to a mail server.
 Port: 25 (default), 587 (with TLS)
 Functionality:
o SMTP only handles sending emails.
o Works with POP3 or IMAP for email retrieval.
o Supports email queuing for retries if the recipient server is unavailable.
Example Workflow:
1. A user sends an email via Gmail.
2. Gmail’s SMTP server forwards the email to the recipient’s mail server.
3. The recipient retrieves the email using POP3 or IMAP.
4. Post Office Protocol v3 (POP3) & Internet Message Access Protocol (IMAP)
 Purpose: Used for retrieving emails from a mail server.
 Ports: POP3 (110), IMAP (143)
 Differences:
Feature POP3 IMAP
Downloads emails to the client and Stores emails on
Message storage
deletes them from the server the server
Access from multiple
No Yes
devices
Synchronization No Yes
Offline access Yes Limited
Example Use Case:
 POP3: A user downloads emails on Outlook, and they are removed from the server.
 IMAP: A user reads emails on multiple devices (smartphone, tablet, laptop).

5. Domain Name System (DNS)


 Purpose: Converts domain names into IP addresses.
 Port: 53 (UDP)
 Functionality:
o Instead of remembering 192.168.1.1, users type www.google.com.
o DNS resolves the name to the correct IP address.
Example Workflow:
1. A user enters www.google.com in a browser.
2. The browser requests DNS resolution.
3. The DNS server responds with the corresponding IP address.
4. The browser connects to the web server using the IP address.

6. Dynamic Host Configuration Protocol (DHCP)


 Purpose: Assigns dynamic IP addresses to devices in a network.
 Port: 67 (server), 68 (client)
 Functionality:
o Reduces manual IP configuration.
o Assigns IP address, subnet mask, gateway, and DNS server to devices.
Example Workflow:
1. A laptop connects to a Wi-Fi network.
2. The laptop sends a DHCP request.
3. The DHCP server assigns an IP address automatically.

7. Telnet & Secure Shell (SSH)


 Purpose: Remote login to network devices.
 Ports: Telnet (23), SSH (22)
 Differences:
Feature Telnet SSH
Encryption No Yes
Security Vulnerable to attacks Secure with encryption
Use Case Remote login within trusted networks Secure remote administration
Example Use Case:
 An administrator remotely accesses a Linux server using SSH instead of Telnet for
security.

8. Trivial File Transfer Protocol (TFTP)


 Purpose: Lightweight file transfer protocol.
 Port: 69 (UDP)
 Functionality:
o No authentication required.
o Used for configuring network devices (routers, switches).
Example Use Case:
 A network switch automatically downloads a firmware update via TFTP.

9. Network Time Protocol (NTP)


 Purpose: Synchronizes time across devices in a network.
 Port: 123 (UDP)
 Functionality:
o Keeps accurate timestamps for logs and security purposes.
Example Use Case:
 Servers in a data center synchronize their clocks to prevent mismatched log
timestamps.

10. Simple Network Management Protocol (SNMP)


 Purpose: Monitors and manages network devices.
 Ports: 161 (queries), 162 (traps)
 Functionality:
o Collects data from routers, switches, and servers.
o Alerts administrators about network failures.
Example Use Case:
 A network administrator monitors CPU usage and bandwidth of network devices
using SNMP.

Summary Table of Application Layer Protocols


Protocol Purpose Port
HTTP/HTTPS Web browsing 80/443
FTP File transfer 20/21
SMTP Sending emails 25/587
POP3 Email retrieval 110
IMAP Email management 143
DNS Domain name resolution 53
DHCP IP address allocation 67/68
Telnet Remote login (insecure) 23
SSH Secure remote login 22
TFTP Simple file transfer 69
NTP Time synchronization 123
SNMP Network monitoring 161/162
Email Protocols: SMTP, POP3, and IMAP
Email communication relies on a set of protocols that handle sending, receiving, and
managing messages across networks. The three primary email protocols are:
1. Simple Mail Transfer Protocol (SMTP)
2. Post Office Protocol v3 (POP3)
3. Internet Message Access Protocol (IMAP)
Each of these protocols serves a different function in email transmission and retrieval. Let’s
explore them in detail.
1. Simple Mail Transfer Protocol (SMTP)
Purpose:
 Used for sending emails from a client (like Gmail, Outlook) to a mail server.
 Also used for forwarding emails between mail servers.
Port Numbers:
 25 → Default SMTP port (used for mail transfer between mail servers).
 465 → SMTP with SSL encryption (deprecated).
 587 → SMTP with TLS encryption (recommended for email clients).
How SMTP Works:
1. A user composes an email in an email client (e.g., Outlook, Gmail).
2. The email client sends the message to the SMTP server.
3. The SMTP server forwards the email to the recipient’s mail server.
4. The recipient's mail server stores the email until it is retrieved using POP3 or IMAP.
Example SMTP Workflow:
1. Sender: [email protected]
2. Recipient: [email protected]
3. Alice’s email client sends the email to example.com's SMTP server.
4. Example.com’s SMTP server looks up Gmail’s SMTP server using DNS MX
records.
5. The email is transferred to Gmail’s mail server.
6. Bob retrieves the email using POP3 or IMAP.
Limitations of SMTP:
 Cannot retrieve emails; only sends them.
 Does not store emails after sending.
 Requires additional security measures to prevent spam (e.g., SPF, DKIM, DMARC).

2. Post Office Protocol v3 (POP3)


Purpose:
 Used to retrieve emails from a mail server.
 Downloads emails from the server to a local device and usually deletes them from
the server.
Port Numbers:
 110 → Default POP3️ port (unencrypted).
 995 → POP3️ over SSL/TLS (secure).
How POP3 Works:
1. The email client connects to the POP3 server.
2. The server authenticates the user.
3. The client downloads all emails to the local device.
4. Emails are deleted from the server (unless configured otherwise).
5. The user can read emails offline.
Example POP3 Workflow:
1. Bob’s email client (e.g., Outlook) connects to Gmail’s POP3️ server.
2. The server authenticates Bob’s credentials.
3. Emails are downloaded to his computer.
4. Gmail deletes the emails from the server (unless "Keep a copy on the server" is
enabled).
Advantages of POP3:
✔️ Saves storage space on the server.
✔️ Allows offline access to emails.
Limitations of POP3:
❌ Emails cannot be accessed from multiple devices since they are removed from the server.
❌ Does not synchronize read/unread status between devices.

3. Internet Message Access Protocol (IMAP)


Purpose:
 Allows email retrieval and management while keeping emails stored on the server.
 Provides multi-device synchronization (ideal for modern users).
Port Numbers:
 143 → Default IMAP port (unencrypted).
 993 → IMAP over SSL/TLS (secure).
How IMAP Works:
1. The email client connects to the IMAP server.
2. The server authenticates the user.
3. Emails remain stored on the server.
4. The client fetches email headers (not the full email) until the user clicks on a message.
5. Read/unread status and folder organization sync across devices.
Example IMAP Workflow:
1. Bob logs into Gmail from his laptop, phone, and tablet.
2. Emails are displayed without being downloaded completely.
3. If Bob marks an email as “read” on his phone, it is also marked as read on his laptop.
4. Emails remain on Gmail’s server, allowing access from any device.
Advantages of IMAP:
✔️ Emails stay on the server, preventing data loss.
✔️ Multi-device access and synchronization.
✔️ Supports email folders and organization.
Limitations of IMAP:
❌ Requires more server storage.
❌ Needs an internet connection to access emails.

Comparison of SMTP, POP3, and IMAP


Feature SMTP POP3 IMAP
Sending Retrieving & managing
Purpose Retrieving emails
emails emails
Port (Unsecure) 25 110 143
Port (Secure -
587 995 993
SSL/TLS)
Emails downloaded to Emails remain on the
Email Storage No storage
device server
Multi-device Access No No Yes
Feature SMTP POP3 IMAP
Synchronization No No Yes
Offline Access No Yes Limited

When to Use POP3 vs IMAP?


🔹 Use POP3 if:
✅ You want to store emails on your device (e.g., personal computer).
✅ You have limited email server storage.
✅ You don’t need to access emails from multiple devices.
🔹 Use IMAP if:
✅ You want to access emails from multiple devices (phone, laptop, tablet).
✅ You need emails to stay on the server for backup and synchronization.
✅ You frequently manage folders, labels, and email statuses.

 SMTP is used for sending emails.


 POP3 is used for retrieving and downloading emails to a local device.
 IMAP is used for retrieving, managing, and syncing emails across multiple devices.

Domain Name System (DNS) – The Internet's Phonebook


The Domain Name System (DNS) is a fundamental protocol in the Application Layer that
translates human-friendly domain names (e.g., www.google.com) into machine-readable IP
addresses (e.g., 142.250.182.14). This enables users to access websites without memorizing
numerical addresses.

Why is DNS Important?


 The internet operates on IP addresses, but humans find domain names easier to
remember.
 DNS acts as a distributed database that maps domain names to IP addresses.
 Without DNS, users would need to enter numeric IP addresses to access websites.

How DNS Works – Step-by-Step Process


Example: Accessing www.example.com
1. User enters www.example.com in a browser.
2. The browser checks its cache for a stored IP address.
3. If not found, the request is sent to a DNS resolver (provided by the ISP).
4. The resolver queries a root DNS server.
5. The root server directs the query to a Top-Level Domain (TLD) server (e.g., .com).
6. The TLD server points to the authoritative DNS server for example.com.
7. The authoritative server returns the IP address (e.g., 192.168.1.1) to the resolver.
8. The resolver sends the IP address to the browser, which then connects to the web
server.
Diagram Representation:
pgsql
CopyEdit
User → DNS Resolver → Root Server → TLD Server → Authoritative Server → Web
Server
Types of DNS Servers
1. Recursive Resolver
 Handles DNS queries on behalf of the client.
 Provided by ISPs (e.g., Google Public DNS - 8.8.8.8, Cloudflare DNS - 1.1.1.1).
 Caches responses to speed up future queries.
2. Root Name Server
 Top-level DNS servers (only 13 root servers globally).
 Directs queries to the correct TLD server.
3. Top-Level Domain (TLD) Server
 Manages domains under specific extensions:
o .com, .org, .net → Generic TLD servers
o .us, .uk, .in → Country-code TLD servers (ccTLDs)
4. Authoritative Name Server
 Holds the final answer for a domain name.
 Stores A records, CNAME records, MX records, etc.

DNS Record Types


Record Type Purpose Example
A (Address) Maps a domain to an IPv4 address example.com → 1️92️.1️68.1️.1️
AAAA (IPv6 Address) Maps a domain to an IPv6 address example.com → 2️001️:db8::1️
CNAME (Canonical blog.example.com →
Creates an alias for a domain
Name) example.com
Directs emails to the correct mail
MX (Mail Exchange) mail.example.com
server
Stores arbitrary text data (e.g., SPF,
TXT (Text Record) Used for email security
DKIM)
NS (Name Server) Specifies authoritative DNS servers ns1.example.com
Maps an IP to a domain (reverse
PTR (Pointer Record) 1️92️.1️68.1️.1️ → example.com
lookup)

DNS Caching & Performance


To reduce query time, DNS caching is used:
 Browser Cache: Stores recently visited websites.
 OS Cache: Local device storage of DNS lookups.
 ISP Cache: The Internet Service Provider caches frequent queries.
 CDN Caching: Content Delivery Networks use DNS caching to speed up access.

Common DNS Issues


1. DNS Propagation Delay: When updating DNS records, changes take time to reflect
globally.
2. DNS Spoofing (Cache Poisoning): Attackers alter DNS records to redirect users to
malicious sites.
3. Slow DNS Resolution: Can be improved by using fast DNS providers (Google DNS,
Cloudflare DNS).

Popular DNS Providers


Provider Primary DNS Secondary DNS
Google DNS 8.8.8.8 8.8.4.4
Provider Primary DNS Secondary DNS
Cloudflare DNS 1.1.1.1 1.0.0.1
OpenDNS 208.67.222.222 208.67.220.220

Conclusion
 DNS is essential for translating domain names into IP addresses.
 It works through a hierarchical structure, resolving queries via recursive, root, TLD,
and authoritative servers.
 DNS caching improves performance, but security risks like DNS spoofing must be
mitigated.
Transport Layer Functions (Layer 4 of OSI Model)
The Transport Layer is responsible for end-to-end communication between devices over a
network. It ensures data integrity, reliability, and proper sequencing during transmission.

Key Functions of the Transport Layer


1. Process-to-Process Communication
 Enables communication between applications running on different devices.
 Uses port numbers to distinguish different services (e.g., web browsing, email, file
transfer).
 Example:
o HTTP (Web Browsing): Port 80/443
o SMTP (Email Sending): Port 25
o FTP (File Transfer): Port 21
2. Multiplexing & Demultiplexing
 Multiplexing: Combines multiple application-layer messages into a single transport-
layer data stream for efficient transmission.
 Demultiplexing: Extracts data from incoming packets and delivers it to the correct
application using port numbers.
Example:
o A computer downloads a file via FTP while browsing the web. The Transport
Layer ensures FTP data goes to the FTP application and web data to the
browser.
3. Segmentation & Reassembly
 Segmentation: Large messages are divided into smaller segments before
transmission.
 Reassembly: At the destination, segments are reassembled in the correct order to
reconstruct the original message.
Example:
o A 10MB file is divided into smaller packets and sent over the network. The
receiver reconstructs the file correctly.
4. Flow Control
 Prevents fast senders from overwhelming slow receivers.
 Ensures smooth data transmission and prevents packet loss due to buffer overflow.
 TCP implements flow control using the Sliding Window Protocol.
Example:
o If a receiver can handle only 5 packets per second but the sender is
transmitting 10, the sender adjusts its speed.
5. Error Detection & Correction
 Ensures data integrity by detecting and correcting errors.
 Uses checksums to verify data accuracy.
 TCP retransmits lost or corrupted data, while UDP does not provide error
correction.
Example:
o If a network error corrupts a packet, TCP detects it and requests a
retransmission.
6. Reliable & Unreliable Transmission
 TCP (Transmission Control Protocol):
o Ensures reliable delivery with acknowledgments, retransmissions, and
sequencing.
o Used for applications requiring data accuracy (e.g., emails, file transfers, web
browsing).
 UDP (User Datagram Protocol):
o Provides faster but unreliable delivery without acknowledgments or
retransmissions.
o Used for applications requiring low latency (e.g., VoIP, live streaming, online
gaming).
7. Connection Establishment & Termination
 TCP uses a Three-Way Handshake:
1. SYN → Client sends a connection request.
2. SYN-ACK → Server acknowledges the request.
3. ACK → Client confirms the connection.
 TCP uses a Four-Way Handshake to terminate a connection.
Example:
o When loading a website, a TCP connection is established. When the page is
fully loaded, the connection is closed.

Comparison of TCP vs. UDP


Feature TCP (Reliable) UDP (Unreliable)
Connection
Connection-oriented Connectionless
Type
Ensures delivery (ACKs &
Reliability No delivery guarantee
retransmissions)
Speed Slower (extra control) Faster (minimal overhead)
Uses checksums and retransmits lost Uses checksums but does not
Error Checking
data retransmit
Use Cases Web browsing, email, file transfers Streaming, gaming, VoIP

Conclusion
 The Transport Layer ensures efficient, reliable, or fast communication between
applications.
 TCP is reliable but slower, while UDP is faster but less reliable.
 It manages segmentation, flow control, error handling, and connection
management.
Functions of the Transport Layer (Layer 4 of OSI Model)
The Transport Layer is responsible for end-to-end communication between devices across
a network. It provides essential services such as process-to-process communication, error
handling, flow control, and reliable data delivery.
1. Process-to-Process Communication
 The Transport Layer enables communication between applications running on
different devices.
 Uses port numbers to differentiate services (e.g., HTTP, FTP, SMTP).
 Example: A computer can run multiple applications (web browser, email, FTP)
simultaneously, and the Transport Layer ensures the correct data reaches the right
application.
Protocol Port Number
HTTP (Web Browsing) 80/443
FTP (File Transfer) 21
SMTP (Email Sending) 25
DNS (Domain Name System) 53

2. Multiplexing and Demultiplexing


 Multiplexing: Combines multiple application-layer messages into a single transport-
layer data stream.
 Demultiplexing: Extracts data from incoming transport-layer segments and delivers it
to the appropriate application using port numbers.
Example:
 A device simultaneously downloads a file (FTP) and browses the web (HTTP).
 The Transport Layer ensures that FTP data goes to the FTP client and HTTP data
goes to the browser.

3. Segmentation and Reassembly


 Segmentation: Large data messages are divided into smaller segments before
transmission.
 Reassembly: At the destination, the segments are reassembled in the correct order.
 Each segment has a sequence number to ensure proper ordering.
Example:
 A 100MB file is broken into small packets for transmission. The receiver uses
sequence numbers to reconstruct the file correctly.

4. Flow Control
 Prevents faster senders from overwhelming slower receivers.
 Ensures smooth data transmission and avoids buffer overflow.
 TCP uses the Sliding Window Protocol for flow control.
Example:
 If a sender can transmit 10 packets per second but the receiver can only handle 5, the
sender slows down its rate.

5. Error Detection and Correction


 Ensures data integrity by detecting and correcting errors during transmission.
 Uses checksums to verify that data is not corrupted.
 TCP detects lost packets and retransmits them, while UDP does not provide
retransmission.
Example:
 If a packet is corrupted, TCP requests retransmission, ensuring reliable
communication.
6. Reliable and Unreliable Transmission
The Transport Layer provides two types of transmission based on application needs:
Feature TCP (Reliable) UDP (Unreliable)
Connection Type Connection-oriented Connectionless
Reliability Ensures delivery (ACKs & retransmissions) No delivery guarantee
Error Checking Detects errors & retransmits lost packets Only detects errors
Speed Slower (extra control mechanisms) Faster (minimal overhead)
Use Cases Web browsing, emails, file transfer Streaming, gaming, VoIP

7. Connection Establishment and Termination


 TCP uses a Three-Way Handshake to establish a reliable connection:
1. SYN: Client requests a connection.
2. SYN-ACK: Server acknowledges the request.
3. ACK: Client confirms, and the connection is established.
 TCP uses a Four-Way Handshake to terminate a connection.
Example:
 When a user loads a webpage, a TCP connection is established, and once the page is
fully loaded, the connection is closed.

Conclusion
The Transport Layer plays a crucial role in ensuring smooth, efficient, and reliable
communication between devices. It provides process-to-process communication,
segmentation, error handling, flow control, multiplexing, and connection management.

Functions of the Transport Layer


1. Process-to-Process Communication – Enables communication between applications
on different devices using port numbers.
2. Multiplexing and Demultiplexing – Allows multiple applications to use the network
simultaneously by assigning unique port numbers.
3. Segmentation and Reassembly – Breaks large data into smaller segments and
reassembles them at the destination.
4. Flow Control – Regulates data transmission speed to prevent buffer overflow using
mechanisms like the Sliding Window Protocol.
5. Error Detection and Correction – Ensures data integrity using checksums and
retransmission (TCP).
6. Reliable and Unreliable Data Transfer – Provides both reliable (TCP) and
unreliable (UDP) communication based on application needs.
7. Connection Establishment and Termination – Uses TCP Three-Way Handshake
to establish a connection and Four-Way Handshake to terminate it.
8. Congestion Control – Manages network congestion by adjusting the data
transmission rate dynamically.
9. Data Sequencing – Assigns sequence numbers to packets to ensure correct order at
the receiver's end.
10. End-to-End Communication – Ensures seamless data transmission between source
and destination, independent of intermediate devices.

Multiplexing and Demultiplexing in the Transport Layer


Multiplexing and demultiplexing are essential functions of the Transport Layer that enable
efficient communication between multiple applications on a network.
1. What is Multiplexing?
 Definition: Multiplexing allows multiple applications to send data over a single
network connection simultaneously.
 It ensures that data from different applications is properly combined and transmitted
over the network.
 Each data segment is assigned a port number to identify the application.
Example of Multiplexing:
 A user is:
o Streaming a video (YouTube – port 443)
o Downloading a file (FTP – port 21)
o Browsing a website (HTTP – port 80)
 The Transport Layer adds port numbers to each data segment and sends them over
the network.
Diagram:
scss
CopyEdit
Application 1 (Port 80) → Transport Layer
Application 2 (Port 443) → Transport Layer
Application 3 (Port 21) → Transport Layer

Multiplexed into a single connection

Sent to the receiver

2. What is Demultiplexing?
 Definition: Demultiplexing ensures that the received data is correctly delivered to the
appropriate application.
 When data reaches the destination device, the Transport Layer checks port numbers
and forwards each segment to the correct application.
Example of Demultiplexing:
 The receiver's computer gets incoming packets from various applications.
 The Transport Layer reads the port numbers and sends data to the correct
application:
o Port 443 → Web browser
o Port 21 → FTP client
o Port 80 → Web service
Diagram:
scss
CopyEdit
Received Data Stream

Transport Layer checks port numbers

Application 1 (Port 80)
Application 2 (Port 443)
Application 3 (Port 21)

3. How Port Numbers Work in Multiplexing & Demultiplexing


 Port numbers (0–65535) help identify applications.
 Commonly Used Ports:
Service Port Number
HTTP (Web) 80
HTTPS (Secure Web) 443
FTP (File Transfer) 21
SMTP (Email Sending) 25
DNS (Domain Name Resolution) 53

4. Types of Multiplexing in the Transport Layer


1. Connection-Oriented Multiplexing (TCP)
o Ensures reliable data delivery.
o Uses unique socket pairs (IP + Port).
o Example: Video calls (Zoom, Skype).
2. Connectionless Multiplexing (UDP)
o Fast but unreliable (no acknowledgment or retransmission).
o Example: Live streaming, VoIP calls, online gaming.

Conclusion
 Multiplexing allows multiple applications to send data over a single connection.
 Demultiplexing ensures that received data is delivered to the correct application.
 Port numbers play a crucial role in both processes.

User Datagram Protocol (UDP) – Transport Layer Protocol


UDP (User Datagram Protocol) is a connectionless, fast, and lightweight transport layer
protocol used for applications requiring low latency and real-time communication. Unlike
TCP, UDP does not provide reliability, sequencing, or error correction.

1. Features of UDP
 Connectionless – No handshake or session establishment before communication.
 Unreliable – No acknowledgment, retransmission, or error correction.
 Fast and Lightweight – Minimal overhead since it does not require connection
management.
 Supports Broadcast & Multicast – Can send data to multiple recipients
simultaneously.
 Used for Real-time Applications – Ideal for streaming, gaming, VoIP, and DNS.

2. UDP Header Format


UDP has a simple 8-byte header, making it efficient for fast transmission.
Field Size (Bytes) Description
Source Port 2 Identifies sender’s port number
Destination Port 2 Identifies receiver’s port number
Length 2 Specifies the total size of UDP packet
Checksum 2 Used for error detection (optional)
📌 Unlike TCP (which has a 20-60 byte header), UDP's 8-byte header makes it faster.
3. Working of UDP
1. Sender:
o The application generates data.
o The UDP header is added.
o The datagram is sent to the network.
2. Receiver:
o The incoming datagram is received.
o The UDP header is read to determine the destination application.
o The data is delivered without error checking or retransmission.

4. Comparison: UDP vs. TCP


Feature UDP TCP
Connection
Connectionless Connection-oriented
Type
No acknowledgment,
Reliability Ensures delivery with ACKs
retransmission
Uses checksum (no error Uses checksum & retransmits lost
Error Checking
correction) packets
Speed Faster (low overhead) Slower (more control)
Use Cases Streaming, VoIP, gaming, DNS Web browsing, email, file transfer

5. Applications of UDP
🔹 Live Streaming (YouTube, Netflix) – Fast transmission, occasional packet loss is
acceptable.
🔹 Online Gaming (PUBG, Fortnite) – Low latency is more important than reliability.
🔹 Voice over IP (VoIP) – Audio transmission requires fast delivery, even if some packets
are lost.
🔹 DNS (Domain Name System) – Quick resolution of domain names to IP addresses.
🔹 IoT Devices – Used in sensors and lightweight communication protocols.

6. Advantages & Disadvantages of UDP


✅ Advantages:
✔️ Faster than TCP due to minimal overhead.
✔️ Supports real-time applications.
✔️ Efficient for broadcast and multicast transmission.
❌ Disadvantages:
❌ No guarantee of packet delivery.
❌ No error correction or retransmission.
❌ Packets may arrive out of order or be lost.

Conclusion
UDP is a high-speed, connectionless protocol best suited for real-time and low-latency
applications. While it lacks reliability, its simplicity and speed make it ideal for applications
where occasional data loss is acceptable.
Transmission Control Protocol (TCP) – Transport Layer Protocol
TCP (Transmission Control Protocol) is a connection-oriented, reliable transport layer
protocol that ensures accurate and complete data delivery between applications. Unlike
UDP, TCP provides error correction, retransmission, and flow control, making it ideal for
applications that require data integrity.

1. Features of TCP
✅ Connection-Oriented: Establishes a handshake before transmitting data.
✅ Reliable Data Transfer: Ensures packets are delivered without loss, duplication, or
errors.
✅ Error Checking & Correction: Uses checksums and acknowledgments (ACKs) to
detect and fix errors.
✅ Flow Control: Prevents overwhelming the receiver using the Sliding Window Protocol.
✅ Congestion Control: Adjusts transmission speed based on network conditions.
✅ Ordered Data Delivery: Reassembles packets in the correct sequence.

2. TCP Header Format


TCP has a 20-60 byte header containing essential control information.
Field Size (Bytes) Description
Source Port 2 Identifies sender's port number
Destination Port 2 Identifies receiver's port number
Sequence Number 4 Ensures correct ordering of data
Acknowledgment Number 4 Confirms receipt of data
Data Offset 1 Specifies header size
Flags (Control Bits) 1 Manages connection (SYN, ACK, FIN, etc.)
Window Size 2 Controls data flow
Checksum 2 Ensures error detection
Urgent Pointer 2 Indicates urgent data

3. How TCP Works


TCP follows a step-by-step process to ensure reliable communication.
A. Connection Establishment (Three-Way Handshake)
Before data transmission, TCP establishes a reliable connection between sender and
receiver.
1️⃣ SYN (Synchronize):
 Client → Server: "Can we communicate?"
2️⃣ SYN-ACK (Synchronize-Acknowledge):
 Server → Client: "Yes, let's connect!"
3️⃣ ACK (Acknowledge):
 Client → Server: "Connection established!"
📌 Now, data transfer can begin!

B. Data Transfer with Reliability


 TCP assigns sequence numbers to packets for ordered delivery.
 If a packet is lost, TCP retransmits it.
 Receiver sends ACK (acknowledgment) for successfully received packets.

C. Connection Termination (Four-Way Handshake)


When communication ends, TCP gracefully closes the connection.
1️⃣ FIN (Finish) → Client requests termination.
2️⃣ ACK → Server acknowledges request.
3️⃣ FIN → Server initiates termination.
4️⃣ ACK → Client confirms termination.
📌 The connection is now closed!

4. TCP vs. UDP Comparison


Feature TCP UDP
Connection Type Connection-Oriented Connectionless
Reliability Guaranteed (Retransmission) No Guarantee
Minimal (Checksum
Error Handling Yes (Checksum, ACKs)
Only)
Data Ordering Yes No
Flow & Congestion
Yes No
Control
Faster (Minimal
Speed Slower (More Overhead)
Overhead)
Web browsing, Email, File
Use Cases Streaming, VoIP, Gaming
Transfer

5. Applications of TCP
✅ Web Browsing (HTTP/HTTPS) – Ensures complete page loading.
✅ Email (SMTP, IMAP, POP3) – Guarantees correct message delivery.
✅ File Transfers (FTP, SFTP) – Ensures complete and error-free file downloads.
✅ Remote Access (SSH, Telnet) – Provides secure and reliable communication.

6. Advantages & Disadvantages of TCP


✅ Advantages:
✔️ Reliable, error-free data delivery.
✔️ Ensures ordered and complete transmission.
✔️ Handles network congestion efficiently.
❌ Disadvantages:
❌ Slower than UDP (more control overhead).
❌ Requires more processing power and memory.
❌ Not suitable for real-time applications like streaming or gaming.

Conclusion
TCP is the backbone of reliable internet communication. It ensures secure, accurate, and
ordered data transmission, making it essential for web browsing, emails, and file
transfers. However, for real-time applications, UDP is preferred due to its lower latency.

Flow Control in the Transport Layer


1. What is Flow Control?
Flow control is a mechanism in the Transport Layer that regulates data transmission speed
to prevent the sender from overwhelming the receiver. This ensures efficient and reliable
communication by preventing buffer overflow at the receiver’s end.
2. Why is Flow Control Needed?
 The sender may transmit data faster than the receiver can process.
 If the receiver's buffer overflows, data may be lost.
 Flow control ensures the receiver has enough time to process incoming data without
losing packets.

3. Flow Control Mechanisms in TCP


TCP uses two primary flow control mechanisms to manage data transmission efficiently:
A. Stop-and-Wait Protocol
✔️ How It Works:
 The sender sends one packet and waits for an acknowledgment (ACK) before
sending the next.
 If the ACK is received, the sender transmits the next packet.
 If no ACK is received (timeout), the sender retransmits the packet.
✔️ Pros:
 Simple and ensures reliable delivery.
❌ Cons:
 Inefficient for high-speed networks (idle waiting time).
 Low throughput due to continuous waiting.

B. Sliding Window Protocol (TCP Flow Control)


✔️ How It Works:
 Instead of sending one packet at a time, TCP sends multiple packets before waiting
for ACKs.
 A window size is defined (e.g., 4 packets).
 The sender slides the window forward as it receives ACKs, allowing continuous data
transmission.
✔️ Types of Sliding Window Protocols:
1. Go-Back-N (GBN) – If an error occurs, all unacknowledged packets are
retransmitted.
2. Selective Repeat (SR) – Only the corrupted/lost packets are retransmitted.
✔️ Pros:
 Efficient for high-speed networks.
. Introduction
Congestion control in the Transport Layer is essential to prevent excessive data from
overwhelming network resources. When too many packets are sent at once, the network
becomes congested, leading to packet loss, high delays, and reduced throughput.
📌 Key Differences:
 Flow Control: Regulates data transmission between sender and receiver to prevent
the receiver from being overwhelmed.
 Congestion Control: Regulates data transmission to prevent overloading the network
itself.
Why is Congestion Control Important?
✅ Prevents packet loss due to overloaded routers.
✅ Reduces delays and ensures smooth data transmission.
✅ Improves network performance and efficiency.
2. Causes of Network Congestion
🔹 High Traffic Load: Too many devices sending data at once.
🔹 Insufficient Bandwidth: Network capacity is lower than the demand.
🔹 Limited Router Buffer Space: Packets get dropped if routers can't handle more data.
🔹 Bursty Traffic: Sudden increases in data transmission cause congestion.
🔹 Network Failures: Link failures or routing changes create bottlenecks.

3. Congestion Control Mechanisms in TCP


A. Slow Start (Exponential Growth) 🚀
✔️ How It Works:
 TCP starts by sending a small number of packets (typically 1 or 2).
 Each time an ACK (Acknowledgment) is received, TCP doubles the congestion
window size.
 This exponential growth continues until congestion is detected.
✔️ Pros:
 Quickly utilizes available bandwidth.
❌ Cons:
 Can cause congestion if growth is too fast.
📌 Example:
1️⃣ Starts with 1 segment.
2️⃣ After an ACK, sends 2 segments.
3️⃣ Then 4, 8, 16, and so on.
4️⃣ If congestion is detected, it switches to Congestion Avoidance mode.

B. Congestion Avoidance (AIMD – Additive Increase, Multiplicative Decrease) 📉


✔️ How It Works:
 If no congestion occurs, TCP increases the congestion window size slowly
(Additive Increase).
 If congestion is detected, TCP cuts the congestion window by half (Multiplicative
Decrease).
✔️ Pros:
 Prevents congestion by stabilizing transmission rates.
❌ Cons:
 Slows down after congestion is detected.
📌 Example:
 If the congestion window is 16 segments, it grows slowly: 17, 18, 19…
 If congestion occurs, it drops to 8 segments, then increases gradually again.

C. Fast Retransmit & Fast Recovery ⚡


✔️ How It Works:
1️⃣ If a packet is lost, the receiver sends duplicate ACKs.
2️⃣ When the sender receives three duplicate ACKs, it immediately retransmits the lost
packet (Fast Retransmit).
3️⃣ Instead of going back to Slow Start, TCP reduces the congestion window size moderately
(Fast Recovery).
✔️ Pros:
 Speeds up recovery from minor congestion.
❌ Cons:
 Doesn’t work well if multiple packets are lost.
📌 Example:
1️⃣ Sender sends packets 1, 2, 3, 4, 5.
2️⃣ Packet 3 is lost → Receiver keeps ACKing packet 2.
3️⃣ After three duplicate ACKs, the sender immediately resends packet 3.

D. Explicit Congestion Notification (ECN) 🚦


✔️ How It Works:
1️⃣ If a router detects congestion, instead of dropping packets, it marks them with ECN bits.
2️⃣ The receiver notifies the sender about congestion.
3️⃣ The sender reduces its transmission rate proactively.
✔️ Pros:
 Prevents congestion before packet loss happens.
❌ Cons:
 Requires support from both sender and receiver.
📌 Example:
1️⃣ A router notices high traffic and marks packets instead of dropping them.
2️⃣ The receiver informs the sender about congestion.
3️⃣ The sender reduces its data rate before congestion worsens.

4. TCP Congestion Control Phases


Phase Description Growth Rate
Starts with a small window and increases 🚀 Exponential (2x per
Slow Start
exponentially RTT)
Congestion Increases window slowly to prevent 📈 Linear (1 segment per
Avoidance congestion RTT)
Congestion Detects congestion via timeouts or
❌ Detects loss
Detection duplicate ACKs
Reduces sending rate and resumes normal
Recovery 📉 Cuts rate by half
operation

5. Congestion Control vs. Traffic Shaping


Aspect Congestion Control Traffic Shaping
Purpose Prevents congestion in the network Regulates outgoing traffic
Method Adjusts sending rate dynamically Delays packets when necessary
Where Applied Transport Layer (TCP) Network Layer (Routers, ISPs)

6. Other Congestion Control Mechanisms


🔹 Leaky Bucket Algorithm: Controls data flow by processing packets at a fixed rate.
🔹 Token Bucket Algorithm: Allows bursts of data by using tokens.
🔹 Random Early Detection (RED): Drops packets before congestion happens.

 Reduces idle waiting time.
❌ Cons:
 Requires buffering at sender and receiver.

4. TCP Flow Control Using the Window Size


 TCP advertises a "Receive Window (rwnd)" in each ACK packet.
 The sender adjusts its transmission rate based on the receiver’s window size.
 If the window size = 0, the sender pauses transmission until further notice.

5. Flow Control vs. Congestion Control


Aspect Flow Control Congestion Control
Prevents receiver
Purpose Prevents network congestion
overflow
Manages sender-
Focus Manages network traffic
receiver speed
Control Sliding Window, Stop- Slow Start, AIMD (Additive Increase,
Mechanism and-Wait Multiplicative Decrease)

6. Conclusion
 Flow control ensures the sender does not overwhelm the receiver.
 TCP uses Sliding Window Protocol for efficient data transmission.
 Window size (rwnd) dynamically adjusts to maintain a balance.

Retransmission Strategies in the Transport Layer


Retransmission strategies are mechanisms used in the Transport Layer to ensure reliable
data delivery when packets are lost, corrupted, or not acknowledged. These strategies help
recover lost data and maintain efficient communication between sender and receiver.

1. Why is Retransmission Needed?


 Packets may be lost due to network congestion.
 Data may get corrupted due to transmission errors.
 The receiver may fail to acknowledge (ACK) a packet.
 Ensures reliable communication, especially in TCP.

2. Types of Retransmission Strategies


A. Automatic Repeat reQuest (ARQ)
ARQ is a fundamental retransmission technique where the receiver requests retransmission
if an error or packet loss is detected. It includes:
1. Stop-and-Wait ARQ
✔️ How It Works:
 Sender sends one packet and waits for an acknowledgment (ACK).
 If ACK is received, the sender sends the next packet.
 If ACK is not received (timeout or error detected), the sender retransmits the
packet.
✔️ Pros:
 Simple and reliable.
❌ Cons:
 Inefficient for high-speed networks due to idle waiting time.

2. Go-Back-N ARQ
✔️ How It Works:
 Sender can send multiple packets before waiting for ACKs.
 If a packet is lost, the receiver discards all subsequent packets.
 The sender then retransmits all unacknowledged packets starting from the lost one.
✔️ Pros:
 Better efficiency than Stop-and-Wait.
❌ Cons:
 Wastes bandwidth by retransmitting unnecessary packets.
3. Selective Repeat ARQ
✔️ How It Works:
 The sender retransmits only the lost or corrupted packets instead of all subsequent
packets.
 Receiver buffers correctly received packets and waits for missing ones.
✔️ Pros:
 More efficient than Go-Back-N (avoids redundant retransmissions).
❌ Cons:
 Requires more complex buffering and processing.

B. Fast Retransmit (TCP-Specific Strategy)


✔️ How It Works:
 Instead of waiting for a timeout, TCP retransmits a lost packet immediately if it
receives three duplicate ACKs (same ACK repeatedly).
✔️ Example:
1️⃣ Sender sends Packets 1, 2, 3, 4, 5.
2️⃣ Packet 3 is lost.
3️⃣ Receiver ACKs Packet 2 three times (duplicate ACKs).
4️⃣ Sender immediately retransmits Packet 3 instead of waiting for a timeout.
✔️ Pros:
 Speeds up recovery of lost packets.
❌ Cons:
 Works best for minor packet losses, but not for heavy congestion.

C. Timer-Based Retransmission (Timeout)


✔️ How It Works:
 Sender starts a timer when a packet is sent.
 If an ACK is not received before the timer expires, the packet is retransmitted.
✔️ Pros:
 Ensures eventual delivery of all packets.
❌ Cons:
 Choosing the right timeout value is crucial:
o Too short → Unnecessary retransmissions.
o Too long → Increased delays.
3. Comparison of Retransmission Strategies
Strategy Best Used For Drawback
Stop-and-Wait ARQ Simple, low-bandwidth networks Slow, inefficient
High-speed networks with
Go-Back-N ARQ Wastes bandwidth
occasional errors
High-speed networks needing
Selective Repeat ARQ Complex buffering
efficiency
May not handle severe
Fast Retransmit TCP, quick recovery
congestion
Timer-Based Choosing the right timeout is
General error recovery
Retransmission tricky

4. Conclusion
 ARQ-based retransmissions (Stop-and-Wait, Go-Back-N, Selective Repeat)
provide reliability in packet-based networks.
 Fast Retransmit and Timer-Based Retransmission improve TCP efficiency.
 Choosing the right retransmission strategy depends on network speed, congestion
levels, and error rates.
.

CONGESTION CONTROL Introduction


Congestion control in the Transport Layer is essential to prevent excessive data from
overwhelming network resources. When too many packets are sent at once, the network
becomes congested, leading to packet loss, high delays, and reduced throughput.
📌 Key Differences:
 Flow Control: Regulates data transmission between sender and receiver to prevent
the receiver from being overwhelmed.
 Congestion Control: Regulates data transmission to prevent overloading the network
itself.
Why is Congestion Control Important?
✅ Prevents packet loss due to overloaded routers.
✅ Reduces delays and ensures smooth data transmission.
✅ Improves network performance and efficiency.

2. Causes of Network Congestion


🔹 High Traffic Load: Too many devices sending data at once.
🔹 Insufficient Bandwidth: Network capacity is lower than the demand.
🔹 Limited Router Buffer Space: Packets get dropped if routers can't handle more data.
🔹 Bursty Traffic: Sudden increases in data transmission cause congestion.
🔹 Network Failures: Link failures or routing changes create bottlenecks.

3. Congestion Control Mechanisms in TCP


A. Slow Start (Exponential Growth) 🚀
✔️ How It Works:
 TCP starts by sending a small number of packets (typically 1 or 2).
 Each time an ACK (Acknowledgment) is received, TCP doubles the congestion
window size.
 This exponential growth continues until congestion is detected.
✔️ Pros:
 Quickly utilizes available bandwidth.
❌ Cons:
 Can cause congestion if growth is too fast.
📌 Example:
1️⃣ Starts with 1 segment.
2️⃣ After an ACK, sends 2 segments.
3️⃣ Then 4, 8, 16, and so on.
4️⃣ If congestion is detected, it switches to Congestion Avoidance mode.

B. Congestion Avoidance (AIMD – Additive Increase, Multiplicative Decrease) 📉


✔️ How It Works:
 If no congestion occurs, TCP increases the congestion window size slowly
(Additive Increase).
 If congestion is detected, TCP cuts the congestion window by half (Multiplicative
Decrease).
✔️ Pros:
 Prevents congestion by stabilizing transmission rates.
❌ Cons:
 Slows down after congestion is detected.
📌 Example:
 If the congestion window is 16 segments, it grows slowly: 17, 18, 19…
 If congestion occurs, it drops to 8 segments, then increases gradually again.

C. Fast Retransmit & Fast Recovery ⚡


✔️ How It Works:
1️⃣ If a packet is lost, the receiver sends duplicate ACKs.
2️⃣ When the sender receives three duplicate ACKs, it immediately retransmits the lost
packet (Fast Retransmit).
3️⃣ Instead of going back to Slow Start, TCP reduces the congestion window size moderately
(Fast Recovery).
✔️ Pros:
 Speeds up recovery from minor congestion.
❌ Cons:
 Doesn’t work well if multiple packets are lost.
📌 Example:
1️⃣ Sender sends packets 1, 2, 3, 4, 5.
2️⃣ Packet 3 is lost → Receiver keeps ACKing packet 2.
3️⃣ After three duplicate ACKs, the sender immediately resends packet 3.

D. Explicit Congestion Notification (ECN) 🚦


✔️ How It Works:
1️⃣ If a router detects congestion, instead of dropping packets, it marks them with ECN bits.
2️⃣ The receiver notifies the sender about congestion.
3️⃣ The sender reduces its transmission rate proactively.
✔️ Pros:
 Prevents congestion before packet loss happens.
❌ Cons:
 Requires support from both sender and receiver.
📌 Example:
1️⃣ A router notices high traffic and marks packets instead of dropping them.
2️⃣ The receiver informs the sender about congestion.
3️⃣ The sender reduces its data rate before congestion worsens.

4. TCP Congestion Control Phases


Phase Description Growth Rate
Starts with a small window and increases 🚀 Exponential (2x per
Slow Start
exponentially RTT)
Congestion Increases window slowly to prevent 📈 Linear (1 segment per
Avoidance congestion RTT)
Congestion Detects congestion via timeouts or
duplicate ACKs ❌ Detects loss
Detection
Reduces sending rate and resumes normal
Recovery
operation 📉 Cuts rate by half

5. Congestion Control vs. Traffic Shaping


Aspect Congestion Control Traffic Shaping
Purpose Prevents congestion in the network Regulates outgoing traffic
Method Adjusts sending rate dynamically Delays packets when necessary
Where Applied Transport Layer (TCP) Network Layer (Routers, ISPs)

6. Other Congestion Control Mechanisms


🔹 Leaky Bucket Algorithm: Controls data flow by processing packets at a fixed rate.
🔹 Token Bucket Algorithm: Allows bursts of data by using tokens.
🔹 Random Early Detection (RED): Drops packets before congestion happens.

You might also like