title: How do I calculate the FCS field in an Ethernet Frame?
body: <p>I see a few implementations, but I decided to look at exactly how the specification calls out the FCS for encoding.</p>
  <p>So say my input is as follows:</p>
  <pre><code>dst: 0xAA AA AA AA AA AA
  src: 0x55 55 55 55 55 55
  len: 0x00 04
  msg: 0xDE AD BE EF
  </code></pre>
  <p>concatenating this in the order that seems to be specified in the format (and the order expressed in the spec later on) seems to indicate my input is:</p>
  <pre><code>M(x) = 0xAA AA AA AA AA AA 55 55 55 55 55 55 00 04 DE AD BE EF
  </code></pre>
  <p>a) &quot;The first 32 bits of the frame are complemented.&quot;</p>
  <pre><code>complemented first 32 MSB of M(x): 0x55 55 55 55 AA AA 55 55 55 55 55 55 00 04 DE AD BE EF
  </code></pre>
  <p>b) &quot;The n bits of the protected fields are then considered to be the coefficients of a polynomial M(x) of
  degree n – 1. (The first bit of the Destination Address field corresponds to the x(n–1) term and the last
  bit of the MAC Client Data field (or Pad field if present) corresponds to the x0 term.)&quot;</p>
  <p>I did this in previous. see M(x)</p>
  <p>c) &quot;M(x) is multiplied by x^32 and divided by G(x), producing a remainder R(x) of degree &lt;=31.&quot;</p>
  <p>Some options online seem to ignore the 33rd bit to represent x^32. I am going to ignore those simplified shortcuts for this exercise since it doesn't seem to specify that in the spec.
  It says to multiply M(x) by x^32. So this is just padding with 32 zeroes on the LSBs. (i.e. if <code>m(x) = 1x^3 + 1</code>, then <code>m(x) * x^2 = 1x^5 + 1x^2 + 0</code>)</p>
  <pre><code>padded: 0x55 55 55 55 AA AA 55 55 55 55 55 55 00 04 DE AD BE EF 00 00 00 00
  </code></pre>
  <p>Next step is to divide. I am dividing the whole M(x) / G(x). Can you use XOR shifting directly? I see some binary division examples have the dividened as 101 and the divisior as 110 and the remainder is 11. Other examples explain that by converting to decimal, you cannot divide. Which one is it for terms for this standard?</p>
  <p>My remainder result is for option 1 (using XOR without carry bit consideration, shifting, no padding) was:</p>
  <pre><code>0x15 30 B0 FE
  </code></pre>
  <p>d) &quot;The coefficients of R(x) are considered to be a 32-bit sequence.&quot;</p>
  <p>e) &quot;The bit sequence is complemented and the result is the CRC.&quot;</p>
  <pre><code>CRC = 0xEA CF 4F 01
  </code></pre>
  <p>so my entire Ethernet Frame should be:</p>
  <pre><code>0xAA AA AA AA AA AA 55 55 55 55 55 55 00 04 DE AD BE EF EA CF 4F 01
  </code></pre>
  <p>In which my dst address is its original value.</p>
  <p>When I check my work with an online CRC32 BZIP2 calculator, I see this result: <code>0xCACF4F01</code></p>
  <p>Is there another option or online tool to calculate the Ethernet FCS field? (not just one of many CRC32 calculators)</p>
  <p>What steps am I missing? Should I have padded the M(x)? Should I have complemented the 32 LSBs instead?</p>
  <p><strong>Update</strong></p>
  <p>There was an error in my CRC output in my software. It was a minor issue with copying a vector. My latest result for CRC is (before post-complement) <code>35 30 B0 FE</code>.</p>
  <p>The post-complement is: <code>CA CF 4F 01</code> (matching most online CRC32 BZIP2 versions).</p>
  <p>So my ethernet according to my programming is currently:</p>
  <pre><code>0xAA AA AA AA AA AA 55 55 55 55 55 55 00 04 DE AD BE EF CA CF 4F 01
  </code></pre>