Application Layer: CPE 400 / 600 Computer Communication Networks
Application Layer: CPE 400 / 600 Computer Communication Networks
Lecture 5
Chapter 2
Application Layer
2.5 DNS
2.6 P2P applications
2.7 Socket programming with TCP
2.8 Socket programming with UDP
2: Application Layer 2
Processes communicating
host or host or
server
Process:
server
Message syntax:
what fields in messages & how fields are delineated
Message semantics
meaning of information in fields
2: Application Layer 5
Internet transport protocols services
TCP service:
connection-oriented: setup required between client and server
processes
reliable transport between sending and receiving process
flow control: sender won’t overwhelm receiver
congestion control: throttle sender when network overloaded
does not provide: timing, minimum throughput guarantees,
security
UDP service:
unreliable data transfer between sending and receiving process
does not provide: connection setup, reliability, flow control,
congestion control, timing, throughput guarantee, or security
2: Application Layer 6
HTTP overview
Web page consists of base HTML-file
which includes several referenced
objects
Each object is addressable by a URL
PC running
Explorer
HTTP: hypertext transfer protocol
Web’s application layer protocol
client/server model
Server
running
client: browser that requests,
Apache Web receives, “displays” Web objects
server server: Web server sends objects
in response to requests
Mac running uses TCP
Navigator
is “stateless”
2: Application Layer 7
HTTP connections
Nonpersistent HTTP Persistent HTTP
At most one object is Multiple objects can
sent over a TCP be sent over single
connection. TCP connection
between client and
server.
2: Application Layer 8
Non-Persistent HTTP: Response time
Definition of RTT: time for a
small packet to travel from
client to server and back.
initiate TCP
connection
Response time: RTT
Persistent HTTP
server leaves connection open after sending response
subsequent HTTP messages between same client/server sent
over open connection
client sends requests as soon as it encounters a referenced
object
as little as one RTT for all the referenced objects
2: Application Layer 10
HTTP messages
two types of HTTP messages: request, response
HTTP request message:
ASCII (human-readable format)
2: Application Layer 11
Method types
HTTP/1.0 HTTP/1.1
GET GET, POST, HEAD
request an object from PUT
server uploads file in entity
POST body to path specified
upload information using in URL field
forms DELETE
HEAD deletes file specified in
2: Application Layer 12
Cookies: Keeping state
What cookies can bring:
authorization aside
Cookies and privacy:
shopping carts
cookies permit sites to
recommendations learn a lot about you
user session state (Web you may supply name
e-mail) and e-mail to sites
2: Application Layer 13
Web caches (proxy server)
Goal: satisfy client request without involving origin server
user sets browser: origin
Web accesses via cache server
2.5 DNS
2: Application Layer 16
FTP: the file transfer protocol
2: Application Layer 17
FTP: separate control, data connections
TCP control connection
port 21
FTP client contacts FTP server
at port 21
client authorized over TCP data connection
FTP port 20 FTP
control connection client server
client browses remote directory
by sending commands over control connection.
when server receives file transfer command, server opens 2nd TCP
connection (for file) to client
after transferring one file, server closes data connection.
server opens another TCP data connection to transfer another file.
control connection: “out of band”
FTP server maintains “state”: current directory, earlier
authentication
2: Application Layer 18
FTP commands, responses
Sample commands:
sent as ASCII text over control channel
USER username
PASS password
Solution
Secure FTP (SSH FTP)
• allows a range of operations on remote files
FTPS ( FTP over Secure Sockets Layer (SSL) )
Transport Layer Security (TLS) encryption
2: Application Layer 20
Lecture 5: Outline
2.1 Principles of network applications
2.2 Web and HTTP
2.3 FTP
2.4 Electronic Mail
SMTP
POP3
IMAP
2.5 DNS
2: Application Layer 21
Electronic Mail outgoing
message queue
user mailbox
Three major components: user
agent
user agents
mail
mail servers user
server
agent
simple mail transfer
protocol: SMTP SMTP mail
server user
User Agent SMTP agent
a.k.a. “mail reader”
composing, editing, reading
SMTP
mail user
mail messages server agent
e.g., Eudora, Outlook, elm,
Mozilla Thunderbird user
agent
outgoing, incoming messages user
stored on server agent
2: Application Layer 22
Electronic Mail: mail servers
2: Application Layer 23
Electronic Mail: SMTP [RFC 2821]
2: Application Layer 24
Scenario: Alice sends message to Bob
1) Alice uses UA to compose message and “to”
[email protected]
2) Alice’s UA sends message to her mail server; message placed
in message queue
3) Client side of SMTP opens TCP connection with Bob’s mail
server
4) SMTP client sends Alice’s message over the TCP connection
5) Bob’s mail server places the message in Bob’s mailbox
6) Bob invokes his user agent to read message
1 mail
mail
server user
user server
2 agent
agent 3 6
4 5
2: Application Layer 25
Sample SMTP interaction
S: 220 hamburger.edu
C: HELO crepes.fr
S: 250 Hello crepes.fr, pleased to meet you
C: MAIL FROM: <[email protected]>
S: 250 [email protected]... Sender ok
C: RCPT TO: <[email protected]>
S: 250 [email protected] ... 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
2: Application Layer 26
SMTP: final words
SMTP uses persistent connections
SMTP requires message (header & body) to be in 7-bit ASCII
SMTP server uses CRLF.CRLF to determine end of message
2: Application Layer 27
Mail message format
body
body
the “message”,
ASCII characters only
2: Application Layer 28
Message format: multimedia extensions
MIME: multimedia mail extension, RFC 2045, 2056
additional lines in msg header declare MIME content type
From: [email protected]
MIME version To: [email protected]
Subject: Picture of yummy crepe.
method used MIME-Version: 1.0
to encode data Content-Transfer-Encoding: base64
Content-Type: image/jpeg
multimedia data
type, subtype, base64 encoded data .....
parameter declaration .........................
......base64 encoded data
encoded data
2: Application Layer 29
Mail access protocols
SMTP SMTP access user
user
agent protocol agent
2: Application Layer 30
POP3 protocol S: +OK POP3 server ready
C: user bob
authorization phase S: +OK
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
S: .
+OK
C: retr 1
-ERR S: <message 1 contents>
transaction phase, client: S: .
C: dele 1
list: list message numbers C: retr 2
retr: retrieve message by S: <message 1 contents>
number S: .
C: dele 2
dele: delete
C: quit
quit S: +OK POP3 server signing off
2: Application Layer 31
POP3 (more) and IMAP
More about POP3
Previous example uses “download and delete” mode.
Bob cannot re-read e-mail if he changes client
“Download-and-keep”: copies of messages on
different clients
POP3 is stateless across sessions
IMAP
Keep all messages in one place: the server
Allows user to organize messages in folders
IMAP keeps user state across sessions:
names of folders and mappings between message IDs and
folder name
2: Application Layer 32
Try SMTP interaction for yourself:
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)
2: Application Layer 33
Lecture 5: Outline
2.1 Principles of network applications
2.2 Web and HTTP
2.3 FTP
2.4 Electronic Mail
SMTP
POP3
IMAP
2.5 DNS
2: Application Layer 34
DNS: Domain Name System
People: many identifiers:
SSN, name, passport #
Internet hosts, routers:
IP address (32 bit) - used for addressing datagrams
“name”, e.g., ww.yahoo.com - used by humans
Domain Name System:
distributed database implemented in hierarchy of many name
servers
application-layer protocol host, routers, name servers to
communicate to resolve names (address/name translation)
note: core Internet function, implemented as application-
layer protocol
complexity at network’s “edge”
2: Application Layer 35
DNS services
hostname to IP address translation
host aliasing
Canonical, alias names
2: Application Layer 38