Sie sind auf Seite 1von 31

Lecture 04:

Application Layer (1/3)

Principles of network applications &


Web and HTTP

CSI3601504 - Jaringan Komunikasi Data


Semester Gasal 2017-2018
Fakultas Ilmu Komputer UI
Lecture 04: Roadmap
Chapter 02:
 2.1 Principles of network applications
 2.2 Web and HTTP

2
Some network apps
 e-mail  voice over IP (e.g.,
 web Skype)
 text messaging  real-time video
 remote login
conferencing
 P2P file sharing
 social networking
 multi-user network
 search
games  …
 streaming stored video  …
(YouTube, Hulu,
Netflix)

Application Layer 2-3


Creating a network app application
transport
network
data link

write programs that: physical

 run on (different) end systems


 communicate over network
 e.g., web server software
communicates with browser
software

no need to write software for


application
network-core devices transport
network
 network-core devices do not data link
physical
application
transport
run user applications network
data link

 applications on end systems


physical

allows for rapid app


development, propagation

Application Layer 2-4


Application architectures

possible structure of applications:


 client-server
 peer-to-peer (P2P)

Application Layer 2-5


Client-server architecture
server:
 always-on host
 permanent IP address
 data centers for scaling

clients:
 communicate with server
 may be intermittently
client/server
connected
 may have dynamic IP
addresses
 do not communicate directly
with each other

Application Layer 2-6


P2P architecture
 no always-on server peer-peer
 arbitrary end systems
directly communicate
 peers request service from
other peers, provide service
in return to other peers
 self scalability – new
peers bring new service
capacity, as well as new
service demands
 peers are intermittently
connected and change IP
addresses
 complex management

Application Layer 2-7


Processes communicating

process: program clients, servers


running within a host client process: process
that initiates
 within same host, two
communication
processes communicate
server process: process
using inter-process that waits to be contacted
communication (defined
by OS)
 aside: applications with
 processes in different P2P architectures have
hosts communicate by client processes &
exchanging messages server processes

Application Layer 2-8


Sockets
 process 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
application application
socket controlled by
process process app developer

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

Application Layer 2-9


Addressing processes
 to receive messages,  identifier includes both
process must have IP address and port
identifier numbers associated with
 host device has unique process on host.
32-bit IP address  example port numbers:
 Q: does IP address of  HTTP server: 80
host on which process  mail server: 25
runs suffice for  to send HTTP message
identifying the process? to gaia.cs.umass.edu web
 A: no, many server:
processes can be  IP address: 128.119.245.12
running on same host  port number: 80
 more shortly…
Application Layer 2-10
What transport service does an app need?
data integrity throughput
 some apps (e.g., file  some apps (e.g.,
transfer, web multimedia) require
transactions) require minimum amount of
100% reliable data throughput to be
transfer “effective”
 other apps (e.g., audio) can  other apps (“elastic
tolerate some loss apps”) make use of
timing whatever throughput
they get
 some apps (e.g.,
Internet telephony, security
interactive games)  encryption, data
require low delay to be integrity, …
“effective”
Application Layer 2-11
Transport service requirements: common apps

application data loss throughput time sensitive

file transfer 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, 100’s
video:10kbps- msec
stored audio/video loss-tolerant 5Mbps
interactive games loss-tolerant same as above yes, few secs
text messaging no loss few kbps up yes, 100’s
elastic msec
yes and no

Application Layer 2-12


Internet transport protocols services
TCP service: UDP service:
 reliable transport  unreliable data transfer
between sending and between sending and
receiving process receiving process
 flow control: sender  does not provide:
won’t overwhelm reliability, flow control,
receiver
congestion control, timing,
 congestion control: throughput guarantee,
throttle sender when security, or connection
network overloaded
setup,
 does not provide: timing,
minimum throughput
guarantee, security Q: why bother? Why is
 connection-oriented: there a UDP?
setup required between
client and server
processes
Application Layer 2-13
Internet apps: application, transport protocols

application underlying
application layer protocol transport protocol

e-mail SMTP [RFC 2821] TCP


remote terminal access Telnet [RFC 854] TCP
Web HTTP [RFC 2616] TCP
file transfer FTP [RFC 959] TCP
streaming multimedia HTTP (e.g., YouTube), TCP or UDP
RTP [RFC 1889]
Internet telephony SIP, RTP, proprietary
(e.g., Skype) TCP or UDP

Application Layer 2-14


Securing TCP

TCP & UDP SSL is at app layer


 no encryption  Apps use SSL
 cleartext passwds libraries, which
sent into socket
“talk” to TCP
traverse Internet in
cleartext SSL socket API
SSL  cleartext passwds
 provides encrypted sent into socket
TCP connection traverse Internet
 data integrity encrypted
 end-point
 See Chapter 7
authentication
Application Layer 2-15
Lecture 04: Roadmap
Chapter 02:
 2.1 Principles of network applications
 2.2 Web and HTTP

16
Web and HTTP
First, a review…
 web page consists of objects
 object can be HTML file, JPEG image, Java
applet, audio file,…
 web page consists of base HTML-file which
includes several referenced objects
 each object is addressable by a URL, e.g.,

www.someschool.edu/someDept/pic.gif

host name path name


Application Layer 2-17
HTTP overview
HTTP: hypertext
transfer protocol
 Web’s application
layer protocol PC running
Firefox browser
 client/server model
 client: browser that
requests, receives,
(using HTTP server
protocol) and running
“displays” Web Apache Web
objects server
 server: Web server
sends (using HTTP iphone running
protocol) objects in Safari browser
response to
requests
Application Layer 2-18
HTTP overview (continued)

uses TCP: HTTP is “stateless”


 client initiates TCP  server maintains no
connection (creates socket) information about past
to server, port 80 client requests
 server accepts TCP
aside
connection from client protocols that maintain
 HTTP messages (application- “state” are complex!
layer protocol messages)  past history (state) must
exchanged between browser be maintained
(HTTP client) and Web  if server/client crashes,
server (HTTP server) their views of “state” may
be inconsistent, must be
 TCP connection closed
reconciled

Application Layer 2-19


HTTP connections
non-persistent HTTP persistent HTTP
 at most one object  multiple objects
sent over TCP can be sent over
connection single TCP
 connection then connection between
closed client, server
 downloading
multiple objects
required multiple
connections
Application Layer 2-20
Nonpersistent HTTP
(contains text,
Suppose user enters URL references to 10
www.someSchool.edu/someDepartment/home.index jpeg images)

1a. HTTP client initiates TCP


connection to HTTP server
(process) at
1b. HTTP server at host
www.someSchool.edu waiting
www.someSchool.edu on port 80
for TCP 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
socket. Message indicates message, forms response
that client wants object message containing requested
someDepartment/home.index object, and sends message
into its socket

time
21
Nonpersistent HTTP (cont.)

4. HTTP server closes TCP


connection.
5. HTTP client receives response
message containing html file,
displays html. Parsing html
file, finds 10 referenced jpeg
objects
time 6. Steps 1-5 repeated for each
of 10 jpeg objects

22
Non-persistent HTTP: response time

RTT (definition): time for a


small packet to travel from
client to server and back
HTTP response time: initiate TCP
 one RTT to initiate TCP connection
connection RTT
 one RTT for HTTP request request
file
and first few bytes of HTTP time to
response to return RTT transmit
file
 file transmission time
file
 non-persistent HTTP received
response time =
2RTT+ file transmission time time
time

Application Layer 2-23


Persistent HTTP

non-persistent HTTP persistent HTTP:


issues:  server leaves connection
open after sending
 requires 2 RTTs per response
object  subsequent HTTP messages
 OS overhead for each between same
TCP connection client/server sent over
open connection
 browsers often open  client sends requests as
parallel TCP soon as it encounters a
connections to fetch referenced object
referenced objects  as little as one RTT for all
the referenced objects

Application Layer 2-24


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: Firefox/3.6.10\r\n
Accept: text/html,application/xhtml+xml\r\n
header Accept-Language: en-us,en;q=0.5\r\n
lines Accept-Encoding: gzip,deflate\r\n
Accept-Charset: ISO-8859-1,utf-8;q=0.7\r\n
carriage return, Keep-Alive: 115\r\n
line feed at start Connection: keep-alive\r\n
\r\n
of line indicates
end of header lines
Application Layer 2-25
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-26


Uploading form input
POST method:
 web page often
includes form input
 input is uploaded to
server in entity body
URL method:
 uses GET method
 input is uploaded in
URL field of request
line: www.somesite.com/animalsearch?monkeys&banana

Application Layer 2-27


Method types

HTTP/1.0: HTTP/1.1:
 GET  GET, POST, HEAD
 POST  PUT
 HEAD  uploads file in
 asks server to leave entity body to path
requested object specified in URL
out of response field
 DELETE
 deletes file
specified in the
URL field
Application Layer 2-28
HTTP response message
status line
(protocol
status code HTTP/1.1 200 OK\r\n
status phrase) Date: Sun, 26 Sep 2010 20:09:20 GMT\r\n
Server: Apache/2.0.52 (CentOS)\r\n
Last-Modified: Tue, 30 Oct 2007 17:00:02 GMT\r\n
ETag: "17dc6-a5c-bf716880"\r\n
header Accept-Ranges: bytes\r\n
Content-Length: 2652\r\n
lines
Keep-Alive: timeout=10, max=100\r\n
Connection: Keep-Alive\r\n
Content-Type: text/html; charset=ISO-8859-1\r\n
\r\n
data data data data data ...

data, e.g.,
requested
HTML file
Application Layer 2-29
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 msg
301 Moved Permanently
 requested object moved, new location specified later in this
msg (Location:)
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-30
Review
 What is
 Client-server  Put method
 Peer-to-peer  Head method
 TCP  Delete method
 UDP  Http Non-persistent
 Socket  Http Persistent
 SSL
 http
 Post method
 Get method

31

Das könnte Ihnen auch gefallen