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

Akshat SharmaAkshat Sharma
27 min read

πŸ”Ž 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:

  1. You type google.com in your browser.

  2. Your computer sends a request to Google’s server.

  3. The server processes the request and sends back a response.

βœ… How Does Your Computer Find Google?
The domain google.com is mapped to an IP address like 142.250.190.14. This is similar to finding a phone number by searching someone’s name in your contact list. This process is handled by the Domain Name System (DNS).
βœ… ICANN – The Root Authority
ICANN (Internet Corporation for Assigned Names and Numbers) manages the root of the domain system and delegates control to registrars. When someone registers a domain like google.com, they do it through a domain registrar, which updates the global DNS directory.
βœ… IP Addresses
IP addresses consist of 4 numbers ranging from 0–255. Example: 142.250.190.14

πŸ—‚οΈ 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 IP

  • Tracks 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

PartNameDescription
.comTop-Level Domain (TLD)The highest level domain like .com, .org, .net, etc.
exampleSecond-Level Domain (SLD)The name registered under the TLD (e.g., example.com)
shopSubdomainA category or section of the main domain
blog.shopNested SubdomainA subdomain under another subdomain (optional layers)

πŸ—‚οΈ Few Topics Revision

βœ… LAN
A Local Area Network (LAN) is typically used in your home or office. It connects devices like your phone, laptop, printer, and smart TV within a small area, such as a room, house, or building.
βœ… MAN
A Metropolitan Area Network (MAN) connects multiple LANs across a city or campus. Often used by internet service providers (ISPs) or large organizations. It links offices, data centers, or campuses within the same metropolitan area.
βœ… WAN
The internet itself is the biggest example of a WAN (Wide Area Network) . It connects many smaller networks (LANs and MANs) across the world.
βœ… Topology
refers to the arrangement of computers or devices in a network. It defines how different devices communicate and interact with each other. Below are the Types of Topologies.
βœ… Bus Topology
All devices share a single communication line. Simple but can suffer from congestion if too many devices are added.
βœ… Star Topology
All devices connect to a central hub or switch. Easy to manage and scale but relies on the central hub.
βœ… Ring Topology
Devices are connected in a closed loop. Data travels in one direction until it reaches its destination.
βœ… Mesh Topology
Every device is connected to every other device. Provides high redundancy and fault tolerance but is expensive to implement.
βœ… Tree Topology
A combination of star and bus topologies. Hierarchical structure with multiple levels of devices.
βœ… Hybrid Topology
A mix of two or more topologies. Provides flexibility and can be customized to suit different needs.

πŸ’‘
Let’s first see the Network Model and it’s layers and then we will see an example of End to End , how a message you type and sent travels over internet to reach your friend.

πŸ”Ž 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.

  • 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.

  • 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.

  1. 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
  1. 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!
  1. 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.
  1. 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.
  1. 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!"
  1. 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:

  1. The sender sends a TCP segment and starts the retransmission timer.

  2. The sender waits for an ACK from the receiver.

  3. 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.

  4. The process is repeated until the sender gets the ACK or a maximum number of retries is reached.

FeatureTCP (Transmission Control Protocol)UDP (User Datagram Protocol)
TypeConnection-orientedConnectionless
Handshake3-way handshake (SYN, SYN-ACK, ACK)No handshakeβ€”sends data directly
ReliabilityReliableβ€”ensures delivery and orderUnreliableβ€”no guarantee of delivery or order
AcknowledgmentACKs are sent for every packet receivedNo acknowledgment mechanism
RetransmissionsLost packets are retransmitted automaticallyNo retransmission; application must handle it if needed
Data OrderingGuarantees ordered deliveryNo guarantee of order
Flow ControlUses windowing for flow controlNo flow controlβ€”can overwhelm receiver
Error CheckingExtensiveβ€”includes checksums and reassembly mechanismsMinimalβ€”basic checksum only
SpeedSlower due to overhead of connection, ACKs, and retransmissionsFaster due to low overhead
Use CasesFile transfer, email, web browsing (HTTP, FTP, etc.)Video streaming, VoIP, online gaming, DNS
Real-world AnalogyCertified mailβ€”confirmation of delivery and orderPostcardsβ€”may arrive late, out of order, or not at all
  1. IP Packet Creation

IP Header:
Src IP: 192.168.1.10
Dst IP: 17.172.224.47
TTL: 64
Protocol: TCP

"Data: TCP segment"
  1. 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
  1. 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.
  1. 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
πŸ’‘
Then it travels: β†’ ISP β†’ Internet Backbone β†’ Apple Data Center

πŸ—‚οΈ Part 2: iMessage Server to Your Friends Phone.

  1. 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

  1. 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.

  1. 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.

  1. 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!”
    
  1. 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")
  1. 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"

  1. 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:

PeerChunks Owned
Peer APart 1, Part 4
Peer BPart 2
Peer CPart 3, Part 4
Peer DPart 1, Part 2, Part 3

Now you join as Peer E, aiming to download the full file.

πŸ“‚ Step 3: Downloading Chunks

Your P2P app:

  1. Connects to a tracker or DHT (Distributed Hash Table) to discover which peers have which parts.

  2. 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.

ModelLayer NameRepeater Lives Here?
OSI ModelLayer 1 – Physicalβœ… Yes
TCP/IP ModelNetwork 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

ModelLayer NameDoes Hub Work Here?
OSI ModelLayer 1 – Physical Layerβœ… Yes
TCP/IP ModelNetwork Access Layerβœ… Yes

πŸ“‚ 3 Main Types of Hubs

Hub TypeDescriptionOSI Layer
1️⃣ Passive HubJust connects cables and passes signals without amplificationLayer 1
2️⃣ Active HubBoosts/amplifies the signal before sending it out β€” like a repeater + hubLayer 1
3️⃣ Intelligent HubOffers 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)

ModelLayer NameWorks Here?
OSI ModelLayer 2 – Data Link Layerβœ… Yes
TCP/IP ModelNetwork 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]β”€β”€β”˜
ModelLayer NameWorks Here?
OSI ModelLayer 2 – Data Link Layerβœ… Yes
TCP/IP ModelNetwork 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:

MethodPurposeExample
GETRead/Retrieve data"Get me all blog posts"
POSTCreate new data"Create a new user"
PUTUpdate an entire resource"Update the whole profile info"
PATCHUpdate part of a resource"Just update the profile picture"
DELETEDelete 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 succeeded

  • 201 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 data

  • 401 Unauthorized: Not logged in / missing credentials

  • 403 Forbidden: Logged in but no permission

  • 404 Not Found: Resource doesn’t exist

Server Errors (Issues from the server)
  • 500 Internal Server Error: Server malfunction

  • 502 Bad Gateway: Invalid response from another upstream server

  • 503 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.

HeaderDescription
Content-TypeFormat of the request body (e.g., application/json)
AuthorizationTokens or API keys for authentication
User-AgentInfo 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

ProtocolPurposeTCP/IP Model Layer
SMTP(Simple Mail Transfer Protocol)Used to send emailsApplication Layer
POP3 (Post Office Protocol v3)Used to receive/download emailsApplication 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:

  1. You write an email and hit β€œSend”.

  2. Your client (e.g., Gmail app) connects to Gmail’s SMTP server.

  3. SMTP delivers the email across the internet to the recipient’s email server.

βœ… SMTP Port Numbers

PortDescription
25Default SMTP port (often blocked by ISPs)
465SMTP with SSL (older secure method)
587SMTP 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

PortDescription
110Default POP3 (unencrypted)
995POP3 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.

0
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.