CS161 Programming Assignment 3: IMAP Client

1) Preliminaries

Questions: cs161tas@cs.brown.edu
Help sessions:
    Yanif - XXX
    Haru - XXX
    Ron - XXX

Due date: Monday, October 18th, 5 PM.

2) CS161 Environment Setup

Add this line to your shell startup scripts:

    source /course/cs161/startups/cs161student

3) Introduction

Your third programming task is to implement an IMAP client in Java. IMAP is a protocol for remote access of email, and is described in RFC 3501. This is a long document, but you should read through it with care.

Your goal in this assignment is to develop a client that will be useful when you develop and test your (future) IMAP server. As such, your focus should be on flexibility, rather than performance. Howevere, since one use your client will be to simulate high loads, performance does matter, and you will, once again, use an event-based architecture to support large numbers of concurrent connections.

To increase the flexibility of you client, you will embed Jython, the Java version of the Python programming language. You should be able to run you program in two ways, in interactive, or batch. In interactive mode, invoking your client will present a command prompt from which IMAP commands can be issued. It will be up to you to design a set of commands that allows the user to exercise an IMAP server interactively. In batch mode, your client will evaluate a file of Jython code. Your command set should be capable of setting up useful test cases, such as a large number of clients, clients operating at different speeds, clients with different mail habits (such as downloading, or refiling messages), and ill-behaved clients.

4) Assignment Specification

  1. Do not use a thread per connection. However, you may make limited use of threads, if desired, to provide a command-line interface.
  2. You should implement support for the following IMAP4 commands: CAPABILITY, NOOP, LOGOUT, LOGIN, SELECT, EXAMINE, CREATE, DELETE, RENAME, LIST, STATUS, APPEND, CLOSE, EXPUNGE, SEARCH, FETCH, STORE, COPY That is, a user of your program should be able to exercise each of these commands on the server.
  3. You will turn in a "script" conformance.py that, when run by your imap client in batch mode, will test an imap server in as many ways as you can think of. You should try to determine not only whether the server is implementing various MUSTs and SHOULDs from the RFC, but alos try to find legal differences that might exist between various implementations. We'll provide two different servers for you to test against. The script should simply print out a report about what it discovers.
  4. You will turn in a "script" performance.py that, when run by your imap client in batch mode, will test an imap server's performance. You should choose a few interesting things to measure. You should design this script not to bring a server to its knees. For example, you slowly increase the number of simultaneous connections, and record the effect this has on some measure of performance. Output your data in a simple format that can be graphed by an external program like gnuplot (a table of numbers is just fine).
  5. Your explanations of both scripts, and design choices you made should be placed in a README file.

5) Testing

We have set up an IMAP server for you to test against on pythagoras.ilab.cs.brown.edu, port 145. We hope to add some test accounts, but for now you can begin testing by logging in as yourself, with your normal departmental password

Be aware that you can use telnet as a quick way to explore from the command line. For example, this sequence shows a LOGIN command:

cslab5b:~> telnet pythagoras.ilab.cs.brown.edu 145
Trying 10.116.20.7...
Connected to pythagoras.
Escape character is '^]'.
* OK [CAPABILITY IMAP4REV1 LITERAL+ SASL-IR LOGIN-REFERRALS STARTTLS AUTH=LOGIN] pythagoras.ilab.cs.brown.edu IMAP4rev1 2004.352 at Wed, 6 Oct 2004 23:52:05 -0400 (EDT)
A0001 LOGIN jj "mypassword"
A0001 OK [CAPABILITY IMAP4REV1 LITERAL+ IDLE NAMESPACE MAILBOX-REFERRALS BINARY UNSELECT SCAN SORT THREAD=REFERENCES THREAD=ORDEREDSUBJECT MULTIAPPEND] User jj authenticated

You should also read RFC 2683 which contains advice for IMAP developers (clients and servers). It will help you write a better client, but more importantly, it will give you ideas for variant behavior that your client can provide in order to test your server.

6) Support Code

Not this time! You should begin with your finger client. In addition, some Jython boilerplate may be presented in class.

7) Submitting your code

To submit your code, first make sure your source files reside in a "imap/" directory. Run the following script from the parent directory of "imap/" to hand in:
    /course/cs161/bin/cs161_handin imap
Please contact the TAs if you have problems submitting. For your own sanity, don't leave your submission until the minute before the deadline.

8) Grading scheme

Your code will be graded on the following factors (and their weights).

Documentation and code legibility: 20%
Functionality (non-blocking, error reporting, etc): 50%
Robustness (malicious input, many connections, etc): 30%