Skip to main content

Command Palette

Search for a command to run...

🧠 Network Protocols – Complete Notes

Published
5 min readView as Markdown

🌐 What Are Network Protocols?

Definition:
A network protocol defines a set of rules and conventions that govern how data is transmitted, received, and interpreted between two or more machines over a network.

Think of protocols as the languages computers use to communicate.


🧩 The OSI Model (7 Layers of Networking)

The OSI (Open Systems Interconnection) model organizes network communication into seven layers, each with a distinct role.

Layer No.Layer NameFunctionExamples
7Application LayerUser-facing protocols & appsHTTP, FTP, SMTP, WebSocket, WebRTC
6Presentation LayerData formatting, encryption, compressionSSL/TLS, MIME
5Session LayerManages sessions and connectionsNetBIOS, RPC
4Transport LayerEnsures reliable or fast deliveryTCP, UDP
3Network LayerRouting and addressingIP, ICMP
2Data Link LayerNode-to-node data transferEthernet, PPP
1Physical LayerHardware transmissionCables, NICs, Wi-Fi signals

🧱 Focus Areas (For This Session)

We’ll focus mainly on two key layers:

  1. Application Layer

  2. Transport Layer


🕸️ 1. Application Layer

This is the topmost layer of the OSI model and interacts directly with end-user applications.

It has two main communication models:

🖥️ A. Client–Server Model

In this model:

  • Client requests data or services.

  • Server responds to those requests.

  • Communication is typically unidirectional (client → server).

🔹 Common Protocols:

ProtocolFull FormDescription
HTTP (HyperText Transfer Protocol)Used for web communication (e.g., browsing websites).
FTP (File Transfer Protocol)Used to transfer files between client and server. Has two connections: control and data. ⚠️ Data connection is not secure unless FTPS is used.
SMTP (Simple Mail Transfer Protocol)Used for sending emails between servers.
WebSocketsAllows bi-directional communication between client and server in real-time (used in chat apps, live updates, etc.).

🧠 Example:

  • Web Browser (client) requests a webpage using HTTP from a web server (e.g., Nginx).

  • WhatsApp Web, Telegram Web, and Google Meet signaling use WebSockets to maintain live, two-way connections.


🔄 B. Peer-to-Peer (P2P) Model

In this model:

  • Every node (computer or device) can act as both client and server.

  • Direct communication happens between peers — no central server needed.

  • Generally faster and more scalable for media sharing or real-time communication.

🔹 Common Protocol:

  • WebRTC (Web Real-Time Communication) → Used in Google Meet, Zoom, and WhatsApp video/audio calls.

🧠 Example:

When you make a video call on WhatsApp:

  • Devices communicate using WebRTC for direct peer-to-peer streaming.

  • Signaling may still go through a central server to establish the connection.


🚚 2. Transport Layer

This layer handles the delivery of data between devices — deciding whether to send it reliably (TCP) or quickly (UDP).

⚙️ Protocols

ProtocolTypeCharacteristicsUse Cases
TCP (Transmission Control Protocol)Connection-orientedReliable, ordered, and acknowledged. Ensures every packet reaches its destination in the right order.Web apps, file transfers (HTTP, FTP, SMTP).
UDP (User Datagram Protocol)ConnectionlessFast, lightweight, no error checking or acknowledgment. May lose packets but reduces latency.Live streaming, gaming, voice/video calls (e.g., WhatsApp, YouTube Live).

🧩 Comparison of TCP vs UDP

FeatureTCPUDP
ReliabilityHigh (retransmits lost packets)Low (no retransmission)
OrderingMaintains packet orderNo guarantee
SpeedSlowerFaster
OverheadMoreLess
Use CaseHTTP, FTP, EmailVideo Calls, Gaming, Live Streams

📞 Real-World Examples

ApplicationProtocol UsedDescription
Google MeetWebRTC (over UDP)Real-time video/audio data via P2P + signaling via HTTP/WebSocket
WhatsAppWebRTC + WebSocketsWebSocket for chat, WebRTC for calls
YouTube LiveUDPLow-latency streaming
GmailSMTP + HTTPSMTP for sending, HTTP for UI interaction
FTP ClientFTP (TCP-based)File uploads/downloads

🧭 Diagram (Concept Overview)

(Text-based representation — can generate image if needed)

+-----------------------------------------------------+
|                   Application Layer                 |
| (HTTP, FTP, SMTP, WebSocket, WebRTC, etc.)          |
+-----------------------------------------------------+
|                   Transport Layer                   |
| (TCP - Reliable)       (UDP - Fast, Unreliable)     |
+-----------------------------------------------------+
|                   Network Layer (IP)                |
|                 Handles routing & addressing         |
+-----------------------------------------------------+
|                   Data Link & Physical Layers       |
|               Transmit bits over physical media      |
+-----------------------------------------------------+

🎥 YouTube Playlists

  1. Network Protocols for DevelopersfreeCodeCamp.org

  2. Computer Networking Full CourseTelusko

  3. WebRTC Deep DiveFireship

  4. How WebSockets WorkWeb Dev Simplified

📚 Blogs & Docs

  • MDN Web Docs – HTTP Overview

  • WebRTC Official Guide

  • Real-Time Communication Architecture (Google Developers)


🧩 Key Takeaways

  • Protocols = Rules of communication between systems.

  • Application layer defines what service is provided (e.g., HTTP, WebRTC).

  • Transport layer defines how data is delivered (e.g., TCP or UDP).

  • Client–Server = Centralized control; Peer-to-Peer = Direct, fast communication.

  • Modern apps (Google Meet, WhatsApp) use WebRTC and WebSockets for real-time interaction.