EmbeddedRelated.com
Forums

crc32 calculation

Started by salimbaba April 1, 2010
hey! i am using spartan 3E board to transmit UDP packets to my pc. I have
implemented most of it, i have interfaced the PHY but there seems to be one
problem, the data leaves the FPGA bt the packet is dropped at the pc's end,
how i know it is that i can see the light blink bt nothing gets through to
ethereal. 
I am assuming that my crc32 is not correct as i have double checked my
other headers, the way i am sending them i.e.  lower nibble first followed
by higher nibble of each byte starting from Preamble -> SFD and so on. IP
checksum is also correct as i have implemented it in the same manner as was
said on different forums i.e. add all 16bit ip headers and then take their
one's complement. This final value is our checksum.

i need to know that how should i send data to crc32 generator? i took the
code from [outputlogic.com]. I am sending one byte at a time to the
generator and i am calculating crc32 on the fly. I read it on some forums
that you have to invert or reverse or do what to the bits and then invert
or complement the final result again before transmitting . And also can you
tell me how to transmit the final crc32 value i.e. lowest nibble first or
what. 

Thanks!	   
					
---------------------------------------		
Posted through http://www.EmbeddedRelated.com
On Apr 1, 10:07=A0am, "salimbaba" <ark_lightz@n_o_s_p_a_m.yahoo.com>
wrote:
> hey! i am using spartan 3E board to transmit UDP packets to my pc. I have > implemented most of it, i have interfaced the PHY but there seems to be o=
ne
> problem, the data leaves the FPGA bt the packet is dropped at the pc's en=
d,
> how i know it is that i can see the light blink bt nothing gets through t=
o
> ethereal.
Ethereal should be able to show you that you have a packet even if it has an invalid CRC. First, put ethereal in promiscuous mode. Second, make sure that you use a simple ethernet card -- one with no onboard calculation of CRCs. Ethereal will tell you if the PC is doing CRC calculations or if the card is doing them by indicating that it sees them as valid. They won't be valid if they are not completed at the time Ethereal gets them, that is by the PC's stack. If other traffic has a valid CRC and Ethereal tells you that the ones from your board don't, you'll have confirmed that the problem is indeed CRC related. If not, ethereal should indicate another problem. Steve
>First, put ethereal in promiscuous mode. Second, make sure that you >use a simple ethernet card -- one with no onboard calculation of >CRCs. > >Ethereal will tell you if the PC is doing CRC calculations or if the >card is doing them by indicating that it sees them as valid. They >won't be valid if they are not completed at the time Ethereal gets >them, that is by the PC's stack. If other traffic has a valid CRC and >Ethereal tells you that the ones from your board don't, you'll have >confirmed that the problem is indeed CRC related. If not, ethereal >should indicate another problem. > > Steve >
My ethernet card has an on board crc calculator. And one more thing, i am broadcasting the packets just to make sure they are received at the other end. And i read it somewhere that ethereal drops the packets with invalid crc. And if a packet is received , dont you think that the network light of incoming traffic should blink? ,it isnt blinking either. --------------------------------------- Posted through http://www.EmbeddedRelated.com
> My ethernet card has an on board crc calculator.
That will stop packets with bad CRCs from getting through then. You are likely correct that it is a CRC problem, but if you want to be sure, you'll have to get another card or test against another PC.
> And i read it somewhere that ethereal drops the packets with invalid crc.
I don't have a specific reference to indicate the contrary, but intuitively that doesn't seem correct. Why would ethereal indicate for each packet that the CRC was valid if it only captured packets with valid CRCs? At least the newer Wireshark does that, and ISTR that ethereal does too.
> And if a packet is received , dont you think that the network light of > incoming traffic should blink? ,it isnt blinking either. =A0
I'm not following that. In your original post you indicated, "i can see the light blink bt nothing gets through to ethereal." But to answer your question, it would depend on who causes the LED to blink -- the card's interrupt routine or packet processor. Steve
>That will stop packets with bad CRCs from getting through then. You >are likely correct that it is a CRC problem, but if you want to be >sure, you'll have to get another card or test against another PC. >
hmmm, well i'll see if i can get my hands on another card for testing purposes.
>I don't have a specific reference to indicate the contrary, but >intuitively that doesn't seem correct. Why would ethereal indicate >for each packet that the CRC was valid if it only captured packets >with valid CRCs? At least the newer Wireshark does that, and ISTR >that ethereal does too.
you do have a point there. I didnt think of it that way actually :p
>I'm not following that. In your original post you indicated, "i can >see the light blink bt nothing gets through to ethereal." But to >answer your question, it would depend on who causes the LED to blink >-- the card's interrupt routine or packet processor.
And yeah it sounds confusing as i read it now. To make it clear, let me elaborate it a little bit. When i transmit a packet from FPGA, the light at the back of cpu i.e. network card's LED blinks indicating that it has received some data. But the blinking is not displayed in system tray, network connectivity's icon. i think it's clear now :) Do you have any idea how should i feed the bytes to the CRC32 generator ? --------------------------------------- Posted through http://www.EmbeddedRelated.com
On 2010-04-01, steve_schefter@hotmail.com <steve_schefter@hotmail.com> wrote:

> I'm not following that. In your original post you indicated, "i can > see the light blink bt nothing gets through to ethereal." But to > answer your question, it would depend on who causes the LED to blink > -- the card's interrupt routine or packet processor.
In my experience, the LED blink is caused by circuitry in the PHY. -- Grant Edwards grant.b.edwards Yow! Are we THERE yet? at gmail.com
On Apr 1, 2:05=A0pm, "salimbaba" <ark_lightz@n_o_s_p_a_m.yahoo.com>
wrote:
> Do you have any idea how should i feed the bytes to the CRC32 generator ?=
=A0 =A0 =A0 =A0 I realize that that was your original question and my hoping to show how to confirm that it really was a CRC issue didn't address that. I'm afraid that it has been quite a long time since I have done any CRC in code. At the time, I took a sample short packet from a trace similar to ethereal, then ran the numbers through my algorithm to see if I can up with the same CRC as the trace showed. Steve
Am Thu, 01 Apr 2010 08:53:58 -0700 schrieb steve_schefter:

>> My ethernet card has an on board crc calculator. > > That will stop packets with bad CRCs from getting through then. You are > likely correct that it is a CRC problem, but if you want to be sure, > you'll have to get another card or test against another PC.
If your problem is your ethernet card dropping the packets, why don't you give your localhost interface a go? /Christof
On 2010-04-06, Christof Klaiber <christof.klaiber@merath-maschinen.de> wrote:
> Am Thu, 01 Apr 2010 08:53:58 -0700 schrieb steve_schefter: > >>> My ethernet card has an on board crc calculator. >> >> That will stop packets with bad CRCs from getting through then. You are >> likely correct that it is a CRC problem, but if you want to be sure, >> you'll have to get another card or test against another PC. > > If your problem is your ethernet card dropping the packets, why don't you > give your localhost interface a go?
How do you send packets from an external, single-board computer to a PC's localhost interface? -- Grant Edwards grant.b.edwards Yow! Civilization is fun! at Anyway, it keeps me busy!! gmail.com