A2.1.4 — Network Protocols

← Back to A2.1 overview

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

FeatureTCPUDP
Full nameTransmission Control ProtocolUser Datagram Protocol
ConnectionConnection-oriented (handshake before data)Connectionless (no handshake)
ReliabilityGuaranteed delivery, ordered, error-checkedNo guarantee — packets may be lost or arrive out of order
SpeedSlower — overhead of connection setup and acknowledgementsFaster — no overhead
Use whenData integrity matters — every packet must arriveSpeed matters — occasional loss is acceptable
ExamplesWeb browsing, email, file transfers, bankingVideo 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

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.