4514 Project 1

Stuff and Unstuff

Due date: Friday, January 29th, by Midnight

Index


Description

This assignment is intended to introduce you to Data Link layer. You are to implement the programs described below on any CCC DEC machines.

You are to write two programs that simulate services provided by a simple Data Link layer. The two programs are:

You will use a parity bit for single bit error detection. You must use EVEN parity.

The simulated interfaces between the physical layer and network layer are stdin and stdout, as appropriate. For example, stuff reads from stdin (network layer) and writes to stdout (physical layer).

Both stuff and unstuff should stop reading and exit when they encounter EOF from stdin.

Important! You must follow these details:

This is to ensure that your program can be graded properly as we will compare the output of your stuff and unstuff to output as specified above.


Hints

You can use Unix pipes and filters to make debugging your pair of programs easier. For example:

   cat data1 | stuff | unstuff > data2
should result in data2 being identical to data1.

There are numerous ways to obtain bit information. However, here is a sample that does a bit-mask looking at each bit in a long integer that you are free to use and modify:


/* print out the bit information of the long integer passed in */
void printBits(int c) {
   int i;			/* loop index */
   int mask;			/* for checking for each individual bit */

   /* set the mask to have a 1 in the furthest bit left, rest 0 */
   mask = 1 << 15; /* 10000000 */

   /* each char is 1 byte = 8 bits */
   for (i=1; i<=16; i++) {

      /* is the bit a 1 or a 0? */
      if (c & mask)
	 printf("1");
      else
	 printf("0");

      /* shift the mask to the next bit down */
      mask >>= 1;

      /* but a space between bytes */
      if (i%8==0)
	printf(" ");
   }

   return;
}

A few recommendations on completing this lab if you find yourself struggling (in order):

  1. Convert a single char on stdin to bits.
  2. Convert multiple chars on stdin to bits.
  3. Stuff bits.
  4. Add frame ending.
  5. Repeat for unstuff.
  6. Polish, clean-up, debug thoroughly ...
  7. Work on making it faster.
  8. Turn it in.
  9. Relax!

Remember, do each step thoroughly. Make sure the step you are on works well and you understand it before going to the next step.


Test Cases

There will be a series of longer test cases released shortly before the project is due (so as not to give you a chance to optimize your project for the test cases. :-) ). However, some minimal test cases you should get working are:

hello
world
Results from Stuff
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLNOPQRSTUVWXYZ1234567890!@#$%^&*()
The
quick
brown
fox
jumped
over
the
lazy
dogs.
We the people of the United States, in order to form a more perfect union...
She saw sea shells at the seashore.
Results from Stuff


Examples

claypool@saagar=>> cat a
a
claypool@saagar=>> cat a | stuff
011000010111101claypool@saagar=>> 
claypool@saagar=>> cat abc
abc
claypool@saagar=>> cat abc | stuff
0110000101100010011000110111100claypool@saagar=>> 
claypool@saagar=>> cat abc | stuff | unstuff
abc
claypool@saagar=>> cat test2
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLNOPQRSTUVWXYZ1234567890!@#$%^&*()
The
quick
brown
fox
jumped
over
the
lazy
dogs.
We the people of the United States, in order to form a more perfect union...
She saw sea shells at the seashore.
claypool@saagar=>> cat test2 | stuff
0110000101100010011000110110010001100101011001100110011100110100001101001011010100110101101101100011011010110111000110111010111000000111000010111000100111000110111001000111001010111001100111001110011101000011101001011101010010000010100001001000011010001000100010101000110010001110010010000100100101001010010010110100110001001110001001110101010000010100010101001001010011010101000101010101010110010101110010110000101100101011010001100010011001000110011001101000011010100110110001101110001110000001110001001100000010000101000000001000110010010000100101010111010001001100010101000101000001010010111100010101000110100001100101011110001110000101110010101101001011000110110101101111000110001001110001001101110101110011100110111000111100011001100110111010111010000111100011010100111001010110110101110000001100101011001000111100011011101011100110011001010111000100111101011100100011010000110010101111010110110001100001011101010011101001011110101100100011011101011001110011100011001011100011110101010111001100101001000000111001000110100001100101001000000111000000110010101101110101110000001101100011001010010000001101110101100110001000000111001000110100001100101001000000101010101101110001101001011100100011001010110010000100000010100110111001000110000101110010001100101011100011001011000010000001101001011011100001000000110111010111000100110010001100101011100010001000000111001000110111010010000001100110011011101011100010011011010010000001100001001000000110110101101110101110001001100101001000000111000000110010101110001001100110011001010110001101110010000100000011100101011011100011010010110111010110111000010111000010111000010111000111101010100110110100001100101001000000111000110110000101110011100010000001110001101100101011000010010000001110001101101000011001010110110001101100011100011001000000110000101110010000100000011100100011010000110010100100000011100011011001010110000101110001101101000011011101011100010011001010010111000111100claypool@saagar=>>
claypool@saagar=>> cat test2 | stuff | unstuff > temp
claypool@saagar=>> cat test2 | stuff | unstuff > temp
claypool@saagar=>> diff temp test2
claypool@saagar=>>

Bonus

A bonus of 10 points will be rewarded to the group that has the fastest overall stuff and unstuff times. The test cases used for this performance test will be announced later.


Hand In

The main information I'd like you to have from the documentation standard is; author, date, project id, language, OS dependencies, description and building information. All this information should appear in a README file that accompanies your program.

Here is a sample of the information you should have:

Author:                         Mark Claypool
Date:                           1/21/99
Project ID:                     Project 1
CS Class:                       CS4514
Programming Language:           C
OS/Hardware dependencies:       None

Problem Description:            This program implements blah, blah, blah

How to build the program:       make

You will turn in your assignment using the "turn-in" program. Check here for information on how to turn in your assignments.


Return to 4514 Home Page

Send all questions to the TA mailing list.