CS-335a: Computer Networking
Tutorial 2: Application Layer
Application Layer Architectures
1. Client-server architecture
● An always-on host (server) services requests
from many other hosts (clients)
● Server has a fixed, well-known address (IP
address)
● Because the server is always on, a client can
always contact the server by sending a packet
to the server’s IP address
● Clients do not communicate directly with each
other
● E.g. Web, FTP, e-mail
2
Application Layer Architectures
2. Peer-2-Peer architecture
● No always-on server
● Arbitrary end systems directly communicate
(peers)
● Peers request service from other peers, provide
service in return to other peers
● Peers are desktops and laptops controlled by
users
● P2P architectures have self-scalability
● E.g. BitTorrent, Skype
3
Transport Services Available to Applications
Application Layer
When you develop an application, which of the available
transport-layer protocols should you choose ? Transport Layer
Network Layer
Transport Layer Protocols provide:
Link Layer
i) Reliable data transfer
Physical Layer
(e.g file transfer, web transactions)
ii) Throughput
(e.g. multimedia applications are bandwidth sensitive)
iii) Timing
(e.g., Internet telephony, interactive games) require low delay to be “effective”
iv) Security
(e.g. encryption of data, end-point authentication)
4
Transport Services Provided by the Internet
TCP: UDP:
➔ reliable transport between sending and ➔ unreliable data transfer
receiving process between sending and
receiving process
➔ flow control: sender won’t overwhelm
receiver ➔ does not provide:
reliability, flow control,
➔ congestion control: throttle sender when
congestion control, timing,
network overloaded
throughput guarantee,
➔ connection-oriented: setup required security, or connection
between client and server processes setup.
➔ does not provide: timing, minimum
throughput guarantee, security
5
Application Layer Protocol
An application-layer protocol defines how an application’s processes, running on
different end systems, pass messages to each other.
In particular, an application-layer protocol defines:
1. The types of messages exchanged, for example, request messages and response
messages
2. The syntax of the various message types, such as the fields in the message and how
the fields are delineated
3. The semantics of the fields, that is, the meaning of the information in the fields
4. Rules for determining when and how a process sends messages and responds to
messages
6
HTTP (HyperText Transfer Protocol): Overview
HTTP is implemented in two programs (client-server architecture used by the Web):
● client: browser that requests, receives, (using HTTP protocol) and “displays”
Web objects
● server: Web server sends (using HTTP protocol) objects in response to
requests
Web objects:
● a web page consists of objects, each of which can be stored on different
Web servers
● an object can be: HTML file, JPEG image, Java applet, audio file etc.
● web page consists of base HTML-file which includes several referenced
objects (addressable by a URL)
7
HTTP: Overview
HTTP uses TCP:
● client initiates TCP connection (creates socket)
to server, port 80
● server accepts TCP connection from client
● HTTP messages exchanged between browser
and Web server
● TCP connection closed
HTTP is stateless:
● If a client asks for the same object twice, the server re-sends the object, as
it has completely forgotten what it did earlier
8
HTTP: Persistent vs Non-Persistent Connections
Non-persistent HTTP: each request/response pair is sent over a separate TCP
connection.
Persistent HTTP: each request/response pair is sent over the same TCP
connection.
● By default HTTP uses persistent connections (with pipelining), but clients
and servers can be configured to use non-persistent connections.
9
Non-Persistent HTTP Example
[Link]
Suppose this webpage consists of:
- 1 base HTML file
- 5 references to JPEG images
- 5 references to other HTML files
➔ Total: 11 objects
10
Non-Persistent HTTP Example
1. Client process initiates a TCP connection to the server [Link] (port
80).
2. Client sends an HTTP request message to the server via its socket. The request
message includes the path name /someDepartment/home .index.
3. Server process receives the request message via its socket, retrieves the object
/someDepartment/[Link], encapsulates the object in an HTTP response
message, and sends the response message to the client via its socket.
4. Server process tells TCP to close the TCP connection.
5. The HTTP client receives the response message. The TCP connection terminates.
The client extracts the file from the response message, examines the HTML file, and
finds references to the 5 JPEG and 5 HTML objects.
6. Steps 1-4 are then repeated for each of the 10 referenced objects.
➔ 11 TCP connections in total ! 11
Client Server
Round-Trip Time (RTT)
RTT: the time it takes for a small packet to
travel from client to server and then back
to the client.
RTThandshake
RTT includes packet-propagation delays,
packet queuing delays in intermediate HTTP request +
routers and switches, and ACK
packet-processing delays
Total response time = RTT1
RTThandshake + RTT1 + Transmission Delay
➔ What is the total response time in the previous
example ?
12
Persistent HTTP - Pipelining
● The server leaves the TCP connection open after sending a response.
● Subsequent requests and responses between the same client and server can be sent
over the same TCP connection.
● These requests can be made
i. Sequentially
Total transmission time = RTThandshake + (RTT + Transmission Delay) * Nobjects
ii. back-to-back, without waiting for replies from the server (pipelining)
Total transmission time = RTThandshake + RTT + Transmission Delay
13
HTTP Message Format
14
HTTP Request
GET /somedir/[Link] HTTP/1.1<cr><lf>Host:
[Link]<cr><lf> Connection: close<cr><lf>User-agent:
Mozilla/5.0<cr><lf>Accept-language: fr <cr><lf><cr><lf>
GET /somedir/[Link] HTTP/1.1
Host: [Link]
Connection: close
User-agent: Mozilla/5.0
Accept-language: fr
<blank line>
15
HTTP Request
method URL HTTP version
where to GET /somedir/[Link] HTTP/1.1 request line
find object Host: [Link]
Connection: close
Non-persistent
User-agent: Mozilla/5.0 header lines
connection !
Accept-language: fr
<blank line>
16
HTTP Response
HTTP status
version status message
code
server will HTTP/1.1 200 OK status line
close TCP
connection Connection: close
Date: Tue, 18 Aug 2015 [Link] GMT
when server Server: Apache/2.2.3 (CentOS) header lines
created Last-Modified: Tue, 18 Aug 2015 [Link] GMT
response
Content-Length: 6821
when the
Content-Type: text/html
object was
created or <data> entity body
last
modified
17
Web Caching
Goal: satisfy client requests without involving origin server
● user configures browser to point to a (local) Web cache
● Web cache (or proxy server): network entity that satisfies HTTP requests on the behalf
of an origin Web server. The Web cache has its own disk storage and keeps copies of
recently requested objects in this storage
● browser sends all HTTP requests to cache
○ if object in cache: cache returns object to client
○ else cache requests object from origin server, caches received object, then returns
object to client
● A Web cache acts as both server and client
18
Electronic Mail in the Internet: Overview
Three major components:
● user agents: allow users to read, reply to,
forward, save, and compose messages
(e.g. Microsoft Outlook)
● mail servers: where message are placed
● Simple Mail Transfer Protocol (SMTP):
transfers messages from senders’ mail
servers to the recipients’ mail servers
19
E-mail
How will Alice send an e-mail to Bob ?
1. Alice composes her email
2. Her user agent sends the message to her mail server
3. The message is placed in the mail server’s outgoing
message queue
4. Bob’s user agent retrieves the message from his mailbox
in his mail server
A user’s mail server contains:
● Mailbox: maintains the messages that have been sent to them
● Message queue: holds outgoing messages (until they are sent to the recipient)
20
SMTP
● Principal application-layer protocol for Internet electronic mail
● Uses TCP (reliable data transfer)
● Uses persistent connections
● Has two sides:
i) client side: executes on the sender’s mail server
ii) server side: executes on the recipient’s mail server
● Both the client and server sides of SMTP run on every mail server
➔ SMTP transfers messages from senders’ mail servers to the recipients’ mail servers
21
Mail Access Protocols
● Bob’s user agent can’t use SMTP to obtain the messages because obtaining the
messages is a pull operation, whereas SMTP is a push protocol
● Instead, Bob can use email access protocols such as POP3, IMAP or HTTP
22
Web-based E-mail
● User agent is an ordinary Web browser
● User communicates with its remote mailbox via HTTP
● When a recipient wants to access a message in their mailbox, the e-mail message is
sent from the recipients mail server to the recipients browser using HTTP rather than
POP3 or IMAP
● When a sender wants to send an e-mail message, the e-mail message is sent from
the senders browser to the senders mail server over HTTP rather than over SMTP
● The senders mail server still sends messages to, and receives messages from, other
mail servers using SMTP.
23
FTP (File Transfer Protocol)
● Application layer protocol that uses TCP
● Used to transfer files between a local and a remote host
● To transfer a file, FTP uses to parallel connections (channels):
i) Control channel: controls the conversation between the two hosts
(e.g. user identification, password, commands to change the remote directory, commands to
retrieve and store files, etc.)
ii) Data channel: transmits the file content
24
FTP Session
● Client initiates a control TCP connection with the server side and sends control
information
● When the server receives this, it initiates a data connection to the client side (only
one file can be sent over one data connection)
● Control connection remains active throughout the user session
25