Homework 2
Due Monday, May 8

Note: Problem I has been postponed, and will be included in Homework 3. For Homework 2, turn in only Problems II and III.

Problem I:

Here you will so some calculations on the relation regarding Fourier series,, very similar to what is discussed in our printed lecture notes.

You will be asked to do some graphing. All that I require is that your graphs be .gif files, linked to from your Amaya .html file, using the Amaya Insert Image icon. I recommend that you use either gnuplot or jgraph to generate Encapsulated Postscript files, and then convert them to .gif using xv.

We will continue to assume the conditions in the example in the notes: We wish to send the bits 101010..., transmitting at the rate of 2 million bits per second. However, suppose we do this using 4B/5B coding.

A. State what actual repeating bit pattern (1s and 0s) will be put on the line. Assume that before the repeating pattern is placed on the line, the previous line state had been low (-1). Also, assume that we send 101010... as 010101..., which will make things more convenient. (Check: The period T should consist of 10 bits.)

B. Continuing to assume that a line 1 is at level +1 and a line 0 is at level -1, graph the truncated Fourier series up through the n-th harmonic, for n = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12.

Use my program AnBn.C to find the coefficients an and bn, instead of evaluating the integrals yourself. However, you are required to set up the integrals for the case n = 1. These must be set up so that any calculus student could evaluate them, even if he/she has never heard of networks, x(t), etc.; the string "x(t)" must NOT appear in the integrands of your integrals. (Note: You are welcome to modify the output format of AnBn.C program, in order to make it generate gnuplot commands, which you can then use the mouse to copy into gnuplot, thus saving yourself some work.)

Make sure to superimpose the true x(t) on your graphs for comparison purposes. (I've recently added something at the end of my gnuplot Web page on how to do "cases" type functions, e.g. "z(t) is equal to 9 for t < 12.0 and equal to 7.2 for t > 12.0.".)

C. Suppose the bandwidth of our transmission medium is 0.4 MHz, and suppose each bit is sampled in the middle of its bit time, and count any positive line value as a 1 and any negative line value as a 0. Which bits, if any, will be received incorrectly? What if the bandwidth of the medium is 0.6 MHz?

Problem II:

Consider the example of serial asynchronous transmission in our printed lecture notes.. Let X denote the actual bit time for a clock, corresponding to a nominal bit time of 100 microseconds. X will be a constant time for any particular clock, but will vary from clock to clock, and thus is a random variable in our context here. Suppose X has a N(100,c2) distribution, i.e. is normally distributed with mean 100 and standard deviation c.

Let X1 and X2 denote actual bit times of two clocks chosen at random, the first one to drive the transmitter and the second to drive the receiver. Recall from our notes that if X1 and X2 are far enough apart, then at some time during the transmission of a character the receiver will be looking at the wrong bit. For example, we found that if X1 - X2 = 7, then this "looking at the wrong bit" problem will occur, though it won't occur if the difference is 5. Find the probability of this kind of problem occurring, for various interesting values of c.

Problem III:

In this problem you will write a pair of programs whose goal is to perform experiments which illustrate the following two points (only the first is required; the second is for Extra Credit):

Name your program executables sender and counter. The command-line usage will be:

sender chunk_size number_of_chunks reuse
counter hostname

(You may reverse the roles of the two programs if you wish.)

For sender reuse = 1 means that the socket is to be immediately reusable, and 0 means not.

The main part of sender will consist of a loop whose main action is to call write() to send chunk_size bytes to counter. The loop will execute number_of_chunks iterations. The sender will then terminate. (Note that since the purpose of the program is to serve as an experiment to investigate TCP traffic patterns, it does not matter which bytes you send. Thus you might as well send 0s.)

The main part of counter will consist of a loop whose main action is to call read() and report how many bytes are received in that call. There will be an indefinite number of iterations, looping until read() returns a nonpositive value. Also, this program will report at the end as to how many total bytes it received, which should match the number sent, chunk_size * number_of_chunks.

You must run the server and client on different architectures, say running counter on sgi8 while running sender on hp12.

(If you find difficulties on one pair of platforms, then try another.)

The files you submit for this problem will consist of (a) your source files and Makefile and (b) the output files from running script to record what happens when you run the programs. Again, remember that these files must illustrate the fact that the sizes of the chunks received by read() need not match those send by write(), and also must illustrate the fact that a socket can't be immediately reused unless SO_REUSEADDR is set. (Show both that it can't be reused if that option is not set, and that it can be reused if it is set.)