Discussion:
Trying to Specify the CRC-16-CCITT FCS
Kenneth Finnegan
2014-06-26 20:34:59 UTC
Permalink
Gentlemen,

I've been working on trying to specify the frame check sum we use for
Bell 202/HDLC for my thesis. Do we really not have some kind of spec
document like for AX.25 or APRS for layer 1? I've been able to find a
few disjoint articles on the topic, and have been working out of ITU
V.23 and V.42, but the checksum calculation has really got me stumped.

Does anyone have a known-good code snippet that generates the correct
CRC given a complete frame? Attached is what I have working off of a
few examples online but they all seem to generate different results,
particularly for empty sets... The endianess is a total mess, so which
byte gets sent first?

Attached: Loading Image...
--
Kenneth Finnegan
http://blog.thelifeofkenneth.com/
Charles Bland
2014-06-26 23:51:39 UTC
Permalink
Kenneth,

Have you seen this?

https://www.tapr.org/pub_ax25.html

2.2.7 Frame-Check SequenceThe frame-check sequence (FCS) is a sixteen-bit
number calculated by both the sender and receiver of a frame. It is used to
insure that the frame was not corrupted by the medium used to get the frame
from the sender to the receiver. It shall be calculated in accordance with
ISO 3309 (HDLC) Recommendations



On Thu, Jun 26, 2014 at 1:34 PM, Kenneth Finnegan <
Post by Kenneth Finnegan
Gentlemen,
I've been working on trying to specify the frame check sum we use for
Bell 202/HDLC for my thesis. Do we really not have some kind of spec
document like for AX.25 or APRS for layer 1? I've been able to find a
few disjoint articles on the topic, and have been working out of ITU
V.23 and V.42, but the checksum calculation has really got me stumped.
Does anyone have a known-good code snippet that generates the correct
CRC given a complete frame? Attached is what I have working off of a
few examples online but they all seem to generate different results,
particularly for empty sets... The endianess is a total mess, so which
byte gets sent first?
Attached: http://i.imgur.com/vfojzUB.png
--
Kenneth Finnegan
http://blog.thelifeofkenneth.com/
_______________________________________________
aprssig mailing list
http://www.tapr.org/mailman/listinfo/aprssig
Charles Bland
2014-06-26 23:56:42 UTC
Permalink
Kenneth,

This looks more helpful....

http://cs.nju.edu.cn/yangxc/dcc_teach/fcs-calc.pdf

Chuck
Post by Charles Bland
Kenneth,
Have you seen this?
https://www.tapr.org/pub_ax25.html
2.2.7 Frame-Check SequenceThe frame-check sequence (FCS) is a sixteen-bit
number calculated by both the sender and receiver of a frame. It is used to
insure that the frame was not corrupted by the medium used to get the frame
from the sender to the receiver. It shall be calculated in accordance with
ISO 3309 (HDLC) Recommendations
On Thu, Jun 26, 2014 at 1:34 PM, Kenneth Finnegan <
Post by Kenneth Finnegan
Gentlemen,
I've been working on trying to specify the frame check sum we use for
Bell 202/HDLC for my thesis. Do we really not have some kind of spec
document like for AX.25 or APRS for layer 1? I've been able to find a
few disjoint articles on the topic, and have been working out of ITU
V.23 and V.42, but the checksum calculation has really got me stumped.
Does anyone have a known-good code snippet that generates the correct
CRC given a complete frame? Attached is what I have working off of a
few examples online but they all seem to generate different results,
particularly for empty sets... The endianess is a total mess, so which
byte gets sent first?
Attached: http://i.imgur.com/vfojzUB.png
--
Kenneth Finnegan
http://blog.thelifeofkenneth.com/
_______________________________________________
aprssig mailing list
http://www.tapr.org/mailman/listinfo/aprssig
John Hansen
2014-06-26 23:56:43 UTC
Permalink
Kenneth:

The source code for TNC-X (including the CRC) calculation is available on
my documentation page:

http://www.tnc-x.com/documentation.htm

The code is pretty thoroughly commented. Note the starting value and the
xor manipulation that occurs at the end.

John W2FS



On Thu, Jun 26, 2014 at 4:34 PM, Kenneth Finnegan <
Post by Kenneth Finnegan
Gentlemen,
I've been working on trying to specify the frame check sum we use for
Bell 202/HDLC for my thesis. Do we really not have some kind of spec
document like for AX.25 or APRS for layer 1? I've been able to find a
few disjoint articles on the topic, and have been working out of ITU
V.23 and V.42, but the checksum calculation has really got me stumped.
Does anyone have a known-good code snippet that generates the correct
CRC given a complete frame? Attached is what I have working off of a
few examples online but they all seem to generate different results,
particularly for empty sets... The endianess is a total mess, so which
byte gets sent first?
Attached: http://i.imgur.com/vfojzUB.png
--
Kenneth Finnegan
http://blog.thelifeofkenneth.com/
_______________________________________________
aprssig mailing list
http://www.tapr.org/mailman/listinfo/aprssig
Kenneth Finnegan
2014-06-27 00:39:37 UTC
Permalink
John,

Thanks. It looks like I'm doing one extra byte swap, which might
explain why most of our documentation says we send low byte first. Was
someone clever at some point and canceled out the final byte swap when
calculating the CRC via this inverted method and then converting to
network order? That would explain why we contradict V.42 and pretty
much every other network protocol ever!

Chuck,

I've got plenty of examples of long hand calculations of the CRC, but
want a concise presentation of what an implementor would need for my
thesis. I've managed to find plenty of conflicting examples that end
up with different byte orders, bit inversions, etc.

I'll remove line 16 and call mine good. Should probably collect some
unit tests and actually code it up, but it's a lot of work for a
single figure in my thesis... I'm not convinced either of our
algorithms properly handle empty frames, but then empty layer 1 frames
with a FCS would be kind of silly...


--
Kenneth Finnegan
http://blog.thelifeofkenneth.com/
The source code for TNC-X (including the CRC) calculation is available on my
http://www.tnc-x.com/documentation.htm
The code is pretty thoroughly commented. Note the starting value and the
xor manipulation that occurs at the end.
John W2FS
On Thu, Jun 26, 2014 at 4:34 PM, Kenneth Finnegan
Post by Kenneth Finnegan
Gentlemen,
I've been working on trying to specify the frame check sum we use for
Bell 202/HDLC for my thesis. Do we really not have some kind of spec
document like for AX.25 or APRS for layer 1? I've been able to find a
few disjoint articles on the topic, and have been working out of ITU
V.23 and V.42, but the checksum calculation has really got me stumped.
Does anyone have a known-good code snippet that generates the correct
CRC given a complete frame? Attached is what I have working off of a
few examples online but they all seem to generate different results,
particularly for empty sets... The endianess is a total mess, so which
byte gets sent first?
Attached: http://i.imgur.com/vfojzUB.png
--
Kenneth Finnegan
http://blog.thelifeofkenneth.com/
_______________________________________________
aprssig mailing list
http://www.tapr.org/mailman/listinfo/aprssig
_______________________________________________
aprssig mailing list
http://www.tapr.org/mailman/listinfo/aprssig
John Langner WB2OSZ
2014-06-27 00:51:51 UTC
Permalink
Does anyone have a known-good code snippet that generates the correct CRC
given a complete frame?

Look at the file fcs_calc.c in the Dire Wolf source code here:
http://home.comcast.net/~wb2osz/site/?/page/Download/
Loading...