π What are Network Protocols?
-
Network Protocols are a set of rules that define how two systems communicate over the internet.
- These rules are organized into layers, each with specific responsibilities.
π Layers of Network Communication (OSI Model)
- Application Layer
- Presentation Layer
- Session Layer
- Transport Layer
- Network Layer
- Data Link Layer
(Only Application and Transport layers are the main focus here.)
π§ Application Layer Protocols
1. Client-Server Model Protocols
- These follow a request-response model: the client sends a request, the server responds.
- Examples:
- HTTP (Hypertext Transfer Protocol)
- Used for accessing web pages.
- Stateless, one-time connection per request.
- Not secure; use HTTPS for encrypted communication.
- FTP (File Transfer Protocol)
- Maintains two connections:
-
Control Connection: persistent, used for commands.
-
Data Connection: temporary, used for actual file transfer.
-
Not secure (no encryption on data connection), hence not preferred today.
- SMTP (Simple Mail Transfer Protocol)
- Used to send emails.
- Works with:
-
IMAP (Internet Message Access Protocol) β reads/accesses mail without deleting, maintains mail on server.
-
POP3 (Post Office Protocol v3) β downloads and deletes mail (now outdated).
- SMTP uses a client-server model:
- User Agent β SMTP Client β Mail Transfer Agent (MTA) β MTA Server β User Agent
2. Peer-to-Peer Model Protocols
- Communication occurs directly between two peers, without a dedicated server.
- Example:
- WebRTC (Web Real-Time Communication)
- Enables real-time communication (video/audio) directly between browsers.
- Uses UDP for low latency.
- Example: Live streaming apps (video may blur if packets are lost, but speed is preferred over reliability).
π WebSockets vs HTTP vs WebRTC
Protocol |
Model |
Connection Type |
Use Case |
HTTP |
Client-Server |
Stateless |
Browsing web pages |
WebSocket |
Client-Server |
Persistent |
Real-time messaging (e.g. WhatsApp) |
WebRTC |
Peer-to-Peer |
Persistent |
Live streaming, video calls |
π Transport Layer Protocols
1. TCP/IP (Transmission Control Protocol / Internet Protocol)
-
Connection-oriented: reliable.
- Data is sent in an ordered fashion.
-
Acknowledgments are sent for every packet.
- Slower due to overhead but reliable.
- Used by:
2. UDP (User Datagram Protocol) / ICMP (Internet Control Message Protocol)
-
Connectionless: faster but unreliable.
- No acknowledgments or packet ordering.
- Used in:
- WebRTC
- Live video/audio streaming
- Advantage: Low latency.
β Security Note
-
FTP is outdated because it lacks encryption on the data connection.
- Prefer HTTPS for secure communication over HTTP.
β
Summary
Feature |
HTTP |
WebSocket |
WebRTC |
Communication Model |
Client-Server |
Client-Server |
Peer-to-Peer |
Connection Type |
Stateless |
Persistent |
Persistent |
Protocol Type |
TCP |
TCP |
UDP |
Used For |
Browsing |
Chat Apps |
Live Streaming |
Reliability |
High |
High |
Low (but fast) |
π§ͺ Real-world Examples
-
HTTP: Visiting a website like Wikipedia.
-
WebSocket: WhatsApp or Slack for chat messaging.
-
WebRTC: Zoom, Google Meet, YouTube Live, etc.
Top comments (1)
try this if you get stuck during the interview. its an AI co-pilot that solves the questions for you so you can focus on the more important part of the interview, the communication part. its also a really good study tool: ghostengineer.com