Application Layer Overview

Chapter 2: Application Layer

Overview of Application Layer

  • Goals:

    • Understand conceptual and implementation aspects of application-layer protocols:

      • Transport-layer service models

      • Client-server paradigm

      • Peer-to-peer (P2P) paradigm

    • Learn about popular application-layer protocols and infrastructure:

      • HTTP

      • SMTP, IMAP

      • DNS

      • Video streaming systems, CDNs

    • Programming network applications using socket API.

Types of Network Applications

  • Examples of network applications include:

    • Social media

    • Web services

    • Text messaging

    • Email

    • Multimedia network games

    • Streaming video platforms (YouTube, Hulu, Netflix)

    • Peer-to-peer file sharing

    • Voice over IP (VoIP)

    • Real-time video conferencing (e.g., Zoom)

    • Internet search engines

    • Remote login services.

Network Application Design

  • Principles:

    • Network applications consist of software that runs on end systems and communicates over a network.

    • Example: Web server software communicates with browser software.

    • Rapid app development is facilitated because applications reside on end systems rather than network-core devices, which do not run user applications.

Client-Server Paradigm
  • Server:

    • Always-on host, usually with a permanent IP address.

    • Often located in data centers for scaling purposes.

  • Clients:

    • Contact and communicate with servers.

    • Can be intermittently connected and often have dynamic IP addresses.

    • Do not communicate directly with each other.

    • Examples include HTTP, IMAP, and FTP.

Peer-to-Peer Architecture
  • Characteristics:

    • No always-on server (arbitrary end systems communicate directly).

    • Peers request services from other peers and provide services in return.

    • Self-scaling as new peers add service capacity and demand.

    • Examples include P2P file sharing protocols like BitTorrent.

Communication Between Processes

  • Process: A program currently executing on a host.

  • Processes on the same host use inter-process communication (defined by the Operating System).

  • Processes on different hosts communicate via message exchanges.

    • Client Process: Initiates communication requests.

    • Server Process: Waits for incoming requests from clients.

Sockets
  • Sockets serve as endpoints for sending and receiving messages.

  • Analogous to doors:

    • The sending process pushes messages out through its socket.

    • The transport infrastructure is responsible for delivering the message to the corresponding socket on the receiving end.

Addressing Processes

  • To receive messages, each process must have a unique identifier:

  • Hosts have a unique 32-bit IP address.

  • The identifier for a process includes both the IP address and a port number associated with the process.

  • Examples of port assignments:

    • HTTP server: 80

    • Mail server: 25

  • Both the host’s IP address and port number are crucial for distinguishing between processes, as multiple processes can run on the same host.

Application-Layer Protocols

  • An Application-Layer Protocol defines:

    • Types of messages exchanged (e.g., request/response).

    • Message syntax (fields and their delineation).

    • Message semantics (meaning of the fields).

    • Rules governing when and how processes send and respond to messages.

  • Open Protocols:

    • Defined in RFCs and widely accessible for interoperability (e.g., HTTP, SMTP).

  • Proprietary Protocols:

    • Restricted to specific applications (e.g., Zoom).

Transport Service Requirements
  • Applications may have diverse transport service requirements:

    • Data Integrity: Apps like file transfer require 100% reliable data transfer, while others (e.g., audio) can tolerate some loss.

    • Timing: Apps require low delay (e.g., Internet telephony, interactive games) for effective performance.

    • Throughput: Some apps (e.g., multimedia) require minimum throughput levels essential for effectiveness, while others (elastic apps) adapt to available bandwidth.

    • Security: Protocols may require encryption and data integrity measures.

Common Application Requirements
  • File Transfer/Download:

    • Loss: No loss tolerated

    • Throughput: Elastic

    • Time-sensitive: No

  • Email:

    • Loss: No loss tolerated

    • Throughput: Elastic

    • Time-sensitive: No

  • Web Documents:

    • Loss: No loss tolerated

    • Throughput: Elastic

    • Time-sensitive: No

  • Real-Time Audio/Video:

    • Loss: Loss-tolerant

    • Throughput: Specific ranges defined (e.g., audio: 5Kbps-1Mbps, video: 10Kbps-5Mbps)

    • Time-sensitive: Yes

Internet Transport Protocols

  • TCP (Transmission Control Protocol):

    • Reliable transport between sending and receiving processes.

    • Implements flow control and congestion control.

    • Connection-oriented with setup phases.

    • Does not provide timing, throughput guarantees, or inherent security.

  • UDP (User Datagram Protocol):

    • Unreliable data transfer between sending and receiving processes.

    • Offers no reliability, flow control, congestion control, timing/data throughput guarantees, security, or connection establishment.

Application Layer Protocol Use Cases

  • Common applications and associated transport protocols:

    • File Transfer/Download:

    • Protocol: FTP

    • Transport: TCP

    • Email:

    • Protocol: SMTP

    • Transport: TCP

    • Web Documents:

    • Protocol: HTTP

    • Transport: TCP or UDP

    • Internet Telephony:

    • Protocol: SIP, RTP

    • Transport: TCP or UDP

    • Streaming Audio/Video:

    • Protocol: DASH, WOW

    • Transport: TCP or UDP

Security in TCP and UDP

  • Standard TCP and UDP sockets are unencrypted.

  • Transport Layer Security (TLS) provides:

    • Encrypted TCP connections

    • Data integrity and endpoint authentication

    • Implemented at application level with TLS libraries over TCP.

Web and HTTP

  • Web Page Composition:

    • Composed of objects, which may reside on different web servers.

    • Objects include HTML files, JPEG images, etc.

  • HTTP Overview:

    • Hypertext Transfer Protocol (HTTP) is the application-layer protocol for the web.

    • Based on the client/server model where browsers (clients) request and receive web objects from web servers.

    • Types of HTTP Connections:

    • Non-persistent HTTP:

      • Opens TCP connection for a single object; closes afterwards.

    • Persistent HTTP:

      • Keeps TCP connection open for multiple objects, reducing overhead.

HTTP Request Structure

  • Request Message Format:

    • Two types of messages: requests and responses.

    • Request messages are in ASCII format and consist of a request line, headers, and optional body.

    • Example Request:

    • `GET /index.html HTTP/1.1
      Host: www-net.cs.umass.edu

`

  • Response Message Structure:

    • Contains a status line, headers, and the body (e.g., requested HTML).

HTTP Status Codes

  • Common HTTP response status codes:

    • 200 OK: Request succeeded.

    • 301 Moved Permanently: Resource moved, new location specified.

    • 400 Bad Request: Client request not understood.

    • 404 Not Found: Requested resource doesn't exist.

    • 505 HTTP Version Not Supported: Server does not support HTTP version.

Cookies for State Management

  • Cookies are used to maintain user state across multiple HTTP transactions.

    • Consists of:

    • Cookie header line in server response

    • Cookie header line in subsequent requests from client

    • Cookie file managed by client browser

    • Backend storage for cookie ID on web server.

  • Applications of Cookies:

    • User authentication, shopping cart state preservation, personalized recommendations.

    • Privacy Issues:

    • Cookies may track users across websites; affect privacy.

Domain Name System (DNS)

  • Purpose: Resolves human-readable hostnames to IP addresses.

  • Distributed hierarchical architecture enhances reliability and scalability.

  • Typical DNS query flow:

    • A client queries a local DNS server, which may cache results and potentially query authoritative name servers as needed.

DNS Records
  • Types of DNS Records:

    • A Record: Maps hostnames to IP addresses.

    • CNAME: Canonical name records for aliases.

    • MX Record: Mail exchange records directing email messages for a domain.

Streaming Video and Content Distribution Networks (CDNs)

  • Challenges of Video Streaming: High bandwidth consumption (e.g., Netflix, YouTube accounts for 80% of residential ISP traffic).

    • Solution: Use CDNs for distributing content across networks, distributing load.

Multimedia Implementation
  • Video is composed of frames at fixed rates (e.g., 24 frames/sec).

  • Encoding methods reduce data rates:

    • Spatial Coding: Compresses pixel data within frames.

    • Temporal Coding: Compresses data between successive frames.

Socket Programming

  • Goal: Build client/server applications using sockets.

  • Socket Types:

    • UDP sockets for unreliable communication (datagrams).

    • TCP sockets for reliable, stream-oriented communication.

Example Programs
  • The provided examples illustrate socket-based interactions, sending data from clients to servers and vice versa through UDP and TCP.

HTTP Overview
  • Hypertext Transfer Protocol (HTTP) is the application-layer protocol for the web.

  • Based on the client/server model where browsers (clients) request and receive web objects from web servers.

  • Versions of HTTP:

    • HTTP/1.1:

    • Introduced in 1999 as an improvement over HTTP/1.0.

    • Persistent connections by default: allows multiple requests and responses over a single TCP connection, reducing latency and improving performance.

    • Chunked transfer encoding: allows dynamically generated content to be sent to the client while being generated; enables streaming and better handling of large resources.

    • Introduced additional caching mechanisms.

    • Improved handling of multiple clients.

    • HTTP/2:

    • Established to address performance issues of HTTP/1.1.

    • Introduced multiplexing, allowing multiple requests and responses to be sent in parallel over the same connection without blocking.

    • Header compression reduces overhead, optimizing the transmission of header metadata.

    • Server push feature allows the server to send resources to the client before they are explicitly requested, speeding up page load times.

    • HTTP/3:

    • Built on QUIC (Quick UDP Internet Connections), addressing issues like latency and loss recovery.

    • Multiplexing at the application layer, eliminating head-of-line blocking seen in HTTP/2 over TCP.

    • QUIC employs encryption by default, providing better security.

    • Faster connection establishment due to reduced round-trip time.

Web Caching
  • Caching allows storing copies of frequently requested resources, reducing server load and latency for users.

  • Mechanisms:

    • Caches can be at client, intermediary (e.g., proxy servers), or server levels.

    • Cache control headers instruct how and for how long content should be cached.

    • Caching enhances performance by serving cached responses without needing to contact the server for every request, particularly valuable for static content.

QUIC
  • QUIC is a transport layer network protocol developed by Google to enhance performance and security.

  • Utilizes UDP instead of TCP: minimizes latency and improves connection establishment.

  • Incorporates features like:

    • Multiplexing: allows concurrent streams without head-of-line blocking.

    • Forward error correction: helps mitigate packet loss effects without needing to retransmit.

    • Connection migration: maintains connections while switching networks (e.g., from cellular to Wi-Fi).

Email is a widely used application for exchanging messages over the Internet. It operates on a client-server model, where email clients send requests to email servers to send and receive messages. The Simple Mail Transfer Protocol (SMTP) is the protocol used for sending emails across networks. It defines how email messages are transmitted from client to server and between servers. SMTP operates over TCP and is a text-based protocol that consists of a set of commands and replies. Key features of SMTP include:

  • Message Transmission: SMTP typically handles the sending of plain text and a limited set of encoded attachments (like images and documents).

  • User Interaction: SMTP requires an outgoing mail server and relies on a mail client to initiate email transmission.

  • Delivery Attempts: SMTP servers will attempt to deliver messages to the recipient's server, queuing them if necessary in case of temporary failures.

  • Error Handling: SMTP includes mechanisms for reporting delivery failure, such as undeliverable messages.

Overall, SMTP is crucial for the functioning of email communication, allowing users to exchange messages quickly and efficiently.