Homework 3 - Chapter 3

Due: Monday April 23, 2007 at 5pm

Part 1: Questions

Each question is worth 2 points.

  1. If a packet from the network layer is broken into 10 frames and each frame has a 15% chance of being corrupted in transit, how many frames on average will be transmitted before the whole packet is received without error? Answer this question for the following types of data link protocols:
    1. A data link protocol that does no frame retransmission or error detection. So if a frame is corrupted in transit, the data link layer will not detect it. The responsibility for error detection and recovery is on the higher layers (ie the network or transport layer will retransmit the whole packet).
    2. A data link protocol with error detection that will retransmit a frame that is corrupted in transit.
  2. The message 0110 0111 1110 0000 0111 1110 1111 1001 is to be transmitted. Show the bit sequence for the message if it is encoded using the following framing methods:
    1. Flag bytes with byte stuffing. FLAG = 0111 1110, ESC = 1110 0000
    2. Starting and ending flag bits with bit stuffing, FLAG = 0111 1110
  3. A 32 bit message is transmitted using a Hamming code. How many check bits are needed to properly detect and correct 1-bit errors in this 32 bit message (e.g. what is the value of r)?
  4. The character 'A' is represented in 8-bit ASCII as the bit string 01000001. You are transmitting 'A' with an even-parity Hamming code. What is the bit string that is transmitted?
  5. You wish to transmit the frame containing 10010110010 with a CRC attached. Your generator polynomial is x3 + 1. What bit string would be transmitted? Show all work using a style similar to Figure 3.8 on page 198.
  6. Suppose that while your answer to Question 4 is in transit, the bit at position 12 (numbered as one would number the bits in the Hamming code table, not as with binary exponents) flipped. Show how the receiver would detect and correct this error.
  7. Why do most data link protocols put the CRC in the footer, not the header?
  8. A 1500km long T1 line has a propagation delay of two-thirds the speed of light in a vacuum. A sliding window with go back N data link protocol using 64 byte frames transmits on the line. How many bits are needed for the sequence number?
  9. HDLC uses bit stuffing. PPP uses byte stuffing. Give one reason why PPP uses byte stuffing instead of bit stuffing.
  10. PPP is used to transmit a 1500 byte IP packet. What percentage of the PPP frame is overhead? Assume there is no LCP negociation (i.e. the protocol field is 2 bytes and the checksum field is 2 bytes).

Part 2: Using the Book's Data Link Simulator

This section is worth 10 points.

I've been told the publisher's website is down. Here's a local copy of cn3-simulator.zip.

Download the book's simulator package from http://authors.phptr.com/tanenbaumcn4/simulator/cn3-simulator.zip. You can do this via the wget command in your Helios shell window. Save to its own directory as when unzipped it just places files in the current directory. Unzip with the unzip command.

The printf commands in the files distributed by the book get interleaved so one cannot distinguish them without the following modification (or another modification to the processes such as a semaphore to allow only one to print at a time). Edit worker.c and change the function print_statistics to the following:

void print_statistics(void)
{
/* Display statistics. */

  int word[3];

  sleep(1);
  printf("Process %d:\tTotal data frames sent:  %9d\n", id, data_sent);
  printf("Process %d:\tData frames lost:        %9d\n", id, data_lost);
  printf("Process %d:\tData frames not lost:    %9d\n", id, data_not_lost);
  printf("Process %d:\tFrames retransmitted:    %9d\n", id, data_retransmitted);
  printf("Process %d:\tGood ack frames rec'd:   %9d\n", id, good_acks_recd);
  printf("Process %d:\tBad ack frames rec'd:    %9d\n\n", id, cksum_acks_recd);

  printf("Process %d:\tGood data frames rec'd:  %9d\n", id, good_data_recd);
  printf("Process %d:\tBad data frames rec'd:   %9d\n", id, cksum_data_recd);
  printf("Process %d:\tPayloads accepted:       %9d\n", id, payloads_accepted);
  printf("Process %d:\tTotal ack frames sent:   %9d\n", id, acks_sent);
  printf("Process %d:\tAck frames lost:         %9d\n", id, acks_lost);
  printf("Process %d:\tAck frames not lost:     %9d\n", id, acks_not_lost);

  printf("Process %d:\tTimeouts:                %9d\n", id, timeouts);
  printf("Process %d:\tAck timeouts:            %9d\n", id, ack_timeouts);
  fflush(stdin);

  word[0] = 0;
  word[1] = payloads_accepted;
  word[2] = data_sent;
  write(mwfd, word, 3*sizeof(int));     /* tell main we are done printing */
  sleep(1);
  exit(0);
}
Turn in the answers to the following as the write-up for this section:
  1. Do a "make all" and run the following tests. For each test, explain the resulting output. You must explain why you got the output. Do not just cut and paste the output.
    1. Protocol 2 - Stop and Wait - sim 2 100 10 0 0 3
    2. Protocol 3 - PAR - sim 3 100 10 10 10 7
    3. Protocol 5 - Sliding Window with Go Back N - sim 5 100 10 10 10 7
    4. Protocol 6 - Sliding Window with Selective Repeat - sim 6 100 10 10 10 7
  2. Modify the code according to the following questions in the book. Turn in the segment of code you altered, but you do not need to turn in all of the code. Just cut and paste what you changed or give the results of the diff command. Also, explain the difference the modification made in the output of the corresponding command from Question 1 (ie if you modified protocol 5, give the changes to 1(c)).
    1. 3.21
    2. 3.22
    3. 3.23
    4. 3.24