notes
notes
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
Uses Internet technologies (HTTP, FTP) but is not accessible to the public.
4. Extranet
A controlled extension of an intranet that allows external access to selected users (e.g.,
partners, suppliers).
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.
A domain name is a human-readable address used to identify websites on the Internet. It consists of
two main parts:
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:
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).
subdomain.second-level-domain.top-level-domain
This is the rightmost part of the domain name, following the last dot. TLDs categorize websites based
on their purpose, ownership, or geographical origin.
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.
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).
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:
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.
2. Recursive Resolver: Your ISP’s DNS server searches for the IP.
3. Root Server: Directs the query to the correct TLD server (.com).
6. Browser Access: The browser loads the website using the IP.
3. Protocols
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:
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.
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.
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.
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.
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).
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.
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 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).
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?
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
https://www.example.com:443/path/to/page?name=ankan&id=101#section1
Component Description
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.
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:
Client-Server Model: Many TCP/IP applications are based on the client-server model, where
a client requests services from a server.
Reliable (TCP): TCP ensures that data is delivered accurately and in order.
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.
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:
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.
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.
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.
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.
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.
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.
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.
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:
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 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 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.
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.
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 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 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.
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) 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.
🔑 Key Components:
🔁 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 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:
Example: Outlook downloading all your emails and removing them from the server.
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:
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.
Port numbers:
25 (default), 587
Ports 110 (default), 995 (SSL) 143 (default), 993 (SSL)
(submission), 465 (SSL)
❌ 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:
html
CopyEdit
<a href="https://example.com" target="_blank" title="Visit
Example">Visit Site</a>
html
CopyEdit
<img src="image.jpg" alt="Nature" width="300" height="200">
3. <input> – Input Tag
html
CopyEdit
<input type="text" name="username" placeholder="Enter your name">
html
CopyEdit
<p style="color:blue; font-size:16px;">This is a blue paragraph.</p>
html
CopyEdit
<div id="content" class="main-section" style="background-
color:lightgray;">
Welcome to my website!
</div>
html
CopyEdit
<button type="button" onclick="alert('Hello!')">Click Me</button>
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
CopyEdit
<form action="submit.php" method="post">
<!-- Form elements go here -->
</form>
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
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.
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>
html
CopyEdit
<ol>
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
</ol>
html
CopyEdit
<ul>
<li>Home</li>
<li>About</li>
<li>Contact</li>
</ul>
html
CopyEdit
<dl>
<dt>HTML</dt>
<dd>HyperText Markup Language</dd>
<dt>CSS</dt>
<dd>Cascading Style Sheets</dd>
</dl>
2. Layout Tags
1. <header> – Top section (logo, title, nav)
<header><h1>My Site</h1></header>
✅ 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 */
1. <map> Tag
2. <area> Tag
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>
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)
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
href URL to navigate to when the area is clicked. <area href="page.html" ...>
xml
CopyEdit
<bookstore>
<book>
<title>XML Basics</title>
<author>John Doe</author>
</book>
</bookstore>
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.
Key points:
Custom Tags Allowed You can define your own tags in XML.
Separation of Data & Presentation XML carries data only, no design or layout.
✅ 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.
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.
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 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.
A small part of the XML file is only It loads whole XML documents in
loaded in memory. memory.
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.
When a CGI script runs, the web server passes important information to it using environment
variables. These variables include data like:
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).
Python
#!/usr/bin/env python3
import os
import cgi
name = None
if name:
print(f"<h1>Hello, {name}!</h1>")
else:
print("<p>Please enter your name and submit the form.</p>")
print("</body>")
print("</html>")
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.
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).
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.
Basic Syntax:
perl
CopyEdit
print "Hello, World!\n"; # This prints Hello, World!
🔸 Scalars ($)
perl
CopyEdit
my $name = "Ankan";
my $age = 21;
🔸 Arrays (@)
perl
CopyEdit
my @colors = ("red", "green", "blue");
print $colors[0]; # prints red
🔸 Hashes (%)
perl
CopyEdit
my %student = ("name" => "Ankan", "age" => 21);
print $student{"name"}; # prints Ankan
🔸 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
perl
CopyEdit
my $text = "I love Perl";
if ($text =~ /Perl/) {
print "Matched!\n";
}
Common symbols:
Writing to a file:
perl
CopyEdit
open(my $fh, ">", "output.txt");
print $fh "Writing to file\n";
close($fh);
✅ 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.
✅ 1. Concatenation
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
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
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";
}
✅ 3. Common Metacharacters
Symbol Meaning Example
+ 1 or more go+gle
? 0 or 1 go?gle
✅ 5. Regex Flags
Flag Purpose
i Case-insensitive matching
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.
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
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.
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
}
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++;
}
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);
🔹 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.
js
CopyEdit
let msg = "Hello";
console.log(msg.length); // 5
js
CopyEdit
let fruits = ["apple", "banana"];
console.log(fruits[0]); // apple
js
CopyEdit
let isActive = true;
js
CopyEdit
let pattern = /abc/;
console.log(pattern.test("abcdef")); // true
These objects help handle various data formats and operations easily.
js
CopyEdit
function greet(name) {
return "Hello " + name;
}
console.log(greet("Ankan")); // Hello Ankan
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.
📋 What We Validated:
Field Validation Rules
✅ 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.
🎯 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
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 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.
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.
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.
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
CopyEdit
<applet code="MyApplet.class" width="300" height="200">
<param name="username" value="Ankan">
<param name="age" value="22">
</applet>
java
CopyEdit
import java.applet.*;
import java.awt.*;
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:
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.
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.
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.
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.
✅ 1. Application Layer
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.
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.
✅ 3. Transport Layer
This is the lowest layer and handles actual communication over the network using TCP/IP.
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.
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)
}
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"
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)
🧩 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 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.
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.
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.
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.
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 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.
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.
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.
🔒 How to Prevent:
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.
🔒 How to Prevent:
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.
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.
🔐 Key Features:
📬 You write a letter and just seal the contents inside the envelope.
But on the outside of the envelope, you still write:
So, the postman can see the addresses, but can’t read the message inside.
✅ In IPSec terms:
🎯 Use Case: Two computers in the same company securely exchanging data.
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:
🌍 Where is it used?
🔑 Benefits:
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).
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.
✅ Indicators of SSL:
🔄 SSL vs TLS:
💡 Used in:
Online shopping
Online banking
Login pages
Email and messaging apps
✅ 4. SSH (Secure Shell)
🔍 What is SSH?
A developer sitting at home can use SSH to safely log in to a company server and run commands.
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.
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:
💡 Used For:
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:
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.
Source IP address
Destination IP address
Protocol (TCP, UDP, ICMP)
Compares packet information against a set of access control rules (ACLs) to decide whether
to allow, block, or drop the packet.
Example rules:
Stateless Firewall:
Stateful Firewall:
Advantages:
Disadvantages:
❌ Limited Security: Only examines headers, not packet contents (vulnerable to application-
layer attacks).
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.
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:
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.
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.
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.
Proxy-Based Filtering
Example:
A user’s HTTP request goes to the firewall → Firewall inspects it → Then forwards it to the
web server.
Advantages
✅ Stops Application-Layer Attacks – Prevents SQLi, XSS, malware, and zero-day exploits.
✅ Logging & Reporting – Tracks detailed application usage (e.g., "Who accessed
Dropbox?").
Disadvantages
Proxy Firewalls
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:
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.
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.
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.
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.
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:
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.
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.
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.
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.
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.
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.
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:
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).