943,779 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 731
  • C++ RSS
Nov 15th, 2008
0

cyclic codes help

Expand Post »
Hi,

I need help with implementing cyclic codes.Its much like crc.I've found a lot of software implementations for crc but havent understood them.I've looked at a crc guide which gave,
C++ Syntax (Toggle Plain Text)
  1. So to implement CRC division, we have to feed the message through a
  2. division register. At this point, we have to be absolutely precise
  3. about the message data. In all the following examples the message will
  4. be considered to be a stream of bytes (each of 8 bits) with bit 7 of
  5. each byte being considered to be the most significant bit (MSB). The
  6. bit stream formed from these bytes will be the bit stream with the MSB
  7. (bit 7) of the first byte first, going down to bit 0 of the first
  8. byte, and then the MSB of the second byte and so on.
  9.  
  10. With this in mind, we can sketch an implementation of the CRC
  11. division. For the purposes of example, consider a poly with W=4 and
  12. the poly=10111. Then, the perform the division, we need to use a 4-bit
  13. register:
  14.  
  15. 3 2 1 0 Bits
  16. +---+---+---+---+
  17. Pop! <-- | | | | | <----- Augmented message
  18. +---+---+---+---+
  19.  
  20. 1 0 1 1 1 = The Poly
  21.  
  22. (Reminder: The augmented message is the message followed by W zero bits.)
  23.  
  24. To perform the division perform the following:
  25.  
  26. Load the register with zero bits.
  27. Augment the message by appending W zero bits to the end of it.
  28. While (more message bits)
  29. Begin
  30. Shift the register left by one bit, reading the next bit of the
  31. augmented message into register bit position 0.
  32. If (a 1 bit popped out of the register during step 3)
  33. Register = Register XOR Poly.
  34. End
  35. The register now contains the remainder.

I havent understood how this works.

I've also looked at this algorithm...
C++ Syntax (Toggle Plain Text)
  1. unsigned int wombat(unsigned char *data, int len)
  2. {
  3. unsigned int result;
  4. int i,j;
  5. unsigned char octet;
  6.  
  7. result = -1;
  8.  
  9. for (i=0; i<len; i++)
  10. {
  11. octet = *(data++);
  12. for (j=0; j<8; j++)
  13. {
  14. if ((octet >> 7) ^ (result >> 31))
  15. {
  16. result = (result << 1) ^ QUOTIENT;
  17. }
  18. else
  19. {
  20. result = (result << 1);
  21. }
  22. octet <<= 1;
  23. }
  24. }
  25.  
  26. return ~result; /* The complement of the remainder */
  27. }

if someone could give me a basic idea of how this works I'd really appreciate it
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
AutoC is offline Offline
74 posts
since Sep 2008
Reputation Points: 1159
Solved Threads: 285
Posting Virtuoso
vijayan121 is offline Offline
1,606 posts
since Dec 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Dev C++ error
Next Thread in C++ Forum Timeline: Using variable as filename





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC