-PROJECT ITERATION #5-



-HOME-

-DAILY LOGS-

-WEEKLY GOALS-

-TABLE OF INTERESTS-

-LINKS-

-TOOLS-

-PROJECT PROPOSAL-

-ABOUT AUTHOR-
Sami Siddiqui
Computer Systems Lab- Per 6
January 29, 2003

PROJECT ITERATION/PROGRESS REPORT

PLAN:
The plan for this iteration is to complete the second part of the chapter 3 assignment pertaining to bit stuffing and unstuffing. As you might recall, on the last iteration I said that my code for bit stuffing wasn't working, but I was able to fix that code because of some minor errors. The problem had been that there was an internal "for" loop that filled in the matrix with what was supposed to be there. This loop took over everytime I ran my code so I could never see how my code was functioning. I finally found this built-in loop and deleted it so that my code could execute. My code worked properly so I finished the bit stuffing aspect. The second aspect of this assignment is bit unstuffing, which should be easy given I have done the first part. However, one problem with unstuffing is that the length is unknown and thus the only way to stop the function is to search for the stop code. This is the hardest part probably because the stop code is eight bits long so I have to build in a statement that will account for this. (this complicated statement is seen in my code below)

DESIGN:
To accomplish the task of unstuffing bits, I have to copy bits from the stuffed frame into the unstuffed frame. The problem is knowing when to stop, which is accomplished by an extremely confusing while statement that has eight parameters that must be satisfied. Because my code is not functioning properly, it is probably in this line where my code messes up. Within the loop, the code must check for a series of ones and if it finds five ones in a row and then a zero, and then another one, the computer must recognize that this is a stuffed bit and it should unstuff it. The problem that occurs here is that the counters must be updated when this occurs and if the counter is off by even one, there will be data loss.

CODE:
 void stack::unstuff(bit_frame* unstuffed_frame,bit_frame* stuffed_frame)
{
  int bitpos;
  int stuffct=0;
  int unstuffct=0;
  int ct=0;
  for(int x=1; x<=8; x++)
  {
	  unstuffed_frame->frame_bits[x]=stuffed_frame->frame_bits[x];
  }
  stuffct=9;
  unstuffct=9;
  while(!(stuffed_frame->frame_bits[stuffct]==0 && 
	  stuffed_frame->frame_bits[stuffct+1]==1 &&
      stuffed_frame->frame_bits[stuffct+2]==1 &&
      stuffed_frame->frame_bits[stuffct+3]==1 &&
      stuffed_frame->frame_bits[stuffct+4]==1 &&
      stuffed_frame->frame_bits[stuffct+5]==1 &&
      stuffed_frame->frame_bits[stuffct+6]==1 &&
      stuffed_frame->frame_bits[stuffct+7]==0))
	{
		if(ct==5 && stuffed_frame->frame_bits[stuffct+1]==1)
		{
			stuffct++;
			ct=0;
		}
		
		if(stuffed_frame->frame_bits[stuffct]==1)
		{
			ct++;
		}
		else
		{
			ct=0;
		}
		unstuffed_frame->frame_bits[unstuffct]=stuffed_frame->frame_bits[stuffct];
		stuffct++;
		unstuffct++;
	}
	
	for(int y=0; y<8; y++)
	{
		unstuffed_frame->frame_bits[unstuffct]=stuffed_frame->frame_bits[stuffct];
		unstuffct++;
		stuffct++;
	}
	showbits(unstuffed_frame->frame_bits, 500);
	}
  


TESTING:
So far, this is my preliminary code to finishing the unstuffing, but during testing, I have found that is doesn't function properly. Maybe my algorithm is incorrect so I need to try more efficient ways. Thus, this code needs to be tested more.

USERS:
There are no users for this iteration.