Don't Bother the Internet, This Is How It Works!


π Introduction
In simple terms, if you're familiar with computers, you can think of the internet as a massive collection of interconnected computers.
During the early stages of technological advancement, there was a global race among countries to achieve dominance. Russia took the lead by launching the first satellite, named Sputnik.
This development spurred the United States to act. In response, they established ARPA (Advanced Research Projects Agency). ARPA aimed to connect all its offices and research centers, leading to the creation of ARPANET β a network that initially connected four universities for the purpose of sharing information.
They used a set of rules known as protocols to send messages and files securely. One of these rules was TCP (we'll dive into this later). For now, just understand that these protocols ensured that data was shared in a structured and reliable way.
This marked the very early stages of the internet. It wasnβt global yet and was used strictly for research purposes. One major challenge at the time was navigating between multiple documents or pages β until a computer scientist named Tim Berners-Lee introduced several key innovations:
HTML β the language used to create web pages
HTTP β the protocol used to fetch those pages
URL β the addressing system to locate web resources
The first browser β originally called World Wide Web, later renamed Nexus
At this point, search engines didnβt exist. They were introduced later, and their arrival significantly accelerated the growth of the internet.
We'll dive into the technical details soon, but itβs worth noting that the internet is governed by certain organizations. One of the key ones is the Internet Society (ISOC).
The Internet Society, a non-profit organization founded in 1992 (around the time the internet was becoming publicly accessible), has the mission:
βTo keep the internet open, globally connected, trustworthy, and secure β for everyone.β
π How Does a User Reach Google.com?
Letβs break down what happens when you type google.com into your browser:
You type
google.com
in your browser.Your computer sends a request to Googleβs server.
The server processes the request and sends back a response.
β How Does Your Computer Find Google?
β ICANN β The Root Authority
β IP Addresses
ποΈ Example: Accessing Google from Your Phone (via Wi-Fi)
Assume your phone is connected to a Wi-Fi router. Here's the simplified flow:
[Your Phone]
192.xxx.xx.23
β
[Router Local IP]
192.xxx.xx.1
β (NAT: translates local IP to public IP)
[Router Public IP]
1xx.xx.xx.xx
β
[Internet Hops]
β
[Google Server]
142.250.64.78
β
(Response follows the reverse path)
π DHCP β Dynamic Host Configuration Protocol
When your phone connects to Wi-Fi, it doesnβt have an IP address yet.
So it sends a DHCP Discover message:
"Hello! I just joined the network. Can someone assign me an IP?"
The router (acting as the DHCP server) responds with something like:
"Sure! Hereβs your IP:
192.xxx
.xx.23
Gateway:192.xxx
.xx.1
DNS:8.8.8.8
Now your phone knows:
Its own IP address:
192.xxx
.xx.23
The gateway (router's local IP):
192.xxx
.xx.1
The DNS server to resolve domain names.
π NAT β Network Address Translation
NAT allows multiple devices in a local network to access the internet using a single public IP address.
Hereβs what NAT does:
Translates your internal/private IP (e.g.,
192.xxx
.xx.23
) to the routerβs public IPTracks which request came from which device
Ensures the correct device receives the correct response
This is essential for home networks where many devices share one internet connection.
π Ports
Ports help identify which service or app a device is using.
Valid range:
0 β 65535
Ports
0 β 1023
are reserved for well-known services
Common examples:
Port 80 β HTTP (web traffic)
Port 443 β HTTPS (secure web traffic)
When your browser accesses google.com, it connects to port 80 (for HTTP) or 443 (for HTTPS) on Googleβs server.
π DNS: The Phonebook of the Internet
DNS stands for Domain Name System.
Itβs like a phonebook for the internet.
You type: google.com
DNS translates it to: 142.250.72.14
Computers communicate via IP addresses β DNS helps humans use readable names instead.
π Domain Structure: Read Right to Left
Letβs break down the domain: blog.shop.example.com
Part | Name | Description |
.com | Top-Level Domain (TLD) | The highest level domain like .com , .org , .net , etc. |
example | Second-Level Domain (SLD) | The name registered under the TLD (e.g., example.com ) |
shop | Subdomain | A category or section of the main domain |
blog.shop | Nested Subdomain | A subdomain under another subdomain (optional layers) |
ποΈ Few Topics Revision
β LAN
β MAN
β WAN
β Topology
β Bus Topology
β Star Topology
β Ring Topology
β Mesh Topology
β Tree Topology
β Hybrid Topology
π Network Structure
ποΈ OSI Model
The Open Systems Interconnection (OSI) model is a conceptual framework that defines the steps through which two computers communicate over a network. It consists of 7 layers, each with its specific responsibilities.
1. Application Layer
Implemented in software such as web browsers, messaging apps, etc.
This is the layer closest to the user, where network services like email, web browsing, and file transfer occur.
2. Presentation Layer
Receives data from the Application Layer.
Converts data into a format that the network can understand (encoding).
Responsible for translation, encryption, and compression of data.
Data is already in binary format at this layer, but this layer prepares it for transmission.
3. Session Layer
Collects data from the Presentation Layer.
Responsible for establishing, maintaining, and terminating sessions between devices.
Handles authentication and authorization.
Manages the dialog control (keeps track of which device is sending/receiving data).
4. Transport Layer
Responsible for end-to-end delivery of data.
Breaks data into segments, each with source port, destination port, and sequence numbers.
Handles flow control to prevent the receiver from being overwhelmed.
Adds a checksum to detect errors in data transmission.
Key protocols: TCP (reliable) and UDP (faster but no guarantee).
5. Network Layer
Responsible for logical addressing, assigning source and destination IP addresses to each data packet.
Handles routing, moving packets across different networks.
Routers operate at this layer.
Data is broken into packets at this stage.
6. Data Link Layer
Breaks data into frames for transmission.
Adds the senderβs and receiverβs MAC addresses to ensure correct delivery on the local network.
Responsible for error detection and access control to the physical medium.
7. Physical Layer
Converts data into physical signals (electrical signals, light pulses, or radio waves) depending on the medium (cables, fiber optics, Wi-Fi).
Handles the actual transmission of raw bitstream over the physical medium.
Note: The OSI model is a conceptual framework. The real-world model, which is widely used, is the TCP/IP model.
ποΈ TCP/IP Model
While the OSI model is conceptual and often used for design and learning, the TCP/IP model is a practical, simplified framework that powers the modern internet. It consists of 4 layers, each serving a similar function to the corresponding layers in the OSI model.
1. Application Layer
Closest to the user.
Handles high-level protocols, data representation, encoding, and dialog control.
Key protocols: HTTP, FTP, SMTP, DNS, Telnet.
Application resides on this Layer , where the user interacts with it. Client Server Architecture.
request client < ======= > server response
2. Transport Layer
Responsible for end-to-end communication and error recovery.
Ensures complete data transfer.
Key protocols: TCP (reliable) and UDP (unreliable).
3. Internet Layer
Handles logical addressing and routing.
Determines the best path for data through the network.
Key protocols: IP (IPv4/IPv6), ICMP, ARP.
4. Network Access Layer (also known as Link Layer)
Deals with the physical transmission of data.
Includes hardware addressing and protocols that operate at the data link level.
Key protocols: Ethernet, Wi-Fi, ARP (again), Frame Relay.
The TCP/IP model is simpler, more efficient, and serves as the foundation for modern internet communication. The OSI model, while still important for understanding how networks work, is more detailed and used primarily in theoretical and design contexts.
π Meπ±βHeyβ β Internet β π²Friend
ποΈ Part 1: Your Phone to iMessage Server.
Wi-Fi Join and IP Assignment (DHCP Process)
Airplane Mode = No network.
MAC Address =
AA:BB:CC:DD:EE:FF
You turn off Airplane Mode and join a Wi-Fi network.
Phone: "Hi, DHCP server, who am I? Please give me an IP address."
(DHCP Discover β broadcast)
Router: "Here! Take 192.168.1.10, gateway 192.168.1.1, DNS 8.8.8.8"
(DHCP Offer)
Phone: "Okay, Iβll use that!"
(DHCP Request)
Router: "Confirmed."
(DHCP Acknowledgment)
β
Your phone now knows:
IP Address: 192.168.1.10
Gateway: 192.168.1.1
DNS: 8.8.8.8
DNS Resolution (Finding the iMessage Server)
You want to send a message to: imessage.apple.com (example domain).
Your phone sends a DNS query:
Protocol: UDP
Source IP: 192.168.1.10, Source Port: Random UDP port
Destination IP: 8.8.8.8, Destination Port: 53 (DNS)
β‘οΈ Router performs NAT and forwards the query to 8.8.8.8.
DNS server replies:
imessage.apple.com β 17.172.224.47
β
Your phone now knows where to send the message!
TCP Connection Setup (3-Way Handshake)
Before sending any data, your phone establishes a TCP connection:
SYN: Phone β Apple
"Letβs start a connection! Seq=1000"
SYN-ACK: Apple β Phone
"Okay! Seq=3000, Ack=1001"
ACK: Phone β Apple
"Got it! Ack=3001"
β
TCP connection established.
TLS Handshake (Securing the Connection)
Now, a TLS handshake occurs over the TCP connection to encrypt the message.
π TLS Handshake Steps:
ClientHello (Phone β Apple):
- Supported cipher suites
- Random number
- TLS version
ServerHello (Apple β Phone):
- Chosen cipher suite
- Server random
- Digital certificate (includes Appleβs public key)
Certificate Verification:
- Phone verifies Appleβs certificate using a trusted CA.
Key Exchange:
- Phone generates a pre-master secret.
- Encrypts it using Appleβs public key.
- Sends it to Apple.
Session Key Derivation: Both Phone & Apple derive session keys using:
- Client random
- Server random
- Pre-master secret
Finished Messages (Encrypted):
- Both sides confirm TLS handshake success.
β
Session secured β all data is now encrypted.
Encrypting Your Message
"hey"
Plain Message: "hey"
Is encrypted using the session key.
Encrypted Application Data Includes:
- TLS Header
- Encrypted Payload
"Even your router or ISP canβt read it!"
TCP Segment Creation
TCP Header:
Src Port: 5050
Dst Port: 443
Seq Num: 1002
Ack Num: 3001
'Data: Encrypted "hey" message'
TCP Header: Whatβs Inside?
In addition to port numbers (both source and destination), the TCP header contains several important fields that enable its reliability and connection management. Hereβs a breakdown of whatβs inside:
Source Port & Destination Port: To identify the sending and receiving applications.
Sequence Number: Used to track the order of the packets and ensure the data arrives in the correct sequence.
Acknowledgment Number: Used for confirming receipt of data. The receiver sends back an acknowledgment number to confirm the packets it has received.
Flags:
SYN
(Synchronize) for establishing a connection.
ACK
(Acknowledgment) for confirming receipt.
FIN
(Finish) for terminating the connection.Window Size: For flow control, telling the sender how much data the receiver can handle.
Checksum: For error-checking, ensuring the integrity of the data.
What is a Retransmission Timer?
In TCP, when a sender sends a data segment (packet), it expects an ACK from the receiver to confirm that the packet was successfully received. If the sender doesn't receive the ACK within a specified period, the retransmission timer expires, and the sender retransmits the data packet.
This mechanism ensures that data loss (due to network congestion, packet corruption, or other issues) does not lead to permanent data loss.
How it works:
The sender sends a TCP segment and starts the retransmission timer.
The sender waits for an ACK from the receiver.
If the sender doesnβt receive the ACK within the timer period (also known as the Timeout Interval), the timer expires, and the sender retransmits the segment.
The process is repeated until the sender gets the ACK or a maximum number of retries is reached.
Feature | TCP (Transmission Control Protocol) | UDP (User Datagram Protocol) |
Type | Connection-oriented | Connectionless |
Handshake | 3-way handshake (SYN, SYN-ACK, ACK) | No handshakeβsends data directly |
Reliability | Reliableβensures delivery and order | Unreliableβno guarantee of delivery or order |
Acknowledgment | ACKs are sent for every packet received | No acknowledgment mechanism |
Retransmissions | Lost packets are retransmitted automatically | No retransmission; application must handle it if needed |
Data Ordering | Guarantees ordered delivery | No guarantee of order |
Flow Control | Uses windowing for flow control | No flow controlβcan overwhelm receiver |
Error Checking | Extensiveβincludes checksums and reassembly mechanisms | Minimalβbasic checksum only |
Speed | Slower due to overhead of connection, ACKs, and retransmissions | Faster due to low overhead |
Use Cases | File transfer, email, web browsing (HTTP, FTP, etc.) | Video streaming, VoIP, online gaming, DNS |
Real-world Analogy | Certified mailβconfirmation of delivery and order | Postcardsβmay arrive late, out of order, or not at all |
IP Packet Creation
IP Header:
Src IP: 192.168.1.10
Dst IP: 17.172.224.47
TTL: 64
Protocol: TCP
"Data: TCP segment"
MAC Frame (Ethernet/Wi-Fi)
To send to the router, phone checks ARP table:
If unknown, it sends an ARP request:
"Who is 192.168.1.1?"
Router replies:
"Thatβs me! MAC: BB:CC:DD:EE:FF:11"
Ethernet Frame:
Src MAC: AA:BB:CC:DD:EE:FF
Dst MAC: BB:CC:DD:EE:FF:11
Data: IP Packet
What the Full Frame Looks Like
------------------------------------------------------------------------------
[ Frame ]
β
βββ [ MAC Header (src MAC, dst MAC) ] β Data Link Layer
β βββ [ Packet ]
β βββ [ IP Header (src IP, dst IP) ] β Network Layer
β β βββ [ Segment ]
β β βββ [ TCP Header (src port, dst port) ] β Transport Layer
β β β βββ [ TLS-encrypted payload ]
β β β βββ [ Actual data + metadata ] β Application Layer
-------------------------------------------------------------------------------
Fragmentation & Splitting into Packets
- If the message is too large (exceeds MTU β 1500 bytes), itβs split into smaller packets.
- Each packet still carries its own headers β crucial for reassembly.
π§± Packet 1. = [MAC][IP][TCP][TLS part 1 (start of encrypted data)]
π§± Packet 2. = [MAC][IP][TCP][TLS part 2 (middle of encrypted data)]
π§± Packet 3. = [MAC][IP][TCP][TLS part 3 (end of encrypted data)]
β
Every packet is complete and self-contained, ready to travel the internet independently.
Router NAT & Internet Journey
Router performs NAT:
Changes source IP to public IP (e.g.,
203.0.113.45
)Tracks mapping:
192.168.1.10:5050 β 203.0.113.45:40000
Packet Goes Out to ISP:
Src IP: 203.0.113.45
Dst IP: 17.172.224.47
ποΈ Part 2: iMessage Server to Your Friends Phone.
Message Storage & Routing (Apple Server)
When Apple receives your message:
The message remains end-to-end encrypted.
Apple temporarily stores the message in its encrypted form.
Apple looks up your friendβs device tokens (your friend may own multiple Apple devices like an iPhone, iPad, or Mac).
It determines the optimal delivery paths.
Device Token Example:
ab56b4d92b40713acc5af89985d4b786
Push Notification via APNs
To wake your friendβs iPhone, Apple uses the Apple Push Notification service (APNs):
APNs sends a notification: βWake up, you have a new iMessage!β
Transport details:
Persistent TCP connection between APNs and your friendβs iPhone.
Already established to save battery and latency.
Fully TLS-encrypted for security.
Friendβs iPhone β Network Connection Setup
Your friendβs phone, like yours, is:
Connected to Wi-Fi or cellular.
Assigned a local IP, public IP (via NAT), and MAC address.
Maintains an active TCP connection to APNs to avoid repeated handshakes and conserve power.
TLS Handshake (Initial Setup)
When your friendβs phone powers on and connects to APNs:
It performs a TLS handshake with Apple. (already covered above while sending message)
Session keys are established for secure, encrypted communication.
Apple sends the push notification: APNs β Friendβs iPhone Message: βYou have a new iMessage!β
Encrypted Message Delivery
Appleβs server delivers the end-to-end encrypted message:
Apple cannot read the message because:
It only stores encrypted blobs.
Only your friendβs device holds the private decryption keys.
Example Encrypted Payload:
TLS-encrypted packet:
- TCP header
- TLS header
- Encrypted data:
- Message metadata (e.g., sender, timestamp)
- Message content ("hey")
Message Decryption on Friendβs Device
Your friendβs iPhone:
Receives the encrypted data.
The iMessage app decrypts the message using the private key stored on the device.
The message appears: "hey"
Delivery Acknowledgment
iMessage sends a delivery receipt back to Apple:
- Over TCP + TLS
Apple updates the message status.
You, the sender, see: βDelivered β β
π P2P
P2P (Peer-to-Peer) architecture is a network model in which each device (called a peer) functions both as a client and a server.
Unlike traditional client-server systemsβwhere clients request resources and servers respondβP2P allows all peers to:
Request data
Provide data
Communicate directly with other peers
This decentralized model enhances scalability and resilience.
ποΈ Example Scenario: Downloading a Text File via P2P
Letβs imagine you're downloading a file named:
story.txt (1 MB)
You're using a BitTorrent-like P2P application.
π Step 1: File is Split into Chunks
Before the file is shared, the original uploader (called a seeder) splits it into small parts. For example:
story.txt β‘οΈ split into 4 chunks:
- Part 1: 0β256 KB
- Part 2: 256β512 KB
- Part 3: 512β768 KB
- Part 4: 768 KBβ1 MB
Each chunk is assigned a hash (a unique identifier) to verify data integrity during download.
π Step 2: Chunks are Shared Across Peers
As users download pieces, they also upload the ones they have to others. Over time, the file is distributed like this:
Peer | Chunks Owned |
Peer A | Part 1, Part 4 |
Peer B | Part 2 |
Peer C | Part 3, Part 4 |
Peer D | Part 1, Part 2, Part 3 |
Now you join as Peer E, aiming to download the full file.
π Step 3: Downloading Chunks
Your P2P app:
Connects to a tracker or DHT (Distributed Hash Table) to discover which peers have which parts.
Downloads multiple chunks simultaneously from different peers for speed.
Example download pattern:
Part 1 from Peer D
Part 2 from Peer B
Part 3 from Peer C
Part 4 from Peer A
These chunks are downloaded independently and in parallel, not necessarily in order.
π Step 4: Reassembling the File
Once all chunks are downloaded:
The app verifies each part using its hash to ensure data integrity.
Then it reassembles the parts into the original file:
[Part 1] + [Part 2] + [Part 3] + [Part 4] β‘οΈ story.txt
Now the file is complete and ready to be opened like any normal file.
π Step 5: You Become a Seeder
After successfully downloading the full file:
Your app begins uploading chunks to other peers still downloading.
You become a seeder, contributing to the network and helping others.
π Some Network Devices You Should Know
ποΈ Repeater
A repeater receives a signal, amplifies or regenerates it, and retransmits it over a network.
Main Use: To extend the range of a network where the signal gets weak or degraded over distance β commonly seen in early Ethernet or Wi-Fi setups.
Model | Layer Name | Repeater Lives Here? |
OSI Model | Layer 1 β Physical | β Yes |
TCP/IP Model | Network Access Layer | β Yes |
ποΈ Hub
A hub broadcasts incoming data to all connected ports, regardless of the actual destination.
Think of it like a loudspeaker: one device talks, and everyone hears β even if the message was meant for just one.
In a hub-based network, every device receives all the traffic, but:
Your network card (NIC) is smart enough to say:
βIs this packet for me? No? Ignore it.β
π But... What About Sniffing?
Since all data goes through your NIC:
You can use tools like Wireshark to sniff traffic from others.
Only possible if:
The data is unencrypted (e.g., HTTP, not HTTPS)
You're using a dumb hub, not a switch
You're running packet sniffing software
Model | Layer Name | Does Hub Work Here? |
OSI Model | Layer 1 β Physical Layer | β Yes |
TCP/IP Model | Network Access Layer | β Yes |
π 3 Main Types of Hubs
Hub Type | Description | OSI Layer |
1οΈβ£ Passive Hub | Just connects cables and passes signals without amplification | Layer 1 |
2οΈβ£ Active Hub | Boosts/amplifies the signal before sending it out β like a repeater + hub | Layer 1 |
3οΈβ£ Intelligent Hub | Offers monitoring/diagnostics and limited traffic management (still broadcasts) | Layer 1 |
ποΈ Bridge
A bridge connects two or more network segments, making them work as one β but with intelligence.
It examines MAC addresses and decides whether to forward or block traffic.
Goal: Reduce traffic, isolate collisions, and improve LAN performance.
[Floor 1 Devices] ββ
β
[ Bridge ] βββ [ Router / Internet ]
β
[Floor 2 Devices] ββ
It forwards external traffic (e.g., to the internet)
It blocks internal traffic that doesnβt need to cross segments (like a print job on Floor 2)
Model | Layer Name | Works Here? |
OSI Model | Layer 2 β Data Link Layer | β Yes |
TCP/IP Model | Network Access Layer | β Yes |
π Example Scenario
You're on Floor 1, browsing the web:
Your PC sends a DNS/HTTP(S) request β the bridge forwards it to the router.
Someone on Floor 2 prints something β the bridge blocks it from reaching Floor 1.
Result: Less congestion, faster performance.
π Without a Bridge?
All traffic goes everywhere.
Broadcast storms and high congestion.
Slower browsing and poor performance.
ποΈ Switch
A switch connects multiple devices within a LAN and forwards data intelligently β only to the intended recipient.
It uses MAC addresses to learn which device is connected to which port, unlike a hub that sends to all.
[PC1]βββ
[PC2]βββ€
[PC3]βββ€ββ[Switch]ββ[Router]ββπ Internet
[PC4]βββ
Model | Layer Name | Works Here? |
OSI Model | Layer 2 β Data Link Layer | β Yes |
TCP/IP Model | Network Access Layer | β Yes |
π Let's Talk About Protocols
Everything in networking has a protocol β a set of rules that devices follow to communicate.
ποΈ What Are Protocols?
Protocols are like rules in a game β both sides must follow the same rules for it to work.
In networks, protocols define how devices communicate, ensuring they understand and share data correctly.
π Why Are Protocols Important?
Without protocols:
Data would be lost or misinterpreted
Devices from different manufacturers wouldnβt communicate
The internet wouldnβt function
Protocols ensure consistency, compatibility, and reliability.
ποΈ Types of Protocols
π HTTP / HTTPS (Web Protocols)
β What is HTTP?
HTTP (Hyper Text Transfer Protocol) is a protocol used for communication between a client (usually a browser) and a web server.
It transfers data in plain text, meaning itβs not secure β anyone intercepting the request can read the data.
Port: 80
Security: β No encryption
Use cases: Non-sensitive websites or internal tools
β What is HTTPS?
HTTPS (HTTP Secure) is the secure version of HTTP.
It uses SSL/TLS encryption to protect data during transmission β especially important for:
Banking websites
Logins and authentication
E-commerce
Any site handling sensitive data
Port: 443
Security: β Encrypted via SSL/TLS
β HTTP Methods
These methods tell the server what action the client wants to perform:
Method | Purpose | Example |
GET | Read/Retrieve data | "Get me all blog posts" |
POST | Create new data | "Create a new user" |
PUT | Update an entire resource | "Update the whole profile info" |
PATCH | Update part of a resource | "Just update the profile picture" |
DELETE | Delete a resource | "Remove this user" |
β HTTP Status Codes
HTTP responses come with status codes that explain the result of your request.
Success
200 OK
: Request succeeded201 Created
: Resource created (usually after a POST)204 No Content
: Success, no data returned (commonly for DELETE)
Client Errors (Issues from your side)
400 Bad Request
: Syntax error or missing required data401 Unauthorized
: Not logged in / missing credentials403 Forbidden
: Logged in but no permission404 Not Found
: Resource doesnβt exist
Server Errors (Issues from the server)
500 Internal Server Error
: Server malfunction502 Bad Gateway
: Invalid response from another upstream server503 Service Unavailable
: Server is down or overloaded
β HTTP Request Basics
When making a request to a server (especially with POST
, PUT
, or PATCH
), here are the main components:
Headers
Metadata sent with the request or response.
Header | Description |
Content-Type | Format of the request body (e.g., application/json ) |
Authorization | Tokens or API keys for authentication |
User-Agent | Info about the browser or device making the request |
Only used with methods like POST
, PUT
, PATCH
.
Usually sent in JSON format or form-encoded data.
Example:
{
"username": "bob",
"password": "1234"
}
Cookies
Small pieces of data stored in your browser and automatically sent with each request to a domain. The use cases are below.
Session management (stay logged in)
Shopping carts
Analytics and tracking
Both HTTP and HTTPS operate at the Application Layer, built on top of TCP (which is in the Transport Layer).
HTTPS adds encryption using protocols like TLS, but still functions within the application layer.
TCP/IP Layer: Application Layer
π FTP / SFTP (File Transfer Protocols)
FTP
Port: 21
Channels: Command + Data
Modes: Active & Passive
Encryption: None (plaintext)
SFTP
Port: 22 (over SSH)
Connection: Single encrypted channel
Encryption: Full via SSH
TCP/IP Layer: Application Layer
π SMTP / IMAP / POP3 (Email Protocols)
β SMTP (Sending)
Port: 25 (or 587 with STARTTLS)
Use: Only for sending
β IMAP (Receiving)
Port: 143 (or 993 secure)
Emails stay on server, supports sync
β POP3 (Receiving)
Port: 110 (or 995 secure)
Downloads and deletes emails
β SMTP vs POP3 β The Basics
Protocol | Purpose | TCP/IP Model Layer |
SMTP(Simple Mail Transfer Protocol) | Used to send emails | Application Layer |
POP3 (Post Office Protocol v3) | Used to receive/download emails | Application Layer |
β SMTP β Sending Email
You send an email from an email client (e.g., Gmail, Outlook) to your email server
Email servers communicate with each other
Analogy: Like handing your letter to a postman, who then delivers it through a chain of post offices.
β SMTP in Action:
You write an email and hit βSendβ.
Your client (e.g., Gmail app) connects to Gmailβs SMTP server.
SMTP delivers the email across the internet to the recipientβs email server.
β SMTP Port Numbers
Port | Description |
25 | Default SMTP port (often blocked by ISPs) |
465 | SMTP with SSL (older secure method) |
587 | SMTP with TLS (modern, secure, preferred) β |
β POP3 β Receiving Email
You retrieve/download email from a mail server to your device
The email is usually deleted from the server after download (unless configured otherwise)
Analogy: Like visiting the post office, picking up your mail, and taking it home. The post office keeps no copy.
β POP3 Port Numbers
Port | Description |
110 | Default POP3 (unencrypted) |
995 | POP3 over SSL/TLS (secure) β |
β Email Flow Scenario β Step by Step
- You: you@gmail.com
- Your Friend: friend@hotmail.com
1. You Write & Send the Email
- You open Gmail and write:
- "Hey, letβs catch up this weekend!"
- To: friend@hotmail.com
- You hit SEND π₯
2. Gmail Uses SMTP to Send the Mail
- Your Gmail client talks to:
- smtp.gmail.com
- Gmailβs SMTP server prepares and forwards the message:
- From: you@gmail.com
- To: friend@hotmail.com
- Message: "Hey, letβs catch up..."
3. Gmail SMTP Contacts Hotmail Server
- Gmail uses DNS to find Hotmailβs MX record.
- It connects to:
- smtp.live.com
- Then it transfers the message using SMTP.
- Now the message is waiting on Hotmailβs mail server.
4. Friend Checks Email via POP3
- Your friend opens Outlook (or any email app) configured with POP3.
- The app connects to:
- pop-mail.outlook.com
- Using port 995 (secure), it says:
- "Any new mail for friend@hotmail.com?"
5. POP3 Server Sends the Email
- Hotmail POP3 server responds:
- "Yes! Here is a new message from you@gmail.com"
- The email gets downloaded to your friendβs device.
If using default POP3 behavior β the message is deleted from the server after download.
TCP/IP Layer: Application Layer
π DNS (Domain Name System)
Port: 53
Use: Translates domains (e.g., google.com β IP)
Queries: A, AAAA, MX, CNAME
Protocol: UDP (mostly), TCP for larger transfers
TCP/IP Layer: Application Layer
π TCP (Transmission Control Protocol)
Connection-oriented, reliable
Uses three-way handshake (SYN, SYN-ACK, ACK)
Ensures:
Packet ordering
Retransmission of lost packets
Congestion & flow control
TCP/IP Layer: Transport Layer
π UDP (User Datagram Protocol)
Connectionless, fast, lightweight
No ordering, no delivery guarantee
Ideal for real-time apps (games, VoIP, video)
TCP/IP Layer: Transport Layer
π IP (Internet Protocol)
Use: Routing packets between networks
Versions: IPv4 (32-bit), IPv6 (128-bit)
Routes based on destination IP
No delivery or ordering guarantees
TCP/IP Layer: Internet Layer
π ICMP (Internet Control Message Protocol)
Use: Diagnostics & error reporting
Used by ping, traceroute
Doesnβt carry user data β only control messages
TCP/IP Layer: Internet Layer
π Ethernet
Use: Wired LAN communication
Identifies devices by MAC address
Uses CSMA/CD to handle collisions
MTU: ~1500 bytes
TCP/IP Layer: Network Access Layer
π Wi-Fi (IEEE 802.11)
Use: Wireless LAN communication
Uses SSID, MAC addresses, and frequencies (2.4 / 5 GHz)
Uses CSMA/CA to avoid collisions
Encryption via WPA2/WPA3
TCP/IP Layer: Network Access Layer
π SSL / TLS (Security Protocols)
Use: Encryption (mostly HTTPS)
Performs a handshake to exchange keys
Uses digital certificates (e.g., from Letβs Encrypt)
TLS 1.3 is current (SSL is deprecated)
TCP/IP Layer: Application Layer
π IP Sec (Internet Protocol Security)
Use: Encrypts IP packets (often in VPNs)
Modes: Transport & Tunnel
Uses:
AH (Authentication Header)
ESP (Encapsulating Security Payload)
TCP/IP Layer: Internet Layer
π SSH (Secure Shell)
Use: Secure remote access
Port: 22
Uses key-based/password authentication
Encrypts all communication
Also supports port forwarding, SCP, SFTP
TCP/IP Layer: Application Layer
Thank-you!
I'm glad you made it to the end of this article. I hope you found it helpful and learned something new. If you did, a Like would mean a lot β it really encourages me to keep writing more!
Feel free to comment below if there's a topic you'd like me to cover in future posts. I'm always open to suggestions and love hearing from readers.
Connect with me on Linkedin
Start your own blogs
Subscribe to my newsletter
Read articles from Akshat Sharma directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Akshat Sharma
Akshat Sharma
I am a Human who trys to learn new stuff every day.