Laboratory 1
Objectives
- Get to know your TA.
- Become familiar with laboratory processes and procedures.
- Start doing some socket-layer programming in C.
Preparation
Browse the class web site and find the materials related to the laboratories.
In particular, look at the Unix Network Programming
Manual.
Capturing Output
For this lab and others, you'll need to be able to capture input to and output
from your programs. One way to capture program output is to just redirect
stdout to a file, but this doesn't capture the input that you might enter.
A handier way of capturing part of a terminal session is to use the
script command. At the Unix command prompt, if you enter
it will capture all terminal I/O into the specified file name. (If you omit
the file name, it will write to a file called typescript.) Make
sure that you don't use the name of a file you want to keep - as you
are probably already aware, Unix will happily overwrite pretty much any file
that you can write to with no warnings.
Once you have the script running, everything you enter or that is printed to
your terminal will also go to this file. When you want to end logging to the
file, just enter <CTRL>-D (the end-of-file or EOF command) at the command
prompt.
In Lab Activities
This is an opportunity for you to get to know your TA, get familiar with the
lab setup, and start getting some hands-on experience with network programming.
In particular, if you aren't used to working on the Linux machines in EPS 254,
this will be a chance to get acquanted with the environment. To get started,
you will just be getting a client and server program running and modifying
them a little.
The code for the lab is available in /students/bwall/CS440/lab1.tgz. You should
be familiar with extracting files from a .tgz file from the first
assignment. Extract the contents of this file and take a look at each of the
files. Get familiar with what is there, then do
make lab1srvr
make lab1clnt
This should create a simple client and server program that can talk to each
other using TCP/IP. Once you have the programs built, open up two terminal
windows. Try typing the following commands
in one window and figure out what the available options are. Then just
start up the server with no arguments. In the other window, you should start
up the client so that it connects to that server. Type in a couple of lines of
text and see what happens. When you are done, just enter a <CTRL>-D (EOF),
and the client will terminate. This should cause the server to stop too.
Now you are ready to try to connect to another person's server. People need to
pair up to complete the rest of the lab. First, determine some information
about your own server - in one of your terminal windows, use the ifconfig
command to get your computer's fully qualified domain name (FQDN) and IP
address. Record these - you'll need them for your lab write-up. Now use
script to capture your session, then start up your server and figure
out what IP port number it is using. Let your lab partner know what your
server's IP address and port number are, then in the other window, start up a
second script, then run your client and connect to your lab partner's server.
Enter a couple of lines of text and EOF. Close the client script. When both
of you has done this, close the server script too. Save these two script files
for your lab write-up.
Modifying the Client and Server
Now you need to modify the client program so that instead of providing the IP
address of the server, you can provide the host name. An example of this was
given in the programs in section 1.4 of the text, and you can also find the
required information in the Unix Network Programming
Manual. Once you have the client modified and rebuilt, start your server
in one window and try starting the client in the other window, using the name
localhost. Once that works, start the server again and try connecting
using the name of your computer.
Once you have that running, you should also modify the server program so that
it prints the host name of the client after it establishes a connection, rather
than printing the IP address. You can find out how to do this in the manual
mentioned above.
Once you and your lab partner have gotten everything running, repeat the process
of starting a script and starting your server, then starting another script in
another window and connecting your client with your lab partner's server.
Lab Write-Up
Your lab write-up should include the following information:
- Name and lab section
- The name and IP address of the computer you were using
- The name and IP address of your lab partner's computer
- The scripts of the client and server runs where you connected to your
lab partner's server using the IP address
- A copy of the source for the server and client programs that you
modified to use the host name rather than the IP address
- The scripts of the client and server runs where you connected to your
lab partner's server using the host name
As I said, the write-up doesn't need to be too formal, but you are submitting
this for a grade, so make a reasonable attempt to organize it in a readable
format.
The lab write-up is due by the end of the day Wednesday for the Tuesday lab
section and by the end of the day Friday for the Thursday lab section.