Subject: [lp-wan] CRC as MIC

From: Laurent Toutain <[email-masked]>
Date: Fri, 8 Dec 2017 14:03:35 +0100

Hi,

I'm made some test to use CRC to detect fragment losses. The protocol is
the following:
- generate different packet length, packet payload (uniform, repeated,
random) and fragment length.
- compute the packet CRC
- try all the frag loss combination and compute the resulting CRC
- compare the resulting CRC and the packet CRC
- if the result is the same when one or several frag are lost then the CRC
fails to detect an
error.

Since I'm testing all the possible combinations, the test can be very long
when there is more that 20 fragments (2^20 tests).

But the results are encouraging.

The first test are with a CRC16 (0xA001), it works well with less that 16
fragments (which mean 16 frag in no Ack and a window of 16 with Ack
always/on error). After the result are not that bad, for instance for 20
frag there is 2^20 possible loss pattern and only 12 lead to a erroneous
detection but one of the pattern has only 6 frag losses. The other are
causing trouble with more than half of the frag lost.

With CRC32 the test leads to no error, only the complete frag sequence is
validated by the CRC.

My  feeling for the document is to recommend a CRC32 as 0xEDB88320 (the one
used by Ethernet).

-----
The following table contains:
- first column the number of loss sequence matching with the CRC
- second column fragment size in byte
- third column packet size in byte
- fourth column the pattern leading to a CRC matching (0 lost, 1 received)
- fifth column the number of lost fragment (ie the number of 0 in the
previous field)
- sixth column repeat the number of fragments to send the packet.

For CRC16

Max frag =  1
0   200   100   0b1  losses = 0 frag = 1
Max frag =  1
0   200   200   0b1  losses = 0 frag = 1
Max frag =  3
0   200   500   0b111  losses = 0 frag = 3
Max frag =  5
0   200   1000   0b11111  losses = 0 frag = 5
Max frag =  1
0   170   100   0b1  losses = 0 frag = 1
Max frag =  2
0   170   200   0b11  losses = 0 frag = 2
Max frag =  3
0   170   500   0b111  losses = 0 frag = 3
Max frag =  6
0   170   1000   0b111111  losses = 0 frag = 6
Max frag =  1
0   140   100   0b1  losses = 0 frag = 1
Max frag =  2
0   140   200   0b11  losses = 0 frag = 2
Max frag =  4
0   140   500   0b1111  losses = 0 frag = 4
Max frag =  8
0   140   1000   0b11111111  losses = 0 frag = 8
Max frag =  1
0   110   100   0b1  losses = 0 frag = 1
Max frag =  2
0   110   200   0b11  losses = 0 frag = 2
Max frag =  5
0   110   500   0b11111  losses = 0 frag = 5
Max frag =  10
0   110   1000   0b1111111111  losses = 0 frag = 10
Max frag =  2
0   80   100   0b11  losses = 0 frag = 2
Max frag =  3
0   80   200   0b111  losses = 0 frag = 3
Max frag =  7
0   80   500   0b1111111  losses = 0 frag = 7
Max frag =  13
0   80   1000   0b1111111111111  losses = 0 frag = 13
Max frag =  2
0   50   100   0b11  losses = 0 frag = 2
Max frag =  4
0   50   200   0b1111  losses = 0 frag = 4
Max frag =  10
0   50   500   0b1111111111  losses = 0 frag = 10
Max frag =  20
0   50   1000   0b101110110011  losses = 12 frag = 20
1   50   1000   0b110101011110011  losses = 10 frag = 20
2   50   1000   0b100100111111011011  losses = 8 frag = 20
3   50   1000   0b111110001010100010  losses = 11 frag = 20
4   50   1000   0b1000001100011001000  losses = 14 frag = 20
5   50   1000   0b1010011001111101001  losses = 9 frag = 20
6   50   1000   0b1010111001111011100  losses = 8 frag = 20
7   50   1000   0b1100100000000110100  losses = 14 frag = 20
8   50   1000   0b10101111001011111010  losses = 7 frag = 20
9   50   1000   0b10110000101110001101  losses = 10 frag = 20
10   50   1000   0b10110011001101010001  losses = 10 frag = 20
*11   50   1000   0b11011111101100011101  losses = 6 frag = 20*
12   50   1000   0b11111110110100010110  losses = 7 frag = 20
13   50   1000   0b11111111111111111111  losses = 0 frag = 20

For CRC32

Max frag =  1
0   200   100   0b1  losses = 0 frag = 1
Max frag =  1
0   200   200   0b1  losses = 0 frag = 1
Max frag =  3
0   200   500   0b111  losses = 0 frag = 3
Max frag =  5
0   200   1000   0b11111  losses = 0 frag = 5
Max frag =  1
0   170   100   0b1  losses = 0 frag = 1
Max frag =  2
0   170   200   0b11  losses = 0 frag = 2
Max frag =  3
0   170   500   0b111  losses = 0 frag = 3
Max frag =  6
0   170   1000   0b111111  losses = 0 frag = 6
Max frag =  1
0   140   100   0b1  losses = 0 frag = 1
Max frag =  2
0   140   200   0b11  losses = 0 frag = 2
Max frag =  4
0   140   500   0b1111  losses = 0 frag = 4
Max frag =  8
0   140   1000   0b11111111  losses = 0 frag = 8
Max frag =  1
0   110   100   0b1  losses = 0 frag = 1
Max frag =  2
0   110   200   0b11  losses = 0 frag = 2
Max frag =  5
0   110   500   0b11111  losses = 0 frag = 5
Max frag =  10
0   110   1000   0b1111111111  losses = 0 frag = 10
Max frag =  2
0   80   100   0b11  losses = 0 frag = 2
Max frag =  3
0   80   200   0b111  losses = 0 frag = 3
Max frag =  7
0   80   500   0b1111111  losses = 0 frag = 7
Max frag =  13
0   80   1000   0b1111111111111  losses = 0 frag = 13
Max frag =  2
0   50   100   0b11  losses = 0 frag = 2
Max frag =  4
0   50   200   0b1111  losses = 0 frag = 4
Max frag =  10
0   50   500   0b1111111111  losses = 0 frag = 10
Max frag =  20
0   50   1000   0b11111111111111111111  losses = 0 frag = 20
Max frag =  5
0   20   100   0b11111  losses = 0 frag = 5
Max frag =  10
0   20   200   0b1111111111  losses = 0 frag = 10
Max frag =  25
0   20   500   0b1111111111111111111111111  losses = 0 frag = 25

---

From: Carsten Bormann <[email-masked]>
Date: Fri, 8 Dec 2017 14:11:46 +0100

Hi Laurent,

I haven’t tested this, but would expect slightly different results for CRC-CCITT (a 16-bit CRC), which should be good for packets that aren’t quite IPv6 MTU, IIRC.
Also, the SCTP people switched to CRC-32c (≠ CRC32) in RFC 3309 (they had started out with Adler32).
(We selected some shorter CRCs for ROHC, maybe also worth a look.)

Grüße, Carsten