Assignment 1

Java 11

no additional dependencies

encapsulate communication through sockets (InputStream, OutputStream)

Concurrency

Short lived → ExecutorService (ThreadPools) - because making Threads is expensive

connections because ServerSocket.accept() is blocking.

Forwarding mails

Long lived → seperate threads

accept-loop for server sockets

Application Shell

For administrators to interact with the application itself (ie. shutdown() ) in the console window of the running application.

Blocks main() → see example repository

Application Shutdown

Throw StopShellException

  1. Serversockets
  1. Socket
  1. IO

DMAP

DsLab Message Access Protocol DMAP

Client requests

login <username> <passwort>

User must first log in

list

format: <message-id> <sender> <subject>

show <message-id>

delete <message-id>

logout

quit

DMTP

DsLab Message Transfer Protocol DMTP

Client requests

Writing multiple times overwrites previous value

Input strings to subject, data are single lines.

begin

Must be called before any other instruction

to <address, address, ...>

from <address>

Address can be from user from other Mail-Service

subject <string>

data <string>

send

quit

Close socket connection

Server responses

For undefined instructions: immediately terminate connection.

ok DMTP

initial response telling client that server is ready and speaks DMTP

ok

valid instruction

ok <number of accepted recipients>

as a response to to <address, address, ...>

Number of accepted messages depend on server type.

Transfer servers

accept any recipients.

Mail servers

only accept recipients of the domain they manage.

otherwise show error.

error <explanation>

ok bye

response to quit

Servers

Transfer Server

Receives mails from users outside of the mailservice, transfers the messages to mailbox servers.

Accepts any recipient.

Implements DMTP (as client and server)


Domain lookup

find mailboxes to forward messages to.

replay received messages to all of them.

Reporting to Monitoring Server

For each sent message - UDP packet:

<host of transfer server>:<port> <senders email-address>

Message delivery failure

If no domain found after domain-lookup:

ie. error-mail to sender, domain lookup failed (no server found)

(If the sender couldn't be found, ignore)

Send error-message-mail back to the sender notifying

address of transfer server: mailer@[IP]

If the error delivery failed, discard error message

Mailbox Server

Users can read / delete messages, not send them.

Implements DMTP (as server only), DMAP

Database is persistent.

Recipients must be from this server.

Else they are ignored

Monitoring Server

Usage statistics, via UDP

Preventing server abuse (ie. DDOS)

Receives usage statistics with UDP socket.

<host of transfer server>:<port> <senders email-address>

addresses

lists all senders and # messages they have sent

<senders email-address> #

servers

lists all transfer servers and the # messages sent over them.

<host of transfer server>:<port> #