title: C - CRC32 checksum does not match Wireshark on Ethernet Frame Check Sequence
body: <p>I'm using an online CRC-32 calculator to check that my output is correct however it seems that Wireshark has a different expected FCS for the ethernet packet.</p>
  
  <p>message2 is the ethernet frame minus the FCS as seen in Wireshark</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdint.h&gt;
  
  unsigned int crc32b(unsigned char *message) {
     int i, j;
     unsigned int byte, crc, mask;
  
     i = 0;
     crc = 0xFFFFFFFF;
     while (message[i] != 0) {
        //printf("%i %x \n\n", i, message[i]);
        byte = message[i];            
        crc = crc ^ byte;
        for (j = 7; j &gt;= 0; j--) {  
           mask = -(crc &amp; 1);
           crc = (crc &gt;&gt; 1) ^ (0xEDB88320 &amp; mask);
        }
        i = i + 1;
     }
     return ~crc;
  }
  
  int main(void)
  {
      unsigned char * message = "hello test";
      unsigned char * message2 = "aabbccddeeff5cb9017c5a53080000000000000000000000000000";
      unsigned int res = crc32b(message2);
      printf("%x\n", res);
      return 0;
  }
  </code></pre>
  
  <p>I've tried using different Polynomials as defined in [1 - subsection CRC-32 IEEE 802.3], however the result does not match Wireshark.</p>
  
  <p>Output using 0xED Polynomial: 0xd81e4af3</p>
  
  <p>Wireshark FCS expected: 0xa8cd3084</p>
  
  <p>I'd really like to code in the FCS for my ethhdr packet, I guess when creating a software packet, the FCS isn't entered by the NIC...</p>
  
  <p>Sources:</p>
  
  <p>[1] - <a href="http://crppit.epfl.ch/documentation/Hash_Function/WiKi/Cyclic_redundancy_check.htm" rel="nofollow noreferrer">http://crppit.epfl.ch/documentation/Hash_Function/WiKi/Cyclic_redundancy_check.htm</a></p>