0% found this document useful (0 votes)
9 views98 pages

notes

The document provides an overview of the Internet, explaining its structure as a 'Network of Networks' and differentiating between the Internet, intranets, and extranets. It details domain names, subdomains, and the Domain Name System (DNS) for address resolution, along with protocols like FTP and HTTP for data transfer. Additionally, it covers the functions of HTTP methods and the importance of URLs in accessing online resources.

Uploaded by

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

notes

The document provides an overview of the Internet, explaining its structure as a 'Network of Networks' and differentiating between the Internet, intranets, and extranets. It details domain names, subdomains, and the Domain Name System (DNS) for address resolution, along with protocols like FTP and HTTP for data transfer. Additionally, it covers the functions of HTTP methods and the importance of URLs in accessing online resources.

Uploaded by

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

1.

Overview of the Internet

The Internet is a global network of interconnected computers and devices that communicate using
standardized protocols (like TCP/IP). It enables services like the World Wide Web (WWW), email, file
sharing, and online communication.

2. Network of Networks

The Internet is called a "Network of Networks" because it connects millions of smaller networks
(like LANs, WANs, ISPs) worldwide. These networks exchange data using routers and switches.

3. Intranet

 A private network within an organization.

 Uses Internet technologies (HTTP, FTP) but is not accessible to the public.

 Example: A company’s internal portal for employees.

4. Extranet

 A controlled extension of an intranet that allows external access to selected users (e.g.,
partners, suppliers).

 Uses VPNs or secure logins for security.

 Example: A vendor accessing a company’s inventory system.

5. Internet vs. Intranet vs. Extranet

Feature Internet Intranet Extranet

Access Public Private Restricted (External partners)

Security Less secure Highly secure Secure (with authentication)

Example Google, Facebook Company HR portal Supplier order system

What Is a Domain?

Every website has a primary domain name (or web address) which is how visitors find your content
online. Meanwhile, web servers use IP addresses to serve the right website when called upon. But, IP
addresses are made up of long strings of numbers which are difficult for humans to remember.

To spare internet users the headache of remembering IP addresses, the Domain Name System (DNS)
maps them to more user-friendly domain names.

The domain will be preceeded by “www” which stands for world wide web. And, it will end with
a domain extension like .com or .org. So, our domain is “www.namehero.com”.

What Is a Subdomain?As we mentioned above, a subdomain is a branch of your main website and
usually has some degree of separation from your core content. You can also think of subdomains as
child domains of the larger parent domain.
Subdomains can organize and structure your content more clearly, which provides easy navigation for
visitors. Plus, subdomains can also help search engines better comprehend your website.

Most website owners use a subdomain when they want to create specific types of content that
aren’t relevant to the core site. A subdomain presents an easy way to do this without setting up a
whole new website.

1. Domain & Subdomain

A domain name is a human-readable address used to identify websites on the Internet. It consists of
two main parts:

 Second-Level Domain (SLD): The unique name chosen by the owner


(e.g., google in google.com).

 Top-Level Domain (TLD): The extension (e.g., .com, .org, .edu, .in).

A subdomain is an extension of the main domain, used to organize different sections of a website.
For example:

 mail.google.com (subdomain: mail)

 blog.example.com (subdomain: blog)

Subdomains help in separating services (e.g., support.website.com for customer help) or hosting
different regions (e.g., uk.store.com for the British version of a store).

Here's a more comprehensive look at the typical structure of a domain name:

subdomain.second-level-domain.top-level-domain

Let's dissect each part:

1. Top-Level Domain (TLD)

This is the rightmost part of the domain name, following the last dot. TLDs categorize websites based
on their purpose, ownership, or geographical origin.

2. Second-Level Domain (SLD)

This is the part immediately to the left of the TLD. It's the unique name you or the organization
register. This is often the brand name, the name of the organization, or a descriptive term.

Examples (continuing from before):

 In google.com, google is the SLD.

 In makaut.ac.in, ac is actually a second-level domain under the .in ccTLD, specifically used for
academic institutions in India. makaut is then the third-level domain (which in many contexts
functions similarly to a standard SLD under a gTLD).

3. Third-Level Domain (and beyond) / Subdomain

This is the part to the left of the SLD, separated by a dot. As we discussed, this is also known as a
subdomain. It allows you to organize different sections of your website. You can have multiple levels
of subdomains, although it's generally recommended to keep it concise for usability.
Examples:

 In blog.google.com, blog is the subdomain (third-level domain).

2. Address Resolution

Address resolution is the process of converting a domain name into an IP address, which computers
use to locate servers. This is done using the Domain Name System (DNS), which works like a
phonebook for the Internet.

Steps in DNS Resolution:

1. User Query: You type www.example.com in a browser.

2. Recursive Resolver: Your ISP’s DNS server searches for the IP.

3. Root Server: Directs the query to the correct TLD server (.com).

4. TLD Server: Refers to the authoritative DNS server of example.com.

5. Authoritative Server: Returns the IP address (e.g., 93.184.216.34).

6. Browser Access: The browser loads the website using the IP.

3. Protocols

a) DNS (Domain Name System)

DNS is a hierarchical, decentralized naming system that translates domain names to IP addresses. It
ensures users don’t need to remember numeric IPs (e.g., 142.250.190.46 for youtube.com).

 DNS Records:

o A Record: Maps a domain to an IPv4 address.

o AAAA Record: Maps a domain to an IPv6 address.

o MX Record: Directs email to a mail server.

 DNS Caching: Temporarily stores DNS queries to speed up future requests.

b) Telnet

Telnet is a legacy protocol for remote terminal access over a network. It allows users to control a
computer as if they were sitting in front of it. Telnet is a network protocol that allows a user to
establish a text-based command-line interface (CLI) with a remote computer or device over a TCP/IP
network. It essentially provides a way to log in to another system and execute commands on it as if
you were directly sitting in front of it.Think of it like having a virtual terminal session on a remote
machine. Whatever you type on your local machine is sent to the remote machine, and the output
from the remote machine is displayed on your screen.Features:Text-based communication (no
graphics).Operates on port 23.Drawbacks:No encryption (passwords sent in plain text).Mostly
replaced by SSH (Secure Shell), which encrypts data.

🌐 File Transfer Protocol (FTP)


FTP is one of the older internet protocols, designed to facilitate the exchange of files between
computers. It operates on a client-server architecture, where an FTP client (software on your
computer) connects to an FTP server (software running on a remote computer) to upload or
download files.

Key Characteristics of FTP:

 Separate Control and Data Connections: FTP uses two distinct TCP connections:

o Control Connection (Port 21): This connection is used for sending commands and
receiving responses between the client and the server (e.g., login, navigation,
requesting file transfer). This remains active throughout the session.

o Data Connection (Port 20 in Active Mode, Dynamic in Passive Mode): This


connection is used for the actual transfer of file data. A new data connection is
established each time a file is transferred or a directory listing is requested.

File Transfer Modes: Supports two main transfer modes:

 ASCII Mode: Used for transferring plain text files. It handles different end-of-line character
conventions between operating systems.

 Binary Mode: Used for transferring all other types of files (executables, images, archives,
etc.) without any modification.

 1. ASCII Mode (Type A):ASCII (American Standard Code for Information Interchange) mode is
designed for transferring plain text files.When transferring in ASCII mode, the sending FTP
client or server converts the text file to a standard network virtual terminal (NVT) ASCII
format before transmission.The receiving FTP client or server then converts the data from
the NVT ASCII format to its local system's text format, handling differences in end-of-line
characters (e.g., CRLF in Windows vs. LF in Unix).This ensures that text files are readable on
different operating systems after transfer.However, ASCII mode should only be used for plain
text files. Using it for binary files can lead to data corruption as the system might
misinterpret byte sequences as text formatting characters and alter them.

 2. Binary Mode (Type I or Image Mode):Binary mode, also known as Image mode, is used
for transferring all types of files that are not plain text, such as executables, images, audio
files, video files, compressed archives (.zip, .rar), and documents (.doc, .pdf).In binary mode,
the file is transferred byte-by-byte without any interpretation or conversion. The data is sent
as a continuous stream of bytes, and the receiving end stores this byte stream exactly as it
receives it.This ensures that the integrity of the file is maintained during the transfer, and
the received file is an exact copy of the original.It is generally recommended to use binary
mode as the default for most file transfers because it works reliably for both text and non-
text files, eliminating the risk of accidental corruption of binary data. Modern FTP clients
often default to binary mode. While modern text editors are often capable of handling
different line endings, binary mode ensures no unintended modifications occur.

Data Connection Establishment:

 Active Mode: The client tells the server its IP address and a port number, and the server
initiates the data connection back to the client from its port 20. This mode can have issues
with firewalls on the client side.
 Passive Mode: The client asks the server to open a port for data transfer (using the PASV
command). The server responds with an IP address and a port number, and the client
initiates the data connection to that port on the server. This mode is generally more firewall-
friendly.

How FTP Works (Simplified Steps):

1. Client Initiates Connection: You open an FTP client and provide the server's hostname or IP
address. The client establishes a control connection to the FTP server on port 21.

2. Authentication: The server prompts for a username and password (unless anonymous access
is allowed).

3. Command and Control: Once authenticated, the client sends commands over the control
connection (e.g., to list files, change directories, request a file transfer).

4. Data Connection Establishment:

o Active Mode: The client tells the server its IP address and a port number, and the
server initiates the data connection back to the client from its port 20. This mode
can have issues with firewalls on the client side.

o Passive Mode: The client asks the server to open a port for data transfer (using the
PASV command). The server responds with an IP address and a port number, and the
client initiates the data connection to that port on the server. This mode is generally
more firewall-friendly.

5. Data Transfer: Once the data connection is established, the requested file is transferred.

6. Closing Connection: The client can send a command to close the control connection, ending
the FTP session.

Common Uses of FTP:

Website Management: Uploading website files to a web server.Software Distribution: Providing


files for download.File Sharing: Sharing large files between users.Backup and Recovery:
Transferring backup files to a remote server.

HTTP stands for “Hypertext Transfer Protocol.” It is a set of rules for sharing data on the World Wide
Web (WWW). When you visit a website, HTTP helps your browser request and receive the data
needed to display the web pages you see. It is a fundamental part of how the internet works, making
it possible for us to browse and interact with websites.

 Basic Structure: HTTP forms the foundation of the web, enabling data communication and
file sharing.

 Web Browsing: Most websites use HTTP, so when you click on a link or download a file, HTTP
is at work.
 Client-Server Model: HTTP works on a request-response system. Your browser (client) asks
for information, and the website’s server responds with the data.

 Application Layer Protocol: HTTP operates within the Internet Protocol Suite, managing how
data is transmitted and received.

 Status Codes: HTTP responses include status codes, which are three-digit numbers that
indicate the outcome of the server's attempt to understand and satisfy the client's request.
Common categories include:

o 2xx (Success): The request was successful (e.g., 200 OK).

o 3xx (Redirection): The client needs to take further action to complete the request
(e.g., 301 Moved Permanently).

o 4xx (Client Error): The client's request contains an error (e.g., 404 Not Found).

o 5xx (Server Error): The server encountered an error while trying to fulfill the request
(e.g., 500 Internal Server Error).

How HTTP Works (Simplified Steps):

1. Client Request: A user enters a URL in their web browser or clicks a link. The browser parses
the URL and constructs an HTTP request message. This message includes the requested
resource (e.g., /index.html), the HTTP method (usually GET), and other headers providing
information about the browser and the request.

2. Server Receives Request: The HTTP request is sent over the internet to the web server
associated with the domain name in the URL. The server listens for incoming HTTP requests
on a specific port (usually port 80 for standard HTTP and port 443 for HTTPS).

3. Server Processes Request: The web server receives the request and processes it. This might
involve retrieving a static file, running a server-side script, or accessing a database.

4. Server Response: The server constructs an HTTP response message. This message includes a
status code indicating the outcome of the request, response headers providing information
about the server and the content, and the body containing the requested data (e.g., the
HTML content of the webpage, an image, etc.).

5. Client Receives Response: The server sends the HTTP response back to the client's browser.

6. Browser Renders Content: The browser receives the response and processes it. For an HTML
file, the browser parses the HTML, fetches any additional resources (like images, CSS,
JavaScript) using further HTTP requests, and then renders the webpage on the user's screen.

Evolution to HTTPS:

Due to the inherently unencrypted nature of standard HTTP, HTTPS (HTTP Secure) was developed.
HTTPS uses TLS/SSL (Transport Layer Security/Secure Sockets Layer) to encrypt the communication
between the client and the server, providing secure transmission of sensitive data. HTTPS typically
uses port 443.

In essence, HTTP is the language that web browsers and web servers use to communicate and
exchange information, making the World Wide Web possible. Understanding its request-response
model, stateless nature, methods, and status codes is fundamental to comprehending how the
internet works.

HTTP GET: Primarily for retrieving data from a server. Parameters are appended to the URL, making
them visible. GET requests are idempotent (multiple identical requests have the same outcome) and
safe (no server-side modifications). Responses can be cached and bookmarked, but data
transmission via URL has length limitations and is less secure for sensitive information. Used for
accessing webpages and simple data retrieval.

HTTP POST: Designed to send data to the server to create or update resources. Data is sent in the
request body, offering better security and allowing for larger data transmission. POST requests are
not idempotent (multiple requests can have different outcomes) and not safe (can modify server-
side data). Responses are typically not cached or bookmarked. Used for form submissions, file
uploads, and creating/updating data.

HTTP PUT (Short): Used to update or create a resource at a specific URL, with data in the request
body. It's idempotent but not safe, so responses are usually not cached or bookmarked. Security
relies on the connection (like HTTPS). Primarily for modifying resources at a known location.

HTTP DELETE (Short): Used to remove a resource identified by its URL. Generally idempotent but
not safe, so responses are typically not cached or bookmarked. Security depends on server-side
authentication. Primarily for deleting resources at a given URL.

What is URL?

URL stands for Uniform Resource Locator.


It is the address used to access resources on the Internet, like websites, images, videos, files, etc.

Think of a URL like a home address – it tells your browser where to go and how to reach a specific
resource on the web.

✅ Components of a URL

A standard URL looks like this:

https://www.example.com:443/path/to/page?name=ankan&id=101#section1

Let’s break it down:

Component Description

Specifies the protocol used to access the resource.


Common ones: http, https, ftp, mailto, etc.
1. Scheme/Protocol (https://)
Example: https:// means the browser will use secure
HTTP.

The domain name or IP address of the server where the


2. Hostname / Domain Name
resource is located.
(www.example.com)
It tells the browser which server to connect to.

3. Port (:443) (Optional) Specifies the port number on the server.


Default ports: 80 for HTTP, 443 for HTTPS.
Component Description

Usually hidden unless a non-default port is used.

Specifies the location of the resource on the server.


4. Path (/path/to/page) It’s like a folder structure.
Example: /blog/article.html

Starts with a question mark (?) and includes key-value


5. Query String (?name=ankan&id=101) pairs separated by &.
(Optional) Used to pass data to the server.
Example: ?search=hello&lang=en

Points to a specific section within the page.


6. Fragment / Anchor (#section1)
Used for internal navigation.
(Optional)
Example: #contact scrolls to the contact section of a page.

The Transmission Control Protocol/Internet Protocol (TCP/IP) is a suite of communication protocols


that forms the foundation of the internet and most modern networks. Think of it as the language
that computers use to talk to each other across the internet.

Here's a breakdown of what that means:

 Protocol Suite: TCP/IP isn't just one protocol; it's a collection of protocols that work together
to ensure reliable and efficient data transmission. The two most important protocols in this
suite are the Transmission Control Protocol (TCP) and the Internet Protocol (IP), hence the
name.

 Transmission Control Protocol (TCP): This protocol is responsible for the reliable delivery of
data between applications. It ensures that data is broken down into packets, transmitted,
and reassembled in the correct order at the destination. TCP also handles error checking and
retransmission of lost packets, making it a connection-oriented and reliable protocol.
Imagine it as a careful postal service that tracks your package and ensures it arrives complete
and in order.

 Internet Protocol (IP): This protocol deals with addressing and routing data packets across
networks. Each device connected to a network using TCP/IP is assigned a unique IP address.
IP is responsible for ensuring that data packets are sent to the correct destination based on
these addresses. Unlike TCP, IP is connectionless and doesn't guarantee delivery; it simply
routes the packets. Think of it as the street address system that gets your package to the
right city and house.

How TCP/IP Works (The Layered Model):

To manage the complexity of network communication, TCP/IP uses a layered model. This model
divides the communication process into four distinct layers, each with specific responsibilities:

1. Network Access Layer (or Link Layer): This is the lowest layer and deals with the physical
connection to the network. It handles the hardware and physical media used to transmit
data, such as Ethernet cables, Wi-Fi, and network interface cards.
2. Internet Layer: This layer is primarily concerned with IP addressing and routing. It ensures
that data packets are properly addressed and can travel across different networks to reach
their destination. The main protocol at this layer is IP (IPv4 or IPv6).

3. Transport Layer: This layer provides reliable (using TCP) or unreliable (using UDP - User
Datagram Protocol) end-to-end communication between applications. TCP handles
connection establishment, data segmentation, sequencing, error control, and flow control.
UDP provides a faster but less reliable connection, often used for applications where speed is
more critical than guaranteed delivery (like streaming).

4. Application Layer: This is the highest layer and interacts directly with user applications. It
includes protocols that applications use to exchange data, such as HTTP (for web browsing),
SMTP (for email), FTP (for file transfer), and DNS (for domain name resolution).

In simple terms, when you send data over the internet using TCP/IP:

1. The Application Layer prepares the data for transmission using a specific protocol (e.g., HTTP
for a web request).

2. The Transport Layer (using TCP) breaks the data into packets, adds headers for sequencing
and error checking, and establishes a connection with the receiving application.

3. The Internet Layer adds source and destination IP addresses to these packets, making them
IP datagrams, and routes them across the network.

4. The Network Access Layer handles the physical transmission of these datagrams over the
network medium.

When the data is received, this process is reversed at each layer until the receiving application gets
the original data.

Features of TCP/IP:

 Scalability: Easily accommodates small LANs to massive global networks.


 Interoperability: Supports communication between different hardware and OS platforms.
 Open Standard: TCP/IP is not owned by any single entity, allowing for broad adoption and
interoperability across different hardware and software.

 Client-Server Model: Many TCP/IP applications are based on the client-server model, where
a client requests services from a server.

 Routeable: IP enables data to be routed across multiple networks, which is fundamental to


the internet's functionality.

 Reliable (TCP): TCP ensures that data is delivered accurately and in order.

TCP Segment structure –


A TCP segment consists of data bytes to be sent and a header that is added to the data by TCP as
shown:
The header of a TCP segment can range from 20-60 bytes. 40 bytes are for options. If there are no
options, a header is 20 bytes else it can be of upmost 60 bytes.
Header fields:

 Source Port Address –


A 16-bit field that holds the port address of the application that is sending the data segment.

 Destination Port Address –


A 16-bit field that holds the port address of the application in the host that is receiving the
data segment.

 Sequence Number –
A 32-bit field that holds the sequence number, i.e, the byte number of the first byte that is
sent in that particular segment. It is used to reassemble the message at the receiving end of
the segments that are received out of order.

 Acknowledgement Number –
A 32-bit field that holds the acknowledgement number, i.e, the byte number that the
receiver expects to receive next. It is an acknowledgement for the previous bytes being
received successfully.

 Header Length (HLEN) –


This is a 4-bit field that indicates the length of the TCP header by a number of 4-byte words
in the header, i.e if the header is 20 bytes(min length of TCP header), then this field will hold
5 (because 5 x 4 = 20) and the maximum length: 60 bytes, then it’ll hold the value
15(because 15 x 4 = 60). Hence, the value of this field is always between 5 and 15.

 Control flags –
These are 6 1-bit control bits that control connection establishment, connection termination,
connection abortion, flow control, mode of transfer etc. Their function is:

o URG: Urgent pointer is valid

o ACK: Acknowledgement number is valid( used in case of cumulative


acknowledgement)

o PSH: Request for push

o RST: Reset the connection

o SYN: Synchronize sequence numbers

o FIN: Terminate the connection

 Window size –
This field tells the window size of the sending TCP in bytes.

 Checksum –
This field holds the checksum for error control. It is mandatory in TCP as opposed to UDP.

 Urgent pointer –
This field (valid only if the URG control flag is set) is used to point to data that is urgently
required that needs to reach the receiving process at the earliest. The value of this field is
added to the sequence number to get the byte number of the last urgent byte.

Three-way handshaking is a process used in TCP/IP networks to establish a reliable


connection between a client and a server before data transfer begins. It ensures both devices
are synchronized and agree on parameters for communication. The process involves three
steps:

1. SYN (Synchronize): The client initiates the connection by sending a TCP packet with
the SYN flag set to the server. This packet includes a sequence number (e.g., X) to
track the order of data bytes.
2. SYN-ACK (Synchronize-Acknowledgment): The server responds with a packet that
has both SYN and ACK flags set. The ACK acknowledges the client's SYN (with
acknowledgment number X+1), and the SYN includes the server's own sequence
number (e.g., Y).
3. ACK (Acknowledgment): The client sends a packet with the ACK flag set,
acknowledging the server's SYN (with acknowledgment number Y+1). This
completes the handshake, and the connection is established.

This process ensures reliable, ordered, and error-checked data transfer by confirming both
sides are ready and synchronized. It’s critical for TCP’s reliability but adds slight overhead
compared to connectionless protocols like UDP.

Flow Control

Flow Control is a technique used in data communication to prevent the sender from overwhelming
the receiver with too much data at once. It ensures a balanced and smooth data flow between
devices. There are two primary methods of flow control: Stop-and-Wait and Sliding Window
Protocol. In Stop-and-Wait, the sender sends one frame at a time and waits for an acknowledgment
before sending the next. In Sliding Window, multiple frames can be sent before needing an
acknowledgment, which increases efficiency. Flow control helps maintain data integrity and prevents
buffer overflow at the receiver’s end.

Stop-and-Wait and Sliding Window Protocols are two fundamental techniques used in
flow control to manage the rate of data transmission between a sender and a receiver in a
communication system.

In the Stop-and-Wait protocol, the sender transmits one frame at a time and then waits for
an acknowledgment (ACK) from the receiver before sending the next frame. If the
acknowledgment is received successfully, the sender proceeds with the next frame. If no
acknowledgment is received within a specified timeout period, the sender retransmits the
same frame. This method is very simple and easy to implement, using just a single buffer.
However, it is highly inefficient in networks with high latency or long distances because the
sender remains idle while waiting for acknowledgments, resulting in poor utilization of
available bandwidth.

On the other hand, the Sliding Window protocol is a more efficient and sophisticated
method of flow control. It allows the sender to transmit multiple frames before requiring
an acknowledgment, depending on the size of the window. The “window” refers to the
number of frames that can be sent without waiting for an acknowledgment. As
acknowledgments are received, the window “slides” forward, allowing the sender to continue
transmitting new frames. This approach increases channel utilization and throughput,
especially in high-latency environments.

There are two main types of Sliding Window protocols: Go-Back-N ARQ and Selective
Repeat ARQ. In Go-Back-N, if a frame is lost or damaged, the sender retransmits that frame
and all subsequent frames, even if some were correctly received. In contrast, Selective Repeat
is more efficient as it retransmits only the specific frames that were lost or corrupted, not the
entire sequence.

While Sliding Window protocols are more complex to implement compared to Stop-and-
Wait, they offer significantly better performance by making full use of the communication
channel. They require buffers on both the sender and receiver sides to keep track of frame
statuses and manage the sliding window mechanism. In summary, Stop-and-Wait is suitable
for simpler, low-latency connections, whereas Sliding Window is preferred for high-speed,
long-distance communication where efficiency and throughput are critical.

Selective Repeat ARQ (Automatic Repeat reQuest) is a data transmission protocol used
for flow and error control in communication systems. It is a type of Sliding Window
Protocol that ensures reliable data transfer by retransmitting only those frames that are lost or
corrupted during transmission, rather than resending all subsequent frames as in other
protocols like Go-Back-N.

In Selective Repeat ARQ, the sender can transmit multiple frames at once, each identified by
a unique sequence number, without waiting for an acknowledgment after every frame. The
receiver checks each incoming frame for errors and sends an acknowledgment (ACK) only
for correctly received frames. If a frame is found to be missing or corrupted, the receiver does
not acknowledge it, prompting the sender to retransmit only that specific frame after a
timeout. Meanwhile, the receiver accepts and stores out-of-order frames in a buffer, waiting
for the missing frames to arrive so that it can rearrange them in the correct order before
delivering them to the application layer.

This method greatly improves efficiency, especially in networks where errors or losses are
infrequent but latency is high. However, it is more complex to implement because both
sender and receiver need to maintain buffers and track the status of individual frames.
Despite the added complexity, Selective Repeat ARQ is widely used in systems that require
high throughput and reliability, as it minimizes unnecessary retransmissions and makes better
use of the available bandwidth compared to simpler protocols.

Error Control

Error Control is the process of detecting and correcting errors in transmitted data to ensure
reliability. It involves two main techniques: Error Detection and Error Correction. Common error
detection methods include Parity Bits, Checksum, and Cyclic Redundancy Check (CRC). Once an
error is detected, it can be corrected using techniques like Automatic Repeat reQuest (ARQ),
including Stop-and-Wait ARQ, Go-Back-N ARQ, and Selective Repeat ARQ. These protocols enable
retransmission of erroneous or lost data, ensuring that the received data is accurate and consistent.

Error Control is an essential aspect of data communication that ensures the reliable delivery of data
across a noisy or unreliable communication channel. It involves two key techniques: error detection
and error correction. These techniques work together to identify when data has been corrupted
during transmission and to correct or recover the original data as needed.

🔹 1. Error Detection Techniques

Error detection is the process of identifying errors in transmitted data. It does not correct the errors
but helps the receiver recognize that an error has occurred so that corrective action can be taken.
Parity Check – Explained Briefly

A parity check is a simple error detection technique used in digital communication and data storage.
It involves adding a parity bit to a binary message to help detect errors during transmission.

There are two types of parity:

 Even Parity: The total number of 1s (including the parity bit) is even.
 Odd Parity: The total number of 1s (including the parity bit) is odd.

For example, for data 1011 (which has 3 ones), an even parity bit would be 1 (making total 4 ones),
and an odd parity bit would be 0 (keeping total 3 ones).

The receiver checks the parity of the received data. If the parity condition is not satisfied, it means an
error has occurred. This method can detect only single-bit errors. If two or more bits are changed,
the parity may still appear correct, and the error will go undetected.

Parity check is commonly used in RAM, simple communication systems, and basic data protocols
where quick and low-cost error detection is required. However, it cannot correct errors and is not
suitable for detecting multiple-bit errors.

Checksum – Explained Briefly

A checksum is an error detection method used to verify the integrity of data during transmission or
storage. It works by treating the data as a sequence of numbers (usually in binary), which are then
added together using binary addition. The resulting sum is called the checksum, and it is sent along
with the data. At the receiving end, the receiver performs the same calculation on the received data
and compares its result with the received checksum. If both values match, the data is assumed to be
error-free.

The most common type of checksum used in simple systems is the 1’s complement checksum. In this
method, the binary data is divided into equal-sized blocks (e.g., 8 or 16 bits), and all the blocks are
added using binary addition. If a carry is generated, it is wrapped around and added back to the sum.
Finally, the 1’s complement of the total sum is taken to form the checksum. The receiver repeats the
same process and adds the checksum to the received data blocks. If the final result is all 1s, the data
is considered correct.

The main advantage of checksums is that they can detect multiple-bit errors better than simple
parity checks. However, like parity, checksums cannot correct errors—they can only detect them.
Also, checksums are not foolproof; if errors occur in such a way that they cancel each other out, the
error might go undetected.

Checksums are widely used in network communication protocols (like TCP/IP), file transfers, and
data storage systems to ensure data integrity. They offer better error detection than parity bits,
especially for detecting burst errors (multiple errors occurring together).
Cyclic Redundancy Check (CRC)

Cyclic Redundancy Check, or CRC, is a widely used error detection technique that ensures the
accuracy of data during transmission or storage. It is more powerful than parity or checksum
methods and is especially good at detecting burst errors — errors that affect multiple bits in a
sequence. CRC treats the data as a binary number and uses a predefined binary divisor known as a
generator polynomial. To generate the CRC code, the sender appends a number of zeros to the end
of the data — the number of zeros is equal to the degree of the generator polynomial. The sender
then performs binary division (using XOR instead of subtraction) between this extended data and the
generator polynomial. The remainder from this division is the CRC value, which is then attached to
the original data. The complete message (data + CRC) is sent to the receiver.

At the receiver's end, the same binary division is performed using the same generator polynomial on
the received message. If the result of this division (the remainder) is all zeros, it means that no error
has occurred during transmission. If the remainder is non-zero, it indicates that the data has been
corrupted. CRC is called "cyclic" because it uses cyclic binary division, and the arithmetic involved is
modulo-2, where subtraction and addition are both done using XOR.

CRC is extremely reliable in detecting common types of errors like single-bit errors, double-bit errors,
and burst errors up to the length of the polynomial. However, it cannot correct errors — it can only
detect them. Also, the reliability of CRC depends on choosing a good generator polynomial. Despite
being more complex than parity or checksum, CRC is used extensively in digital communication
protocols such as Ethernet, Wi-Fi, USB, and disk storage systems due to its high accuracy in error
detection.

Congestion Control

Congestion Control refers to techniques used to prevent network congestion by regulating the traffic
entry into the network. Congestion occurs when too many packets are present in the network,
leading to packet loss and delays. TCP uses several algorithms for congestion control, such as Slow
Start, Congestion Avoidance, Fast Retransmit, and Fast Recovery. These mechanisms dynamically
adjust the congestion window (cwnd) based on network feedback, reducing transmission rates
during congestion and increasing them gradually when the network is stable. Effective congestion
control is essential for maintaining the quality of service (QoS) in networks.

The key algorithms used by TCP (Transmission Control Protocol) to manage congestion control in a
network. They ensure that data is sent efficiently without overwhelming the network. Let’s
understand them one by one in simple terms and paragraph form.

✅ 1. Slow Start

The Slow Start algorithm is used at the beginning of a TCP connection or after a timeout to avoid
overloading the network. Initially, TCP starts by sending only a small amount of data — typically one
segment (packet). After each successful acknowledgment (ACK) from the receiver, the size of the
data sent (known as the congestion window) increases exponentially (it doubles). This continues
until a certain threshold (called the slow start threshold) is reached, or packet loss occurs. Despite its
name, slow start grows quickly, but it prevents sending too much data too soon.

✅ 2. Congestion Avoidance

Once the congestion window reaches the slow start threshold, TCP switches from slow start to
Congestion Avoidance mode. In this phase, the window size increases linearly instead of
exponentially. This more cautious approach helps prevent network congestion. The goal here is to
probe the available bandwidth slowly, avoiding packet loss. If no loss occurs, the window keeps
growing. But if a packet is lost, TCP assumes there’s congestion and reacts accordingly.

✅ 3. Fast Retransmit

When a packet is lost, TCP usually waits for a timeout before retransmitting. However, Fast
Retransmit speeds up this process. If the sender receives three duplicate ACKs (indicating that a
packet was missed but later packets arrived), it immediately retransmits the lost packet without
waiting for the timeout. This avoids unnecessary delay and improves performance, especially over
high-speed networks.

✅ 4. Fast Recovery

After Fast Retransmit, TCP enters the Fast Recovery phase instead of going back to slow start. It
assumes the network is still capable of handling some data. Instead of reducing the congestion
window to 1 (as in slow start), it reduces it moderately (typically to half of what it was before loss),
and then increases it linearly. This allows the sender to continue transmitting data without fully
backing off, helping maintain a reasonable throughput.

IP Datagram

An IP Datagram is the fundamental unit of data in the Internet Protocol (IP) used to transmit
information across networks. It consists of a header and payload (data). The header contains critical
information such as source and destination IP addresses, time to live (TTL), protocol type, header
length, and fragmentation details. IP datagrams are connectionless and unreliable, meaning they
can arrive out of order, be duplicated, or get lost. However, higher-layer protocols like TCP handle
these issues. If the datagram is too large for the next network segment, it is fragmented and later
reassembled at the destination.

1. Source IP Address

This is the IP address of the device sending the datagram. It tells the network where the packet
originated, allowing replies to be sent back correctly.
🔸 2. Destination IP Address

This field contains the IP address of the target device. Routers use it to forward the datagram toward
its intended recipient across the internet.

🔸 3. Version

Specifies the version of IP being used (usually IPv4 or IPv6). This helps the device understand how to
interpret the datagram's structure.

🔸 4. Total Length

This indicates the entire size of the IP datagram in bytes, including both the header and the data. It
tells routers how much data to expect.

🔸 5. Time to Live (TTL)

This value sets a limit on how many hops (routers) the datagram can pass through. It decreases with
each hop and prevents infinite looping in case of routing errors.

🔸 6. Protocol

This field tells the IP layer what protocol is encapsulated in the data section (e.g., TCP, UDP, ICMP). It
ensures the correct upper-layer protocol handles the data.

🔸 7. Header Checksum

A checksum value calculated only for the header. It helps detect errors in the header during
transmission; if errors are found, the packet is discarded.

🔸 8. Identification, Flags, Fragment Offset

These three fields work together for fragmentation:

 Identification labels fragments of the same packet,


 Flags control whether the packet can be fragmented,
 Fragment Offset tells where a fragment belongs in the original data.
They help when large packets are split across networks with smaller size limits.

IPv4 vs IPv6

IPv4 (Internet Protocol version 4) and IPv6 (version 6) are two versions of the IP protocol. IPv4 uses a
32-bit address format allowing about 4.3 billion unique addresses, written in dotted decimal
notation (e.g., 192.168.1.1). Due to the shortage of IPv4 addresses, IPv6 was introduced with a 128-
bit address space, allowing a virtually unlimited number of addresses (340 undecillion), written in
hexadecimal colon-separated format (e.g., 2001:0db8::1). IPv6 also simplifies header structures,
supports auto-configuration, and provides better security through built-in IPSec. Unlike IPv4, it
eliminates the need for NAT (Network Address Translation), making routing more efficient.

Feature IPv4 IPv6


32-bit address →
128-bit address → allows approximately
1. Address Length allows about 4.3 billion
3.4×10³⁸ addresses (virtually unlimited).
unique addresses.
Written in decimal
Written in hexadecimal format, e.g.,
2. Address Format format, e.g.,
2001:0db8:85a3::8a2e:0370:7334.
192.168.0.1.
3. Header Has a complex header
Has a simplified header for faster processing.
Complexity with many fields.
Supports manual
4. Address (static) or DHCP Supports auto-configuration using SLAAC
Configuration (dynamic) (Stateless Address Autoconfiguration).
configuration.
Security is optional
IPSec is mandatory, offering built-in
5. Security (IPSec can be used but
encryption and authentication.
not required).
Uses broadcasting to Does not support broadcasting; uses
6. Broadcasting
send data to all nodes. multicasting and anycasting instead.
Both sender and
Only the sender can fragment; routers do not
7. Fragmentation routers can fragment
perform fragmentation.
packets.
8. NAT (Network
Uses NAT due to No need for NAT because of a vast address
Address
limited address space. space.
Translation)

IP Addressing and Subnetting

IP Addressing is the process of assigning unique identifiers to devices on a network to enable


communication. Each IP address has two parts: the network ID and the host ID. IP addresses are
categorized into two main versions: IPv4 and IPv6. Subnetting divides a large network into smaller,
manageable sub-networks (subnets) to enhance routing efficiency, improve security, and optimize
address usage. It allows better utilization of IP address space by borrowing bits from the host portion
to create subnets. Subnetting is essential for designing scalable and efficient IP networks.
Classful Addressing

Classful Addressing divides the IPv4 address space into five classes (A to E). This system was used in
early networking before CIDR. Each class has a default subnet mask and fixed size:

 Class A: 0.0.0.0 to 127.255.255.255 (Default Mask: 255.0.0.0)


 Class B: 128.0.0.0 to 191.255.255.255 (Default Mask: 255.255.0.0)
 Class C: 192.0.0.0 to 223.255.255.255 (Default Mask: 255.255.255.0)
 Class D: 224.0.0.0 to 239.255.255.255 (Multicasting)
 Class E: 240.0.0.0 to 255.255.255.255 (Reserved for research)
Classful addressing is inefficient because it wastes IP addresses, especially in Class A and B
networks.

Default Subnet
Class IP Range Private IP Range Use
Mask
1.0.0.0 – 10.0.0.0 –
A 255.0.0.0 (/8) Large Networks
126.255.255.255 10.255.255.255
128.0.0.0 – 172.16.0.0 –
B 255.255.0.0 (/16) Medium Networks
191.255.255.255 172.31.255.255
192.0.0.0 – 192.168.0.0 – 255.255.255.0
C Small Networks
223.255.255.255 192.168.255.255 (/24)
224.0.0.0 –
D N/A N/A Multicast
239.255.255.255
240.0.0.0 – Experimental /
E N/A N/A
255.255.255.255 Reserved

Classless Addressing (CIDR – Classless Inter-Domain Routing)

Classless Addressing eliminates the rigid structure of classful addressing by allowing variable-length
subnet masking (VLSM). Instead of fixed classes, IP addresses use a CIDR notation, e.g.,
192.168.1.0/24, where /24 indicates the number of bits used for the network part. CIDR allows
for more flexible allocation of IP addresses, reducing wastage and making routing more scalable and
efficient. It supports route aggregation, which simplifies routing tables.

Subnetting (with Examples)

Subnetting is the practice of dividing a single network into smaller sub-networks using a custom
subnet mask. This helps in efficient IP address management, improves network performance, and
enhances security.
Example:
Given 192.168.1.0/24, and we want 4 subnets.

 Convert /24 to /26 (borrow 2 bits: 2² = 4 subnets).


 New subnet mask: 255.255.255.192
 Subnets:
1. 192.168.1.0 – 192.168.1.63
2. 192.168.1.64 – 192.168.1.127
3. 192.168.1.128 – 192.168.1.191
4. 192.168.1.192 – 192.168.1.255
Each subnet has 62 usable host addresses. Subnetting is essential in network design
to avoid IP conflicts and isolate traffic.

NAT (Network Address Translation)

NAT allows multiple devices on a local network to share a single public IP address when accessing the
internet. It translates private IP addresses (like 192.168.x.x, 10.x.x.x) into a public IP address.
This conserves IPv4 addresses and adds a layer of security by hiding internal IPs from the external
network. There are types of NAT: Static NAT (one-to-one mapping), Dynamic NAT (one-to-many), and
PAT (Port Address Translation) which allows multiple devices to share a single public IP using port
numbers.

Static NAT (One-to-One Mapping) involves a permanent, one-to-one relationship between a


private IP address and a public IP address. This is often used when a device, like a web
server, inside a private network needs to be consistently reachable from outside. For example,
a private IP like 192.168.1.2 might always map to the public IP 203.0.113.5, so every
request to 203.0.113.5 is directed to 192.168.1.2.

Dynamic NAT (One-to-Many Mapping) uses a pool of public IP addresses to dynamically


assign them to private IP addresses. The router picks a public IP from the pool whenever a
private device needs access to the internet. This is useful when multiple devices need internet
access but there are fewer public IPs than private ones. For example, 192.168.1.2 might be
mapped to 203.0.113.5, 192.168.1.3 to 203.0.113.6, and so on, with each device using a
different public IP as needed.

PAT (Port Address Translation) allows multiple private devices to share a single public IP
address by distinguishing the devices through unique port numbers. When devices inside a
network access the internet, their requests are mapped to the same public IP, but each device
is differentiated by its port number. This is particularly helpful when there’s a shortage of
public IPs. For instance, private IPs like 192.168.1.2, 192.168.1.3, and 192.168.1.4 can
all share the same public IP 203.0.113.5, with each request identified by a unique port, like
5001 for 192.168.1.2 and 5002 for 192.168.1.3.

IP Masquerading

IP Masquerading is a form of NAT commonly used in Linux-based routers. It enables an entire private
network to access the internet using a single public IP. The router rewrites the source IP of outgoing
packets to its public IP and tracks responses to forward them back to the correct internal device. It’s
often used in home or small business networks. IP masquerading is typically enabled using iptables
with MASQUERADE rules.
What is iptables?
At its core, iptables is a command-line utility that allows system administrators to configure
the Netfilter framework, which is the packet filtering subsystem within the Linux kernel.
Think of iptables as the user interface to the kernel's firewall. It lets you define rules for how
network traffic is treated.
Key things to understand about iptables:

 Tables: iptables organizes rules into different tables, each designed for a specific
purpose. The most common tables are:
o filter (default): This table deals with general packet filtering – deciding whether
to allow or block traffic based on source/destination IP addresses, ports, protocols,
etc. It has three built-in chains:
 INPUT: Rules applied to packets destined for the local system.
 OUTPUT: Rules applied to packets originating from the local system.
 FORWARD: Rules applied to packets passing through the system (e.g., in a
router scenario).

Routing Concepts

Routing is the process of selecting paths for traffic in a network or between multiple networks. It
ensures that data is efficiently delivered from the source to the destination. Routers are devices
responsible for routing packets based on IP addresses. Routing is classified into two types:

 Static Routing: Routes are manually configured and don’t change unless modified.
 Dynamic Routing: Routes are automatically adjusted by routing protocols based on network
conditions.

The Routing Table is a key component in routers, storing information about possible paths. Routing
protocols help routers communicate with each other to discover and maintain these paths. Common
routing protocols include RIP, OSPF, and BGP.

Intra-domain Routing

Intra-domain Routing (also known as Interior Gateway Protocols or IGP) deals with routing within a
single autonomous unit or administrative domain, such as within an enterprise or an ISP network.
These protocols are responsible for managing routing within a specific network or area. Key intra-
domain routing protocols include:

 RIP (Routing Information Protocol): An older distance-vector protocol that uses hop count as
a metric.
 OSPF (Open Shortest Path First): A link-state protocol that uses the Dijkstra algorithm to find
the shortest path and scales better in large networks.
 EIGRP (Enhanced Interior Gateway Routing Protocol): A Cisco proprietary protocol that
combines the features of both distance-vector and link-state protocols, offering faster
convergence and better scalability.
Intra-domain routing focuses on maintaining consistent routing paths within the network, ensuring
that data travels efficiently between devices within the same organization.

RIP (Routing Information Protocol)

RIP is a distance vector routing protocol used in small to medium-sized networks. It determines the
best path to a destination based on the hop count — the number of routers a packet must pass
through. The maximum hop count allowed is 15, making it unsuitable for large networks. RIP sends
routing updates every 30 seconds, which can lead to slow convergence and outdated routing
information.

OSPF (Open Shortest Path First)

OSPF is a link-state routing protocol used within larger or more complex networks. It calculates the
shortest path using Dijkstra’s algorithm and considers multiple factors like bandwidth, cost, and
delay — not just hop count. OSPF converges faster than RIP and supports hierarchical routing using
areas to improve scalability and manageability. It is more efficient and accurate in route calculation.

Feature Distance Vector Routing Link State Routing


How it works Sends entire routing table to neighbors Shares only link info with all routers
Network view Knows only about neighbors Knows the entire network map
Speed Slower to update (converge) Faster to update
Complexity Simple and easy to set up More complex and powerful
Used in Small networks Large and modern networks
Examples RIP OSPF, IS-IS
Metric Hop count Cost (bandwidth, delay, etc.)
Routing loops Can occur (needs prevention tricks) Rarely occurs

Inter-domain Routing

Inter-domain Routing (also known as Exterior Gateway Protocols or EGP) handles routing between
different networks or autonomous systems (AS). The primary protocol used for inter-domain routing
is:

 BGP (Border Gateway Protocol): The most widely used inter-domain protocol, BGP is a path
vector protocol that exchanges routing information between different autonomous systems
on the internet. BGP is responsible for determining the most efficient routes based on
policies and network performance.
 BGP uses attributes like AS path, Next-hop, and Prefix to decide the best routes for data
between different networks.

Inter-domain routing is crucial for managing how internet traffic is routed between different
organizations, ISPs, or network providers, ensuring global connectivity.
BGP (Border Gateway Protocol)

BGP is a path vector protocol and is used to exchange routing information between autonomous
systems (ASes) on the internet. It is the backbone routing protocol of the internet. Unlike RIP and
OSPF, which are used within a network, BGP is used between networks. It makes routing decisions
based on policies, path attributes, and rule sets rather than shortest distance. BGP is highly scalable
and stable, but more complex to configure and manage.

Unicast Routing

Unicast Routing refers to the transmission of data from one sender to one receiver over a network. In
unicast routing, each packet is sent directly to the intended recipient. Routers and protocols like
OSPF or BGP use unicast routing to deliver packets from the source to the destination based on IP
address matching. The routing path is determined by the routing table that specifies the next hop for
each packet. It is the most common form of routing on the internet and local networks, where each
connection requires a dedicated communication path.

Example: Sending an email to a specific recipient or visiting a website where data travels from the
server to one client.

Multicast Routing

Multicast Routing allows data to be sent from one source to multiple receivers at once. It is used in
applications like video conferencing, live streaming, and online gaming, where data needs to be
broadcasted to multiple clients but not to the entire network. Multicast groups are created based on
IP addresses in the range 224.0.0.0 to 239.255.255.255. Routers use protocols like PIM (Protocol
Independent Multicast) and IGMP (Internet Group Management Protocol) to manage multicast
routing. PIM supports both Sparse Mode (PIM-SM) and Dense Mode (PIM-DM) to efficiently
manage multicast traffic depending on whether receivers are sparsely or densely located across the
network.

Example: A live sports stream sent to many viewers simultaneously, where each viewer receives the
same broadcasted data without overwhelming the network.

Broadcast

Broadcast refers to sending data from one sender to all devices within a specific network. It uses a
special broadcast address, usually the all-hosts broadcast address (e.g., 255.255.255.255 in IPv4).
Broadcast messages are typically used in local area networks (LANs) for tasks like network discovery
and announcements. ARP (Address Resolution Protocol) is an example of broadcast communication,
where a host sends a request to find the MAC address of another device within the same network.
In contrast to multicast, which targets a specific group, broadcast affects all devices in the subnet.
While broadcast is efficient for LANs, it’s not scalable for larger networks due to the potential
congestion caused by sending data to every device on the network.

Electronic Mail (Email)

Electronic Mail (Email) is a widely used communication system that allows users to exchange
messages over the Internet or other computer networks. It supports text messages, multimedia
attachments, and file transfers. Emails are composed using a Mail User Agent (MUA) (like Gmail,
Outlook, or Thunderbird) and delivered via various protocols that handle message submission,
transfer, and retrieval. Email systems rely on a set of client-server protocols that ensure proper
delivery from sender to recipient, even if they are on different networks or servers.

Email Architecture (Using SMTP Flow)


The Email Architecture consists of multiple components that work together to send, route, deliver,
and retrieve email messages efficiently. These components and protocols follow a well-defined flow:

🔑 Key Components:

1. MUA (Mail User Agent):


The email client used by users to compose and read emails (e.g., Gmail, Outlook).
2. MSA (Mail Submission Agent):
Submits the outgoing email from the MUA to the sender’s mail server using SMTP.
3. MTA (Mail Transfer Agent):
Transfers emails across networks from sender to receiver domain via SMTP (e.g., Postfix,
Sendmail).
4. MDA (Mail Delivery Agent):
Delivers incoming emails from the receiver's MTA to the recipient's Mailbox.
5. Mailbox (Message Store):
Stores the delivered emails until the recipient accesses them.
6. POP3 / IMAP:
Protocols used by the recipient’s MUA to retrieve emails from their mailbox:
o POP3 downloads and may delete emails from the server.
o IMAP keeps emails on the server and syncs across devices.

🔁 Workflow:
Email Delivery Workflow (Explained)
1. MUA → SMTP → MSA (Mail Submission):
The process begins when the sender composes an email using a Mail User Agent (MUA) like
Gmail or Outlook. Once the user clicks "Send," the email is handed off to a Mail Submission
Agent (MSA) using the SMTP protocol. The MSA is responsible for accepting the message
from the MUA and preparing it for transport.
2. MSA → SMTP → Sender MTA (Mail Transfer):
The MSA forwards the email to the sender's Mail Transfer Agent (MTA) using SMTP. The
MTA acts like a post office—it determines how to deliver the message to the recipient's mail
server.
3. Sender MTA → SMTP → Receiver MTA (Server-to-Server Transfer):
The sender’s MTA looks up the recipient's domain via DNS and establishes an SMTP
connection with the receiver’s MTA. The email is then transferred from the sender’s server
to the recipient’s mail server.
4. Receiver MTA → MDA → Mailbox (Delivery):
Once the receiver’s MTA accepts the email, it passes it to a Mail Delivery Agent (MDA). The
MDA delivers the email into the recipient’s mailbox, which acts as a storage space until the
user accesses it.
5. Mailbox → POP3/IMAP → MUA (Retrieval):
Finally, the recipient uses their MUA to check their mailbox. To retrieve the email, the MUA
uses either POP3 (downloads messages) or IMAP (synchronizes with the server). The email is
now available for the user to read.

POP3 (Post Office Protocol v3)

POP3 is an application-layer protocol used by email clients to retrieve messages from a mail server. It
works on port 110 and follows a "download-and-delete" model by default, meaning emails are
downloaded to the client and deleted from the server (though many clients now allow keeping a
copy on the server). POP3 is simple and requires less server storage, but it does not support folder
management or multi-device sync.

Key Features:

 Operates in two modes: Delete Mode and Keep Mode.


 No synchronization between client and server (unlike IMAP).
 Suitable for users who access mail from a single device.

Example: Outlook downloading all your emails and removing them from the server.

SMTP (Simple Mail Transfer Protocol)

SMTP is the protocol used to send email messages from a client to a server or between servers. It
works over port 25 (or port 587 for client submission with authentication and encryption). SMTP is a
push protocol, meaning it pushes emails from the sender’s side to the receiver's server. It does not
retrieve messages (retrieval is handled by POP3 or IMAP).

SMTP Workflow:

 MUA uses SMTP to send the email to the sender's MTA.


 MTA forwards the email to the recipient’s MTA using SMTP.
 If delivery fails, the message is queued and retried or bounced.

SMTP Commands:
Some common commands include HELO, MAIL FROM, RCPT TO, DATA, and QUIT.
Limitations:

 No encryption by default (extensions like STARTTLS are used for secure SMTP).
 Cannot retrieve emails.

Together, SMTP handles sending, while POP3 handles receiving, forming the core of traditional email
communication systems. For modern, multi-device use, IMAP (not covered here) is often used
instead of POP3 for advanced synchronization.

IMAP (Internet Message Access Protocol)


IMAP is a protocol used by email clients (MUAs) to access and manage emails stored on a remote
mail server. Unlike POP3, IMAP allows users to view, organize, and synchronize emails across
multiple devices without downloading them permanently.

🔹 Key Features of IMAP:

 Emails are stored on the server, not downloaded by default.


 Allows multiple devices (phone, laptop, webmail) to access the same mailbox.
 Supports folders, labels, flags, and real-time sync.
 Useful when accessing email from multiple locations/devices.

Port numbers:

 IMAP (unsecured): 143


 IMAP over SSL/TLS (secure): 993

📊 SMTP vs POP3 vs IMAP


SMTP (Simple Mail POP3 (Post Office Protocol IMAP (Internet Message
Feature/Aspect
Transfer Protocol) v3) Access Protocol)

Receiving emails Receiving & managing emails


Purpose Sending emails (push)
(download-and-delete) (sync)

Client → Server (MUA Server ↔ Client (sync both


Direction Server → Client
to MTA) ways)

25 (default), 587
Ports 110 (default), 995 (SSL) 143 (default), 993 (SSL)
(submission), 465 (SSL)

Emails downloaded &


Storage Not applicable usually deleted from Emails remain on the server
server

Multi-device ❌ Not applicable ❌ Poor (messages not ✅ Excellent (real-time sync


SMTP (Simple Mail POP3 (Post Office Protocol IMAP (Internet Message
Feature/Aspect
Transfer Protocol) v3) Access Protocol)

access synced) across devices)

Folder support ❌ No ❌ No ✅ Yes (Inbox, Sent, Trash, etc.)

❌ One-way (sending
Sync capability ❌ No real-time sync ✅ Two-way sync
only)

Offline Access ❌ Not for delivery ✅ Yes (after download) ✅ Yes (cached copy)

Sending mail from MUA For single-device email For accessing and managing
Use Case
to MTA retrieval mail on multiple devices

Uses STARTTLS or
Security Uses SSL/TLS (optional) Uses SSL/TLS (recommended)
SSL/TLS for encryption

Summary:

 SMTP = Used to send emails only.


 POP3 = Used to download and delete emails from the server (simple, offline use).
 IMAP = Used to access and manage emails directly on the server (ideal for multi-device use).

7 common HTML tags along with their attributes and examples:

1. <a> – Anchor Tag

 Use: Creates hyperlinks.


 Common Attributes: href, target, title
 Example:

html
CopyEdit
<a href="https://example.com" target="_blank" title="Visit
Example">Visit Site</a>

2. <img> – Image Tag

 Use: Embeds images.


 Common Attributes: src, alt, width, height
 Example:

html
CopyEdit
<img src="image.jpg" alt="Nature" width="300" height="200">
3. <input> – Input Tag

 Use: Creates form fields.


 Common Attributes: type, name, placeholder, value
 Example:

html
CopyEdit
<input type="text" name="username" placeholder="Enter your name">

4. <p> – Paragraph Tag

 Use: Adds text paragraphs.


 Common Attributes: align, style
 Example:

html
CopyEdit
<p style="color:blue; font-size:16px;">This is a blue paragraph.</p>

5. <div> – Division Tag

 Use: Groups elements, often styled with CSS.


 Common Attributes: id, class, style
 Example:

html
CopyEdit
<div id="content" class="main-section" style="background-
color:lightgray;">
Welcome to my website!
</div>

6. <button> – Button Tag

 Use: Creates clickable buttons.


 Common Attributes: type, onclick, disabled
 Example:

html
CopyEdit
<button type="button" onclick="alert('Hello!')">Click Me</button>

7. <table> – Table Tag

 Use: Creates a table layout.


 Common Attributes: border, cellpadding, cellspacing
 Example:
html
CopyEdit
<table border="1" cellpadding="5" cellspacing="0">
<tr><th>Name</th><th>Age</th></tr>
<tr><td>Alice</td><td>22</td></tr>
</table>

What is an <iframe> in HTML?

An iframe (short for inline frame) is an HTML element that allows you to embed another HTML page
or website within your current webpage.

🔧 Syntax:
html
CopyEdit
<iframe src="https://example.com" width="600" height="400"></iframe>

HTML Forms Overview


An HTML form is used to collect user input. It contains form elements like text fields, checkboxes,
radio buttons, buttons, etc.

html
CopyEdit
<form action="submit.php" method="post">
<!-- Form elements go here -->
</form>

🧩 1. Input Types in HTML


The <input> tag is used to create different types of form elements by using the type attribute:

Input Type Purpose Example

text Single-line text input <input type="text">

password Hidden text (like passwords) <input type="password">

email Email input (validates format) <input type="email">

number Number input <input type="number">

checkbox Checkbox input <input type="checkbox">

radio Radio button (for single choice) <input type="radio">

submit Submit button <input type="submit">


2. Text Fields
A text field is a basic input where users type text.

html
CopyEdit
<label for="name">Name:</label>
<input type="text" id="name" name="username" placeholder="Enter your name">

🔘 3. Buttons in Forms
You can create different buttons in HTML:

🔹 Submit Button

Sends form data to the server.

html
CopyEdit
<input type="submit" value="Submit">

Or using <button>:

html
CopyEdit
<button type="submit">Submit</button>

1. Radio Buttons
 Use: When you want the user to select only ONE option from a group.
 Key Point: All radio buttons in the same group must have the same name attribute.

🔹 Example: Gender Selection


html
CopyEdit
<form>
<label><input type="radio" name="gender" value="male"> Male</label><br>
<label><input type="radio" name="gender" value="female">
Female</label><br>
<label><input type="radio" name="gender" value="other"> Other</label>
</form>

 Only one option can be selected at a time because the name is the same.

✅ 2. Checkboxes
 Use: When you want the user to select multiple options.
 Key Point: You can give the same or different name depending on how you handle the data.
🔹 Example: Choose Hobbies
html
CopyEdit
<form>
<label><input type="checkbox" name="hobby" value="reading">
Reading</label><br>
<label><input type="checkbox" name="hobby" value="music">
Music</label><br>
<label><input type="checkbox" name="hobby" value="sports"> Sports</label>
</form>

 The user can select any number of checkboxes (even all).

1. Head Section Tags


The <head> tag contains meta-information about the webpage, which is not displayed on the page
itself.

✨ Common <head> Tags:


html
CopyEdit
<head>
<title>My Web Page</title> <!-- Title in browser tab -->
<meta charset="UTF-8"> <!-- Character encoding -->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Responsive -->
<link rel="stylesheet" href="style.css"> <!-- External CSS -->
<script src="script.js"></script> <!-- External JavaScript -->
</head>

List Tags (All Types)


✅ a) Ordered List (<ol>)

Used for numbered items.

html
CopyEdit
<ol>
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
</ol>

✅ b) Unordered List (<ul>)

Used for bulleted items.

html
CopyEdit
<ul>
<li>Home</li>
<li>About</li>
<li>Contact</li>
</ul>

✅ c) Description List (<dl>)

Used for terms and definitions.

html
CopyEdit
<dl>
<dt>HTML</dt>
<dd>HyperText Markup Language</dd>
<dt>CSS</dt>
<dd>Cascading Style Sheets</dd>
</dl>

📊 4. Table Tags (All Important Tags)


HTML tables are defined using the <table> tag.

✨ Common Table Structure:


html
CopyEdit
<table border="1">
<caption>Student Marks</caption>
<thead>
<tr>
<th>Name</th>
<th>Math</th>
<th>Science</th>
</tr>
</thead>
<tbody>
<tr>
<td>Alice</td>
<td>95</td>
<td>88</td>
</tr>
<tr>
<td>Bob</td>
<td>85</td>
<td>90</td>
</tr>
</tbody>
<tfoot>
<tr>
<td>Total</td>
<td colspan="2">--</td>
</tr>
</tfoot>
</table>

2. Layout Tags
1. <header> – Top section (logo, title, nav)
<header><h1>My Site</h1></header>

2. <nav> – Navigation links


<nav><a href="#home">Home</a></nav>

3. <main> – Main content area


<main><h2>Welcome</h2></main>

4. <section> – Group related content


<section><h3>Services</h3></section>

5. <article> – Independent content (e.g., blog)


<article><h3>Post Title</h3></article>

6. <aside> – Sidebar or related info


<aside><p>Related Links</p></aside>

7. <footer> – Bottom of the page


<footer><p>© 2025</p></footer>

8. <div> – Generic block container


<div class="box">Box Content</div>

9. <span> – Inline text container


<p>This is <span style="color:red;">red</span>.</p>

CSS Formatting (Text & Elements)


✅ Text Formatting:
css
CopyEdit
color: blue; /* Text color */
font-size: 16px; /* Size of text */
font-family: Arial; /* Font style */
text-align: center; /* Align text */
font-weight: bold; /* Bold text */
text-decoration: underline; /* Underline */

✅ Box Formatting:
css
CopyEdit
background-color: yellow; /* Background color */
padding: 10px; /* Space inside element */
margin: 20px; /* Space outside element */
border: 2px solid black; /* Border style */

Image Maps in HTML


An image map lets you define clickable areas on an image, each linking to different destinations.

1. <map> Tag

 Defines the image map.


 Has a name attribute used to reference the map in the <img> tag.

2. <area> Tag

 Defines each clickable area inside the map.


 Attributes:
o shape — shape of the area (rect, circle, poly)
o coords — coordinates of the shape on the image
o href — URL to open when area is clicked
o alt — alternate text for the area

Example:
html
CopyEdit
<img src="world-map.jpg" usemap="#worldmap" alt="World Map">

<map name="worldmap">
<area shape="rect" coords="34,44,270,350" href="asia.html" alt="Asia">
<area shape="circle" coords="450,100,50" href="europe.html" alt="Europe">
<area shape="poly" coords="290,172,333,250,300,300" href="africa.html"
alt="Africa">
</map>

How coords Work in Image Maps


The coords attribute defines the exact pixel positions on the image where the clickable area lies.
The meaning of the numbers depends on the shape:
1. rect (Rectangle)

 4 values: x1,y1,x2,y2
 (x1, y1) = top-left corner
 (x2, y2) = bottom-right corner

Example:
coords="34,44,270,350" means rectangle from pixel (34,44) to (270,350).

2. circle (Circle)

 3 values: x_center,y_center,radius
 (x_center, y_center) = center of circle
 radius = radius in pixels

Example:
coords="450,100,50" means a circle centered at (450,100) with radius 50 pixels.

3. poly (Polygon)

 Multiple pairs of x,y values: x1,y1,x2,y2,x3,y3,...


 Defines a polygon by connecting points in order.

Example:
coords="290,172,333,250,300,300" means a triangle with vertices at (290,172), (333,250),
and (300,300).

Attributes of <area>
Attribute Description Example

Defines the shape of the clickable area. Values:


shape <area shape="rect" ...>
rect, circle, poly, or default.

Specifies the coordinates for the shape (pixels on <area coords="34,44,270,350"


coords ...>
the image).

href URL to navigate to when the area is clicked. <area href="page.html" ...>

Alternate text description for the area (important


alt <area alt="Asia" ...>
for accessibility).

Specifies where to open the linked document


target <area target="_blank" ...>
(_blank, _self, etc.).
1. Introduction to XML
XML (Extensible Markup Language) is a flexible text format used to create structured documents and
data. It allows you to define your own custom tags, making it ideal for storing, transporting, and
sharing data across different systems, especially over the internet. Unlike HTML, which focuses on
displaying data, XML focuses on carrying data and its meaning.it is understood by machines and
humans also.

2. XML Tree Structure


XML documents are structured as a hierarchical tree of elements. Each element can have child
elements, attributes, and text content. The root element is the top-level container, and all other
elements branch out from it like nodes in a tree.

For example, consider:

xml
CopyEdit
<bookstore>
<book>
<title>XML Basics</title>
<author>John Doe</author>
</book>
</bookstore>

 bookstore is the root element.


 book is a child of bookstore.
 title and author are children of book.

3. Syntax, Elements, Attributes


 Syntax Rules:
o XML is case-sensitive.
o Every start tag must have a matching end tag.
o Elements must be properly nested.
o There must be one root element.
o Attribute values must be quoted.
 Elements: Defined by tags that enclose data.
Example: <name>John</name>
 Attributes: Provide additional information about elements in name="value" pairs inside the
start tag.
Example: <book category="fiction">...</book>
4. Validation (DTD, Schema)
Validation ensures the XML document follows the correct structure and rules.

 DTD (Document Type Definition): An older method to define the allowed structure and
elements of XML. It declares the elements, their relationships, and attributes. DTD is a set of
rules that tells what elements and structure an XML document should have.
It checks if your XML tags are written correctly and in the right order. Think of it like a
grammar checker for your XML.

XML Schema (XSD): A more powerful and flexible way to validate XML. It defines data types, allowed

values, and complex structures. XML Schema is written in XML syntax. XML Schema is a more
advanced version of DTD.It not only checks the structure but also the type of data (like
numbers, dates, text) in your XML.Think of it like a spell checker + grammar checker with
more power.Both help make sure that XML data is consistent and correct before processing.

5. Viewing XML
 XML files are plain text files and can be opened with any text editor or browser.
 Browsers display XML in a collapsible tree format but don’t style it by default.
 XML can be transformed with XSLT or styled with CSS for better presentation.

6. Brief Overview of XHTML


XHTML (Extensible HyperText Markup Language) is a stricter and XML-based version of HTML. It
combines the flexibility of HTML with the strict syntax rules of XML, making web pages more
consistent and easier to parse by browsers and devices.

Key points:

 XHTML documents must be well-formed XML.


 All tags must be properly closed.
 Tags and attributes must be lowercase.
 Attribute values must be quoted.

Summary: DTD vs. XML Schema


Feature DTD XML Schema (XSD)

Syntax Not XML XML-based

Data Types Not supported Supported (string, int, etc.)


Feature DTD XML Schema (XSD)

Namespaces Not supported Supported

Readability Simple Verbose but powerful

Usage Older, simpler validation Modern, robust validation

🔁 XML vs HTML – Easy Comparison Table


Feature XML HTML

Purpose Data storage & transport Data display & formatting

Custom Tags Yes (user-defined) No (fixed tags only)

Case Sensitivity Case-sensitive Not case-sensitive

Closing Tags Mandatory Optional for some tags

Structure Strict (well-formed) Lenient

Data Validation Supports DTD/Schema No built-in validation

Presentation Support No Yes (uses CSS, etc.)

Why is XML superior to HTML?


🔹 Reason 🔍 Explanation

Data Focused XML is designed to store and transport data.

Custom Tags Allowed You can define your own tags in XML.

Strict Structure XML is well-formed and easier to validate.

Separation of Data & Presentation XML carries data only, no design or layout.

Machine and Human Readable Easy to parse and understand.

✅ HTML is used to display data, while XML is used to store and carry data.
That’s why XML is more flexible and powerful for data exchange.

📘 DOM (Document Object Model) Parser

The DOM parser reads the entire XML document and stores it in memory as a tree structure. Each
tag, attribute, and text is represented as a node in this tree. Once loaded, the application can access,
navigate, and modify any part of the XML document easily. DOM is easier to program because it
provides a lot of flexibility and allows both reading and writing of XML data. However, since it loads
the whole document at once, it uses more memory, so it's best suited for small to medium-sized
XML files. DOM parsers are commonly used in languages like JavaScript, Java, and Python for working
with XML or HTML documents.
📗 SAX (Simple API for XML) Parser

The SAX parser is an event-driven parser that reads an XML file sequentially from top to bottom. It
does not store the entire document in memory, making it a good choice for parsing large XML files
where memory efficiency is important. As the parser reads the document, it triggers events such as
startElement, characters, and endElement. Developers write handlers for these events to
process the XML data. Unlike DOM, SAX is read-only, so you cannot modify the XML structure during
parsing. It’s faster and more memory-efficient, but harder to work with if the application needs
random access to different parts of the XML.

📙 StAX (Streaming API for XML) Parser

The StAX parser is a pull-based parser, which gives more control to the programmer. Instead of
reacting to events (like in SAX), the application explicitly asks the parser to read the next element or
attribute. This makes the code easier to manage compared to SAX and more memory-efficient than
DOM. StAX supports both reading and writing XML streams. It is commonly used in Java and is
suitable for medium to large-sized XML documents where you need a balance between
performance, control, and memory usage. It is ideal for applications that process XML data step by
step.

SAX Parser DOM Parser

It is called a Simple API for XML It is called as Document Object


Parsing. Model.

It’s an event-based parser. It stays in a tree structure.

SAX Parser is slower than DOM DOM Parser is faster than SAX
Parser. Parser.

Best for the larger sizes of files. Best for the smaller size of files.

It is read-only. It can insert or delete nodes.

In the SAX parser backward In DOM parser backward and forward


navigation is not possible. search is possible

Suitable for efficient memory. Suitable for large XML document.


SAX Parser DOM Parser

A small part of the XML file is only It loads whole XML documents in
loaded in memory. memory.

Introduction to CGI (Common Gateway Interface)

CGI stands for Common Gateway Interface. It is a standard protocol used to connect web servers
with external programs (like scripts written in Python, Perl, or C). These programs can generate
dynamic web pages or process user input from HTML forms. When a user submits a form or requests
a webpage, the web server uses CGI to run a script on the server, and the script sends back the result
(usually in HTML). This allows websites to become interactive and dynamic, rather than just
displaying static content.

Why Use CGI?

 To make websites dynamic (i.e., change content based on user input)


 To process forms (e.g., login, feedback)
 To interact with databases, files, or other systems

🧠 How It Works (Simple Steps):

1. User fills a form and clicks submit.


2. The web browser sends the data to the web server.
3. The server runs a CGI script (written in Python, Perl, etc.).
4. The script does some work (e.g., saving info or generating a page).
5. The server sends the result (like an HTML page) back to the user.

Environment Variables in CGI

When a CGI script runs, the web server passes important information to it using environment
variables. These variables include data like:

 REQUEST_METHOD – tells whether the request is GET or POST


 QUERY_STRING – contains data sent through a GET request
 CONTENT_LENGTH – size of the data sent in a POST request
 REMOTE_ADDR – the user's IP address
These variables help the CGI script understand what the user is trying to do and respond
accordingly.

---------------------------------------------- EXPLANATION CGI WORKING---------------------------------------


Scenario: Imagine a very basic webpage with a form that asks for your name. When you
submit the form, a CGI script will greet you by name.

1. The HTML Form (form.html):

HTML
<!DOCTYPE html>
<html>
<head>
<title>Greeting Form</title>
</head>
<body>
<h1>Enter Your Name</h1>
<form action="/cgi-bin/greet.py" method="get">
<label for="name">Name:</label>
<input type="text" id="name" name="name"><br><br>
<input type="submit" value="Submit">
</form>
</body>
</html>

Explanation:

 This is a simple HTML form with one input field named "name" and a submit button.
 The action="/cgi-bin/greet.py" tells the browser to send the form data to the
CGI script located at /cgi-bin/greet.py on the server.
 The method="get" specifies that the form data will be sent as part of the URL (in the
QUERY_STRING).

2. The CGI Script (greet.py - located in the server's cgi-bin directory):

Python
#!/usr/bin/env python3

import os
import cgi

# Print the necessary HTTP headers for a plain text response


print("Content-Type: text/html\n")

# Access the environment variable containing the query string


query_string = os.environ.get("QUERY_STRING")

name = None

# If there's a query string, parse it to get the 'name' value


if query_string:
form_data = cgi.parse_qs(query_string)
if "name" in form_data:
name = form_data["name"][0] # Get the first value of the 'name'
parameter

# Generate the HTML response


print("<!DOCTYPE html>")
print("<html>")
print("<head>")
print("<title>Greeting</title>")
print("</head>")
print("<body>")

if name:
print(f"<h1>Hello, {name}!</h1>")
else:
print("<p>Please enter your name and submit the form.</p>")

print("</body>")
print("</html>")

Explanation of the Python CGI Script:

1. #!/usr/bin/env python3: This is a shebang line, telling the server to execute this
script using the Python 3 interpreter.
2. import os: This line imports the os module, which provides a way to interact with
the operating system, including accessing environment variables.
3. import cgi: This line imports the cgi module, which helps with processing CGI
forms.
4. print("Content-Type: text/html\n"): This is crucial! A CGI script must first
print the Content-Type header to tell the browser what kind of data to expect (in this
case, HTML). The \n creates a blank line, separating the headers from the actual
content.
5. query_string = os.environ.get("QUERY_STRING"): This is where we access the
environment variable named QUERY_STRING. The os.environ dictionary contains
all the environment variables passed by the web server. get("QUERY_STRING")
retrieves the value associated with the key "QUERY_STRING". If the QUERY_STRING
doesn't exist (e.g., if the page was accessed directly without submitting the form),
query_string will be None.
6. form_data = cgi.parse_qs(query_string): If there is a query_string (meaning
the form was submitted using the GET method), the cgi.parse_qs() function parses
it into a dictionary. The keys of the dictionary are the form field names (like "name"),
and the values are lists of the submitted values.
7. if "name" in form_data:: We check if the "name" field was present in the
submitted data.
8. name = form_data["name"][0]: If the "name" field exists, we get its value (the first
value in the list, as a single text input will have only one value).
9. The rest of the script generates the HTML response. If a name was provided in the
query string, it displays a personalized greeting. Otherwise, it prompts the user to
enter their name.

How it Works When You Run It:

1. You open form.html in your web browser.


2. You enter your name (e.g., "Alice") in the text field and click "Submit."
3. Your browser sends a GET request to the server for /cgi-bin/greet.py. The URL
will look something like http://your-server.com/cgi-bin/greet.py?
name=Alice.
4. The web server receives this request. It recognizes that /cgi-bin/greet.py is a CGI
script.
5. The web server executes the greet.py script.
6. Crucially, the web server sets the QUERY_STRING environment variable to
name=Alice before running the script.
7. The Python script reads the QUERY_STRING environment variable using
os.environ.get("QUERY_STRING").
8. The cgi.parse_qs() function parses name=Alice into a dictionary: {'name':
['Alice']}.
9. The script extracts the value "Alice" and generates the HTML output: <h1>Hello,
Alice!</h1>.
10. The script prints the Content-Type: text/html\n header followed by the generated
HTML to standard output.
11. The web server receives this output and sends it back to your browser.
12. Your browser renders the "Hello, Alice!" message.

---------------------------------------------- EXPLANATION CGI WORKING END------------------------------------

GET and POST are two of the most common HTTP methods used by web browsers to
interact with web servers. They define the action the client (browser) wants the server to
perform.

GET:

 Purpose: Primarily used to retrieve data from the server. Think of it as asking the
server for something (a webpage, an image, information).
 Data Transmission: Sends data through the URL parameters (the part after the ? in
the web address). Key-value pairs are appended to the URL.
 Visibility: Data is visible in the URL. www.example.com/search.cgi?name=John
 Security: Less secure for sensitive data (like passwords) as it's visible in the URL and
can be stored in browser history and server logs.
 Data Size: Limited amount of data can be sent due to URL length restrictions.
 Use Cases:
o Requesting a webpage.
o Searching (where the search terms appear in the URL).
o Filtering or sorting data.
o Any request that doesn't modify data on the server.
 Analogy: Asking a librarian for a specific book by its title (the title is like the URL
parameters).

POST:

 Purpose: Primarily used to send data to the server to create or update a resource.
Think of it as submitting information to the server (like filling out a form).
 Data Transmission: Sends data in the body of the HTTP request, which is not visible
in the URL.
 Visibility: Data is not visible in the URL.
 Security: More secure for sensitive data as it's not directly exposed in the URL.
However, it's still crucial to use HTTPS for encryption.
 Data Size: Can send larger amounts of data compared to GET.
 Use Cases:
o Submitting forms (login, registration, contact forms).
o Uploading files.
o Creating new resources on the server (e.g., a new user account).
o Any request that might modify data on the server.
 Analogy: Mailing an application form to an office (the form details are in the
envelope - the request body).

Here's a table summarizing the key differences:

Feature GET POST


Primary Use Retrieve data Send data to create/update resources
Data in URL parameters Request body
Visibility Visible in URL Not visible in URL
More secure for sensitive data (but use
Security Less secure for sensitive data
HTTPS)
Data Size Limited Larger amounts allowed
Caching Can be cached Not typically cached
Browser
Stored in browser history Not stored in browser history
History
Yes (multiple identical requests No (multiple identical requests might
Idempotent
have the same effect) have different effects)
Export to Sheets

In essence, choose GET when you want to get information without changing anything on the
server, and choose POST when you want to send information that might create or modify
data on the server.

🔹 1. Introduction & Syntax of PERL


PERL stands for Practical Extraction and Report Language. It’s a powerful and flexible scripting
language used for text processing, system administration, web development, and data
manipulation.

Basic Syntax:

 PERL files end with .pl


 Statements end with a semicolon ;
 Comments start with #

perl
CopyEdit
print "Hello, World!\n"; # This prints Hello, World!

You can run a Perl script using:


perl filename.pl
🔹 2. Variables in PERL
PERL has 3 main types of variables:

🔸 Scalars ($)

 Store single values (number or string)

perl
CopyEdit
my $name = "Ankan";
my $age = 21;

🔸 Arrays (@)

 Store a list of values

perl
CopyEdit
my @colors = ("red", "green", "blue");
print $colors[0]; # prints red

🔸 Hashes (%)

 Store key-value pairs (like dictionaries)

perl
CopyEdit
my %student = ("name" => "Ankan", "age" => 21);
print $student{"name"}; # prints Ankan

🔹 3. Conditions & Loops


🔸 Conditional Statements:
perl
CopyEdit
if ($age > 18) {
print "Adult\n";
} elsif ($age == 18) {
print "Just turned adult\n";
} else {
print "Minor\n";
}

🔸 Loops:
perl
CopyEdit
# for loop
for (my $i = 0; $i < 5; $i++) {
print "$i\n";
}

# while loop
my $x = 0;
while ($x < 3) {
print "x = $x\n";
$x++;
}

🔹 4. String Operations
PERL is very powerful with strings.

perl
CopyEdit
my $str = "Hello";
my $name = "Ankan";
my $full = $str . " " . $name; # Concatenation
print length($full); # String length

Other string operations: uc(), lc(), substr(), index(), etc.

🔹 5. Regular Expressions (Regex)


Used to match patterns in strings.

perl
CopyEdit
my $text = "I love Perl";

if ($text =~ /Perl/) {
print "Matched!\n";
}

$text =~ s/Perl/Python/; # Replaces Perl with Python

Common symbols:

 . matches any character


 * matches 0 or more
 + matches 1 or more
 \d matches digit
 \w matches word character

🔹 6. File Handling & I/O


Reading from a file:
perl
CopyEdit
open(my $fh, "<", "file.txt") or die "Can't open file!";
while (my $line = <$fh>) {
print $line;
}
close($fh);

Writing to a file:
perl
CopyEdit
open(my $fh, ">", "output.txt");
print $fh "Writing to file\n";
close($fh);

🔹 7. Implementing Basic Data Structures


You can use arrays and hashes to create simple data structures.

Example: Stack using Array


perl
CopyEdit
my @stack;
push(@stack, 1);
push(@stack, 2);
my $top = pop(@stack); # $top = 2

Example: Key-Value Store using Hash


perl
CopyEdit
my %phonebook = ("Ankan" => "12345", "Supriya" => "67890");
print $phonebook{"Ankan"};

✅ Summary:

PERL is easy to learn and useful for many tasks involving text, files, and automation. It supports
strong string handling, regular expressions, and dynamic data types (scalars, arrays, hashes). With
PERL, you can build simple scripts as well as complex programs quickly.

------------------------------------------ MORE ON PERL STRING AND REG EXP-----------------------------------

4. String Operations in PERL


PERL is known for its strong string processing capabilities. Here are some of the most useful string
operations:

✅ 1. Concatenation

Joining strings together using the . operator.

perl
CopyEdit
my $first = "Hello";
my $second = "World";
my $message = $first . " " . $second; # Hello World
print "$message\n";

✅ 2. Length of a String
perl
CopyEdit
my $text = "PERL programming";
my $len = length($text);
print "Length is $len\n"; # Output: Length is 16

✅ 3. Changing Case

 uc($str) → converts to UPPERCASE


 lc($str) → converts to lowercase

perl
CopyEdit
print uc("hello"); # HELLO
print lc("HELLO"); # hello

✅ 4. Substring
perl
CopyEdit
my $data = "Programming";
my $sub = substr($data, 0, 4); # From index 0, take 4 characters
print "$sub\n"; # Prog

✅ 5. Index (Search position)


perl
CopyEdit
my $sentence = "I love Perl";
my $position = index($sentence, "Perl"); # returns 7
print "Found at position $position\n";

✅ 6. Reversing and Repeating


perl
CopyEdit
my $text = "abc";
print reverse($text); # cba

print "Ha" x 3; # HaHaHa

PERL provides dozens of built-in string functions, which makes it ideal for text-processing tasks.
🔹 5. Regular Expressions in PERL
Regular Expressions (Regex) are powerful tools for pattern matching and string manipulation. In
PERL, they are built right into the language.

✅ 1. Pattern Matching
perl
CopyEdit
my $sentence = "I love Perl";

if ($sentence =~ /Perl/) {
print "Yes, it matches!\n";
}

 =~ is the pattern match operator.


 /Perl/ is the pattern.

✅ 2. Substitution (Find & Replace)


perl
CopyEdit
my $text = "I love Perl";
$text =~ s/Perl/Python/; # Replace Perl with Python
print "$text\n"; # Output: I love Python

 s/find/replace/ → used to substitute strings.

✅ 3. Common Metacharacters
Symbol Meaning Example

. Any single character a.b matches acb

* 0 or more of previous char go*gle

+ 1 or more go+gle

? 0 or 1 go?gle

\d Any digit (0–9) \d\d → 2 digits

\w Word character (A–Z, 0–9, _) \w+

^ Start of line ^Hi matches start

$ End of line end$ matches end


✅ 4. Example: Extracting Data
perl
CopyEdit
my $email = "[email protected]";
if ($email =~ /(.+)@(.+)/) {
print "Username: $1\n"; # ankan
print "Domain: $2\n"; # example.com
}

$1, $2 etc., are capture groups from matched text.

✅ 5. Regex Flags
Flag Purpose

i Case-insensitive matching

g Global (match all, not just first)


perl
CopyEdit
my $text = "Perl is perl";
$text =~ s/perl/Python/gi;
print "$text\n"; # Python is Python

✅ Summary of String Ops & Regex:

 Strings in PERL can be manipulated with built-in functions like length(), substr(), uc(),
etc.
 Regex allows pattern matching, substitution, validation (e.g., email format), and data
extraction.
 PERL's integration of regex makes it perfect for text-heavy tasks like log file parsing, web
scraping, and form validation.

------------------------------------- MORE ON PERL STRING AND REG EXP END---------------------------------

1. JavaScript Basics: Statements, Comments, Variables


JavaScript is a lightweight scripting language used to make web pages interactive. A statement in
JavaScript is an instruction to the browser to do something. Examples include variable declarations,
loops, function calls, etc. Statements usually end with a semicolon (;), although it's optional in many
cases.

Comments in JavaScript are used to explain the code and are ignored during execution. Single-line
comments use // and multi-line comments are written with /* ... */.

Variables in JavaScript are used to store data. You can declare them using var, let, or const. let
and const are block-scoped and modern, while var is function-scoped and older. let is used for
variables that may change, and const is for constants.
Example:

js
CopyEdit
let name = "Ankan";
const pi = 3.14;
Feature var let
Feature Function scope Block scope
Feature Hoisted (to undefined) Hoisted (but in TDZ)
Feature Allowed Not allowed (in same scope)
Creates properties on
Global Scope (outside functions) window Doesn't create global properties

2. Flow Control: Condition, Switch, Loops, Break


JavaScript provides several flow control mechanisms. The if-else statement checks conditions and
runs code based on whether they are true or false.

js
CopyEdit
if (age > 18) {
console.log("Adult");
} else {
console.log("Minor");
}

The switch statement is used for multiple condition checks more efficiently than many if-else
statements.

js
CopyEdit
switch (day) {
case 1: console.log("Monday"); break;
case 2: console.log("Tuesday"); break;
default: console.log("Other Day");
}

Loops such as for, while, and do-while allow repeating tasks. The break statement exits a loop
early, and continue skips to the next iteration.

JavaScript Loops Explained


Loops are used when you want to repeat a task multiple times — like printing numbers, checking
values in a list, or asking a question until the answer is correct.

1. for Loop

This is used when you know how many times you want to repeat.

javascript
CopyEdit
for (let i = 0; i < 5; i++) {
console.log(i); // prints 0 to 4
}

 let i = 0: Start from 0


 i < 5: Keep going while i is less than 5
 i++: Increase i by 1 each time

✅ Good for counting, looping through arrays, etc.

2. while Loop

This is used when you don’t know how many times you need to repeat, and the loop continues as
long as the condition is true.

javascript
CopyEdit
let i = 0;
while (i < 5) {
console.log(i);
i++;
}

It checks the condition before running the code block.

3. do-while Loop

Same as while, but it runs at least once, even if the condition is false — because it checks the
condition after running the code block.

javascript
CopyEdit
let i = 0;
do {
console.log(i);
i++;
} while (i < 5);

✅ Use when the code should run at least one time.

⏹️break and continue

🔹 break

Used to exit the loop early, even if the condition is still true.
javascript
CopyEdit
for (let i = 0; i < 10; i++) {
if (i === 5) break;
console.log(i); // prints 0 to 4
}

🔹 continue

Used to skip the current loop and move to the next iteration.

javascript
CopyEdit
for (let i = 0; i < 5; i++) {
if (i === 2) continue;
console.log(i); // prints 0, 1, 3, 4
}

When i === 2, it skips the console.log() and jumps to the next loop.

🔹 3. Objects: String, Array, Boolean, RegExp


JavaScript has built-in objects for handling different types of data.

 String: Used for text.

js
CopyEdit
let msg = "Hello";
console.log(msg.length); // 5

 Array: Stores multiple values in a single variable.

js
CopyEdit
let fruits = ["apple", "banana"];
console.log(fruits[0]); // apple

 Boolean: Holds either true or false.

js
CopyEdit
let isActive = true;

 RegExp (Regular Expressions): Used to search or match patterns in strings.

js
CopyEdit
let pattern = /abc/;
console.log(pattern.test("abcdef")); // true
These objects help handle various data formats and operations easily.

🔹 4. Functions & Error Handling


Functions are blocks of code that perform a task and can be reused. You define a function using the
function keyword.

js
CopyEdit
function greet(name) {
return "Hello " + name;
}
console.log(greet("Ankan")); // Hello Ankan

JavaScript also supports anonymous and arrow functions.

Error Handling in JavaScript is done using try-catch-finally. This prevents your program from
crashing and lets you handle unexpected behavior.

js
CopyEdit
try {
let x = y + 1; // y is undefined
} catch (error) {
console.log("An error occurred: " + error);
} finally {
console.log("Always runs");
}

🔹 5. Form Validation
Form validation is used to ensure the user has entered valid data before submitting a form. JavaScript
can validate things like required fields, valid email format, password length, etc.

Example:

js
CopyEdit
function validateForm() {
let email = document.forms["myForm"]["email"].value;
if (email == "") {
alert("Email must be filled out");
return false;
}
}

This improves user experience and protects the server from invalid inputs.
🔍 Explanation step-by-step:

1. document
Refers to the HTML document (webpage) itself.
2. document.forms
Refers to all the <form> elements on the page. It behaves like an array or object that holds
all forms.
3. document.forms["myForm"]
This accesses the form with the name="myForm".
4. ["email"]
Inside that form, this accesses the input field with the name="email".
5. .value
This gets the actual text/value entered by the user in the email input field.

✍️Example HTML Form


html
CopyEdit
<form name="myForm" onsubmit="return validateForm()">
Name: <input type="text" name="username"><br>
Email: <input type="text" name="email"><br>
Age: <input type="text" name="age"><br>
<input type="submit" value="Submit">
</form>

💡 JavaScript Validation Function


javascript
CopyEdit
function validateForm() {
let name = document.forms["myForm"]["username"].value;
let email = document.forms["myForm"]["email"].value;
let age = document.forms["myForm"]["age"].value;

// Check empty name


if (name === "") {
alert("Name must be filled out");
return false;
}

// Check valid email using regex


let emailPattern = /^[^ ]+@[^ ]+\.[a-z]{2,3}$/;
if (!email.match(emailPattern)) {
alert("Please enter a valid email address");
return false;
}

// Check age is a number and between 1-120


if (isNaN(age) || age < 1 || age > 120) {
alert("Please enter a valid age between 1 and 120");
return false;
}

return true; // All good!


}

📋 What We Validated:
Field Validation Rules

Name Must not be empty

Email Must match standard email format using RegEx

Age Must be a number between 1 and 120

✅ Summary
 JavaScript controls how the webpage behaves.
 You use variables and statements to build logic.
 Control flow manages decisions and repetition.
 Built-in objects simplify tasks like working with strings and arrays.
 Functions organize your code, and error handling makes it safer.
 Form validation ensures good user input before submission.

🍪 What are Cookies?


Cookies are small pieces of data (text files) stored on a user’s computer by a website. They are used
to remember information between sessions.

🎯 Purpose of Cookies
 To store user preferences (e.g., language or theme)
 To keep users logged in (session management)
 To track user activity (analytics, ads, shopping carts)
 To personalize the user experience

✍️How Cookies Work


1. Website sends a cookie to the browser.
2. Browser stores it and sends it back with future requests to the same website.
3. Server reads the cookie to retrieve data about the user.

Cookies are small text files that websites store on a user’s browser to remember
information about that user. The main purpose of cookies is to keep track of user data
across sessions, such as login status, preferences, or activity. For example, when you log
into a website and check "Remember Me," a cookie is stored to keep you logged in even
after closing the browser.

In JavaScript, cookies are created using the document.cookie property. A cookie can be
set like this: document.cookie = "username=Ankan; expires=Fri, 30 Dec 2025
12:00:00 UTC; path=/", which sets a cookie with a name username and value Ankan.
You can retrieve all cookies available to the current page using document.cookie, which
returns a string of key-value pairs. If multiple cookies exist, they will be separated by
semicolons in that string.

To delete a cookie, you set its expiration date to a past time. For example,
document.cookie = "username=; expires=Thu, 01 Jan 1970 00:00:00 UTC;
path=/" will remove the username cookie.

Cookies play a crucial role in personalizing user experience and maintaining session data
without requiring the user to re-enter information every time. However, since cookies are
stored on the client side, they should not be used to store sensitive data unless properly
secured using flags like Secure and HttpOnly. Cookies are domain-specific, meaning
only the website that created them can read them, and they have a size limit of around
4KB each.

Java Applets – Overview

Java Applets are small Java programs that run inside a web browser or an applet viewer. Unlike
regular Java applications, applets do not need a main() method to start execution. Instead, they rely
on specific lifecycle methods that are automatically invoked by the browser or the JVM. Applets are
mostly used for creating interactive web-based user interfaces.

🧱 Container Class & GUI Components

Applets are built using container classes like Applet, JApplet (from Swing), or Panel. These
classes allow you to add GUI components such as buttons, labels, text fields, checkboxes, and more.
These components come from the Abstract Window Toolkit (AWT) or Swing libraries. You can use
layout managers to arrange them properly on the applet screen.

update() Method

The update(Graphics g) method is used for refreshing the applet’s display. It is automatically
called before paint() to clear the screen. However, if you override paint() directly, you don’t
usually need update(). You can use repaint() to call update() and then paint() to redraw the
applet.

Java Applet Life Cycle


The below diagram demonstrates the life cycle of Java Applet:
It is important to understand the order in which the various methods
shown in the above image are called.
 When an applet begins, the following methods are called, in this
sequence:
o init( )
o start( )
o paint( )
 When an applet is terminated, the following sequence of method calls
takes place:
o stop( )
o destroy( )
Let’s look more closely at these methods.
1. init( ): The init( ) method is the first method to be called. This is where
you should initialize variables. This method is called only once during the
run time of your applet.
2. start( ): The start( ) method is called after init( ). It is also called to
restart an applet after it has been stopped.
Note: init( ) is called once i.e. when the first time an applet is loaded
whereas start( ) is called each time an applet’s HTML document is
displayed onscreen. So, if a user leaves a web page and comes back, the
applet resumes execution at start( )
3. paint( ): The paint( ) method is called each time an AWT-based applet’s
output must be redrawn. This situation can occur for several reasons. For
example, the window in which the applet is running may be overwritten by
another window and then uncovered. Or the applet window may be
minimized and then restored.
 paint( ) is also called when the applet begins execution. Whatever the
cause, whenever the applet must redraw its output, paint( ) is called.
 The paint( ) method has one parameter of type Graphics. This
parameter will contain the graphics context, which describes the
graphics environment in which the applet is running. This context is
used whenever output to the applet is required.
 paint() is the only method among all the methods mention above
(which is parameterized).
This method is crucial for updating or redrawing the visual content of the
applet.
Example:
public void paint(Graphics g)
{
// Drawing a string on the applet window
// g is an object reference of class Graphic.
g.drawString("Hello, Applet!", 50, 50);
}
Now the below Question Arises:
In the prototype of paint() method, we have created an object reference
without creating its object. But how is it possible to create object reference
without creating its object?
Ans. Whenever we pass object reference in arguments then the object
will be provided by its caller itself. In this case the caller of paint() method
is browser, so it will provide an object. The same thing happens when we
create a very basic program in normal Java programs. For Example:
public static void main(String []args) {
}
Here we have created an object reference without creating its object but it
still runs because it’s caller, i.e. JVM will provide it with an object.
4. stop( ): The stop( ) method is called when a web browser leaves the
HTML document containing the applet, when it goes to another page.
For example: When stop( ) is called, the applet is probably running. You
should use stop( ) to suspend threads that don’t need to run when the
applet is not visible. You can restart them when start( ) is called if the user
returns to the page.
5. destroy( ): The destroy( ) method is called when the environment
determines that your applet needs to be removed completely from
memory. At this point, you should free up any resources the applet may be
using. The stop( ) method is always called before destroy( ).
Applet Applications

Applets can be used in applications like online forms, calculators, educational tools, simple games,
or interactive graphics on websites. However, due to security restrictions and lack of modern
browser support, applets are now mostly outdated and replaced by modern technologies like
JavaScript and HTML5.

*** imp ques*** Parameter Passing in Java Applets (With Example)

In Java Applets, parameters can be passed from an HTML page using the <param> tag. These
parameters allow you to send dynamic values to the applet at runtime. The applet can access these
parameters using the getParameter(String name) method.

Example:

HTML code to pass parameters:

html
CopyEdit
<applet code="MyApplet.class" width="300" height="200">
<param name="username" value="Ankan">
<param name="age" value="22">
</applet>

Java Applet code to receive parameters:

java
CopyEdit
import java.applet.*;
import java.awt.*;

public class MyApplet extends Applet {


String user;
int age;

public void init() {


user = getParameter("username");
age = Integer.parseInt(getParameter("age"));
}

public void paint(Graphics g) {


g.drawString("Name: " + user, 20, 50);
g.drawString("Age: " + age, 20, 70);
}
}
Explanation:

 The <param> tag in HTML passes values to the applet.


 getParameter() is used in the init() method to fetch those values.
 The applet displays the name and age using drawString().

What is TCP? (Transmission Control Protocol)

Imagine you're sending a very important document by mail and you need to be absolutely
sure it arrives correctly. TCP is like using a registered mail service with delivery
confirmation. Here's how it works:

 Connection-Oriented: Before sending any data, TCP establishes a dedicated


"connection" between the sender and the receiver (like making a phone call first).
 Reliable: TCP guarantees that all the data you send will arrive at the destination, in
the correct order, and without errors. If any data is lost or corrupted along the way,
TCP will detect it and retransmit it until it arrives correctly.
 Ordered Delivery: If you send multiple pieces of data, TCP ensures they arrive in the
same order you sent them. It numbers each piece and reassembles them at the
destination.
 Error Checking: TCP includes mechanisms to detect and correct errors that might
occur during transmission.
 Flow Control: TCP manages the rate of data transmission to prevent the sender from
overwhelming the receiver.

What is UDP? (User Datagram Protocol)

Now, imagine sending a postcard. You write your message, put it in the mail, but you don't
get any confirmation of delivery. UDP is similar to this:

 Connectionless: UDP doesn't establish a connection before sending data. It just sends
the data packets out.
 Unreliable: There's no guarantee that the data will arrive at the destination. Packets
might get lost, duplicated, or arrive out of order. UDP doesn't have built-in
mechanisms for error recovery or retransmission.
 Faster: Because UDP doesn't have the overhead of establishing connections, tracking
packets, and ensuring reliability, it's generally faster than TCP.
 Simple: UDP is a much simpler protocol with a smaller header (less extra information
added to the data).

Applications of TCP:

Because of its reliability, TCP is used for applications where data integrity is crucial:
 Web Browsing (HTTP/HTTPS): When you visit a website, TCP ensures that all the
text, images, and other files are downloaded correctly.
 Email (SMTP, POP3, IMAP): TCP guarantees that your emails are sent and
received completely.
 File Transfer (FTP, SFTP): When you upload or download files, TCP ensures that
the files are transferred without any data loss.
 Secure Shell (SSH): For secure remote access to systems, TCP provides a reliable
connection.
 Databases: Many database systems use TCP for reliable communication between
clients and the server.

Applications of UDP:

Because of its speed and lower overhead, UDP is often used for applications where
occasional data loss is acceptable or where speed is more critical than perfect reliability:

 Online Gaming: Real-time games often use UDP for transmitting player movements
and game states because low latency (delay) is crucial. Losing a few packets might
cause a minor visual glitch but is better than a laggy game.
 Voice over IP (VoIP) and Video Conferencing: Applications like Skype, Zoom,
etc., often use UDP for transmitting audio and video data. Some packet loss might
result in brief audio/video artifacts, but it's preferable to delays caused by
retransmissions.
 Streaming Media: Live video and audio streaming often use UDP to maintain a
continuous flow of data. Buffering can handle minor data loss.
 DNS (Domain Name System): When your computer looks up the IP address of a
website, it often uses UDP for quick queries.
 Network Monitoring (SNMP): Simple Network Management Protocol often uses
UDP for sending and receiving management information.

TCP (Transmission Control


Feature Protocol) UDP (User Datagram Protocol)
Connection Connection-oriented Connectionless
Reliability Reliable (guaranteed delivery) Unreliable (no delivery guarantee)
Ordering Guarantees ordered delivery No guarantee of order
Error
Checking Yes Basic checksum
Flow Control Yes No
Speed Slower (due to overhead) Faster (lower overhead)
Web, Email, File Transfer, SSH, Online Gaming, VoIP, Streaming, DNS, Network
Use Cases Databases Monitoring
What is a Java Socket?
A Java socket is like a virtual "phone line" that allows two computers to communicate
over a network. It's one of the fundamental tools for network programming in Java,
enabling programs to send and receive data between machines.{ For establishing a
stable fixed communation between two programs(serverSocket and clintSocket) for
realtime or bidirectional data transfer.}
So, what is a Socket?
A socket in Java is a connection point between two programs running on a network.
One side creates a server socket (like a shopkeeper waiting for customers).
The other side creates a client socket (like a customer reaching the shop).
Once connected, they can send and receive data like a phone call.
Java provides two main socket classes:
Socket – Used by the client to connect to a server.
ServerSocket – Used by the server to wait and accept connections from clients.
🧱 Example Scenario:
Imagine a chat app:
The server runs with a ServerSocket and waits.
The client runs with a Socket, connects to the server.
They exchange messages back and forth (like texting).
Server Code:
ServerSocket serverSocket = new ServerSocket(1234); // Server listens on port 1234
Socket socket = serverSocket.accept(); // Waits for client to connect
Client Code:
Socket socket = new Socket("localhost", 1234); // Connects to server on port 1234
After this, both can send and receive data using InputStream and OutputStream.
📦 Real-World Uses:
Chat apps (WhatsApp, Messenger backend)
Online games
File sharing tools
Remote access software

RMI Architecture (Remote Method Invocation)

RMI (Remote Method Invocation) is a Java technology that allows a program running on one Java
Virtual Machine (JVM) to invoke methods on an object located in another JVM over a network. It’s
used to build distributed applications in Java.

✅ Main Components of RMI Architecture:

1. Client
o The part of the application that wants to call a method on a remote object.
o It uses the stub to communicate with the remote object.
2. Server (Remote Object)
o The remote object whose method is being called.
o It implements a remote interface and is hosted on the server machine.
3. Stub
o A client-side proxy for the remote object.
oIt hides network communication from the client.
oWhen a method is called, it passes the request to the skeleton via the RMI system.
4. Skeleton (in older versions)
o A server-side helper that receives the request from the stub, calls the actual method
on the remote object, and sends the response back.
5. RMI Registry
o A service that allows clients to look up remote objects using a name.
o Acts like a phone book where remote objects are registered.
6. Transport Layer
o Handles network-level communication between client and server.
o Based on TCP/IP.

🔁 How RMI Works (Step-by-Step):

1. Server creates a remote object and registers it with the RMI registry.
2. Client looks up the remote object in the registry using its name.
3. The client uses the stub to call a method.
4. The stub forwards the call to the skeleton on the server.
5. The skeleton invokes the actual method and sends the result back.
6. The stub receives the result and gives it to the client program.

RMI Architecture (Remote Method Invocation) – Full


Explanation
RMI (Remote Method Invocation) allows Java programs to call methods on remote Java objects as if
they were local. It's Java's way of doing distributed computing.

The RMI system is divided into three main layers:

✅ 1. Application Layer

This is where the client and server code lives.

 Client: A Java program that wants to use a remote service (like calling a method on an object
in another machine).
 Server: Hosts the remote object (service) and registers it with the RMI Registry.

✅ 2. RMI Runtime Layer

This is the core part of RMI that handles communication.

It has two important components:


a) Stub and Skeleton

 Stub: The client-side proxy for the remote object. It looks like the real object to the client.
 Skeleton: (Used in Java versions < 1.2) on the server side, it receives requests from the stub
and passes them to the actual object.

In newer Java versions, the skeleton is no longer required, and dynamic proxies are used.

b) Remote Reference Layer (RRL)

 It handles object references across the network.


 It manages creating, tracking, and deleting references to remote objects.
 Ensures the call goes to the correct object on the server.

✅ 3. Transport Layer

This is the lowest layer and handles actual communication over the network using TCP/IP.

 It is responsible for setting up connections, sending requests, and returning responses.


 Ensures that the data is transferred reliably and in order.

🔁 How RMI Works – Step-by-Step


1. Server Side Setup
o The server creates a remote object by implementing a remote interface.
o It binds this object to the RMI Registry using a name.
2. Client Side Lookup
o The client uses Naming.lookup("rmi://...") to find the remote object in the
registry.
o The client gets a stub (proxy) of the remote object.
3. Method Call
o The client calls a method on the stub.
o The stub marshals (packs) method parameters and sends the request to the server.
4. Remote Reference Layer & Transport
o The Remote Reference Layer (RRL) ensures the request goes to the right remote
object.
o The Transport Layer sends the request over the network.
5. Server Execution
o The server receives the request.
o The skeleton or dynamic proxy unmarshals (unpacks) the request.
o The real method on the remote object is executed.
6. Response Returned
o The result is sent back via the same layers: Skeleton → RRL → Transport → Stub.
o The client receives the result as if it came from a local object.
🧠 Real-World Analogy:

Think of RMI like ordering food via a delivery app:

 The client is you.


 The remote object is the restaurant.
 The stub is the app interface.
 The RRL is the system keeping track of which restaurant serves what.
 The transport layer is the delivery guy.
 You get the food (result) without knowing the full process.

What is JNI (Java Native Interface)?


JNI is a bridge between Java code and native code (like C or C++).

🧠 Sometimes, Java alone is not enough. You may want to:

 Use some existing C/C++ libraries


 Access hardware or OS-level features
 Improve performance

That’s where JNI helps. It lets Java and C/C++ talk to each other.
🎯 Real-Life Example:
Imagine Java is a person who speaks only Hindi, and C is a person who speaks only Bengali.
To work together, they need a translator — that translator is JNI.

🧱 Components of JNI Architecture


1. Java Code

Your normal Java program — it calls a native method using native keyword.

java
CopyEdit
public class HelloJNI {
public native void sayHello(); // Native method
static {
System.loadLibrary("hello"); // Loads the native library (hello.dll
/ hello.so)
}

public static void main(String[] args) {


new HelloJNI().sayHello(); // Calls native method
}
}

2. JNI (Java Native Interface)

This is the translator/bridge that connects Java and C/C++.


It defines how Java can call native code and receive data from it.

3. Native Code (C/C++)

This is the code written in another language (like C) that will do the actual work.

c
CopyEdit
#include <jni.h>
#include <stdio.h>
#include "HelloJNI.h"

JNIEXPORT void JNICALL Java_HelloJNI_sayHello(JNIEnv *env, jobject obj) {


printf("Hello from C code!\n");
}

4. Header File (.h)

This is an auto-generated file by Java that tells C how to name and call the function.
You generate it using:

bash
CopyEdit
javac HelloJNI.java
javah HelloJNI // (Old method; now use javac -h . HelloJNI.java)

It creates HelloJNI.h, which contains the function signature.

5. Shared Library / DLL

Once you compile your C code, it becomes a shared library:

 .dll (on Windows)


 .so (on Linux)
 .dylib (on Mac)

Java loads this library using System.loadLibrary("hello").

🧩 Flow of Execution
Let’s understand the step-by-step flow:

sql
CopyEdit
[Java Code] →
calls → [Native Method]

JNI translates the call

[Native C/C++ Code] runs and returns result

JNI brings result back

[Java Code continues...]

📦 Structure Summary
Component Role

Java Class Calls native method using native keyword

Header File (.h) Auto-generated interface for C/C++

C/C++ Code Implements the logic

JNI Acts as a bridge/translator

Shared Library (.dll/.so) Compiled native code loaded into Java


🛠️Advantages of JNI
 Reuse existing C/C++ code
 Access hardware or OS-level functions
 Boost performance in critical sections

Java Native Interface (JNI) is a framework that allows Java code to interact with native
applications or libraries written in languages like C or C++. Sometimes, Java alone isn't
enough—for example, when you need to access low-level system resources, use legacy C/C+
+ code, or boost performance for critical tasks. JNI acts like a bridge that lets Java and native
code "talk" to each other. The architecture involves several components working together.
First, a Java program declares a native method using the native keyword and loads the
corresponding native library using System.loadLibrary("name"). Then, a header file (.h)
is generated from the Java class, which provides the structure needed for the native code.
Next, you write the native method’s implementation in C or C++ using that header file and
the JNI library, which contains special functions to interact with Java data and objects. After
compiling the C/C++ code, it becomes a shared library file (.dll for Windows, .so for
Linux), which Java can load and use at runtime. When the Java program runs and calls the
native method, the call goes through the JNI layer to reach the native code, and any results
are passed back to Java through the same interface. JNI allows the integration of native
capabilities within Java applications but adds complexity and reduces portability since the
native code is platform-dependent. Still, it's a powerful tool when used wisely.

🦠 Virus – Short Note (5 Marks)

A virus is a type of malicious software (malware) that is designed to spread from one file to another
and from one computer to another. It attaches itself to executable files or documents and becomes
active only when the infected file is run. Once activated, a virus can delete files, corrupt programs,
or slow down the system.
Viruses usually need some user interaction, like opening a file or running a program. They can spread
through email attachments, USB drives, websites, or file downloads. Antivirus software is used to
detect and remove viruses.

Example: A virus-infected MS Word file that corrupts your documents when opened.

🪱 Worm – Short Note (5 Marks)

A worm is another form of malware, but unlike a virus, it can replicate and spread on its own
without any user action. Worms usually spread through network connections by exploiting security
flaws. They do not need to attach themselves to files or programs to function.

Worms consume a large amount of network bandwidth and system memory, often slowing down or
crashing systems and networks. Although not always harmful to files, their rapid spreading makes
them dangerous.

Example: The “ILOVEYOU” worm spread via email and caused billions in damage.

🧱 Trojan Horse – Short Note (5 Marks)

A Trojan Horse (or simply Trojan) is a type of malicious program that pretends to be legitimate
software but actually performs harmful activities. Unlike viruses and worms, Trojans do not replicate
or spread by themselves. Instead, they trick users into installing them, thinking they are useful
software.

Once installed, a Trojan can steal data, monitor user activity, open a backdoor for hackers, or delete
files. They are often used for spying, data theft, or remote control of a device.

Example: A fake antivirus program that actually steals your passwords.

👂 Eavesdropping – Short Note (5 Marks)

Eavesdropping is a passive attack where an unauthorized person secretly listens to or monitors


private communications like phone calls, emails, or data being transmitted over a network. The
attacker does not change the data but steals sensitive information, such as passwords, credit card
numbers, or personal messages.

Eavesdropping often happens on unsecured networks (like public Wi-Fi) and can be prevented using
encryption (SSL, HTTPS) and secure communication channels.

Example: A hacker listens to the conversation between a user and a bank's website to steal login
credentials.
🎭 Spoofing – Short Note (5 Marks)

Spoofing is when an attacker pretends to be someone else to trick a system or user. It involves faking
data such as IP addresses, email addresses, or websites to gain unauthorized access or steal
information.

The attacker uses spoofing to bypass security checks and impersonate trusted sources. This can lead
to phishing attacks or unauthorized system access.

Example: An attacker sends an email that looks like it came from a trusted friend or company (like a
bank) asking for your personal information.

📝 Data Modification – Short Note (5 Marks)

Data Modification is an active attack where an unauthorized person changes, deletes, or tampers
with data during transmission. The goal is to corrupt the message, mislead the receiver, or damage
the integrity of the data.

This type of attack can cause wrong decisions, loss of money, or security failures. It is a serious threat
to data reliability.

Example: An attacker intercepts and modifies a bank transfer amount before it reaches the server.

💥 Denial of Service (DoS) – Short Note (5 Marks)

A Denial of Service (DoS) attack is when a hacker overloads a server or network with fake requests
so that the legitimate users can't access it. The system becomes slow, crashes, or becomes
completely unavailable.

DoS attacks do not steal data, but they cause major disruption to businesses, websites, and services.
A more advanced version is DDoS (Distributed Denial of Service), which uses multiple computers.

Example: A website becomes unreachable because it's flooded with millions of fake visits.

🔐 Active and Passive Attacks – 10 Marks

In network security, attacks are actions taken by intruders to gain unauthorized access, damage, or
disrupt communication and data. These attacks are mainly classified into two types: Active Attacks
and Passive Attacks.
🛡️1. Passive Attack

A Passive Attack is when the attacker silently monitors or eavesdrops on data being transmitted over
the network without altering or affecting it. The main goal is to gather information such as login
credentials, personal messages, or confidential files without being detected.

Passive attacks are harder to detect because they do not cause any direct damage or noticeable
changes in the network.

🔸 Examples of Passive Attacks:

 Eavesdropping (Sniffing): Monitoring network traffic to capture sensitive information like


usernames and passwords.
 Traffic Analysis: Observing the pattern, size, and frequency of data to infer useful
information, even if the content is encrypted.

🔒 How to Prevent:

 Use encryption like SSL/TLS.


 Implement secure protocols (HTTPS, VPN).
 Use firewalls and intrusion detection systems.

⚔️2. Active Attack

An Active Attack is when the attacker tries to modify, delete, or insert data into the network or
system. The goal is to disrupt operations, gain access, or mislead users. These attacks are easier to
detect because they cause visible damage or interruption.

🔸 Examples of Active Attacks:

 Masquerading (Spoofing): Pretending to be a legitimate user to gain access.


 Denial of Service (DoS): Flooding a server with fake traffic to make it unavailable to real
users.
 Replay Attack: Reusing captured data packets to trick the system.
 Data Modification: Changing the contents of a message during transmission.

🔒 How to Prevent:

 Use authentication techniques.


 Implement data integrity checks.
 Monitor networks with IDS/IPS tools.
 Regularly update firewalls and security patches.

Passwords and Authentication

Passwords and Authentication are the first line of defense in network security.
 Password: A secret word or phrase used to verify identity. Strong passwords are a mix of
letters, numbers, and symbols.
 Authentication: The process of verifying that a user is who they claim to be.
Common methods include:
 Single-factor authentication (SFA): Uses just a password.
 Two-factor authentication (2FA): Combines password + another method (like OTP or
fingerprint).
 Multi-factor authentication (MFA): Uses more than two methods for stronger security.

Passwords and Authentication: A Short Note (10 Marks)


Authentication is the process of verifying the identity of a user, device, or application.
Passwords, a sequence of characters chosen by the user, are a common credential used in this
process. When a user attempts to access a system, they provide their username and password.
The system then compares the entered password with the stored, securely managed version
associated with that username. Successful matching grants access, confirming the user is who
they claim to be.
However, storing passwords in their original, plain-text form is extremely dangerous. If a
system is compromised, these passwords would be readily available to attackers. Therefore,
modern systems employ cryptographic hashing to securely store passwords. Hashing is a
one-way function that transforms a password into a fixed-size string of seemingly random
characters (the hash). Even if an attacker obtains the password hashes, it is computationally
infeasible to reverse the process and retrieve the original passwords.
To further enhance security, salting is often used in conjunction with hashing. A salt is a
unique, randomly generated string added to each password before it is hashed. This prevents
attackers from using pre-computed tables of common password hashes (rainbow tables) to
crack multiple accounts even if they have the same password. Each password, even if
identical to others, will have a unique salt and thus a unique hash.
Beyond basic password authentication, multi-factor authentication (MFA) significantly
strengthens security. MFA requires users to provide two or more verification factors from
different categories (something you know - password/PIN, something you have -
phone/security token, something you are - biometric data). This makes it much harder for
attackers to gain unauthorized access, even if they manage to compromise one factor like a
password.
In summary, secure password management and robust authentication mechanisms are crucial
for protecting user accounts and sensitive data. This involves employing strong hashing
algorithms, using unique salts for each password, and ideally implementing multi-factor
authentication to provide layered security against various attack vectors. The goal is to make
it computationally expensive and practically infeasible for unauthorized individuals to gain
access, even if password databases are compromised.
Sources and related content

🔒 Importance: Prevents unauthorized access and protects sensitive information.


What Is a VPN
A VPN (Virtual Private Network) is a technology that creates a secure,
encrypted connection between your device and the internet. It essentially
acts as a private tunnel for your internet traffic, preventing hackers, ISPs,
and even governments from monitoring your activities. When using a
VPN, your IP address is masked, and your online actions are routed
through a remote server, making it harder to track your online activity.
Key Benefits of Using a VPN:
1. Privacy Protection: A VPN hides your IP address, ensuring that your
browsing habits and activities remain private.
2. Security on Public Networks: Public Wi-Fi networks are often
insecure, but a VPN encrypts your connection, making it safer to
browse the internet on networks like those in cafes or airports.
3. Bypass Geo-restrictions: A VPN allows you to access content that
may be blocked in certain regions (such as streaming platforms, social
media sites, etc.).
4. Prevent Data Throttling: Some ISPs throttle your connection speed
when you stream or play games. A VPN can bypass this, allowing for
faster internet speeds.
5. Accessing Remote Work Resources: A VPN enables secure access
to private networks, making it ideal for businesses and remote workers.
How Does a VPN Work
A VPN works by creating an encrypted tunnel between your device and a
remote server. Here's the process simplified:
1. Connection Establishment: When you activate a VPN on your
device, it connects to a server operated by the VPN provider.
2. Encryption: The VPN encrypts your data (information, files, web
traffic) so that it’s unreadable to anyone trying to intercept it, whether
it's a hacker on the same Wi-Fi network or an entity trying to monitor
your browsing.
3. Traffic Redirection: Your device’s internet traffic is routed through the
VPN server, which can be located in any country. This makes it appear
as though you’re browsing from the server’s location, masking your
actual IP address.
4. Decryption: Once your data reaches the VPN server, it is decrypted
and sent to the destination (such as a website, app, or service). Any
response from the server is then sent back to you through the
encrypted tunnel.
This end-to-end encryption ensures that your sensitive data stays
private and your location remains anonymous.
Types of VPN
VPNs come in various types, each catering to different needs, from
individual privacy to enterprise-level solutions. Below are the main types
of VPNs:
1. Remote Access VPN
A Remote Access VPN allows individual users to connect to a network
remotely, such as accessing work files from home. It's ideal for people
who need secure access to a private network from anywhere.
2. Site-to-Site VPN
A Site-to-Site VPN is used to connect two networks, often used by
businesses with multiple office locations. It securely links two private
networks over the internet, enabling employees to access resources from
both locations.
3. Mobile VPN
A Mobile VPN is designed for mobile devices like smartphones and
tablets. It ensures stable connections even when switching between
different networks (such as from Wi-Fi to mobile data) and is used in
industries like healthcare and logistics where users need continuous
access while moving.

1. IPSec (Internet Protocol Security)


🔍 What is IPSec?

IPSec is a set of protocols that secure data as it travels over an IP network (like the internet).
It provides confidentiality, integrity, and authentication for data sent over the network.

Think of IPSec as a security guard for your internet data.

🔐 Key Features:

 Encrypts data so that only authorized people can read it.


 Checks for tampering to make sure data wasn’t changed.
 Confirms identity of sender and receiver.

🛠️Two Main Modes:

1. Transport Mode – Protects just the data (payload).


2. Tunnel Mode – Protects both data and header (used in VPNs).
IPSec Modes – Think of it Like Sending a Letter
Imagine you are sending a secret letter to your friend.

There are two ways you can send it:

✅ 1. Transport Mode – "Just Seal the Letter"

📬 You write a letter and just seal the contents inside the envelope.
But on the outside of the envelope, you still write:

 To: Your friend’s address


 From: Your address

So, the postman can see the addresses, but can’t read the message inside.

✅ In IPSec terms:

 Only the message inside (the data/payload) is encrypted.


 The IP header (address info) is visible.
 Used when two computers are talking directly to each other (end-to-end).

🎯 Use Case: Two computers in the same company securely exchanging data.

✅ 2. Tunnel Mode – "Put the Whole Letter in a Bigger Envelope"

📦 Now imagine you:

 Take the whole sealed letter (including its envelope),


 Put it into a bigger envelope,
 And write new fake addresses on the outer envelope.

So now, the postman can't even see who the real sender and receiver are. It’s all hidden.

✅ In IPSec terms:

 The entire IP packet (message + original address) is hidden inside another packet.
 A new IP header is added on top.
 Used when a computer or network connects to another network securely (like VPNs).

🎯 Use Case: A remote employee connecting to their office network using a VPN.
📚 Components of IPSec:

 AH (Authentication Header) – Ensures data integrity & origin.


 ESP (Encapsulating Security Payload) – Encrypts and optionally authenticates data.

🌍 Where is it used?

 VPNs (Virtual Private Networks)


 Secure remote connections
 Protecting data between two computers or networks

🔑 Benefits:

 Works at the network layer, so it's invisible to applications.


 Protects all data without changing the apps or services.

Secure Electronic Transaction (SET) Protocol


Last Updated : 20 Jun, 2024



Secure Electronic Transaction or SET is a security protocol designed to


ensure the security and integrity of electronic transactions conducted using
credit cards. Unlike a payment system, SET operates as a security protocol
applied to those payments. It uses different encryption and hashing
techniques to secure payments over the internet done through credit cards.
The SET protocol was supported in development by major organizations
like Visa, Mastercard, and Microsoft which provided its Secure Transaction
Technology (STT), and Netscape which provided the technology of Secure
Socket Layer (SSL).

SET protocol restricts the revealing of credit card details to merchants thus
keeping hackers and thieves at bay. The SET protocol includes Certification
Authorities for making use of standard Digital Certificates like X.509
Certificate.
SET functionalities:
 Provide Authentication
o Merchant Authentication - To prevent theft, SET allows
customers to check previous relationships between merchants
and financial institutions. Standard X.509V3 certificates are
used for this verification.
o Customer / Cardholder Authentication - SET checks if the
use of a credit card is done by an authorized user or not using
X.509V3 certificates.
 Provide Message Confidentiality: Confidentiality refers to preventing
unintended people from reading the message being transferred. SET
implements confidentiality by using encryption techniques. Traditionally
DES is used for encryption purposes.
 Provide Message Integrity: SET doesn't allow message modification
with the help of signatures. Messages are protected against
unauthorized modification using RSA digital signatures with SHA-1 and
some using HMAC with SHA-1,
Dual Signature: The dual signature is a concept introduced with SET,
which aims at connecting two information pieces meant for two different
receivers :
Order Information (OI) for merchant
Payment Information (PI) for bank
🔍 What is SSL?

SSL is a security protocol that encrypts the connection between your browser and a website.

So, when you visit a banking or shopping site, SSL protects your data like passwords, credit card info,
etc.

Imagine you're sending a secret message to someone over the internet. If you send it like a
regular postcard, anyone who intercepts it can read it. This is like the old way websites used
to send information (HTTP).

SSL (Secure Sockets Layer) is like putting that secret message in a special, locked envelope
that only the intended recipient has the key to open. It's a technology that creates a secure,
encrypted connection between your computer (your browser) and a server (like a website
you're visiting).

Here's what it does in simple terms:

1. Encryption: This is the "scrambling" part. When you send information (like your
login details or credit card number) to a website that uses SSL, SSL encrypts that
data. This means it turns it into a jumbled mess of characters that is unreadable to
anyone who might try to intercept it along the way.
2. Authentication: This is about verifying identity. How do you know you're sending
your information to the real website you intended to, and not a fake one set up by
someone trying to steal your data? SSL helps with this by using something called an
SSL Certificate. This certificate is like a digital ID card for the website, issued by a
trusted third party (called a Certificate Authority). Your browser checks this
certificate to make sure the website is legitimate.
3. Data Integrity: SSL also helps ensure that the data sent hasn't been tampered with
during transmission.

In short:

When you see "HTTPS" at the beginning of a website's address and a padlock icon in your
browser's address bar, it means that the website is using SSL (or its more modern version,
TLS - Transport Layer Security). This tells you that the connection is secured, and any
information you exchange with the website is encrypted and protected.

It's essentially a way to create a private and safe channel for communication over the not-so-
private internet.

🔑 How SSL Works:

1. Browser connects to a website with https://


2. Website sends its SSL certificate.
3. Browser checks it.
4. If trusted, they agree on encryption keys.
5. Secure connection starts.

✅ Indicators of SSL:

 URL starts with https://


 A padlock icon in the browser bar

🔄 SSL vs TLS:

 SSL is older and now considered insecure.


 TLS (Transport Layer Security) is its modern replacement.

💡 Used in:

 Online shopping
 Online banking
 Login pages
 Email and messaging apps
✅ 4. SSH (Secure Shell)
🔍 What is SSH?

SSH is a secure method to remotely connect to another computer (usually a server).


It’s like a secure tunnel you use to control another computer over the internet.

🧑‍💻 Example Use:

A developer sitting at home can use SSH to safely log in to a company server and run commands.

Okay, let's explain SSH in simple terms.

Imagine you need to control a computer that's far away, maybe a server in another city or
even another country. In the past, you might have used methods that sent your commands and
the computer's responses across the internet like plain text on a postcard – easily read by
anyone who might intercept it.

SSH (Secure Shell) is like having a secure, encrypted tunnel that you can use to connect to
and control that faraway computer. It's a network protocol that provides a safe way to access
and manage systems remotely over an unsecured network like the internet.

Here's what makes it "secure":

1. Encryption: Just like SSL, SSH encrypts all the data that passes between your
computer (the SSH client) and the faraway computer (the SSH server). This means
that even if someone intercepts the communication, they'll only see scrambled,
unreadable data.
2. Authentication: SSH verifies that you are who you say you are, and that the server
you're connecting to is the legitimate server you intend to reach. This is often done
using passwords or, more securely, with SSH keys. SSH keys are like a digital
fingerprint system where you have a public key (shared with the server) and a private
key (kept secret by you). The server can use your public key to challenge your
computer, and only your private key can correctly answer that challenge, proving your
identity without sending your password over the network.

🔐 Key Features:

 Encrypted communication
 Authentication using passwords or keys
 Prevents eavesdropping and attacks
🔑 How SSH Works:

1. You request to connect to a server using SSH.


2. The server asks for your password or SSH key.
3. If authenticated, a secure encrypted session is created.
4. You can now control the server remotely.

💡 Used For:

 Managing web servers


 Transferring files securely (SCP/SFTP)
 Running programs remotely
 Network administration

Firewall (1L)
🔹 Introduction:

A firewall is a security system (software, hardware, or both) that controls and monitors incoming and
outgoing network traffic based on security rules.
Its main purpose is to protect your computer or network from unauthorized access and cyber
threats.

Think of it like a security guard standing at the gate of your computer network, checking every data
packet that comes in or goes out — and allowing or blocking it based on rules.

🔹 Types of Firewalls:

1. Packet Filtering Firewall

A packet filtering firewall is a type of network security device or software that monitors and
controls incoming and outgoing network traffic based on predefined rules. It operates at the
network layer (Layer 3) and sometimes the transport layer (Layer 4) of the OSI model.

How Packet Filtering Works:

Inspects Packet Headers:

Examines key fields in IP and TCP/UDP headers, such as:

Source IP address

Destination IP address
Protocol (TCP, UDP, ICMP)

Source & Destination Port numbers

Packet flags (SYN, ACK, FIN, etc.)

Applies Rule-Based Filtering:

Compares packet information against a set of access control rules (ACLs) to decide whether
to allow, block, or drop the packet.

Example rules:

Allow inbound TCP traffic on port 80 (HTTP)

Block all ICMP (ping) requests from external networks

Deny outbound traffic to malicious IPs

Stateless vs. Stateful Packet Filtering:

Stateless Firewall:

Treats each packet in isolation (no memory of previous packets).

Faster but less secure (vulnerable to attacks like IP spoofing).

Stateful Firewall:

Tracks active connections (e.g., TCP handshake).

More secure but requires more resources.

Advantages:

✔ Fast & Efficient (low latency due to minimal processing).

✔ Works at the Network Layer (good for basic traffic filtering).

✔ Easy to Implement (simple rule-based filtering).

Disadvantages:

❌ Limited Security: Only examines headers, not packet contents (vulnerable to application-
layer attacks).

❌ No User Authentication: Cannot enforce policies based on user identity.

❌ Vulnerable to Spoofing & Fragmentation Attacks.


Common Use Cases:

Basic network perimeter security (e.g., routers with ACLs).

First line of defense in a layered security approach.

Traffic filtering in small networks with low security needs.

Stateless Firewall: The Simple Guard

Imagine a security guard who only looks at the ID badge of everyone trying to enter a
building. They have a list of allowed ID numbers, and they check each person's badge against
that list. They don't remember anyone who has already entered or what they are doing inside.
Each person is treated as if they are arriving for the first time.

 How it works: A stateless firewall looks at each data packet that comes through, one
by one, without any memory of previous packets or connections. It checks the
packet's basic information, like where it's coming from (source IP address), where it's
going (destination IP address), and what type of traffic it is (like web Browse or
email). It compares this information to a set of rules you've given it. If the packet
matches a rule that says "allow," it goes through. If it matches a "block" rule, it's
stopped.
 Think of it like: A simple filter.
 Pros: Fast and efficient because it doesn't have to keep track of anything. Easier to set
up for basic filtering.
 Cons: Not very smart about ongoing conversations. It can't tell if a packet is part of a
legitimate back-and-forth or if it's an unexpected or potentially malicious packet sent
out of sequence.

Stateful Firewall: The Smart Guard with Memory

Now, imagine a security guard who not only checks your ID but also keeps track of everyone
who is inside, who they are talking to, and what they are doing. If someone inside the
building sends a request to someone outside, the guard remembers that conversation is
happening and expects a reply. When the reply comes, the guard knows it's part of an
ongoing, legitimate interaction and lets it through, even if the initial rules might have
otherwise blocked an incoming connection from that source.

 How it works: A stateful firewall keeps track of the "state" of active network
connections. It remembers information about the connection, such as the source and
destination IP addresses and ports, and the sequence numbers of packets. When a new
packet arrives, the firewall checks if it belongs to an existing, legitimate connection
that it's already tracking. If it does, it's usually allowed through based on the
established connection's state, even if there isn't a specific rule just for that single
packet. If it's a new connection attempt, it checks the rules like a stateless firewall
would.
 Think of it like: A smart tracker.
 Pros: Much more secure because it understands the context of traffic and can block
unexpected or malicious packets that aren't part of a known connection. Better at
protecting against certain types of attacks that rely on sending unexpected packets.
 Cons: Requires more processing power and memory to keep track of all the
connections. Can be more complex to configure.

In short:

 Stateless firewalls look at each packet individually based on simple rules.


 Stateful firewalls understand and track the flow of traffic, looking at packets in the
context of the entire connection.

Stateful firewalls provide a much higher level of security for most modern networks because
they have a better understanding of what constitutes legitimate communication. Stateless
firewalls are typically used for simpler filtering tasks or in specific high-performance
scenarios where the overhead of state tracking is a concern and other security measures are in
place.

Here's how Statefull Firewall works:

1. Tracking Connections: When a device inside your network starts a connection to a


device outside (like your computer opening a web page on a server), the stateful
firewall notices this. It records important details about this connection, such as:
o The source IP address (your computer's address)
o The source port (a number your computer uses for this connection)
o The destination IP address (the web server's address)
o The destination port (usually port 80 for HTTP or 443 for HTTPS)
o The protocol being used (like TCP or UDP)
o The current stage or "state" of the connection (like setting up, established, or
closing).
2. Maintaining a State Table: The firewall keeps all this information in a temporary
database called a state table. This table is constantly updated as connections are
established, maintained, and closed.
3. Intelligent Decision Making: When subsequent packets arrive at the firewall, instead
of just checking them against a static list of rules like a stateless firewall, the stateful
firewall first looks at its state table.
o If an incoming packet belongs to an existing, legitimate connection that is
already in the state table (like the web server sending back parts of the web
page you requested), the firewall knows it's expected traffic and allows it
through without needing to check all the regular rules again for that specific
packet.
o If an incoming packet does not match any active connection in the state table
(for example, if a random external device tries to send data to your computer
without your computer initiating a connection), the firewall will then check its
predefined security rules to decide whether to allow or block it. Since it
doesn't match an established connection, it's more likely to be blocked if
there's no specific rule allowing unsolicited incoming connections.
4. Understanding Context: Because the stateful firewall understands the context of an
entire conversation or session, it can be much more effective at preventing malicious
traffic. It can detect things like:
o Packets that arrive out of the expected sequence in a connection.
o Attempts to send data to a port that wasn't part of the initial, allowed
connection.
o Certain types of attacks that try to exploit the way connections are established.

In essence:

A Stateful Inspection Firewall provides a dynamic layer of security. It doesn't just filter
individual packets; it monitors the entire flow of traffic and makes decisions based on the
context of active connections. This makes it significantly more secure and the standard type
of firewall used in most networks today, from homes to large enterprises.

Application Layer Firewall (Layer 7 Firewall)

An Application Layer Firewall (also called a Layer 7 Firewall or Proxy Firewall) operates at
the highest layer of the OSI model (Layer 7) and inspects application-specific traffic (e.g.,
HTTP, FTP, DNS, SMTP). Unlike packet filtering or stateful firewalls, it examines the actual
content or payload of network traffic rather than just headers.

How an Application Layer Firewall Works

Deep Packet Inspection (DPI)

Analyzes the payload of packets (not just IP/port info).

Detects malicious content in:

HTTP requests/responses (SQLi, XSS)

Email attachments (malware in SMTP)

File transfers (block unauthorized FTP uploads)

Proxy-Based Filtering

Acts as an intermediary between clients and servers.

Terminates and re-establishes connections, preventing direct exposure.

Example:

A user’s HTTP request goes to the firewall → Firewall inspects it → Then forwards it to the
web server.

Granular Access Control

Blocks traffic based on:


URLs, domains (e.g., block social media)

User identity (Active Directory integration)

File types (block .exe downloads)

Behavioral patterns (detect brute-force login attempts)

Advantages

✅ Stops Application-Layer Attacks – Prevents SQLi, XSS, malware, and zero-day exploits.

✅ Content Filtering – Blocks malicious files, restricted websites, or unauthorized apps.

✅ User-Aware Policies – Enforces rules based on usernames (not just IPs).

✅ Logging & Reporting – Tracks detailed application usage (e.g., "Who accessed
Dropbox?").

Disadvantages

❌ High Resource Usage – Deep inspection slows traffic (latency).

❌ Complex Configuration – Requires fine-tuning for different apps.

❌ Cannot Inspect Encrypted Traffic Without Decryption – Needs SSL/TLS decryption


(MITM).

Types of Application Firewalls

Web Application Firewall (WAF)

Protects web apps (HTTP/HTTPS) from OWASP Top 10 threats.

Examples: Cloudflare WAF, ModSecurity, AWS WAF.

Next-Gen Firewall (NGFW)

Combines stateful + application-layer filtering.

Examples: Palo Alto, FortiGate, Cisco Firepower.

Proxy Firewalls

Acts as a gateway for specific apps (e.g., SMTP proxy).

Examples: Squid (HTTP), SMTP gateways.

Common Use Cases


✔ Securing Web Servers – Blocks SQL injection, API abuse.

✔ Data Loss Prevention (DLP) – Stops sensitive file uploads.

✔ Compliance (PCI DSS, HIPAA) – Logs application-level access.

✔ Enterprise Traffic Control – Restricts SaaS apps (e.g., block Zoom).

Conclusion

An Application Layer Firewall provides the highest level of security by inspecting traffic
content, but at the cost of performance. For best protection, it’s often used alongside:

NGFW (for hybrid L3-L7 filtering)

IPS/IDS (for threat detection)

SSL Decryption (to inspect encrypted traffic)

Proxy Firewalls, also known as Application-Level Gateways.

Imagine you want to talk to someone far away, but instead of talking directly, you use a
trusted friend in between. You tell your friend what you want to say, they go and talk to the
other person, and then they come back and tell you the response. You never directly interact
with the other person.

That's essentially how a proxy firewall works in a network. It acts as an intermediary or a


gateway between your internal network and the external network, like the internet.

Here's a simple breakdown:

1. Acting as a Stand-in: When a device on your internal network (like your computer)
wants to connect to something on the internet (like a website), it doesn't connect
directly. Instead, it sends the request to the proxy firewall.
2. Deep Inspection: Unlike simpler firewalls that might only look at the basic packet
information (like source and destination IP addresses and ports), a proxy firewall
operates at the application layer. This means it can understand the specific type of
traffic (like HTTP for web Browse, FTP for file transfers, or SMTP for email) and
inspect the content of the data being sent. It can understand the commands and data
being exchanged within that specific application protocol.
3. Making the Connection on Your Behalf: If the request is allowed based on the
firewall's rules and the content is deemed safe after inspection, the proxy firewall
creates its own separate connection to the destination on the internet. It essentially
makes the request for your computer.
4. Receiving and Forwarding the Response: When the response comes back from the
internet, it goes to the proxy firewall first. The firewall inspects this incoming traffic
just as thoroughly. If it's safe, the proxy firewall then forwards the response back to
your computer.

Key Benefits of Using a Proxy Firewall:


 Enhanced Security: By inspecting the actual content of application traffic, they can
detect and block threats that are hidden within the data itself, not just based on where
it's coming from or going. They prevent direct connections between your internal
devices and the outside, adding a layer of separation.
 Improved Privacy: Since the proxy firewall makes the connection to the internet on
your behalf, your internal device's IP address is hidden from the external website or
service. The external world only sees the IP address of the proxy firewall.
 Content Filtering: They can be configured to block access to specific websites or
types of content based on application-level information (like keywords or categories),
offering more granular control over internet usage.
 Caching: Some proxy firewalls can store copies of frequently visited web pages or
files. When another user requests the same content, the firewall can serve it directly
from its cache, speeding up access and reducing bandwidth usage.
 Granular Control: Administrators can set very specific rules based on users,
applications, and even the content being transmitted.

Things to Consider:

 Latency: Because every request and response has to go through the proxy and be
inspected, it can sometimes add a delay to communication.
 Complexity: Setting up and managing proxy firewalls can be more complex than
simpler firewall types.
 Protocol Support: A proxy firewall needs to understand the specific application
protocol to inspect its content. This means it might not support every single
application protocol out there.

In simple terms:

A proxy firewall acts as a secure intermediary that understands the language of different
applications (like web Browse or email). It inspects the actual content of your network traffic
before allowing it to pass through, providing a higher level of security and privacy by
preventing direct connections between your devices and the outside world.

Firewall Type Works At Layer Checks Pros Cons


Basic
Packet Filtering Network IP, Port, Protocol Fast
protection
Stateful Network + Tracks
More secure Uses memory
Inspection Transport connections
Application Blocks
Application Data content Slower
Layer apps/websites
Proxy Firewall Application Entire traffic High privacy Complex setup

Internet Telephony: Understanding VoIP


Internet Telephony, commonly known as VoIP (Voice over Internet Protocol), is a
technology that allows you to make and receive phone calls using a broadband internet
connection instead of traditional analog phone lines. Think of it as sending your voice as data
over the internet, just like sending an email or Browse a website.
Definition:
VoIP is a method of digital communication that converts audio signals (your voice) into data
packets and transmits them over an Internet Protocol (IP) network. At the receiving end, these
data packets are converted back into audible voice.
How it Works (Easily Explained):
Here's a simplified look at the process:

1. Speaking into the Device: When you speak into a VoIP phone, a regular phone
connected to a special adapter, or a computer/smartphone running VoIP software, your
voice is captured as an analog signal (like sound waves).
2. Converting to Digital: This analog voice signal is immediately converted into a
digital format. This is like turning the continuous wave of your voice into a series of
numbers or bits.
3. Compressing and Packaging: The digital voice data is then compressed to save
bandwidth and broken down into small chunks called packets. Each packet contains a
small piece of your conversation along with information about where it came from,
where it's going (the destination IP address), and its order in the sequence of packets.
4. Sending over the Internet: These packets travel across the internet, hopping from
one router or server to another, much like how any other data (like website
information) travels online. The internet's infrastructure is designed to route these
packets efficiently.
5. Receiving and Reassembling: At the other end, the recipient's VoIP device collects
these incoming data packets. It uses the information in the packet headers to
reassemble them in the correct order.
6. Converting Back to Voice: Once the packets are reassembled, the digital data is
converted back into an analog audio signal that the recipient can hear as your voice
through their phone's speaker or headset.

Key takeaway: Instead of a dedicated physical phone line for each call, VoIP uses your
existing internet connection to send and receive voice data as packets. This digital approach
offers flexibility, often lower costs (especially for long distance), and a range of features not
typically available with traditional phone services.

1. RSVP (Resource Reservation Protocol)- RSVP (Resource Reservation Protocol) with a


simpler analogy.

Imagine the internet is like a big highway system with many roads of different sizes and
traffic levels. When you send regular data, like an email or loading a webpage, it's like
sending a regular car onto the highway. These cars just go with the flow, and if there's traffic,
they slow down. This is fine for data that doesn't need to arrive at a specific time.

Now, imagine you are trying to stream a live video call or watch a high-definition movie
online. This is like needing to send a high-priority vehicle, like an ambulance or a VIP
convoy, that needs a clear path and consistent speed to arrive on time without interruptions.

RSVP is like a system you can use to ask the "highway system" (the network) to reserve
a clear lane or a certain amount of "road space" specifically for your important
"vehicle" (your multimedia data).
Here's how the analogy works with RSVP:

1. The "Important Vehicle" (Multimedia Stream): Your video call or streaming


movie needs a consistent flow of data to play smoothly without buffering or freezing.
This data is sensitive to delays and variations in arrival time (jitter).
2. Asking for a "Reserved Lane" (RSVP Request): Before the multimedia stream
starts, or as it begins, the receiver (your computer or device) can use RSVP to send a
request to the network. This request is like saying, "Hey network, I'm about to receive
a high-priority data stream from this sender (the streaming server), and I need a
guaranteed amount of bandwidth and a consistent path for it. Can you reserve
resources for me along the way?"
3. Routers as "Traffic Managers": The routers along the path of your data stream are
like the traffic managers on the highway. When they receive the RSVP request, they
look at their current traffic and see if they can dedicate the requested resources
(bandwidth) for your stream.
4. Making the "Reservation": If the routers can meet the request, they set aside those
resources. This is the "resource reservation." They will then prioritize the packets
belonging to your multimedia stream to ensure they get through with less delay and
without getting stuck behind lower-priority traffic.
5. Maintaining the "Reserved Lane": RSVP uses a "soft state," which means the
reservation isn't permanent. The receiver periodically sends messages to refresh the
reservation, like letting the traffic managers know the VIP convoy is still coming and
needs the lane kept clear. If the network path changes, RSVP can work with routing
protocols to try and establish a new reservation on the new path.

In simple terms, RSVP is a signaling protocol that helps applications tell the network
that they need a certain quality of service (like guaranteed bandwidth and low delay)
for their data, and it helps the network try to make those resources available.

It's less about the data itself (that's RTP's job) and more about the path and resources that the
data will use to ensure it arrives with the quality needed for real-time multimedia.

Think of it as booking a fast pass or a dedicated line for your multimedia traffic on the
internet highway.

RSVP (Resource Reservation Protocol) is designed to reserve resources across a network to


provide a guaranteed quality of service (QoS) for data flows, including multimedia. It
operates at the transport layer and allows applications to request a specific amount of
bandwidth and other resources from the network on behalf of a data flow. RSVP is receiver-
initiated, meaning the receiver of a data flow is responsible for initiating and maintaining the
resource reservation. It is not a routing protocol but works in conjunction with routing
protocols to establish and maintain reservations along the data path. RSVP helps in ensuring
that multimedia streams receive the necessary network resources to maintain a desired level
of quality, minimizing issues like delay and jitter.

2. RTP (Real-Time Transport Protocol) RTP (Real-time Transport Protocol) in a simple


way with an example.

Imagine you're sending a stream of building blocks (your multimedia data, like video frames
and audio samples) from one place (the sender) to another (the receiver) over the internet.
RTP is like the specially designed trucks that carry these building blocks in real-time.

Here's how the analogy works with RTP:

1. The "Building Blocks" (Multimedia Data): Your video and audio are broken down
into small pieces, like individual building blocks. For a video, these might be small
parts of a picture; for audio, they might be tiny sound segments.
2. The "Specialized Trucks" (RTP Packets): Instead of just putting these blocks into
any regular box, RTP puts each block (or a few blocks) into a special container called
an RTP packet.
3. Labels on the Trucks (RTP Header): Each RTP truck has important labels on it,
like a shipping label:
o Sequence Number: This is like a number on each truck showing the order it
left the sender (Truck 1, Truck 2, Truck 3, etc.). This helps the receiver know
the correct order to put the building blocks back together, even if some trucks
arrive out of order.
o Timestamp: This is like a clock on the truck that tells you when the building
block inside was picked up at the sender's side. This is crucial for the receiver
to play the audio and video at the correct speed and to keep them synchronized
(so the sound matches the picture).
o Payload Type: This label indicates what kind of building block is inside – is it
a video piece or an audio piece? And what format is it in (e.g., a specific video
or audio codec)? This tells the receiver how to interpret and use the data
inside.
o Source Identifier: This is like a unique ID for the sender's factory, so the
receiver knows which stream these blocks belong to, especially if receiving
multiple streams.
4. Sending the Trucks (Transport): These RTP trucks are sent over the internet,
usually using a fast but not always perfectly reliable delivery service like UDP (User
Datagram Protocol). Think of UDP as a postal service that focuses on speed but might
occasionally lose a letter or deliver them in a different order than they were sent.
5. Reassembling at the Destination (Receiver): At the receiver's side, the RTP packets
arrive. Your media player (the "construction worker") uses the labels on the trucks:
o It uses the sequence numbers to put the building blocks back in the correct
order.
o It uses the timestamps to know when to place each block in the final structure
and to ensure the audio and video streams line up correctly.
o It uses the payload type to understand the data and process it accordingly.

In simple terms, RTP is the protocol that packages your real-time audio and video data
into standardized packets with timing and sequencing information, allowing the
receiver to reconstruct and play the multimedia stream smoothly, even if the network
isn't perfect.

It doesn't worry about whether every single packet arrives (that's usually handled by other
mechanisms or simply accepted as a potential for minor glitches in real-time), but it provides
the essential information needed for the receiver to handle the real-time nature of the data.

RTP (Real-time Transport Protocol) is the workhorse for transporting the actual
multimedia data (audio and video) over IP networks in real time. It is an application-layer
protocol that runs on top of UDP (User Datagram Protocol) in most cases, prioritizing timely
delivery over guaranteed arrival of every packet. RTP packets contain essential information
for reconstructing the multimedia stream at the receiver, including sequence numbers to
detect packet loss and reorder out-of-sequence packets, and timestamps to allow for
synchronization of different media streams (like audio and video) and to enable jitter
compensation. RTP is designed for end-to-end real-time transfer and supports multicast for
efficient delivery to multiple recipients.

3.RTCP (RTP Control Protocol) works alongside RTP to provide control and feedback mechanisms for
the multimedia session. While RTP carries the media data, RTCP is used to monitor the quality of
data distribution and to convey information about the participants in the session. RTCP periodically
sends control packets to all participants in an RTP session containing statistics such as packet loss,
jitter, round-trip delay, and the number of bytes and packets sent and received. This feedback allows
senders to adapt their transmission rate or encoding to prevailing network conditions, thereby
improving the quality of the streaming experience. RTCP also provides a way to synchronize multiple
media streams originating from different sources.

Okay, let's make RTCP (RTP Control Protocol) easy to understand, building on our previous
analogy.

Remember our RTP "specialized trucks" carrying "building blocks" (multimedia data) from
the sender to the receiver?

If RTP is like the trucks delivering the building blocks, RTCP is like the system of
feedback forms and reports that go back from the receiver to the sender and other
participants.

Here's how the analogy works with RTCP:

1. The "Construction Site Supervisor" (The Receiver): At the receiver's end, your
media player is like a supervisor at a construction site receiving the building blocks.
It's trying to assemble the final structure (play the video and audio).
2. Filling Out "Feedback Forms" (Sending RTCP Reports): As the supervisor
receives the trucks (RTP packets), they constantly check how things are going. Are
the trucks arriving on time? Are any trucks missing? Are they in the right order? The
supervisor fills out "feedback forms" with this information. These feedback forms are
the RTCP packets.
3. Types of "Feedback Forms" (RTCP Packet Types): There are different types of
feedback forms:
o Receiver Reports (RR): This is the most common form sent by receivers who
are not also sending data. It's like the supervisor telling the sender's factory:
"Here's how the deliveries are going from my end. This many trucks arrived,
this many were lost, and the ones that arrived had this much variation in their
arrival time."
o Sender Reports (SR): If the sender is also receiving data (like in a video call
where both sides are sending and receiving), they send Sender Reports. This is
like the sender's factory saying: "Here's how many trucks I've sent out and
how much data I've sent so far." This helps everyone keep track.
o Source Description (SDES): This is like a form with information about the
participant, such as their name or a unique identifier.
o Bye: This is like a note saying, "I'm leaving the construction site now."
4. Sending Forms Back (RTCP Transmission): These feedback forms (RTCP
packets) are sent back to the sender and sometimes to other receivers in the session
(like in a group video call). They are sent separately from the main data trucks,
typically using the same underlying transport protocol (usually UDP) but on a
different port number.
5. Sender and Participants Read the Feedback: The sender's factory reads these
feedback forms. If they see a lot of reports about lost trucks or delays, they might
decide to send the trucks slower or use smaller building blocks (adjust the encoding or
bit rate) to try and improve the delivery. Other participants can also read the reports to
understand the quality of the session for everyone.
6. Keeping Things Synchronized: The information in RTCP reports, especially the
timing information in Sender Reports, helps the construction supervisor at the
receiver's end make sure the audio and video building blocks are assembled in sync,
so the sound matches the picture.

In simple terms, RTCP is the protocol that provides a back channel for communication
about the quality of the multimedia stream. It allows participants to report statistics and
control information to help manage the session and adapt to changing network conditions,
ensuring the best possible quality for the real-time delivery of data handled by RTP.

5. RTSP ……………..Okay, let's make RTSP (Real-Time Streaming Protocol) easy to


understand with an example.

Imagine you have a fancy media player (like a DVD player or a streaming box) and the
multimedia content (like a movie) is stored on a server somewhere else, not on your device.

RTSP is like the remote control you use to tell the media server what you want it to do
with the movie.

Here's how the analogy works with RTSP:

1. The "Movie Collection" (Multimedia Content on Server): The audio and video
data you want to stream is stored on a server. Think of this server as holding a library
of movies.
2. Your "Remote Control" (Your Device Running an RTSP Client): Your computer
or device with a media player acts as the remote control. It sends commands to the
media server.
3. Sending Commands (RTSP Requests): You use RTSP commands (like pressing
buttons on a remote) to control the streaming:
o SETUP: This is like pressing "Setup" on your remote before playing. You tell
the server, "I want to watch this specific movie. Let's get ready and figure out
how the data will be sent (which ports to use for RTP and RTCP)."
o PLAY: This is like pressing the "Play" button. You tell the server, "Okay, I'm
ready, start sending the movie data now!"
o PAUSE: Like pressing "Pause." You tell the server, "Stop sending the data
temporarily."
o TEARDOWN: Like pressing "Stop" or turning off the player. You tell the
server, "I'm finished watching. You can stop the stream and free up the
resources."
o DESCRIBE: Like looking at the movie information on the remote. You ask
the server, "Tell me about this movie – what are the available audio and video
tracks, what formats are they in?"
o OPTIONS: Like pressing an "Options" button to see what the player can do.
You ask the server, "What commands do you support for this stream?"
4. The "Media Server" Responds: The server receives your RTSP commands and acts
accordingly. It sets up the streaming session, starts sending the data (using protocols
like RTP), pauses it, or stops it.
5. Separate Data Delivery (RTP/RTCP): It's important to remember that RTSP
doesn't actually send the movie data itself. Once you've used RTSP to tell the
server to "PLAY," the server then uses other protocols like RTP to send the actual
audio and video packets, and RTCP to send feedback about the quality, as we
discussed before. RTSP just controls when and how that data transfer happens.

In simple terms, RTSP is a control protocol that allows you to remotely manage the
playback of multimedia streams from a server. It's the signaling mechanism that sets up
and tears down the streaming session and allows you to control the stream's playback state
(play, pause, etc.), while RTP and RTCP handle the actual delivery and monitoring of the
media data.

Think of RTSP as the bridge between your media player's controls and the media server that
holds the content.

RTSP (Real-Time Streaming Protocol) is an application-layer control protocol that acts as


a "network remote control" for multimedia servers. It is used to establish and control media
sessions between a client and a media server. Unlike RTP, which carries the data, RTSP
handles the signaling for setting up, pausing, playing, fast-forwarding, and stopping the
delivery of a multimedia stream. It uses a request-response model, similar to HTTP, to
manage the streaming session. RTSP often works in conjunction with RTP and RTCP, where
RTSP is used for the initial setup and control of the stream, and RTP/RTCP are used for the
actual data transport and quality feedback during the session. RTSP is commonly used in
streaming applications, IP cameras, and video surveillance systems.

Typical Workflow for Live Streaming with RTSP:

1. The client connects to the RTSP server.


2. The client sends an OPTIONS request to determine the server's capabilities.
3. The client sends a DESCRIBE request to get the SDP description of the media stream.
4. The client sends a SETUP request to specify the transport parameters and ports for the
media data (RTP/RTCP).
5. The client sends a PLAY request to start the live stream.
6. The server begins sending the audio and video data using RTP over the negotiated
transport protocol (UDP or TCP) to the specified ports on the client.
7. The client receives the RTP packets, decodes the audio and video, and plays the
stream.
8. RTCP packets are exchanged periodically to provide feedback and synchronization.
9. The client can send PAUSE or TEARDOWN commands to control or end the stream.
In summary, these protocols collaborate to enable multimedia over IP: RTSP sets up and controls the
streaming session, RTP transports the real-time multimedia data with information for
synchronization and loss detection, RTCP monitors the session quality and provides feedback for
adaptation, and RSVP can be used to reserve network resources to ensure a certain level of QoS for
the multimedia streams. This combination of protocols provides the necessary framework for
delivering rich, interactive multimedia experiences over the internet.

Streaming media is the delivery of multimedia content (audio and video) over the internet in
a continuous flow, allowing users to watch or listen without having to download the entire
file first. To make this possible and efficient, several technologies and concepts are crucial,
including codecs, plugins, and IPTV.

Codecs
Codecs are essential for streaming media because raw audio and video data files are typically
very large. Transmitting these large files over the internet would require significant
bandwidth and would be impractical for real-time playback. Codec is a portmanteau of
"coder-decoder" or "compressor-decompressor."

 Purpose: Codecs use algorithms to compress (encode) the multimedia data at the source,
significantly reducing its size for efficient transmission over the network. At the receiving
end, the same codec is used to decompress (decode) the data back into a playable format.
 How they work: Codecs employ various techniques to reduce file size, including removing
redundant information (e.g., parts of an image that don't change much between frames) and
using mathematical transformations.
 Types: There are different codecs for audio (like AAC, MP3, Opus) and video (like H.264/AVC,
H.265/HEVC, AV1). The choice of codec impacts the compression efficiency, the quality of the
final output, and compatibility with different devices and software.
 Importance in Streaming: Codecs enable streaming by making it possible to transmit high-
quality audio and video over typical internet connections without excessive buffering.

Plugins
Plugins, in the context of older streaming technologies and web browsers, were software
components that extended the functionality of a media player or web browser to handle
specific multimedia formats or streaming protocols.

 Purpose: Historically, different media formats and streaming technologies required specific
software to play them. Plugins acted as add-ons that allowed a generic media player or web
browser to understand and render content it didn't natively support.
 Examples: Common examples included plugins for Adobe Flash Player, Microsoft Silverlight,
and QuickTime, which were necessary to stream video content on many websites in the past.
 Evolution: With the advent of HTML5 and more standardized web technologies, the reliance
on browser plugins for streaming has significantly decreased. Modern web browsers and
media players have built-in support for a wider range of codecs and streaming protocols,
reducing the need for external plugins.
 Current Relevance: While less prevalent for standard web video playback, plugins can still be
used in specific or professional streaming setups, media servers, or specialized applications
to add custom functionalities or support niche formats.

IPTV
IPTV (Internet Protocol Television) is a system where television services are delivered
using the Internet Protocol suite over a network, typically managed by a service provider. It's
a form of streaming media specifically focused on delivering television channels and video-
on-demand content.

 How it works: Unlike traditional broadcast, cable, or satellite TV, IPTV sends television signals
as data packets over an IP network. When a user selects a channel or a video, the content is
streamed to their device (often via a set-top box or a dedicated app).
 Managed Network: IPTV services are often delivered over a managed network (like a
telecom provider's private network) to ensure a certain level of quality of service (QoS) and
reliability, minimizing issues like buffering and picture degradation, which can be more
common on the public internet.
 Features: IPTV often offers interactive features not typically available with traditional TV,
such as video-on-demand (VOD), time-shifted TV (pausing live TV, catching up on ‫گذشته‬
programs), and interactive program guides.
 Relationship to Streaming: IPTV is a specific application of streaming media technology for
delivering television content. It leverages protocols like RTP and RTCP for data transport and
quality monitoring, and often uses codecs to compress the video and audio. While some OTT
(Over-The-Top) streaming services like Netflix and YouTube also use IP for delivery, IPTV is
often distinguished by its delivery over a provider-managed network for potentially higher
quality and reliability.

In essence, streaming media encompasses the techniques and technologies used to deliver
real-time audio and video over IP. Codecs are fundamental for compressing the media,
making streaming feasible. Plugins were historically important for compatibility but are less
central now due to evolving web standards. IPTV is a specialized form of streaming media
focused on delivering television services over managed IP networks with enhanced features
and quality control.

Search engine technology is the complex system that allows users to find information on the
vast expanse of the internet. It involves several interconnected components working together
to discover, organize, and rank web content in response to user queries.
Here's a breakdown of the key elements:

What is a Search Engine?


A search engine is a software system designed to search for information on the World Wide
Web. It works by taking keywords or phrases entered by a user and returning a list of relevant
web pages, images, videos, and other online resources. Popular examples include Google,
Bing, and Yahoo.

Metadata, Web Crawlers, and Indexing


These are fundamental processes that search engines use to build their vast databases of web
content:

 Web Crawlers (or Spiders): These are automated programs that systematically browse the
internet. They start with a list of known web pages and follow hyperlinks from those pages to
discover new ones. Crawlers analyze the content of each page they visit, including the text,
images, and links. They are constantly exploring the web to find new information and
updates to existing pages.
 Metadata: Metadata is "data about data." In the context of web pages, it includes
information embedded in the HTML code that describes the content of the page but isn't
always visible to the user. Examples include:
o Meta Title: The title of the page that appears in the browser tab and often as the
main headline in search results.
o Meta Description: A brief summary of the page's content that may appear below the
title in search results.
o Meta Keywords: (Less relevant now than in the past) Keywords that the page creator
thought were relevant to the content.
o Other metadata can describe the author, publication date, and the type of content.
While search engines have become more sophisticated at understanding page
content itself, relevant and accurate metadata can still help them categorize and
present information effectively.
 Indexing: Once web crawlers have found and analyzed a web page, the information is
processed and stored in a massive database called an index. Think of the index as a gigantic
digital library catalog. Instead of storing the entire web page, the index stores key
information about the page, such as the words it contains, where those words appear, the
metadata, and other data points. When you perform a search, the search engine doesn't
search the entire internet in real-time; it searches its index to find pages relevant to your
query. The indexing process organizes this information in a way that allows for very fast
retrieval of relevant results.

PageRank Algorithm
PageRank is an algorithm developed by Google founders Larry Page and Sergey Brin. It was
a foundational element in Google's early success and is still a part of Google's complex
ranking system today.

 Purpose: PageRank's primary goal was to measure the importance or authority of a web
page based on the number and quality of links pointing to it.
 How it works (Simply): The basic idea is that a link from one web page to another is
considered a "vote" of confidence or endorsement. A page that receives many links is likely
to be more important. However, not all links are equal. A link from a highly important or
authoritative page is worth more than a link from a less important page. The PageRank
algorithm calculates a score for each page based on the recursive nature of these links and
their values. It's like a system where the importance of a page is distributed among the pages
it links to.
 Analogy: Imagine a popularity contest where votes are cast by people. The more votes
someone gets, the more popular they are. But if a very popular person votes for someone,
that vote counts for more. PageRank works similarly with web pages and links.
 Beyond PageRank: While PageRank was revolutionary, modern search engines use hundreds
of factors in their ranking algorithms, including content relevance, user engagement, mobile-
friendliness, and more. PageRank is just one piece of a much larger puzzle.

Basics of SEO
SEO (Search Engine Optimization) is the practice of optimizing web content and websites
to improve their visibility and ranking in search engine results pages (SERPs). The goal of
SEO is to attract more organic (non-paid) traffic to a website from search engines.
Key aspects of basic SEO include:

 Keyword Research: Identifying the words and phrases that people are searching for that are
relevant to your content or business.
 On-Page SEO: Optimizing elements on your actual web pages, such as:
o Using relevant keywords in titles, headings, and content.
o Writing compelling meta descriptions.
o Creating high-quality, original, and valuable content.
o Optimizing images (alt text, file size).
o Ensuring a good user experience ( readability, site speed, mobile-friendliness).
 Off-Page SEO: Activities done outside of your website to improve its authority and
reputation, primarily through:
o Link Building: Acquiring high-quality backlinks from other reputable websites.
o Social media signals and online mentions (though the direct impact on ranking is
debated, they can drive traffic and visibility).
 Technical SEO: Ensuring the technical aspects of your website are optimized for crawling and
indexing, such as site speed, mobile-friendliness, site structure, and using sitemaps.

In essence, SEO is about making your website understandable and appealing to both search
engines (so they can crawl, index, and rank it correctly) and users (so they find it relevant and
useful).

You might also like