A2.1.4 — Network Protocols
What is a Protocol?
A set of rules and standards defining how data should be structured, transmitted, and received across a network. Protocols determine format, timing, sequencing, and error checking.
- Stateful protocol: Maintains information about the client-server session across multiple requests and responses.
- Stateless protocol: Each request is treated independently — no memory of previous interactions. HTTP is stateless.
TCP vs UDP
| Feature | TCP | UDP |
|---|---|---|
| Full name | Transmission Control Protocol | User Datagram Protocol |
| Connection | Connection-oriented (handshake before data) | Connectionless (no handshake) |
| Reliability | Guaranteed delivery, ordered, error-checked | No guarantee — packets may be lost or arrive out of order |
| Speed | Slower — overhead of connection setup and acknowledgements | Faster — no overhead |
| Use when | Data integrity matters — every packet must arrive | Speed matters — occasional loss is acceptable |
| Examples | Web browsing, email, file transfers, banking | Video streaming, online gaming, VoIP, live broadcasts |
TCP key features:
- Handshake process: SYN → SYN-ACK → ACK before data transfer.
- Flow control: Prevents network congestion by controlling data rate.
- Acknowledgements: Receiver confirms each packet received. Lost packets are retransmitted.
HTTP and HTTPS
HTTP — Hypertext Transfer Protocol
- Foundational protocol for data communication over the WWW.
- Request/response model: client sends HTTP request (GET, POST), server returns HTTP response.
- Stateless — each request is independent. Session info must be maintained externally (cookies).
- Requests include: method, header (content type, auth info), sometimes a body.
- Responses include: status code, headers, response body.
HTTPS — HTTP Secure
- Extension of HTTP with encryption for security.
- Uses TLS (Transport Layer Security) to encrypt data before sending and decrypt on arrival.
- Even if intercepted during transmission, data is unreadable.
- Indicated by https://
- Combination of asymmetric and symmetric encryption.
- Protects against: eavesdropping, tampering, message forgery.
Cookies and State
- Cookies: Files stored on the client's device that hold state information. Sent with requests to enable stateful communication.
- Allow sessions across multiple HTTP requests — e.g. staying logged in, remembering your cart, time zone preferences.
- HTTP state management: Methods and techniques to maintain the state of a user's interaction across multiple HTTP requests. Cookies are the most common mechanism.
DHCP — Dynamic Host Configuration Protocol
Automatically assigns IP addresses and other essential network configuration parameters to devices when they connect to a network.
- When a device connects, it sends a broadcast query. The DHCP server assigns an IP from a predefined range (scope).
- Also provides: subnet mask, default gateway, DNS server addresses.
- Dynamic allocation: IP assigned for a limited period (lease). Expires and may be reassigned. Good for frequently changing devices (guest Wi-Fi).
- Static allocation: Permanent IP assigned based on MAC address. Used for devices needing a consistent address (servers, printers).
- Subnet mask: 32-bit number that divides an IP address into network and host portions. 1s indicate the network part, 0s indicate the host. Example: 255.255.255.0 = 11111111.11111111.11111111.00000000.
- TCP = reliable, ordered, slower. UDP = fast, no guarantee. Match to use case in exams.
- HTTP = stateless, unencrypted. HTTPS = HTTP + TLS encryption.
- DHCP dynamic = lease expires. DHCP static = based on MAC, permanent. Know the difference.
Summary