ch2 APPL 2122 V01deel1

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 60

Communication Networks

P. Demeester & W. Tavernier

Chapter 2
Application Layer
Computer Networking
A Top-Down Approach
7th Edition, 2017
Pearson,
James F. Kurose, Keith W. Ross

Application Layer 2-1


Part of slides provided by J.F Kurose and K.W. Ross, All Rights Reserved
Chapter 2 outline
2.1 Principles of network applications
2.2 Web and HTTP
2.3 Electronic mail
− SMTP, POP3, IMAP
2.4 DNS
2.5 P2P applications
[2.6 video streaming and content distribution networks]
2.7 Socket programming with UDP and TCP

Application Layer 2-2


Focus : Application Layer

App 1 App 2

IP TCP-Connection
-d
a ta
gr
am

Internet Protocol
Q:router
How to communicate among
10 Mbit/s local area
56.6 kbit/s remote processes? network
modem connection

2 Mbit/s
ISDN link 100 Gbit/s WDM 140 Mbit/s
local telephone
PDH link
switch transatlantic optical cable Application Layer 2-3
Network Applications
• e-mail • voice over IP (e.g., Skype)
• web • real-time video
conferencing
• text messaging
• social networking
• remote login
• search
• P2P file sharing
• …
• multi-user network
games • …
• streaming stored video
(YouTube, Hulu, Netflix)

Q: Which application architectures can we identify?

Application Layer 2-4


Client-Server Architecture
server:
• always-on host
• permanent I P address
• data centers for scaling

clients:
• communicate with server
• may be intermittently connected
• may have dynamic I P addresses
• do not communicate directly with each other

Application Layer 2-5


Application Client - Server
CLIENT : “active open” application
transport
• invoked directly by user network
data link
• local on user’s personal computer physical

• actively initiates contact with server request


• one session at a time (per (instance of) application)
• access multiple application(s) (instances) as needed
• simple hardware and software
e.g. : Thunderbird, Outlook, Chrome, Firefox, Safari, …
reply
SERVER : “passive open”
• special purpose program for one application
• can handle multiple remote clients at same time
• runs on a shared computer application
• waits passively for contact from arbitrary remote client
transport
network
• publicly known address, port
data link
physical
• powerful hardware and sophisticated operating system
• server program also called daemon (e.g. FTP daemon)
e.g.: Apache, IIS, Sendmail, Postfix, …

Information can flow in both directions between client and server


Application Layer 2-6
Some application programs act as client and server
P2P Architecture
• no always-on server
• 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


Hybrid of client-server and P2P
• Skype
– voice-over-IP P2P application
– centralized server: finding address of remote party
– client-client connection: direct (not through server)

• Instant messaging
– chatting between two users is P2P
– centralized service: client presence detection/location
▪ user registers its IP address with central server when it
comes online
▪ user contacts central server to find IP addresses of contacts

Application Layer 2-8


Focus : Application Layer

App 1 App 2

IP TCP-Connection
-d
a ta
gr
am
Q: What doInternet
we need for
Protocol
communication
router between two 10 Mbit/s local area
56.6 kbit/s
modem connection
remote applications? network

2 Mbit/s
ISDN link 100 Gbit/s WDM 140 Mbit/s
local telephone
PDH link
switch transatlantic optical cable Application Layer 2-9
What is needed for application-
layer communication?

1. Addressing of remote processes


– Nodes (i.e., interface) on the Internet are addressed using IP
addresses (32-bit IPv4 address or 128-bit IPv6 address)
– Applications (i.e., OS processes) on the considered nodes are
addressed using a port number (16-bit value, i.e. 0-65535)

2. Type of connectivity
– Provided by the lower layer = transport layer protocol
– Two (most used) types:
▪ Reliable byte stream service = TCP
▪ Best-effort datagram service = UDP

Application Layer 2-10


1. Addressing
Examples: web browsing & DNS
Web browser Web server

TCP connectivity

• Server port numbers are


IP address: 213.118.203.222 IP address: 104.200.23.95
port: 12355 usually fixed by convention to port: 80
particular applications

• Client port numbers are


assigned (pseudo-)randomly
nslookup and temporary DNS server

UDP connectivity

IP address: 213.118.203.202 IP address: 104.200.23.95


port: 2398 port: 53

Application Layer 2-11


1. Addressing
Common server port mappings for
applications
Application Usual server port Transport Layer
Protocol
FTP 20,21 TCP

SSH 22 TCP

Telnet 23 TCP

SMTP (email transfer 25 TCP


server)
DNS 53 UDP/TCP

HTTP (web) 80 TCP

POP (email server) 109, 110 TCP

Note that these are assigned by convention (reserved as per RFC 1700).
Port numbers > 1024 can be freely used (e.g., web server at port 443)

$ sudo netstat -plnt


Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 3686/mysqld
tcp 0 0 :::443 :::* LISTEN 2218/httpd
tcp 0 0 :::80 :::* LISTEN 2218/httpd
tcp 0 0 :::22 :::* LISTEN
Application Layer 2-12
1051/sshd
2. Connectivity

What Transport Service Does An App Need?


data integrity throughput

• some apps (e.g., file transfer, • some apps (e.g., multimedia)


web transactions) require require minimum amount of
100% reliable data transfer throughput to be “effective”

• other apps (e.g., audio) can • other apps (“elastic apps”)


tolerate some loss make use of whatever
throughput they get

timing security
• some apps (e.g., Internet • encryption, data integrity, …
telephony, interactive
games) require low delay to
be “effective”

Application Layer 2-13


2. Connectivity
Type of connectivity (transport layer)
• TCP = reliable byte stream service
– Connection setup before communication (3-way handshake)
When sending “Hi!” and “Hope you’re well”

– Ensures every byte has arrived in order (acknowledgements)

Bytes stream

l l e w…e p o H ! i H
• UDP = best-effort datagram service
– UDP treats them as separate messages (of max 65507 bytes)
– Application itself must handle lost messages

Hope
Hi!
you’re well
Application Layer 2-14
Network programming using sockets
• Network communication from one process to another
remote process relies on Operating System Calls for
network programming
• Most common API is based on Berkeley Sockets:
• Socket = communication endpoint, referring to the
“door” between the application process and the end-to-
end transport protocol
application application
socket controlled by
process process app developer

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

Application Layer 2-16


Socket Example (in Python 3)
TCP Hello Server TCP Hello Client

from socket import * from socket import *

s = socket(AF_INET, SOCK_STREAM) s = socket(AF_INET, SOCK_STREAM)


s.bind(('127.0.0.1', 9999)) s.connect((’127.0.0.1’, 9999))
s.listen(5)
s.send(b'Hello, world')
while True: data = s.recv(1024)
c, addr = s.accept()
g = bytes(“Hello %s” % a[0]) s.close()
c.send(bytes(g,’utf-8’)
c.close() print 'Received', data

# start server first # next start client

$ python tcp-server.py $ python tcp-client.py


Received b'Hello 127.0.0.1\n'

Application Layer 2-17


Clarification of the socket primitives in notes
Dynamic Server Process creation
request request request
...
thread

handler 1 handler 2 handler N


pool

server
request reception and thread creation
IP address: 148.35. 2.205
TCP protocol: 6
HTTP port: 80

network

CLIENT 1 CLIENT N
CLIENT 2
IP address: 157.193.122.12 IP address: 134.182.113.65
TCP protocol: 6 IP address: 157.193.122.112 TCP protocol: 6
HTTP port: 1173 TCP protocol: 6 HTTP port:
Application 1173
Layer 2-18
HTTP port: 1212
Applications and application-layer protocols
Web browser Web server
IP:213.118.203.222 IP:104.200.23.95
port:12355 port:80

• Network Application : communicating, distributed


processes (e.g. Web, e-mail, P2P file sharing, …)
– Applications are responsible for WHAT is sent between the processes

Q: How to enable different user interfaces for the same application


(e.g., Chrome vs. Firefox, Outlook vs. Thunderbird)?

• Applications use an application-layer protocol to


implement these services
• The application layer is the collection of these protocols
(FTP, SMTP, POP, IMAP, HTTP, DNS, SNMP, etc.)
– Example: HTTP protocol: GET and POST messages Application Layer 2-19
App-layer protocol defines
• types of messages open protocols:
exchanged,
• defined in RFCs
e.g., request, response
• allows for
• message syntax: interoperability
what fields in messages &
• e.g. HTTP, SMTP
how fields are delineated
• message semantics proprietary protocols:
meaning of information in • e.g. Skype, BitTorrent
fields
• rules for when and how
processes send & respond
to messages
Application Layer 2-20
Telnet client
• You can use a telnet client (software) to play with the
protocols: HTTP, SMTP and others.
• The telnet client is a ‘generic’ TCP client:
– Sends whatever you type to the TCP socket.
– Prints whatever comes back through the TCP socket
– Useful for testing TCP servers (ASCII based protocols).

telnet command line (Linux)

Putty (Windows) Application Layer 2-21 21


Investigate simple protocols using Telnet
Some application-layer protocols which can be tested with the telnet client:
• ECHO (port 7)
• DAYTIME (port 13)
• TELNET (port 23)
• HTTP (port 80)
• …

Ask creation of a socket to 157.193.40.10 at port 13

We type Hallo and see it on the display


(Telnet operation)
We receive it a second time on the display
(Echo operation) Application Layer 2-22
^C will close the connection
Chapter 2 outline
2.1 Principles of network applications
2.2 Web and HTTP
2.3 electronic mail
− SMTP, POP3, IMAP
2.4 DNS
2.5 P2P applications
[2.6 video streaming and content distribution networks]
2.7 Socket programming with UDP and TCP

Application Layer 2-23


HTTP overview
HTTP: HyperText Transfer Protocol
• Web’s application layer protocol
to exchange Web objects (e.g.,
HT
html pages, videos, pictures) TP
req
PC running ues
HT t
• client/server model Firefox browser TPr
esp
ons
• client: browser that requests, e
receives, and “displays” Web
objects t
u es
req server
• server: Web server sends T P nse
HT s po running
objects in response to requests re Apache Web
T P
HT server
• HTTP 1.0: RFC 1945
• HTTP 1.1: RFC 2068 iPhone running
Safari browser
• HTTP 2.0: RFC 7540

Application Layer 2-24


URL : <IP address> : port / <filepath of object>
Web object example <domain/host name>

ComNet.html
Base H T ML - file which
includes several
referenced objects

ietf.gif
First referenced object (with
own url:
https://ietf.org/media/images/ietf-logo
.original.png
)

ugent.png
Second referenced object …

IDLab.jpg
Third referenced object …

Application Layer 2-25


HTTP overview
uses TCP: HTTP is “stateless”
• server is listening (open • server maintains no information
socket, port 80) about past client requests
• client initiates TCP connection
(creates socket, port >1024) aside

to server, port 80
protocols that maintain “state”
• server accepts TCP are complex!
connection from client
• past history (state) must be
• HTTP messages (application- maintained
layer protocol messages)
• if server/client crashes, their
exchanged between browser
views of “state” may be
(HTTP client) and Web server
inconsistent, must be
(HTTP server)
reconciled
• TCP connection closed
Application Layer 2-26
HTTP overview
uses TCP: HTTP is “stateless”
• server is listening (open • server maintains no information
socket, port 80) (application state) about past client
requests
• client initiates TCP connection
(creates socket, port >1024) aside

to server, port 80
protocols that maintain “state”
• server accepts TCP are complex!
connection from client
• past history (state) must be
• HTTP messages (application- maintained
layer protocol messages)
• if server/client crashes, their
exchanged between browser
views of “state” may be
(HTTP client) and Web server
inconsistent, must be
(HTTP server)
reconciled
• TCP connection closed
Application Layer 2-27
HTTP in the global picture
APPLICATION APPLICATION
CLIENT SERVER

Web Web HTML


browser server documents
GUI GUI ...
Application Layer Communicating Application Layer
Protocol processes (messages) Protocol

API:socket interface (SAP)

transport transport
network network network network
data link data link data link data link data link data link
physical physical physical physical physical physical

terminal router router terminal


Application Layer 2-28
HTTP Connections
non-persistent HTTP persistent HTTP
• at most one object • multiple objects can
sent over TCP be sent over single
connection TCP connection
connection then closed between client,
server
• downloading multiple
objects requires • HTTP/1.1 uses
multiple connections persistent
connections in
• HTTP/1.0 uses
default mode
non-persistent HTTP

Application Layer 2-29


Non-persistent HTTP (contains text,
references to 10
jpeg images)
Suppose user enters URL
idlab.technology/infrastructure/virtual-wall/index.php

1a. HTTP client initiates TCP


connection to HTTP
server (process) at
idlab.technology 1b. HTTP server at host
on port 80 www.ibcn.intec.UGent.be
waiting for TCP connection at
port 80 “accepts” connection,
2. HTTP client sends HTTP notifying client
request message (containing
URL) into TCP connection
socket. Message indicates
that client wants object 3. HTTP server receives request
infrastructure/virtual message, forms response
-wall/index.php message containing requested
object, and sends message into
its socket
time Application Layer 2-30
Non-persistent HTTP (cont.)

4. HTTP server closes TCP


connection.

5. HTTP client receives response


message containing html file,
displays html and closes TCP
connection. Parsing html file,
finds 4 referenced .gif objects

6. Steps 1-5 repeated for each of


10 jpg objects

time Application Layer 2-31


Non-persistent HTTP: Response Time
• one RTT to initiate TCP
connection
• one RTT for HTTP
request and first few initiate TCP
connection
bytes of HTTP response
RTT
to return request
file
• file transmission time time to
RTT
transmit
total = 2RTT+file transmit file
file
time received

time time

Definition of RTT (Round Trip Time) : time to send


a small packet to travel from client to server and back
Application Layer 2-32
Persistent HTTP
Nonpersistent HTTP issues: Persistent without pipelining:
• requires 2 RTTs per object • client issues new request
only when previous response
• OS must work and allocate has been received
host resources for each TCP
connection • one RTT for each referenced
object
• but browsers often open
parallel TCP connections to Persistent with pipelining:
fetch referenced objects
• default in HTTP/1.1
Persistent HTTP
• client sends requests as soon
• server leaves connection as it encounters a referenced
open after sending response object
• subsequent HTTP messages • as little as one RTT for all the
between same client/server referenced objects
are sent over connection Application Layer 2-34
HTTP request
HTTP messages
HTTP response

Request message Response message


• Client -> Server • Server -> Client
• Message structure • Message structure
Method + url headers body status headers body

• Request methods: • Status codes:


• GET • 200
http/1

• POST • 301
• HEAD • 400
• 404
• PUT • 505
http/1.1

• DELETE Application Layer 2-35


HTTP : Request Message
method SP URL SP version CR/LF request
line

...
header field name SP value CR/LF

header field name SP value CR/LF


header
lines
new
CR/LF
line
used with POST
Entity Body (e.g. when a form is filled and
transferred with the request)

GET http://www.ietf.org/ HTTP/1.1


Connection: keep-alive
User-agent: Mozilla/5.0 Chrome/69.0…
Accept: text/html,image/webp,image/apng
Accept-language: en,en-GB,nl Application Layer 2-36
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-37


HTTP : Response Message
version SP Status code SP phrase CR/LF status
line

...
header field name SP value CR/LF
header
lines
header field name SP value CR/LF
new
CR/LF line

Entity Body the requested


information
HTTP/1.1 200 OK
Date: Fri, 21 Sep 2018 13:49:54 GMT
Server: Apache/2.4.25 (Debian)
Last-Modified:
version - HTTP/1.0 orFri, 22 Sep 2017 13:05:41 GMT
HTTP/1.1
ETag: "3b2-559c6ddb38ba8-gzip"
-> status code : bytes
Accept-Ranges: number
Content-Length: 634 of status code
-> phrase : explanation
Keep-Alive:
header timeout=5, max=100
Connection: Keep-Alive Server: , Last-Modified:
- Connection: , Date: ,
Application Layer 2-38
,
Content-Type:
Content-Length: , Content-Type: , ...
text/html Application Layer 2-38
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-39


HTTP example (in the old days)
$ telnet www.ugent.be 80
Trying 157.193.40.33... connection set-up
Connected to sangoku.ugent.be.
GET HTTP://www.UGent.be/ HTTP/1.1 request to get
HTTP/1.1 200 OK UGent homepage
Date: Fri, 18 Feb 2000 15:46:11 GMT
Server: Apache/1.3.6 (Unix)
Last-Modified: Tue, 21 Dec 1999 13:44:47 GMT
ETag: "a-8ae-385f844f" reply header
Accept-Ranges: bytes
Content-Length: 2222
Connection: close
Content-Type: text/html
<html>
<head>
<title>UNIVERSITEIT GENT - UNIVERSITY OF
GHENT</title>
<style type="text/css">
...
</style> HTML document
</head> UGent homepage
<body bgcolor="#000066" link="#cccccc"
vlink="#cccccc" alink="#666666">
...
</body>
</html>
Connection closed by foreign host close connection
Application Layer 2-40
HTTP today (using HTTPS)
$ openssl s_client -crlf -connect www.ugent.be:443
<certification handshake> secure
GET / HTTP/1.1 connection set-up
HTTP/1.1 200 OK
using TLS Chapter 8
Date: Thu, 23 Sep 2021 09:35:38 GMT
Server: waitress

Accept-Ranges: bytes
Via: 1.1 www.ugent.be
Set-Cookie: ROUTEID=.1; path=/
<html>
<head>
<title>UNIVERSITEIT GENT - UNIVERSITY OF
GHENT</title>
<style type="text/css">
...
</style>
</head>
<body bgcolor="#000066" link="#cccccc"
vlink="#cccccc" alink="#666666">
...
</body>
</html>
Connection closed by foreign host
Application Layer 2-41
Application Layer 2-42
User-Server State: Cookies
Many Web sites use cookies example:
Cookies rely on four
• Susan always accesses
components:
Internet from PC
1) cookie header line of
HTTP response • visits specific e-
message commerce site for first
2) cookie header line in time
next HTTP request • when initial HTTP
message requests arrives at site,
3) cookie file kept on site creates:
user’s host, managed – unique ID
by user’s browser – entry in backend
4) back-end database at database for ID
Web site

Application Layer 2-43


Cookies: keeping “state”

client server

ebay 8734
usual http request msg Amazon server
cookie file creates ID
usual http response 1678 for user create backend
ebay 8734
set-cookie: 1678 entry database
amazon 1678

usual http request msg


cookie: 1678 cookie- access
specific
action
usual http response msg

one week later:


access
ebay 8734 usual http request msg
amazon 1678 cookie: 1678 cookie-
specific
action
usual http response msg
Application Layer 2-44
Cookies cookies and privacy: aside

what cookies can be • cookies permit sites to learn a


used for: lot about you
• you may supply name and e-
• authorization mail to sites
• shopping carts • EU GDPR law requires
explicit agreement for use of
• recommendations cookies since 2018
• 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
Application Layer 2-45
Web caches (proxy server)
Goal: satisfy client request without involving origin server

• user sets browser: Web


accesses via cache
proxy
• browser sends all HTTP HT
TP server st
ue
r eq u r eq
requests to cache client HTTP es t
HT
TP
o ns
e
r es p e s p origin
r
• object in cache: cache ons
e HT
TP server
returns object u es
t
P req e
• else cache requests TT o ns
H p
r es
object from origin server, HT
TP
then returns object to
client client origin
server

Application Layer 2-46


More About Web Caching
• cache acts as both client why Web caching?
and server
• reduce response time
• server for original for client request
requesting client
• client to origin server • reduce traffic on an
institution’s access link
• typically cache is
• Internet dense with
installed by ISP
(university, company, caches: enables “poor”
residential ISP) content providers to
effectively deliver
content
(so too does P2P file sharing)

Application Layer 2-47


Conditional GET: client-side caching

Goal: don’t send object if client client server


has up-to-date cached version
HTTP request msg
• no object transmission delay If-modified-since:
object
• lower link utilization <date>
not
• client: specify date of cached HTTP response modified
copy in HTTP request HTTP/1.0
304 Not Modified
If-modified-since:
<date>

• server: response contains no HTTP request msg


If-modified-since:
object if cached copy is up-to- <date> object
date: modified
HTTP/1.0 304 Not HTTP response
Modified HTTP/1.0 200 OK
<data>
Application Layer 2-48
HTTP evolution and versions
HTTP/1.0 HTTP/1.1 HTTP2.0

GET, POST Persistent connections Improve page load speed


(decreasing latency)
• Data compression of HTTP
headers
• Multiplexing multiple
requests
• HTTP/2 Server Push

HEAD OPTIONS method Longer lived (~permanent)


asks server to leave Used to determine abilities HTTP connections
requested object out of of the server.
response

PUT Additional caching, HTTP/2 is a binary protocol


uploads file in entity body authenti- cation & instead of text-based (as 1.*)
to path specified in U RL compression options
field
DELETE
deletes file specified in the
U RL field

increasing performance

Application Layer 2-49


HTTP/2 to HTTP/3

HTTP/2 over single TCP connection means:


 recovery from packet loss still stalls all object transmissions
• as in HTTP 1.1, browsers have incentive to open multiple parallel
TCP connections to reduce stalling, increase overall throughput
 no security over vanilla TCP connection
 HTTP/3: adds security, per object error- and congestion-
control (more pipelining) over UDP
• more on HTTP/3 in transport layer

Application Layer 2-50


Chapter 2 outline
2.1 Principles of network applications
2.2 Web and HTTP
2.3 electronic mail
− SMTP, POP3, IMAP
2.4 DNS
2.5 P2P applications
[2.6 video streaming and content distribution networks]
2.7 Socket programming with UDP and TCP

Application Layer 2-57


History of email
ARPANET

1971: 1988:
1982: MSMail 1993: 2004:
Invention SMTP (Outlook Webmail Gmail
of email v0)

1976: The 1978: First 1991: First


> 2010:
1992:
Queen's
first email
spam
email
email from
space
MIME fighting
spam

Application Layer 2-58


Electronic mail
User agent (UA)
Email client
(e.g. Outlook, Thunderbird, Message Transfer Agent (MTA)
smartphone mail client ) Email server, SMTP server
(e.g. sendmail)
SMTP
mail
SMTP Port 25
server there may be
Simple Mail Transfer Protocol intermediate
MTA’s

Internet SMTP

SMTP outgoing
Port 25 message queue
user mailbox
POP3 mail
POP3 server
Post Office Protocol Port 110

Application Layer 2-59


Electronic mail protocols/formats
SMTP (Simple Mail Transfer Protocol) :
transfer e-mail message from UA to MTA or between MTAs
POP3 (Post Office Protocol 3)
retrieve e-mail from MTA
IMAP (Internet Message Access Protocol)
advanced retrieve of e-mail from MTA
intelligence in MTA (also advanced database structure)

RFC 822 (message format)  not a protocol !


format of a plain text message
MIME (Multipurpose Internet Mail Extensions)  not a protocol !
format and coding of non plain text messages (e.g. JPEG, Word)
and split into several sub-messages (e.g. attachments)
Application Layer 2-60
Electronic mail : SMTP [RFC 2821]
Server port 25
acnet0:/home/staff/janedoe$ telnet mailserver.intec.ugent.be 25
Trying 157.193.84.4...
Connected to mailserver.intec.ugent.be.
Escape character is '^]'.
220 mailserver.intec.ugent.be ESMTP Sendmail 8.9.0/8.9.0; Fri, 11 Feb 2018 10:36:18
+0100 (MET)
HELO intec.ugent.be
250 mailserver.intec.ugent.be Hello acnet0.intec.ugent.be [157.193.84.63],

Handshaking
pleased to meet you
MAIL FROM:<[email protected]>
250 <[email protected]>... Sender ok
RCPT TO:<[email protected]>
250 <[email protected]>... Recipient ok
DATA

Message
354 Enter mail, end with "." on a line by itself
Subject: example message
John,
hier een kleine test-boodschap.

Close
.
250 KAA29013 Message accepted for delivery

Application Layer 2-61


Remark: both commands and text in ASCII
Electronic mail : POP3

intec2:home/staff/johndoe$ telnet allserv.ugent.be 110


Trying 157.193.40.42...
Connected to allserv.ugent.be.
Escape character is '^]'.
+OK QPOP (version 2.2) at allserv.ugent.be starting.
<[email protected]>
USER johndoe
+OK Password required for johndoe.
PASS <right password>
+OK johndoe has 145 messages (8421978 octets).
STAT
+OK 145 8421978
LIST 125
+OK 125 1596
RETR 125
+OK 1596 octets
< RFC822-headers + MIME-headers + message contents> (see later slides)

Application Layer 2-62


POP3 (as HTTP) : pull protocol <> SMTP : push protocol
IMAP (Internet Message Access Protocol)
• 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

IMAP (port 143) IMAP (port 25) SMTP


mail
server
+ archive

Application Layer 2-63


Web based e-mail access : HTTP protocol – e.g. gmail.com
Mail message format
[SMTP: protocol for
exchanging email msgs]
header
RFC 822: standard for text blank
message format: line

• header lines, e.g.,


• To: body

• From:
• Subject:
different from SMTP
commands !

• body
• the “message”, ASCII
characters only
Application Layer 2-64
Message format: multimedia extensions
• MIME (Multipurpose Internet Mail Extensions) :
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
(base64: 6 bits encoding)
Application Layer 2-65
BASE64

Application Layer 2-66


Mail message format example
Return-Path: <[email protected]>
Delivered-To: [email protected]
Received: from mserv.rug.ac.be (mserv.rug.ac.be [157.193.40.37])
by allserv.rug.ac.be (8.9.3/8.9.3) with ESMTP id RAA19192
for <[email protected]>; Fri, 11 Feb 2000 10:39:45 +0100
(MET)
Received: from mailserver.intec.rug.ac.be (mailserver.intec.rug.ac.be
[157.193.84.3])
by mserv.rug.ac.be (8.9.3/8.9.3) with ESMTP id RAA21860 RFC 822
for <[email protected]>; Fri, 11 Feb 2000 10:39:19 +0100 (MET)
Received: from acnet0.intec.rug.ac.be (acnet0.intec.rug.ac.be headers
[157.193.84.63])
by mailserver.intec.rug.ac.be (8.9.3/8.9.3) with SMTP id RAA19039
for <[email protected]>; Fri, 11 Feb 2000 10:38:41 +0100 (MET)
Date: Fri, 11 Feb 2000 10:38:41 +0100 (MET)
From: Jane Doe <[email protected]>
Subject: example message
Message-Id: <[email protected]>
MIME-Version: 1.0 MIME
Content-Type: text
Content-Length: 34 headers
John,
hier een kleine test-boodschap. Message
.

Application Layer 2-67


Mail message format example (with 2 attachments)
<RFC822 headers left away>
Mime-Version: 1.0
RFC 822 headers
Content-Type: multipart/mixed; boundary="=====================_909671503==_"
X-UIDL: 8adae81620fdf73614975fcaa08a3ed5
Status: O
X-Status:
MIME
--=====================_909671503==_ header
Content-Type: text/plain; charset="us-ascii"

John,
This is an email message with two attached MS-Word documents.
Message
--=====================_909671503==_
Content-Type: application/msword; name="MIMEtest1.doc";
x-mac-type="42494E41"; x-mac-creator="4D535744"
MIME
Content-Transfer-Encoding: base64 header
Content-Disposition: attachment; filename="MIMEtest1.doc"

0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAAPgADAP7/CQAGAAAAAAAAAAAAAAABAAAAIQAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
...
Attachment1
AAAAAAAAAAAAAAAAAAAAAAAAAA==
--=====================_909671503==_
Content-Type: application/msword; name="MIMEtest2.doc";
x-mac-type="42494E41"; x-mac-creator="4D535744"
MIME
Content-Transfer-Encoding: base64 header
Content-Disposition: attachment; filename="MIMEtest2.doc"

0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAAPgADAP7/CQAGAAAAAAAAAAAAAAABAAAAIQAAAAAAAAAA
EAAAIwAAAAEAAAD+////AAAAACAAAAD/////////////////////////////////////////////
...
Attachment2
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAA==
--=====================_909671503==_--
.
End Of Layer
Application Message
2-68

You might also like