Tom Kelliher, CS 325
Mar. 7, 2011
In this lab, you'll be experimenting with the TCP and UDP client/server code we just finished discussing in class. You'll use Wireshark to observe the packet/datagram traffic between client and server. I'll also ask you to make some modifications to the client and server code to prepare you for later projects.
Open an NX connection to merlin and login. All the source code you'll need is on the course web site. You can copy/paste the code from a web browser into your editor. You'll need to modify the server code to select a unique port number, preferably (and ). You have two options for the location of your server:
127.0.0.1
-- which can get confusing in a big hurry.
If you choose this option, you'll need to change the hostname in the client
source code to localhost
and set the port number to
whatever port number you chose for the server. When you use Wireshark,
you'll need to start it on the loopback interface (lo
) rather than
the physical interface (eth0
).
Use two copies of the terminal, one for running the server and the other for running the client. Similarly, depending upon your work flow, you may find it easiest to use two copies of an editor for client/source code modification.
If you choose this option, you'll need to change the hostname in the client
source code to phoenix.goucher.edu
and set the port number to
whatever port number you chose for the server. When you use Wireshark,
you'll need to start it on the physical interface (eth0
), as you've
done previously. Remember, set your capture filter to
not tcp portrange 6000-6016
.
From merlin, you'll need to ssh from a terminal window to phoenix. Depending upon your work flow, you may need two ssh sessions to phoenix. Locally on merlin, you'll be editing and running the client code.
You compile and run your code from a terminal shell. Compiling a Java application looks like this:
javac TCPClient.javaRunning a Java application looks like this:
java TCPClient
Hand in answers to each of the questions asked below.
Ctrl-c
to it to terminate it.
Run the client, typing a line of text to it once it's running for it to pass along to the server.
tcp.port == <port>
, where <port>
is the port number you're
using, to restrict the display to your specific TCP session. Answer
these questions:
largeFile
, bytes) with a single
newline character as the final character of the file. The file should
contain no other newline characters. Feed the file to the client
program like this:
java TCPClient < largeFile
Ctrl-c
to it to terminate it.
Run the client, typing a line of text to it once it's running for it to pass along to the server.
udp.port == <port>
, where <port>
is the port number you're
using, to restrict the display to your specific UDP datagrams. Answer
these questions:
largeFile
from the TCP client/server experiment with your
UDP client/server:
java UDPClient < largeFile
Ctrl-d
) at the beginning of a
line.
You can test your modifications by feeding a Java source file to the client:
java TCPClient < TCPClient.java