DEV Community

Cover image for HLD | Network Protocols in Action: How the Internet Communicates
Shubham Sourabh
Shubham Sourabh

Posted on

HLD | Network Protocols in Action: How the Internet Communicates

πŸ“Œ 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)

  1. Application Layer
  2. Presentation Layer
  3. Session Layer
  4. Transport Layer
  5. Network Layer
  6. 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:
    • HTTP
    • HTTPS
    • FTP
    • SMTP

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)

Collapse
 
ghost_engineer_2883a1ca0a profile image
Ghost Engineer

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