<p>pespin has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/libosmocore/+/17750">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">tests/coding: Test decoding of DL EGPRS data packet<br><br>Change-Id: Ide23a484b980995f24092d1cfbf062aed58fdf61<br>---<br>M tests/coding/coding_test.c<br>M tests/coding/coding_test.ok<br>2 files changed, 106 insertions(+), 28 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/50/17750/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/tests/coding/coding_test.c b/tests/coding/coding_test.c</span><br><span>index 17ddfaa..5ae464f 100644</span><br><span>--- a/tests/coding/coding_test.c</span><br><span>+++ b/tests/coding/coding_test.c</span><br><span>@@ -316,7 +316,76 @@</span><br><span>       printf("\n");</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-static void test_pdtch(uint8_t *l2, int len)</span><br><span style="color: hsl(120, 100%, 40%);">+struct test_macblock {</span><br><span style="color: hsl(120, 100%, 40%);">+  bool is_egprs;</span><br><span style="color: hsl(120, 100%, 40%);">+        uint16_t exp_burst_bits;</span><br><span style="color: hsl(120, 100%, 40%);">+      uint16_t l2_len;</span><br><span style="color: hsl(120, 100%, 40%);">+      uint8_t l2[54];</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+struct test_macblock test_macblock[] = {</span><br><span style="color: hsl(120, 100%, 40%);">+       /* Random frame */</span><br><span style="color: hsl(120, 100%, 40%);">+    {       false,</span><br><span style="color: hsl(120, 100%, 40%);">+                GSM0503_GPRS_BURSTS_NBITS,</span><br><span style="color: hsl(120, 100%, 40%);">+            54,</span><br><span style="color: hsl(120, 100%, 40%);">+           { 0xa3, 0xaf, 0x5f, 0xc6, 0x36, 0x43, 0x44, 0xab,</span><br><span style="color: hsl(120, 100%, 40%);">+               0xd9, 0x6d, 0x7d, 0x62, 0x24, 0xc9, 0xd2, 0x92,</span><br><span style="color: hsl(120, 100%, 40%);">+               0xfa, 0x27, 0x5d, 0x71, 0x7a, 0x59, 0xa8, 0x42,</span><br><span style="color: hsl(120, 100%, 40%);">+               0xa3, 0xaf, 0x5f, 0xc6, 0x36, 0x43, 0x44, 0xab,</span><br><span style="color: hsl(120, 100%, 40%);">+               0xa3, 0xaf, 0x5f, 0xc6, 0x36, 0x43, 0x44, 0xab,</span><br><span style="color: hsl(120, 100%, 40%);">+               0xd9, 0x6d, 0x7d, 0x62, 0x24, 0xc9, 0xd2, 0x92,</span><br><span style="color: hsl(120, 100%, 40%);">+               0xfa, 0x27, 0x5d, 0x71, 0x7a, 0xa8 }</span><br><span style="color: hsl(120, 100%, 40%);">+        },</span><br><span style="color: hsl(120, 100%, 40%);">+    /* jolly frame */</span><br><span style="color: hsl(120, 100%, 40%);">+     {       false,</span><br><span style="color: hsl(120, 100%, 40%);">+                GSM0503_GPRS_BURSTS_NBITS,</span><br><span style="color: hsl(120, 100%, 40%);">+            23,</span><br><span style="color: hsl(120, 100%, 40%);">+           { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,</span><br><span style="color: hsl(120, 100%, 40%);">+               0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,</span><br><span style="color: hsl(120, 100%, 40%);">+               0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 }</span><br><span style="color: hsl(120, 100%, 40%);">+  },</span><br><span style="color: hsl(120, 100%, 40%);">+/*</span><br><span style="color: hsl(120, 100%, 40%);">+GSM RLC/MAC: EGPRS DL HEADER</span><br><span style="color: hsl(120, 100%, 40%);">+    0... .... .... 0000 = DL TFI: 0</span><br><span style="color: hsl(120, 100%, 40%);">+    0... .... crumb 1 of DL TFI (decoded above)</span><br><span style="color: hsl(120, 100%, 40%);">+    .00. .... = RRBP: Reserved Block: (N+13) mod 2715648 (0)</span><br><span style="color: hsl(120, 100%, 40%);">+    ...0 0... = ES/P: RRBP field is not valid (no Polling) (0)</span><br><span style="color: hsl(120, 100%, 40%);">+    .... .111 = USF: 7</span><br><span style="color: hsl(120, 100%, 40%);">+    01.. .... 0000 0000 .... ...0 = BSN: 1</span><br><span style="color: hsl(120, 100%, 40%);">+    01.. .... crumb 2 of BSN (decoded above)</span><br><span style="color: hsl(120, 100%, 40%);">+    ..00 .... = PR: 0 dB (included) to 3 dB (excluded) less than BCCH level - P0 (0)</span><br><span style="color: hsl(120, 100%, 40%);">+    .... 0000 crumb 0 of DL TFI (decoded above)</span><br><span style="color: hsl(120, 100%, 40%);">+    0000 0000 crumb 1 of BSN (decoded above)</span><br><span style="color: hsl(120, 100%, 40%);">+    .00. .... = SPB (DL): No retransmission (0)</span><br><span style="color: hsl(120, 100%, 40%);">+    ...1 011. = CPS: MCS-1/P1 (0x0b)</span><br><span style="color: hsl(120, 100%, 40%);">+    .... ...0 crumb 0 of BSN (decoded above)</span><br><span style="color: hsl(120, 100%, 40%);">+GSM RLC/MAC: EGPRS DL DATA BLOCK 1 (BSN 1)</span><br><span style="color: hsl(120, 100%, 40%);">+    .... ..0. = FBI: Current Block is not last RLC data block in TBF</span><br><span style="color: hsl(120, 100%, 40%);">+    .... ...0 = Extension: Extension octet follows immediately</span><br><span style="color: hsl(120, 100%, 40%);">+    0000 100. = Length Indicator: 4</span><br><span style="color: hsl(120, 100%, 40%);">+    .... ...0 = Extension: Extension octet follows immediately</span><br><span style="color: hsl(120, 100%, 40%);">+    0010 000. = Length Indicator: 16</span><br><span style="color: hsl(120, 100%, 40%);">+    .... ...1 = Extension: No extension octet follows</span><br><span style="color: hsl(120, 100%, 40%);">+    data segment: LI[0]=4 indicates: (Last segment of) LLC frame (4 octets)</span><br><span style="color: hsl(120, 100%, 40%);">+        Data (4 bytes)</span><br><span style="color: hsl(120, 100%, 40%);">+            Data: 012b2b2b</span><br><span style="color: hsl(120, 100%, 40%);">+            [Length: 4]</span><br><span style="color: hsl(120, 100%, 40%);">+    data segment: LI[1]=16 indicates: (Last segment of) LLC frame (16 octets)</span><br><span style="color: hsl(120, 100%, 40%);">+        Data (16 bytes)</span><br><span style="color: hsl(120, 100%, 40%);">+            Data: 43c0012b2b2b2b2b2b2b2b2b2b2b2b2b</span><br><span style="color: hsl(120, 100%, 40%);">+            [Length: 16]</span><br><span style="color: hsl(120, 100%, 40%);">+*/</span><br><span style="color: hsl(120, 100%, 40%);">+  {       true,</span><br><span style="color: hsl(120, 100%, 40%);">+         GSM0503_GPRS_BURSTS_NBITS,</span><br><span style="color: hsl(120, 100%, 40%);">+            27,</span><br><span style="color: hsl(120, 100%, 40%);">+           { 0x07, 0x40, 0x00, 0x16, 0x10, 0x42, 0x02, 0x56,</span><br><span style="color: hsl(120, 100%, 40%);">+               0x56, 0x56, 0x86, 0x80, 0x03, 0x56, 0x56, 0x56,</span><br><span style="color: hsl(120, 100%, 40%);">+               0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56,</span><br><span style="color: hsl(120, 100%, 40%);">+               0x56, 0x56, 0x00 }</span><br><span style="color: hsl(120, 100%, 40%);">+  },</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static void test_pdtch(struct test_macblock *tmb, int len)</span><br><span> {</span><br><span>    uint8_t result[len];</span><br><span>         ubit_t bursts_u[116 * 4];</span><br><span>@@ -328,19 +397,22 @@</span><br><span>    switch (len) {</span><br><span>       case 34:</span><br><span>     case 54:</span><br><span style="color: hsl(0, 100%, 40%);">-                l2[len - 1] &= 0x7f;</span><br><span style="color: hsl(120, 100%, 40%);">+              tmb->l2[len - 1] &= 0x7f;</span><br><span>             result[len - 1] &= 0x7f;</span><br><span>                 break;</span><br><span>       case 40:</span><br><span style="color: hsl(0, 100%, 40%);">-                l2[len - 1] &= 0x07;</span><br><span style="color: hsl(120, 100%, 40%);">+              tmb->l2[len - 1] &= 0x07;</span><br><span>             result[len - 1] &= 0x07;</span><br><span>                 break;</span><br><span>       }</span><br><span> </span><br><span>        /* Encode L2 message */</span><br><span style="color: hsl(0, 100%, 40%);">- printf("Encoding: %s\n", osmo_hexdump(l2, len));</span><br><span style="color: hsl(0, 100%, 40%);">-      rc = gsm0503_pdtch_encode(bursts_u, l2, len);</span><br><span style="color: hsl(0, 100%, 40%);">-   CHECK_RC_OR_RET(rc == GSM0503_GPRS_BURSTS_NBITS, "encoding");</span><br><span style="color: hsl(120, 100%, 40%);">+       printf("Encoding: %s\n", osmo_hexdump(tmb->l2, len));</span><br><span style="color: hsl(120, 100%, 40%);">+    if (tmb->is_egprs)</span><br><span style="color: hsl(120, 100%, 40%);">+         rc = gsm0503_pdtch_egprs_encode(bursts_u, tmb->l2, len);</span><br><span style="color: hsl(120, 100%, 40%);">+   else</span><br><span style="color: hsl(120, 100%, 40%);">+          rc = gsm0503_pdtch_encode(bursts_u, tmb->l2, len);</span><br><span style="color: hsl(120, 100%, 40%);">+ CHECK_RC_OR_RET(rc == (int)tmb->exp_burst_bits, "encoding");</span><br><span> </span><br><span>        /* Prepare soft-bits */</span><br><span>      osmo_ubit2sbit(bursts_s, bursts_u, 116 * 4);</span><br><span>@@ -349,15 +421,21 @@</span><br><span>         dump_sbits((uint8_t *)bursts_s, 348);</span><br><span> </span><br><span>    /* Decode */</span><br><span style="color: hsl(0, 100%, 40%);">-    rc = gsm0503_pdtch_decode(result, bursts_s, NULL,</span><br><span style="color: hsl(0, 100%, 40%);">-               &n_errors, &n_bits_total);</span><br><span style="color: hsl(120, 100%, 40%);">+    if (tmb->is_egprs) {</span><br><span style="color: hsl(120, 100%, 40%);">+               /* gsm0503_pdtch_egprs_decode() is meant to decode EGPRS UL frames, so we cannot use it here */</span><br><span style="color: hsl(120, 100%, 40%);">+               rc = gsm0503_pdtch_egprs_decode(result, bursts_s, rc, NULL, &n_errors, &n_bits_total);</span><br><span style="color: hsl(120, 100%, 40%);">+                OSMO_ASSERT(rc == -EIO);</span><br><span style="color: hsl(120, 100%, 40%);">+              return;</span><br><span style="color: hsl(120, 100%, 40%);">+       } else {</span><br><span style="color: hsl(120, 100%, 40%);">+              rc = gsm0503_pdtch_decode(result, bursts_s, NULL, &n_errors, &n_bits_total);</span><br><span style="color: hsl(120, 100%, 40%);">+  }</span><br><span>    CHECK_RC_OR_RET(rc == len, "decoding");</span><br><span> </span><br><span>        printf("Decoded: %s\n", osmo_hexdump(result, len));</span><br><span>        printf("pdtch_decode: n_errors=%d n_bits_total=%d ber=%.2f\n",</span><br><span>             n_errors, n_bits_total, (float)n_errors/n_bits_total);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-      OSMO_ASSERT(!memcmp(l2, result, len));</span><br><span style="color: hsl(120, 100%, 40%);">+        OSMO_ASSERT(!memcmp(tmb->l2, result, len));</span><br><span> </span><br><span>   printf("\n");</span><br><span> }</span><br><span>@@ -377,21 +455,6 @@</span><br><span>  0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 },</span><br><span> };</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-uint8_t test_macblock[][54] = {</span><br><span style="color: hsl(0, 100%, 40%);">-    /* Random frame */</span><br><span style="color: hsl(0, 100%, 40%);">-      { 0xa3, 0xaf, 0x5f, 0xc6, 0x36, 0x43, 0x44, 0xab,</span><br><span style="color: hsl(0, 100%, 40%);">-       0xd9, 0x6d, 0x7d, 0x62, 0x24, 0xc9, 0xd2, 0x92,</span><br><span style="color: hsl(0, 100%, 40%);">- 0xfa, 0x27, 0x5d, 0x71, 0x7a, 0x59, 0xa8, 0x42,</span><br><span style="color: hsl(0, 100%, 40%);">- 0xa3, 0xaf, 0x5f, 0xc6, 0x36, 0x43, 0x44, 0xab,</span><br><span style="color: hsl(0, 100%, 40%);">- 0xa3, 0xaf, 0x5f, 0xc6, 0x36, 0x43, 0x44, 0xab,</span><br><span style="color: hsl(0, 100%, 40%);">- 0xd9, 0x6d, 0x7d, 0x62, 0x24, 0xc9, 0xd2, 0x92,</span><br><span style="color: hsl(0, 100%, 40%);">- 0xfa, 0x27, 0x5d, 0x71, 0x7a, 0xa8 },</span><br><span style="color: hsl(0, 100%, 40%);">-   /* jolly frame */</span><br><span style="color: hsl(0, 100%, 40%);">-       { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,</span><br><span style="color: hsl(0, 100%, 40%);">-       0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,</span><br><span style="color: hsl(0, 100%, 40%);">- 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 },</span><br><span style="color: hsl(0, 100%, 40%);">-};</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> /* 11-bit Access Burst soft-bits (payload only) from an EGPRS capable phone (BSIC 63) */</span><br><span> static const sbit_t test_rach_11bit[6][36] = {</span><br><span>  {  103,  109, -108, -110,  107,  108, -106, -120, -121,</span><br><span>@@ -480,10 +543,14 @@</span><br><span>              test_hr(test_l2[i], sizeof(test_l2[0]));</span><br><span> </span><br><span>         for (i = 0; i < len_mb; i++) {</span><br><span style="color: hsl(0, 100%, 40%);">-               test_pdtch(test_macblock[i], 23);</span><br><span style="color: hsl(0, 100%, 40%);">-               test_pdtch(test_macblock[i], 34);</span><br><span style="color: hsl(0, 100%, 40%);">-               test_pdtch(test_macblock[i], 40);</span><br><span style="color: hsl(0, 100%, 40%);">-               test_pdtch(test_macblock[i], 54);</span><br><span style="color: hsl(120, 100%, 40%);">+             if (test_macblock[i].is_egprs) {</span><br><span style="color: hsl(120, 100%, 40%);">+                      test_pdtch(&test_macblock[i], test_macblock[i].l2_len);</span><br><span style="color: hsl(120, 100%, 40%);">+           } else {</span><br><span style="color: hsl(120, 100%, 40%);">+                      test_pdtch(&test_macblock[i], 23);</span><br><span style="color: hsl(120, 100%, 40%);">+                        test_pdtch(&test_macblock[i], 34);</span><br><span style="color: hsl(120, 100%, 40%);">+                        test_pdtch(&test_macblock[i], 40);</span><br><span style="color: hsl(120, 100%, 40%);">+                        test_pdtch(&test_macblock[i], 54);</span><br><span style="color: hsl(120, 100%, 40%);">+                }</span><br><span>    }</span><br><span> </span><br><span>        printf("Success\n");</span><br><span>diff --git a/tests/coding/coding_test.ok b/tests/coding/coding_test.ok</span><br><span>index 3a4fbf2..91083e4 100644</span><br><span>--- a/tests/coding/coding_test.ok</span><br><span>+++ b/tests/coding/coding_test.ok</span><br><span>@@ -356,4 +356,15 @@</span><br><span> Decoded: 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 </span><br><span> pdtch_decode: n_errors=0 n_bits_total=444 ber=0.00</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+Encoding: 07 40 00 16 10 42 02 56 56 56 86 80 03 56 56 56 56 56 56 56 56 56 56 56 56 56 00 </span><br><span style="color: hsl(120, 100%, 40%);">+U-Bits:</span><br><span style="color: hsl(120, 100%, 40%);">+100111000001011111111010101010011100010011111010000110110 00  00  000110110000010000000011000000000110011001100110010000000</span><br><span style="color: hsl(120, 100%, 40%);">+100010010000000000001101001111110010100100001000100111010 00  01  001001010101100010111000000000010111100011100011010001001</span><br><span style="color: hsl(120, 100%, 40%);">+111100001101001011010000110111100001001001000001000100110 00  01  000000110110110100011111011110011001101100000111100010001</span><br><span style="color: hsl(120, 100%, 40%);">+001000110011010110011011001011100100010001101101011100000 01  00  000010000010010110001111111001011101011000000011101100010</span><br><span style="color: hsl(120, 100%, 40%);">+S-Bits:</span><br><span style="color: hsl(120, 100%, 40%);">+81 7f 7f 81 81 81 7f 7f 7f 7f 7f 81 7f 81 81 81 81 81 81 81 81 7f 81 7f 81 7f 81 7f 81 7f 7f 81 81 81 7f 7f 7f 81 7f 7f 81 81 81 81 81 7f 81 7f 7f 7f 7f 81 81 7f 81 81 7f  7f  7f  7f 7f 7f 81 81 7f 81 81 7f 7f 7f 7f 7f 81 7f 7f 7f 7f 7f 7f 7f 7f 81 81 7f 7f 7f 7f 7f 7f 7f 7f 7f 81 81 7f 7f 81 81 7f 7f 81 81 7f 7f 81 81 7f 7f 81 7f 7f 7f 7f 7f 7f 7f </span><br><span style="color: hsl(120, 100%, 40%);">+81 7f 7f 7f 81 7f 7f 81 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 81 81 7f 81 7f 7f 81 81 81 81 81 81 7f 7f 81 7f 81 7f 7f 81 7f 7f 7f 7f 81 7f 7f 7f 81 7f 7f 81 81 81 7f 81 7f  7f  81  7f 7f 81 7f 7f 81 7f 81 7f 81 7f 81 81 7f 7f 7f 81 7f 81 81 81 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 81 7f 81 81 81 81 7f 7f 7f 81 81 81 7f 7f 7f 81 81 7f 81 7f 7f 7f 81 7f 7f 81 </span><br><span style="color: hsl(120, 100%, 40%);">+81 81 81 81 7f 7f 7f 7f 81 81 7f 81 7f 7f 81 7f 81 81 7f 81 7f 7f 7f 7f 81 81 7f 81 81 81 81 7f 7f 7f 7f 81 7f 7f 81 7f 7f 81 7f 7f 7f 7f 7f 81 7f 7f 7f 81 7f 7f 81 81 7f  7f  81  7f 7f 7f 7f 7f 7f 81 81 7f 81 81 7f 81 81 7f 81 7f 7f 7f 81 81 81 81 81 7f 81 81 81 81 7f 7f 81 81 7f 7f 81 81 7f 81 81 7f 7f 7f 7f 7f 81 81 81 81 7f 7f 7f 81 7f 7f 7f 81 </span><br><span style="color: hsl(120, 100%, 40%);">+7f 7f 81 7f 7f 7f 81 81 7f 7f 81 81 7f 81 7f 81 81 7f 7f 81 81 7f 81 81 7f 7f 81 7f 81 81 81 7f 7f 81 7f 7f 7f 81 7f 7f 7f 81 81 7f 81 81 7f 81 7f 81 81 81 7f 7f 7f 7f 7f  81  7f  7f 7f 7f 7f 81 7f 7f 7f 7f 7f 81 7f 7f 81 7f 81 81 7f 7f 7f 81 81 81 81 81 81 81 7f 7f 81 7f 81 81 81 7f 81 7f 81 81 7f 7f 7f 7f 7f 7f 7f 81 81 81 7f 81 81 7f 7f 7f 81 7f </span><br><span> Success</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/libosmocore/+/17750">change 17750</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/libosmocore/+/17750"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: libosmocore </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Ide23a484b980995f24092d1cfbf062aed58fdf61 </div>
<div style="display:none"> Gerrit-Change-Number: 17750 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>