Lecture 6
Lecture 6
Lecture 6
Lecture 6
OSI
TCP/IP
MODEL
APPLICATION
7 APPLICATION
TRANSPORT
TRANSPORT
4 Tranmission Control Protocol (TCP)
User Datagram Protocol (UDP)
INTERNETWORKING
NETWORK
3 Internet Protocol (IP)
Internet Control Message Protocol (ICMP)
NETWORK INTERFACE
DATA LINK
&
2
HARDWARE
CONNECTIONS
PHYSICAL
LAN: Ethernet, Token Ring, FDDI, ATM...
1
WAN: SLIP/PPP, X.25, Frame Relay...
P2
1
Chapter 2
Application Layer
Chapter 2: outline
2.1 principles of network 2.6 P2P applications
applications 2.7 socket programming
app architectures with UDP and TCP
app requirements
2.2 Web and HTTP
2.3 FTP
2.4 electronic mail
SMTP, POP3, IMAP
2.5 DNS
2
Electronic mail outgoing
message queue
user mailbox
Three major components: user
agent
user agents
mail servers mail user
server agent
simple mail transfer
protocol: SMTP SMTP mail user
server agent
3
Electronic Mail: SMTP [RFC 2821]
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 (like HTTP, FTP)
commands: ASCII text
response: status code and phrase
messages must be in 7-bit ASCI
Application Layer 2-7
4
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
above lets you send email without using email client (reader)
5
SMTP: final words
SMTP uses persistent comparison with HTTP:
connections
HTTP: pull
SMTP requires message
(header & body) to be in SMTP: push
7-bit ASCII both have ASCII
SMTP server uses command/response
CRLF.CRLF to interaction, status codes
determine end of message
HTTP: each object
encapsulated in its own
response msg
SMTP: multiple objects
sent in multipart msg
6
Mail access protocols
user
mail access user
SMTP SMTP protocol agent
agent
(e.g., POP,
IMAP)
POP3 protocol
S: +OK POP3 server ready
C: user bob
authorization phase S:
C:
+OK
pass hungry
client commands: S: +OK user successfully logged on
user: declare username
pass: password C: list
S: 1 498
server responses
S: 2 912
+OK S: .
-ERR C: retr 1
transaction phase, client: S:
S:
<message 1 contents>
.
list: list message numbers C: dele 1
retr: retrieve message by C: retr 2
number S: <message 1 contents>
dele: delete S: .
quit C: dele 2
C: quit
S: +OK POP3 server signing off
Application Layer 2-14
7
POP3 (more) and IMAP
more about POP3 IMAP
previous example uses keeps all messages in one
POP3 “download and place: at server
delete” mode allows user to organize
Bob cannot re-read e- messages in folders
mail if he changes keeps user state across
client sessions:
POP3 “download-and- names of folders and
keep”: copies of messages mappings between
on different clients message IDs and folder
POP3 is stateless across name
sessions
Chapter 2: outline
2.1 principles of network 2.6 P2P applications
applications 2.7 socket programming
app architectures with UDP and TCP
app requirements
2.2 Web and HTTP
2.3 FTP
2.4 electronic mail
SMTP, POP3, IMAP
2.5 DNS
8
DNS: domain name system
people: many identifiers: Domain Name System:
SSN, name, passport # distributed database
Internet hosts, routers: implemented in hierarchy of
IP address (32 bit) - many name servers
used for addressing application-layer protocol: hosts,
datagrams name servers communicate to
“name”, e.g., resolve names (address/name
www.yahoo.com - translation)
used by humans note: core Internet function,
Q: how to map between IP implemented as application-
layer protocol
address and name, and
vice versa ? complexity at network’s
“edge”
9
DNS: a distributed, hierarchical database
Root DNS Servers
… …
10
TLD, authoritative servers
top-level domain (TLD) servers:
responsible for com, org, net, edu, aero, jobs, museums,
and all top-level country domains, e.g.: uk, fr, ca, jp
Network Solutions maintains servers for .com TLD
Educause for .edu TLD
authoritative DNS servers:
organization’s own DNS server(s), providing
authoritative hostname to IP mappings for organization’s
named hosts
can be maintained by organization or service provider
11
DNS name root DNS server
resolution example
2
host at cis.poly.edu 3
TLD DNS server
wants IP address for 4
gaia.cs.umass.edu
5
gaia.cs.umass.edu
gaia.cs.umass.edu
12
DNS: caching, updating records
once (any) name server learns mapping, it caches
mapping
cache entries timeout (disappear) after some time (TTL)
TLD servers typically cached in local name servers
• thus root name servers not often visited
cached entries may be out-of-date (best effort
name-to-address translation!)
if name host changes IP address, may not be known
Internet-wide until all TTLs expire
update/notify mechanisms proposed IETF standard
RFC 2136
DNS records
DNS: distributed db storing resource records (RR)
RR format: (name, value, type, ttl)
type=A type=CNAME
name is hostname name is alias name for some
value is IP address “canonical” (the real) name
type=NS www.ibm.com is really
name is domain (e.g., servereast.backup2.ibm.com
foo.com) value is canonical name
value is hostname of
authoritative name type=MX
server for this domain value is name of mailserver
associated with name
13
DNS protocol, messages
query and reply messages, both with same message
format 2 bytes 2 bytes
2 bytes 2 bytes
identification flags
14