Montana Tech of The University of Montana
Computer Science & Software Engineering

CSCI 466
Networks
Fall 2011


Program #1
Due: start of class, Tuesday 9/13.

You will be developing a set of C++ classes that implement socket communication. You will gain experience with the Berkley sockets API. You will be using your classes to benchmark network bandwidth and latency between different network hosts.



Start by downloading socket.zip. The zip contains a Visual Studio 2010 solution as well as a Unix style makefile. You need to implement the socket functionality in the Socket, SocketClient, and SocketServer classes. The Socket class contains the code common to both socket clients and servers. The subclasses SocketClient and SocketServer contain only the initial socket setup code which is different between clients and servers. When a SocketServer accepts a new client, it creates a Socket object that can be used to converse with the client.

I have provided a completed client/server command-line test program TestSocket. The program sports a variety of command line options:
TestSocket
 -backlog   <server: maximum backlog>
 -port      <client/server: port number>
 -host      <client: hostname>
 -msgsize   <client: message size in bytes>
 -maxsend   <client: max bytes to send at one time>
 -cycles    <client: send/recv cycles>
 -printmsg  [dump the buffer for debugging]
TestSocket runs as a server unless the -host option is specified. The message size and maximum bytes per send() are determined by the client's options. The client communicates these settings to the server during an initial setup communication. After setup is complete, the client and server take turns sending messages back and forth to each other. After all cycles are completed, the client program terminates while the server program waits for a new client.

You will need to instrument the program for the performance experiments using the provided HiResTimer class. Your program should be cross-platform, compiling and running on both Windows and Linux (also Mac OS, but you only need to test Windows and Linux).

Using your program, conduct the following experiments:
  1. Bandwidth estimate. Estimate the transmission bandwidth by measuring how long it takes to send data on a connection between a variety of hosts. Explain how you made your measurements. At a minimum, measure the bandwidth from a machine to itself (localhost), katie to our London server, from one lab machine to another, and (if possible) from your home connection to London. Feel free to test other combinations you think are interesting such as those involving wireless networks.
  2. Latency estimate. Estimate the RTT delay between various pairs of hosts. Explain how you made your measurements. Assuming a speed of propagation of 2.0 x 10^8 m/s, estimate the distance between the hosts. Compare this with the actual physical distance between the hosts. What are some factors that might influence the accuracy of using the RTT to estimate the physical distance? For the links you tested, compute the delay x bandwidth product. Use the RTT as the delay (i.e. the number of bits you could have in flight before hearing anything from the other side).
  3. Maximum send size. Varying the maximum size of buffer sent using send(). Is there a performance benefit to using larger sends?
  4. Server backlog. Vary the server's maximum backlog setting. What happens to clients that attempt to connect when the server is talking to another client? How many clients can queue up?
Submission. Email me a zip of your project directory. Turn in a hard copy of your experimental findings.


Page last updated: August 16, 2012.  Copyright © 2011 by Keith Vertanen.