You are on page 1of 34

Lecture_05

Application
Layer
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-2


Principles of Network Applications:
Network Applications Architecture

 From the application developer’s perspective, the network


architecture is fixed and provides a specific set of services to
applications.
 on the other hand, is designed by the application developer and
dictates how the application is structured over the various end
systems.
 client-server architecture
 peer-to-peer (P2P) architecture

Application Layer: 2-3


Application layer: overview
Our goals:  learn about protocols by
 conceptual and examining popular
implementation aspects of application-layer protocols
application-layer protocols and infrastructure
• HTTP
• transport-layer service • SMTP, IMAP
models • DNS
• client-server paradigm • video streaming systems, CDNs
• peer-to-peer paradigm  programming network
applications
• socket API
Application Layer: 2-4
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-5


Creating a network app
application

write programs that:


transport
network
mobile network
data link
physical
 run on (different) end systems 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


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

 applications on end systems allows data link


physical

for rapid app development, enterprise


propagation network

Application Layer: 2-6


Client-server paradigm
server: mobile network
 always-on host national or global ISP

 permanent IP address
 often in data centers, for scaling
clients: local or
 contact, communicate with server regional ISP

 may be intermittently connected home network content


provider
 may have dynamic IP addresses network datacenter
network

 do not communicate directly with


each other
enterprise
 examples: HTTP, IMAP, FTP, telnet network

Application Layer: 2-7


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
network
 example: P2P file sharing [BitTorrent],
Skype Application Layer: 2-8
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
OS)  note: applications with
P2P architectures have
 processes in different hosts client processes &
communicate by exchanging server processes
messages
Application Layer: 2-9
The application developer has control of everything

Sockets(Software Interface) on the application layer side of the socket but has litt
control of the transport-layer side of the socket.

 Process (house) sends/receives messages to/from its socket


 socket analogous to 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

API is known as socket application application


socket controlled by
It is the interface between process process app developer
the network and the
transport transport
applications
network network controlled
link
by OS
link Internet
physical physical

Application Layer: 2-10


Application Layer: 2-11
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 gaia.cs.umass.edu web server:
can be running on • IP address: 128.119.245.12
same host • port number: 80
 more shortly…
Application Layer: 2-12
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 described  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-13
What transport service does an app need?
throughput
data integrity (process-to-  some apps (e.g., multimedia)
process reliable data transfer) require minimum amount of
 some apps (e.g., file transfer, throughput to be “effective”
web transactions) require other apps (“elastic apps”) make
100% reliable data transfer use of whatever throughput
 other apps (e.g., simple talk) they get(Electronic mail, file transfer,
can tolerate some loss and Web transfers are all elastic
timing applications)
 some apps (e.g., Internet security
telephony, interactive games)  encryption, data integrity,
require low delay to be “effective” …
An example guarantee might be that every bit that the sender pumps
into the socket arrives at the receiver’s socket no more than 100 msec later.
Application Layer: 2-14
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-15
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-16
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 [RFC 7230, 9110] TCP
Internet telephony SIP [RFC 3261], RTP [RFC TCP or UDP
3550], or proprietary
streaming audio/video HTTP [RFC 7230], DASH TCP
interactive games WOW, FPS (proprietary) UDP or TCP
Session Initiation Protocol World of Warcraft
Real-time Transport protocol
Application Layer: 2-17
Dynamic Adaptive Streaming over HTTP
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-18


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-19


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

Application Layer: 2-20


HTTP overview
HTTP: hypertext transfer protocol
 Web’s application-layer protocol HT
 client/server model: PC running
TP
req
ues
HT t
• client: browser that requests, Firefox browser TP
res
pon
receives, (using HTTP protocol) and se

“displays” Web objects ues


t
req
• server: Web server sends (using HTTP
p o ns
e server running
es Apache Web
HTTP protocol) objects in response HTTP
r
server
to requests
iPhone running
Safari browser

Application Layer: 2-21


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
protocol messages) exchanged “state” are complex!
 past history (state) must be
between browser (HTTP client) and maintained
Web server (HTTP server)  if server/client crashes, their
 TCP connection closed views of “state” may be
inconsistent, must be reconciled

Application Layer: 2-22


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-23


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-24
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-25


Non-persistent HTTP: response time

RTT (definition): time for a small


packet to travel from client to initiate TCP
server and back connection
RTT
HTTP response time (per object):
 one RTT to initiate TCP connection request file
 one RTT for HTTP request and first few RTT time to
transmit
bytes of HTTP response to return file
file received
 object/file transmission time

time time
Non-persistent HTTP response time = 2RTT+ file transmission time
Application Layer: 2-26
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-27
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-28
HTTP Request message
The first line of an HTTP request message is called the request line; the subsequent lines are
called the header lines. The request line has three fields: the method field, the URL field, and
the HTTP version field.
The method field can take on several different values, including GET, POST, HEAD, PUT, and
DELETE . The great majority of HTTP request messages use the GET method.
The GET method is used when the browser requests an object, with the requested object
identified in the URL field.

In this example,
the browser is requesting the object
/somedir/page.html .

The version is self explanatory;


in this example,
the browser implements version HTTP/1.1. Transport Layer: 3-29
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-30


HTTP Methods
• The HEAD method is similar to the GET method. When a server receives a request with the HEAD method, it
responds with an HTTP message but it leaves out the requested object.
• Application developers often use the HEAD method for debugging.

• The PUT method is often used in conjunction with Web publishing tools. It allows a user to upload an object
to a specific path (directory) on a specific Web server.
• The PUT method is also used by applications that need to upload objects to Web servers.

• The DELETE method allows a user, or an application, to delete an object on a Web server.

• An HTTP client often uses the POST method when the user fills out a form—for example, when a user provides search
words to a search engine.
• With a POST message, the user is still requesting a Web page from the server, but the specific contents of the Web page

Transport Layer: 3-31


HTTP Response message

Transport Layer: 3-32


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
Last-Modified: Tue, 01 Mar 2016 18:57:50 GMT
header ETag: "a5b-52d015789ee9e"
lines Accept-Ranges: bytes
Content-Length: 2651
Content-Type: text/html; charset=UTF-8
\r\n
data data data data data ...
data, e.g., requested
HTML file

* Check out the online interactive exercises for more examples: h ttp://gaia.cs.umass.edu/kurose_ross/interactive/
Application Layer: 2-33
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-34

You might also like