Professional Documents
Culture Documents
Trying Out HTTP (Client Side) For Yourself: 1. Telnet To Your Favorite Web Server
Trying Out HTTP (Client Side) For Yourself: 1. Telnet To Your Favorite Web Server
32 ©Vaide Narvaez
User-server interaction: cookies
Many major Web sites Example:
use cookies Susan always access
Four components: Internet from home PC
1) cookie header line of visits specific e-commerce
HTTP response message site for first time
2) cookie header line in
when initial HTTP
HTTP request message
requests arrives at site,
3) cookie file kept on user’s
site creates:
host, managed by user’s
browser unique ID
4) back-end database at entry in backend database
33 ©Vaide Narvaez
Cookies: keeping “state” (cont.)
client server
ebay 8734
usual http request msg
Amazon server
cookie file usual http response creates ID
Set-cookie: 1678 1678 for user create
ebay 8734 entry
amazon 1678
usual http request msg
cookie: 1678 cookie- access
specific
one week later: usual http response msg action backend
database
access
ebay 8734
usual http request msg
amazon 1678
cookie: 1678 cookie-
spectific
usual http response msg action
34 ©Vaide Narvaez
Cookies (continued)
What cookies can bring: Cookies and privacy:
authorization cookies permit sites to
shopping carts learn a lot about you
recommendations you may supply name and e-
mail to sites
user session state (Web e-
mail)
How to keep “state”:
protocol endpoints:
maintain state at sender/
receiver over multiple
transactions
cookies: http messages
carry state
35 ©Vaide Narvaez
Web caches (proxy server)
Goal: satisfy client request without involving origin server
36 ©Vaide Narvaez
More about Web caching
cache acts as both client and Why Web caching?
server reduce response time for
typically cache is installed by client request
ISP (university, company, reduce traffic on an
residential ISP) institution’s access link.
Internet dense with caches:
enables “poor” content
providers to effectively
deliver content (but so does
P2P file sharing)
37 ©Vaide Narvaez
Conditional GET
Goal: don’t send object
server
if cache has up-to-date cache
cached version HTTP request msg
If-modified-since:
cache: specify date of <date>
object
not
cached copy in HTTP
HTTP response modified
request HTTP/1.0
If-modified-since: <date> 304 Not Modified
40 ©Vaide Narvaez
FTP: separate control and data connections
TCP control connection
FTP client contacts FTP server at port 21
port 21, TCP is transport protocol
client authorized over control TCP data connection
connection FTP port 20 FTP
client server
client browses remote directory by
sending commands over control ❒ server opens another TCP data
connection. connection to transfer another
when server receives file transfer file.
command, server opens 2nd TCP ❒ control connection: “out of band”
connection (for file) to client
❒ FTP server maintains “state”:
after transferring one file, server current directory, earlier
closes data connection. authentication
41 ©Vaide Narvaez
E-mail
43 ©Vaide Narvaez
Electronic Mail: mail servers
user
Mail Servers agent
mailbox contains incoming mail
user
messages for user server
agent
message queue of outgoing (to be SMTP
sent) mail messages mail
server user
SMTP protocol between mail
SMTP agent
servers to send email messages
client: sending mail server SMTP
mail user
“server”: receiving mail server agent
server
user
agent
user
agent
44 ©Vaide Narvaez
Electronic Mail: SMTP
uses TCP to reliably transfer email message from client to server,
port 25
direct transfer: sending server to receiving server
three phases of transfer
handshaking (greeting)
transfer of messages
closure
command/response interaction
commands: ASCII text
response: status code and phrase
45 ©Vaide Narvaez
Scenario: Alice sends message to Bob
1) Alice uses UA to compose 4) SMTP client sends Alice’s
message to message over the TCP
bob@someschool.edu connection
2) Alice’s UA sends message to her 5) Bob’s mail server places the
mail server; message placed in message in Bob’s mailbox
message queue 6) Bob invokes his user agent to
3) Client side of SMTP opens TCP read message
connection with Bob’s mail
server
1 mail
mail
server user
user server
2 agent
agent 3 6
4 5
46 ©Vaide Narvaez
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
47 ©Vaide Narvaez
Try SMTP interaction for yourself:
telnetmail.payap.ac.th 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)
48 ©Vaide Narvaez
SMTP: final words
SMTP uses persistent connections Comparison with HTTP:
SMTP requires message (header &
HTTP: pull
body) to be in 7-bit ASCII
SMTP: push
SMTP server uses CRLF.CRLF to
determine end of message both have ASCII command/
response interaction, status codes
49 ©Vaide Narvaez
Mail access protocols
SMTP SMTP access user
user
agent protocol agent
50 ©Vaide Narvaez
telnet mail.payap.ac.th 110
POP3 protocol S: +OK POP3 server ready
C: user bob
S: +OK
authorization phase C: pass hungry
client commands: S: +OK user successfully logged on
user: declare username
C: list
pass: password
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 numbers C: dele 1
retr: retrieve message by C: retr 2
number S: <message 1 contents>
dele: delete S: .
C: dele 2
quit C: quit
S: +OK POP3 server signing off
51 ©Vaide Narvaez
POP3 (more) and IMAP
More about POP3 IMAP
Previous example uses Keep all messages in one
“download and delete” place: the server
mode. Allows user to organize
Bob cannot re-read e-mail messages in folders
if he changes client IMAP keeps user state
“Download-and-keep”: across sessions:
copies of messages on names of folders and
different clients mappings between message
IDs and folder name
POP3 is stateless across
sessions
52 ©Vaide Narvaez