Compare Iso Osi Model And Stack Computer Science Essay

Published: Last Edited:

This essay has been submitted by a student. This is not an example of the work written by our professional essay writers.

First of all, our focus of this assignment is based on application layer. We brief through the application layer functions and standards. The Open Systems Interconnection or OSI reference model is a layered representation created as a guideline for network protocol design. The OSI model has seven logical layers, each of which has unique functionality and to which are assigned specific services and protocols. The information is passed from one layer to the next, starting at the Application layer to the Physical layer and vice versa. The Application layer is the layer that provides the interface between the applications we use to communicate and the underlying network over which our messages are transmitted and are used to exchange data between programs running on the source and destination hosts. The figure below shows the model:

Application Layer - compare ISO OSI model and stack TCP/IP Model

From the many protocols of application layer, our focus will be the POP protocol, which is an Internet electronic mail standard that specifies how an Internet-connected computer can function as a mail-handling agent. Firstly, messages arrive at a user's electronic mailbox, which is in the service provider's computer then from this central storage point; you can access your mail from different computers. In both case, a POP-compatible electronic mail program, which runs on your workstation or PC, establishes a connection with the POP server, and detects that new mail, has arrived. From that you can then download the mail to the workstation or computer, and reply to it. In computing world, the Post Office Protocol (POP) used by local e-mail clients to retrieve e-mail from a remote server over a TCP/IP connection is an application-layer Internet standard protocol. The two most prevalent Internet standard protocols for e-mail retrieval are POP and IMAP (Internet Message Access Protocol). All modern e-mail clients and servers support both. With version 3 (POP3) being the current standard, the POP protocol has been developed through several versions. Most webmail service providers also provide IMAP and POP3 service.


POP (Post Office Protocol)

In the world of snail mail, the sender writes a letter and drops it into a mail box.

When this happens, the letter has just entered a sorting and transportation system where it stays for some amount of time. Eventually the letter ends up with a mail carrier who delivers it into the mail box of the receiver. The receiver opens the mail and, ah, lets it lay on the front hall table until someone throws it away. To find the mail later, the receiver must dig through the trash. If the receiver needs the mail while away from home and the trash, well, too bad. The Post Office Protocol (POP) for delivering email works somewhat similarly to this. A person sends an email from a computer, similar to dropping it into a mail box. An SMTP server routes it across the Internet to an email server, analogous to sorting and transporting. The receiver contacts the email server using POP and downloads the email to a local computer, like the mail carrier delivering a letter. Once on the computer it can be moved from the inbox into a different email folder, so much for the hall table. The mail stays on the computer until the user deletes it.

Besides that, POP supports simple download-and-delete requirements for access to remote mailboxes when most POP clients have an option to leave mail on server after download, e-mail clients using POP can connect, retrieve all messages, store them on the user's PC as new messages, delete them from the server, and then disconnect. Available messages to the client are fixed when a POP session opens the mail drop, and are identified by message-number local to that session or, optionally, by a unique identifier assigned to the message by the POP server. This unique identifier is permanent and unique to the mail drop and allows a client to access the same message in different POP sessions. Mail is retrieved and marked for deletion by message-number. When the client exits the session, the mail marked for deletion is removed from the mail drop. POP3, which is an abbreviation for Post Office Protocol 3, is the third version of a widespread method of receiving email. Much like the physical version of a post office clerk, POP3 receives and holds email for an individual until they pick it up. And, much as the post office does not make copies of the mail it receives, in previous versions of POP3, when an individual downloaded email from the server into their email program, there were no more copies of the email on the server; POP automatically deleted them .POP3 makes it easy for anyone to check their email from any computer in the world, provided they have configured their email program properly to work with the protocol.

Mail Server Functionality

POP3 has become increasingly sophisticated so that some administrators can configure the protocol to "store" email on the server for a certain period of time, which would allow an individual to download it as many times as they wished within that given time frame. However, this method is not practical for the vast majority of email recipients. While mail servers can use alternate protocol retrieval programs, such as IMAP, POP3 is extremely common among most mail servers because of its simplicity and high rate of success. Although the newer version of POP offers more "features," at its basic level, POP3 is preferred because it does the job with a minimum of errors.

Working With Email Applications

Because POP3 is a basic method of storing and retrieving email, it can work with virtually any email program, as long as the email program is configured to host the protocol. Many popular email programs, including Eudora and Microsoft Outlook, are automatically designed to work with POP3. Each POP3 mail server has a different address, which is usually provided to an individual by their web hosting company. This address must be entered into the email program in order for the program to connect effectively with the protocol. Generally, most email applications use the 110 port to connect to POP3. Those individuals who are configuring their email program to receive POP3 email will also need to input their username and password in order to successfully receive email.

The Purpose of POP, the Post Office Protocol

If someone sends a message to us it usually cannot be delivered directly to our computer. The message has to be stored somewhere, though. It has to be stored in a place where we can pick it up easily. The internet service provider are operating 24hours and it receives the message for us and keeps it until we download it. For example suppose our email address is [email protected] As our ISP's mail server receives email from the internet it will look at each message and if it finds one addressed to [email protected] that message will be filed to a folder reserved for our mail. This is where the message is kept until either we retrieve it or one of our ISP's administrators finds our account has been filled with spam and decides to delete all the mail in it. Now, POP, the Post Office Protocol is what allows us to retrieve mail from our ISP.

What the Post Office Protocol Allows You to Do

We can do these things with this protocol:

Retrieve mail from an ISP and delete it on the server.

Retrieve mail from an ISP but not delete it on the server.

Ask whether new mail has arrived but not retrieve it.

Peek at a few lines of a message to see whether it is worth retrieving.

Of these, the second probably sounds the most dangerous. Deleting something is always frightening. Remember, though, that you retrieve your mail before you delete it and thus have a copy. When your mailbox is full, nobody will be able to send you any email before you haven't cleaned up .If you leave all your mail on the server, it will pile up there and eventually lead to a full mailbox..

The Post Office Protocol (POP) used to retrieve mail from a remote server is a very simple protocol. It defines the basic functionality in a straight forward manner and is easy to implement. Of course, it is also easy to understand. Let's find out what happens behind the scenes when your email program fetches mail in a POP account. First, it needs to connect to the server.

Usually the POP server listens to port 110 for incoming connections. Upon connection from a POP client (your email program) it will hopefully respond with +OK ready or something similar. The +OK indicates that everything is â€" OK. Its negative equivalent is -ERR, which means something has gone wrong. Maybe your email client has already shown you one of these negative server replies.

Now that the server has greeted us, we need to log on using our username (let's suppose the user name is "platoon"; what the server says is printed in italics):

+OK ready

USER platoon

Since a user with this name does exist, the POP server responds with +OK and maybe some gibberish we don't really care about. Were there no such user at the server, it would of course make us panic with -ERR user unknown.

To make the authentication complete we also need to give our password. This is done with the "pass" command:

+OK send your password

pass noplato

If we type the password correctly, the server responds with +OK great password or whatever the programmer of the POP server had in mind. The important part again is the +OK. Unfortunately, passwords can also be wrong. The server notes this with a dry -ERR username and password don't match (as if you'd use your user name as your password).

If everything went okay, though, we are connected to the server and it knows who we are, thus we're ready to peek the newly arrived mail.

After we have successfully logged in to our POP account at the server, we may first want to know if there is new mail at all and then possibly how much.

The command used to retrieve these basic mailbox statistics is STAT.

A possible server response would be +OK 18 67042. In this case it does matter what follows the +OK sign. Immediately following is the number of messages in the mailbox, then, separated by a whitespace, comes the size of the mailbox in octets (an octet are 8 bits).


+OK 18 67042

If there is no mail, the server responds with +OK 0 0. Since there are 18 new messages on the server, however, we can list these using the LIST command. In response, the server lists the messages in the following format:


+OK 18 messages (67042 octets)

1 2552

2 3297


18 3270


The messages are listed one at a time, each followed by its size in octets. The list ends with a period on a line by itself.

The LIST command can take the number of a message as an optional argument, LIST 2 for example. The server's response to this request would be +OK 2 3297, the message number followed by the size of the message. If you try to list a message that does not exist, like LIST 23, the server shows no imagination and says: -ERR no such message.

Now that we know how many messages are in our account and how big they are, it's finally time to retrieve them so we can read them too.

Now, after finding out whether we have new mail, comes the real real thing. The messages are retrieved one by one with their message number as an argument to the RETR command.

The server responds with an +OK and the message as it is, in multiple lines. The message is terminated by a period on a line by itself. For example:


+OK 2552 octets

Blah! <POP server sends message here>


If we try to get a message that does not exist, we get -ERR no such message.

Now we can delete the message using the DELE command. (We can, of course, also delete the message without having retrieved it if it is one of those days).

It is good to know that the server will not purge the message immediately. It is merely marked for deletion. Actual deletion only happens if we regularly end the connection to the server. So no mail will ever be lost if the connection suddenly dies, for example.

The server's response to the DELE command is +OK message deleted:


+OK message 1 deleted

If it is indeed one of those days and we have marked a message for deletion that we do not want to be deleted, it is possible to undelete all messages by resetting the deletion marks. The RSET command returns the mailbox to the state it was in before we logged in.

The server responds with an +OK and possibly the number of messages:


+OK 18 messages

After we have retrieved and deleted all the messages it is time to say goodbye using the QUIT command. This will purge the messages marked for deletion and close the connection. The server responds with +OK and a farewell message:


+OK bye, bye

It is possible that the server was unable to delete a message. Then it will respond with an error like -ERR message 2 not deleted.


In RFC 918 (1984), POP (POP1) was specified. Then a year later was POP2 .The original specification of POP3 is RFC 1081 (1988). Its current specification is RFC 1939, updated with an extension mechanism, RFC 2449 and an authentication mechanism in RFC 1734.POP2 has been assigned well-known port 109.Intially the original POP3 specification supported only an unencrypted USER/PASS login mechanism. POP3 currently supports several authentication methods to provide varying levels of protection against illegitimate access to a user's e-mail. Most are provided by the POP3 extension mechanisms. Besides that APOP is challenge/response protocol which uses the MD5 hash function in an attempt to avoid replay attacks and disclosure of the shared secret. An informal proposal had been outlined for a "POP4" specification, complete with a working server implementation. This "POP4" proposal added basic folder management, multipart message support, as well as message flag management, allowing for a light protocol which supports some popular IMAP features which POP3 currently lacks. However no progress has been observed in this "POP4" proposal since 2003.


A clear example would be e-mail. E-mail, the most popular network service, has revolutionized how people communicate through its simplicity and speed. Hence to run on a computer or other end device, e-mail requires several applications and services. Two example Application layer protocols are Post Office Protocol (POP) and Simple Mail Transfer Protocol (SMTP), shown in the figure. When people compose e-mail messages, they typically use an application called a Mail User Agent (MUA), or e-mail client. The MUA allows messages to be sent and places received messages into the client's mailbox, both of which are distinct processes. In order to receive e-mail messages from an e-mail server, the e-mail client can use POP.

email client MUA Mail User Agent

E-mail Server Processes - MTA and MDA

The e-mail server operates two separate processes:

Mail Transfer Agent (MTA)

Mail Delivery Agent (MDA)

The Mail Transfer Agent (MTA) process is used to forward e-mail. As shown in the figure, the MTA receives messages from the MUA or from another MTA on another e-mail server. Based on the message header, it determines how a message has to be forwarded to reach its destination. If the mail is addressed to a user whose mailbox is on the local server, the mail is passed to the MDA. If the mail is for a user not on the local server, the MTA routes the e-mail to the MTA on the appropriate server. In the figure, we see that the Mail Delivery Agent (MDA) accepts a piece of e-mail from a Mail Transfer Agent (MTA) and performs the actual delivery. The MDA receives all the inbound mail from the MTA and places it into the appropriate users' mailboxes. The MDA can also resolve final delivery issues, such as virus scanning, spam filtering, and return-receipt handling.

MDA Mail Delivery Agent MTA Mail Transfer Agent

As mentioned earlier, e-mail can use the protocols, POP and POP and POP3 (Post Office Protocol, version 3) are inbound mail delivery protocols and are typical client/server protocols. They deliver e-mail from the e-mail server to the client (MUA). The MDA listens for when a client connects to a server. Once a connection is established, the server can deliver the e-mail to the client.

Here's an example with the user input shown in bold type:

% telnet 109

Trying ...

Connected to

Escape character is '^]'.

+ POP2 almond POP2 Server at Wed 30-Mar-94 3:48PM-EST

HELO hunt WatsWatt

#3 ...(From folder 'NEWMAIL')




{The full text of message 1}




{The full text of message 2}




{The full text of message 3}




+OK POP2 Server exiting (0 NEWMAIL messages left)

Connection closed by foreign host.

The HELO command provides the username and password for the account of the mailbox that is being retrieved. (This is the same username and password used to log into the mail server.) In response to the HELO command the server sends a count of the number of messages in the mailbox, three (#3) in our example. The READ command begins reading the mail. RETR retrieves the full text of the current message. ACKD acknowledges receipt of the message and deletes it from the server. After each acknowledgment the server sends a count of the number of bytes in the new message. If the byte count is zero (=0) it indicates that there are no more messages to be retrieved and the client ends the session with the QUIT command. Simple! Table 3.2 lists the full set of POP2 commands.

Table 3.2: POP2 Commands





HELO user password

Identify user account


FOLD mail-folder

Select mail folder


READ [n]

Read mail, optionally start with message n



Retrieve message



Acknowledge and save



Acknowledge and delete



Negative acknowledgement



End the POP2 session

The commands for POP3 are completely different from the commands used for POP2. Table 3.3 shows the set of POP3 commands defined in RFC 1725.

Table 3.3: POP3 Commands



USER username

The user's account name

PASS password

The user's password


Display the number of unread messages/bytes


Retrieve message number n


Delete message number n


Display the number of the last message accessed

LIST [n]

Display the size of message n or of all messages


Undelete all messages; reset message number to 1

TOP n l

Print the headers and l lines of message n


Do nothing


End the POP3 session

Despite the fact that these commands are different from those used by POP2, they can be used to perform similar functions. In the POP2 example we logged into the server and read and deleted three mail messages. Here's a similar session using POP3:

% telnet almond 110

Trying ...

Connected to

Escape character is '^]'.

+OK almond POP3 Server Process 3.3(1) at Mon 15-May-95 4:48PM-EDT

user hunt

+OK User name (hunt) ok. Password, please.

pass Watts?Watt?

+OK 3 messages in folder NEWMAIL (V3.3 Rev B04)


+OK 3 459

retr 1

+OK 146 octets

The full text of message 1

dele 1

+OK message # 1 deleted

retr 2

+OK 155 octets

The full text of message 2

dele 2

+OK message # 2 deleted

retr 3

+OK 158 octets

The full text of message 3

dele 3

+OK message # 3 deleted


+OK POP3 almond Server exiting (0 NEWMAIL messages left)

Connection closed by foreign host.

Naturally you don't really type these commands in yourself, but experiencing hands-on interaction with SMTP and POP gives you a clearer understanding of what these programs do and why they are needed.

Example - receiving e-mail using POP3 protocol


* POP3Session - Class for checking e-mail via POP3 protocol.




import java.util.*;

public class POP3Session extends Object


/** 15 sec. socket read timeout */

public static final int SOCKET_READ_TIMEOUT = 15*1000;

protected Socket pop3Socket;

protected BufferedReader in;

protected PrintWriter out;

private String host;

private int port;

private String userName;

private String password;


* Creates new POP3 session by given POP3 host, username and password.

* Assumes POP3 port is 110 (default for POP3 service).


public POP3Session(String host, String userName, String password)


this(host, 110, userName, password);



* Creates new POP3 session by given POP3 host and port, username and password.


public POP3Session(String host, int port, String userName, String password)

{ = host;

this.port = port;

this.userName = userName;

this.password = password;



* Throws exception if given server response if negative. According to POP3

* protocol, positive responses start with a '+' and negative start with '-'.


protected void checkForError(String response)

throws IOException


if (response.charAt(0) != '+')

throw new IOException(response);



* @return the current number of messages using the POP3 STAT command.


public int getMessageCount()

throws IOException


// Send STAT command

String response = doCommand("STAT");

// The format of the response is +OK msg_count size_in_bytes

// We take the substring from offset 4 (the start of the msg_count) and

// go up to the first space, then convert that string to a number.

try {

String countStr = response.substring(4, response.indexOf(' ', 4));

int count = (new Integer(countStr)).intValue();

return count;

} catch (Exception e) {

throw new IOException("Invalid response - " + response);




* Get headers returns a list of message numbers along with some sizing

* information, and possibly other information depending on the server.


public String[] getHeaders()

throws IOException



return getMultilineResponse();



* Gets header returns the message number and message size for a particular

* message number. It may also contain other information.


public String getHeader(String messageId)

throws IOException


String response = doCommand("LIST " + messageId);

return response;



* Retrieves the entire text of a message using the POP3 RETR command.


public String getMessage(String messageId)

throws IOException


doCommand("RETR " + messageId);

String[] messageLines = getMultilineResponse();

StringBuffer message = new StringBuffer();

for (int i=0; i<messageLines.length; i++) {




return new String(message);



* Retrieves the first <linecount> lines of a message using the POP3 TOP

* command. Note: this command may not be available on all servers. If

* it isn't available, you'll get an exception.


public String[] getMessageHead(String messageId, int lineCount)

throws IOException


doCommand("TOP " + messageId + " " + lineCount);

return getMultilineResponse();



* Deletes a particular message with DELE command.


public void deleteMessage(String messageId)

throws IOException


doCommand("DELE " + messageId);



* Initiates a graceful exit by sending QUIT command.


public void quit()

throws IOException





* Connects to the POP3 server and logs on it

* with the USER and PASS commands.


public void connectAndAuthenticate()

throws IOException


// Make the connection

pop3Socket = new Socket(host, port);


in = new BufferedReader(new InputStreamReader(pop3Socket.getInputStream()));

out = new PrintWriter(new OutputStreamWriter(pop3Socket.getOutputStream()));

// Receive the welcome message

String response = in.readLine();


// Send a USER command to authenticate

doCommand("USER " + userName);

// Send a PASS command to finish authentication

doCommand("PASS " + password);



* Closes down the connection to POP3 server (if open).

* Should be called if an exception is raised during the POP3 session.


public void close()


try {




} catch (Exception ex) {

// Ignore the exception. Probably the socket is not open.




* Sends a POP3 command and retrieves the response. If the response is

* negative (begins with '-'), throws an IOException with received response.


protected String doCommand(String command)

throws IOException




String response = in.readLine();


return response;



* Retrieves a multi-line POP3 response. If a line contains "." by itself,

* it is the end of the response. If a line starts with a ".", it should

* really have two "."'s. We strip off the leading ".". If a line does not

* start with ".", there should be at least one line more.


protected String[] getMultilineResponse()

throws IOException


ArrayList lines = new ArrayList();

while (true) {

String line = in.readLine();

if (line == null) {

// Server closed connection

throw new IOException("Server unawares closed the connection.");


if (line.equals(".")) {

// No more lines in the server response



if ((line.length() > 0) && (line.charAt(0) == '.')) {

// The line starts with a "." - strip it off.

line = line.substring(1);


// Add read line to the list of lines



String response[] = new String[lines.size()];


return response;




* POP3Session example. Receives email using POP3 protocol.


import POP3Session;

import java.util.StringTokenizer;

public class POP3Client


public static void main(String[] args)


POP3Session pop3 = new POP3Session("", "username", "password");

try {

System.out.println("Connecting to POP3 server...");


System.out.println("Connected to POP3 server.");

int messageCount = pop3.getMessageCount();

System.out.println("\nWaiting massages on POP3 server : " + messageCount);

String[] messages = pop3.getHeaders();

for (int i=0; i<messages.length; i++) {

StringTokenizer messageTokens = new StringTokenizer(messages[i]);

String messageId = messageTokens.nextToken();

String messageSize = messageTokens.nextToken();

String messageBody = pop3.getMessage(messageId);


"\n-------------------- messsage " + messageId +

", size=" + messageSize + " --------------------");


System.out.println("-------------------- end of message " +

messageId + " --------------------");


} catch (Exception e) {


System.out.println("Can not receive e-mail!");






Looking into IMAP and POP, the main difference, as far as we are concerned here, is the way in which IMAP or POP controls our e-mail inbox. When we use IMAP we are accessing our inbox on the U of M's central mail server. IMAP does not actually move messages onto our computer. We can think of an e-mail program using IMAP as a window to our messages on the server. Although the messages appear on our computer while we work with them, they remain on the central mail server.POP does the opposite. Instead of just showing we what is in our inbox on the U's mail server, it checks the server for new messages, downloads all the new messages in our inbox onto our computer, and then deletes them from the server. This means that every time we use POP to view our new messages; they are no longer on the central mail server. Figure below illustrates these concepts.

POP client-server diagram, office computer retrieves new mail, home computer then sees nonePOP client-server diagram, office computer retrieves new mail, home computer then sees none


POP is the oldest and most recognizable Internet email protocol. Its current widespread implementation is POP3. POP is a simple protocol to configure, operate and maintain. When POP was first designed, the cost of constantly staying online was very high. Because of this, POP was built around the offline mail delivery model. This means the end-user connects to an email server, downloads messages, disconnects from the server, then reads email while offline. In other words, POP was designed to collect mail for a single email client. POP Messages are stored on the mail server until downloaded to the client. They are then stored on the client machine and deleted from the server. The client can contain multiple folders for organizing email. Filters can place mail into specific folders during the download process. The user can mark mail with flags such as read, unread and urgent. A change to the POP standard includes the option to leave email on the server after downloading it. This enables a user to download the same mail using multiple clients on more than one computer. However, there are no server-side file manipulation capabilities, such as marking mail as read or unread. There are also no facilities for creating server-side directories. Instead, leaving email on a server, allows each client to download the same messages one time.

POP Benefits

Local Storage - When not connected, the user can still access and read downloaded email.

Server Saving - POP frees server disk space because it downloads emails and attachments then deletes them from the server.

Legacy Systems - For people with older systems, POP may be the only choice.

IMAP is mostly available only on recent email clients, many of which cannot run on older machines.

POP Drawbacks

Single Computer and Client - Despite the "leave-mail-on-server" enhancements of newer POP servers and clients, POP is primarily designed for use with a single email client on a single computer. When implemented, the "leave-mail-on-server" feature forces the downloading of the same emails multiple times, eating bandwidth, server resources and client disk space on multiple machines.


POP and IMAP both offer viable email capabilities.POP is design to be used by one client on one computer. IMAP is client and computer independent with each client seeing the same information for every IMAP account. POP stores mail on the client computer. IMAP stores mail on the server and caches it on the computer. POP clients have facilities for organizing mail into client-side folders. IMAP folders can be on the server or client side. POP sends messages one way, from the server to the client. IMAP can copy and move messages back and forth between mailboxes on multiple accounts as well as between servers and clients. POP allows one user to connect to one mailbox. IMAP supports both private and public folders. Each public folder can have either unique or shared status flags for its messages.