DEBRE BERHAN UNIVERSITY
COLLEGE OF COMPUTING
DEPARTMENT OF INFORMATION TECHNOLOGY
Advanced Computer Networking and
Communications
Course Code: CNS 6112
CHAPTER TWO
APPLICATION LAYER
Binyam Tekalign
[Link]@[Link]
PhD student
2018
What Is the Application Layer?
• Highest layer of the Internet protocol stack
• Provides network services directly to end-users and applications
• Implements protocols used by distributed applications
• Examples: HTTP, Web Browsing, Email (SMTP/IMAP/POP3), FTP,
DNS, VoIP, P2P
• Defines message formats, client-server interactions, and behavior of
networked apps.
Why Study the Application Layer?
• It is where most innovation happens
• Web apps, cloud services, streaming, AI services
• Determines user experience, responsiveness, and reliability
• Important for understanding:
• Performance of web systems
• Caching and latency reduction
• Security (TLS, HTTPS)
• Scalability (load balancing, CDNs, P2P)
Key Characteristics of Applications
• Each application protocol defines:
• Type of service needed (reliable, fast, secure)
• Message formats (request/response)
• Stateful or stateless behavior
• Scalability requirements
• Security mechanisms
• Latency tolerance (e.g., VoIP vs. email)
Core Principle
• Network applications run at the network edge and not
inside the network core.
• The Internet core (routers/switches) does NOT run application
code
• Intelligence is at end systems (hosts)
• Applications depend on underlying transport services (TCP/UDP)
Types of Network Applications
•Client–Server Applications
•Web (HTTP/HTTPS), Email, DNS
•Peer-to-Peer Applications
•BitTorrent, Blockchain networks
•Hybrid Architectures
•Streaming services (CDNs + central servers), Cloud gaming
•Real-Time / Multimedia Applications
•VoIP, video conferencing, streaming services
Client–Server Architecture
• Characteristics:
• Servers are always on.
• Client initiates requests
• Server has fixed IP/domain name
• Examples:
• Web (HTTP/HTTPS), Email (SMTP, IMAP), DNS
• Pros:
• Simple, centralized management
• Cons:
• Scalability limitations
• Server can become a bottleneck
Peer-to-Peer (P2P) Architecture
• Characteristics:
• Peers act as clients and servers
• Highly scalable (more peers ⇒ more capacity)
• Examples:
• BitTorrent
• Blockchain networks
• Pros:
• Reduced server cost
• Naturally scalable
• Cons:
• Management complexity
• Security challenges
Hybrid Architectures
• Combine client-server and P2P features.
• Examples:
• Spotify (central server + P2P sharing, historically)
• YouTube/Netflix (CDNs + client playback)
• VoIP (central servers + peer-to-peer call path)
Goal: efficiency + scalability + quality
Sockets: The Door to the Network
• A socket is the API connecting an application to the
network.
• Application writes to socket → goes to transport layer
• Transport layer delivers data to remote socket
• Types:
• TCP socket → reliable byte stream
• UDP socket → message-oriented, no reliability
Addressing Processes in Sockets
• Many service or process could be running in the same server
• To receive message, servers must have identifier.
• A process is addressed by:
• IP Address (host location)
• Port Number (specific application process)
• Examples:
• HTTP → port 80 / 443
• DNS → port 53
• SMTP → port 25
• FTP → port 21
Transport Services Available to Applications
• Applications choose between services offered by TCP or
UDP:
• TCP Services
• Reliable, ordered delivery
• Congestion control
• Flow control
• Connection-oriented
Used by: Web, Email, FTP, SSH
• UDP Services
• Fast, connectionless
• No reliability
• No congestion control
Used by: DNS, VoIP, real-time apps
Application Requirements from Transport
Layer
• Each application requires different features:
• Reliability (Email, file transfer)
• Timing (Real-time audio/video)
• Throughput (Large file downloads)
• Security (HTTPS, TLS encryption)
Transport protocol must match application needs.
Security Considerations
• Applications must ensure:
• Authentication (who are you?)
• Authorization (what can you access?)
• Data integrity
• Confidentiality (encryption)
• Availability (e.g., DoS protection)
Application layer security often uses TLS/HTTPS.
Web and HTTP
• The Web is a distributed information system built on top of the Internet
• Core components:
• Web browsers (clients)
• Web servers (content providers)
• HTTP protocol (communication standard)
• HTML, CSS, JavaScript (content & presentation)
URL (Uniform Resource Locator)
• A URL identifies a resource on the web.
• E.g. scheme://host:port/path?query#fragment
• Examples:
• [Link]
• [Link]
• Components:
• Scheme (http/https)
• Hostname or IP
• Optional port
• Path, query, fragment
HTTP Overview
•HyperText Transfer Protocol
•Application-layer protocol used for Web communication
•Based on a request–response model
•Originally simple: text-based, stateless
•Evolved to support:
•Persistent connections
•Pipelining (deprecated)
•Modern version: HTTP/2 (binary), HTTP/3 (QUIC)
HTTP Message Types
• Two message types:
1. HTTP Request
• Sent by client
• Includes method, headers, and optional body
2. HTTP Response
• Sent by server
• Includes status code, headers, and content body
HTTP Request Structure
• Key components:
• Method: GET, POST, PUT, DELETE, PATCH, OPTIONS
• Request line: method + path + version
• Headers: metadata
• Body: (only in some methods, e.g., POST, PUT)
HTTP Response Structure
• Status line (version + status code + reason)
• Response headers
• Response body (HTML, images, JSON, video, etc.)
• Common status codes:
• 200 (OK)
• 301/302 (Redirect)
• 404 (Not Found)
• 500 (Server Error)
Connection Types in HTTP
• Non-Persistent HTTP (HTTP/1.0)
• Each request-response pair uses a separate TCP connection
• Slow due to repeated TCP handshakes
• Persistent HTTP (HTTP/1.1)
• Single TCP connection used for multiple objects
• “Keep-Alive” improves efficiency
• Browser can parallelize requests (6 connections per domain)
HTTP Cookies
• Used to maintain state over stateless HTTP.
Consist of:
• Cookie value stored in browser
• Server sets cookie with Set-Cookie header
• Browser returns cookie with each request
• Used for:
• Authentication sessions
• Shopping carts
• User tracking
• Personalization
• Security issues:
• Can leak data through cross-site access
• Must use Secure, HttpOnly, SameSite attributes
HTTPS (HTTP Secure)
• HTTPS = HTTP over TLS encryption
Provides:
• Confidentiality
• Authentication (via certificates)
• Data integrity
• Key concepts:
• TLS handshake
• Certificates issued by Certificate Authorities
• Padlock symbol in browsers
• HTTPS is now required by major browsers for many
features (e.g., geolocation, service workers).
Web Server Redirection and Caching
• Redirection occurs when the server instructs the client to
request a different URL.
Used for:
• Website migration
• URL shorteners
• HTTPS enforcement
• Load balancing
• CDN offloading
HTTP Status Codes for Redirection
•Key redirection codes:
Code Meaning Use Case
Domain move, URL
301 Moved Permanently
restructuring
302 Found (Temporary) Temporary move
After POST →
303 See Other
redirect to GET
Preserve method
307 Temporary Redirect
(POST stays POST)
Permanent +
308 Permanent Redirect
preserves method
What Is Web Caching
• Caching stores copies of resources closer to the user to
reduce:
• Latency
• Bandwidth usage
• Server load
• Types of caches:
• Browser cache
• Proxy cache
• CDN cache
• Server-side cache
Browser Cache vs. Proxy Cache
• Browser Cache:
• Local to the user
• Stores visited websites
• Reduces repeated downloads
• Proxy Cache:
• Shared by many users
• Used by ISPs, enterprises
• Good for reducing repeated traffic (e.g., software updates)
CDN Caching
• CDNs store cached copies of content at edge servers.
Benefits:
• Low latency
• Distributed load
• High availability
• Global delivery
• Used heavily for:
• Video streaming
• Large files
• Websites with global audience
Application Layer Protocols
• FTP (File Transport Protocol)
• SMTP
• POP
• IMAP
• DNS
FTP (File Transfer Protocol)
•FTP is a standard protocol for file transfer between client and server
•Uses TCP for reliable transport
•Provides:
•Uploading and downloading
•Directory navigation
•Authentication (username/password)
FTP Architecture
•FTP uses two parallel TCP connections:
•Control connection (port 21)
•Data connection (port 20 or negotiated)
•Control connection is persistent
•Data connection opens per transfer
FTP Limitations
• Credentials sent in clear text
• No encryption
• Vulnerable to sniffing and MITM
Solution: FTPS / SFTP (SSH File Transfer)
SMTP (Simple Mail Transfer Protocol)
•Core protocol for sending email across the Internet
•Default port: 25 (or 587 for submission)
•Uses TCP
•Push protocol (sender → receiver mail server)
SMTP Operation Flow
•Email client sends message to SMTP server
•SMTP server relays to recipient’s server
•Recipient’s mail server stores email
•User retrieves mail using POP3 or IMAP
POP3 (Post Office Protocol v3)
•Used for retrieving email from server
•Typically port 110
•Simple protocol: limited features
•Download-and-Delete
•Email removed from server after download
•Download-and-Keep
•Email stored locally but also kept on server
•Limitations:
•No folder management
•No synchronization between devices
IMAP (Internet Message Access Protocol)
•More advanced than POP3
•Port 143 (or 993 for SSL)
•Keeps mail on server
•Designed for multi-device access (web, mobile, desktop)
IMAP Features
•Server-side folders
•Message flags (seen/unseen, starred)
•Partial download (headers only)
•Sync across devices
•Supports concurrent sessions
POP3 vs IMAP Comparison
Feature POP3 IMAP
Storage Local Server-side
Multiple Devices Poor Excellent
Folder Support No Yes
Sync No Full
Offline Use Excellent Good
DNS (Domain Name System)
• DNS translates domain names → IP addresses
Examples:
• [Link] → [Link]
• Works as the "Internet phonebook"
• DNS uses:
• UDP port 53 (primary)
• TCP port 53 (large responses, zone transfers)
Why DNS Is Needed
•IP addresses change
•Humans prefer names
•Load balancing (same domain → different IPs)
•Redundancy & geo-distribution
DNS Hierarchy
• DNS is distributed and hierarchical:
• Root servers
• TLD (Top-Level Domains) servers (.com, .org, .et)
• Authoritative name servers
• Local/ISP DNS resolvers
Domain Name System (DNS)
• Interaction with DNS Servers
• Root DNS Servers:
• Starting point of the DNS hierarchy.
• They handle the top-level domains (TLDs) such as .com, .org, .net
• Country-code like .et, us or .uk.
• There are 13 sets of root DNS servers.
• The resolver sends the query to the root DNS servers,
• Which respond with information about the TLD servers.
DNS hierarchy
Domain Name System (DNS)
• Interaction with DNS Servers
• Top-Level Domains (TLD) DNS Servers:
• Responsible for handling requests for specific domain extensions (e.g., .com, .org).
• Each TLD has its set of authoritative name servers.
• Direct it to the authoritative DNS servers for the specific domain.
• Authoritative DNS Servers:
• Hold the actual DNS records for specific domains.
• The resolver queries the authoritative DNS servers for the IP address associated
with the requested domain.
• Send the IP address back to the resolver, which, in turn, returns it to the client.
• The client can now use the IP address to connect to the desired resource.
DNS Caching
•DNS responses cached at resolver and browser
•Reduced lookup time
DNS Security Issues
•DNS poisoning
•Cache poisoning
Solutions:
•DNSSEC (cryptographic signatures)
•DNS-over-HTTPS (DoH)
•DNS-over-TLS (DoT)
Socket Programming with TCP/UDP
• Sockets provide the interface between application processes and the
transport layer
• A socket = endpoint for sending/receiving data
• Applications use sockets to communicate over:
• TCP → reliable, connection-oriented
• UDP → fast, connectionless
What Is a Socket?
• A socket is defined by:
• IP Address
• Transport protocol (TCP/UDP)
• Port number
• Two communicating processes form a socket pair.
Client–Server Model in Socket Programming
• Server
• Client
• Create socket
• Create socket
• Bind socket to port
• Connect to server
• Listen for incoming connections
• Send/receive data
(TCP)
• Close connection
• Accept connection
• Read/write data
TCP Socket Characteristics
• Reliable byte-stream communication
• Ordered, without duplication
• Connection-oriented (3-way handshake)
• Stream-based (no message boundaries)
• Used for:
• File transfers
• Web communication
• Emails
• Database connections
UDP Socket Characteristics
•Connectionless
•Message-oriented
•No reliability / ordering
•Lower latency than TCP
•Good for:
•VoIP
•Video conferencing
•Online gaming
•Real-time sensor data
TCP vs UDP Programming Differences
Feature TCP UDP
Connection Yes No
Reliability Built-in Application-managed
Ordering Guaranteed Not guaranteed
Latency Higher Lower
Use Cases Web, FTP, Email VoIP, games, streaming
Application-Level Issues: Why Apps Need Their Own Protocols
• Key Problems at Application Layer (Applications must solve)
• Naming & addressing
• Resource discovery
• Multimedia timing & jitter
• Scalability under heavy load
• Peer coordination (P2P)
• Content distribution efficiency
• Web server performance & caching
Transport/network layers cannot solve these alone.
Naming & Resource Identification
• Applications need human-readable identifiers:
• Hostnames → IPs (DNS)
• Email domains → mail servers (MX)
• Service names → ports/endpoints
Naming provides location independence and simplifies user
access.
Traditional Applications & Naming
• Examples:
• Web browsers → URLs resolved via DNS
• SMTP → MX lookup for mail delivery
• FTP → hostname resolution
• Enterprise apps → LDAP/Active Directory
Problems solved: central management, flexibility, abstraction from IP
changes.
Multimedia Applications
• Multimedia requires handling:
• Low latency (VoIP, gaming)
• Jitter and packet loss
• Synchronization of audio/video
• Adaptive bitrate for streaming
• Compression (H.264, Opus)
Transport alone cannot manage these — application protocols must.
Protocols for Multimedia
• Common application-layer protocols:
• RTP/RTCP — timing, sequencing, jitter management
• SIP — session setup and control
• DASH/HLS — adaptive video streaming
Key features: buffering, error concealment, codec negotiation.
Why P2P & Overlay Networks
• P2P solves scaling and distribution limits:
• No central server bottleneck
• Self-scaling: more peers → more capacity
• Efficient content distribution (BitTorrent)
• Overlay networks provide:
• Logical networks built on top of the Internet
• Custom routing, search, and replication strategies
Examples & Key Concepts
• Examples:
• BitTorrent (chunk-based sharing)
• Blockchain networks (distributed ledger)
• Skype (original P2P voice architecture)
• Key P2P issues:
• Peer discovery
• Churn handling (peers joining/leaving)
• Distributed hash tables (DHTs)
• Security and trust
Web Server Performance Challenges
• Applications must handle high traffic and dynamic content:
• Stateless HTTP design
• Load balancing
• Caching (browser, CDN, reverse proxy)
• Database bottlenecks
• TLS (Transport Layer Security) overhead
• Scalability for millions of users
These require application-layer architectural solutions.
Modern Web Server Architecture
• Key components:
• Front-end servers (Nginx, Apache)
• Application servers ([Link], Django, Spring)
• Reverse proxies
• CDNs for static content
• Microservices and API gateways
• Focus on:
• Horizontal scaling
• Fault tolerance
• Efficient request handling
Transport Layer