Application Layer in Computer Networks
Overview
The application layer enables networked applications by facilitating communication between processes. It provides the interface through which users interact with network services.
Interaction Models
Client-Server (C/S)
- Involves two roles: client (requester) and server (responder).
- Servers run continuously, listen on well-known ports (e.g., port 80 for HTTP), and have static IP addresses.
- Scalability is often addressed using server clusters or load balancers to handle high request volumes.
Peer-to-Peer (P2P)
- No fixed client or server roles; each node acts as both consumer and provider of resources.
- Offers high scalability and lower infrastructure costs compared to centralized models.
- Commonly used in file-sharing (e.g., BitTorrent) and decentralized applications.
Dynamic Host Configuration Protocol (DHCP)
DHCP automates IP address assignment and network configuration when a device joins a network.
- Uses UDP: client on port 68, server on port 67.
- Initial client IP is
0.0.0.0before assignment. - Key message types:
DHCPDISCOVERDHCPOFFERDHCPREQUESTDHCPACK/DHCPNAKDHCPRELEASE
- DHCP relay agents (often routers) forward requests across subnets to central DHCP servers.
Domain Name System (DNS)
DNS translates human-readable domain names (e.g., example.com) into IP addresses using a distributed, hierarchical database.
Naming Rules
- Name are case-insensitive strings separated by dots (e.g.,
www.example.com). - Leftmost label is the most specific; rightmost is the top-level domain (TLD).
- Each label ≤ 63 characters; total name ≤ 253 characters.
Domain Types
- Top-Level Domains (TLDs):
- Country-code (ccTLD):
.cn,.uk,.de - Generic (gTLD):
.com,.org,.net,.edu, etc. - Infrastructure:
.arpa(used for reverse DNS lookups)
- Country-code (ccTLD):
- Second-level domains under country TLDs are managed nationally (e.g.,
.gov.cn,.ac.uk).
DNS Operation
- Uses UDP port 53 (TCP for large responses).
- Four server types:
- Root servers: Know all TLD server addresses.
- TLD servers: Manage second-level domains under their TLD.
- Authoritative servers: Hold definitive records for specific domains.
- Local (recursive) resolver: Acts on behalf of clients, queries the hierarchy.
- Resolution methods:
- Recursive: Resolver handles entire lookup (heavy server load).
- Iterative: Each server refers client to next level (preferred).
- Caching improves performance; TTL typically set to 1–2 days.
File Transfer Protocol (FTP)
FTP enables reliable file transfer between hosts over a network.
- Uses TCP: control connection on port 21, data connection on port 20 (active mode) or negotiated port (passive mode).
- Two parallel connections:
- Control: Persistent session for commands (e.g.,
USER,PWD,RETR). - Data: Created per transfer, closed afterward.
- Control: Persistent session for commands (e.g.,
- Supports file type specification, directory navigation, and access permissions.
Email Systems
Email relies on a C/S architecture with three components:
- User Agent (UA): Client software (e.g., Outlook, Thunderbird).
- Mail Server: Stores and forwards messages.
- Protocols:
- SMTP (port 25): Sends mail between servers and from UA to server. Supports only ASCII; MIME extands it for binary/Unicode content.
- POP3 (port 110): Downloads mail to local device (usually deletes from server).
- IMAP (port 143): Synchronizes mailbox state across devices; mail remains on server.
Web-Based Email
Accessed via browser (e.g., Gmail, Outlook Web). No dedicated UA needed—HTTP(S) handles all communication with the mail server.
World Wide Web (WWW)
The WWW is a distributed information system built on HTTP, HTML, and URLs.
URL Structure
<scheme>://<host>[:<port>]/<path>
Example: https://www.example.com:443/index.html
Web Technologies
- HTML: Defines document structure.
- CSS: Controls presentation and layout.
- JavaScript: Enables dynamic behavior.
Hypertext Transfer Protocol (HTTP)
HTTP defines how browsers and servers exchange web resources.
- HTTP/1.0: Non-persistent connections (new TCP per request).
- HTTP/1.1: Persistent connections by default (reuses TCP).
- Text-based protocol using ASCII.
Request Message Format
Method SP Request-URI SP HTTP-Version CRLF
Header: Value CRLF
...
CRLF
[Message Body]
Response Message Format
HTTP-Version SP Status-Code SP Reason-Phrase CRLF
Header: Value CRLF
...
CRLF
[Message Body]
Cookies
Cookies store stateful data (e.g., session IDs, preferences) on the client side, enabling servers to recognize returning users despite HTTP’s stateless nature.
Web Caching and Proxy Servers
Web caches (including proxy servers) store copies of recently accessed resources locally. On subsequent requests, they serve cached content if valid, reducing latency and bandwidth usage. Proxies act as intermediaries between clients and origin servers.