Bài giảng Mạng máy tính - Chapter 2: Application Layer (Part I) - Hồ Phương Đắc
Chapter 2: Application Layer
Chapter goals:
More chapter goals
specific protocols:
conceptual +
implementation aspects
of network application
protocols
http
ftp
smtp
pop
dns
client server
paradigm
service models
learn about protocols by
examining popular
application-level
protocols
programming network
applications
socket programming
2: Application Layer
1
Applications and application-layer protocols
application
Application: communicating,
transport
network
distributed processes
data link
physical
running in network hosts in
“user space”
exchange messages to
implement app
e.g., email, file transfer,
the Web
Application-layer protocols
application
transport
network
data link
physical
application
one “piece” of an app
transport
network
data link
physical
define messages
exchanged by apps and
actions taken
user services provided by
lower layer protocols
2: Application Layer
2
Network applications: some jargon
A process is a program
A user agent is an
that is running within a
host.
interface between the
user and the network
application.
Within the same host, two
processes communicate
with interprocess
Web:browser
E-mail: mail reader
communication defined by
the OS.
streaming audio/video:
Processes running in
different hosts
media player
communicate with an
application-layer protocol
2: Application Layer
3
Client-server paradigm
Typical network app has two
application
transport
network
data link
physical
pieces: client and server
Client:
request
initiates contact with server
(“speaks first”)
typically requests service from
server,
reply
for Web, client is implemented
in browser; for e-mail, in mail
reader
application
transport
network
data link
physical
Server:
provides requested service to
client
e.g., Web server sends
requested Web page, mail
server delivers e-mail
2: Application Layer
4
Application-layer protocols (cont).
API: application
Q: how does a process
programming interface “identify” the other
process with which it
wants to communicate?
defines interface
between application
and transport layer
IP address of host
running other process
socket: Internet API
“port number” - allows
receiving host to
determine to which
local process the
message should be
delivered
two processes
communicate by sending
data into socket,
reading data out of
socket
… lots more on this later.
2: Application Layer
5
What transport service does an app need?
Data loss
some apps (e.g., audio) can
tolerate some loss
other apps (e.g., file
transfer, telnet) require
100% reliable data transfer
Timing
some apps (e.g., Internet
telephony, interactive
Bandwidth
some apps (e.g., multimedia)
require minimum amount of
bandwidth to be “effective”
games) require low delay to
be “effective”
other apps (“elastic apps”)
make use of whatever
bandwidth they get
2: Application Layer
6
Transport service requirements of common apps
Time Sensitive
Application Data loss
Bandwidth
no
file transfer no loss
e-mail no loss
Web documents loss-tolerant elastic
real-time audio/video loss-tolerant audio: 5Kb-1Mb
video:10Kb-5Mb
elastic
elastic
no
no
yes, 100’s msec
yes, few secs
yes, 100’s msec
yes and no
stored audio/video loss-tolerant same as above
interactive games loss-tolerant few Kbps up
financial apps no loss
elastic
2: Application Layer
7
Services provided by Internet
transport protocols
UDP service:
unreliable data transfer
between sending and
receiving process
TCP service:
connection-oriented: setup
required between client,
server
does not provide:
reliable transport between
connection setup,
sending and receiving process
reliability, flow control,
congestion control, timing,
or bandwidth guarantee
flow control: sender won’t
overwhelm receiver
congestion control: throttle
sender when network
overloaded
does not providing: timing,
minimum bandwidth
guarantees
Q: why bother? Why is
there a UDP?
2: Application Layer
8
Internet apps: their protocols and transport
protocols
Application
layer protocol
Underlying
transport protocol
Application
smtp [RFC 821]
telnet [RFC 854]
http [RFC 2068]
ftp [RFC 959]
proprietary
(e.g. RealNetworks)
NSF
e-mail
remote terminal access
Web
TCP
TCP
TCP
TCP
TCP or UDP
file transfer
streaming multimedia
remote file server
Internet telephony
TCP or UDP
typically UDP
proprietary
(e.g., Vocaltec)
2: Application Layer
9
The Web: some jargon
User agent for Web is
Web page:
called a browser:
consists of “objects”
addressed by a URL
MS Internet Explorer
Netscape Communicator
Most Web pages
consist of:
Server for Web is
called Web server:
Apache (public domain)
base HTML page, and
several referenced
MS Internet
objects.
Information Server
URL has two
components: host name
and path name:
www.someSchool.edu/someDept/pic.gif
2: Application Layer
10
The Web: the http protocol
http: hypertext transfer
protocol
Web’s application layer
PC running
Explorer
protocol
client/server model
client: browser that
requests, receives,
Server
running
NCSA Web
server
“displays” Web objects
server: Web server
sends objects in
response to requests
Mac running
Navigator
http1.0: RFC 1945
http1.1: RFC 2068
2: Application Layer
11
The http protocol: more
http is “stateless”
http: TCP transport
service:
client initiates TCP
connection (creates socket)
to server, port 80
server maintains no
information about
past client requests
aside
server accepts TCP
Protocols that maintain
connection from client
“state” are complex!
http messages (application-
layer protocol messages)
exchanged between browser
(http client) and Web server
(http server)
past history (state) must
be maintained
if server/client crashes,
their views of “state” may
be inconsistent, must be
reconciled
TCP connection closed
2: Application Layer
12
http example
Suppose user enters URL
(contains text,
references to 10
jpeg images)
1a. http client initiates TCP
connection to http server
1b. http server at host
www.someSchool.edu waiting
for TCP connection at port 80.
“accepts” connection, notifying
client
(process) at
www.someSchool.edu. Port 80
is default for http server.
2. http client sends http request
message (containing URL) into
TCP connection socket
3. http server receives request
message, forms response
message containing requested
object
(someDepartment/home.index),
sends message into socket
time
2: Application Layer
13
http example (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
6. Steps 1-5 repeated for each
of 10 jpeg objects
time
2: Application Layer
14
Non-persistent and persistent connections
Persistent
Non-persistent
default for HTTP/1.1
HTTP/1.0
on same TCP
connection: server,
parses request,
responds, parses new
request,..
server parses request,
responds, and closes
TCP connection
2 RTTs to fetch each
object
Client sends requests
Each object transfer
suffers from slow
start
for all referenced
objects as soon as it
receives base HTML.
Fewer RTTs and less
But most 1.0 browsers use
parallel TCP connections.
slow start.
2: Application Layer
15
http message format: request
two types of http messages: request, response
http request message:
ASCII (human-readable format)
request line
(GET, POST,
GET /somedir/page.html HTTP/1.0
User-agent: Mozilla/4.0
HEAD commands)
Accept: text/html, image/gif,image/jpeg
Accept-language:fr
header
lines
(extra carriage return, line feed)
Carriage return,
line feed
indicates end
of message
2: Application Layer
16
http request message: general format
2: Application Layer
17
http message format: respone
status line
(protocol
HTTP/1.0 200 OK
Date: Thu, 06 Aug 1998 12:00:15 GMT
Server: Apache/1.3.0 (Unix)
Last-Modified: Mon, 22 Jun 1998 …...
Content-Length: 6821
status code
status phrase)
header
lines
Content-Type: text/html
data data data data data ...
data, e.g.,
requested
html file
2: Application Layer
18
http response status codes
In first line in server->client response message.
A few 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 (Location:)
400 Bad Request
request message not understood by server
404 Not Found
requested document not found on this server
505 HTTP Version Not Supported
2: Application Layer
19
Trying out http (client side) for yourself
1. Telnet to your favorite Web server:
Opens TCP connection to port 80
Anything typed in sent
2. Type in a GET http request:
By typing this in (hit carriage
return twice), you send
this minimal (but complete)
GET request to http server
GET /~ross/index.html HTTP/1.0
3. Look at response message sent by http server!
2: Application Layer
20
Tải về để xem bản đầy đủ
Bạn đang xem 20 trang mẫu của tài liệu "Bài giảng Mạng máy tính - Chapter 2: Application Layer (Part I) - Hồ Phương Đắc", để tải tài liệu gốc về máy hãy click vào nút Download ở trên
File đính kèm:
bai_giang_mang_may_tinh_chapter_2_application_layer_part_i_h.ppt

