160 likes | 290 Views
Application Protocols: ELECTRONIC MAIL (SMTP, POP). CSNB534 Semester 2, 2007/2008 Asma Shakil. Application Protocols. An application protocol facilitates communication between applications using the services of lower-level OSI model layers.
E N D
Application Protocols:ELECTRONIC MAIL(SMTP, POP) CSNB534 Semester 2, 2007/2008 Asma Shakil
Application Protocols • An application protocol facilitates communication between applications using the services of lower-level OSI model layers. • E.g. when you check your e-mail, browse a web site, play games or download files over the Internet, the s/w you run is using an application protocol for communication.
Why do we need to have an application protocol? • For applications to interoperate, they must implement an application protocol. • In other words, both applications must be talking the same language. • It is not necessary that the implementation of a protocol • support every feature of the protocol. • must be in the same way or in the same language or on the same machine. • However, protocol implementations must • outwardly behave in the same wayu. • When they cannot fulfill a request or support a feature • They must communicate it effectively using a commonly understood process.
Application Protocol Specification • The design of a network protocol is an evolutionary process that involves many contributors. • When the protocol nears completion and is ready for applications to implement it, it is published as a Request For Comment (RFC) document. • Each RFC is assigned a number for identification. • E.g. RFC 1945 for HTTP/1.0 • Finding RFC Documents • http://www.rfc-editor.org/rfc.html
Application Protocol Implementation • The most enjoyable part of n/w programming is putting the n/w theory (that you have learnt so far ) by writing real-life applications. • In today’s class, we will look at implementing e-mail protocols.
Electronic Mail • Among most widely used Internet services • Two major components • User interface • Mail transfer software • Paradigm: transfer is separate background activity. • This is because a mail system must provide for instances when the remote machine is temporarily unreachable – done by spooling. • The background mail transfer process become a client that attempts to form a TCP connection to the mail server on the destination machine.
Format Of Email Message • Message consists of • Header • Blank line • Body of message • Headers have form • keyword : information • Standard given in RFC 2822
Protocol For Email Transfer • Specifies interaction between transfer components • Transfer client • Transfer server • Standard protocol is Simple Mail Transfer Protocol (SMTP)
SMTP • Application-level protocol known as RFC2821 • Uses TCP • Commands and responses encoded in ASCII • This protocol assumes that some other method is used to actually read the messages.
Example Of SMTP S: 220 Beta.GOV Simple Mail Transfer Service Ready // Upon connecting, the server will send a response code in greeting, to ensure that the client is talking to an SMTP service and not some other service using port 25. C: HELO Alpha.EDU // Protcol specification for telling the server who we really are. S: 250 Beta.GOV // Correct response is 250 which signals OK. C: MAIL FROM:Smith@Alpha.EDU// used to set the sender information S: 250 OK C: RCPT TO:Jones@Beta.GOV// used to set the recipient information S: 250 OK C: RCPT TO:Green@Beta.GOV// recipient rejected S: 550 No such user here C: RCPT TO:Brown@Beta.GOV// there can be more than one recipient S: 250 OK C: DATA // to signal that the client is ready to send a message body S: 354 Start mail input; end with <CR><LF>.<CR><LF> // valid response code is 354 C: ...sends body of mail message... C: ...continues for as many lines as message contains C: <CR><LF>.<CR><LF> S: 250 OK C: QUIT // to indicate that the client has completed its transaction with the SMTP server. S: 221 Beta.GOV Service closing transmission channel
SMTP Client Implementation • Code for SMTPClientDemo.
POP • The SMTP transfer scheme implies that a server must be ready to accept e-mail at all times. • The scenario works well if the server runs on a computer that has a permanent Internet connection but not for one with intermittent connectivity (e.g. a laptop computer). • To resolve this, a two-stage delivery process is adpoted. • Each user is assigned a mailbox on a computer that is always on and has a permanent Internet connectivity. • The computer runs a conventional SMTP server, which always remains ready to accept e-mail. • The user connects to the Internet and then runs a protocol that retrieves messages from the permanent mailbox. • The protocol transfers the messages to the user’s computer where they can be read. • Two protocols used for this are • POP (Post Office Protocol) • IMAP(Internet Message Access Protocol)
Example of POP telnet pop.foo.bar 110 Trying 192.168.1.1... Connected to pop.foo.bar. Escape character is '^]'. +OK QPOP (version 2.4) at pop.foo.bar starting. USER user.123 +OK Password required for foo.123. PASS foo +OK user.123 has 3 messages (1548 octets). STAT//Displays number of messages and space taken by mailspool +OK 3 1548 LIST//Displays space taken by each message +OK 3 messages (1548 octets) 1 344 2 386 3 818 RETR 2// Displays message message_number +OK 386 octets Return-Path: Received: (from user.123@localhost) by pop.foo.bar (8.8.8/8.8.8) id SAA29614 for user.123; Wed, 3 Dec 1997 18:55:43 -0500 (EST) Date: Wed, 3 Dec 1997 18:55:43 -0500 (EST) From: Pat Gunn Message-Id: <199712032355.SAA29614@pop.foo.bar> X-Real-To: user.123 Subject: Hi! Content-Type: text/plain X-UIDL: f6aba8f9429ffcb4f343c6b061cd82bb Status: U Hi Pat! What's up? .
POP3 Client Implementation • Code for POP3ClientDemo.