








Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
In this lab, students will explore the operation of communications services provided through the internet by using existing applications and a short java program. The focus will be on smtp (simple mail transfer protocol) and pop (post office protocol), two widely used protocols for sending and receiving email. Students will use bluej, the ide, to enter and run a simple java program and intercept packets using tcpcapture to inspect messages exchanged between the apple mail program and the email server.
Typology: Lab Reports
1 / 14
This page cannot be seen from the preview
Don't miss anything!
Due: Friday, 9/ In most of our labs this semester, you will be writing Java programs that explore the operation of commu- nications services provided through the Internet. This lab, however, will be a bit different. You will still be exploring Internet communication mechanisms and Java programs, but you will do it using existing applications and a short Java program we will provide rather than by writing a program of your own. In this lab you will learn about two important Internet email protocols by experimenting with their opera- tion in various ways. The protocols we want you to explore are SMTP (Simple Mail Transfer Protocol), which is the standard protocol used to send email messages, and POP (Post Office Protocol), which is one of two protocols that are widely used by mail clients when you are reading your email. You will also use BlueJ, the IDE (Integrated Development Environment) we will be using in labs throughout the semester, to enter and run a simple Java program. The goal of this exercise will be to give you some concrete experience with the mechanics of entering and running a program so that you can bet- ter appreciate the introduction to Java we will present in class. There are several things you should do to prepare for this lab. First, however, we want to tell you some- thing you do not have to do before lab. You do not have to read the entire lab handout. You only have to read the first page. For most of the other labs in this course, carefully reading the entire lab handout be- fore coming to lab will be an extremely important part of your preparation for lab. This week’s lab hand- out, however, is designed to function as a tutorial. As you read through most of the handout, you will be expected to perform the operations it describes using one of the computers in our lab. You may want to skim the handout a bit before you come to lab but don’t waste time reading beyond the first page. On the other hand, this lab will assume that you are familiar with the readings assigned from the course reading packet. The readings for this lab are Chapter 1 and the first section of Chapter 4 of “Program- ming with Java, Swing and Squint” before coming to lab. Finally, there is something very simple you can do to make the lab go smoothly. Special accounts for each of you have been created on our department’s server. During lab, you will be using the account to send and read email messages. Before starting the lab, you should send a few email messages using your usual university email account (via whatever web interface you like) to this account. The addresses for the account look like cs150_01@cauchy.richmond.edu. Eighteen such accounts have been created (with names cs150-01 through cs150-18). We will assign each of you an individual account at the beginning of the lab. If you want some variety, feel free to have some friends send some mail to this account as well. Be sure, however, that you don’t send too many messages to this account. The main reason we are using accounts on our server rather than having you use your standard UR email account is to avoid having to process too many messages. During the lab, you will be monitoring conversations between a mail program and our mail server. If you have too many messages sent to your account, the number of packets you intercept when you monitor the conversation between the Mail program and our mail server will be overwhelming. Having somewhere between 4 and 8 messages sent to your cauchy.richmond.edu account before lab would be great.
You will use three programs to explore how some of the mail protocols used within the Internet function: Mail: The standard mail client provided with Apple’s Macintosh operating system. You will use this program to send and read some email messages using the mail account we have created for you on our department’s server. TCPCapture: This is a program we have constructed which allows you to intercept and inspect messages sent from your machine through the Internet. You will use it to determine exactly what messages are exchanged between the Apple Mail program and our email server when you send messages and check your mail. You may have noticed a bit of a vocabulary problem here. In order to send an email message, a client program sends several messages of its own. It is confusing to use the word “message” for both sorts of communications. So in the rest of this handout we will use the word “message” only when talking about actual email messages. We will use the term “packet” to refer to the smaller, individual communications sent between clients and servers. NetTap: This is a program we have constructed that allows you to exchange packets directly with a re- mote server rather than depending on a client program like a mail program or a web browser. Af- ter having seen the packets the Apple Mail program uses to communicate with a mail server, you will use this program to communicate with the mail server directly.
The first step you need to complete for this lab is to configure the preferences for the Mail to allow it to connect to the mail server. We will lead you through this process in some detail in recognition of the fact that some of you may not have previous experience with the Macintosh interface. We will expect you to become comfortable with this interface quickly because we will not provide the same level of step-by- step instructions in future labs. First, log in to one of the machines in our lab by entering your usual university user name and password. Once you have logged in, your computer display should look something like the image shown below.
We want to configure the Apple Mail program to use your account on our mail server. We want to do this without letting the program actually go and fetch your mail. We want to keep it from doing this until we are ready to run the TCPCapture program so that we can watch the conversation between the Mail client program and our server. So, as you follow the steps to configure your account we will instruct you not to enter your password at one point when the configuration process asks for it. This will keep the program from being able to contact the server until you want it to. So, in the first configuration step (the window above) you should enter “ur” in the “Full Name” field, and the email address you have been assigned for this lab in the “Email Address” field. Leave the password blank and press “Continue”.When the Mail application opens, it should first display a window informing you that it wants to guide you through the process of setting up your mail account. Click “Continue.” The next box you get looks like this: Choose account type “POP” (which stands for “post office protocol”) in the “Account Type” field. Enter “cauchy.richmond.edu” (this is case sensitive) as the incoming mail server, and your assigned user name as the username. Leave the password field blank. Press Continue. Because you have not entered a pass- word, you will receive an error message (shown below). Ignore this by pressing Continue.
Next, Mail will display a window asking questions about incoming mail security (shown below). Make sure that “Use Secure Sockets Layer” is UNCHECKED and press Continue. You now need to configure the outgoing mail server. Enter “cauchy.richmond.edu” as the outgoing mail server, and be sure the “Use only this server” is checked.
The last thing you need to do to get Mail set up is to change the port number that Mail uses. To do this, click on the Mail -> Preferences menu item (be sure that Mail has the focus when you do this). Click on “Accounts” and then the “Advanced” tab to get a window like the one shown below. Enter the number 25 in the port field, then click on the red dot in the upper left hand corner of the window and save the changes you made (Mail prompts you with a window). Mail is now set to use the special lab accounts.
Our next step is to start running the TCPCapture program. This is not a standard application pro- gram. In fact, it makes some people nervous to have it around at all since it has the potential to snoop on network traffic. To start TCPCapture, go to the Applications folder in the Finder window, and scroll down until you see TCPCapture. Click- ing on it will open the application. Immediately after you launch TCPCapture an odd looking window containing some messages that talk about your last login will appear. Ignore this (In fact, once the actual program is running you might want to close this window by clicking once in the red circle in its upper left corner). Moments later, a window like the one shown on the right should appear. This is the TCPCapture program’s window.
Near the top of the window is a menu that will initially display “HTTP.” These are the initials for “Hy- pertext Transfer Protocol,” the protocol used to talk to web servers. The program is capable of intercept- ing packets sent using five different protocols, but it is designed to only work with one protocol at a time. This menu controls which one. We want to look at the packets sent when the SMTP protocol is used to send outgoing mail. So, you should change the setting of this menu to “SMTP.” Once you have done this, click the “Start” button. The program will now display any SMTP packets sent to or from your ma- chine. The little cow icon at the top of the program’s window will start running to indicate that it is ac- tively monitoring network traffic. Click on the icon for the Mail program in the dock to bring the program’s window to the top of your desk- top. Let’s send a mail message. If you want, send one to your own account at cauchy.richmond.edu. If you are feeling friendly, send it to the cauchy.richmond.edu account for the person sitting next to you. It is easy to do. Just click on the “New” button in the Mail program’s window. Fill in the “To” field (make sure the address you use ends with “@cauchy.richmond.edu”) and add any message or subject you would like (keep it short). Then press “Send.” Once this is complete, bring the TCPCapture win- dow back to the top of your desktop (if it has be- come buried under other windows you can just click once on its icon in the dock). It should now look something like the image shown on the left. The program’s window is now filled with a series of cryptic lines of text. Each of these lines corresponds to a packet sent between the mail client program and our department’s email server. The lines that start with “cauchy.richmond.edu -> CLIENT” correspond to packets that travelled from our server to your ma- chine. Lines that start with “CLIENT -> ...” corre- spond to lines your machine sent to our server. Ob- viously, sending just a single email message in- volves sending many smaller packets through the network. The remaining text on each line of the display pre- sented by TCPCapture shows the contents of the packet that was actually sent. For example, the first packet sent from the client to the server was: EHLO lh205123.richmond.edu which might translate into english roughly as “Hello, I’m lh205123.richmond.edu”. Some of the packets sent between the client and server are too long to fit on one line of the screen. They are truncated in the summary display, but there is a way to see the entire contents of such packets. If you click once on the summary line for a packet, its complete contents will be displayed in the region at the bottom the the TCPCapture window. For example, near the end of the exchange between the client and server there should be a packet containing the text 354 Enter mail, end with “.” on a line by itself If you click on the line immediately below this packet, the program’s window should display something that looks like a standard email message. (It probably isn’t surprising that one of the packets exchanged between a client and a server when sending an email message actually contains the email itself!)
To illustrate this fact, we have constructed a simple program that isn’t a mail client but can be used to send packets to an SMTP server. The program is named NetTap.jar. Like TCPCapture, it can be found in the Utilities folder within the Application folder on each of the machines in the lab. Find NetTap and double-click on its icon to launch the program. A win- dow like the one shown on the right should appear once the program has started. Near the top of the program there is a text field labeled “Server name:” You should type the name of the server to which we want to send packets, cauchy.richmond.edu, into this field. When a packet arrives at a server machine, the machine needs some way to figure out which program should be expected to process and respond to the packet. A single ma- chine might be running several dif- ferent server programs at the same time. For example, cauchy.richmond.edu is constantly running a POP server program, an SMTP server program and an HTTP (web) server. When this machine receives a packet it needs a way to decide which of these three pro- grams is the intended destination for the packet. This is accomplished by associating a standard “port number” with each protocol. A port number is a bit like a telephone extension number. When a packet is sent it is addressed not just to a machine but to a particular port on that machine. The port number associated with the SMTP protocol is
server and displayed in the NetTap window preceded by the symbols “-> “. If you typed the packet cor- rectly, a series of “250” response packets should be received from the server. Continue to mimic the dialogue you recorded using TCPCapture in this way until you have sent the “DATA” command. Make sure that you receive a 250 response to each line you enter (except the DATA command) before moving on to the next line. After receiving the DATA command, the server expects you to send the body of the email message you want delivered. The Apple Mail program (and most other real email clients) include many things in addi- tion to the text of the message including a subject line and the date the message was sent. You don’t need to mimic all this. Just enter the message you want to send line-by-line and enter a line containing a single period when you are done. That’s it. You have just sent an email message without the help of an email program! Later on in the lab, we will check to make sure it was actually delivered by using the Apple Mail program to check all the mail that has been sent to your CS mail account. For now, either press the “Disconnect” button or send the server a “QUIT” command to terminate your conversation. If you left TCPCapture running while you were using NetTap (you probably were since we never told you to stop it), you might want to take a look at the packets it captured while you were using NetTap.
We can also use TCPCapture and NetTap to explore the function of one of the protocols used to retrieve email, the POP protocol. This time, we will approach the process in the opposite order. First, you will learn about the types of packets that can be sent to a POP server by entering them yourself using NetTap. Then, you will use TCPCapture to see how the Apple Mail program actually uses this protocol (and be- fore doing so, you will need to reset the port number to 110 using the same Mail preferences steps that you used above). Like SMTP, the POP protocol requires that the client start each packet it sends to the server with a four letter command name. The commands you will need to use in this lab and their functions are discussed below. As with SMTP, if you wish to learn more, you might either read the Wikipedia discussion of POP: http://en.wikipedia.org/wiki/Post_Office_Protocol or read the official description: http://www.ietf.org/rfc/rfc1939.txt In this case, the official description is actually short enough that you may find it readable. The first two commands you will need are used to identify the account whose mail is to be accessed: USER - The first packet sent to the server should be composed of the code “USER” followed by a user name (such as cs150_01). PASS - The second packet sent to the server should be composed of the word “PASS” followed by the account password. (This is why we warned you that your password might appear on your com- puter’s screen during this lab.) When your are all done you will enter a very simple command: QUIT - This command requires no additional information.
We would like you to use TCPCapture to explore two questions about how the Apple Mail program uses the POP protocol. As your “report” for this lab, we ask that you turn in before class on Wednesday, a brief, typed paper including your answers to the following questions:
In all of our remaining labs, you will be writing and running Java programs of your own. As a first step, today we would like you to become familiar with the process of entering and running a Java program us- ing the program discussed in Chapter 1 of the reading “Programming with Java, Swing and Squint.” Just in case you didn’t bring the course reading packet with you today, the text of the program is reproduced below: import squint.; import javax.swing.; public class TouchyButton extends GUIManager { private final int WINDOW_WIDTH = 150; private final int WINDOW_HEIGHT = 300; public TouchyButton() { this.createWindow( WINDOW_WIDTH, WINDOW_HEIGHT ); contentPane.add( new JButton( "Click Here" ) ); } public void buttonClicked() { contentPane.add( new JLabel( "I'm Touched" ) ); } } Using BlueJ to Enter and Run a Program Begin by launching the BlueJ application (just click on its icon in the dock – it’s the one with the Blue Jay on it). Once BlueJ is running: