From: Raphaƫl on
same problem here !
I start thinking the matlab code for the crc is not the standard one..



dee <deepthif(a)yahoo.com> wrote in message <90f42468-61a6-4717-ab4e-4e1a928520b6(a)c3g2000yqd.googlegroups.com>...
> Subject:
> From: deepthi <gdd0014(a)londonmet.ac.uk>
>
> Dear Sir,
>
> I am trying to calculate the FCS Feild of a MAC Frame (IEEE
> 802.11-2007 p.70).
>
> bits='0000010000110000100000000000011100000011110001101100101011100101100110000000000001100111100010101101111011101101100110001000100010001000100010001000100010001000100010000000000100000011000010110001001100011011001000110010101100110011001110110100001101001011010100110101101101100011011010110111001101111011100000111000101110010011100110111010001110101011101100111011101111000011110010111101000110001001100100011001100110100001101010011011000000001000010001000000110000010100001011000101110010010100110001010010010110110'
>
> I am using a slightly modified code d/loaded from
> http://www.cs.washington.edu/homes/dhalperi/useful.html#LATEX
>
> --------------------------------------
>
> function ret = crc32(bits) % receives string of characters (class
> char) from main program
> poly = [1 de2bi(hex2dec('EDB88320'), 32)]' % generates the poly from
> CRC32
> bits = bits(:);
> bits=str2num(bits) % converts characters to numbers for type
> compatibility- i added this line
>
> % Flip first 32 bits
> bits(1:32) = 1 - bits(1:32);
> % Add 32 zeros at the back
> bits = [bits; zeros(32,1)];
>
> % Initialize remainder to 0
> rem = zeros(32,1);
> % Compute the CRC32
>
> for i = 1:length(bits)
> rem = [rem; bits(i)]; %#ok<AGROW>
> if rem(1) == 1
> rem = mod(rem + poly, 2);
> end
> rem = rem(2:33);
> end
>
> % Flip the remainder before returning it
> ret = 1 - rem;
> ret=num2str(ret); % converts back to chars before passing back to main
> program - i added this line
> end
>
> ----------------------------------------
> I cannot fully understand how this works. But, I feel the output is
> not correct.
>
> When I calculated the poly for edb88320 manually it gives 1110 1101
> 1011 1000 1000 0011 1110 0000 which is different to the output for
> poly in the program.
>
> I have spent 2 weeks trying to understand how crc-32 works and how
> this works, but it seems that more i look at it, more trouble I am
> getting into now.
>
> Can someone pls explain your code or check where I am wrong?
>
> Thank you very much
>
> Deepthi