PPP checksum/FCS befuddlement

Hi. Does anyone know by what magic the Mikrotik implementation of PPP generates the FCS at the end of the PPP packet ?

I thought it was either CRC-16 or CRC-CCITT, but i get this coming out of the serial port :-

FF 03 C0 21 01 15 00 13 03 05 C2 23 81 05 06 35 6E 4A 35 07 02 08 02 22 32

The FCS is the ‘22 32’ at the end.

As i understand it, the FCS is calulated on the whole packet from the FF to the end, along with 00 00 inserted at the end as placeholder for the checksum.

So, on FF 03 C0 21 01 15 00 13 03 05 C2 23 81 05 06 35 6E 4A 35 07 02 08 02 00 00

CRC-CCITT (reverse 1021 polynom, initial FCS=ffff) gives 8C AA
reverse the bit order (in case LSB/MSB error) gives 55 4F

CRC-16 (8005 polynom, inital FCS=0000) gives CD D4
reversing the data bit order gives BF 8E

The pppd GPL source code shows a lookup tables based on reverse polynom 1021, so i was expecting to see 8C AA as the FCS.

Anyone got an idea where i’ve got it wrong ?

found it in AN724.
this code snippet works. slower, but much smaller than a 1k table.


checksum= 0xffff;
for(i=0;i<buffer_len_minus_0000;i++)
{ checksum = calc(c^checksum) ^ (checksum/256);
}
checksum = ~checksum; // invert

unsigned int calc(unsigned int c)
{char i;
c = c & 0xFF;
for (i=0;i<8;i++)
{ if (c&1)
{ c = c / 2;
c = c ^0x8408;
}
else c = c / 2;
}
return c;
}