SDSU CS 580 Client-Server Programming
Fall Semester, 2002
Client-Server Protocols & POP
Previous    Lecture Notes Index    Next    
© 2002, All Rights Reserved, SDSU & Roger Whitney
San Diego State University -- This page last updated 10-Oct-02

Contents of Doc 14, Client-Server Protocols & POP



Reference

Reference RFC 1939, http://www.ietf.org/rfc/rfc1939.txt

CS 580, Spring 1997 lecture notes, http://www.eli.sdsu.edu/courses/spring97/cs596/notes/protocol/protocol.html



Doc 14, Client-Server Protocols & POP Slide # 2

Protocol


Communication between client and server


Good protocols are hard to design


Requirements for a "good protocol":







Doc 14, Client-Server Protocols & POP Slide # 3

Well defined


Every bit of data sent in either direction has to have its place in the protocol description.

Protocol is a Language

Common formal description:

BNF and Augmented BNF

Format of the description language needs to be part of the protocol document.

Examples are important


Doc 14, Client-Server Protocols & POP Slide # 4

Complete


The protocol must cover all possible situations.



Doc 14, Client-Server Protocols & POP Slide # 5

Parsable


Both clients and servers are computer programs.

A computer program's IQ is generally 0.

Design goals:

Allow parsing independent of semantics

Allow for code reuse

For example name-value pairs


Doc 14, Client-Server Protocols & POP Slide # 6

Available


Different groups may write clients and servers at different times.

Central registry for Internet protocols

Self regulating:


Official:



Doc 14, Client-Server Protocols & POP Slide # 7

Protocol Types


Two basic types



Typical synchronous


Examples

HTTP, POP, SMTP, GOPHER, XMODEM


Typical asynchronous

Client and server both send information to each other concurrently.

Examples

TELNET, RLOGIN, ZMODEM


A hybrid protocol is also possible

Doc 14, Client-Server Protocols & POP Slide # 8

Protocol Design Issues


Protocol design is difficult!

Learn from examples

Some issues




Easy of debugging
Efficiency

Protocol overhead
Roundtrip delays
Who is writing, who is reading?
Timeouts vs. Synchronous protocols



Doc 14, Client-Server Protocols & POP Slide # 9

POP3 Protocol


Purpose: Allow PC's, Macs, etc. to download mail from server

Port number 110

Protocol uses ASCII only


Doc 14, Client-Server Protocols & POP Slide # 10

Command Format

Format of commands to server

keyword blank argument 1 [ blank argument k ] CRLF
| keyword | = 3, 4 characters

| argument | <= 40 characters

keyword and arguments are separated by single space character
Server Response
Status keyword additionalInfo

Status is either "+OK" or "-ERR0.3."

A single line response ends in CRLF

If response requires more than one line:
Each line ends in a CRLF
The response ends in CRLF.CRLF
If a line starts with a "." prepend a "." to it


Doc 14, Client-Server Protocols & POP Slide # 11
Timeouts

A POP3 server may have an autologout timer

A server must wait at least 10 minutes before timing out a client

The POP3 server on cs.sdsu.edu times out in 2 minutes




Doc 14, Client-Server Protocols & POP Slide # 12

States


AUTHORIZATION

Must log in with password before entering transaction state


TRANSACTION

Client can request actions of server, get mail for example


UPDATE

Updates mail box to reflect actions taken in transaction state



Doc 14, Client-Server Protocols & POP Slide # 13

Commands

AUTHORIZATION

Server acknowledges connection from client with

+OK "message"
+OK UCB Pop server (version 2.1.2-R3) at sciences.sdsu.edu starting.

Commands: USER, PASS, APOP, QUIT



Doc 14, Client-Server Protocols & POP Slide # 14
USER PASS

Combination is used to progress to transaction state

USER must come first
PASS or QUIT must come after USER

Example
Ti 38-> telnet cs.sdsu.edu 110
Trying 130.191.226.116...
Connected to cs.sdsu.edu.
Escape character is '^]'.
+OK QPOP (version 3.1.2) at sciences.sdsu.edu starting.
USER whitney
+OK Password required for whitney.
PASS typeYourPasswordHere
+OK whitney has 116 visible messages (0 hidden) in 640516 octets.


Doc 14, Client-Server Protocols & POP Slide # 15
TRANSACTION

Commands: STAT, LIST, RETR, RSET, QUIT

STAT

Arguments: none

Returns "+OK" numberOfMessages SizeOfMail

Example

STAT
+OK 22 45595


LIST

Arguments: a message-number ( optional )

Returns: size of message in octets

Examples:

LIST 2
+OK 2 3064

LIST
+OK 116 visible messages (640516 octets)
1 2980
2 3064
( message 3 - 116 deleted to save space )
116 1290
.


Doc 14, Client-Server Protocols & POP Slide # 16
RETR

Arguments: a message-number

Returns: the message

Example:

RETR 21
+OK 825 octets
Received: from [130.191.9.18] (ebb2p9.sdsu.edu [130.191.9.18]) by sciences.sdsu.edu
(4.1/8.6.10) with SMTP id UAA29486 for <whitney@saturn.sdsu.edu>; Mon, 11 Mar
1996 20:16:07 -0800 (PST)
X-Sender: whitney@cs.sdsu.edu (Unverified)
Message-Id: <v02110100ad6aaaf097b6@[130.191.9.70]>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Date: Mon, 11 Mar 1996 20:16:50 -0800
To: whitney@saturn.sdsu.edu
From: whitney@saturn.sdsu.edu (Roger Whitney)
Subject: Sample Mail
X-UIDL: 826604201.000
this is a test
..
the end
---
Roger Whitney Math & Computer Science Dept.
whitney@cs.sdsu.edu San Diego State University
http://www.eli.sdsu.edu San Diego, CA 92182-7720
(619) 594-3535
(619) 594-6746 (fax)
.


Doc 14, Client-Server Protocols & POP Slide # 17
DELE

Arguments: a message-number to delete

Returns: a confirmation of deletion

Marks a message to be deleted


NOOP

Arguments: none

Returns: a positive response

Does nothing


QUIT

Arguments: none

Returns: a positive response

Send POP3 server to UPDATE state


UPDATE State

Updates mail box to reflect transactions taken during the transaction state, then logs user out

If session ends by any method except the QUIT command during the transaction state, the update state is not entered

Doc 14, Client-Server Protocols & POP Slide # 18

Optional POP3 Commands

TOP

Arguments: a message-number and number of lines to return

Returns: Requested lines of indicated message

State allowed in: transaction

UIDL

Arguments: a message-number ( optional )

Returns: a unique-id listing for message

State allowed in: transaction

Examples:
UIDL 1
+OK 1 826312760.001
UIDL
+OK uidl command accepted.
1 826312760.001
2 826312760.006
3 826493796.004
etc.
.


Doc 14, Client-Server Protocols & POP Slide # 19
APOP

Arguments: a mailbox and a MD5 digest string


State allowed in: authorization

Action: If MD5 string is correct move to transaction state




Copyright ©, All rights reserved.
2002 SDSU & Roger Whitney, 5500 Campanile Drive, San Diego, CA 92182-7700 USA.
OpenContent license defines the copyright on this document.

Previous    visitors since 10-Oct-02    Next