Beruflich Dokumente
Kultur Dokumente
Shivkumar Kalyanaraman
shivkuma@ecse.rpi.edu
Biplab Sikdar
sikdab@rpi.edu
Overview
Conceptual + implementation aspects of
network application protocols
client server paradigm
service models
Specific protocols:
http, ftp, smtp, pop, dns
Sockets
Rensselaer Polytechnic Institute
Shivkumar Kalvanaraman, Biplab Sikdar
TCP/IP Protocols
Application
Transport
TCP
UDP
Internetwork
IP
Host to
Network
application
transport
network
data link
physical
application
transport
network
data link
physical
application
transport
network
data link
physical
Client-server paradigm
Typical network app has two
pieces: client and server
Client:
initiates contact with
server (speaks first)
typically requests
service from server,
for Web, client is
implemented in
browser; for e-mail, in
mail reader
application
transport
network
data link
physical
request
reply
application
transport
network
data link
physical
Client-server paradigm
Typical network app has two
pieces: client and server
Server:
provides requested
service to client, via
replies
e.g., Web server
sends requested Web
page, mail server
delivers e-mail
application
transport
network
data link
physical
request
reply
application
transport
network
data link
physical
Application-layer protocols
API: application
programming
interface
defines interface
between application
and transport layer
socket: Internet API
two processes
communicate by
sending data into
socket, reading data
out of socket
Timing
some apps (e.g.,
Internet telephony,
interactive games)
require low delay to
be effective
Bandwidth
some apps (e.g., multimedia) require minimum
amount of bandwidth to be effective
other apps (elastic apps) make use of
whatever bandwidth they get
Rensselaer Polytechnic Institute
Shivkumar Kalvanaraman, Biplab Sikdar
Bandwidth
Time Sensitive
file transfer
e-mail
Web documents
real-time audio/video
no loss
no loss
loss-tolerant
loss-tolerant
no
no
no
yes, 100s msec
stored audio/video
interactive games
financial apps
loss-tolerant
loss-tolerant
no loss
elastic
elastic
elastic
audio: 5Kb-1Mb
video:10Kb-5Mb
same as above
few Kbps up
elastic
Application
10
TCP service:
connection-oriented: setup
required between client,
server
reliable transport between
sending and receiving
process
flow control: sender wont
overwhelm receiver
congestion control:
throttle sender when
network overloaded
does not provide: timing,
minimum bandwidth
guarantees
UDP service:
unreliable data
transfer between
sending and
receiving process
does not provide:
connection setup,
reliability, flow
control, congestion
control, timing, or
bandwidth guarantee
Q: why bother? Why is
there a UDP?
11
Application
layer protocol
Underlying
transport protocol
TCP
TCP
TCP
TCP
TCP or UDP
TCP or UDP
typically UDP
12
http is stateless
server maintains
no information
about past client
requests
aside
14
http example
Suppose user enters URL www.
School.edu/Department/home.index
(contains text,
references to 10
jpeg images)
time
15
time
response message
containing html file,
displays html.
Parsing html file, finds
10 referenced jpeg
objects
16
Persistent
default for HTTP/1.1
on same TCP
connection: server,
parses request,
responds, parses new
request,..
Client sends requests
for all referenced
objects as soon as it
receives base HTML.
Fewer RTTs and less
slow start.
17
Carriage return,
line feed
indicates end
of message
18
19
data, e.g.,
requested
html file
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
Content-Type: text/html
data data data data data ...
20
21
22
time
23
server
client
usual http request msg
usual http response +
client presents
cookie in later
requests
Set-cookie: #
usual http request msg
cookie: 1678453
server matches
presented-cookie
with server-stored
info
authentication
remembering user
preferences
cookie: #
usual http response msg
usual http request msg
cookie: #
usual http response msg
cookiespectific
action
cookiespectific
action
24
server
object
not
modified
server: response
contains no object if
cached copy up-todate:
If-modified-since:
<date>
HTTP/1.1 200 OK
<data>
object
modified
25
26
origin
servers
public
Internet
institutional
network
link out of
institutional/local
ISP network often
bottleneck
Rensselaer Polytechnic Institute
Shivkumar Kalvanaraman, Biplab Sikdar
1.5 Mbps
access link
10 Mbps LAN
institutional
cache
27
Web Server
Rensselaer Polytechnic Institute
Shivkumar Kalvanaraman, Biplab Sikdar
28
Routers
Web
Rensselaer Polytechnic Institute
Shivkumar Kalvanaraman, Biplab Sikdar
Servers
29
Replicated
content
Content Sink
Router
Content Source
Web Server
30
Client
Distribution
System
Surrogate
Origin
31
user
at host
FTP
FTP
user
client
interface
file transfer
local file
system
FTP
server
remote file
system
32
FTP
client
FTP
server
33
34
Electronic Mail
Three major components:
user agents
mail servers
simple mail transfer
protocol: smtp
outgoing
message queue
user mailbox
user
agent
mail
server
SMTP
User Agent
a.k.a. mail reader
SMTP
composing, editing,
SMTP
reading mail messages
mail
e.g., Eudora, Outlook,
server
elm, Netscape
user
Messenger
agent
user
outgoing, incoming
agent
messages stored on
Rensselaer Polytechnic Institute
server
Shivkumar Kalvanaraman, Biplab Sikdar
user
agent
mail
server
user
agent
user
agent
35
user
agent
mail
server
user
agent
user
agent
36
37
220 hamburger.edu
HELO crepes.fr
250 Hello crepes.fr, pleased to meet you
MAIL FROM: <alice@crepes.fr>
250 alice@crepes.fr... Sender ok
RCPT TO: <bob@hamburger.edu>
250 bob@hamburger.edu ... Recipient ok
DATA
354 Enter mail, end with "." on a line by itself
Do you like ketchup?
How about pickles?
.
250 Message accepted for delivery
QUIT
221 hamburger.edu closing connection
Rensselaer Polytechnic Institute
Shivkumar Kalvanaraman, Biplab Sikdar
38
telnet servername 25
see 220 reply from server
enter HELO, MAIL FROM, RCPT TO,
DATA, QUIT commands
above lets you send email without
using email client (reader)
Rensselaer Polytechnic Institute
Shivkumar Kalvanaraman, Biplab Sikdar
39
header
blank
line
body
body
the message, ASCII
characters only
Rensselaer Polytechnic Institute
Shivkumar Kalvanaraman, Biplab Sikdar
41
From: alice@crepes.fr
To: bob@hamburger.edu
Subject: Picture of yummy crepe.
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Type: image/jpeg
base64 encoded data .....
.........................
......base64 encoded data
42
MIME types
Content-Type: type/subtype; parameters
Text
example subtypes:
plain, html
Image
example subtypes:
jpeg, gif
Video
example subtypes:
mpeg, quicktime
Application
other data that must
be processed by
reader before
viewable
example subtypes:
msword, octetstream
Audio
exampe subtypes:
basic (8-bit mu-law
encoded), 32kadpcm
(32 kbps coding) Rensselaer Polytechnic Institute
43
Multipart Type
From: alice@crepes.fr
To: bob@hamburger.edu
Subject: Picture of yummy crepe.
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary=98766789
--98766789
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain
Dear Bob,
Please find a picture of a crepe.
--98766789
Content-Transfer-Encoding: base64
Content-Type: image/jpeg
base64 encoded data .....
.........................
......base64 encoded data
--98766789-Rensselaer Polytechnic Institute
Shivkumar Kalvanaraman, Biplab Sikdar
44
SMTP
SMTP
senders mail
server
POP3 or
IMAP
user
agent
receivers mail
server
45
POP3 protocol
authorization phase
S: +OK POP3 server ready
C: user alice
client commands:
S: +OK
user: declare
C: pass hungry
username
S: +OK user successfully logged
pass: password
C: list
S: 1 498
server responses
S: 2 912
+OK
S: .
-ERR
C: retr 1
S: <message 1 contents>
transaction phase, client:
S: .
list: list message
C: dele 1
C: retr 2
numbers
S: <message 1 contents>
retr: retrieve
S: .
message by number
C: dele 2
C: quit
dele: delete
S: +OK POP3 server signing off
quit
Rensselaer Polytechnic Institute
46
Shivkumar Kalvanaraman, Biplab Sikdar
on
48
49
50
2
7
gaia.cs.umass.edu
51
recursive query:
puts burden of name
resolution on
contacted name
server
heavy load?
iterated query:
contacted server
replies with name of
server to contact
I dont know this
name, but ask this
server
iterated query
3
4
7
requesting host
surf.eurecom.fr
gaia.cs.umass.edu
52
53
DNS records
DNS: distributed db storing resource records
(RR)
RR format: (name,
Type=A
name is hostname
value is IP address
Type=NS
name is domain (e.g.
foo.com)
value is IP address
of authoritative
name server for this
domain
value, type,ttl)
Type=CNAME
name is an alias name
for some cannonical
(the real) name
value is cannonical
name
Type=MX
value is hostname of
mailserver associated
with name
54
55
56
Sockets
Goal: learn models of client/server application
that communicate using sockets
Socket API
introduced in BSD4.1
UNIX, 1981
explicitly created,
used, released by apps
client/server paradigm
two types of transport
service via socket API:
unreliable datagram
reliable, byte
stream-oriented
socket
a host-local, applicationcreated/owned,
OS-controlled interface
(a door) into which
application process can
both send and
receive messages to/from
another (remote or
local) application process
57
TCP sockets
Socket: a door between application process
and end-end-transport protocol (UCP or
TCP)
TCP service: reliable transfer of bytes from
one process to another
controlled by
application
developer
controlled by
operating
system
process
process
socket
TCP with
buffers,
variables
host or
server
internet
socket
TCP with
buffers,
variables
controlled by
application
developer
controlled by
operating
system
host or
server
Rensselaer Polytechnic Institute
Shivkumar Kalvanaraman, Biplab Sikdar
58
TCP sockets
Client must contact server
server process must
first be running
server must have
created socket (door)
that welcomes clients
contact
Client contacts server by:
creating client-local
TCP socket
specifying IP address,
port number of server
process
59
TCP Sockets
inFromUser
iinFromServer
client socket
60
Client
create socket,
port=x, for
incoming request:
welcomeSocket =
ServerSocket()
TCP
setup
create socket,
connect to hostid, port=x
clientSocket =
Socket()
61
UDP Sockets
UDP: no connection
between client and
server
no handshaking
sender explicitly
attaches IP address
and port of
destination
server must extract IP
address, port of
sender from received
datagram
application viewpoint
62
(running on hostid)
create socket,
port=x, for
incoming request:
serverSocket =
DatagramSocket()
Client
create socket,
clientSocket =
DatagramSocket()
Create, address (hostid, port=x,
send datagram request
using clientSocket
63
specific protocols:
http
ftp
smtp, pop3
dns
sockets
client/server
implementation
using tcp, udp
sockets
64
message formats:
headers: fields giving
info about data
data: info being
communicated
65