Application Layer Protocols
for the Internet
(selected notes)
HTTP : HyperText Transfer
Protocol
Sockets are communication portals between client and server
Sockets are API between OS/network and application
Internet sockets implemented using either TCP or UDP
We'll focus on TCP
Guaranteed error-free and sequenced delivery
Connection-oriented stream service
Basic protocol for TCP-based sockets
3-way handshake to establish client-server connection
two way communication through connection socket
close connection socket
Some links on sockets programming in C/C++:
Course notes on client-server interaction. (www.cs.smsu.edu/~pete/csc465/spring97/notes/Chap21.html)
(www.cs.smsu.edu/~pete/csc465/spring97/notes/Chap22.html)
(www.cs.smsu.edu/~pete/csc465/spring97/notes/Chap23.html)
Old as the hills
RFC 959.
Utilizes 2 TCP connections:
Control connection is persistent
Data connection is non-persistent
FTP server maintains state throughout session (e.g. current directory)
Commands are plaintext
Common client commands are:
Each command results in
response from server: 3 digit code followed by message
Try it out (can at least log in)
Components are:
User agent (mail reader)
Mail server
· holds received messages (mailbox)
· sends messages (outgoing message queue)
Protocol between mail servers: SMTP
Protocol between user agent and mail server:
· POP
· IMAP
· HTTP
· ??
Electronic trail Alice to Bob:
SMTP : Simple Mail Transfer Protocol
Example SMTP session
(my commands are bolded)
> telnet csc.smsu.edu 25
Trying 146.7.45.212...
Connected to csc.smsu.edu.
Escape character is '^]'.
220 csc.smsu.edu ESMTP Sendmail 8.11.1/8.11.1; Mon, 5 Feb
2001 08:44:37 -0600 ()
250 csc.smsu.edu Hello csc.smsu.edu [146.7.45.212], pleased
to meet you
250 2.1.0 <dps910f@smsu.edu>... Sender ok
250 2.1.5 <pete@csc.smsu.edu>... Recipient ok
354 Enter mail, end with "." on a line by itself
TO: Charlie Brown
FROM:Lucy
SUBJECT: football
Charlie, I promise I will not pull away
the football when
you kick off.
.
250 2.0.0 f15Eiu537020 Message accepted for delivery
221 2.0.0 csc.smsu.edu closing connection
Connection closed by foreign host.
>
Resulting message is:
Date: Mon, 5 Feb 2001 08:45:22 -0600 (CST)
From: Lucy
To: Charlie, Brown
Subject: football
Charlie, I promise I will not pull away the football when
you kick off.
NOTE CORRECTION ON PAGE 111 OF BOOK: at end of first paragraph, change "HELO crepes.fr" with "MAIL FROM:"
·
Connection is persistent
: can send multiple messages by starting each new one with MAIL FROM:
MIME : Multipurpose Internet Mail Extensions
Mail Access Protocols
POP3 : Post Office Protocol version 3
IMAP : Internet Mail Access Protocol
3. State and Flow Diagram
An IMAP4rev1 server is in one of four states. Most commands are
valid in only certain states. It is a protocol error for the client
to attempt a command while the command is in an inappropriate state.
In this case, a server will respond with a BAD or NO (depending upon
server implementation) command completion result.
3.1. Non-Authenticated State
In non-authenticated state, the client MUST supply authentication
credentials before most commands will be permitted. This state is
entered when a connection starts unless the connection has been pre-
authenticated.
3.2. Authenticated State
In authenticated state, the client is authenticated and MUST select a
mailbox to access before commands that affect messages will be
permitted. This state is entered when a pre-authenticated connection
starts, when acceptable authentication credentials have been
provided, or after an error in selecting a mailbox.
3.3. Selected State
In selected state, a mailbox has been selected to access. This state
is entered when a mailbox has been successfully selected.
3.4. Logout State
In logout state, the connection is being terminated, and the server
will close the connection. This state can be entered as a result of
a client request or by unilateral server decision.
+--------------------------------------+
|initial connection and server greeting|
+--------------------------------------+
|| (1) || (2) || (3)
VV || ||
+-----------------+ || ||
|non-authenticated| || ||
+-----------------+ || ||
|| (7) || (4) || ||
|| VV VV ||
|| +----------------+ ||
|| | authenticated |<=++ ||
|| +----------------+ || ||
|| || (7) || (5) || (6) ||
|| || VV || ||
|| || +--------+ || ||
|| || |selected|==++ ||
|| || +--------+ ||
|| || || (7) ||
VV VV VV VV
+--------------------------------------+
| logout and close connection |
+--------------------------------------+
(1) connection without pre-authentication (OK greeting)
(2) pre-authenticated connection (PREAUTH greeting)
(3) rejected connection (BYE greeting)
(4) successful LOGIN or AUTHENTICATE command
(5) successful SELECT or EXAMINE command
(6) CLOSE command, or failed SELECT or EXAMINE command
(7) LOGOUT command, server shutdown, or connection closed
Example IMAP session
(my commands are bolded)
> telnet csc.smsu.edu 143
Trying 146.7.45.212...
Connected to csc.smsu.edu.
Escape character is '^]'.
* OK [CAPABILITY IMAP4 IMAP4REV1 LOGIN-REFERRALS AUTH=LOGIN]
csc.smsu.edu IMAP4r
ev1 2000.284 at Tue, 6 Feb 2001 20:53:10 -0600 (CST)
A002 LOGIN pete myPassword
* CAPABILITY IMAP4 IMAP4REV1 NAMESPACE IDLE
MAILBOX-REFERRALS SCAN SORT THREAD=R
EFERENCES THREAD=ORDEREDSUBJECT MULTIAPPEND
A002 OK LOGIN completed
A003 SELECT INBOX
* 31 EXISTS
* 0 RECENT
* OK [UIDVALIDITY 915631092] UID validity status
* OK [UIDNEXT 4315] Predicted next UID
* FLAGS (\Answered \Flagged \Deleted \Draft \Seen)
* OK [PERMANENTFLAGS (\* \Answered \Flagged \Deleted \Draft
\Seen)] Permanent fl
ags
A003 OK [READ-WRITE] SELECT completed
A004 SEARCH ALL
* SEARCH 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
A004 OK SEARCH completed
A005 SEARCH UNSEEN
* SEARCH
A005 OK SEARCH completed
A006 FETCH 29 (FLAGS BODY[HEADER.FIELDS (DATE FROM)])
* 29 FETCH (FLAGS (\Seen) BODY[HEADER.FIELDS
("DATE" "FROM")] {89}
Date: Mon, 22
Jan 2001 16:17:26 -0500
From: Scott Grissom <grissom@GVSU.EDU>
)
A006 OK FETCH completed
A007 LOGOUT
* BYE csc.smsu.edu IMAP4rev1 server terminating connection
A007 OK LOGOUT completed
Connection closed by foreign host.
Resolver is library function that application calls to request translation of name to IP address. In Unix, this is “gethostbyname(string)” It issues original DNS request and application suspends until it returns with either pointer to data structure with requested info or null pointer.
Local name server is within organization (or ISP) of requester. This is who resolver asks first.
Root name server is at tip of hierarchy. There are currently 13 worldwide (but they are replicated). If local name server cannot map resolver’s
request (either from its database or cache), it asks root server. Called “root” because it handles only
top-level domain (TLD), e.g. the suffix that appears after the last period
(.com, .edu, .fr, etc).
Domain names and numbers
are controlled by ICANN, the Internet Corporation for Assigned Names and
Numbers. See www.icann.org.
There are renegade
“alternative root servers” out there, supporting ICANN’s TLDs plus a slew of
others.
·
Iperdome, www-iperdome.com, offers personal domain
services under “.per” domain.
·
TINC, The Internet
Namespace Cooperative, www.tinc-org.com,
also supports alternative root servers, and has a form that allows you to test
it out (the proxy) by typing in an URL from among domains it supports (try
www.b).
·
OpenNIC is yet another
alternative, www.opennic.unrated.net/.
·
And others. See if you can find more.
Authoritative name server is the one whose database (not cache) contains DNS entry for a requested host.
Intermediate name server is one that root server (or another intermediate name server) knows about but which turns out not to be the authoritative server for a given request.
Caching is crucial to DNS performance. Info from DNS response (containing results) is put into name server cache as it passes through on return trip to resolver.
Resource Record is DNS database or cache entry. Fields are:
Example: A worst case for “www.cs.pitt.edu” is this:
Recursive query: each client in chain issues DNS request on behalf of original requester and gets definitive response - resource record(s) or error. The “www.cs.pitt.edu” example above is of this type.
Iterative query: client may get a “referral” response that contains address of a different DNS server for client to ask.
Same example as above, only using iterative approach:
(NOTE: steps 5-8 are
unlikely to occur this way; more likely the “pitt.edu” server will ask the
“cs.pitt.edu” directly. Thus a
combination of iterative and recursive)
[notes | CSC 465 | Peter Sanderson | Computer Science | SMSU ]