Loading W Code...
HTTP/HTTPS, DNS, DHCP, SMTP, FTP, SSH & TCP vs UDP Deep Dive
Network Protocols: Standardized rules defining how data is formatted, transmitted, and received across networked hardware.
Application Layer
HTTP is the stateless application-layer protocol powering web communications. HTTPS wraps raw HTTP streams inside an encrypted TLS (Transport Layer Security) tunnel to prevent eavesdropping and man-in-the-middle attacks.
GET: Retrieves resources without modifying server state (Idempotent).POST: Submits data payloads to create new server resources.PUT: Replaces target resources entirely with the request payload.PATCH: Applies partial modifications to existing resources.DELETE: Removes target resources from the server.2xx (Success): 200 OK, 201 Created, 204 No Content3xx (Redirection): 301 Moved Permanently, 304 Not Modified4xx (Client Error): 400 Bad Request, 401 Unauthorized, 404 Not Found5xx (Server Error): 500 Internal Server Error, 503 Service Unavailable// HTTP/1.1 Request Payload Example
GET /api/v1/courses HTTP/1.1
Host: api.wcode.edu
User-Agent: WCodeClient/2.0
Authorization: Bearer eyJhbGciOiJIUzI1Ni...
Accept: application/json
// Server Response Payload
HTTP/1.1 200 OK
Content-Type: application/json
Cache-Control: max-age=3600
{"status": "success", "courses": ["DSA", "System Design", "Networks"]}Application Layer
Computers communicate using numerical IP addresses (104.21.32.88), but humans prefer human-readable domain names (wcode.edu). DNS operates over Port 53 (primarily UDP for fast lookups, TCP for zone transfers) to resolve hostnames to IP addresses.
| Record Type | Format | Functionality |
|---|---|---|
| A | IPv4 Address | Maps domain name to 32-bit IPv4 address |
| AAAA | IPv6 Address | Maps domain name to 128-bit IPv6 address |
| CNAME | Canonical Name | Alias pointing one hostname to another canonical domain |
| MX | Mail Exchanger | Directs domain email traffic to mail server IP |
| TXT | Text Data | Stores domain verification, SPF, and DKIM keys |
# Command-Line DNS Query via dig & nslookup
$ dig +noall +answer A wcode.edu
wcode.edu. 300 IN A 104.21.32.88
$ nslookup -type=MX wcode.edu
Server: 8.8.8.8
Address: 8.8.8.8#53
wcode.edu mail exchanger = 10 mail.wcode.edu.Application Layer
Imagine plugging a new smartphone into a home Wi-Fi router. Instead of manually entering your IP address, subnet mask, and gateway IP, DHCP automatically assigns network configuration settings dynamically.
DHCPDISCOVER on UDP Port 67 asking for an IP.DHCPOFFER).DHCPREQUEST).DHCPACK).# Inspecting Client DHCP Lease via Linux dhclient
$ sudo dhclient -v eth0
Internet Systems Consortium DHCP Client 4.4.1
Listening on LPF/eth0/aa:bb:cc:11:22:33
Sending on LPF/eth0/aa:bb:cc:11:22:33
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 3
DHCPOFFER of 192.168.1.105 from 192.168.1.1
DHCPREQUEST for 192.168.1.105 on eth0 to 255.255.255.255 port 67
DHCPACK of 192.168.1.105 from 192.168.1.1
bound to 192.168.1.105 -- renewal in 41235 seconds.Application Layer
Electronic mail delivery relies on a combination of push and pull protocols:
// Raw SMTP Telnet Communication Session
$ telnet mail.wcode.edu 25
250 mail.wcode.edu Simple Mail Transfer Service Ready
EHLO client.wcode.edu
250-mail.wcode.edu Hello client.wcode.edu
250-SIZE 52428800
250-AUTH LOGIN PLAIN
MAIL FROM:<user@wcode.edu>
250 2.1.0 Sender OK
RCPT TO:<dest@example.com>
250 2.1.5 Recipient OK
DATA
354 Start mail input; end with <CR><LF>.<CR><LF>
Subject: W Code System Notification
Hello, your build finished successfully.
.
250 2.0.0 Message accepted for deliveryApplication Layer
FTP uses separate control (Port 21) and data channels (Port 20 or passive ports). SFTP runs entirely over SSH (Port 22), encrypting both authentication credentials and data transfers into a single secure channel.
| Feature | FTP (File Transfer Protocol) | SFTP (SSH File Transfer Protocol) |
|---|---|---|
| Port | Port 21 (Control), Port 20 (Data) | Port 22 (Single Encrypted Stream) |
| Security | Plaintext Credentials & Payload | SSH AES-256 Encrypted |
| Firewall Setup | Complex (Requires 2 separate ports) | Simple (Single Port 22) |
# Secure File Transfer via SFTP CLI
$ sftp -i ~/.ssh/id_ed25519 deploy@server.wcode.edu
Connected to server.wcode.edu.
sftp> put build.tar.gz /var/www/releases/
Uploading build.tar.gz to /var/www/releases/build.tar.gz
build.tar.gz 100% 45MB 15.2MB/s 00:03Application Layer
SSH (Secure Shell) provides encrypted command-line access over Port 22 using public key cryptography. Telnet (Port 23) sends all keystrokes in unencrypted plaintext, making it obsolete for modern production environments.
~/.ssh/id_ed25519) instead of passwords.ssh -L).# Passwordless SSH Authentication & Remote Tunneling
$ ssh-keygen -t ed25519 -C "dev@wcode.edu"
$ ssh-copy-id -i ~/.ssh/id_ed25519.pub user@server.wcode.edu
# Local Port Forwarding (Connect local port 5432 to remote PostgreSQL)
$ ssh -L 5432:127.0.0.1:5432 user@db.wcode.eduTransport Layer
The two bedrock protocols of the Transport Layer dictate how data payloads move across networks:
| Feature | TCP (Transmission Control Protocol) | UDP (User Datagram Protocol) |
|---|---|---|
| Connection Type | Connection-Oriented (3-Way Handshake) | Connectionless (No handshake) |
| Reliability | Guaranteed in-order delivery with ACKs | Best-effort delivery (No ACKs) |
| Header Overhead | 20 – 60 Bytes | 8 Bytes |
| Primary Use Cases | Web (HTTP/HTTPS), SSH, Email (SMTP), SQL | Streaming Video, Gaming, DNS, VoIP |
// C POSIX Socket Instantiation for TCP vs UDP
#include <sys/socket.h>
// 1. TCP Socket (Byte Stream, Connection-Oriented)
int tcp_fd = socket(AF_INET, SOCK_STREAM, 0);
// 2. UDP Socket (Datagram Stream, Connectionless)
int udp_fd = socket(AF_INET, SOCK_DGRAM, 0);