You are on page 1of 54

Application layer: overview

▪ Application layer is the top-most layer of internet protocol stack


(TCP/IP model).
▪ Unit of information is known as message at application layer
▪ Present on the top of Transport layer.
▪ Application layer need not to refer to the actual applications that the
user run on end-systems.
▪ It provides network access to user applications that we use to
communicate and the underlying network over which message is to be
transmitted.
▪ Application layer uses/provides services of Transport layer.
▪ There are 1000 of applications, but only we focus some common
applications. Application Layer: 2-1
Application layer: overview
Application Application layer protocol Underlying Transport layer
protocol

Email SMTP TCP

Remote Terminal Access Telnet TCP

File Transfer FTP TCP

Web HTTP TCP

Domain Name Server DNS UDP

Application Layer: 2-2


Some network apps
▪ social networking ▪ voice over IP (e.g., Skype)
▪ Web ▪ real-time video conferencing
▪ text messaging (e.g., Zoom)
▪ e-mail ▪ Internet search
▪ multi-user network games ▪ remote login
▪ streaming stored video ▪…
(YouTube, Hulu, Netflix)
▪ P2P file sharing Q: your favorites?

Application Layer: 2-3


Creating a network app
application
transport
write programs that: mobile network
network
data link

▪ run on (different) end systems


physical
national or global ISP

▪ communicate over network


▪ e.g., web server software
communicates with browser software
local or
no need to write software for regional ISP

network-core devices home network content


▪ network-core devices do not run user
application
transport
provider
network network datacenter
application
applications data link
physical
transport
network
network

▪ applications on end systems allows


data link
physical

for rapid app development, enterprise


propagation network

Application Layer: 2-4


Client-server paradigm
server: mobile network
▪ always-on host which provides national or global ISP

services to many clients


▪ permanent IP address
▪ often in data centers, for scaling
local or
clients: regional ISP

▪ contact, communicate with server to get service home network content


from server provider
▪ may be intermittently connected network datacenter
network
▪ may have dynamic IP addresses
▪ do not communicate directly with each other
▪ examples: Web-application (host that run web enterprise
browser act as client host and the host that
network
provides service act as server)
Application Layer: 2-5
Peer-peer architecture
▪ no always-on server mobile network
▪ arbitrary end systems directly national or global ISP

communicate
▪ peers request service from other
peers, provide service in return to
other peers local or
regional ISP
• self scalability – new peers bring new
service capacity, as well as new service home network content
demands provider
network datacenter

▪ peers are intermittently connected network

and change IP addresses


• complex management enterprise

▪ example: P2P file sharing network

Application Layer: 2-6


Process Communicating: Client and Sever Process
▪ A network application consists of pairs of processes that send messages to each other over
a network.
▪ Processes on two different end systems communicate with each other by exchanging
messages across the computer network. A sending process creates and sends messages
into the network; a receiving process receives these messages and possibly responds by
sending messages back
▪ For example, in the Web application a client browser process exchanges messages with a
Web server process.
▪ In a P2P file-sharing system, a file is transferred from a process in one peer to a process in
another peer. For each pair of communicating processes, we typically label one of the two
processes as the client and the other process as the server.
▪ With the Web, a browser is a client process and a Web server is a server process.
▪ With P2P file sharing, the peer that is downloading the file is labeled as the client, and the
peer that is uploading the file is labeled as the server.

Application Layer: 2-7


Processes communicating
process: program running clients, servers
within a host client process: process that
initiates communication
▪within same host, two server process: process
processes communicate that waits to be contacted
using inter-process
communication (defined by ▪ note: applications with P2P architectures have
client processes & server processes
OS) ▪ In P2P architecture, a peer can act as both client
and server depending on scenario but
▪processes in different hosts client-server model client always execute client
process and server always execute server
communicate by exchanging
process.
messages
Application Layer: 2-8
Sockets
▪ process sends/receives messages to/from its socket
▪ A process is analogous to a house and its socket is analogous to its door.
▪ sending process shoves message out door
• sending process relies on transport infrastructure on other side of door to
deliver message to socket at receiving process
• two sockets involved: one on each side
▪ A socket is the interface between the application layer and the transport layer
within a host.
application application
proce socket proce controlled by
ss ss app developer

transport transport
network network controlled
link link by OS
Internet
physical physical

Application Layer: 2-9


Addressing processes
▪ to receive messages, process ▪ identifier includes both IP address
must have identifier and port numbers associated with
▪ host device has unique 32-bit process on host.
IP address ▪ example port numbers:
▪ Q: does IP address of host on • HTTP server: 80
which process runs suffice for • mail server: 25
identifying the process? ▪ to send HTTP message to
▪ A: no, many processes www.iiits.ac.in web server:
can be running on • IP address: 103.21.58.130
same host • port number: 443
▪ more shortly…
Application Layer: 2-10
An application-layer protocol defines:
▪ types of messages exchanged, open protocols:
• e.g., request, response ▪ defined in RFCs, everyone
▪ message syntax: has access to protocol
• what fields in messages & definition
how fields are delineated ▪ allows for interoperability
▪ message semantics ▪ e.g., HTTP, SMTP
• meaning of information in proprietary protocols:
fields
▪ e.g., Skype, Zoom
▪ rules for when and how
processes send & respond to
messages
Application Layer: 2-11
What transport service does an app need?
data integrity throughput
▪ some apps (e.g., file transfer, ▪ some apps (e.g., multimedia)
web transactions) require require maximum amount of
100% reliable data transfer throughput to be “effective”
▪ other apps (e.g., audio) can ▪ other apps (“elastic apps”)
tolerate some loss make use of whatever
throughput they get
timing
▪ some apps (e.g., Internet security
telephony, interactive games) ▪ encryption, data integrity,
require low delay to be “effective” …
Application Layer: 2-12
Transport service requirements: common
apps
application data loss throughput time sensitive?

file transfer/download no loss elastic no


e-mail no loss elastic no
Web documents no loss elastic no
real-time audio/video loss-tolerant audio: 5Kbps-1Mbps yes, 10’s msec
video:10Kbps-5Mbps
streaming audio/video loss-tolerant same as above yes, few secs
interactive games loss-tolerant Kbps+ yes, 10’s msec
text messaging no loss elastic yes and no
Application Layer: 2-13
Internet transport protocols services
TCP service: UDP service:
▪ reliable transport between sending ▪ unreliable data transfer
and receiving process between sending and receiving
▪ flow control: sender won’t process
overwhelm receiver ▪ does not provide: reliability,
▪ congestion control: throttle sender flow control, congestion
when network overloaded control, timing, throughput
guarantee, security, or
▪ connection-oriented: setup required connection setup.
between client and server processes
▪ does not provide: timing, minimum Q: why bother? Why
throughput guarantee, security is there a UDP?
Application Layer: 2-14
Internet applications, and transport
protocols application
application layer protocol transport protocol

file transfer/download FTP [RFC 959] TCP


e-mail SMTP [RFC 5321] TCP
Web documents HTTP 1.1 [RFC 7320] TCP
Internet telephony SIP [RFC 3261], RTP [RFC TCP or UDP
3550], or proprietary
streaming audio/video HTTP [RFC 7320], DASH TCP
interactive games WOW, FPS (proprietary) UDP or TCP

Application Layer: 2-15


Securing TCP
Vanilla TCP & UDP sockets: TLS implemented in
▪ no encryption application layer
▪ cleartext passwords sent into socket ▪ apps use TLS libraries, that
traverse Internet in cleartext (!) use TCP in turn
Transport Layer Security (TLS) ▪ cleartext sent into “socket”
▪ provides encrypted TCP connections traverse Internet encrypted
▪ data integrity ▪ more: Chapter 8
▪ end-point authentication

Application Layer: 2-16


Application layer: overview
▪ P2P applications
▪ Principles of network ▪ video streaming and content
applications distribution networks
▪ Web and HTTP ▪ socket programming with
▪ E-mail, SMTP, IMAP UDP and TCP
▪ The Domain Name System
DNS

Application Layer: 2-17


Web and HTTP
First, a quick review…
▪ web page consists of objects, each of which can be stored on
different Web servers
▪ object can be HTML file, JPEG image, Java applet, audio file,…
▪ web page consists of base HTML-file which includes several
referenced objects, each addressable by a URL, e.g.,
www.someschool.edu/someDept/pic.gif

host name path name


▪ One HTTP request for each object.
Application Layer: 2-18
HTTP overview
HTTP: hypertext transfer protocol:
(heart of the web)
▪ Web’s application-layer protocol
HT
▪ client/server model: TP
re
que
• client: browser that requests, receives, (using PC running H st
TTP
HTTP protocol) and “displays” Web objects Firefox browser res
pon
• server: Web server sends (using HTTP protocol) se
objects in response to requests
▪ HTTP defines how Web clients request Web pages e st
r equ
from Web servers and how servers transfer Web TP nse server running
pages to clients. HT po Apache Web
r es
P
▪ When a user requests a Web page (for example, HT
T server
clicks on a hyperlink), the browser sends HTTP
request messages for the objects in the page to the
server. The server receives the requests and iPhone running
responds with HTTP response messages that Safari browser
contain the objects.
Application Layer: 2-19
HTTP overview (continued)
HTTP uses TCP: HTTP is “stateless”
▪ client initiates TCP connection ▪ server maintains no
(creates socket) to server, port 80 information about past client
▪ server accepts TCP connection requests
from client aside
▪ HTTP messages (application-layer protocols that maintain “state”
protocol messages) exchanged are complex!
▪ past history (state) must be
between browser (HTTP client) and maintained
Web server (HTTP server) ▪ if server/client crashes, their views
▪ TCP connection closed of “state” may be inconsistent, must
be reconciled

Application Layer: 2-20


HTTP connections: two types
Non-persistent HTTP Persistent HTTP
1. TCP connection opened ▪TCP connection opened to
2. at most one object sent a server
over TCP connection ▪multiple objects can be
3. TCP connection closed sent over single TCP
connection between client,
downloading multiple and that server
objects required multiple ▪TCP connection closed
connections

Application Layer: 2-21


Non-persistent HTTP: example
User enters URL: www.someSchool.edu/someDepartment/home.index
(containing text, references to 10 jpeg images)

1a. HTTP client initiates TCP


connection to HTTP server 1b. HTTP server at host
(process) at www.someSchool.edu on www.someSchool.edu waiting for TCP
port 80 connection at port 80 “accepts”
connection, notifying client
2. HTTP client sends HTTP
request message (containing
URL) into TCP connection 3. HTTP server receives request message,
socket. Message indicates forms response message containing
time that client wants object requested object, and sends message
someDepartment/home.index into its socket
Application Layer: 2-22
Non-persistent HTTP: example (cont.)
User enters URL: www.someSchool.edu/someDepartment/home.index
(containing text, references to 10 jpeg images)

4. HTTP server closes TCP


5. HTTP client receives response connection.
message containing html file,
displays html. Parsing html file,
finds 10 referenced jpeg objects

6. Steps 1-5 repeated for


each of 10 jpeg objects
time

Application Layer: 2-23


Non-persistent HTTP: response time

Remember Transmission Delay?


▪ Larger for larger packets and vice versa.
initiate TCP
RTT (definition): time for a small connection
RTT
packet to travel from client to
server and back request file
RTT time to
HTTP response time (per object): transmit
▪ one RTT to initiate TCP connection file received
file
▪ one RTT for HTTP request and file
transmission time
time time
Non-persistent HTTP response time = 2RTT+ file transmission time
Application Layer: 2-24
Persistent HTTP (HTTP 1.1)
Non-persistent HTTP issues: Persistent HTTP (HTTP1.1):
▪ requires 2 RTTs per object ▪ server leaves connection open after
▪ OS overhead for each TCP sending response
connection ▪ subsequent HTTP messages
▪ browsers often open multiple between same client/server sent
parallel TCP connections to over open connection
fetch referenced objects in ▪ client sends requests as soon as it
parallel encounters a referenced object
▪ as little as one RTT for all the
referenced objects (cutting
response time in half)
Application Layer: 2-25
Persistent v/s Non-persistent HTTP
1. Suppose you want to fetch an HTML page (index.html) from https://iiits.ac.in such that it also has
references to 8 very small objects on the same server. Let RTT0 denotes the RTT between your
computer and the IIIT’s web server. Neglecting transmission times, how much time elapses with
a) Non-persistent HTTP with no parallel TCP connections?
2*RTT0+8*2*RTT0 = 18RTT0
b) Non-persistent HTTP with the browser configured for 6 parallel connections?
2*RTT0+2*RTT0+2*RTT0=6RTT0
c) Persistent HTTP?
i. Without pipelining:
2*RTT0+8*RTT0 = 10RTT0
ii. With pipelining:
2*RTT0+ 1*RTT0 = 3RTT0 (note that objects are very small and thus, assume that transmission
delay is negligible.)
Which one should HTTP use?
Persistent HTTP with pipelining (But due to issues such as Head-of-Line blocking, pipelining is not used
by default. So the most common is persistent HTTP w/o pipelining.) Application Layer: 2-26
HTTP request message
▪ two types of HTTP messages: request, response
▪ HTTP request message:
• ASCII (human-readable format)
carriage return character
line-feed character
request line (GET, POST,
GET /index.html HTTP/1.1\r\n
HEAD commands) Host: www-net.cs.umass.edu\r\n
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X
10.15; rv:80.0) Gecko/20100101 Firefox/80.0 \r\n
header Accept: text/html,application/xhtml+xml\r\n
lines Accept-Language: en-us,en;q=0.5\r\n
Accept-Encoding: gzip,deflate\r\n
Connection: keep-alive\r\n
\r\n
carriage return, line feed
at start of line indicates
end of header lines * Check out the online interactive exercises for more
examples: http://gaia.cs.umass.edu/kurose_ross/interactive/ Application Layer: 2-27
HTTP request message: general format
method sp URL sp version cr lf request
line
header field name value cr lf
header
~
~ ~
~ lines

header field name value cr lf


cr lf

~
~ entity body ~
~ body

Application Layer: 2-28


Other HTTP request messages
POST method: HEAD method:
▪ web page often includes form ▪ requests headers (only) that
input would be returned if specified
▪ user input sent from client to URL were requested with an
server in entity body of HTTP HTTP GET method.
POST request message
PUT method:
▪ uploads new file (object) to server
GET method (for sending data to server):
▪ include user data in URL field of HTTP
GET request message (following a ‘?’):
www.somesite.com/animalsearch?monkeys&banana

Application Layer: 2-29


HTTP response message
status line (protocol HTTP/1.1 200 OK
status code status phrase) Date: Tue, 08 Sep 2020 00:53:20 GMT
Server: Apache/2.4.6 (CentOS)
OpenSSL/1.0.2k-fips PHP/7.4.9
mod_perl/2.0.11 Perl/v5.16.3
header Last-Modified: Tue, 01 Mar 2016 18:57:50 GMT
lines ETag: "a5b-52d015789ee9e"
Accept-Ranges: bytes
Content-Length: 2651
Content-Type: text/html; charset=UTF-8
\r\n
data, e.g., requested data data data data data ...
HTML file

* Check out the online interactive exercises for more examples: http://gaia.cs.umass.edu/kurose_ross/interactive/
Application Layer: 2-30
HTTP request message: general format

Application Layer: 2-31


HTTP response status codes
▪ status code appears in 1st line in server-to-client response message.
▪ some sample codes:
200 OK
• request succeeded, requested object later in this message
301 Moved Permanently
• requested object moved, new location specified later in this message (in
Location: field)
400 Bad Request
• request msg not understood by server
404 Not Found
• requested document not found on this server
505 HTTP Version Not Supported
Application Layer: 2-32
Trying out HTTP (client side) for yourself
1. netcat to your favorite Web server:
% nc -c -v gaia.cs.umass.edu 80 ▪ opens TCP connection to port 80 (default HTTP server
port) at gaia.cs.umass. edu.
▪ anything typed in will be sent to port 80 at
gaia.cs.umass.edu
2. type in a GET HTTP request:
GET /kurose_ross/interactive/index.php HTTP/1.1
Host: gaia.cs.umass.edu ▪ by typing this in (hit carriage return twice), you send
this minimal (but complete) GET request to HTTP
server

3. look at response message sent by HTTP server!


(or use Wireshark to look at captured HTTP request/response)
Application Layer: 2-33
Maintaining user/server state: cookies
Web sites and client browser use Example:
cookies to maintain some state ▪ Susan uses browser on laptop,
visits specific e-commerce site
between transactions for first time
four components: ▪ when initial HTTP requests
1) cookie header line of HTTP response arrives at site, site creates:
message • unique ID (aka “cookie”)
2) cookie header line in next HTTP • entry in backend database
for ID
request message
• subsequent HTTP requests
3) cookie file kept on user’s host, from Susan to this site will
managed by user’s browser contain cookie ID value,
4) back-end database at Web site allowing site to “identify”
Susan
Application Layer: 2-34
Maintaining user/server state: cookies
client
server
ebay 8734 usual HTTP request msg Amazon server
cookie file creates ID
usual HTTP response 1678 for user backend
create
ebay 8734 set-cookie: 1678 entry database
amazon 1678

usual HTTP request msg


cookie: 1678 cookie- access
specific
usual HTTP response msg action

one week later:


access
ebay 8734 usual HTTP request msg
amazon 1678
cookie: 1678 cookie-
specific
usual HTTP response msg action
time time Application Layer: 2-35
HTTP cookies: comments
aside
What cookies can be used for: cookies and privacy:
▪ authorization ▪ cookies permit sites to
▪ shopping carts learn a lot about you on
their site.
▪ recommendations ▪ third party persistent
▪ user session state (Web e-mail) cookies (tracking cookies)
allow common identity
(cookie value) to be
tracked across multiple
web sites

Application Layer: 2-36


Web caches
Goal: satisfy client requests without involving origin server

▪ user configures browser to


point to a (local) Web cache HTT
P re
Web
q u est
que cache P re
▪ browser sends all HTTP client HTTP
resp
ons
st H TT
P re
ons
sp
e
origin
e T T server
requests to cache e st
H
u
• if object in cache: cache P req se
T T o n
H esp
r
returns object to client HT
TP

• else cache requests object


client
from origin server, caches
received object, then
returns object to client
Application Layer: 2-37
Web caches (aka proxy servers)
▪ Web cache acts as both Why Web caching?
client and server
▪ reduce response time for client
• server for original
requesting client request
• client to origin server • cache is closer to client
▪ reduce traffic on an institution’s
▪ server tells cache about
object’s allowable caching in access link
response header: ▪ Internet is dense with caches
• enables “poor” content providers
to more effectively deliver content

Application Layer: 2-38


FTP (File Transfer Protocol)

Transport Layer: 3-39


FTP: overview
▪ FTP is an application layer protocol that helps for copying file from one host
to another.
▪ FTP differs from other client-server applications in that it establishes two TCP
connections between hosts.
▪ One connection is used for data transfer-> Data connection. This connection
uses port number 20.
▪ Another connection is used for control (command and response) information
-> Control connection. This connection uses port number 21.
▪ When user starts FTP session, the control connection opens. While control
connection is open, data connection can be opened and closed multiple
times if several files transferred.
▪ FTP is stateful and “out of band” protocol.
Application Layer: 2-40
FTP: overview
▪ FTP client and server which run on different computers must communicate
with each other.
▪ These two computer may use different operating systems, different file
structure, and different file formats.
▪ FTP must take this heterogeneity compatible (all of these problems are
solved by FTP in simple and elegant approach).
▪ File transfer occurs over the data connection under the control of commands
sent over control connection.
▪ Commands are sent from FTP client program.
▪ FTP uses control connection to establish a communication between the
client process and server process. During this communication commands are
sent from client to server and then responses are from server to client.
Application Layer: 2-41
Transport Layer: 3-42
Transport Layer: 3-43
Transport Layer: 3-44
Application layer: overview
▪ P2P applications
▪ Principles of network ▪ video streaming and content
applications distribution networks
▪ Web and HTTP ▪ socket programming with
▪ E-mail, SMTP, IMAP UDP and TCP
▪ The Domain Name System
DNS

Application Layer: 2-45


E-mail user
agent
Three major components: mail user
▪ user agents server agent

▪ mail servers SMTP mail user


▪ simple mail transfer protocol: SMTP SMTP
server agent

SMTP user
User Agent mail agent
▪ a.k.a. “mail reader” server
user
▪ composing, editing, reading mail messages agent

▪ e.g., Outlook, iPhone mail client user


agent
▪ outgoing, incoming messages stored on outgoing
message queue
server user mailbox

Application Layer: 2-46


E-mail: mail servers user
agent
mail servers: mail user
server
▪ mailbox contains incoming agent

messages for user SMTP mail user


server agent
▪ message queue of outgoing (to be SMTP
sent) mail messages user
SMTP agent
SMTP protocol between mail mail
server
servers to send email messages user
agent
▪ client: sending mail server user
▪ “server”: receiving mail server agent
outgoing
message queue
user mailbox

Application Layer: 2-47


SMTP RFC (5321) “client”
SMTP server
“server”
SMTP server

▪ uses TCP to reliably transfer email message


initiate TCP
from client (mail server initiating connection
connection) to server, port 25 RTT
▪ direct transfer: sending server (acting like client) TCP connection
initiated
to receiving server
▪ three phases of transfer 220
• SMTP handshaking (greeting) SMTP HELO
handshaking
• SMTP transfer of messages 250 Hello
• SMTP closure
▪ command/response interaction (like HTTP) SMTP
• commands: ASCII text transfers
• response: status code and phrase time
Application Layer: 2-48
Scenario: Alice sends e-mail to Bob
1) Alice uses UA to compose e-mail 4) SMTP client sends Alice’s message
message “to” bob@someschool.edu over the TCP connection
2) Alice’s UA sends message to her 5) Bob’s mail server places
mail server using SMTP; message the message in Bob’s
placed in message queue mailbox
3) client side of SMTP at mail server 6) Bob invokes his user
opens TCP connection with Bob’s mail agent to read message
server

1user mail user


mail agent
agent server server
2 3 6
4
5
Alice’s mail server Bob’s mail server
Application Layer: 2-49
Sample SMTP interaction
S: 220 hamburger.edu
C: HELO crepes.fr
S: 250 Hello crepes.fr, pleased to meet you
C: MAIL FROM: <alice@crepes.fr>
S: 250 alice@crepes.fr... Sender ok
C: RCPT TO: <bob@hamburger.edu>
S: 250 bob@hamburger.edu ... Recipient ok
C: DATA
S: 354 Enter mail, end with "." on a line by itself
C: Do you like ketchup?
C: How about pickles?
C: .
S: 250 Message accepted for delivery
C: QUIT
S: 221 hamburger.edu closing connection
Application Layer: 2-50
SMTP: observations
comparison with HTTP: ▪ SMTP uses persistent
▪ HTTP: client pull connections
▪ SMTP requires message
▪ SMTP: client push
(header & body) to be in
▪ both have ASCII command/response 7-bit ASCII
interaction, status codes ▪ SMTP server uses
CRLF.CRLF to determine
end of message

Application Layer: 2-51


Mail message format
SMTP: protocol for exchanging e-mail messages, defined in RFC 5321
(like RFC 7231 defines HTTP)
RFC 2822 defines syntax for e-mail message itself (like HTML defines
syntax for web documents)
▪ header lines, e.g., header
blank
• To: line
• From:
• Subject:
these lines, within the body of the email body
message area different from SMTP MAIL FROM:,
RCPT TO: commands!
▪ Body: the “message” , ASCII characters only
Application Layer: 2-52
Retrieving email: mail access protocols
user e-mail access user
SMTP SMTP protocol
agent agent
(e.g., IMAP,
HTTP)

sender’s e-mail receiver’s e-mail


server server

▪ SMTP: delivery/storage of e-mail messages to receiver’s server


▪ mail access protocol: retrieval from server
• IMAP: Internet Mail Access Protocol [RFC 3501]: messages stored on server, IMAP
provides retrieval, deletion, folders of stored messages on server
▪ HTTP: gmail, Hotmail, Yahoo!Mail, etc. provides web-based interface on
top of STMP (to send), IMAP (or POP) to retrieve e-mail messages
Application Layer: 2-53
POP3 and IMAP
IMAP
POP3
▪ POP3 have 2 modes:
▪ Keeps all messages at one
▪ Download and delete
place: at server
▪ POP3 protocol does not provide any ▪ Allows users to organize mails in
means to create remote folders and folders
assign message to the folders. ▪ Messages will not be deleted from
▪ POP3 server does not maintain any state the server if downloaded on local
information. computer

▪ POP3 uses 110 port number ▪ IMAP protocol provide users to


create remote folders and assign
message to the folders.
▪ IMAP folder maintain state
information.
▪ IMAP uses 143 port number Application Layer: 2-54

You might also like